NameObjectsDlg Class Reference

#include <ngdialog.h>

Inheritance diagram for NameObjectsDlg:

DialogOp BaseNameObjectsDlg Operation DialogOp MessageHandler Operation ListItem MessageHandler CCObject ListItem SimpleCCObject CCObject SimpleCCObject List of all members.

Public Member Functions

 NameObjectsDlg ()
void DoWithParam (OpDescriptor *, OpParam *)
 Creates then opens the dialog.
MsgResult Message (Msg *Message)
 Handles kernel messages for the NameObjectsDlg dialog operation.

Static Public Member Functions

static BOOL Init ()
 Initialises preferences for this class.
static BOOL Init ()
 Declares a preference that allows you to clear memory in delete().
static OpState GetState (String_256 *, OpDescriptor *)
 The usual default GetState function for the NameObjectsDlg dialog operation.

Protected Member Functions

 NameObjectsDlg ()
 Constructs a NameObjectsDlg object, a modeless version of the base class dialog, which creates names of objects in the Attribute gallery.
virtual StringBaseGetDescription (StringBase *pstrDesc)
virtual StringBaseGetSuggestion (StringBase *pstrDesc)
 Works out a suggestion for the name of the selected objects, if any.
virtual UINT32 IsValid (const StringBase &strName)
virtual BOOL DoCommit (const StringBase &strName)
 Applies the name to the selected objects, if any.

Private Member Functions

 CC_DECLARE_DYNCREATE (NameObjectsDlg)

Private Attributes

String_256m_pstrOutputName
BOOL * m_pfOkCancel

Static Private Attributes

static BOOL m_fModeless = FALSE

Detailed Description

Definition at line 155 of file ngdialog.h.


Constructor & Destructor Documentation

NameObjectsDlg::NameObjectsDlg  )  [protected]
 

Constructs a NameObjectsDlg object, a modeless version of the base class dialog, which creates names of objects in the Attribute gallery.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/5/99
See also:
BaseNameObjectsDlg

Definition at line 329 of file ngdialog.cpp.

00330   : BaseNameObjectsDlg(_R(IDD_NAMEDLG_NAME_TEMPLATE), m_fModeless ? MODELESS : MODAL)
00331 {
00332     // Empty.
00333 }

NameObjectsDlg::NameObjectsDlg  ) 
 


Member Function Documentation

NameObjectsDlg::CC_DECLARE_DYNCREATE NameObjectsDlg   )  [private]
 

BOOL NameObjectsDlg::DoCommit const StringBase strName  )  [protected, virtual]
 

Applies the name to the selected objects, if any.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/5/99
Parameters:
strName --- the name to OpApplyNames [INPUTS]
Returns:
TRUE / FALSE --- don't / do close the dialog on returning.
See also:
BaseNameObjectsDlg::Message; OpApplyNames

Implements BaseNameObjectsDlg.

Definition at line 451 of file ngdialog.cpp.

00452 {
00453     // Invoke either OpApplyNameToSel or OpApplyNameToNone, with a single name parameter.
00454     const TCHAR* pszTok = (GetApplication()->FindSelection()->IsEmpty())
00455                                 ? OPTOKEN_APPLY_NAME_TO_NONE
00456                                 : OPTOKEN_APPLY_NAME_TO_SEL;
00457 
00458     // Apply and (do or do not) close the dialog.
00459     OpDescriptor* pDesc = OpDescriptor::FindOpDescriptor((TCHAR*) pszTok);
00460     ERROR3IF(pDesc == 0, "NameObjectsDlg::DoCommit: can't find descriptor");
00461     OpParam param((void *) &strName, 0);
00462     pDesc->Invoke(&param);
00463     return m_fModeless;
00464 }

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

Creates then opens the dialog.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
pOpParam --- pOpParam->Param1 is a pointer to the String_256 to [INPUTS] set the committed value of the dialog to. pOpParam->Param2 is the dialog template to use ie. _R(IDD_NAMEOBJ_NAMEDLG) or _R(IDD_NAMEOBJ_RENAMEDLG). pOpParam->Output is a pointer to the BOOL to set to TRUE if the dialog is OK's, FALSE if it's cancelled.

