optspntr.cpp

Go to the documentation of this file.
00001 // $Id: optspntr.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 Pointers tab of the options dialog box
00099 
00100 /*
00101 
00102 */
00103 
00104 #include "camtypes.h"
00105 
00106 // WEBSTER-ranbirr-13/11/96
00107 #ifndef WEBSTER
00108 
00109 #include "appprefs.h"
00110 //#include "prefsdlg.h" // dialog/gadget ids
00111 //#include "optsres.h"  // error strings
00112 #include "optspntr.h"
00113 //#include "app.h"      // Camelot object - in camtypes.h [AUTOMATICALLY REMOVED]
00114 //#include "units.h"        // units - in camtypes.h [AUTOMATICALLY REMOVED]
00115 //#include "binds.h"        // ButtonFunction - in camtypes.h [AUTOMATICALLY REMOVED]
00116 
00117 CC_IMPLEMENT_DYNAMIC(PointersTab, OptionsTabs)   
00118 
00119 // This is not compulsory, but you may as well put it in so that the correct version
00120 // of your file can be registered in the .exe
00121 DECLARE_SOURCE("$Revision: 1282 $");
00122 
00123               
00124 /********************************************************************************************
00125 
00126 >   PointersTab::PointersTab() 
00127 
00128 
00129     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00130     Created:    14/3/95
00131     Inputs:     -
00132     Outputs:    -
00133     Returns:    -
00134     Purpose:    PointersTab constructor. Creates a non-undoable operation
00135     Errors:     -
00136     SeeAlso:    -
00137 
00138 ********************************************************************************************/
00139 
00140 PointersTab::PointersTab()
00141 {   
00142     // Do nothing at present
00143 }        
00144 
00145 /********************************************************************************************
00146 
00147 >   PointersTab::~PointersTab()
00148 
00149 
00150     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00151     Created:    14/3/95
00152     Inputs:     -
00153     Outputs:    -
00154     Returns:    -
00155     Purpose:    PointersTab destructor
00156     Errors:     -
00157     SeeAlso:    -
00158 
00159 ********************************************************************************************/
00160                                                                                 
00161 PointersTab::~PointersTab()
00162 {   
00163 }        
00164 
00165 /********************************************************************************************
00166 
00167 >   BOOL PointersTab::Init()
00168 
00169 
00170     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00171     Created:    14/3/95
00172     Inputs:     -
00173     Outputs:    -
00174     Returns:    True if initialised ok, False if failed.
00175     Purpose:    PointersTab initialisation routine
00176     Errors:     -
00177     SeeAlso:    -
00178 
00179 ********************************************************************************************/
00180                                                                                 
00181 BOOL PointersTab::Init()
00182 {   
00183     return TRUE;
00184 }        
00185 
00186 
00187 /******************************************************************************************
00188 
00189 >   CDlgResID PointersTab::GetPageID()()
00190 
00191     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00192     Created:    14/3/95
00193     Inputs:     -
00194     Outputs:    -
00195     Returns:    The dialog ID of this tab section.    
00196     Purpose:    Allows the options dialog code to determine the dialog ID of this section.
00197     Errors:     -
00198     SeeAlso:    -
00199 
00200 ******************************************************************************************/
00201 
00202 CDlgResID PointersTab::GetPageID()
00203 {
00204     return _R(IDD_OPTSTAB_POINTERS);
00205 }
00206 
00207 /******************************************************************************************
00208 
00209 >   BOOL PointersTab::IsDocumentOption()
00210 
00211     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00212     Created:    14/3/95
00213     Inputs:     -
00214     Outputs:    -
00215     Returns:    Returns True if this tab is a document option.    
00216     Purpose:    Allows the document options dialog code to determine if this tab belongs
00217                 to the group of document options.
00218     Errors:     -
00219     SeeAlso:    IsProgramOption();
00220 
00221 ******************************************************************************************/
00222 
00223 BOOL PointersTab::IsDocumentOption()
00224 {
00225     return FALSE;   // This tab is not a document option 
00226 }
00227 
00228 /******************************************************************************************
00229 
00230 >   BOOL PointersTab::IsProgramOption()
00231 
00232     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00233     Created:    14/3/95
00234     Inputs:     -
00235     Outputs:    -
00236     Returns:    Returns True if this tab is a program option.     
00237     Purpose:    Allows the program options dialog code to determine if this tab belongs
00238                 to the group of program options.
00239     Errors:     -
00240     SeeAlso:    IsProgramOption();
00241 
00242 ******************************************************************************************/
00243 
00244 BOOL PointersTab::IsProgramOption()
00245 {
00246     return TRUE;    // This tab is a program option 
00247 }
00248 
00249 
00250 /******************************************************************************************
00251 
00252 >   BOOL PointersTab::CommitSection()
00253 
00254     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00255     Created:    14/3/95
00256     Inputs:     -
00257     Outputs:    -
00258     Returns:    True if values in dialog box ok, False otherwise.     
00259     Purpose:    Takes the values in the Pointers section tab of the options dialog box and
00260                 sets the associated preference values accordingly
00261                 Called when ok is pressed on the dialog box.
00262                 Middle button removed for now as nothing seems to use it.
00263     Errors:     -
00264     SeeAlso:    -
00265 
00266 ******************************************************************************************/
00267 
00268 BOOL PointersTab::CommitSection()
00269 {
00270 TRACEUSER( "Neville", _T("commit PointersTab section\n"));
00271     ERROR2IF(pPrefsDlg == NULL,FALSE,"PointersTab::CommitSection called with no dialog pointer");
00272 
00273     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_POINTERS));  // The pointers page identifier
00274     if (!ok)
00275         return TRUE;    // Talk to page failed to return now
00276 
00277     // Section = Pointers
00278 
00279     // Ok has been pressed so take the values from this section of the dialog box
00280     BOOL Valid=FALSE;       // Flag for validity of value
00281 //  BOOL State=FALSE;       // Flag for state of button/switch
00282     BOOL SetOk=TRUE;        // Preference value set ok
00283 
00284     // Middle button removed for now as nothing seems to use it.
00285 
00286     // 0, 1 or 2 indicating Left Middle or Right mouse button
00287     ButtonFunction LeftButton = (ButtonFunction)pPrefsDlg->GetSelectedValueIndex(_R(IDC_OPTS_LEFTBUTTON));
00288 //  ButtonFunction MiddleButton = (ButtonFunction)pPrefsDlg->GetSelectedValueIndex(_R(IDC_OPTS_MIDDLEBUTTON));
00289     ButtonFunction RightButton = (ButtonFunction)pPrefsDlg->GetSelectedValueIndex(_R(IDC_OPTS_RIGHTBUTTON));
00290     ClickModifiers::SetButtonFunc(0, LeftButton);
00291 //  ClickModifiers::SetButtonFunc(1, MiddleButton);
00292     ClickModifiers::SetButtonFunc(2, RightButton);
00293 
00294     // All units work off the selected document and so we must do nothing if there is no
00295     // selected document. Check our clas variable to see if this is true or not.
00296     // Units should have been set up by the caller.
00297     if (pDocument == NULL || pSpread == NULL)
00298         return (TRUE);
00299 
00300     // Now the magnetic radii
00301     INT32 LineRadius = 0;                   
00302     INT32 PointRadius = 0;                  
00303     LineRadius = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_LINERADIUS), CurrentPageUnits,
00304                                              0, INT_MAX, _R(IDE_OPTS_INVALIDLINERAD), &Valid);
00305 TRACEUSER( "Neville", _T("commit LineRadius distance='%d' Valid ='%d'\n"),LineRadius, Valid);
00306     if (Valid)
00307     {
00308         SetOk = Camelot.SetPrefValue(TEXT("Magnetic Options"), TEXT("Line Radius"), &LineRadius);
00309         ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_EDIT));
00310     }
00311     else
00312         return FALSE;           // Magnetic line radius incorrect, user has been warned already
00313 
00314     PointRadius = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_POINTRADIUS), CurrentPageUnits,
00315                                              0, INT_MAX, _R(IDE_OPTS_INVALIDPOINTRAD), &Valid);
00316 TRACEUSER( "Neville", _T("commit PointRadius distance='%d' Valid ='%d'\n"),PointRadius, Valid);
00317     if (Valid)
00318     {
00319         SetOk = Camelot.SetPrefValue(TEXT("Magnetic Options"), TEXT("Point Radius"), &PointRadius);
00320         ERROR2IF(!SetOk,2,_R(IDE_OPTS_SETPREF_EDIT));
00321     }
00322     else
00323         return FALSE;           // Magnetic point radius incorrect, user has been warned already
00324 
00325 
00326     return TRUE;
00327 }
00328 
00329 /******************************************************************************************
00330 
00331 >   BOOL PointersTab::NewUnitsInSection()
00332 
00333     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00334     Created:    14/3/95
00335     Inputs:     -
00336     Outputs:    -
00337     Returns:    True if values in dialog box ok, False otherwise.     
00338     Purpose:    Function called when new default units come into operation. We must convert
00339                 all units fields to display in the newly specified units.
00340     Errors:     -
00341     SeeAlso:    -
00342 
00343 ******************************************************************************************/
00344 
00345 BOOL PointersTab::NewUnitsInSection()
00346 {
00347 TRACEUSER( "Neville", _T("New units in edit section\n"));
00348     ERROR2IF(pPrefsDlg == NULL,FALSE,"PointersTab::NewUnitsInSection called with no dialog pointer");
00349 
00350     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_POINTERS));  // The edit page identifier
00351     if (!ok)
00352         return TRUE;    // Talk to page failed to return now
00353 
00354     // Set up the common variables
00355 //  BOOL Valid=FALSE;       // Flag for validity of value
00356 
00357     // We will not error on any of the conversions as this might mean double errors
00358     // when say an apply is used but instead just ignore the conversion. This also means
00359     // not specifying an error message in the GetUnitGadgetValue calls.
00360 
00361     // Call the normal code which inits the magnetic radii section
00362     InitMagneticRadii();
00363 
00364     return TRUE;
00365 }
00366 
00367 #if 0
00368     // All units work off the selected document and so we must do nothing if there is no
00369     // selected document. Check our clas variable to see if this is true or not.
00370     // Units should have been set up by the caller.
00371     if (pDocument == NULL || pSpread == NULL)
00372         return (TRUE);
00373 
00374     // Now the magnetic radii
00375     INT32 LineRadius = 0;                   
00376     INT32 PointRadius = 0;                  
00377     LineRadius = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_LINERADIUS), CurrentPageUnits,
00378                                              0, INT_MAX, NULL, &Valid);
00379     if (Valid)
00380     {
00381         ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_LINERADIUS), CurrentPageUnits, LineRadius, FALSE, -1);
00382     }
00383 
00384     PointRadius = pPrefsDlg->GetUnitGadgetValue(_R(IDC_OPTS_POINTRADIUS), CurrentPageUnits,
00385                                              0, INT_MAX, NULL, &Valid);
00386     if (Valid)
00387     {
00388         ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_POINTRADIUS), CurrentPageUnits, PointRadius, FALSE, -1);
00389     }
00390 
00391     return TRUE;
00392 }
00393 #endif
00394 
00395 /********************************************************************************************
00396 
00397 >   BOOL PointersTab::GreySection()
00398 
00399     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00400     Created:    14/3/95
00401     Inputs:     -
00402     Outputs:    -
00403     Returns:    -
00404     Purpose:    Called when the user has closed all documents 
00405     Errors:     -
00406     SeeAlso:    PointersTab::UngreySection;
00407 
00408 ********************************************************************************************/
00409 
00410 BOOL PointersTab::GreySection()
00411 {
00412 TRACEUSER( "Neville", _T("GreySection in PointersTab section\n"));
00413     ERROR2IF(pPrefsDlg == NULL,FALSE,"PointersTab::GreySection called with no dialog pointer");
00414 
00415     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_POINTERS));  // The PointersTab identifier
00416     if (!ok)
00417         return TRUE;    // Talk to page failed to return now
00418 
00419     // Only update if we are not already grey 
00420     if (GreyStatus == TRUE)
00421         return TRUE;
00422 
00423     // Call our central greying/ungreying function
00424     ok = ChangeControlStatus(FALSE);
00425     
00426     GreyStatus = TRUE;
00427 
00428     return ok;
00429 } 
00430 
00431 /********************************************************************************************
00432 
00433 >   BOOL PointersTab::UngreySection()
00434 
00435     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00436     Created:    14/3/95
00437     Inputs:     -
00438     Outputs:    -
00439     Returns:    -
00440     Purpose:    Called when the user has selected a new document 
00441     Errors:     -
00442     SeeAlso:    PointersTab::UngreySection;
00443 
00444 ********************************************************************************************/
00445 
00446 BOOL PointersTab::UngreySection()
00447 {
00448 TRACEUSER( "Neville", _T("UngreySection in PointersTab section\n"));
00449     ERROR2IF(pPrefsDlg == NULL,FALSE,"PointersTab::UngreySection called with no dialog pointer");
00450 
00451     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_POINTERS));  // The PointersTab identifier
00452     if (!ok)
00453         return TRUE;    // Talk to page failed to return now
00454 
00455     // Only update if we are not already ungrey 
00456     if (GreyStatus == FALSE)
00457         return TRUE;
00458 
00459     // Call our central greying/ungreying function
00460     ok = ChangeControlStatus(TRUE);
00461     
00462     GreyStatus = FALSE;
00463 
00464     return ok;
00465 }
00466 
00467 /********************************************************************************************
00468 
00469 >   BOOL PointersTab::ChangeControlStatus(const BOOL Status)
00470 
00471     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00472     Created:    14/3/95
00473     Inputs:     -
00474     Outputs:    -
00475     Returns:    -
00476     Purpose:    Called to grey/ungrey all controls on this tab. 
00477     Errors:     -
00478     SeeAlso:    PointersTab::GreySection;   PointersTab::UngreySection;
00479 
00480 ********************************************************************************************/
00481 
00482 BOOL PointersTab::ChangeControlStatus(const BOOL Status)
00483 {
00484     // Grey/ungrey the controls
00485 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_INFO), Status);
00486 
00487 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_BUTTONGRP), Status);
00488 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_LEFTBUTTON), Status);
00489 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_MIDDLEBUTTON), Status);
00490 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_RIGHTBUTTON), Status);
00491 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_LEFTTXT), Status);
00492 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_MIDDLETXT), Status);
00493 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_RIGHTTXT), Status);
00494 //
00495 //  pPrefsDlg->EnableGadget(_R(IDC_OPTS_RESET), Status);
00496     
00497     pPrefsDlg->EnableGadget(_R(IDC_OPTS_MAGNETICGROUP), Status);
00498     pPrefsDlg->EnableGadget(_R(IDC_OPTS_POINTRADIUSTXT), Status);
00499     pPrefsDlg->EnableGadget(_R(IDC_OPTS_LINERADIUSTXT), Status);
00500     pPrefsDlg->EnableGadget(_R(IDC_OPTS_POINTRADIUS), Status);
00501     pPrefsDlg->EnableGadget(_R(IDC_OPTS_LINERADIUS), Status);
00502 
00503     return TRUE;
00504 }           
00505 
00506 /********************************************************************************************
00507 
00508 >   BOOL PointersTab::UpdateSection(String_256 *DocumentName)
00509 
00510     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00511     Created:    14/3/95
00512     Inputs:     Name of document
00513     Outputs:    -
00514     Returns:    -
00515     Purpose:    Called when we have switched to a new document and need to update all the 
00516                 controls on this tab. Should only init the tab if the page is present.  
00517                 The document name allows the info field on the tab to be filled in correctly.
00518     Errors:     -
00519     SeeAlso:    PointersTab::GreySection; PointersTab::UngreySection; PointersTab::InitSection;
00520 
00521 ********************************************************************************************/
00522 
00523 BOOL PointersTab::UpdateSection(String_256 *DocumentName)
00524 {
00525 TRACEUSER( "Neville", _T("PointersTab::UpdateSection\n"));
00526     ERROR2IF(pPrefsDlg == NULL,FALSE,"PointersTab::UpdateSection called with no dialog pointer");
00527 
00528     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_POINTERS));  // The PointersTab identifier
00529     if (!ok)
00530         return TRUE;        // page not present
00531 
00532     // Remove any lists that we have created.
00533     //pPrefsDlg->DeleteAllValues(_R(IDC_OPTS_SIZELIST));
00534 
00535     // Call the normal init section code
00536     // but only need to update the magnetic radii section so do this instead
00537     // Stops excesive updates of the pull down lists.
00538     InitMagneticRadii();
00539 
00540     return TRUE;
00541 }
00542 
00543 
00544 /********************************************************************************************
00545 
00546 >   BOOL PointersTab::HandleMsg(DialogMsg* Msg)
00547 
00548     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00549     Created:    14/3/95
00550     Inputs:     -
00551     Outputs:    -
00552     Returns:    -
00553     Purpose:    Handles all the Edit options tabs messages 
00554     Errors:     -
00555     SeeAlso:    -
00556 
00557 ********************************************************************************************/
00558 
00559 BOOL PointersTab::HandleMsg(DialogMsg* Msg)
00560 {
00561 TRACEUSER( "Neville", _T("PointersTab::HandleMsg\n"));
00562     ERROR2IF(Msg == NULL,FALSE,"PointersTab::Message null message received");
00563     ERROR2IF(pPrefsDlg == NULL,FALSE,"PointersTab::HandleMsg called with no dialog pointer");
00564 
00565     BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_POINTERS));  // The edit page identifier
00566     if (!ok)
00567         return TRUE;        // no page present = handled message
00568     
00569     switch(Msg->DlgMsg)
00570     {
00571         case DIM_CREATE:    // Initialise controls
00572             GreyStatus = FALSE; // we are ungreyed by default
00573             ok = InitSection();
00574             if (!ok)
00575                 InformError();
00576             break;
00577         case DIM_LFT_BN_CLICKED:
00578             OptionsTabs::SetApplyNowState(TRUE);
00579             // A control on the dialog box has been clicked...
00580             if (Msg->GadgetID == _R(IDC_OPTS_RESET))
00581             {
00582                 // Somebody has pressed the reset defaults button
00583                 // Go and call the nice function which resets the values and then
00584                 // update our values again.
00585                 ClickModifiers::RestoreDefaults();
00586                 InitClickLists();
00587             }
00588             break;
00589         case DIM_SELECTION_CHANGED:
00590         case DIM_TEXT_CHANGED:
00591             OptionsTabs::SetApplyNowState(TRUE);
00592             break;
00593         default:
00594             break;
00595     }
00596     return TRUE;
00597 }  
00598 
00599 
00600 /******************************************************************************************
00601 
00602 >   BOOL PointersTab::InitSection()
00603 
00604     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00605     Created:    14/3/95
00606     Inputs:     -
00607     Outputs:    -
00608     Returns:    TRUE if successful, else FALSE
00609     Purpose:    Sets initial values for the Pointers section of the options dialog box.
00610                 This section includes the:-
00611                  - magnetic snap distances
00612                  - click modifier lists
00613     Errors:     -
00614     SeeAlso:    AppPrefsDlg; OptionsTabs;
00615 
00616 ******************************************************************************************/
00617 
00618 BOOL PointersTab::InitSection()
00619 {
00620 TRACEUSER( "Neville", _T("PointersTab::InitSection\n"));
00621     ERROR2IF(pPrefsDlg == NULL,FALSE,"PointersTab::InitSection called with no dialog pointer");
00622 
00623 //  BOOL ReadOk = FALSE;    // Flag to say whether the preference value was read ok 
00624     BOOL ok = TRUE;         // Flag for whether value set up ok 
00625 
00626     // Set up the click lists for the left, right and middle mouse buttons
00627     ok = InitClickLists();
00628     
00629     // Now set up the magnetic radii section 
00630     ok = InitMagneticRadii();
00631 
00632     return TRUE;
00633 }
00634 
00635 /******************************************************************************************
00636 
00637 >   BOOL PointersTab::InitClickLists()
00638 
00639     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00640     Created:    14/3/95
00641     Inputs:     -
00642     Outputs:    -
00643     Returns:    TRUE if successful, else FALSE
00644     Purpose:    Sets initial values for the click modifier lists in the Pointers section
00645                 of the options dialog box.
00646                 Middle button removed for now as nothing seems to use it.
00647     Errors:     -
00648     SeeAlso:    AppPrefsDlg; OptionsTabs;
00649 
00650 ******************************************************************************************/
00651 
00652 BOOL PointersTab::InitClickLists()
00653 {
00654 TRACEUSER( "Neville", _T("InitClickLists\n"));
00655     ERROR2IF(pPrefsDlg == NULL,FALSE,"PointersTab::InitClickLists called with no dialog pointer");
00656 
00657     BOOL ok = TRUE;         // Flag for whether value set up ok 
00658 
00659     // Middle button removed for now as nothing seems to use it.
00660 
00661     // Make sure that the lists are empty
00662     pPrefsDlg->DeleteAllValues(_R(IDC_OPTS_LEFTBUTTON));
00663 //  pPrefsDlg->DeleteAllValues(_R(IDC_OPTS_MIDDLEBUTTON));
00664     pPrefsDlg->DeleteAllValues(_R(IDC_OPTS_RIGHTBUTTON));
00665 
00666     // 0, 1 or 2 indicating Left Middle or Right mouse button
00667     ButtonFunction LeftButton = ClickModifiers::GetButtonFunc(0);
00668 //  ButtonFunction MiddleButton = ClickModifiers::GetButtonFunc(1);
00669     ButtonFunction RightButton = ClickModifiers::GetButtonFunc(2);
00670 
00671     // Safety checks on the current button function values
00672     if (LeftButton < (ButtonFunction)0 || LeftButton >= BUTTFUNC_LAST)
00673        LeftButton = BUTTFUNC_NORMAL;
00674 //  if (MiddleButton < (ButtonFunction)0 || MiddleButton >= BUTTFUNC_LAST)
00675 //     MiddleButton = BUTTFUNC_ZOOMIN;
00676     if (RightButton < (ButtonFunction)0 || RightButton >= BUTTFUNC_LAST)
00677        RightButton = BUTTFUNC_MENU;
00678 
00679     String_32 FunctionName;
00680     ButtonFunction bf = (ButtonFunction)0; // BUTTFUNC_NORMAL; 
00681     for (INT32 i = (INT32)bf ; i < (INT32)BUTTFUNC_LAST; i++)
00682     {
00683         bf = (ButtonFunction)i;
00684         ClickModifiers::GetButtonFuncName(bf, &FunctionName);
00685         pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_LEFTBUTTON), FunctionName);
00686 //      pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_MIDDLEBUTTON), FunctionName);
00687         pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_RIGHTBUTTON), FunctionName);
00688     }
00689     // Set the length of the list
00690     pPrefsDlg->SetComboListLength(_R(IDC_OPTS_LEFTBUTTON));
00691 //  pPrefsDlg->SetComboListLength(_R(IDC_OPTS_MIDDLEBUTTON));
00692     pPrefsDlg->SetComboListLength(_R(IDC_OPTS_RIGHTBUTTON));
00693 
00694     // Set up the default option displayed
00695     ok = pPrefsDlg->SetSelectedValueIndex(_R(IDC_OPTS_LEFTBUTTON), (INT32)LeftButton);
00696 //  ok = pPrefsDlg->SetSelectedValueIndex(_R(IDC_OPTS_MIDDLEBUTTON), (INT32)MiddleButton);
00697     ok = pPrefsDlg->SetSelectedValueIndex(_R(IDC_OPTS_RIGHTBUTTON), (INT32)RightButton);
00698 
00699     return TRUE;
00700 }   
00701 
00702 /******************************************************************************************
00703 
00704 >   BOOL PointersTab::InitMagneticRadii()
00705 
00706     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00707     Created:    24/3/95
00708     Inputs:     -
00709     Outputs:    -
00710     Returns:    TRUE if successful, else FALSE
00711     Purpose:    Sets initial values for the the magnetic radii fields in the Pointers section
00712                 of the options dialog box.
00713     Errors:     -
00714     SeeAlso:    AppPrefsDlg; OptionsTabs;
00715 
00716 ******************************************************************************************/
00717 
00718 BOOL PointersTab::InitMagneticRadii()
00719 {
00720 TRACEUSER( "Neville", _T("InitMagneticRadii\n"));
00721     ERROR2IF(pPrefsDlg == NULL,FALSE,"PointersTab::InitMagneticRadii() called with no dialog pointer");
00722     // All units work off the selected document and so we must do nothing if there is no
00723     // selected document. Check our clas variable to see if this is true or not.
00724     // Units should have been set up by the caller.
00725     if (pDocument == NULL || pSpread == NULL)
00726     {
00727         // If this fails then there is no document and so we must ensure
00728         // things which need a selected document are greyed.
00729         GreySection();
00730         return (TRUE);
00731     }
00732 
00733     // General flags
00734     BOOL ok = TRUE;          
00735     BOOL ReadOk = TRUE;
00736 
00737     // Now the magnetic radii
00738     // These should just be shown in distance measurements rather than scaled distance
00739     // measurements as they define distance on screen rather than on the page. 
00740     INT32 LineRadius = 0;                   
00741     INT32 PointRadius = 0;                  
00742     ReadOk = Camelot.GetPrefValue(TEXT("Magnetic Options"), TEXT("Line Radius"), &LineRadius);
00743     ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_LINERADIUS), CurrentPageUnits, LineRadius, FALSE, -1);
00744     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_EDIT));
00745 
00746     ReadOk = Camelot.GetPrefValue(TEXT("Magnetic Options"), TEXT("Point Radius"), &PointRadius);
00747     ok = pPrefsDlg->SetUnitGadgetValue(_R(IDC_OPTS_POINTRADIUS), CurrentPageUnits, PointRadius, FALSE, -1);
00748     ERROR2IF(!ReadOk,FALSE,_R(IDE_OPTS_READPREF_EDIT));
00749 
00750     return TRUE;
00751 }   
00752 
00753 #endif //webster

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