layerdlg.cpp

Go to the documentation of this file.
00001 // $Id: layerdlg.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 // Implementation of the LayerDlg class
00100 
00101 /* 
00102 */ 
00103 
00104 #include "camtypes.h" 
00105 //#include "ensure.h"   - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "errors.h"  - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "dlgtypes.h"  - in camtypes.h [AUTOMATICALLY REMOVED]
00108 //#include "resource.h"   
00109 //#include "barsdlgs.h"
00110 //#include "simon.h"
00111 //#include "dialogop.h" // DialogOp header  - in camtypes.h [AUTOMATICALLY REMOVED]
00112 #include "dlgmgr.h"   // Dialog manager class    
00113 #include "layerdlg.h"   
00114 #include "mainfrm.h"
00115 //#include "msg.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 #include "layermgr.h"
00117 
00118 CC_IMPLEMENT_DYNCREATE(LayerDlg, DialogOp)   
00119 
00120 const CDlgMode LayerDlg::Mode = MODELESS;           // The dialog is modeless  
00121 const INT32      LayerDlg::IDD  = _R(IDD_LAYERDLG);     // The dialogs ID
00122 
00123 /********************************************************************************************
00124 
00125 >   LayerDlg::LayerDlg(): DialogOp(LayerDlg::IDD, LayerDlg::Mode) 
00126 
00127 
00128     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00129     Created:    13/12/93
00130     Inputs:     -
00131     Outputs:    -
00132     Returns:    -
00133     Purpose:    LayerDlg constructor. Creates a non-undoable operation
00134     Errors:     -
00135     SeeAlso:    -
00136 
00137 ********************************************************************************************/
00138                                                                                 
00139 
00140 LayerDlg::LayerDlg(): DialogOp(LayerDlg::IDD, LayerDlg::Mode) 
00141 {   
00142 
00143 }        
00144 
00145 /********************************************************************************************
00146 
00147 >   MsgResult LayerDlg::Message( CDlgMessage DlgMsg, CGadgetID Gadget)
00148 
00149     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00150     Created:    13/12/93
00151     Inputs:     -
00152     Outputs:    -
00153     Returns:    -
00154     Purpose:    Handles all the Layer dialog's messages 
00155     Errors:     -
00156     SeeAlso:    -
00157 
00158 ********************************************************************************************/
00159 
00160 MsgResult LayerDlg::Message(Msg* Message)
00161 {
00162     if (IS_OUR_DIALOG_MSG(Message))
00163     {
00164         DialogMsg* Msg = (DialogMsg*)Message;
00165         
00166         BOOL EndDialog = FALSE; 
00167         switch (Msg->DlgMsg)
00168         {
00169             case DIM_COMMIT:
00170             {
00171                 EndDialog = ValidValues(); 
00172                 if (EndDialog)
00173                 {
00174                     // commit all changes made 
00175                     //(Document::GetCurrent()->GetLayerMgr()).CommitLayerChanges(); 
00176                     // Reflect changes in rest of interface 
00177                     //(Document::GetCurrent()->GetLayerMgr()).UpdateInterface();       
00178                 }
00179                 break;
00180             }
00181             case DIM_SOFT_COMMIT:
00182             {
00183                 TRACE( _T("Rgt OK handling here\n"));
00184                 break; 
00185             }
00186             case DIM_CANCEL:
00187             {
00188                 // Cancel all changes made to the Layers 
00189                 //if((Document::GetCurrent()->GetLayerMgr()).CancelLayerChanges())
00190                 //{ 
00191                 //  EndDialog = TRUE; 
00192                 //}
00193                 // else InformError will have been called 
00194                 break;
00195             }
00196             case DIM_LFT_BN_CLICKED:
00197             {
00198                 switch (Msg->GadgetID)
00199                 {
00200                     case _R(IDC_NEW):
00201                         CreateNewLayer(); 
00202                         break; 
00203                     case _R(IDC_DELETE):
00204                         DeleteSelectedLayer(); 
00205                         break; 
00206                     default:        
00207                         ChangeAttribute(Msg->GadgetID); 
00208                 }
00209                 break; 
00210             }
00211             case  DIM_SELECTION_CHANGED_COMMIT:
00212             {
00213                 if (Msg->GadgetID == _R(IDC_LAYER_LIST))
00214                 {
00215                     // A double click, make the Layer active 
00216                     // Obtain the index of the selected item
00217                     GetValueIndex(_R(IDC_LAYER_LIST), &SelectedLyrIndex);
00218                     SetSelectedLayer(SelectedLyrIndex); // Sets the selected Layer 
00219                     SetSelectedLayerActive(); 
00220                     // Update the dialog to show the new Layers details 
00221                     ShowLayerDetails();     
00222                 }
00223                 break;
00224             }
00225             case DIM_SELECTION_CHANGED:
00226             {
00227                 if (Msg->GadgetID == _R(IDC_LAYER_LIST))
00228                 {
00229                     // User clicked on new Layer 
00230                     // Obtain the index of the selected item
00231                     GetValueIndex(_R(IDC_LAYER_LIST), &SelectedLyrIndex); 
00232 
00233                     SetSelectedLayer(SelectedLyrIndex); // Sets the selected Layer 
00234 
00235                     // Update the dialog to show the new Layers details 
00236                     ShowLayerDetails();     
00237                 }
00238                 break;  
00239             }
00240             case DIM_TEXT_CHANGED:
00241             {
00242                 if (Msg->GadgetID == _R(IDC_LAYER_ID))
00243                 {
00244                     // User is editing the Layer identifier 
00245                     UpdateLayerID(); 
00246                     break; 
00247                 }
00248             }
00249         }
00250 
00251         if (EndDialog)  // Dialog communication over 
00252         {
00253             Close(); // Close the dialog 
00254             End();  // Destroy dialog 
00255         //  CMainFrame::pInfoBar->EnableLayerControl(); // Enable the infobar's Layer control 
00256         }
00257 //      return (DLG_EAT_IF_HUNGRY(Msg)); 
00258     }
00259 //  return OK;
00260 
00261     // Pass everything on to the base class . . .
00262     return DialogOp::Message(Message);
00263 }  
00264 
00265 
00266 /********************************************************************************************
00267 
00268 >   void LayerDlg::DeleteSelectedLyr()
00269 
00270     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00271     Created:    12/1/94
00272     Inputs:     -
00273     Outputs:    -
00274     Returns:    -
00275     Purpose:    Deletes the selected Layer 
00276     Errors:     -
00277     SeeAlso:    -
00278 
00279 ********************************************************************************************/
00280 
00281 void LayerDlg::DeleteSelectedLayer()
00282 {
00283     ENSURE(NumLayers > 1, "It is illegal delete the final Layer on a spread");
00284     // Delete the selected Layer from the Layer list 
00285     DeleteValue(_R(IDC_LAYER_LIST), FALSE, SelectedLyrIndex); 
00286 
00287     // Flag the Layer as having been deleted 
00288     SelectedLyr->Deleted = TRUE; 
00289     
00290     // If there is a Layer with a z-order one greater than this Layer, then this becomes the 
00291     // selected Layer. Else the Layer with a z-order one less becomes the selected Layer. 
00292 
00293      if ( (SelectedLyrIndex+1) != NumLayers )
00294      {
00295         // There is a Layer with a z-order one greater so select this  
00296         do
00297         {
00298             ENSURE(SelectedLyr != NULL, "Selected Layer is NULL"); 
00299             //SelectedLyr = (LyrDetails*)((Document::GetCurrent()->GetLayerMgr()).LyrDetList.GetNext(SelectedLyr));    
00300         } while ( ((LyrDetails*)SelectedLyr)->Deleted );
00301         // Note there is no need to change the SelectedLyrIndex
00302      }
00303      else 
00304      {
00305         // Select the Layer which has a z-order one less
00306         do
00307         {
00308             ENSURE(SelectedLyr != NULL, "Selected Layer is NULL"); 
00309             //SelectedLyr = (LyrDetails*)((Document::GetCurrent()->GetLayerMgr()).LyrDetList.GetPrev(SelectedLyr));    
00310         } while ( ((LyrDetails*)SelectedLyr)->Deleted );
00311         SelectedLyrIndex--;  
00312      }
00313      ENSURE(SelectedLyr != NULL, "Selected Layer does not exist"); 
00314      SetSelectedValueIndex(_R(IDC_LAYER_LIST), SelectedLyrIndex); // Select the active Layer 
00315      NumLayers--; 
00316      ShowLayerDetails(); 
00317 
00318 
00319 }
00320 
00321 /********************************************************************************************
00322 
00323 >   void LyrMgr::UpdateLyrID()
00324 
00325     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00326     Created:    13/1/94
00327     Inputs:     -
00328     Outputs:    -
00329     Returns:    -
00330     Purpose:    Updates the  identifier 
00331     Scope:      private 
00332     Errors:     -
00333     SeeAlso:    -
00334 
00335 ********************************************************************************************/
00336 
00337 void LayerDlg::UpdateLayerID()
00338 {
00339     BOOL Valid; 
00340     String_256 TempStr; 
00341     TempStr = GetStringGadgetValue(_R(IDC_LAYER_ID), &Valid); 
00342     // Only update if the string has really changed 
00343     if (TempStr != SelectedLyr->Status.StringLayerID)
00344     {
00345         // Update the selected layer's details  
00346         SelectedLyr->Status.StringLayerID = TempStr; 
00347         ENSURE(Valid, "Error when trying to read a string value");
00348         // Replace the list box string with the updated string 
00349         GadgetRedraw(_R(IDC_LAYER_LIST),FALSE); // Turn off drawing until we have finished making changes 
00350         DeleteValue(_R(IDC_LAYER_LIST), FALSE, SelectedLyrIndex); // Delete old value 
00351         SetStringGadgetValue(_R(IDC_LAYER_LIST),&(SelectedLyr->Status.StringLayerID), FALSE, SelectedLyrIndex); 
00352         // Reset the selection 
00353         SetSelectedValueIndex(_R(IDC_LAYER_LIST), SelectedLyrIndex); // Select the active layer 
00354         GadgetRedraw(_R(IDC_LAYER_LIST),TRUE);  
00355     }
00356 }
00357 
00358 /********************************************************************************************
00359 
00360 >   BOOL LayerDlg::CreateNewLayer()
00361 
00362     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00363     Created:    13/1/94
00364     Inputs:     -
00365     Outputs:    -
00366     Returns:    TRUE if successful, else FALSE
00367     Purpose:    Creates a new layer, adding it to the end of the layer details list. If a new
00368                 layer could not be allocated then InformError is called then FALSE returned. 
00369     Errors:     -
00370     Scope:      private
00371     SeeAlso:    -
00372 
00373 ********************************************************************************************/
00374 
00375 BOOL LayerDlg::CreateNewLayer()
00376 {
00377     LyrDetails* LayerDet; 
00378     LayerDet = new LyrDetails(); 
00379     if (LayerDet == NULL)
00380     {
00381         // Inform the error to the user. The error message is set by new
00382         InformError(); 
00383         return FALSE; 
00384     }
00385 
00386     // Initialise default layer values 
00387     LayerDet->Layer = NULL;     // Because the layer node has not yet been created !
00388     LayerDet->New = TRUE;       // A new layer 
00389     LayerDet->Deleted = FALSE; 
00390 
00391     // Default attribute values 
00392     //LayerDet->Status.Flags.Visible = TRUE; 
00393     //LayerDet->Status.Flags.Locked = FALSE; 
00394     //LayerDet->Status.Flags.Active = FALSE; 
00395     //LayerDet->Status.Flags.Printable = TRUE; 
00396     //LayerDet->Status.Flags.Background = FALSE; 
00397 
00398     //LayerDet->Status.StringLayerID = Document::GetCurrent()->GetLayerMgr().CreateUniqueLayerID();
00399     //LayerDet->Status.LayerQualityLevel = 11; 
00400 
00401     // Add the new layer details record to the tail of the layer details list 
00402     //(Document::GetCurrent()->GetLayerMgr()).LyrDetList.AddTail(LayerDet); 
00403 
00404     NumLayers++;
00405     SelectedLyr = LayerDet; // Make the new layer the selected layer 
00406     SelectedLyrIndex = NumLayers-1; 
00407 
00408     // Update the layer list gadget 
00409     
00410     // Add layerID to end of list box 
00411     SetStringGadgetValue(_R(IDC_LAYER_LIST),&(SelectedLyr->Status.StringLayerID)); 
00412     SetSelectedValueIndex(_R(IDC_LAYER_LIST), SelectedLyrIndex); // Select the new layer  
00413 
00414     ShowLayerDetails(); 
00415 
00416     return TRUE; 
00417 }
00418 
00419 /********************************************************************************************
00420 
00421 >   void LayerDlg::SetSelectedLayer(WORD Index)   
00422 
00423     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00424     Created:    12/1/94
00425     Inputs:     Index:  List index of new selected layer 
00426     Outputs:    -
00427     Returns:    -
00428     Purpose:    Sets the Indexth layer in the list to be the selected layer   
00429     Errors:     -
00430     SeeAlso:    -
00431 
00432 ********************************************************************************************/
00433 
00434 void LayerDlg::SetSelectedLayer(WORD Index)   
00435 {
00436 /*
00437     // Find the Indexth layer  
00438     // Traverse the Layer Manager's LyrDetList and add all layer identifiers to the list gadget
00439     List* LyrList = &((Document::GetCurrent()->GetLayerMgr()).LyrDetList); 
00440     ListItem* CurLayerDet = LyrList->GetHead();  
00441     ENSURE(CurLayerDet != NULL, "The LyrDetList is empty"); 
00442 
00443     WORD i =0; 
00444 
00445     while (CurLayerDet != NULL)
00446     {
00447         if (! (((LyrDetails*)CurLayerDet)->Deleted) )   // The layer has not been deleted 
00448         {
00449             if (i ==  Index)
00450             {
00451                 // Found 
00452                 SelectedLyr = (LyrDetails*)CurLayerDet; 
00453                 return; 
00454             }
00455             i++; 
00456         }
00457         CurLayerDet = LyrList->GetNext(CurLayerDet); 
00458     
00459     }
00460     ENSURE(FALSE, "Could not find layer to select"); 
00461 */
00462 }
00463 
00464 /********************************************************************************************
00465 
00466 >   void LayerDlg::ChangeAttribute(CGadgetID Gadget)
00467 
00468     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00469     Created:    11/1/94
00470     Inputs:     Gadget: Gadget ID for the attribute 
00471     Outputs:    -
00472     Returns:    -
00473     Purpose:    Handles a request to change an attribute of the layer 
00474     Scope:      private 
00475     Errors:     -
00476     SeeAlso:    -
00477 
00478 ********************************************************************************************/
00479 
00480 void LayerDlg::ChangeAttribute(CGadgetID Gadget)
00481 {
00482     switch (Gadget)
00483     {
00484         case _R(IDC_VISIBLE):
00485             //SelectedLyr->Status.Flags.Visible = !(SelectedLyr->Status.Flags.Visible);  
00486             break; 
00487         case _R(IDC_LOCKED):
00488             //SelectedLyr->Status.Flags.Locked = !(SelectedLyr->Status.Flags.Locked); 
00489             break; 
00490         case _R(IDC_ACTIVE): 
00491         
00492             SetSelectedLayerActive(); 
00493             break; 
00494         case _R(IDC_GLOBAL):
00495             // Don't know if we are to implement global or not 
00496             //SelectedLyr->Status.Flags.Global = !(SelectedLyr->Status.Flags.Global);  
00497             break; 
00498         case _R(IDC_PRINTABLE):
00499             //SelectedLyr->Status.Flags.Printable = !(SelectedLyr->Status.Flags.Printable);  
00500             break; 
00501         case _R(IDC_BACKGROUND):
00502             //SelectedLyr->Status.Flags.Background = !(SelectedLyr->Status.Flags.Background);  
00503             break; 
00504     
00505     }
00506 
00507 }
00508 
00509 /********************************************************************************************
00510 
00511 >   void LayerDlg::SetSelectedLayerActive()
00512 
00513     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00514     Created:    24/1/94
00515     Inputs:     -
00516     Outputs:    -
00517     Returns:    -
00518     Purpose:    Sets the selected layer to be the active layer
00519     Errors:     -
00520     SeeAlso:    -
00521 
00522 ********************************************************************************************/
00523 
00524 void LayerDlg::SetSelectedLayerActive()
00525 {
00526 /*
00527     // Traverse the Layer Manager's LyrDetList and set all Active flags to FALSE 
00528     List* LyrList = &((Document::GetCurrent()->GetLayerMgr()).LyrDetList); 
00529     ListItem* CurLayerDet = LyrList->GetHead();  
00530     ENSURE(CurLayerDet != NULL, "The LyrDetList is empty"); 
00531     while (CurLayerDet != NULL)
00532     {
00533         ((LyrDetails*)CurLayerDet)->Status.Flags.Active = FALSE; 
00534         CurLayerDet = LyrList->GetNext(CurLayerDet); // Get next layer detail record 
00535     }
00536     SelectedLyr->Status.Flags.Active = TRUE; 
00537     // Disable the Active control
00538     EnableGadget(_R(IDC_ACTIVE), FALSE); 
00539     // Disable the Delete button 
00540     EnableGadget(_R(IDC_DELETE), FALSE); 
00541     // The visible and locked controls are set to their defaults and disabled 
00542     SetLongGadgetValue(_R(IDC_VISIBLE), 1); 
00543     SetLongGadgetValue(_R(IDC_LOCKED), 0); 
00544     EnableGadget(_R(IDC_VISIBLE), FALSE); 
00545     EnableGadget(_R(IDC_LOCKED), FALSE); 
00546     SelectedLyr->Status.Flags.Visible = TRUE; 
00547     SelectedLyr->Status.Flags.Locked = FALSE;   
00548 */
00549 }
00550 
00551 
00552 /********************************************************************************************
00553 
00554 >   BOOL LayerDlg::ValidValues()
00555 
00556     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00557     Created:    2/2/94
00558     Inputs:     -
00559     Outputs:    -
00560     Returns:    TRUE if the values entered in the dialog are valid. 
00561 
00562     Purpose:    To validate the values that the user has input. If the values are not 
00563                 valid then InformError is called to inform the user of the error. 
00564 
00565     Scope:      private 
00566     Errors:     -
00567     SeeAlso:    -
00568 
00569 ********************************************************************************************/
00570 
00571 BOOL LayerDlg::ValidValues()
00572 {
00573 /*
00574     // Check that the names given to the layers are unique 
00575     List* LyrList = &((Document::GetCurrent()->GetLayerMgr()).LyrDetList); 
00576     ListItem* CurLyrDet = LyrList->GetHead(); 
00577     ListItem* CmpLyrDet;  
00578     while (CurLyrDet != NULL) 
00579     {
00580         CmpLyrDet = LyrList->GetHead(); 
00581         while (CmpLyrDet != NULL) 
00582         {
00583             if (CmpLyrDet != CurLyrDet) // We are not looking at the same details structure 
00584             {
00585                 if (((LyrDetails*)CurLyrDet)->Status.StringLayerID == 
00586                     ((LyrDetails*)CmpLyrDet)->Status.StringLayerID)
00587                 {
00588                     // duplicate layer names found, inform the user  
00589                     InformError(_R(IDS_LAYERIDS_NOT_UNIQUE)); 
00590                     return (FALSE); 
00591                 }
00592             }
00593             CmpLyrDet = LyrList->GetNext(CmpLyrDet); 
00594         }
00595         CurLyrDet = LyrList->GetNext(CurLyrDet); // Get next Layer detail record 
00596     }
00597     return(TRUE); 
00598 */
00599 return (TRUE);
00600 } 
00601 
00602 
00603 /********************************************************************************************
00604 
00605 >   OpState LayerDlg::GetState(String_256*, OpDescriptor*)
00606 
00607     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00608     Created:    13/12/93
00609     Inputs:     -
00610     Outputs:    -
00611     Returns:    -
00612     Purpose:    LayerDlg GetState method
00613     Errors:     -
00614     SeeAlso:    -
00615 
00616 ********************************************************************************************/
00617 
00618 OpState LayerDlg::GetState(String_256*, OpDescriptor*)
00619 {    
00620     OpState OpSt;
00621     return(OpSt);
00622 }
00623          
00624 /********************************************************************************************
00625 
00626 >   BOOL LayerDlg::Init()
00627 
00628     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00629     Created:    13/12/93
00630     Inputs:     -
00631     Outputs:    -
00632     Returns:    -
00633     Purpose:    LayerDlg Init method
00634     Errors:     -
00635     SeeAlso:    -
00636 
00637 ********************************************************************************************/
00638 
00639 
00640 
00641 BOOL LayerDlg::Init()
00642 {  
00643     return (TRUE);
00644 /*
00645     return (RegisterOpDescriptor(
00646                                 0,
00647                                 _R(IDS_LAYERDLG), 
00648                                 CC_RUNTIME_CLASS(LayerDlg),
00649                                 OPTOKEN_LAYERDLG,
00650                                 LayerDlg::GetState,
00651                                 0,  // help ID
00652                                 _R(IDBBL_LAYERDLG),
00653                                 0   // bitmap ID
00654                                 )); 
00655 */
00656 }   
00657  
00658 /********************************************************************************************
00659 
00660 >   BOOL LayerDlg::Create()
00661 
00662     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00663     Created:    13/12/93
00664     Inputs:     -
00665     Outputs:    -
00666     Returns:    TRUE if successful, else FALSE
00667     Purpose:    LayerDlg create method 
00668     Errors:     -
00669     SeeAlso:    -
00670 
00671 ********************************************************************************************/
00672 
00673        
00674 BOOL LayerDlg::Create()
00675 {                            
00676     ENSURE(FALSE,"The old layer dlg is now defunct!");
00677     return (FALSE);
00678 
00679     if (DialogOp::Create())
00680     { 
00681         // Set the initial control values 
00682         InitDialog();
00683 
00684         return TRUE; 
00685     }
00686     else
00687     {
00688         return FALSE; 
00689     }
00690 }           
00691 
00692 /********************************************************************************************
00693 
00694 >   void LayerDlg::Do(OpDescriptor*)
00695 
00696     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00697     Created:    13/12/93
00698     Inputs:     -
00699     Outputs:    -
00700     Returns:    -
00701     Purpose:    Creates then opens the dialog 
00702     Errors:     -
00703     SeeAlso:    -
00704 
00705 ********************************************************************************************/
00706 
00707 
00708 void LayerDlg::Do(OpDescriptor*)
00709 {
00710     ENSURE(FALSE,"The old layer dlg is now defunct!");
00711     return;
00712     if (Create())
00713     {
00714         Open();
00715     }
00716     else              // Could not create 
00717     {
00718         InformError();
00719         End();         // End the operation 
00720     }                   
00721 }
00722 
00723 
00724 /********************************************************************************************
00725 
00726 >   BOOL LayerDlg::InitDialog()
00727 
00728     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00729     Created:    17/12/93
00730     Inputs:     -
00731     Outputs:    -
00732     Returns:    -
00733     Purpose:    Sets initial dialog values 
00734     Errors:     -
00735     SeeAlso:    -
00736 
00737 ********************************************************************************************/
00738 
00739 
00740 BOOL LayerDlg::InitDialog()
00741 {   
00742 /*
00743     // Make the OK button dual function 
00744 //  DualFunctionButton(IDOK);
00745     
00746     // Common controls have currently been disabled
00747     //SetGadgetRange(_R(IDC_QUALITY), 1, 11); 
00748 
00749     // Make the Layer list box dragable so that users can change the Z order of the Layers 
00750     //MakeListBoxDragable(_R(IDC_Lyr_LIST));  
00751 
00752     GadgetRedraw(_R(IDC_LAYER_LIST),FALSE); // Turn off drawing until we have finished making changes 
00753                                         // to the gadget. 
00754 
00755     // Traverse the Layer Manager's LyrDetList and add all Layer identifiers to the list gadget
00756     List* LyrList = &((Document::GetCurrent()->GetLayerMgr()).LyrDetList); 
00757     ListItem* CurLyrDet = LyrList->GetHead();  
00758     ENSURE(CurLyrDet != NULL, "The LyrDetList is empty"); 
00759 
00760     WORD i =0; 
00761     NumLayers = 0; 
00762 
00763     while (CurLyrDet != NULL)
00764     {
00765         // Add string to end of list box 
00766         SetStringGadgetValue(_R(IDC_LAYER_LIST),&(((LyrDetails*)CurLyrDet)->Status.StringLayerID)); 
00767         
00768         // If the current Layer is active then make it the selected item 
00769         if (((LyrDetails*)CurLyrDet)->Status.Flags.Active)
00770         {
00771             SelectedLyr = (LyrDetails*)CurLyrDet; // Set the selected Layer 
00772             SelectedLyrIndex = i; 
00773         }
00774 
00775         CurLyrDet = LyrList->GetNext(CurLyrDet); 
00776         i++; 
00777         NumLayers++;    
00778     }
00779 
00780     GadgetRedraw(_R(IDC_LAYER_LIST),TRUE);  // Turn drawing back on 
00781 
00782     SetSelectedValueIndex(_R(IDC_LAYER_LIST), SelectedLyrIndex); // Select the active Layer 
00783     
00784     ShowLayerDetails();                  
00785 
00786     return TRUE; 
00787 */
00788 return (FALSE);
00789 } 
00790 
00791 
00792 /********************************************************************************************
00793 
00794 >   void LayerDlg::ShowLayerDetails()
00795 
00796     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00797     Created:    11/1/94
00798     Inputs:     - 
00799     Outputs:    -
00800     Returns:    -
00801     Purpose:    Shows Layer info for the selected Layer 
00802     Errors:     -
00803     SeeAlso:    -
00804 
00805 ********************************************************************************************/
00806 
00807 void LayerDlg::ShowLayerDetails()
00808 {
00809     ENSURE(SelectedLyr != NULL, "The Selected Layer is NULL"); 
00810     //SetLongGadgetValue(_R(IDC_VISIBLE), (INT32)SelectedLyr->Status.Flags.Visible ? 1: 0);
00811     //SetLongGadgetValue(_R(IDC_LOCKED), (INT32)SelectedLyr->Status.Flags.Locked ? 1: 0);  
00812     //SetLongGadgetValue(_R(IDC_ACTIVE), (INT32)SelectedLyr->Status.Flags.Active ? 1: 0);  
00813     SetLongGadgetValue(_R(IDC_GLOBAL), (INT32) FALSE);                  // Bodge
00814     //SetLongGadgetValue(_R(IDC_PRINTABLE), (INT32)SelectedLyr->Status.Flags.Printable ? 1: 0);  
00815     //SetLongGadgetValue(_R(IDC_BACKGROUND), (INT32)SelectedLyr->Status.Flags.Background ? 1: 0);   
00816     // Disable the quality gadget if global quality is set 
00817     SetStringGadgetValue(_R(IDC_LAYER_ID), &(SelectedLyr->Status.StringLayerID)); 
00818     // Disable the active, visible, and locked gadgets if the Layer is active
00819     //EnableGadget(_R(IDC_ACTIVE), !(SelectedLyr->Status.Flags.Active)); 
00820     //EnableGadget(_R(IDC_VISIBLE), !(SelectedLyr->Status.Flags.Active)); 
00821     //EnableGadget(_R(IDC_LOCKED), !(SelectedLyr->Status.Flags.Active)); 
00822     // Disable the delete gadget if the Layer is active or if there is only one Layer 
00823     //EnableGadget(_R(IDC_DELETE), !(SelectedLyr->Status.Flags.Active  || NumLayers == 1)); 
00824     return;  
00825 }
00826 

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