Reimplemented from Operation.

Definition at line 1833 of file sgname.cpp.

01834 {
01835     // Remember the output parameters.
01836     ERROR3IF(pOpParam == 0, "NameObjectsDlg::DoWithParam: no OpParam");
01837     ERROR3IF(pOpParam->Param1 == 0 || pOpParam->Output == 0,
01838                     "NameObjectsDlg::DoWithParam: no output parameters");
01839 
01840     // Extract the input and output parameters.
01841     m_pstrOutputName = (String_256*) (pOpParam->Param1);
01842     DlgResID = (CDlgResID) pOpParam->Param2;
01843     m_pfOkCancel = (BOOL*) (pOpParam->Output);
01844 
01845     // Try to run the operation.
01846     *m_pfOkCancel = FALSE;
01847     if (!Create())
01848     {
01849         InformError(0, _R(IDS_OK));
01850         End();
01851     }
01852 }

StringBase * NameObjectsDlg::GetDescription StringBase pstrDesc  )  [protected, virtual]
 

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/5/99
Returns:
The input.
Parameters:
pstrDesc --- a description of the selected objects, if any, [OUTPUTS] to be named.
See also:
BaseNameObjectsDlg

Implements BaseNameObjectsDlg.

Definition at line 348 of file ngdialog.cpp.

00349 {
00350     // No objects, one object, some objects.
00351     SelRange* pSel = GetApplication()->FindSelection();
00352     if (pSel->IsEmpty())
00353         pstrDesc->Load(_R(IDS_NAMEDLG_DESCRIBE_NOSELECT));
00354     else
00355         if (pSel->Count() == 1)
00356         {
00357             String_256 desc=pSel->Describe(MENU);
00358             pstrDesc->MakeMsg(_R(IDS_NAMEDLG_DESCRIBE_SELECT), &desc);
00359         }
00360         else
00361         {
00362             String_256 desc=pSel->Describe(STATUS_BAR);
00363             pstrDesc->MakeMsg(_R(IDS_NAMEDLG_DESCRIBE_SELECT_PL), &desc);
00364         }
00365 
00366     return pstrDesc;
00367 }

OpState NameObjectsDlg::GetState String_256 ,
OpDescriptor
[static]
 

The usual default GetState function for the NameObjectsDlg dialog operation.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94

Definition at line 1903 of file sgname.cpp.

01904 {    
01905     OpState OpSt;
01906     return OpSt;
01907 }

StringBase * NameObjectsDlg::GetSuggestion StringBase pstrSuggest  )  [protected, virtual]
 

Works out a suggestion for the name of the selected objects, if any.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/5/99
Parameters:
pstrSuggest --- a suggested name for the selected objects, if any. [OUTPUTS]
Returns:
pstrSuggest, ie. the input.
See also:
BaseNameObjectsDlg

Implements BaseNameObjectsDlg.

Definition at line 382 of file ngdialog.cpp.

00383 {
00384     // Work out what default text to put in the dialog edit-field.
00385     SelRange* pSel = GetApplication()->FindSelection();
00386     if (pSel->IsEmpty())
00387         pstrSuggest->Load(_R(IDS_NAMEDLG_DEFAULT_NAME));
00388     else
00389     {
00390         // Pluralisise / capitalise the selection description.
00391         if (pSel->Count() == 1)
00392         {
00393             *pstrSuggest = pSel->Describe(MENU);
00394             pstrSuggest->toTitle();
00395         }
00396         else
00397             *pstrSuggest = pSel->Describe(STATUS_BAR);
00398     }
00399 
00400     // Make the name unique, if necessary, by appending ascending numerals.
00401     Document* pDoc = Document::GetCurrent();
00402     if (pDoc != 0)
00403     {
00404         NodeSetSentinel* pSentry = pDoc->GetSetSentinel();
00405         if (pSentry != 0)
00406         {
00407             String_256 strBase = *pstrSuggest;
00408             INT32 nAppend = 2;
00409             while (pSentry->GetNameAttr(*pstrSuggest) != 0)
00410                 pstrSuggest->MakeMsg(_R(IDS_NAMEDLG_UNIQUE_MASK), &strBase, nAppend++);
00411         }
00412     }       
00413 
00414     return pstrSuggest;
00415 }

