LayerNameDlg Class Reference

Allows the user to edit the parts of a layer. More...

#include <layergal.h>

Inheritance diagram for LayerNameDlg:

DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 LayerNameDlg ()
 LayerNameDlg constructor. Creates a non-undoable operation.
void DoWithParam (OpDescriptor *, OpParam *)
 Creates then opens the dialog.
BOOL Create ()
 LayerNameDlg create method.
virtual MsgResult Message (Msg *Message)
 Handles all the scale dialog's messages.
void ShowLayerDetails ()
 Shows layer details in the dialog.
void CommitDialogValues ()
 Takes the values in the dialog and sets the Layer object accordingly. Called when the OK button is selected.

Static Public Member Functions

static OpState GetState (String_256 *, OpDescriptor *)
 LayerNameDlg GetState method.
static BOOL Init ()
 LayerNameDlg Init method.
static void StartUp (LayerDlgParam *pParam)
 Starts up a LayerNameDlg using the OPTOKEN_LAYERNAMEDLG op token.

Static Public Attributes

static const INT32 IDD = _R(IDD_LAYER_NAME)
static const CDlgMode Mode = MODAL

Static Private Member Functions

static void CreateUniqueLayerCopyName (const String_256 &strName, String_256 *pCopyName)

Private Attributes

LayerpLayer
SpreadpSpread
OpLayerGalReason Reason

Static Private Attributes

static BOOL IsOpen = FALSE
static LayerNameDlgpLayerNameDlg = NULL

Detailed Description

Allows the user to edit the parts of a layer.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/6/94
See also:
-

Definition at line 385 of file layergal.h.


Constructor & Destructor Documentation

LayerNameDlg::LayerNameDlg  ) 
 

LayerNameDlg constructor. Creates a non-undoable operation.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1346 of file layergal.cpp.

01346                           : DialogOp(LayerNameDlg::IDD, LayerNameDlg::Mode) 
01347 {   
01348     pLayer  = NULL;
01349     pSpread = NULL;
01350 }        


Member Function Documentation

void LayerNameDlg::CommitDialogValues  ) 
 

Takes the values in the dialog and sets the Layer object accordingly. Called when the OK button is selected.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1712 of file layergal.cpp.

01713 {
01714     String_256 NewName;
01715 //  TCHAR* pD = NewName;
01716     BOOL Valid;
01717 
01718     // Get the string from the layer name dialog
01719     NewName = GetStringGadgetValue(_R(IDC_LAYER_NAME),&Valid);
01720 
01721     // If we're changing the layer's name, but the name hasn't changed, 
01722     // return without doing anything
01723     if (Reason == LAYER_CHANGE_NAME)
01724     {
01725         if (pLayer->GetLayerID() == NewName)
01726             return;
01727     }
01728 
01729     // Initialise the param structure
01730     OpLayerGalParam Param(Reason, pSpread);
01731     Param.pLayer = pLayer;
01732 
01733     // Change the name to the new name
01734     Param.Status.StringLayerID = NewName;
01735 
01736     // If we are copying or creating a new the layer, set up the context node 
01737     // and where to place it relative to the context node
01738     if (Reason == LAYER_COPY || Reason == LAYER_NEW)
01739     {
01740         Param.pContextNode  = pSpread;
01741         Param.AttDir        = LASTCHILD;
01742     }
01743 
01744     // Invoke the operation
01745     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_LAYERGALCHANGE); 
01746     if (pOpDesc != NULL)
01747         pOpDesc->Invoke((OpParam*)&Param);
01748     else
01749     {
01750         ERROR3("Couldn't find OPTOKEN_LAYERGALCHANGE op descriptor");
01751     }
01752 }

BOOL LayerNameDlg::Create void   )  [virtual]
 

LayerNameDlg create method.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successful, else FALSE

Errors: -

See also:
-

Reimplemented from DialogOp.

Definition at line 1525 of file layergal.cpp.

01526 {
01527     if (DialogOp::Create())
01528     {
01529         //ShowLayerDetails();
01530         return TRUE;
01531     }
01532     else
01533         return FALSE;
01534 
01535 }

void LayerNameDlg::CreateUniqueLayerCopyName const String_256 strName,
String_256 pCopyName
[static, private]
 

Definition at line 1666 of file layergal.cpp.

