#include <layerdlg.h>
Inheritance diagram for LayerDlg:
Public Member Functions | |
LayerDlg () | |
LayerDlg constructor. Creates a non-undoable operation. | |
void | Do (OpDescriptor *) |
Creates then opens the dialog. | |
BOOL | Create () |
LayerDlg create method. | |
virtual MsgResult | Message (Msg *Message) |
Handles all the Layer dialog's messages. | |
Static Public Member Functions | |
static BOOL | Init () |
LayerDlg Init method. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
LayerDlg GetState method. | |
Static Public Attributes | |
static const INT32 | IDD = _R(IDD_LAYERDLG) |
static const CDlgMode | Mode = MODELESS |
Private Member Functions | |
BOOL | InitDialog () |
Sets initial dialog values. | |
void | ShowLayerDetails () |
Shows Layer info for the selected Layer. | |
void | ChangeAttribute (CGadgetID Gadget) |
Handles a request to change an attribute of the layer Scope: private. | |
void | DeleteSelectedLayer () |
Deletes the selected Layer. | |
BOOL | CreateNewLayer () |
Creates a new layer, adding it to the end of the layer details list. If a new layer could not be allocated then InformError is called then FALSE returned. | |
void | UpdateLayerID () |
Updates the identifier Scope: private. | |
void | SetSelectedLayer (WORD Index) |
Sets the Indexth layer in the list to be the selected layer. | |
void | SetSelectedLayerActive () |
Sets the selected layer to be the active layer. | |
BOOL | ValidValues () |
To validate the values that the user has input. If the values are not valid then InformError is called to inform the user of the error. | |
Private Attributes | |
LyrDetails * | SelectedLyr |
WORD | SelectedLyrIndex |
WORD | NumLayers |
Definition at line 129 of file layerdlg.h.
|
LayerDlg constructor. Creates a non-undoable operation.
Definition at line 140 of file layerdlg.cpp. 00140 : DialogOp(LayerDlg::IDD, LayerDlg::Mode) 00141 { 00142 00143 }
|
|
Handles a request to change an attribute of the layer Scope: private.
Definition at line 480 of file layerdlg.cpp. 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 }
|
|
LayerDlg create method.
Reimplemented from DialogOp. Definition at line 674 of file layerdlg.cpp. 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 }
|
|
Creates a new layer, adding it to the end of the layer details list. If a new layer could not be allocated then InformError is called then FALSE returned.
Definition at line 375 of file layerdlg.cpp. 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 }
|
|
Deletes the selected Layer.
Definition at line 281 of file layerdlg.cpp. 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 }
|
|
Creates then opens the dialog.
Reimplemented from Operation. Definition at line 708 of file layerdlg.cpp. 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 }
|
|
LayerDlg GetState method.
Definition at line 618 of file layerdlg.cpp. 00619 { 00620 OpState OpSt; 00621 return(OpSt); 00622 }
|
|
LayerDlg Init method.
Reimplemented from SimpleCCObject. Definition at line 641 of file layerdlg.cpp. 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 }
|
|
Sets initial dialog values.
Definition at line 740 of file layerdlg.cpp. 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 }
|
|
Handles all the Layer dialog's messages.
Reimplemented from DialogOp. Definition at line 160 of file layerdlg.cpp. 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 }
|
|
Sets the Indexth layer in the list to be the selected layer.
Definition at line 434 of file layerdlg.cpp. 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 }
|
|
Sets the selected layer to be the active layer.
Definition at line 524 of file layerdlg.cpp. 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 }
|
|
Shows Layer info for the selected Layer.
Definition at line 807 of file layerdlg.cpp. 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 }
|
|
Updates the identifier Scope: private.
Definition at line 337 of file layerdlg.cpp. 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 }
|
|
To validate the values that the user has input. If the values are not valid then InformError is called to inform the user of the error.
Definition at line 571 of file layerdlg.cpp. 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 }
|
|
Definition at line 140 of file layerdlg.h. |
|
Definition at line 141 of file layerdlg.h. |
|
Definition at line 159 of file layerdlg.h. |
|
Definition at line 157 of file layerdlg.h. |
|
Definition at line 158 of file layerdlg.h. |