static BOOL NameObjectsDlg::Init void   )  [static]
 

Declares a preference that allows you to clear memory in delete().

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/4/94
Returns:
TRUE if it worked OK, FALSE if not

Reimplemented from SimpleCCObject.

BOOL NameObjectsDlg::Init void   )  [static]
 

Initialises preferences for this class.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/5/99
Returns:
TRUE if successful.
See also:
BaseNameObjectsDlg; InitNamingSystem

Reimplemented from SimpleCCObject.

Definition at line 478 of file ngdialog.cpp.

00479 {
00480     ERROR2IF(!GetApplication()->DeclareSection(TEXT("Name Gallery"), 5) ||
00481              !GetApplication()->DeclarePref(TEXT("Name Gallery"),
00482                                             TEXT("ModelessNameObjects"),
00483                                             &m_fModeless, FALSE, TRUE),
00484              FALSE,
00485              _R(IDE_BAD_INI_FILE));
00486 
00487     return TRUE;
00488 }

UINT32 NameObjectsDlg::IsValid const StringBase strName  )  [protected, virtual]
 

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/5/99
Parameters:
strName --- name to test for suitability [INPUTS]
Returns:
0 if valid (ie. not a name already in use), ID of an error string explaining why if it is not (new names must be _new_, ie. different to any existing ones).
See also:
BaseNameObjectsDlg::Message

Reimplemented from BaseNameObjectsDlg.

Definition at line 431 of file ngdialog.cpp.

00432 {
00433     // All new names must be unique, it's a policy.
00434     return Document::GetSelected()->GetSetSentinel()->GetNameAttr(strName) != 0
00435                         ? _R(IDE_NAMEDLG_NAME_EXISTS) : 0;
00436 }

MsgResult NameObjectsDlg::Message Msg pMessage  )  [virtual]
 

Handles kernel messages for the NameObjectsDlg dialog operation.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94

Reimplemented from DialogOp.

Definition at line 1864 of file sgname.cpp.

01865 {
01866     // A message from the dialog or its gadgets?
01867     if (IS_OUR_DIALOG_MSG(pMessage))
01868     {
01869         DialogMsg* pMsg = (DialogMsg*) pMessage;
01870         switch (pMsg->DlgMsg)
01871         {
01872         case DIM_CREATE:
01873             SetStringGadgetValue(_R(IDC_NAMEOBJ_NAME), m_pstrOutputName);
01874             SetKeyboardFocus(_R(IDC_NAMEOBJ_NAME));
01875             HighlightText(_R(IDC_NAMEOBJ_NAME));
01876             break;
01877             
01878         case DIM_COMMIT:
01879             *m_pstrOutputName = GetStringGadgetValue(_R(IDC_NAMEOBJ_NAME), m_pfOkCancel);
01880             // nobreak;
01881 
01882         case DIM_CANCEL:
01883             Close();
01884             End();
01885             break;
01886         }
01887     }
01888 
01889     // Pass everything on to the base class . . .
01890     return DialogOp::Message(pMessage);
01891 }  


Member Data Documentation

BOOL NameObjectsDlg::m_fModeless = FALSE [static, private]
 

Definition at line 158 of file ngdialog.h.

BOOL* NameObjectsDlg::m_pfOkCancel [private]
 

Definition at line 383 of file sgname.h.

String_256* NameObjectsDlg::m_pstrOutputName [private]
 

Definition at line 382 of file sgname.h.


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