01667 {
01668     // First, check for junk inputs.
01669     ERROR3IF(pCopyName == NULL,
01670                 "Null output String_256* in LayerNameDlg::CreateUniqueLayerCopyName");
01671 
01672     // The rest of this function is a complete bodge, because to do this properly would
01673     // mean a rewrite of the brain-damaged way that layers are named, copied, and
01674     // identified as unique.  So what I'm going to do is prepend a "Copy of " string
01675     // and make sure it doesn't overflow when I do.
01676     pCopyName->Load(_R(IDS_LAYERGAL_COPYOF));
01677     String_256 strNewName;
01678     if ((strName.Length() + pCopyName->Length()) >= pCopyName->MaxLength())
01679     {
01680         // We must truncate so it won't overflow.
01681         strName.Left(&strNewName, pCopyName->MaxLength() - pCopyName->Length());
01682     }
01683     else
01684     {
01685         // We don't need to truncate.
01686         strNewName = strName;
01687     }
01688 
01689     // Prepend and return the result.
01690     *pCopyName += strNewName;
01691 }

void LayerNameDlg::DoWithParam OpDescriptor ,
OpParam pOpParam
[virtual]
 

Creates then opens the dialog.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
pOpParam = ptr to a OpLayerGalReason struct, cast as an OpParam* [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 1553 of file layergal.cpp.

01554 {
01555     // If there's already one layer name dlg open, return.
01556     if (LayerNameDlg::IsOpen)
01557         return;
01558 
01559     LayerDlgParam* pParam = (LayerDlgParam*)pOpParam;
01560 
01561     // Why are you creating me. I need to know, God damn it!
01562     Reason = pParam->GetReason();
01563 
01564     // Extract the spread and layer in question
01565     pSpread = pParam->GetSpread();
01566     pLayer  = pParam->GetLayer();
01567 
01568     // If we have a layer but not a spread, find the spread via the given layer
01569     if (pLayer != NULL && pSpread == NULL)
01570         pSpread = pLayer->FindParentSpread();
01571 
01572     BOOL ok=FALSE;
01573     
01574     switch (Reason)
01575     {
01576         // If  we're changing the layer's name or copying it, we need both a layer and a spread
01577         case LAYER_CHANGE_NAME:
01578         case LAYER_COPY:
01579             ERROR3IF(pLayer  == NULL, "I don't have a layer");
01580             ERROR3IF(pSpread == NULL, "I dont' have a spread");
01581             ok = ((pLayer != NULL) && (pSpread != NULL));
01582             break;
01583 
01584         case LAYER_NEW:
01585             ERROR3IF(pSpread == NULL, "I dont' have a spread");
01586             ok = (pSpread != NULL);
01587             break;
01588 
01589         default:
01590             ERROR3("The layer name dialog can't process the given reason");
01591             ok = FALSE;
01592             break;
01593     }
01594 
01595     if (ok) ok = Create();
01596 //  if (ok) Open();
01597 
01598     if (!ok)            // Could not create 
01599     {
01600         InformError(0,_R(IDS_OK));
01601         End();          // End the operation 
01602     }
01603 //  else
01604 //  {
01605 //      LayerNameDlg::IsOpen        = TRUE;
01606 //      LayerNameDlg::pLayerNameDlg = this;
01607 //  }
01608 }

OpState LayerNameDlg::GetState String_256 ,
OpDescriptor
[static]
 

LayerNameDlg GetState method.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1439 of file layergal.cpp.

01440 {    
01441     OpState OpSt;
01442     return(OpSt);
01443 }

BOOL LayerNameDlg::Init void   )  [static]
 

LayerNameDlg Init method.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from SimpleCCObject.

Definition at line 1462 of file layergal.cpp.

01463 {  
01464     return (RegisterOpDescriptor(
01465                                 0,
01466                                 _R(IDS_LAYERNAMEDLG),
01467                                 CC_RUNTIME_CLASS(LayerNameDlg),
01468                                 OPTOKEN_LAYERNAMEDLG,
01469                                 LayerNameDlg::GetState,
01470                                 0,  // help ID
01471                                 0   // bubble ID
01472                                 )
01473             ); 
01474 }   

MsgResult LayerNameDlg::Message Msg Message  )  [virtual]
 

Handles all the scale dialog's messages.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from DialogOp.

Definition at line 1367 of file layergal.cpp.

