CNameBrushDlg Class Reference

#include <brshname.h>

Inheritance diagram for CNameBrushDlg:

CBaseBrushNameDlg DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject CInitBrushNameDlg List of all members.

Static Public Member Functions

static BOOL Init ()
 Register operation.
static OpState GetState (String_256 *, OpDescriptor *)
 The usual default GetState function for the CNameBrushDlg dialog operation.

Protected Member Functions

 CNameBrushDlg ()
 Constructs a CNameBrushDlg object, a modeless version of the base class dialog, which gets a name for a newly created brush.
virtual StringBaseGetDescription (StringBase *pstrDesc)
 Nothing, at the moment, when I get around to writing some descriptive strings I will add them in here.
virtual StringBaseGetSuggestion (StringBase *pstrDesc)
 Works out a suggestion for the name of the new brush.
virtual UINT32 IsValid (const StringBase &strName)
virtual BOOL DoCommit (const StringBase &strName)
 Invokes the op to apply the name to the brush.
virtual void InitGadgetText (String_32 *pString=NULL, BOOL resizeDialog=TRUE)
 Initialises the text of the gadgets in the dialog.

Private Member Functions

 CC_DECLARE_DYNCREATE (CNameBrushDlg)

Detailed Description

Definition at line 168 of file brshname.h.


Constructor & Destructor Documentation

CNameBrushDlg::CNameBrushDlg  )  [protected]
 

Constructs a CNameBrushDlg object, a modeless version of the base class dialog, which gets a name for a newly created brush.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/2000
See also:
CBaseNameBrushDlg

Definition at line 309 of file brshname.cpp.

00310   : CBaseBrushNameDlg(_R(IDD_BRUSHNAMEDLG), m_bModeless ? MODELESS : MODAL)
00311 {
00312     // Empty.
00313 }


Member Function Documentation

CNameBrushDlg::CC_DECLARE_DYNCREATE CNameBrushDlg   )  [private]
 

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

Invokes the op to apply the name to the brush.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/2000
Parameters:
strName --- the name to apply [INPUTS]
Returns:
TRUE / FALSE --- don't / do close the dialog on returning.
See also:
BaseCNameBrushDlg::Message; OpApplyNames

Implements CBaseBrushNameDlg.

Reimplemented in CInitBrushNameDlg.

Definition at line 483 of file brshname.cpp.

00484 {
00485     // Apply and (do or do not) close the dialog.
00486     OpDescriptor* pDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_CHANGEBRUSHDEF);
00487     
00488     // if we haven't got a brush then error
00489     if (m_BrushHandle == BrushHandle_NoBrush)
00490     {
00491         ERROR3("No brush handle in CNameBrushDlg::DoCommit");
00492         return FALSE;
00493     }
00494 
00495     // our param needs to know the brush handle and new name
00496     ChangeBrushDefOpParam Param;
00497     Param.m_NewBrushName = (String_32)strName;
00498     Param.m_Handle = m_BrushHandle;
00499     Param.ChangeType = CHANGEBRUSH_NAME;
00500 
00501     ERROR3IF(pDesc == 0, "CNameBrushDlg::DoCommit: can't find descriptor");
00502     pDesc->Invoke(&Param);
00503     return m_bModeless;
00504 }

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

Nothing, at the moment, when I get around to writing some descriptive strings I will add them in here.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/2000
Returns:
The input.
Parameters:
what came in! [OUTPUTS]

Implements CBaseBrushNameDlg.

Definition at line 329 of file brshname.cpp.

00330 {
00331     return pstrDesc;
00332 }

OpState CNameBrushDlg::GetState String_256 ,
OpDescriptor
[static]
 

The usual default GetState function for the CNameBrushDlg dialog operation.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/2000

Reimplemented in CInitBrushNameDlg.

Definition at line 537 of file brshname.cpp.

00538 {    
00539     OpState OpSt;
00540     return OpSt;
00541 }

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

Works out a suggestion for the name of the new brush.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/2000
Parameters:
pstrSuggest --- a suggested name for the new brush, if any. [OUTPUTS]
Returns:
pstrSuggest, ie. the input.

Implements CBaseBrushNameDlg.

Definition at line 421 of file brshname.cpp.

00422 {
00423     ERROR2IF(pstrSuggest == NULL, FALSE, "Null input pointer to CNameBrushDlg::GetSuggestion");
00424 
00425     // get the brush component from the document
00426     Document* pDoc = Document::GetCurrent();
00427     ERROR2IF(pDoc == NULL, FALSE, "Wheres the document?");
00428     BrushComponent* pBrushComp = (BrushComponent*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(BrushComponent));
00429     ERROR2IF(pBrushComp == NULL, FALSE, "No brush component");
00430     
00431     if (!pstrSuggest->IsEmpty())
00432         *pstrSuggest = pBrushComp->GetUniqueName((String_32*)pstrSuggest);
00433     else
00434         *pstrSuggest = pBrushComp->GetUniqueName(NULL);
00435 
00436     return pstrSuggest;
00437 }

