layerprp.cpp

Go to the documentation of this file.
00001 // $Id: layerprp.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 // 
00099 // LayerPrp.cpp
00100 //
00101 // This file implements the dialogue box that allows the user to set the
00102 // properties of a layer. Brought up from the layer gallery menu item.
00103 
00104 /*
00105 */
00106 
00107 #include "camtypes.h"
00108 
00109 // WEBSTER - markn 15/1/97
00110 // Don't need the layer properties dlg in Webster
00111 //#ifndef WEBSTER
00112 
00113 //#include "barsdlgs.h" // _R(IDD_BARCONTROLSTORE), _R(IDC_BTN_UNITSETUPDLG) ...
00114 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00115 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 
00117 //#include "dialogop.h" // DialogOp header - in camtypes.h [AUTOMATICALLY REMOVED]
00118 //#include "optsres.h"  // error strings
00119 //#include "will.h"     // for _R(IDS_CLOSEDOCS)
00120 //#include "resource.h" // for _R(IDS_CANCEL)
00121 
00122 #include "layerprp.h"
00123 //#include "lyrprop.h"  // tabs for the layer properties
00124 
00125 // The property tabs themselves
00126 #include "prpslyrs.h"   // Layer properties tab handler
00127 #include "prpsgds.h"    // Guides properties tab handler
00128 
00129 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00130 #include "sprdmsg.h"    // spread messages
00131 #include "layermsg.h"   // spread messages
00132 #include "colmsg.h"     // more messages
00133 #include "optsmsgs.h"   // & more
00134 
00135 // This is not compulsory, but you may as well put it in so that the correct version
00136 // of your file can be registered in the .exe
00137 DECLARE_SOURCE("$Revision: 1282 $");
00138 
00139 // An implement to match the Declare in the .h file.
00140 // If you have many classes, it is recommended to place them all together, here at the start of the file
00141 CC_IMPLEMENT_DYNCREATE(LayerPropertyTabsDlg, DialogTabOp)
00142 CC_IMPLEMENT_DYNCREATE(LayerPropertiesDlg, LayerPropertyTabsDlg)
00143 CC_IMPLEMENT_DYNCREATE(GuidePropertiesDlg, LayerPropertyTabsDlg)
00144 
00145 CC_IMPLEMENT_DYNAMIC(LayerPropertyTabs, PropertyTabs)
00146 
00147 // This will get Camelot to display the filename and linenumber of any memory allocations
00148 // that are not released at program exit
00149 #define new CAM_DEBUG_NEW
00150 
00151 // Set up explicit details about this dialog box such as the id and type
00152 const CDlgResID LayerPropertyTabsDlg::IDD                   = _R(IDD_LAYERPROPERTIES); // Dialog box id
00153 //const CDlgMode LayerPropertyTabsDlg::Mode                 = MODAL;    //make it modal for now 
00154 const CDlgMode LayerPropertyTabsDlg::Mode                   = MODELESS; // This dialog is modeless
00155 
00156 LayerPropertyTabs * LayerPropertyTabsDlg::pLayerProperties  = NULL; // pointer to the tab handling class
00157 
00158 
00159 List        LayerPropertyTabs::LayerPropertyTabsList;               // The global list of installed options tabs.
00160 DialogTabOp *LayerPropertyTabs::pPropertiesDlg              = NULL; // link to application options dialog class
00161 
00162 //Layer     *LayerPropertyTabs::pCurrentLayer               = NULL; // Layer we are supposed to be working on
00163 
00164 //BOOL LayerPropertyTabs::ApplyNow                          = FALSE;// True if Apply now should be ungreyed
00165 //BOOL LayerPropertyTabs::InitMessage                       = FALSE;// True if sending init message
00166 
00167 // The following are used to open the specific tab in the options dialog box
00168 UINT32 LayerPropertyTabs::LayersTabNumber               = 0;            // Tab number assigned to the layers tab
00169 UINT32 LayerPropertyTabs::GuidesTabNumber               = 0;            // Tab number assigned to the guides tab
00170 
00171 /******************************************************************************************
00172 
00173 >   LayerPropertyTabsDlg::LayerPropertyTabsDlg(): DialogTabOp(LayerPropertyTabsDlg::IDD, LayerPropertyTabsDlg::Mode) 
00174 
00175 
00176     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00177     Created:    28/9/95
00178     Inputs:     -
00179     Outputs:    -
00180     Returns:    -
00181     Purpose:    LayerPropertyTabsDlg constructor. Creates a non-undoable operation
00182     Errors:     -
00183     SeeAlso:    -
00184 
00185 ******************************************************************************************/
00186 
00187 LayerPropertyTabsDlg::LayerPropertyTabsDlg(): DialogTabOp(LayerPropertyTabsDlg::IDD, LayerPropertyTabsDlg::Mode) 
00188 {
00189     // At present, just:- 
00190     if (pLayerProperties)
00191     {
00192         pLayerProperties->SetApplyNowState(FALSE);      // grey the apply now button
00193         pLayerProperties->SetInitMessageState(FALSE);   // not sending an init message
00194 
00195 
00196         // Set default units
00197         pLayerProperties->SetDefaultUnits();                // set up our default display units
00198 
00199         // Document and spread we are supposed to be working on. Of course none at present.
00200         pLayerProperties->pScopeDocument = NULL;            // Document in use when sending messages
00201         pLayerProperties->SetCurrentDocAndSpread(NULL);
00202     }
00203 }
00204 
00205 /******************************************************************************************
00206 
00207 >   LayerPropertyTabsDlg::LayerPropertyTabsDlg(INT32 StartingPage): DialogTabOp(LayerPropertyTabsDlg::IDD, LayerPropertyTabsDlg::Mode) 
00208 
00209 
00210     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00211     Created:    28/9/95
00212     Inputs:     -
00213     Outputs:    -
00214     Returns:    -
00215     Purpose:    LayerPropertyTabsDlg constructor which allows a starting page to be specified.
00216                 Creates a non-undoable operation
00217     Errors:     -
00218     SeeAlso:    -
00219 
00220 ******************************************************************************************/
00221 
00222 LayerPropertyTabsDlg::LayerPropertyTabsDlg(INT32 StartingPage): DialogTabOp(LayerPropertyTabsDlg::IDD, LayerPropertyTabsDlg::Mode,
00223                                                         CC_RUNTIME_CLASS(DialogOp), StartingPage) 
00224 {
00225     // At present, just:- 
00226     if (pLayerProperties)
00227     {
00228         pLayerProperties->SetApplyNowState(FALSE);      // grey the apply now button
00229         pLayerProperties->SetInitMessageState(FALSE);   // not sending an init message
00230 
00231 
00232         // Set default units
00233         pLayerProperties->SetDefaultUnits();                // set up our default display units
00234 
00235         // Document and spread we are supposed to be working on. Of course none at present.
00236         pLayerProperties->pScopeDocument = NULL;            // Document in use when sending messages
00237         pLayerProperties->SetCurrentDocAndSpread(NULL);
00238     }
00239 }
00240 
00241 /******************************************************************************************
00242 
00243 >   LayerPropertyTabsDlg::~LayerPropertyTabsDlg()
00244 
00245 
00246     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00247     Created:    28/9/95
00248     Inputs:     -
00249     Outputs:    -
00250     Returns:    -
00251     Purpose:    LayerPropertyTabsDlg destructor.
00252     Errors:     -
00253     SeeAlso:    -
00254 
00255 ******************************************************************************************/
00256 
00257 LayerPropertyTabsDlg::~LayerPropertyTabsDlg()
00258 {
00259     // Make sure that we remove our options tabs link to the dialog box class
00260     // as the dialog will now be destroyed
00261     // At present, just:- 
00262     if (pLayerProperties)
00263     {
00264         pLayerProperties->SetTabbedDlg(NULL);
00265     }
00266 }
00267 
00268 /******************************************************************************************
00269 
00270 >   BOOL LayerPropertyTabsDlg::CommitDialogValues()
00271 
00272     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00273     Created:    28/9/95
00274     Inputs:     -
00275     Outputs:    -
00276     Returns:    True if values in dialog box ok, False otherwise.     
00277     Purpose:    Takes the values in the dialog box and sets the return values accordingly
00278                 Called when ok is pressed on the dialog box.
00279     Errors:     -
00280     SeeAlso:    -
00281 
00282 ******************************************************************************************/
00283 
00284 BOOL LayerPropertyTabsDlg::CommitDialogValues()
00285 {
00286     // Ok has been pressed so take the values from the dialog box
00287     BOOL ok = TRUE;
00288     BOOL ValuesOk = TRUE;
00289 
00290     // Make sure that we have set up our class variables so that the tabs know what
00291     // is the current document and spread to work on.
00292     Document *pDocument = Document::GetSelected();
00293     pLayerProperties->SetCurrentDocAndSpread(pDocument);
00294     // Plus the current document units are correct
00295     pLayerProperties->SetUpDocUnits();
00296 
00297     // Go through all the tabs declared to the system in turn
00298     // and tell them to commit the values for their tab
00299     LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
00300 
00301     while (pLayerPropertyTabs != NULL)
00302     {
00303         // Only get the tab to commit if it is in use
00304         if ( pLayerPropertyTabs->IsPropertyRequired() )
00305         {
00306             // Get the found page to commit its values.
00307             // Should return False if reported error and we should just fail.
00308             //               2 if set an error which we should report and then fail. 
00309             ok = pLayerPropertyTabs->CommitSection();
00310             if ( ok != TRUE)
00311             {
00312                 if (ok == 2)
00313                     InformError();          // If error required show it.
00314 
00315                 // Carry on with other pages so that report all errors and have a chance
00316                 // to correct mistakes in other pages but make note of error state.
00317                 ValuesOk = FALSE;   
00318             }
00319         }
00320         // Get the next option's tab.
00321         pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
00322     }
00323 
00324     // Return whether we found bad values or not.
00325     return ValuesOk;
00326 }
00327 
00328 /******************************************************************************************
00329 
00330 >   MsgResult LayerPropertyTabsDlg::Message(CDlgMessage DlgMsg, CGadgetID Gadget) 
00331 
00332 
00333     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00334     Created:    28/9/95
00335     Inputs:     -
00336     Outputs:    -
00337     Returns:    OK            Message handled ok (return this even if you don't need to 
00338                               respond to the message). 
00339 
00340                 FAIL          Something terrible happened whilst processing the message
00341                               eg. we ran out of memory. You must set ERROR if you
00342                               are returning this value. 
00343 
00344                 EAT_MSG       The Message was handled ok but don't send it to any
00345                               more MessageHandlers. 
00346     Purpose:    Handles all the layer properties dialog's messages
00347     Errors:     -
00348     SeeAlso:    -
00349 
00350 ******************************************************************************************/
00351 
00352 MsgResult LayerPropertyTabsDlg::Message(Msg* Message)
00353 {
00354     ERROR3IF(Message == NULL,"LayerPropertyTabsDlg::Message null message received");
00355     ERROR3IF(pLayerProperties == NULL,"LayerPropertyTabsDlg::Message no pLayerProperties pointer");
00356     
00357     // Cope with document changing messages so that if all documents are closed then
00358     // we take some remedial action such as greying all controls. 
00359     if (MESSAGE_IS_A(Message, DocChangingMsg))
00360     {
00361         DocChangingMsg *TheMsg = (DocChangingMsg *) Message;
00362 
00363         switch ( TheMsg->State )
00364         {
00365 //          case DocChangingMsg::TITLECHANGED:
00366             case DocChangingMsg::SELCHANGED:
00367             {
00368                 // In the different cases there are different document pointers that
00369                 // we must use.
00370                 Document *pDocument = NULL;
00371                 if (TheMsg->State == DocChangingMsg::TITLECHANGED)
00372                 {
00373                     // Document title has changed message.
00374                     pDocument = TheMsg->pChangingDoc;
00375                 }
00376                 else
00377                 {
00378                     // Document selection changed.
00379                     pDocument = TheMsg->pNewDoc;
00380                 }
00381                             
00382                 // Make sure that we have set up our class variables so that the 
00383                 // tabs know what is the current document and spread to work on.
00384                 pLayerProperties->SetCurrentDocAndSpread(pDocument);
00385                 // Plus the current document units are correct
00386                 pLayerProperties->SetUpDocUnits();
00387 
00388                 // Is the new one null ==> no new document
00389                 if (pDocument == NULL)
00390                 {
00391                     // Now go through all the tabs declared to the system
00392                     // And call a function to get them to update themselves.
00393                     LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
00394 
00395                     while (pLayerPropertyTabs != NULL)
00396                     {
00397                         // Only get the tab to update if it is in use
00398                         if ( pLayerPropertyTabs->IsPropertyRequired() )
00399                         {
00400                             // Get that tab to update itself.
00401                             pLayerPropertyTabs->GreySection();
00402                         }
00403 
00404                         // Get the next option's tab.
00405                         pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
00406                     }
00407                 }
00408                 else
00409                 {
00410                     // Now go through all the tabs declared to the system
00411                     // And call a function to get them to update themselves.
00412                     LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
00413 
00414                     while (pLayerPropertyTabs != NULL)
00415                     {
00416                         // Only get the tab to update if it is in use
00417                         if ( pLayerPropertyTabs->IsPropertyRequired() )
00418                         {
00419                             // Get that tab to update itself.
00420                             pLayerPropertyTabs->UngreySection();
00421                         }
00422                         // Get the next option's tab.
00423                         pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
00424                     }
00425                 }
00426             }
00427             break;
00428             
00429             // This message is sent when a new or just opened document is stable.
00430             // Selection messages no good as the template document is loaded into
00431             // the same document and hence the selected document/spread/view does
00432             // not change and so we do not get the last update.
00433             // Could cache all messages from BORN to this and only update on this.
00434             case DocChangingMsg::BORNANDSTABLE:
00435             {
00436                 // In the different cases there are different document pointers that
00437                 // we must use, in this case the changing doc is relevent.
00438                 Document *pDocument = NULL;
00439                 pDocument = TheMsg->pChangingDoc;
00440                 if (pDocument != NULL)
00441                 {
00442                     // Now go through all the tabs declared to the system
00443                     // And call a function to get them to update themselves.
00444                     // Work out the document name and pass this to the tab so that it has
00445                     // chance to fill in its info field ok.
00446                     pLayerProperties->SetCurrentDocAndSpread(pDocument);
00447 
00448                     LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
00449 
00450                     while (pLayerPropertyTabs != NULL)
00451                     {
00452                         // Only get the tab to update if it is in use
00453                         if ( pLayerPropertyTabs->IsPropertyRequired() )
00454                         {
00455                             // Get that tab to update itself.
00456                             pLayerPropertyTabs->UpdateSection();
00457                         }
00458 
00459                         // Get the next option's tab.
00460                         pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
00461                     }
00462                 }
00463             }
00464             break;
00465             default:
00466                 break;
00467         }
00468     }
00469 
00470 
00471     // Cope with document view changing messages so that we allow all the tabs to update
00472     // themselves when switching to a new view.
00473     // Unfortunately, at present if we sit on the DocView changing message and wait for
00474     // a selection then at this point there is NO SELECTED spread and so things will fail.
00475     // Therefore, wait for a selected spread message  
00476     if (MESSAGE_IS_A(Message, DocViewMsg))
00477     {
00478         DocViewMsg *TheMsg = (DocViewMsg *) Message;
00479 
00480         switch ( TheMsg->State )
00481         {
00482             case DocViewMsg::SELCHANGED:
00483             {
00484                 if (TheMsg->pNewDocView != NULL)
00485                 {
00486                     // Now go through all the tabs declared to the system
00487                     // And call a function to get them to update themselves.
00488                     // Work out the document name and pass this to the tab so that it has
00489                     // chance to fill in its info field ok.
00490                     Document *pDocument = TheMsg->pNewDocView->GetDoc();
00491                     pLayerProperties->SetCurrentDocAndSpread(pDocument);
00492 
00493                     LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
00494 
00495                     while (pLayerPropertyTabs != NULL)
00496                     {
00497                         // Only get the tab to update if it is in use
00498                         if ( pLayerPropertyTabs->IsPropertyRequired() )
00499                         {
00500                             // Get that tab to update itself.
00501                             pLayerPropertyTabs->UpdateSection();
00502                         }
00503 
00504                         // Get the next option's tab.
00505                         pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
00506                     }
00507                 }
00508             }
00509             break;
00510             default:
00511                 break;
00512         }
00513     }
00514 
00515     // Cope with document view changing messages so that we allow all the tabs to update
00516     // themselves when switching to a new view.
00517     // Unfortunately, at present if we sit on the DocView changing message and wait for
00518     // a selection then at this point there is NO SELECTED spread and so things will fail.
00519     // Therefore, wait for a selected spread message  
00520     if (MESSAGE_IS_A(Message, SpreadMsg))
00521     {
00522         SpreadMsg *TheMsg = (SpreadMsg *) Message;
00523 
00524         switch ( TheMsg->Reason )
00525         {
00526             // The selected spread has changed
00527             case SpreadMsg::SELCHANGED:
00528             {
00529                 // pOldSpread = ptr to the old selected spread
00530                 // pNewSpread = ptr to the new selected spread
00531                 if (TheMsg->pNewSpread != NULL)
00532                 {
00533                     // Now go through all the tabs declared to the system
00534                     // And call a function to get them to update themselves.
00535                     // Work out the document name and pass this to the tab so that it has
00536                     // chance to fill in its info field ok.
00537                     Document *pDocument = (Document *)TheMsg->pNewSpread->FindOwnerDoc();
00538                     pLayerProperties->SetCurrentDocAndSpread(pDocument);
00539 
00540                     LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
00541 
00542                     while (pLayerPropertyTabs != NULL)
00543                     {
00544                         // Only get the tab to update if it is in use
00545                         if ( pLayerPropertyTabs->IsPropertyRequired() )
00546                         {
00547                             // Get that tab to update itself.
00548                             pLayerPropertyTabs->UpdateLayerSection();
00549                         }
00550 
00551                         // Get the next option's tab.
00552                         pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
00553                     }
00554                 }
00555             }
00556             break;
00557 
00558 /*          // The layers of a spread have changed.
00559             case SpreadMsg::LAYERCHANGES:
00560             {
00561                 // pOldSpread = pNewSpread = spread whose layers have changed
00562                 if (TheMsg->pNewSpread != NULL)
00563                 {
00564                     // Now go through all the tabs declared to the system
00565                     // And call a function to get them to update themselves.
00566                     // Work out the document name and pass this to the tab so that it has
00567                     // chance to fill in its info field ok.
00568                     Document *pDocument = (Document *)TheMsg->pNewSpread->FindOwnerDoc();
00569                     PropertyTabs::SetCurrentDocAndSpread(pDocument);
00570 
00571                     LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
00572 
00573                     while (pLayerPropertyTabs != NULL)
00574                     {
00575                         // Only get the tab to update if it is in use
00576                         if ( pLayerPropertyTabs->IsPropertyRequired() )
00577                         {
00578                             // Get that tab to update itself.
00579                             pLayerPropertyTabs->UpdateLayerSection();
00580                         }
00581 
00582                         // Get the next option's tab.
00583                         pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
00584                     }
00585                 }
00586             }
00587             break;
00588 */
00589             default:
00590                 break;
00591         }
00592     }
00593 
00594     // Copes with a layer changing method
00595     if (MESSAGE_IS_A(Message, LayerMsg))
00596     {
00597         LayerMsg *TheMsg = (LayerMsg *) Message;
00598 
00599         switch ( TheMsg->Reason )
00600         {
00601             // The active layer has changed.
00602             case LayerMsg::ACTIVE_LAYER_CHANGED:
00603             {
00604                 if (TheMsg->pNewLayer != NULL)
00605                 {
00606                     // Now go through all the tabs declared to the system
00607                     // And call a function to get them to update themselves.
00608                     pLayerProperties->SetActiveLayer(TheMsg->pNewLayer);
00609 
00610                     LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
00611 
00612                     while (pLayerPropertyTabs != NULL)
00613                     {
00614                         // Only get the tab to update if it is in use
00615                         if ( pLayerPropertyTabs->IsPropertyRequired() )
00616                         {
00617                             // Get that tab to update itself.
00618                             pLayerPropertyTabs->UpdateLayerSection();
00619                         }
00620 
00621                         // Get the next option's tab.
00622                         pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
00623                     }
00624                 }
00625             }
00626             break;
00627 
00628             case LayerMsg::GUIDELINES_CHANGED:
00629             {
00630                 // Only pass on if the layer that's changed is the same as the layer we consider
00631                 // to be the active layer.
00632                 if (TheMsg->pNewLayer == pLayerProperties->GetGuideLayer())
00633                 {
00634                     LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
00635 
00636                     while (pLayerPropertyTabs != NULL)
00637                     {
00638                         // Only get the tab to update if it is in use
00639                         if ( pLayerPropertyTabs->IsPropertyRequired() )
00640                         {
00641                             // Get that tab to update itself.
00642                             pLayerPropertyTabs->UpdateGuidelineSection();
00643                         }
00644 
00645                         // Get the next option's tab.
00646                         pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
00647                     }
00648                 }
00649             }
00650             break;
00651             default:
00652                 break;
00653         }
00654     }
00655 
00656     // Cope with a new units messages so that we give the options tabs a chance to
00657     // update themselves to display using the newly specified defaults.
00658     if (MESSAGE_IS_A(Message, OptionsChangingMsg))
00659     {
00660         OptionsChangingMsg *TheMsg = (OptionsChangingMsg *) Message;
00661 
00662         // Make sure that we have set up our class variables so that the tabs know what
00663         // is the current document and spread to work on.
00664         Document *pDocument = Document::GetSelected();
00665         pLayerProperties->SetCurrentDocAndSpread(pDocument);
00666         // Plus the current document units are correct
00667         pLayerProperties->SetUpDocUnits();
00668 
00669         switch ( TheMsg->State )
00670         {
00671             case OptionsChangingMsg::NEWUNITS:
00672             {
00673                 // Current display units may have changed changed so may need to update
00674                 // any display fields on other tabs which are using units. 
00675                 // Now go through all the tabs declared to the system
00676                 // And call a function to get them to update themselves.
00677                 LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
00678 
00679                 while (pLayerPropertyTabs != NULL)
00680                 {
00681                     // Only get the tab to update if it is in use
00682                     if ( pLayerPropertyTabs->IsPropertyRequired() )
00683                     {
00684                         // Get that tab to update itself.
00685                         pLayerPropertyTabs->NewUnitsInSection();
00686                     }
00687 
00688                     // Get the next option's tab.
00689                     pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
00690                 }
00691                 break;
00692             }
00693             default:
00694                 break;
00695         }
00696     }
00697 
00698     
00699     // Cope with messages for the dialog box
00700     if (IS_OUR_DIALOG_MSG(Message))
00701     {
00702         DialogMsg* Msg = (DialogMsg*)Message;
00703 
00704         MsgResult Result;
00705 
00706         // Main handler for dialog type messages
00707         BOOL EndDialog = FALSE;                     // TRUE if we should quit the dialog
00708         BOOL CommitValues = FALSE;                  // TRUE if we should commit the dialog values
00709         BOOL OldApplyNow = pLayerProperties->GetApplyNowState();    // Old ApplyNow button state  
00710 
00711         // Make sure that we have set up our class variables so that the tabs know what
00712         // is the current document and spread to work on.
00713         Document *pDocument = Document::GetSelected();
00714         pLayerProperties->SetCurrentDocAndSpread(pDocument);
00715         // Plus the current document units are correct
00716         pLayerProperties->SetUpDocUnits();
00717         
00718         // Check if sending init/create message and if so set flag True.
00719         // If True then do not ungrey the ApplyNow button on changing messages
00720         if (Msg->DlgMsg == DIM_CREATE)
00721             pLayerProperties->SetInitMessageState(TRUE);                
00722         
00723         // If the message is not for the main options window then try the tab pages 
00724         BOOL FoundPage = FALSE;
00725         if (Msg->PageID != 0)
00726         {
00727             // Now go through all the tabs declared to the system
00728             // And see if the message is for that page or not.
00729             LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
00730 
00731             while (pLayerPropertyTabs != NULL && !FoundPage)
00732             {
00733                 CDlgResID PageId = pLayerPropertyTabs->GetPageID();
00734                 if (PageId == Msg->PageID)
00735                 {
00736                     // Found the correct page so stop the search and send the message
00737                     // to that page
00738                     pLayerPropertyTabs->HandleMsg(Msg);
00739                     FoundPage = TRUE;
00740                 }
00741                 // Get the next option's tab.
00742                 pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
00743             }
00744         }
00745         else
00746         {
00747             // Main page window
00748             switch (Msg->DlgMsg)
00749             {
00750 //              case DIM_CREATE:        // Creating the main dialog box
00751                     // grey out the apply now button as this should only become enabled when 
00752                     // we have made a change to the dialog box.
00753 //                  pLayerProperties->SetInitMessageState(FALSE);
00754 //                  pLayerProperties->SetApplyNowState(FALSE);
00755 //                  pLayerProperties->GreyApplyNow();
00756 //                  break;
00757                 
00758                 case DIM_COMMIT:        // Want to commit and quit
00759                     EndDialog = TRUE;
00760                     CommitValues = TRUE;
00761                     break;
00762 
00763                 case DIM_SOFT_COMMIT:   // Want to commit
00764                     CommitValues = TRUE;
00765                     break;
00766 
00767                 case DIM_CANCEL:        // Want to quit
00768                     EndDialog = TRUE;
00769                     break;
00770 
00771                 default:
00772                     break;
00773             }
00774         }
00775 
00776         // Commit values here
00777         if (CommitValues)
00778         {
00779             BOOL ok = CommitDialogValues();
00780             // Only unset EndDialog as in SOFT_COMMIT case we do not want to end the
00781             // Operation and hence close the dialog box
00782             if (!ok)
00783             {
00784                 EndDialog = FALSE;  // Values not correct so do not allow exit
00785             }
00786         }
00787 
00788         if ( !OldApplyNow && pLayerProperties->GetApplyNowState()
00789              && !EndDialog && !pLayerProperties->GetInitMessageState() )
00790         {
00791             // Check for a change from apply now being False to it becoming
00792             // True as an item has been changed.
00793             pLayerProperties->UngreyApplyNow();
00794         }
00795 
00796         if ( pLayerProperties->GetApplyNowState() && (Msg->DlgMsg == DIM_SOFT_COMMIT)
00797              && !EndDialog && !pLayerProperties->GetInitMessageState() )
00798         {
00799             // Check for an apply now (DIM_SOFT_COMMIT) being used and the
00800             // apply being True, should always be the case, so that we can reset
00801             // the grey state to False as we are in an unchanged state.
00802             pLayerProperties->SetApplyNowState(FALSE);
00803             pLayerProperties->GreyApplyNow();
00804         }
00805 
00806         // Allow the base class access to the message, it will do the
00807         // DLG_EAT_IF_HUNGRY(Msg) for us
00808 
00809         // Must do this before the Close and End
00810         Result = DialogTabOp::Message(Message);
00811 
00812         // End dialog here
00813         if (EndDialog) 
00814         {
00815             // Make sure that we remove our options tabs link to the dialog box class
00816             // as the dialog will now be destroyed
00817             pLayerProperties->SetTabbedDlg(NULL);
00818         }
00819         
00820         // Check if have been sending an init/create message and if so then set flag False.
00821         // Only do this in the init/create case as we might be sent one of these and then
00822         // be sent other messages whilst in the middle of the init/create message such as
00823         // text changing messages.
00824         if (Msg->DlgMsg == DIM_CREATE)
00825             pLayerProperties->SetInitMessageState(FALSE);               
00826         
00827         // The message was for our dialog box so return that we have handled it, if necessary
00828         //return (DLG_EAT_IF_HUNGRY(Msg)); 
00829         return Result;
00830     }
00831 
00832     if (MESSAGE_IS_A(Message, ColourChangingMsg))
00833     {
00834         ColourChangingMsg *Msg = (ColourChangingMsg *) Message;
00835         BOOL CallColourListChanged = FALSE;
00836         Document* pDoc = NULL;
00837 
00838         switch ( Msg->State )
00839         {
00840             case ColourChangingMsg::LISTDESELECTED:
00841                 pDoc = NULL;
00842                 CallColourListChanged = TRUE;
00843                 break;
00844 
00845             case ColourChangingMsg::LISTPAGED:
00846             case ColourChangingMsg::LISTUPDATED:
00847             case ColourChangingMsg::COLOURUPDATED:
00848             case ColourChangingMsg::COLOURUPDATEDINVISIBLE:
00849                 pDoc = Msg->ScopeDoc;
00850                 CallColourListChanged = TRUE;
00851                 break;
00852             default:
00853                 break;
00854         }
00855 
00856         // Call the ColourListChanged() func is the colour list has changed
00857         if (CallColourListChanged)
00858         {
00859             LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
00860 
00861             while (pLayerPropertyTabs != NULL)
00862             {
00863                 // Only get the tab to update if it is in use
00864                 if ( pLayerPropertyTabs->IsPropertyRequired() )
00865                     pLayerPropertyTabs->ColourListChanged(pDoc);
00866 
00867                 // Get the next option's tab.
00868                 pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
00869             }
00870         }
00871     }
00872 
00873     return DialogTabOp::Message(Message);
00874 }
00875 
00876 /******************************************************************************************
00877 
00878 >   OpState LayerPropertyTabsDlg::GetState(String_256*, OpDescriptor*)
00879 
00880     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00881     Created:    28/9/95
00882     Inputs:     -
00883     Outputs:    -
00884     Returns:    -
00885     Purpose:    LayerPropertyTabsDlg GetState method
00886     Errors:     -
00887     SeeAlso:    -
00888 
00889 ******************************************************************************************/
00890 
00891 OpState LayerPropertyTabsDlg::GetState(String_256*, OpDescriptor*)
00892 {    
00893     OpState OpSt;
00894 
00895     // If the pointer is non-null then it implies that another dialog box is up which
00896     // uses our tab set and so we must force greying of the menu option 
00897     if (pLayerProperties && pLayerProperties->GetTabbedDlg() != NULL)
00898         OpSt.Greyed = TRUE;
00899 
00900     return(OpSt);
00901 }
00902 
00903 
00904 
00905 
00906 /******************************************************************************************
00907 
00908 >   BOOL LayerPropertyTabsDlg::Init()
00909 
00910     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00911     Created:    28/9/95
00912     Inputs:     -
00913     Outputs:    -
00914     Returns:    -
00915     Purpose:    LayerPropertyTabsDlg Init method. Called when the kernel initialises.
00916     Errors:     -
00917     SeeAlso:    -
00918 
00919 ******************************************************************************************/
00920 
00921 BOOL LayerPropertyTabsDlg::Init()
00922 {
00923     BOOL InitOK;
00924 
00925     // Now register ourselves with the dialog system
00926     InitOK = RegisterOpDescriptor(
00927                                 0,                              // Tool ID 
00928                                 _R(IDS_LAYERPROPERTYTABDLG),        // String resource ID
00929                                 CC_RUNTIME_CLASS(LayerPropertyTabsDlg), // Runtime class
00930                                 OPTOKEN_LAYERPROPERTYTABS,      // Token string
00931                                 GetState,                       // GetState function
00932                                 0,                              // help ID
00933                                 _R(IDBBL_LAYERPROPERTYTAB),         // bubble help
00934                                 0, //_R(IDD_BARCONTROLSTORE),           // resource ID
00935                                 0, //_R(IDC_BTN_OPTIONSDLG),                // control ID
00936                                 SYSTEMBAR_ILLEGAL,              // Bar ID
00937                                 TRUE,                           // Recieve system messages
00938                                 FALSE,                          // Smart duplicate operation
00939                                 TRUE,                           // Clean operation
00940                                 0,                              // No vertical counterpart
00941                                 _R(IDS_LAYERPROPERTYTABDLG_ONE),    // String for one copy only error
00942                                 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC) // Auto state flags
00943                                 );
00944 
00945     // Now register ourselves with the dialog system for the units button on the windows
00946     // button bar as well
00947     InitOK = InitOK && RegisterOpDescriptor(
00948                                 0,                              // Tool ID
00949                                 _R(IDS_LAYERPROPERTIESDLG),         // String resource ID
00950                                 CC_RUNTIME_CLASS(LayerPropertiesDlg),   // Runtime class
00951                                 OPTOKEN_LAYERPROPERTIESDLG,     // Token string
00952                                 GetState,                       // GetState function
00953                                 0,                              // help ID
00954                                 _R(IDBBL_LAYERPROPERTIESDLG),       // bubble help
00955                                 0, //_R(IDD_BARCONTROLSTORE),           // resource ID
00956                                 0, //_R(IDC_BTN_UNITSETUPDLG),          // control ID
00957                                 SYSTEMBAR_ILLEGAL,              // Bar ID
00958                                 TRUE,                           // Receive messages
00959                                 FALSE,                          // Smart duplicate operation
00960                                 TRUE,                           // Clean operation
00961                                 NULL,                           // No vertical counterpart
00962                                 _R(IDS_LAYERPROPERTIESDLG_ONE),     // String for one copy only error
00963                                 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC) // Auto state flags                               );
00964                                 );
00965 
00966     // Now register ourselves with the dialog system for the units button on the windows
00967     // button bar as well
00968     InitOK = InitOK && RegisterOpDescriptor(
00969                                 0,                              // Tool ID
00970                                 _R(IDS_GUIDEPROPERTIESDLG),         // String resource ID
00971                                 CC_RUNTIME_CLASS(GuidePropertiesDlg),   // Runtime class
00972                                 OPTOKEN_GUIDEPROPERTIESDLG,     // Token string
00973                                 GetState,                       // GetState function
00974                                 0,                              // help ID
00975                                 _R(IDBBL_GUIDEPROPERTIESDLG),       // bubble help
00976                                 0, //_R(IDD_BARCONTROLSTORE),           // resource ID
00977                                 0, //_R(IDC_BTN_UNITSETUPDLG),          // control ID
00978                                 SYSTEMBAR_ILLEGAL,              // Bar ID
00979                                 TRUE,                           // Receive messages
00980                                 FALSE,                          // Smart duplicate operation
00981                                 TRUE,                           // Clean operation
00982                                 NULL,                           // No vertical counterpart
00983                                 _R(IDS_GUIDEPROPERTIESDLG_ONE),     // String for one copy only error
00984                                 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC) // Auto state flags                               );
00985                                 );
00986 
00987     // Set up any layer property tabs that are required and get our link to them
00988     InitOK = InitOK && LayerPropertyTabs::InitLayerPropertyTabs();  
00989     pLayerProperties = LayerPropertyTabs::GetFirst();
00990 
00991     return (InitOK);
00992 }
00993 
00994 
00995 /******************************************************************************************
00996 
00997 >   void LayerPropertyTabsDlg::Deinit()
00998 
00999     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01000     Created:    28/9/95
01001     Inputs:     -
01002     Outputs:    -
01003     Returns:    -
01004     Purpose:    LayerPropertyTabsDlg Deinit method. Called when the kernel deinitialises.
01005     Errors:     -
01006     SeeAlso:    -
01007 
01008 ******************************************************************************************/
01009 
01010 void LayerPropertyTabsDlg::Deinit()
01011 {
01012     // Remove any options tabs that have been declared to the system.
01013     LayerPropertyTabs::DeinitLayerPropertyTabs();   
01014     pLayerProperties = NULL;
01015 }
01016 
01017 
01018 
01019 /******************************************************************************************
01020 
01021 >   void LayerPropertyTabsDlg::Do(OpDescriptor*)
01022 
01023     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01024     Created:    28/9/95
01025     Inputs:     -
01026     Outputs:    -
01027     Returns:    -
01028     Purpose:    Creates then opens the dialog in response to a request from the user.
01029     Errors:     -
01030     SeeAlso:    -
01031 
01032 ******************************************************************************************/
01033 
01034 void LayerPropertyTabsDlg::Do(OpDescriptor*)
01035 {
01036     BOOL ok;
01037 
01038 //  if (LayerPropertyTabs::pPropertiesDlg != NULL)
01039 //  {
01040 //      ERROR3("LayerPropertyTabsDlg::Do an options tabbed dialog box is already present");
01041 //      return;
01042 //  }
01043 
01044     if (pLayerProperties == NULL)
01045     {
01046         // Could not create the dialog box so call inform error 
01047         ERROR3("LayerPropertyTabsDlg::Do no LayerProperty present");
01048         //InformError();                        // Show user the error
01049         End();                              // End the operation 
01050     }
01051 
01052     // Set up the name that the main dialog page is going to use
01053     String_256 Temp(_R(IDN_LAYERPROPERTYTAB)); 
01054     TitleString = Temp;
01055     SetName(&TitleString);
01056     
01057     // Make sure that our options tabs have a link to the dialog box class
01058     LayerPropertyTabs::SetTabbedDlg(this);
01059     pLayerProperties->SetApplyNowState(FALSE);
01060 
01061     // Make sure that we have set up our class variables so that the tabs know what
01062     // is the current document and spread to work on.
01063     Document *pDocument = Document::GetSelected();
01064     pLayerProperties->SetCurrentDocAndSpread(pDocument);
01065         
01066     // Force the dialog box to be created, as it is non-modal it must be opened if the create
01067     // works ok.
01068     ok = Create();                          // create the dialog box
01069 
01070     if ( ok )
01071     {
01072         // Modal at present so remove the Open()
01073         Open();                             // created ok so open the dialog box up
01074         
01075         // grey out the apply now button as this should only become enabled when we have 
01076         // made a change to the dialog box.
01077         pLayerProperties->SetInitMessageState(FALSE);
01078         pLayerProperties->SetApplyNowState(FALSE);
01079         pLayerProperties->GreyApplyNow();
01080     }
01081     else
01082     {
01083         // Could not create the dialog box so call inform error 
01084         InformError();                      // Show user the error
01085         End();                              // End the operation 
01086     }                   
01087 }
01088 
01089 /******************************************************************************************
01090 
01091 >   BOOL LayerPropertyTabsDlg::RegisterYourPagesInOrderPlease()
01092 
01093     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01094     Created:    28/9/95
01095     Inputs:     -
01096     Outputs:    -
01097     Returns:    return TRUE if all calls to AddAPage returned TRUE, else FALSE
01098     Purpose:    This virtual function will get called to give you a chance to add pages to your
01099                 DialogTabOp. This function will usually make multiple calls to AddAPage to 
01100                 register the initial set of pages to be contained in the tab dialog. The pages
01101                 should all be the same size and be registered in the left to right order in which
01102                 you wish them to appear. 
01103 
01104                 This function get's called directly from the Create method, Don't call it 
01105                 explicitly yourself. If you return FALSE from this method then the Create 
01106                 method will fail. 
01107 
01108     Errors:     -
01109     SeeAlso:    DialogTabOp::AddAPage; DialogOp::Create
01110 
01111 ******************************************************************************************/
01112 
01113 BOOL LayerPropertyTabsDlg::RegisterYourPagesInOrderPlease()
01114 {
01115     BOOL ok = TRUE;
01116 
01117     // Now go through all the tabs declared to the system
01118     LayerPropertyTabs *pLayerPropertyTabs = LayerPropertyTabs::GetFirst();
01119 
01120     while (pLayerPropertyTabs != NULL)
01121     {
01122         // Only add the tab if it is a program based option
01123         if ( pLayerPropertyTabs->IsPropertyRequired() )
01124         {
01125             CDlgResID PageId = pLayerPropertyTabs->GetPageID();
01126             ok = ok && AddAPage(PageId);
01127         }
01128 
01129         // Get the next option's tab.
01130         pLayerPropertyTabs = LayerPropertyTabs::GetNext(pLayerPropertyTabs);
01131     }
01132 
01133     return (ok); 
01134 }
01135 
01136 /******************************************************************************************
01137 
01138 >   static LayerPropertyTabs * LayerPropertyTabsDlg::GetLayerPropertiesTabs(); 
01139 
01140     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01141     Created:    04/12/95
01142     Inputs:     -
01143     Outputs:    -
01144     Returns:    Pointer to the layer property tabs handling class, if any.
01145     Purpose:    Allows somebody to get a Pointer to the layer property tabs handling class. 
01146     Errors:     -
01147     SeeAlso:    -
01148 
01149 ******************************************************************************************/
01150 
01151 LayerPropertyTabs * LayerPropertyTabsDlg::GetLayerPropertiesTabs()
01152 {
01153     return pLayerProperties;
01154 }
01155 
01156 
01157 /******************************************************************************************
01158 
01159 >   LayerPropertiesDlg::LayerPropertiesDlg(): LayerPropertyTabsDlg(1) 
01160 
01161 
01162     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01163     Created:    10/10/95
01164     Inputs:     -
01165     Outputs:    -
01166     Returns:    -
01167     Purpose:    LayerPropertiesDlg constructor. Creates a non-undoable operation.
01168                 Just starts up the LayerPropertyTabsDlg specifying the tab number that it is in the
01169                 list. This has been calculated when the options tabs were declared just to
01170                 be on the safe side.
01171                 Must use a number rather than the ID as this is what MFC's property sheet
01172                 constructors require. 
01173     Errors:     -
01174     SeeAlso:    GuidePropertiesDlg;
01175 
01176 ******************************************************************************************/
01177 
01178 LayerPropertiesDlg::LayerPropertiesDlg(): LayerPropertyTabsDlg( LayerPropertyTabs::LayersTabNumber ) 
01179 {
01180     // At present, just:- do nothing
01181 }
01182 
01183 /******************************************************************************************
01184 
01185 >   GuidePropertiesDlg::GuidePropertiesDlg(): LayerPropertyTabsDlg(1) 
01186 
01187 
01188     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01189     Created:    10/10/95
01190     Inputs:     -
01191     Outputs:    -
01192     Returns:    -
01193     Purpose:    GuidePropertiesDlg constructor. Creates a non-undoable operation.
01194                 Just starts up the LayerPropertyTabsDlg specifying the tab number that it is in the
01195                 list. This has been calculated when the options tabs were declared just to
01196                 be on the safe side.
01197                 Must use a number rather than the ID as this is what MFC's property sheet
01198                 constructors require. 
01199     Errors:     -
01200     SeeAlso:    LayerPropertiesDlg;
01201 
01202 ******************************************************************************************/
01203 
01204 GuidePropertiesDlg::GuidePropertiesDlg(): LayerPropertyTabsDlg( LayerPropertyTabs::GuidesTabNumber ) 
01205 {
01206     // At present, just:- do nothing
01207 }
01208 
01209 
01210 
01211 
01212 
01213 
01214 
01215 
01216 
01217 /******************************************************************************************
01218 ******************************************************************************************/
01219 
01220 // Code to handle a list of options tabs available to the system
01221 
01222 /********************************************************************************************
01223 
01224 >   LayerPropertyTabs::LayerPropertyTabs()
01225 
01226     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01227     Created:    28/9/95
01228     Purpose:    Constructor.
01229     Errors:
01230     SeeAlso:    LayerPropertyTabsDlg;
01231 
01232 ********************************************************************************************/
01233 
01234 LayerPropertyTabs::LayerPropertyTabs()
01235 {
01236     // Ensure our link to the application options dialog box is set to a good default.
01237     pPropertiesDlg = NULL;
01238 
01239     ApplyNow = FALSE;
01240     InitMessage = FALSE;
01241 }
01242 
01243 
01244 /********************************************************************************************
01245 
01246 >   LayerPropertyTabs::Init()
01247 
01248     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01249     Created:    28/9/95
01250     Purpose:    Initialiser.
01251     Errors:
01252     SeeAlso:    LayerPropertyTabsDlg;
01253 
01254 ********************************************************************************************/
01255 
01256 BOOL LayerPropertyTabs::Init()
01257 {
01258     // Do nothing for now.
01259     return TRUE;
01260 }
01261 
01262 
01263 /******************************************************************************************
01264 ******************************************************************************************/
01265 
01266 #define ADD_LAYERPROPERTY(Classname)                                                \
01267     /* Create, initialise and install the specified tab to the options system */    \
01268     pLayerProperty = new Classname;                                                 \
01269     if (pLayerProperty == NULL) return FALSE;                                       \
01270                                                                                     \
01271     if (!pLayerProperty->Init())                                                    \
01272     {                                                                               \
01273         /* Error occured - report it and stop trying to initialise options tab. */  \
01274         delete pLayerProperty;                                                      \
01275         InformError();                                                              \
01276         return TRUE;                                                                \
01277     }                                                                               \
01278                                                                                     \
01279     LayerPropertyTabsList.AddTail(pLayerProperty);
01280 
01281 /******************************************************************************************
01282 ******************************************************************************************/
01283 
01284 /********************************************************************************************
01285 
01286 >   static BOOL LayerPropertyTabs::InitLayerPropertyTabs()
01287 
01288     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01289     Created:    28/9/95
01290     Returns:    TRUE if initialised ok, FALSE if not.
01291     Purpose:    Scans all LayerPropertyTabs to find out which LayerPropertyTabs are available
01292                 for use, and instantiates one of each, and holds them in a list.
01293     Errors:     Out of memory (if a LayerProperty fails to initialise for other reasons then
01294                 an error is reported, but Camelot will still start up ok, i.e. TRUE is 
01295                 returned).
01296     SeeAlso:    LayerProperty
01297 
01298 ********************************************************************************************/
01299 
01300 BOOL LayerPropertyTabs::InitLayerPropertyTabs()
01301 {
01302     // Find the LayerPropertyTabs - the kernel ones are hard-wired.
01303     LayerPropertyTabs *pLayerProperty = NULL;
01304 
01305     // Create, initialise and install the built in LayerPropertyTabs list
01306     ADD_LAYERPROPERTY(LayerPropertiesTab)   // Layer
01307 #ifndef WEBSTER 
01308     ADD_LAYERPROPERTY(GuidesPropertiesTab)  // Guide lines
01309 #endif // WEBSTER
01310 
01311     // We must work out what the units tab number is when used in document mode so
01312     // that we can skip to it directly when using the units button on the tool bar.
01313     INT32 i = 0;
01314 
01315     // Now go through all the tabs declared to the system
01316     pLayerProperty = LayerPropertyTabs::GetFirst();
01317 
01318     while (pLayerProperty != NULL)
01319     {
01320         // Only include the tab if it is a document based option
01321         if ( pLayerProperty->IsPropertyRequired() )
01322         {
01323             if (pLayerProperty->GetPageID() == _R(IDD_TAB_LAYER_PROPERTIES))
01324             {
01325                 LayersTabNumber = i;        // note that tab number
01326             }
01327             else if (pLayerProperty->GetPageID() == _R(IDD_TAB_GUIDELINE_PROPERTIES))
01328             {
01329                 GuidesTabNumber = i;        // note that tab number
01330             }
01331             
01332             i += 1;     // increment the counter 
01333         }
01334 
01335         // Get the next option's tab.
01336         pLayerProperty = LayerPropertyTabs::GetNext(pLayerProperty);
01337     }
01338 
01339     // All ok
01340     return TRUE;
01341 }
01342 
01343 /********************************************************************************************
01344 
01345 >   static BOOL LayerPropertyTabs::DeinitLayerPropertyTabs()
01346 
01347     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01348     Created:    28/9/95
01349     Purpose:    Destroy all the LayerProperty objects.
01350     SeeAlso:    LayerProperty
01351 
01352 ********************************************************************************************/
01353 
01354 BOOL LayerPropertyTabs::DeinitLayerPropertyTabs()
01355 {
01356 //  LayerPropertyTabs *pLayerProperty = NULL;
01357 
01358     // Now, we can get rid of our LayerPropertyTabs
01359     LayerPropertyTabsList.DeleteAll();
01360 
01361     // All ok
01362     return TRUE;
01363 }
01364 
01365 /********************************************************************************************
01366 
01367 >   static BOOL LayerPropertyTabs::DeclareLayerProperty(LayerPropertyTabs *pLayerProperty)
01368 
01369     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01370     Created:    28/9/95
01371     Inputs:     A pointer to a new LayerPropertyTabs class already declared into the system
01372     Returns:    True if tab declared, False if something went wrong. 
01373     Purpose:    A function to declare a new tab to the system.
01374     SeeAlso:    LayerProperty
01375 
01376 ********************************************************************************************/
01377 
01378 BOOL LayerPropertyTabs::DeclareLayerProperty(LayerPropertyTabs *pLayerProperty)
01379 {
01380     // First check to see if somebody has actually declared the pointer to be non null.
01381     if (pLayerProperty == NULL) return FALSE;
01382 
01383     if (!pLayerProperty->Init())
01384     {
01385         /* Error occured - report it and stop trying to initialise the options tab. */
01386         InformError();
01387         return TRUE;
01388     }
01389     LayerPropertyTabsList.AddTail(pLayerProperty);
01390     
01391     // All ok
01392     return TRUE;
01393 }
01394 
01395 /********************************************************************************************
01396 
01397 >   virtual DialogTabOp * LayerPropertyTabs::GetTabbedDlg()
01398 
01399     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01400     Created:    28/9/95
01401     Returns:    Pointer to the main dialog box used by this LayerPropertyTabs, maybe NULL
01402                 if none.
01403     Purpose:    Let the base class know what/where the dialog box handling class is.
01404     SeeAlso:    LayerPropertyTabs::GreyApplyNow(); LayerPropertyTabs::UngreyApplyNow();
01405     Scope:      virtual
01406 
01407 ********************************************************************************************/
01408 
01409 DialogTabOp * LayerPropertyTabs::GetTabbedDlg()
01410 {
01411     // returns a pointer to the main dialog box used by this code
01412     return LayerPropertyTabs::pPropertiesDlg;
01413 }
01414 
01415 /********************************************************************************************
01416 
01417 >   stataic BOOL LayerPropertyTabs::SetTabbedDlg(DialogTabOp * pDlg)
01418 
01419     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01420     Created:    28/9/95
01421     Returns:    Pointer to the main dialog box used by this LayerPropertyTabs, maybe NULL
01422                 if none.
01423     Purpose:    Let the base class know what/where the dialog box handling class is.
01424     SeeAlso:    LayerPropertyTabs::GreyApplyNow(); LayerPropertyTabs::UngreyApplyNow();
01425     Scope:      Static
01426 
01427 ********************************************************************************************/
01428 
01429 BOOL LayerPropertyTabs::SetTabbedDlg(DialogTabOp * pDlg)
01430 {
01431     // returns a pointer to the main dialog box used by this code
01432     pPropertiesDlg = pDlg;
01433     
01434     return TRUE;
01435 }
01436 
01437 /********************************************************************************************
01438 
01439 >   static LayerPropertyTabs *LayerPropertyTabs::GetFirst()
01440 
01441     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01442     Created:    28/9/95
01443     Returns:    Pointer to the first LayerProperty, or NULL if none.
01444     Purpose:    Iterating through the list of LayerPropertyTabs known to Camelot.  This function
01445                 returns the first LayerPropertyTabs.
01446     SeeAlso:    LayerPropertyTabs::GetNext()
01447     Scope:      Static
01448 
01449 ********************************************************************************************/
01450 
01451 LayerPropertyTabs *LayerPropertyTabs::GetFirst()
01452 {
01453     return (LayerPropertyTabs *) LayerPropertyTabsList.GetHead();
01454 }
01455 
01456 /********************************************************************************************
01457 
01458 >   static LayerPropertyTabs *LayerPropertyTabs::GetNext(LayerPropertyTabs *pLayerPropertyTabs)
01459 
01460     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01461     Created:    28/9/95
01462     Inputs:     pLayerPropertyTabs - pointer to the LayerPropertyTabs to be used to get the following
01463                 LayerPropertyTabs.
01464     Returns:    Pointer to the next LayerPropertyTabs, or NULL if none.
01465     Purpose:    Iterating through the list of LayerPropertyTabs known to Camelot.  This function
01466                 returns the next LayerPropertyTabs.
01467     SeeAlso:    LayerPropertyTabs::GetFirst
01468 
01469 ********************************************************************************************/
01470 
01471 LayerPropertyTabs *LayerPropertyTabs::GetNext(LayerPropertyTabs *pLayerPropertyTabs)
01472 {
01473     return (LayerPropertyTabs *) LayerPropertyTabsList.GetNext(pLayerPropertyTabs);
01474 }
01475 
01476 
01477 /********************************************************************************************
01478 
01479 >   virtual BOOL LayerPropertyTabs::GetApplyNowState() const
01480 
01481     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01482     Created:    28/9/95
01483     Inputs:     -
01484     Outputs:    -
01485     Returns:    The current ApplyNow state as either True or False.
01486     Purpose:    Finds out the current state of the apply now button.
01487     Errors:     -
01488     SeeAlso:    SetApplyNowState();
01489 
01490 ********************************************************************************************/
01491 
01492 BOOL LayerPropertyTabs::GetApplyNowState()
01493 {
01494     return ApplyNow;
01495 } 
01496 
01497 /********************************************************************************************
01498 
01499 >   virtual BOOL LayerPropertyTabs::SetApplyNowState(BOOL NewState)
01500 
01501     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01502     Created:    28/9/95
01503     Inputs:     New ApplyNow flag state.
01504     Outputs:    -
01505     Returns:    The old ApplyNow state as either True or False.
01506     Purpose:    Allows the setting of a new ApplyNow state.
01507     Errors:     -
01508     SeeAlso:    GetApplyNowState();
01509 
01510 ********************************************************************************************/
01511 
01512 BOOL LayerPropertyTabs::SetApplyNowState(BOOL NewState)
01513 {
01514     BOOL OldState = ApplyNow;       // note current old state
01515     // Only make the change if we are not in an init message state. As otherwise, when we
01516     // do an init, we will be sent a message to say a control has been changed and then
01517     // try to set the ApplyNow TRUE and hence then try to ungrey the ApplyNow button when
01518     // we shouldn't. 
01519     if (!InitMessage)
01520         ApplyNow = NewState;        // Set up the required new state    
01521 
01522     return OldState;                // return old state to the caller
01523 }
01524 
01525 /********************************************************************************************
01526 
01527 >   virtual BOOL LayerPropertyTabs::GetInitMessageState() const
01528 
01529     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01530     Created:    28/9/95
01531     Inputs:     -
01532     Outputs:    -
01533     Returns:    The current ApplInitMessageyNow state as either True or False.
01534     Purpose:    Finds out whether we are sending/handling an init message or not.
01535     Errors:     -
01536     SeeAlso:    SetApplyNowState();
01537 
01538 ********************************************************************************************/
01539 
01540 BOOL LayerPropertyTabs::GetInitMessageState()
01541 {
01542     return InitMessage;
01543 } 
01544 
01545 /********************************************************************************************
01546 
01547 >   virtual BOOL LayerPropertyTabs::SetInitMessageState(BOOL NewState)
01548 
01549     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01550     Created:    28/9/95
01551     Inputs:     New InitMessage state.
01552     Outputs:    -
01553     Returns:    The old InitMessage state as either True or False.
01554     Purpose:    Allows the setting of a new InitMessage state.
01555     Errors:     -
01556     SeeAlso:    GetInitMessageState();
01557 
01558 ********************************************************************************************/
01559 
01560 BOOL LayerPropertyTabs::SetInitMessageState(BOOL NewState)
01561 {
01562     BOOL OldState = InitMessage;    // note current old state
01563     InitMessage = NewState;         // Set up the required new state    
01564     
01565     return OldState;                // return old state to the caller
01566 }
01567 
01568 /******************************************************************************************
01569 
01570 >   CDlgResID LayerPropertyTabs::GetPageID()()
01571 
01572     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01573     Created:    04/12/95
01574     Inputs:     -
01575     Outputs:    -
01576     Returns:    The dialog ID of this tab section.    
01577     Purpose:    Allows the options dialog code to determine the dialog ID of this section.
01578                 Baseclass version, needs overriding by the tab handlers.
01579     Errors:     -
01580     SeeAlso:    -
01581 
01582 ******************************************************************************************/
01583 
01584 CDlgResID LayerPropertyTabs::GetPageID()
01585 {
01586     return 0;
01587 }
01588 
01589 /******************************************************************************************
01590 
01591 >   BOOL LayerPropertyTabs::CommitSection()
01592 
01593     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01594     Created:    04/12/95
01595     Inputs:     -
01596     Outputs:    -
01597     Returns:    True if values in dialog box ok, False otherwise.     
01598     Purpose:    Takes the values in this tab of the layer properties dialog box.
01599                 Called when ok or apply now is pressed on the main dialog box.
01600                 Baseclass version, needs overriding by the tab handlers.
01601     Errors:     -
01602     SeeAlso:    LayerPropertiesTab::InitSection()
01603 
01604 ******************************************************************************************/
01605 
01606 BOOL LayerPropertyTabs::CommitSection()
01607 {
01608     return TRUE;
01609 }
01610 
01611 /********************************************************************************************
01612 
01613 >   BOOL LayerPropertyTabs::HandleMsg(DialogMsg* Msg)
01614 
01615     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01616     Created:    04/12/95
01617     Inputs:     -
01618     Outputs:    -
01619     Returns:    -
01620     Purpose:    Handles all the messages for this layer property tab
01621                 Baseclass version, needs overriding by the tab handlers.
01622     Errors:     -
01623     SeeAlso:    LayerPropertyTabsDlg; LayerPropertiesTab;
01624 
01625 ********************************************************************************************/
01626 
01627 BOOL LayerPropertyTabs::HandleMsg(DialogMsg* Msg)
01628 {
01629     return TRUE;
01630 }  
01631 /******************************************************************************************
01632 
01633 >   BOOL LayerPropertyTabs::InitSection()
01634 
01635     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01636     Created:    04/12/95
01637     Inputs:     -
01638     Outputs:    -
01639     Returns:    TRUE if successful, else FALSE
01640     Purpose:    Sets initial values for this tab on the layer properties dialog box.
01641                 Baseclass version, needs overriding by the tab handlers.
01642     Errors:     -
01643     SeeAlso:    LayerPropertyTabsDlg; LayerPropertiesTab;
01644 
01645 ******************************************************************************************/
01646 
01647 BOOL LayerPropertyTabs::InitSection()
01648 {
01649     return TRUE;
01650 }  
01651 
01652 /******************************************************************************************
01653 ********************************************************************************************/
01654 
01655 //#endif // WEBSTER

Generated on Sat Nov 10 03:45:37 2007 for Camelot by  doxygen 1.4.4