01368 {
01369     if (IS_OUR_DIALOG_MSG(Message))
01370     {
01371         DialogMsg* Msg = (DialogMsg*)Message;
01372         BOOL EndDialog = FALSE;
01373 
01374         switch (Msg->DlgMsg)
01375         {
01376             case DIM_CREATE:
01377                 ShowLayerDetails();
01378                 LayerNameDlg::IsOpen = TRUE;
01379                 LayerNameDlg::pLayerNameDlg = this;
01380                 SetKeyboardFocus(_R(IDC_LAYER_NAME));
01381                 HighlightText (_R(IDC_LAYER_NAME));
01382                 break;
01383                 
01384             case DIM_COMMIT:
01385                 EndDialog = TRUE;
01386                 CommitDialogValues();
01387                 break;
01388 
01389             case DIM_SOFT_COMMIT:
01390                 //TRACE( _T("Rgt OK handling here\n"));
01391                 break; 
01392 
01393             case DIM_CANCEL:
01394                 EndDialog = TRUE;
01395                 break;
01396 
01397             case DIM_LFT_BN_CLICKED:
01398                 break; 
01399 
01400             case DIM_TEXT_CHANGED:
01401                 break;
01402 
01403             default:
01404                 break;
01405         }
01406 
01407         if (EndDialog)  // Dialog communication over 
01408         {              // Isn't this pretty?
01409             Close();  // Close the dialog 
01410             End();   // Destroy dialog 
01411 
01412             LayerNameDlg::IsOpen        = FALSE;    // We no longer have a current layer name dialog
01413             LayerNameDlg::pLayerNameDlg = NULL;     // so reset the static vars
01414             return (DLG_EAT_IF_HUNGRY(Msg)); 
01415         }
01416     }
01417 //  return OK; 
01418 
01419     // Pass everything on to the base class . . .
01420     return DialogOp::Message(Message);
01421 }  

void LayerNameDlg::ShowLayerDetails  ) 
 

Shows layer details in the dialog.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1626 of file layergal.cpp.

01627 {
01628     String_256 Name;
01629 
01630     switch (Reason)
01631     {
01632         case LAYER_CHANGE_NAME:
01633             Name = pLayer->GetLayerID();
01634             break;
01635 
01636         case LAYER_COPY:
01637             CreateUniqueLayerCopyName(pLayer->GetLayerID(), &Name);
01638             break;
01639             break;
01640 
01641         case LAYER_NEW:
01642             Name = LayerSGallery::CreateUniqueLayerID(pSpread);
01643             break;
01644 
01645         default:
01646             ERROR3("Unknown OpLayerGalReason reason");
01647             break;
01648     }
01649 
01650     SetStringGadgetValue(_R(IDC_LAYER_NAME),Name);
01651 }

void LayerNameDlg::StartUp LayerDlgParam pParam  )  [static]
 

Starts up a LayerNameDlg using the OPTOKEN_LAYERNAMEDLG op token.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
pParam - ptr to all the info the dlg needs in order to do its stuff [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1491 of file layergal.cpp.

01492 {
01493     if (!LayerNameDlg::IsOpen)
01494     {
01495         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_LAYERNAMEDLG); 
01496         if (pOpDesc != NULL)
01497             pOpDesc->Invoke((OpParam*)pParam);
01498         else
01499         {
01500             ERROR3("Couldn't find OPTOKEN_LAYERNAMEDLG op descriptor");
01501         }
01502     }
01503     else if (LayerNameDlg::pLayerNameDlg != NULL)
01504         LayerNameDlg::pLayerNameDlg->BringToTop();
01505         // SetActiveWindow(LayerNameDlg::pLayerNameDlg->WindowID);
01506 }


Member Data Documentation

const INT32 LayerNameDlg::IDD = _R(IDD_LAYER_NAME) [static]
 

Definition at line 394 of file layergal.h.

BOOL LayerNameDlg::IsOpen = FALSE [static, private]
 

Definition at line 413 of file layergal.h.

Action const CDlgMode LayerNameDlg::Mode = MODAL [static]
 

Definition at line 395 of file layergal.h.

Layer* LayerNameDlg::pLayer [private]
 

Definition at line 409 of file layergal.h.

LayerNameDlg * LayerNameDlg::pLayerNameDlg = NULL [static, private]
 

Definition at line 414 of file layergal.h.

Spread* LayerNameDlg::pSpread [private]
 

Definition at line 410 of file layergal.h.

OpLayerGalReason LayerNameDlg::Reason [private]
 

Definition at line 411 of file layergal.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:55:45 2007 for Camelot by  doxygen 1.4.4