optsmisc.cpp

Go to the documentation of this file.
00001 // $Id: optsmisc.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 Misc tab of the options dialog box
00099 
00100 /*
00101 
00102 */
00103 
00104 #include "camtypes.h"
00105 #include "appprefs.h"
00106 //#include "prefsdlg.h" // dialog/gadget ids
00107 //#include "optsres.h"  // error strings
00108 #include "optsmisc.h"
00109 //#include "app.h"      // Camelot object - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "spread.h"       // So that knows spreads are derived from nodes - in camtypes.h [AUTOMATICALLY REMOVED]
00111 #include "sprdmsg.h"    // spread messages
00112 
00113 CC_IMPLEMENT_DYNAMIC(MiscTab, OptionsTabs)   
00114 
00115 // This is not compulsory, but you may as well put it in so that the correct version
00116 // of your file can be registered in the .exe
00117 DECLARE_SOURCE("$Revision: 1282 $");
00118 
00119               
00120 /********************************************************************************************
00121 
00122 >   MiscTab::MiscTab() 
00123 
00124 
00125     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00126     Created:    7/12/94
00127     Inputs:     -
00128     Outputs:    -
00129     Returns:    -
00130     Purpose:    MiscTab constructor. Creates a non-undoable operation
00131     Errors:     -
00132     SeeAlso:    -
00133 
00134 ********************************************************************************************/
00135 
00136 MiscTab::MiscTab()
00137 {   
00138     // Do nothing at present
00139 }        
00140 
00141 /********************************************************************************************
00142 
00143 >   MiscTab::~MiscTab()
00144 
00145 
00146     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00147     Created:    7/12/94
00148     Inputs:     -
00149     Outputs:    -
00150     Returns:    -
00151     Purpose:    MiscTab destructor
00152     Errors:     -
00153     SeeAlso:    -
00154 
00155 ********************************************************************************************/
00156                                                                                 
00157 MiscTab::~MiscTab()
00158 {   
00159 }        
00160 
00161 /********************************************************************************************
00162 
00163 >   BOOL MiscTab::Init()
00164 
00165 
00166     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00167     Created:    7/12/94
00168     Inputs:     -
00169     Outputs:    -
00170     Returns:    True if initialised ok, False if failed.
00171     Purpose:    MiscTab initialisation routine
00172     Errors:     -
00173     SeeAlso:    -
00174 
00175 ********************************************************************************************/
00176                                                                                 
00177 BOOL MiscTab::Init()
00178 {   
00179     return TRUE;
00180 }        
00181 
00182 
00183 /******************************************************************************************
00184 
00185 >   CDlgResID MiscTab::GetPageID()()
00186 
00187     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00188     Created:    7/12/94
00189     Inputs:     -
00190     Outputs:    -
00191     Returns:    The dialog ID of this tab section.    
00192     Purpose:    Allows the options dialog code to determine the dialog ID of this section.
00193     Errors:     -
00194     SeeAlso:    -
00195 
00196 ******************************************************************************************/
00197 
00198 CDlgResID MiscTab::GetPageID()
00199 {
00200     return _R(IDD_OPTSTAB_MISC);
00201 }
00202 
00203 /******************************************************************************************
00204 
00205 >   BOOL MiscTab::IsDocumentOption()
00206 
00207     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00208     Created:    14/12/94
00209     Inputs:     -
00210     Outputs:    -
00211     Returns:    Returns True if this tab is a document option.    
00212     Purpose:    Allows the document options dialog code to determine if this tab belongs
00213                 to the group of document options.
00214     Errors:     -
00215     SeeAlso:    IsProgramOption();
00216 
00217 ******************************************************************************************/
00218 
00219 BOOL MiscTab::IsDocumentOption()
00220 {
00221     return FALSE;   // This tab is not a document option 
00222 }
00223 
00224 /******************************************************************************************
00225 
00226 >   BOOL MiscTab::IsProgramOption()
00227 
00228     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00229     Created:    14/12/94
00230     Inputs:     -
00231     Outputs:    -
00232     Returns:    Returns True if this tab is a program option.     
00233     Purpose:    Allows the program options dialog code to determine if this tab belongs
00234                 to the group of program options.
00235     Errors:     -
00236     SeeAlso:    IsProgramOption();
00237 
00238 ******************************************************************************************/
00239 
00240 BOOL MiscTab::IsProgramOption()
00241 {
00242     return TRUE;    // This tab is a program option 
00243 }
00244 
00245 
00246 /******************************************************************************************
00247 
00248 >   BOOL AppPrefsDlg::CommitSection()
00249 
00250     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00251     Created:    7/12/94
00252     Inputs:     -
00253     Outputs:    -
00254     Returns:    True if values in dialog box ok, False otherwise.     
00255     Purpose:    Takes the values in the Misc section tab of the options dialog box and
00256                 sets the associated preference values accordingly
00257                 Called when ok is pressed on the dialog box.
00258     Errors:     -
00259     SeeAlso:    -
00260 
00261 ******************************************************************************************/
00262 
00263 BOOL MiscTab::CommitSection()
00264 {
00265 TRACEUSER( "Neville", _T("commit misc section\n"));
00266     ERROR2IF(pPrefsDlg == NULL,FALSE,"MiscTab::CommitSection called with no dialog pointer");
00267 
00268     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_MISC));  // The Misc page identifier
00269     if (!ok)
00270         return TRUE;    // Talk to page failed to return now
00271 
00272     // Section = Misc
00273 
00274     // Ok has been pressed so take the values from this section of the dialog box
00275     BOOL Valid=0;       // Flag for validity of value
00276     INT32 State=0;      // Flag for state of button/switch
00277     BOOL SetOk=0;       // Preference value set ok
00278 
00279     // Section = Import
00280 //WEBSTER-ranbirr-13/11/96
00281 #ifndef WEBSTER
00282     //State = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_IMPWITHLAYERS), 0, 1, 0, &Valid);
00283     State = pPrefsDlg->GetSelectedValueIndex(_R(IDC_OPTS_IMPWITHLAYERS));
00284     Valid = State >= 0 && State <= 2;
00285 
00286     SetOk = Camelot.SetPrefValue(TEXT("Filters"), TEXT("ImportWithLayers"), &State);
00287     ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_MISC));
00288 
00289     // Section = Preferences
00290 
00291     State = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_SAVEONEXIT), 0, 1, 0, &Valid);
00292     if ( State != FALSE )
00293         AppPrefsDlg::SetSaveOnExit(TRUE);
00294     else
00295         AppPrefsDlg::SetSaveOnExit(FALSE);
00296 
00297     // Section = File menu
00298 
00299     State = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_FILELISTSIZE), 1, 9, _R(IDE_OPTS_INVALIDFILELIST), &Valid);
00300     if (Valid)
00301     {
00302 TRACEUSER( "Neville", _T("commit file list size='%d'\n"), State);
00303         SetOk = Camelot.SetPrefValue(TEXT("Recent File List"), TEXT("FileListSize"), &State);
00304         ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_MISC));
00305     }
00306     else
00307         return FALSE;           // File list size incorrect, user has been warned already
00308 
00309     // Section = Layers
00310 
00311     State = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_VISIBLELAYER), 0, 1, 0, &Valid);
00312     SetOk = Camelot.SetPrefValue(TEXT("Layers"),TEXT("ActiveLayerVisibleAndEditable"),&State);
00313     ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_MISC));
00314     // Now tell the layers gallery to update itself, if present
00315     // Broadcast a SpreadMsg with reason code SpreadMsg::LAYERCHANGES, when the pref changes.
00316     // The layer gallery will then redraw itself. 
00317     BROADCAST_TO_ALL(SpreadMsg(pSpread, pSpread, SpreadMsg::LAYERCHANGES));
00318 
00319     // Section = Attributes
00320 
00321     State = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_ASKSETATTRB), 0, 1, 0, &Valid);
00322     SetOk = Camelot.SetPrefValue(TEXT("Attributes"),TEXT("AskBeforeSettingCurrentAttr"),&State);
00323     ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_MISC));
00324 
00325     State = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_LASTATTRB), 0, 1, 0, &Valid);
00326     SetOk = Camelot.SetPrefValue(TEXT("Attributes"),TEXT("LastAttrAppliedBecomesCurrent"),&State);
00327     ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_MISC));
00328 
00329 //  State = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_ASKGREYSCALEBMP), 0, 1, 0, &Valid);
00330     //AttributeManger::ShouldAskAboutContoneColours = State;
00331 //  SetOk = Camelot.SetPrefValue(TEXT("Attributes"),TEXT("AskBeforeSettingContoneColours"),&State);
00332 //  ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_MISC));
00333 
00334     // Section = ask before closing view
00335 
00336     State = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_CLOSEDOCVIEWS), 0, 1, 0, &Valid);
00337     SetOk = Camelot.SetPrefValue(TEXT("Preferences"),TEXT("RemoveExistingDocs"),&State);
00338     ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_MISC));
00339 
00340     State = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_GROUPTRANSPARENCY), 0, 1, 0, &Valid);
00341     SetOk = Camelot.SetPrefValue(TEXT("Attributes"),TEXT("GroupTransparency"),&State);
00342     ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_MISC));
00343 
00344 #endif //webster
00345     // All units work off the selected document and so we must do nothing if there is no
00346     // selected document. Check our class variable to see if this is true or not.
00347     // Units should have been set up by the caller.
00348     if (pDocument == NULL || pSpread == NULL)
00349         return TRUE;
00350 
00351     // Section = Constraints
00352 
00353     // Now the constraint angle combo box
00354     // Convert to double uses units and so requires a selected document
00355     double Angle = PI / 4;      // Angle stored in radians in the preference system
00356     double AngleInDegrees = 45; // Angle displayed in degrees to the user
00357     AngleInDegrees = pPrefsDlg->GetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 1, 359,
00358                                                      _R(IDE_OPTS_INVALIDANGLE), &Valid);
00359     if (Valid)
00360     {
00361         // Angle in correct range so put it into the preference system
00362         Angle = AngleInDegrees * PI/180.0;      // convert angle to radians
00363 TRACEUSER( "Neville", _T("commit constraint angle in degrees='%d' angle='%d' Valid ='%d'\n"), AngleInDegrees, Angle, Valid);
00364         SetOk = Camelot.SetPrefValue(TEXT("Constraints"), TEXT("Constrain Angle"), &Angle);
00365         ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_MISC));
00366     }
00367     else
00368         return FALSE;           // Angle incorrect, user has been warned already
00369 
00370     // Now the duplicate distance
00371     // These should be shown in scaled coordinates as they measure distances on the page 
00372     // pSpread tells the dimension class which document to pick the dimensioning from
00373     MILLIPOINT x = 0;
00374     MILLIPOINT y = 0;
00375 //  const INT32 Maxxy = INT_MAX;        // maximum value allowed as the distance
00376     BOOL bValidX = FALSE;
00377     BOOL bValidY = FALSE;
00378 
00379     ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_MISC));   // The Misc page identifier
00380     x = pPrefsDlg->GetDimensionGadgetValue(_R(IDC_OPTS_XDUPLICATE), pSpread, &bValidX);
00381 /*  if (Valid && (x > -Maxxy) && (x < Maxxy))
00382     {
00383         // The preference system needs integers rather than MILLIPOINTS.
00384         INT32 xsize = (INT32)x;
00385         SetOk = Camelot.SetPrefValue(TEXT("Duplicate"), TEXT("DuplicatePlacementX"), &xsize);
00386         ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_MISC));
00387     }
00388     else
00389     {
00390         // There is a problem so warn the user that the x size is incorrect
00391         InformWarning(_R(IDE_OPTS_INVALIDDISTANCE));
00392         return FALSE;
00393     }           
00394 */
00395     ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_MISC));   // The Misc page identifier
00396     y = pPrefsDlg->GetDimensionGadgetValue(_R(IDC_OPTS_YDUPLICATE), pSpread, &bValidY);
00397 /*  if (Valid && (y > -Maxxy) && (y < Maxxy))
00398     {
00399         // The preference system needs integers rather than MILLIPOINTS.
00400         INT32 ysize = (INT32)y;
00401         SetOk = Camelot.SetPrefValue(TEXT("Duplicate"), TEXT("DuplicatePlacementY"), &ysize);
00402         ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_MISC));
00403     }
00404     else
00405     {
00406         // There is a problem so warn the user that the y size is incorrect
00407         InformWarning(_R(IDE_OPTS_INVALIDDISTANCE));
00408         return FALSE;
00409     }           
00410 */
00411     if (bValidX && bValidY)
00412     {
00413         pDocument->SetDuplicationOffset(DocCoord(x,y));
00414         pDocument->SetModified(TRUE);
00415     }
00416     else
00417     {
00418         // There is a problem so warn the user that the y size is incorrect
00419         InformWarning(_R(IDE_OPTS_INVALIDDISTANCE));
00420         return FALSE;
00421     }           
00422 
00423     // Now the nudge size distance
00424     MILLIPOINT Nudge = 0;
00425     ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_MISC));   // The Misc page identifier
00426     Nudge = pPrefsDlg->GetDimensionGadgetValue(_R(IDC_OPTS_NUDGESIZE), pSpread, &Valid);
00427     if (Valid && (Nudge > 0) && (Nudge < MaxDocCoord))
00428     {
00429         // Value apparently read ok so set up the value in the preference system
00430         // The preference system needs UINTs rather than MILLIPOINTS.
00431         UINT32 NudgeSize = (UINT32)Nudge;
00432         pDocument->SetDocNudge (NudgeSize);
00433         pDocument->SetModified (TRUE);
00434         //SetOk = TRUE;//Camelot.SetPrefValue(TEXT("Nudge"), TEXT("StepSize"), &NudgeSize);
00435         //ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_MISC));
00436     }
00437     else
00438     {
00439         // There is a problem so warn the user that the Nudge size is incorrect
00440         InformWarning(_R(IDE_OPTS_INVALIDNUDGE));
00441         return FALSE;
00442     }
00443 
00444     return TRUE;
00445 }
00446 
00447 /******************************************************************************************
00448 
00449 >   BOOL MiscTab::NewUnitsInSection()
00450 
00451     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00452     Created:    5/1/95
00453     Inputs:     -
00454     Outputs:    -
00455     Returns:    True if values in dialog box ok, False otherwise.     
00456     Purpose:    Function called when new default units come into operation. We must convert
00457                 all units fields to display in the newly specified units.
00458     Errors:     -
00459     SeeAlso:    -
00460 
00461 ******************************************************************************************/
00462 
00463 BOOL MiscTab::NewUnitsInSection()
00464 {
00465 TRACEUSER( "Neville", _T("MiscTab::NewUnitsInSection\n"));
00466     ERROR2IF(pPrefsDlg == NULL,FALSE,"MiscTab::NewUnitsInSection called with no dialog pointer");
00467 
00468     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_MISC));  // The misc page identifier
00469     if (!ok)
00470         return TRUE;    // Talk to page failed to return now
00471 
00472     // Call the code which sets up any controls displaying measurements in this section code
00473     InitControlsWithUnits();
00474     
00475     return TRUE;
00476 }
00477     
00478 #if 0
00479     // Set up the common variables
00480     BOOL Valid=FALSE;       // Flag for validity of value
00481 
00482     // We will not error on any of the conversions as this might mean double errors
00483     // when say an apply is used but instead just ignore the conversion. This also means
00484     // not specifying an error message in the GetUnitGadgetValue calls.
00485 
00486     // All units work off the selected document and so we must do nothing if there is no
00487     // selected document. Check our class variable to see if this is true or not.
00488     // Units should have been set up by the caller.
00489     if (pDocument == NULL || pSpread == NULL)
00490         return TRUE;
00491 
00492     // Now the duplicate distance
00493     INT32 x = 0;
00494     INT32 y = 0;
00495     const INT32 Maxxy = INT_MAX;        // maximum value allowed as the distance
00496 
00497     x = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_XDUPLICATE), CurrentPageUnits,
00498                                          -Maxxy, Maxxy, NULL, &Valid);
00499     if (Valid)
00500     {
00501         ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_XDUPLICATE), CurrentPageUnits, x, FALSE, -1);
00502     }
00503 
00504     y = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_YDUPLICATE), CurrentPageUnits,
00505                                          -Maxxy, Maxxy, NULL, &Valid);
00506     if (Valid)
00507     {
00508         ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_YDUPLICATE), CurrentPageUnits, y, FALSE, -1);
00509     }
00510 
00511     // Now the nudge size distance
00512     UINT32 Nudge = 0;
00513     Nudge = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_NUDGESIZE), CurrentPageUnits,
00514                                              0, INT_MAX, NULL, &Valid);
00515     if (Valid)
00516     {
00517         ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_NUDGESIZE), CurrentPageUnits, Nudge, FALSE, -1);
00518     }
00519 
00520     return TRUE;
00521 }
00522 #endif
00523 
00524 /********************************************************************************************
00525 
00526 >   BOOL MiscTab::GreySection()
00527 
00528     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00529     Created:    4/2/95
00530     Inputs:     -
00531     Outputs:    -
00532     Returns:    -
00533     Purpose:    Called when the user has closed all documents 
00534     Errors:     -
00535     SeeAlso:    MiscTab::UngreySection;
00536 
00537 ********************************************************************************************/
00538 
00539 BOOL MiscTab::GreySection()
00540 {
00541 TRACEUSER( "Neville", _T("GreySection in MiscTab section\n"));
00542     ERROR2IF(pPrefsDlg == NULL,FALSE,"MiscTab::GreySection called with no dialog pointer");
00543 
00544     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_MISC));  // The MiscTab identifier
00545     if (!ok)
00546         return TRUE;    // Talk to page failed to return now
00547 
00548     // Only update if we are not already grey 
00549     if (GreyStatus == TRUE)
00550         return TRUE;
00551 
00552     // Call our central greying/ungreying function
00553     ok = ChangeControlStatus(FALSE);
00554     
00555     GreyStatus = TRUE;
00556 
00557     return ok;
00558 } 
00559 
00560 /********************************************************************************************
00561 
00562 >   BOOL MiscTab::UngreySection()
00563 
00564     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00565     Created:    4/2/95
00566     Inputs:     -
00567     Outputs:    -
00568     Returns:    -
00569     Purpose:    Called when the user has selected a new document 
00570     Errors:     -
00571     SeeAlso:    MiscTab::UngreySection;
00572 
00573 ********************************************************************************************/
00574 
00575 BOOL MiscTab::UngreySection()
00576 {
00577 TRACEUSER( "Neville", _T("UngreySection in MiscTab section\n"));
00578     ERROR2IF(pPrefsDlg == NULL,FALSE,"MiscTab::UngreySection called with no dialog pointer");
00579 
00580     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_MISC));  // The MiscTab identifier
00581     if (!ok)
00582         return TRUE;    // Talk to page failed to return now
00583 
00584     // Only update if we are not already ungrey 
00585     if (GreyStatus == FALSE)
00586         return TRUE;
00587 
00588     // Call our central greying/ungreying function
00589     ok = ChangeControlStatus(TRUE);
00590     
00591     GreyStatus = FALSE;
00592 
00593     return ok;
00594 }
00595 
00596 /********************************************************************************************
00597 
00598 >   BOOL MiscTab::ChangeControlStatus(const BOOL Status)
00599 
00600     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00601     Created:    4/2/95
00602     Inputs:     -
00603     Outputs:    -
00604     Returns:    -
00605     Purpose:    Called to grey/ungrey all controls on this tab. 
00606     Errors:     -
00607     SeeAlso:    MiscTab::GreySection;   MiscTab::UngreySection;
00608 
00609 ********************************************************************************************/
00610 
00611 BOOL MiscTab::ChangeControlStatus(const BOOL Status)
00612 {
00613     // Grey/ungrey the controls
00614 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_INFO), Status);
00615 
00616     // Grey/ungrey the controlling Switch
00617 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_IMPWITHLAYERS), Status);
00618 
00619 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_PREFSTXT), Status);
00620 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_SAVEONEXIT), Status);
00621 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_SAVENOW), Status);
00622 
00623 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_FILETXT), Status);
00624 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_FILELISTTXT), Status);
00625 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_FILELISTSIZE), Status);
00626 
00627 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_VISIBLELAYER), Status);
00628 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_LASTATTRB), Status);
00629 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_ASKSETATTRB), Status);
00630 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_CLOSEDOCVIEWS), Status);
00631 
00632     pPrefsDlg->EnableGadget(_R(IDC_OPTS_EDITGRP), Status);
00633 
00634     pPrefsDlg->EnableGadget(_R(IDC_OPTS_CONSTRAINTTXT), Status);
00635     pPrefsDlg->EnableGadget(_R(IDC_OPTS_ANGLECONST), Status);
00636 
00637     pPrefsDlg->EnableGadget(_R(IDC_OPTS_NUDGETXT), Status);
00638     pPrefsDlg->EnableGadget(_R(IDC_OPTS_NUDGESIZE), Status);
00639 
00640     pPrefsDlg->EnableGadget(_R(IDC_OPTS_DUPLICATETXT), Status);
00641     pPrefsDlg->EnableGadget(_R(IDC_OPTS_XDUPLICATETXT), Status);
00642     pPrefsDlg->EnableGadget(_R(IDC_OPTS_YDUPLICATETXT), Status);
00643     pPrefsDlg->EnableGadget(_R(IDC_OPTS_XDUPLICATE), Status);
00644     pPrefsDlg->EnableGadget(_R(IDC_OPTS_YDUPLICATE), Status);
00645 
00646     return TRUE;
00647 }           
00648 
00649 /********************************************************************************************
00650 
00651 >   BOOL MiscTab::UpdateSection(String_256 *DocumentName)
00652 
00653     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00654     Created:    4/2/95
00655     Inputs:     Name of document
00656     Outputs:    -
00657     Returns:    -
00658     Purpose:    Called when we have switched to a new document and need to update all the 
00659                 controls on this tab. Should only init the tab if the page is present.  
00660                 The document name allows the info field on the tab to be filled in correctly.
00661     Errors:     -
00662     SeeAlso:    MiscTab::GreySection; MiscTab::UngreySection; MiscTab::InitSection;
00663 
00664 ********************************************************************************************/
00665 
00666 BOOL MiscTab::UpdateSection(String_256 *DocumentName)
00667 {
00668 TRACEUSER( "Neville", _T("MiscTab::UpdateSection\n"));
00669     ERROR2IF(pPrefsDlg == NULL,FALSE,"MiscTab::UpdateSection called with no dialog pointer");
00670 
00671     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_MISC));  // The MiscTab identifier
00672     if (!ok)
00673         return TRUE;        // page not present
00674 
00675     // Remove any lists that we have created.
00676     //pPrefsDlg->DeleteAllValues(_R(IDC_OPTS_ANGLECONST));
00677 
00678     // Call the code which sets up any controls displaying measurements in this section code
00679     InitControlsWithUnits();
00680 
00681     return TRUE;
00682 }
00683 
00684 
00685 /********************************************************************************************
00686 
00687 >   BOOL MiscTab::UpdateImportWithLayers()
00688 
00689     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00690     Created:    9/2/95
00691     Inputs:     -
00692     Outputs:    -
00693     Returns:    -
00694     Purpose:    Called when the state of the option Import with layers has been changed.
00695                 We therefore need to update the state of this button on this tab.
00696                 Should only update it if the page is present.  
00697     Errors:     -
00698     SeeAlso:    MiscTab::GreySection; MiscTab::UngreySection; MiscTab::InitSection;
00699 
00700 ********************************************************************************************/
00701 
00702 BOOL MiscTab::UpdateImportWithLayers()
00703 {
00704 //WEBSTER-ranbirr-13/11/96
00705 #ifndef WEBSTER
00706 TRACEUSER( "Neville", _T("MiscTab::UpdateImportWithLayers\n"));
00707     ERROR2IF(pPrefsDlg == NULL,FALSE,"MiscTab::UpdateImportWithLayers called with no dialog pointer");
00708 
00709     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_MISC));  // The MiscTab identifier
00710     if (!ok)
00711         return TRUE;        // page not present
00712 
00713     BOOL ReadOk = FALSE;
00714     INT32 ImportWithLayers = 2; // use layer names as the default
00715     ReadOk = Camelot.GetPrefValue(TEXT("Filters"), TEXT("ImportWithLayers"), &ImportWithLayers);
00716 //  pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_IMPWITHLAYERS), ImportWithLayers);
00717     pPrefsDlg->SetSelectedValueIndex(_R(IDC_OPTS_IMPWITHLAYERS), ImportWithLayers);
00718     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
00719 
00720     return (TRUE);
00721 #else 
00722     return FALSE;
00723 #endif //webster
00724 }
00725 
00726 /********************************************************************************************
00727 
00728 >   BOOL MiscTab::UpdateAskBefore()
00729 
00730     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00731     Created:    8/2/95
00732     Inputs:     -
00733     Outputs:    -
00734     Returns:    -
00735     Purpose:    Called when the user has requested a change in the ask before setting
00736                 attribute state and hence we need to update the relevent controls on this tab.
00737                 Should only do this if the tab is present.
00738                 Usually happens when the user applies an atribute to no selected object and
00739                 responds Quiet to the prompt.  
00740     Errors:     -
00741     SeeAlso:    AttributeManager::AttributeSelected();
00742 
00743 ********************************************************************************************/
00744 
00745 BOOL MiscTab::UpdateAskBefore()
00746 {
00747 //WEBSTER-ranbirr-13/11/96
00748 #ifndef WEBSTER
00749 TRACEUSER( "Neville", _T("MiscTab::UpdateAskBefore()\n"));
00750     ERROR2IF(pPrefsDlg == NULL,FALSE,"MiscTab::UpdateAskBefore() called with no dialog pointer");
00751 
00752     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_MISC));  // The EditTab identifier
00753     if (!ok)
00754         return TRUE;        // page not present
00755 
00756     BOOL AskBeforeSetting = FALSE;
00757     BOOL ReadOk = FALSE;
00758     ReadOk = Camelot.GetPrefValue(TEXT("Attributes"), TEXT("AskBeforeSettingCurrentAttr"), &AskBeforeSetting);
00759     pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_ASKSETATTRB), AskBeforeSetting);
00760     //ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
00761 
00762     return(TRUE);
00763 #else
00764     return FALSE;
00765 #endif //webster
00766     
00767 }   
00768 
00769 /********************************************************************************************
00770 
00771 >   BOOL MiscTab::HandleMsg(DialogMsg* Msg)
00772 
00773     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00774     Created:    7/12/94
00775     Inputs:     -
00776     Outputs:    -
00777     Returns:    -
00778     Purpose:    Handles all the Misc options tabs messages 
00779     Errors:     -
00780     SeeAlso:    -
00781 
00782 ********************************************************************************************/
00783 
00784 BOOL MiscTab::HandleMsg(DialogMsg* Msg)
00785 {
00786 TRACEUSER( "Neville", _T("MiscTab::HandleMsg\n"));
00787     ERROR2IF(Msg == NULL,FALSE,"MiscTab::Message null message received");
00788     ERROR2IF(pPrefsDlg == NULL,FALSE,"MiscTab::HandleMsg called with no dialog pointer");
00789 
00790     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_MISC));  // The Misc page identifier
00791     if (!ok)
00792         return TRUE;        // page not present
00793 
00794     switch(Msg->DlgMsg)
00795     {
00796         case DIM_CREATE:    // Initialise controls
00797             GreyStatus = FALSE; // we are ungreyed by default
00798             ok = InitSection();
00799             if (!ok)
00800                 InformError();
00801             break;
00802 // Moved by Neville 4/6/97 to cover whole switch statement
00803 //WEBSTER-ranbirr-13/11/96
00804 #ifndef WEBSTER
00805         case DIM_SELECTION_CHANGED:
00806         case DIM_LFT_BN_CLICKED:
00807             // A control on the dialog box has been clicked...
00808             if (Msg->GadgetID == _R(IDC_OPTS_LASTATTRB))
00809             {
00810                 // Ungrey the apply as we have clicked on this button
00811                 OptionsTabs::SetApplyNowState(TRUE);
00812                 // If last attibute applied becomes current is True then the ask before
00813                 // setting attribute is superfluous as it will be ignored.
00814                 // Get current button state. 
00815                 BOOL Valid = TRUE;
00816                 BOOL LastAttribute = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_LASTATTRB), 0, 1, 0, &Valid);
00817                 // Set new state of ask before setting button.
00818                 pPrefsDlg->EnableGadget(_R(IDC_OPTS_ASKSETATTRB), !LastAttribute);
00819                 break;
00820             }
00821             else if (Msg->GadgetID == _R(IDC_OPTS_SAVENOW))
00822             {
00823                 // save now action button pressed, save out preferences 
00824                 // but first we must take all the current values
00825                 // Should only be present in options mode
00826                 if (pPrefsDlg->IsKindOf(CC_RUNTIME_CLASS(AppPrefsDlg)))
00827                 {
00828                     // Cast/Convert our dialog pointer to be the correct type 
00829                     AppPrefsDlg *pOptionsDlg = (AppPrefsDlg*) pPrefsDlg;
00830                     ok = pOptionsDlg->CommitDialogValues();
00831                     if (ok)
00832                         Camelot.WritePreferences();
00833                 }
00834             }
00835             else
00836             {
00837                 OptionsTabs::SetApplyNowState(TRUE);
00838             }
00839             break; // DIM_LFT_BN_CLICKED        
00840 #endif //webster
00841         case DIM_TEXT_CHANGED:
00842             OptionsTabs::SetApplyNowState(TRUE);
00843             break; // DIM_TEXT_CHANGED      
00844         default:
00845             break;
00846     }
00847     
00848     return TRUE;
00849 }  
00850 
00851 
00852 /******************************************************************************************
00853 
00854 >   BOOL MiscTab::InitSection()
00855 
00856     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00857     Created:    6/12/94
00858     Inputs:     -
00859     Outputs:    -
00860     Returns:    TRUE if successful, else FALSE
00861     Purpose:    Sets initial values for the Misc section of the options dialog box.
00862                 This section includes the:-
00863                     - Import with layers
00864                     - Save settings on exit
00865                     - Recently used file list size
00866                     - Ask before setting attribute
00867                     - Last attribute applied becomes current
00868                     - Visible layer editing method
00869                     - Constraint angle 
00870                     - Duplication distance
00871                     - Nudge size
00872     Errors:     -
00873     SeeAlso:    AppPrefsDlg; OptionsTabs;
00874 
00875 ******************************************************************************************/
00876 
00877 BOOL MiscTab::InitSection()
00878 {
00879 TRACEUSER( "Neville", _T("InitMiscSection\n"));
00880     ERROR2IF(pPrefsDlg == NULL,FALSE,"MiscTab::InitSection called with no dialog pointer");
00881 
00882     BOOL ReadOk = FALSE;    // Flag to say whether the preference value was read ok 
00883 //  BOOL ok = TRUE;         // Flag for whether value set up ok 
00884 
00885     // Make sure the information field displaying the name of the current document
00886     // is correct.
00887     //String_256 *DocumentName = GetDocumentName();
00888     //pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_DOCUMENT), DocumentName);
00889 
00890     // Section = Import
00891 //WEBSTER-ranbirr-13/11/96
00892 #ifndef WEBSTER
00893 //  BOOL ImportWithLayers = FALSE;
00894 //  ReadOk = Camelot.GetPrefValue(TEXT("Filters"), TEXT("ImportWithLayers"), &ImportWithLayers);
00896 //  pPrefsDlg->SetSelectedValueIndex(_R(IDC_OPTS_IMPWITHLAYERS), ImportWithLayers);
00897 //  ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
00898 
00899     if (pPrefsDlg->GetSelectedValueIndex(_R(IDC_OPTS_IMPWITHLAYERS)) == -1)
00900     {
00901         INT32 ImportWithLayers = 2;
00902         ReadOk = Camelot.GetPrefValue(TEXT("Filters"), TEXT("ImportWithLayers"), &ImportWithLayers);
00903         pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_IMPWITHLAYERS), _R(IDS_IMPORT_NEW_LAYER), FALSE, 0);
00904         pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_IMPWITHLAYERS), _R(IDS_IMPORT_ACTIVE_LAYER), FALSE, 1);
00905         pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_IMPWITHLAYERS), _R(IDS_IMPORT_NAMED_LAYER), FALSE, 2);
00906         pPrefsDlg->SetSelectedValueIndex(_R(IDC_OPTS_IMPWITHLAYERS), ImportWithLayers);
00907     }
00908 #endif //webster
00909 
00910     
00911     
00912     // Section = Preferences
00913 
00914     // Set up the special save settings on exit switch which has no where else to live
00915     // at present
00916 //WEBSTER-ranbirr-13/11/96
00917 #ifndef WEBSTER
00918     if ( AppPrefsDlg::IsSaveOnExitSet() != FALSE )
00919         pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_SAVEONEXIT), TRUE);
00920     else
00921         pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_SAVEONEXIT), FALSE);
00922 #endif //webster
00923     // Section = File menu
00924 
00925 //WEBSTER-ranbirr-13/11/96
00926 #ifndef WEBSTER
00927     INT32 FileListSize = 1;
00928     ReadOk = Camelot.GetPrefValue(TEXT("Recent File List"), TEXT("FileListSize"), &FileListSize);
00929     pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_FILELISTSIZE), FileListSize);
00930     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
00931 #endif //webster
00932     // Section = Layers
00933 
00934 //WEBSTER-Neville-4/6/97
00935 #ifndef WEBSTER
00936     BOOL VisibleLayerEditing = FALSE;
00937     ReadOk = Camelot.GetPrefValue(TEXT("Layers"), TEXT("ActiveLayerVisibleAndEditable"), &VisibleLayerEditing);
00938     pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_VISIBLELAYER), VisibleLayerEditing);
00939     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
00940 #endif //webster
00941 
00942     // Section = Attributes
00943 //WEBSTER-ranbirr-13/11/96
00944 #ifndef WEBSTER
00945     BOOL AskBeforeSetting = FALSE;
00946     ReadOk = Camelot.GetPrefValue(TEXT("Attributes"), TEXT("AskBeforeSettingCurrentAttr"), &AskBeforeSetting);
00947     pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_ASKSETATTRB), AskBeforeSetting);
00948     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
00949 
00950     BOOL LastAttribute = FALSE;
00951     ReadOk = Camelot.GetPrefValue(TEXT("Attributes"), TEXT("LastAttrAppliedBecomesCurrent"), &LastAttribute);
00952     pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_LASTATTRB), LastAttribute);
00953     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
00954 
00955     BOOL GroupTransparency = FALSE;
00956     ReadOk = Camelot.GetPrefValue(TEXT("Attributes"), TEXT("GroupTransparency"), &GroupTransparency);
00957     pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_GROUPTRANSPARENCY), GroupTransparency);
00958     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
00959 
00960     // If last attibute applied becomes current is True then the ask before setting
00961     // attribute is superfluous as it will be ignored. 
00962     pPrefsDlg->EnableGadget(_R(IDC_OPTS_ASKSETATTRB), !LastAttribute);
00963 #endif //webster
00964 //  BOOL AskGreyscaleBitmap = FALSE;
00965     //AttributeManger::ShouldAskAboutContoneColours;
00966 //  ReadOk = Camelot.GetPrefValue(TEXT("Attributes"), TEXT("AskBeforeSettingContoneColours"), &AskGreyscaleBitmap);
00967 //  pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_ASKGREYSCALEBMP), AskGreyscaleBitmap);
00968 //  ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
00969 
00970     // Section = ask before closing view
00971 //WEBSTER-ranbirr-13/11/96
00972 #ifndef WEBSTER
00973     BOOL CloseDocViews = FALSE;
00974     ReadOk = Camelot.GetPrefValue(TEXT("Preferences"), TEXT("RemoveExistingDocs"), &CloseDocViews);
00975     pPrefsDlg->SetLongGadgetValue(_R(IDC_OPTS_CLOSEDOCVIEWS), CloseDocViews);
00976     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
00977 #endif //webster
00978 
00979     // Set up the control list for this first time only
00980     SetUpAngleList();
00981 
00982     // Sets up controls which display measurements in units 
00983     InitControlsWithUnits();
00984     
00985     return TRUE;
00986 }
00987 
00988 /******************************************************************************************
00989 
00990 >   BOOL MiscTab::SetUpAngleList()
00991 
00992     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00993     Created:    31/3/95
00994     Inputs:     -
00995     Outputs:    -
00996     Returns:    TRUE if successful, else FALSE
00997     Purpose:    Sets up the list of contraint angles. Try and only do this one time as
00998                 otherwise we get a lot of flicker when it is deleted and recreated.
00999     Errors:     -
01000     SeeAlso:    InitSection()
01001 
01002 ******************************************************************************************/
01003 
01004 BOOL MiscTab::SetUpAngleList()
01005 {
01006     // Sets up the list of constraint angles
01007     pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 12.0);
01008     pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 15.0);
01009     pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 30.0);
01010     pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 45.0);
01011     pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 60.0);
01012     pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 72.0);
01013     pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), 90.0);
01014     pPrefsDlg->SetComboListLength(_R(IDC_OPTS_ANGLECONST));
01015     
01016     return TRUE;
01017 }   
01018 
01019 
01020 /******************************************************************************************
01021 
01022 >   BOOL MiscTab::InitControlsWithUnits()
01023 
01024     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01025     Created:    31/3/95
01026     Inputs:     -
01027     Outputs:    -
01028     Returns:    TRUE if successful, else FALSE
01029     Purpose:    Sets initial values for the controls on the Misc section of the options
01030                 dialog box which display measurements in units.
01031                 This section includes the:-
01032                     - Constraint angle 
01033                     - Duplication distance
01034                     - Nudge size
01035     Errors:     -
01036     SeeAlso:    AppPrefsDlg; OptionsTabs;
01037 
01038 ******************************************************************************************/
01039 
01040 BOOL MiscTab::InitControlsWithUnits()
01041 {
01042 TRACEUSER( "Neville", _T("InitControlsWithUnits\n"));
01043     ERROR2IF(pPrefsDlg == NULL,FALSE,"MiscTab::InitControlsWithUnits called with no dialog pointer");
01044 
01045     // All units work off the selected document and so we must do nothing if there is no
01046     // selected document. Check our clas variable to see if this is true or not.
01047     // Units should have been set up by the caller.
01048     if (pDocument == NULL || pSpread == NULL)
01049     {
01050         // If this fails then there is no document and so we must ensure
01051         // things which need a selected document are greyed.
01052         GreySection();
01053         return (TRUE);
01054     }
01055 
01056     BOOL ReadOk = FALSE;    // Flag to say whether the preference value was read ok 
01057     BOOL ok = TRUE;         // Flag for whether value set up ok 
01058 
01059     // Sets up controls which display measurements in units
01060 
01061     // Section = Constraints
01062 
01063     // Now the constraint angle combo box
01064     // Doubles actually need document based units to work.
01065     double Angle = 0.0;         // Angle stored in radians in the preference system
01066     double AngleInDegrees = 0;  // Angle displayed in degrees to the user
01067     ReadOk = Camelot.GetPrefValue(TEXT("Constraints"), TEXT("Constrain Angle"), &Angle);
01068 TRACEUSER( "Neville", _T("set constraint angle '%d'\n"),Angle);
01069     // Set up the default option displayed
01070     AngleInDegrees = (Angle * 180.0/PI);    // Convert angle to degrees
01071     ok = pPrefsDlg->SetDoubleGadgetValue(_R(IDC_OPTS_ANGLECONST), AngleInDegrees, FALSE, -1);
01072     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
01073 
01074     // Now the duplicate distance
01075     // These should be shown in scaled coordinates as they measure distances on the page 
01076     // pSpread tells the dimensioning system which document to get the dimensioning
01077     // details from.
01078 //  INT32 x = 0;
01079 //  INT32 y = 0;
01080     DocCoord offset = pDocument->GetDuplicationOffset();
01081 //  ReadOk = Camelot.GetPrefValue(TEXT("Duplicate"), TEXT("DuplicatePlacementX"), &x);
01082     ok = pPrefsDlg->SetDimensionGadgetValue(_R(IDC_OPTS_XDUPLICATE), offset.x, pSpread, TRUE, FALSE, -1);
01083     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
01084 
01085 //  ReadOk = Camelot.GetPrefValue(TEXT("Duplicate"), TEXT("DuplicatePlacementY"), &y);
01086     ok = pPrefsDlg->SetDimensionGadgetValue(_R(IDC_OPTS_YDUPLICATE), offset.y, pSpread, TRUE, FALSE, -1);
01087     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
01088 
01089     // Now the nudge size distance
01090     UINT32 Nudge = pDocument->GetDocNudge ();
01091     //ReadOk = TRUE;//Camelot.GetPrefValue(TEXT("Nudge"), TEXT("StepSize"), &Nudge);
01092     ok = pPrefsDlg->SetDimensionGadgetValue(_R(IDC_OPTS_NUDGESIZE), Nudge, pSpread, TRUE, FALSE, -1);
01093     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_MISC));
01094 
01095     return TRUE;
01096 }   

Generated on Sat Nov 10 03:46:19 2007 for Camelot by  doxygen 1.4.4