BOOL CNameBrushDlg::Init void   )  [static]
 

Register operation.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/2000
See also:

Reimplemented from SimpleCCObject.

Reimplemented in CInitBrushNameDlg.

Definition at line 516 of file brshname.cpp.

00517 {  
00518     return RegisterOpDescriptor(0,
00519                                 _R(IDS_OK),
00520                                 CC_RUNTIME_CLASS(CNameBrushDlg),
00521                                 OPTOKEN_NAME_BRUSH_DLG,
00522                                 CNameBrushDlg::GetState,
00523                                 0,                              // help ID
00524                                 0);                             // bubble ID
00525 }   

void CNameBrushDlg::InitGadgetText String_32 pString = NULL,
BOOL  resizeDialog = TRUE
[protected, virtual]
 

Initialises the text of the gadgets in the dialog.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/2000
Parameters:
pString - if you want to suggest a name based on a particular string [INPUTS] then pass a string, defaults to FALSE though so you don't have to
See also:
CBaseBrushNameDlg::Message

Implements CBaseBrushNameDlg.

Reimplemented in CInitBrushNameDlg.

Definition at line 347 of file brshname.cpp.

00348 {
00349     if (pString != NULL)
00350         m_strSuggest = *pString;
00351     SetStringGadgetValue(_R(IDC_EDITBRUSHNAME), *GetSuggestion(&m_strSuggest));
00352     HighlightText(_R(IDC_EDITBRUSHNAME));
00353     SetKeyboardFocus(_R(IDC_EDITBRUSHNAME));
00354 
00355     // change the dialog title to "Enter brush name:"
00356     String_256 Name = TEXT("Enter brush name:");
00357     SetTitlebarName(&Name);
00358 
00359     if (resizeDialog)
00360     {
00361         // what we want to do is shrink the dialog by the size of the label and then hide it
00362         RECT LabelRect;
00363         GetGadgetPosition(_R(IDC_STATICBRUSHGROUP), &LabelRect);
00364         
00365         // hide the label
00366         HideGadget(_R(IDC_STATICBRUSHGROUP), TRUE);
00367 
00368         // get the size of this dialog
00369         RECT DialogRect;
00370         GetWindowPosition(&DialogRect);
00371         
00372         // subtract the size of the label
00373         INT32 Subtract = LabelRect.bottom - LabelRect.top;
00374         DialogRect.bottom -= Subtract;
00375 
00376         // We want to move up the buttons
00377         RECT OkRect;
00378         if (GetGadgetPosition(_R(IDOK), &OkRect))
00379         {
00380             OkRect.top -= Subtract;
00381             OkRect.bottom -= Subtract;
00382             INT32 Width = OkRect.right - OkRect.left;
00383             Width = (Width * 2) / 3;
00384             OkRect.left += Width ;
00385             OkRect.right += Width;
00386             SetGadgetPosition(_R(IDOK), OkRect);
00387         }
00388 
00389         RECT CancelRect;
00390         if (GetGadgetPosition(_R(IDCANCEL), &CancelRect))
00391         {
00392             CancelRect.top -= Subtract;
00393             CancelRect.bottom -= Subtract;
00394             INT32 Width = CancelRect.right - CancelRect.left;
00395             Width = (Width * 2) / 3;
00396             CancelRect.left += Width;
00397             CancelRect.right += Width;
00398             SetGadgetPosition(_R(IDCANCEL), CancelRect);
00399         }
00400 
00401         // Reset the window
00402         SetWindowPosition(DialogRect);
00403         
00404         // Hide the help button
00405         HideGadget(_R(ID_CC_HELP_BUTTON), TRUE);
00406     }
00407 }

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

Author:
Diccon_Yamanaka (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:
CBaseNameBrushDlg::Message

Reimplemented from CBaseBrushNameDlg.

Definition at line 453 of file brshname.cpp.

00454 {
00455     UINT32 NumChars = strName.Length();
00456     if (NumChars > 20)
00457         return _R(IDS_BRUSHNAME_TOOLONG);
00458     // get the brush component from the document
00459     Document* pDoc = Document::GetCurrent();
00460     ERROR2IF(pDoc == NULL, FALSE, "Wheres the document?");
00461     BrushComponent* pBrushComp = (BrushComponent*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(BrushComponent));
00462     ERROR2IF(pBrushComp == NULL, FALSE, "No brush component");
00463     
00464     if (pBrushComp->NameIsUnique(strName))
00465         return 0;
00466 
00467     return _R(IDS_BRUSHNAME_INVALID);
00468 }


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