00001 // $Id: optsedit.cpp 1282 2006-06-09 09:46:49Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 // Implementation of the Edit tab of the options dialog box 00099 00100 /* 00101 00102 */ 00103 00104 #include "camtypes.h" 00105 #include "appprefs.h" 00106 #include "optsedit.h" 00107 //#include "app.h" // Camelot object - in camtypes.h [AUTOMATICALLY REMOVED] 00108 //#include "units.h" // units - in camtypes.h [AUTOMATICALLY REMOVED] 00109 //#include "resource.h" // _R(IDS_OK) 00110 00111 CC_IMPLEMENT_DYNAMIC(EditTab, OptionsTabs) 00112 00113 // This is not compulsory, but you may as well put it in so that the correct version 00114 // of your file can be registered in the .exe 00115 DECLARE_SOURCE("$Revision: 1282 $"); 00116 00117 00118 /******************************************************************************************** 00119 00120 > EditTab::EditTab() 00121 00122 00123 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00124 Created: 7/12/94 00125 Inputs: - 00126 Outputs: - 00127 Returns: - 00128 Purpose: EditTab constructor. Creates a non-undoable operation 00129 Errors: - 00130 SeeAlso: - 00131 00132 ********************************************************************************************/ 00133 00134 EditTab::EditTab() 00135 { 00136 // Do nothing at present 00137 } 00138 00139 /******************************************************************************************** 00140 00141 > EditTab::~EditTab() 00142 00143 00144 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00145 Created: 7/12/94 00146 Inputs: - 00147 Outputs: - 00148 Returns: - 00149 Purpose: EditTab destructor 00150 Errors: - 00151 SeeAlso: - 00152 00153 ********************************************************************************************/ 00154 00155 EditTab::~EditTab() 00156 { 00157 } 00158 00159 /******************************************************************************************** 00160 00161 > BOOL EditTab::Init() 00162 00163 00164 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00165 Created: 7/12/94 00166 Inputs: - 00167 Outputs: - 00168 Returns: True if initialised ok, False if failed. 00169 Purpose: EditTab initialisation routine 00170 Errors: - 00171 SeeAlso: - 00172 00173 ********************************************************************************************/ 00174 00175 BOOL EditTab::Init() 00176 { 00177 return TRUE; 00178 } 00179 00180 00181 /****************************************************************************************** 00182 00183 > CDlgResID EditTab::GetPageID()() 00184 00185 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00186 Created: 7/12/94 00187 Inputs: - 00188 Outputs: - 00189 Returns: The dialog ID of this tab section. 00190 Purpose: Allows the options dialog code to determine the dialog ID of this section. 00191 Errors: - 00192 SeeAlso: - 00193 00194 ******************************************************************************************/ 00195 00196 CDlgResID EditTab::GetPageID() 00197 { 00198 return _R(IDD_OPTSTAB_EDIT); 00199 } 00200 00201 /****************************************************************************************** 00202 00203 > BOOL EditTab::IsDocumentOption() 00204 00205 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00206 Created: 14/12/94 00207 Inputs: - 00208 Outputs: - 00209 Returns: Returns True if this tab is a document option. 00210 Purpose: Allows the document options dialog code to determine if this tab belongs 00211 to the group of document options. 00212 Errors: - 00213 SeeAlso: IsProgramOption(); 00214 00215 ******************************************************************************************/ 00216 00217 BOOL EditTab::IsDocumentOption() 00218 { 00219 return FALSE; // This tab is not a document option 00220 } 00221 00222 /****************************************************************************************** 00223 00224 > BOOL EditTab::IsProgramOption() 00225 00226 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00227 Created: 14/12/94 00228 Inputs: - 00229 Outputs: - 00230 Returns: Returns True if this tab is a program option. 00231 Purpose: Allows the program options dialog code to determine if this tab belongs 00232 to the group of program options. 00233 Errors: - 00234 SeeAlso: IsProgramOption(); 00235 00236 ******************************************************************************************/ 00237 00238 BOOL EditTab::IsProgramOption() 00239 { 00240 return TRUE; // This tab is a program option 00241 } 00242 00243 00244 /****************************************************************************************** 00245 00246 > BOOL EditTab::CommitSection() 00247 00248 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00249 Created: 7/12/94 00250 Inputs: - 00251 Outputs: - 00252 Returns: True if values in dialog box ok, False otherwise. 00253 Purpose: Takes the values in the Edit section tab of the options dialog box and 00254 sets the associated preference values accordingly 00255 Called when ok is pressed on the dialog box. 00256 Errors: - 00257 SeeAlso: - 00258 00259 ******************************************************************************************/ 00260 00261 BOOL EditTab::CommitSection() 00262 { 00263 TRACEUSER( "Neville", _T("commit edit section\n")); 00264 ERROR2IF(pPrefsDlg == NULL,FALSE,"EditTab::CommitSection called with no dialog pointer"); 00265 00266 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_EDIT)); // The edit page identifier 00267 if (!ok) 00268 return TRUE; // Talk to page failed to return now 00269 00270 // Section = Edit 00271 00272 // Ok has been pressed so take the values from this section of the dialog box 00273 BOOL Valid=FALSE; // Flag for validity of value 00274 BOOL State=FALSE; // Flag for state of button/switch 00275 BOOL SetOk=TRUE; // Preference value set ok 00276 00277 // Section = Attributes 00278 00279 State = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_ASKSETATTRB), 0, 1, 0, &Valid); 00280 SetOk = Camelot.SetPrefValue(TEXT("Attributes"),TEXT("AskBeforeSettingCurrentAttr"),&State); 00281 ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_EDIT)); 00282 00283 State = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_LASTATTRB), 0, 1, 0, &Valid); 00284 SetOk = Camelot.SetPrefValue(TEXT("Attributes"),TEXT("LastAttrAppliedBecomesCurrent"),&State); 00285 ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_EDIT)); 00286 00287 00288 // Set up the units that are used in the currently selected document 00289 // All units work off the selected document and so we must do nothing if there is no 00290 // selected document. 00291 ok = SetUpDocUnits(); 00292 if (!ok) 00293 return (TRUE); 00294 00295 // Section = Constraints 00296 00297 // Now the constraint angle combo box 00298 // Convert to double uses units and so requires a selected document 00299 double Angle = 0.0; // Angle stored in radians in the preference system 00300 double AngleInDegrees = 0; // Angle displayed in degrees to the user 00301 AngleInDegrees = pPrefsDlg->GetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 00302 0, 360, _R(IDE_OPTS_INVALIDANGLE), &Valid); 00303 if (Valid) 00304 { 00305 // Angle in correct range so put it into the preference system 00306 Angle = AngleInDegrees * PI/180.0; // convert angle to radians 00307 TRACEUSER( "Neville", _T("commit constraint angle in degrees='%d' angle='%d' Valid ='%d'\n"), AngleInDegrees, Angle, Valid); 00308 SetOk = Camelot.SetPrefValue(TEXT("Constraints"), TEXT("Constrain Angle"), &Angle); 00309 ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_EDIT)); 00310 } 00311 else 00312 return FALSE; // Angle incorrect, user has been warned already 00313 00314 // Now the duplicate distance 00315 INT32 x = 0; 00316 INT32 y = 0; 00317 const INT32 Maxxy = INT_MAX; // maximum value allowed as the distance 00318 BOOL bValidX = FALSE; 00319 BOOL bValidY = FALSE; 00320 00321 ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_EDIT)); // The edit page identifier 00322 x = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_XDUPLICATE), CurrentScaledUnits, 00323 -Maxxy, Maxxy, _R(IDE_OPTS_INVALIDDISTANCE), &bValidX); 00324 /* if (Valid) 00325 { 00326 SetOk = Camelot.SetPrefValue(TEXT("Duplicate"), TEXT("DuplicatePlacementX"), &x); 00327 ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_EDIT)); 00328 } 00329 else 00330 return FALSE; // Duplicate x incorrect, user has been warned already 00331 */ 00332 ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_EDIT)); // The edit page identifier 00333 y = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_YDUPLICATE), CurrentScaledUnits, 00334 -Maxxy, Maxxy, _R(IDE_OPTS_INVALIDDISTANCE), &bValidY); 00335 /* if (Valid) 00336 { 00337 SetOk = Camelot.SetPrefValue(TEXT("Duplicate"), TEXT("DuplicatePlacementY"), &y); 00338 ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_EDIT)); 00339 } 00340 else 00341 return FALSE; // Duplicate y incorrect, user has been warned already 00342 */ 00343 if (bValidX && bValidY) 00344 { 00345 pDocument->SetDuplicationOffset(DocCoord(x,y)); 00346 pDocument->SetModified(TRUE); 00347 } 00348 else 00349 return FALSE; 00350 00351 // Now the nudge size distance 00352 UINT32 Nudge = 0; 00353 ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_EDIT)); // The edit page identifier 00354 Nudge = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_NUDGESIZE), CurrentScaledUnits, 00355 0, INT_MAX, _R(IDE_OPTS_INVALIDNUDGE), &Valid); 00356 TRACEUSER( "Neville", _T("commit nudge distance='%d' Valid ='%d'\n"),Nudge, Valid); 00357 if (Valid) 00358 { 00359 /*SetOk =*/ pDocument->SetDocNudge (Nudge);//Camelot.SetPrefValue(TEXT("Nudge"), TEXT("StepSize"), &Nudge); 00360 pDocument->SetModified (TRUE); 00361 //ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_EDIT)); 00362 } 00363 else 00364 return FALSE; // Nudge size incorrect, user has been warned already 00365 00366 return TRUE; 00367 } 00368 00369 /****************************************************************************************** 00370 00371 > BOOL EditTab::NewUnitsInSection() 00372 00373 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00374 Created: 5/1/95 00375 Inputs: - 00376 Outputs: - 00377 Returns: True if values in dialog box ok, False otherwise. 00378 Purpose: Function called when new default units come into operation. We must convert 00379 all units fields to display in the newly specified units. 00380 Errors: - 00381 SeeAlso: - 00382 00383 ******************************************************************************************/ 00384 00385 BOOL EditTab::NewUnitsInSection() 00386 { 00387 TRACEUSER( "Neville", _T("New units in edit section\n")); 00388 ERROR2IF(pPrefsDlg == NULL,FALSE,"EditTab::NewUnitsInSection called with no dialog pointer"); 00389 00390 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_EDIT)); // The edit page identifier 00391 if (!ok) 00392 return TRUE; // Talk to page failed to return now 00393 00394 // Set up the common variables 00395 BOOL Valid=FALSE; // Flag for validity of value 00396 00397 // We will not error on any of the conversions as this might mean double errors 00398 // when say an apply is used but instead just ignore the conversion. This also means 00399 // not specifying an error message in the GetUnitGadgetValue calls. 00400 00401 // Set up the units that are used in the currently selected document 00402 // All units work off the selected document and so we must do nothing if there is no 00403 // selected document. 00404 ok = SetUpDocUnits(); 00405 if (!ok) 00406 return (TRUE); 00407 00408 // Now the duplicate distance 00409 INT32 x = 0; 00410 INT32 y = 0; 00411 const INT32 Maxxy = INT_MAX; // maximum value allowed as the distance 00412 00413 x = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_XDUPLICATE), CurrentScaledUnits, 00414 -Maxxy, Maxxy, 0, &Valid); 00415 if (Valid) 00416 { 00417 ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_XDUPLICATE), CurrentScaledUnits, x, FALSE, -1); 00418 } 00419 00420 y = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_YDUPLICATE), CurrentScaledUnits, 00421 -Maxxy, Maxxy, 0, &Valid); 00422 if (Valid) 00423 { 00424 ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_YDUPLICATE), CurrentScaledUnits, y, FALSE, -1); 00425 } 00426 00427 // Now the nudge size distance 00428 UINT32 Nudge = 0; 00429 Nudge = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_NUDGESIZE), CurrentScaledUnits, 00430 0, INT_MAX, 0, &Valid); 00431 if (Valid) 00432 { 00433 ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_NUDGESIZE), CurrentScaledUnits, Nudge, FALSE, -1); 00434 } 00435 00436 return TRUE; 00437 } 00438 00439 00440 /******************************************************************************************** 00441 00442 > BOOL EditTab::GreySection() 00443 00444 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00445 Created: 4/2/95 00446 Inputs: - 00447 Outputs: - 00448 Returns: - 00449 Purpose: Called when the user has closed all documents 00450 Errors: - 00451 SeeAlso: EditTab::UngreySection; 00452 00453 ********************************************************************************************/ 00454 00455 BOOL EditTab::GreySection() 00456 { 00457 TRACEUSER( "Neville", _T("GreySection in EditTab section\n")); 00458 ERROR2IF(pPrefsDlg == NULL,FALSE,"EditTab::GreySection called with no dialog pointer"); 00459 00460 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_EDIT)); // The EditTab identifier 00461 if (!ok) 00462 return TRUE; // Talk to page failed to return now 00463 00464 // Only update if we are not already grey 00465 if (GreyStatus == TRUE) 00466 return TRUE; 00467 00468 // Call our central greying/ungreying function 00469 ok = ChangeControlStatus(FALSE); 00470 00471 GreyStatus = TRUE; 00472 00473 return ok; 00474 } 00475 00476 /******************************************************************************************** 00477 00478 > BOOL EditTab::UngreySection() 00479 00480 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00481 Created: 4/2/95 00482 Inputs: - 00483 Outputs: - 00484 Returns: - 00485 Purpose: Called when the user has selected a new document 00486 Errors: - 00487 SeeAlso: EditTab::UngreySection; 00488 00489 ********************************************************************************************/ 00490 00491 BOOL EditTab::UngreySection() 00492 { 00493 TRACEUSER( "Neville", _T("UngreySection in EditTab section\n")); 00494 ERROR2IF(pPrefsDlg == NULL,FALSE,"EditTab::UngreySection called with no dialog pointer"); 00495 00496 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_EDIT)); // The EditTab identifier 00497 if (!ok) 00498 return TRUE; // Talk to page failed to return now 00499 00500 // Only update if we are not already ungrey 00501 if (GreyStatus == FALSE) 00502 return TRUE; 00503 00504 // Call our central greying/ungreying function 00505 ok = ChangeControlStatus(TRUE); 00506 00507 GreyStatus = FALSE; 00508 00509 return ok; 00510 } 00511 00512 /******************************************************************************************** 00513 00514 > BOOL EditTab::ChangeControlStatus(const BOOL Status) 00515 00516 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00517 Created: 4/2/95 00518 Inputs: - 00519 Outputs: - 00520 Returns: - 00521 Purpose: Called to grey/ungrey all controls on this tab. 00522 Errors: - 00523 SeeAlso: EditTab::GreySection; EditTab::UngreySection; 00524 00525 ********************************************************************************************/ 00526 00527 BOOL EditTab::ChangeControlStatus(const BOOL Status) 00528 { 00529 // Grey/ungrey the controls 00530 // pPrefsDlg->EnableGadget(_R(IDC_OPTS_LASTATTRB), Status); 00531 // pPrefsDlg->EnableGadget(_R(IDC_OPTS_ASKSETATTRB), Status); 00532 00533 pPrefsDlg->EnableGadget(_R(IDC_OPTS_ANGLEGROUP), Status); 00534 pPrefsDlg->EnableGadget(_R(IDC_OPTS_ANGLECONST), Status); 00535 00536 pPrefsDlg->EnableGadget(_R(IDC_OPTS_NUDGEGROUP), Status); 00537 pPrefsDlg->EnableGadget(_R(IDC_OPTS_NUDGESIZE), Status); 00538 00539 pPrefsDlg->EnableGadget(_R(IDC_OPTS_DUPLICATEGROUP), Status); 00540 pPrefsDlg->EnableGadget(_R(IDC_OPTS_XDUPLICATETXT), Status); 00541 pPrefsDlg->EnableGadget(_R(IDC_OPTS_YDUPLICATETXT), Status); 00542 pPrefsDlg->EnableGadget(_R(IDC_OPTS_XDUPLICATE), Status); 00543 pPrefsDlg->EnableGadget(_R(IDC_OPTS_YDUPLICATE), Status); 00544 00545 return TRUE; 00546 } 00547 00548 /******************************************************************************************** 00549 00550 > BOOL EditTab::UpdateSection() 00551 00552 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00553 Created: 4/2/95 00554 Inputs: Name of document 00555 Outputs: - 00556 Returns: - 00557 Purpose: Called when we have switched to a new document and need to update all the 00558 controls on this tab. Should only init the tab if the page is present. 00559 The document name allows the info field on the tab to be filled in correctly. 00560 Errors: - 00561 SeeAlso: EditTab::GreySection; EditTab::UngreySection; EditTab::InitSection; 00562 00563 ********************************************************************************************/ 00564 00565 BOOL EditTab::UpdateSection(String_256 *DocumentName) 00566 { 00567 TRACEUSER( "Neville", _T("EditTab::UpdateSection\n")); 00568 ERROR2IF(pPrefsDlg == NULL,FALSE,"EditTab::UpdateSection called with no dialog pointer"); 00569 00570 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_EDIT)); // The EditTab identifier 00571 if (!ok) 00572 return TRUE; // page not present 00573 00574 // Remove any lists that we have created. 00575 pPrefsDlg->DeleteAllValues(_R(IDC_OPTS_ANGLECONST)); 00576 00577 // Call the normal init section code 00578 return InitSection(); 00579 } 00580 00581 00582 /******************************************************************************************** 00583 00584 > BOOL EditTab::UpdateAskBefore() 00585 00586 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00587 Created: 8/2/95 00588 Inputs: - 00589 Outputs: - 00590 Returns: - 00591 Purpose: Called when the user has requested a change in the ask before setting 00592 attribute state and hence we need to update the relevent controls on this tab. 00593 Should only do this if the tab is present. 00594 Usually happens when the user applies an atribute to no selected object and 00595 responds Quiet to the prompt. 00596 Errors: - 00597 SeeAlso: AttributeManager::AttributeSelected(); 00598 00599 ********************************************************************************************/ 00600 00601 BOOL EditTab::UpdateAskBefore() 00602 { 00603 TRACEUSER( "Neville", _T("EditTab::UpdateAskBefore()\n")); 00604 ERROR2IF(pPrefsDlg == NULL,FALSE,"EditTab::UpdateAskBefore() called with no dialog pointer"); 00605 00606 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_EDIT)); // The EditTab identifier 00607 if (!ok) 00608 return TRUE; // page not present 00609 00610 BOOL AskBeforeSetting = FALSE; 00611 BOOL ReadOk = FALSE; 00612 ReadOk = Camelot.GetPrefValue(TEXT("Attributes"), TEXT("AskBeforeSettingCurrentAttr"), &AskBeforeSetting); 00613 pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_ASKSETATTRB), AskBeforeSetting); 00614 //ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_EDIT)); 00615 00616 return(TRUE); 00617 00618 } 00619 00620 /******************************************************************************************** 00621 00622 > BOOL EditTab::HandleMsg(DialogMsg* Msg) 00623 00624 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00625 Created: 7/12/94 00626 Inputs: - 00627 Outputs: - 00628 Returns: - 00629 Purpose: Handles all the Edit options tabs messages 00630 Errors: - 00631 SeeAlso: - 00632 00633 ********************************************************************************************/ 00634 00635 BOOL EditTab::HandleMsg(DialogMsg* Msg) 00636 { 00637 TRACEUSER( "Neville", _T("HandleEditMsg\n")); 00638 ERROR2IF(Msg == NULL,FALSE,"EditTab::Message null message received"); 00639 ERROR2IF(pPrefsDlg == NULL,FALSE,"EditTab::HandleMsg called with no dialog pointer"); 00640 00641 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_EDIT)); // The edit page identifier 00642 if (!ok) 00643 return TRUE; // no page present = handled message 00644 00645 switch(Msg->DlgMsg) 00646 { 00647 case DIM_CREATE: // Initialise controls 00648 GreyStatus = FALSE; // we are ungreyed by default 00649 ok = InitSection(); 00650 if (!ok) 00651 InformError(); 00652 break; 00653 case DIM_SELECTION_CHANGED: 00654 case DIM_LFT_BN_CLICKED: 00655 case DIM_TEXT_CHANGED: 00656 OptionsTabs::SetApplyNowState(TRUE); 00657 break; 00658 default: 00659 break; 00660 } 00661 return TRUE; 00662 } 00663 00664 00665 /****************************************************************************************** 00666 00667 > BOOL EditTab::InitSection() 00668 00669 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00670 Created: 6/12/94 00671 Inputs: - 00672 Outputs: - 00673 Returns: TRUE if successful, else FALSE 00674 Purpose: Sets initial values for the Edit section of the options dialog box. 00675 This section includes the:- 00676 Errors: - 00677 SeeAlso: AppPrefsDlg; OptionsTabs; 00678 00679 ******************************************************************************************/ 00680 00681 BOOL EditTab::InitSection() 00682 { 00683 TRACEUSER( "Neville", _T("InitEditSection\n")); 00684 ERROR2IF(pPrefsDlg == NULL,FALSE,"EditTab::InitSection called with no dialog pointer"); 00685 00686 BOOL ReadOk = FALSE; // Flag to say whether the preference value was read ok 00687 BOOL ok = TRUE; // Flag for whether value set up ok 00688 00689 // Section = Attributes 00690 00691 BOOL AskBeforeSetting = FALSE; 00692 ReadOk = Camelot.GetPrefValue(TEXT("Attributes"), TEXT("AskBeforeSettingCurrentAttr"), &AskBeforeSetting); 00693 pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_ASKSETATTRB), AskBeforeSetting); 00694 ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_EDIT)); 00695 00696 BOOL LastAttribute = FALSE; 00697 ReadOk = Camelot.GetPrefValue(TEXT("Attributes"), TEXT("LastAttrAppliedBecomesCurrent"), &LastAttribute); 00698 pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_LASTATTRB), LastAttribute); 00699 ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_EDIT)); 00700 00701 // Set up the units that are used in the currently selected document 00702 // All units work off the selected document and so we must do nothing if there is no 00703 // selected document. 00704 ok = SetUpDocUnits(); 00705 if (!ok) 00706 { 00707 // If this fails then there is no document and so we must ensure 00708 // things which need a selected document are greyed. 00709 GreySection(); 00710 return (TRUE); 00711 } 00712 00713 // Section = Constraints 00714 00715 // Now the constraint angle combo box 00716 double Angle = 0.0; // Angle stored in radians in the preference system 00717 double AngleInDegrees = 0; // Angle displayed in degrees to the user 00718 ReadOk = Camelot.GetPrefValue(TEXT("Constraints"), TEXT("Constrain Angle"), &Angle); 00719 TRACEUSER( "Neville", _T("set constraint angle '%d'\n"),Angle); 00720 // Set up the list of available options 00721 pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 12.0); 00722 pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 15.0); 00723 pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 30.0); 00724 pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 45.0); 00725 pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 60.0); 00726 pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 72.0); 00727 pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 90.0); 00728 pPrefsDlg->SetComboListLength(_R(IDC_OPTS_ANGLECONST)); 00729 // Set up the default option displayed 00730 AngleInDegrees = (Angle * 180.0/PI); // Convert angle to degrees 00731 ok = pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), AngleInDegrees, FALSE, -1); 00732 ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_EDIT)); 00733 00734 // Now the duplicate distance 00735 // INT32 x = 0; 00736 // INT32 y = 0; 00737 DocCoord offset = pDocument->GetDuplicationOffset(); 00738 // ReadOk = Camelot.GetPrefValue(TEXT("Duplicate"), TEXT("DuplicatePlacementX"), &x); 00739 ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_XDUPLICATE), CurrentScaledUnits, offset.x, FALSE, -1); 00740 ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_EDIT)); 00741 00742 // ReadOk = Camelot.GetPrefValue(TEXT("Duplicate"), TEXT("DuplicatePlacementY"), &y); 00743 ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_YDUPLICATE), CurrentScaledUnits, offset.y, FALSE, -1); 00744 ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_EDIT)); 00745 00746 // Now the nudge size distance 00747 UINT32 Nudge = pDocument->GetDocNudge (); 00748 //ReadOk SetOk = pDocument->SetDocNudge (Nudge);//Camelot.GetPrefValue(TEXT("Nudge"), TEXT("StepSize"), &Nudge); 00749 ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_NUDGESIZE), CurrentScaledUnits, Nudge, FALSE, -1); 00750 ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_EDIT)); 00751 00752 return TRUE; 00753 }