ColourNameDlg Class Reference

#include <sgcolour.h>

Inheritance diagram for ColourNameDlg:

DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 ColourNameDlg ()
 ColourNameDlg constructor.
void DoWithParam (OpDescriptor *, OpParam *)
 Creates then opens the dialog.
BOOL Create ()
 ColourNameDlg create method.
virtual MsgResult Message (Msg *Message)
 Handles all the scale dialog's messages.

Static Public Member Functions

static BOOL InvokeDialog (ColourList *Parentlist, IndexedColour *ColourToName)
 Opens the gallery name dialogue on screen, elicits a response, and returns having set the new name. This is a MODAL dlg.
static BOOL InvokeDialog (String_64 *NameToFill, IndexedColour *DisplayColour=NULL)
 Opens the gallery name dialogue on screen, elicits a response, and returns having set the new name. This is a MODAL Dlg.
static OpState GetState (String_256 *, OpDescriptor *)
 ColourNameDlg GetState method.
static BOOL Init ()
 ColourNameDlg Init method. Called by sginit.cpp.

Static Public Attributes

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

Protected Member Functions

void CommitName (void)
 Commits to the current setting for the new name Reads the name into the supplied destination, sets the return value to TRUE and closes and ends the Dlg Op.

Protected Attributes

ColourNameParamInfo

Detailed Description

Definition at line 682 of file sgcolour.h.


Constructor & Destructor Documentation

ColourNameDlg::ColourNameDlg  ) 
 

ColourNameDlg constructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/4/95

Definition at line 4911 of file sgcolour.cpp.


Member Function Documentation

void ColourNameDlg::CommitName void   )  [protected]
 

Commits to the current setting for the new name Reads the name into the supplied destination, sets the return value to TRUE and closes and ends the Dlg Op.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/4/95
Notes: If the result is placed into TheColour, then a ColourChangingMsg broadcast will be sent. Thus, if a caller wants only to rename a colour, they need only call up the dialogue upon that colour - set and forget.

Definition at line 5029 of file sgcolour.cpp.

05030 {
05031     Info->Result = TRUE;
05032 
05033     String_256 NewName = GetStringGadgetValue(_R(IDC_COLNAME_TEXT));
05034 
05035     if (NewName.Length() < 1)   // User gave NULL name. Use 'Unnamed' instead.
05036         NewName.MakeMsg(_R(IDS_UNNAMEDCOLOUR));
05037 
05038     if (Info->TheList != NULL && Info->TheColour != NULL)
05039     {
05040         // We must set the new name for the colour - first make sure it's unique
05041         String_64 UniqueName;
05042         Info->TheList->GenerateUniqueColourName((const StringBase *) &NewName, &UniqueName);
05043 
05044         IndexedColour *NewCol = new IndexedColour(*Info->TheColour);
05045         if (NewCol == NULL)
05046             InformError();
05047         else
05048         {
05049             NewCol->SetName(UniqueName);
05050             ColourManager::ChangeColour(Info->TheList, NewCol, Info->TheColour, TRUE);
05051         }
05052     }
05053     else if (Info->TheName != NULL)
05054     {
05055         // We just copy the string into the result string, truncating at 63 chars
05056         NewName.Left(Info->TheName, 63);
05057     }
05058 
05059     Close();
05060     End();
05061 }

BOOL ColourNameDlg::Create void   )  [virtual]
 

ColourNameDlg create method.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/4/95
Returns:
TRUE if successful, else FALSE

Reimplemented from DialogOp.

Definition at line 5121 of file sgcolour.cpp.

05122 {
05123     return(DialogOp::Create());
05124 }

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

Creates then opens the dialog.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/4/95
Parameters:
pOpParam = ptr to a ColourNameParam struct [INPUTS]

Reimplemented from Operation.

Definition at line 5141 of file sgcolour.cpp.

05142 {
05143     ERROR3IF(pOpParam == NULL, "Come on, play by the rules");
05144 
05145     Info = (ColourNameParam *) pOpParam;
05146 
05147     if (Info->TheColour == NULL && Info->TheName == NULL)
05148     {
05149         ERROR3("ColourNameDlg parameters are unhelpful to say the least");
05150         End();
05151     }
05152 
05153     if (!Create())
05154     {
05155         InformError();
05156         End();
05157     }
05158 }

OpState ColourNameDlg::GetState String_256 ,
OpDescriptor
[static]
 

ColourNameDlg GetState method.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/4/95

Definition at line 5075 of file sgcolour.cpp.

05076 {    
05077     OpState OpSt;
05078     return(OpSt);
05079 }

BOOL ColourNameDlg::Init void   )  [static]
 

ColourNameDlg Init method. Called by sginit.cpp.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/4/95

Reimplemented from SimpleCCObject.

Definition at line 5094 of file sgcolour.cpp.

05095 {  
05096     return (RegisterOpDescriptor(
05097                                 0,
05098                                 _R(IDS_COLOURNAMEDLG),
05099                                 CC_RUNTIME_CLASS(ColourNameDlg),
05100                                 OPTOKEN_COLOURNAMEDLG,
05101                                 ColourNameDlg::GetState,
05102                                 0,  // help ID
05103                                 0   // bubble ID
05104                                 )
05105             ); 
05106 }   

BOOL ColourNameDlg::InvokeDialog String_64 NameToFill,
IndexedColour DisplayColour = NULL
[static]
 

Opens the gallery name dialogue on screen, elicits a response, and returns having set the new name. This is a MODAL Dlg.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/4/95
Returns:
TRUE if the OK button was clicked, FALSE if cancel was clicked
Parameters:
NameToFill - A String_64 containing the default name. This will be [INPUTS] changed to the new nbame to use.
DisplayColour - A colour to be displayed in the dialogue. This is just for the user to look at and say "oooh, pretty!"

This variant gets the name of a new colour. The window indicates that a new colour is being created, and has 'Create' and 'Cancel' buttons. Only if it returns TRUE should you create the colour.

Note that this variant is not 'set and forget'. You have to do something with the returned name.

Notes: DO NOT use this method with the result of a call to the IndexedColour::GetName() function! See the other variant to do this.

If you SetName() a colour already in a colour list, (in which case you should be using the other variant of this method) then you MUST ensure that the name you set is guaranteed to be unique within the list (or export/import will fail).

Definition at line 5242 of file sgcolour.cpp.

05243 {
05244     ERROR3IF(NameToFill == NULL, "Come on, play by the rules");
05245 
05246     ColourNameParam Info(NameToFill, DisplayColour);
05247     OpDescriptor *NameDlg = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(ColourNameDlg));
05248 
05249     ERROR3IF(NameDlg == NULL,
05250             "ColourNameDlg::InvokeDialog is unable to find the Dlg OpDescriptor");
05251 
05252     if (NameDlg != NULL)
05253         NameDlg->Invoke(&Info);
05254 
05255     return(Info.Result);
05256 }

BOOL ColourNameDlg::InvokeDialog ColourList ParentList,
IndexedColour ColourToName
[static]
 

Opens the gallery name dialogue on screen, elicits a response, and returns having set the new name. This is a MODAL dlg.

vAuthor: Jason

Date:
1/4/95
Returns:
TRUE if the OK button was clicked, FALSE if cancel was clicked
Parameters:
ParentList - the list in which the colour resides (not NULL) [INPUTS] ColourToName - the colour whose name should be changed (not NULL)
This variant renames an existing colour. The window indicates that renaming is going to occur, and has 'Apply' and 'Cancel' buttons.

If the name is changed, the colour name will be set (to a name guaranteed to be unique within the colour list), and an appropriate ColourChangingMsg willbe broadcast (i.e. it's a set-and-forget mode)

Definition at line 5188 of file sgcolour.cpp.

05189 {
05190     ERROR3IF(ParentList == NULL || ColourToName == NULL, "Come on, play by the rules");
05191 
05192     ColourNameParam Info(ParentList, ColourToName);
05193     OpDescriptor *NameDlg = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(ColourNameDlg));
05194 
05195     ERROR3IF(NameDlg == NULL,
05196             "ColourNameDlg::InvokeDialog is unable to find the Dlg OpDescriptor");
05197 
05198     if (NameDlg != NULL)
05199         NameDlg->Invoke(&Info);
05200 
05201     return(Info.Result);
05202 }

MsgResult ColourNameDlg::Message Msg Message  )  [virtual]
 

Handles all the scale dialog's messages.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/4/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from DialogOp.

Definition at line 4932 of file sgcolour.cpp.

04933 {
04934     if (IS_OUR_DIALOG_MSG(Message))
04935     {
04936         DialogMsg* Msg = (DialogMsg*)Message;
04937 //      BOOL EndDialog = FALSE;
04938 
04939         switch (Msg->DlgMsg)
04940         {
04941             case DIM_CREATE:
04942                 {
04943                     String_256 Name;
04944 
04945                     if (Info->TheName != NULL)          // Must be creating new colour
04946                     {
04947                         Name.MakeMsg(_R(IDS_COLNAME_CREATE));
04948                         SetStringGadgetValue(_R(IDOK), _R(IDS_COLNAME_YCREATE));
04949                         SetStringGadgetValue(_R(IDC_COLNAME_TEXT), *Info->TheName);
04950                     }
04951                     else if (Info->TheColour != NULL)   // Are renaming existing colour
04952                     {
04953                         Name.MakeMsg(_R(IDS_COLNAME_ALTER));
04954                         SetStringGadgetValue(_R(IDOK), _R(IDS_COLNAME_YALTER));
04955                         SetStringGadgetValue(_R(IDC_COLNAME_TEXT), *Info->TheColour->GetName());
04956                     }
04957 
04958                     SetTitlebarName(&Name);
04959                     SetKeyboardFocus (_R(IDC_COLNAME_TEXT));
04960                     HighlightText    (_R(IDC_COLNAME_TEXT));
04961                 }
04962                 break;
04963                 
04964             case DIM_COMMIT:
04965             case DIM_SOFT_COMMIT:
04966                 CommitName();
04967                 break;
04968 
04969             case DIM_CANCEL:
04970                 Close();
04971                 End();
04972                 break;
04973 
04974             case DIM_REDRAW:
04975                 if (Msg->GadgetID == _R(IDC_COLNAME_PATCH))
04976                 {
04977                     ReDrawInfoType *RedrawInfo = (ReDrawInfoType*) Msg->DlgMsgParam;
04978                     DocRect VirtualSize(0, 0, RedrawInfo->dx, RedrawInfo->dy);
04979                     RenderRegion *pRender = CreateOSRenderRegion(&VirtualSize, RedrawInfo);
04980                     if (pRender)
04981                     {
04982                         pRender->SaveContext();
04983 
04984                         DocColour PatchCol(128L, 128L, 128L);
04985                         if (Info->TheColour != NULL)
04986                             PatchCol.MakeRefToIndexedColour(Info->TheColour);
04987 
04988                         pRender->SetLineWidth(0);
04989                         pRender->SetLineColour(PatchCol);
04990                         pRender->SetFillColour(PatchCol);
04991                         pRender->DrawRect(&VirtualSize);
04992 
04993                         pRender->RestoreContext();
04994 
04995                         DestroyOSRenderRegion(pRender);
04996                     }
04997                 }
04998                 break;
04999 
05000             default:
05001                 break;
05002         }
05003 
05004         return (DLG_EAT_IF_HUNGRY(Msg)); 
05005     }
05006 
05007     return OK; 
05008 }  


Member Data Documentation

const INT32 ColourNameDlg::IDD = _R(IDD_COLOURNAMEDLG) [static]
 

Definition at line 697 of file sgcolour.h.

ColourNameParam* ColourNameDlg::Info [protected]
 

Definition at line 709 of file sgcolour.h.

const CDlgMode ColourNameDlg::Mode = MODAL [static]
 

Definition at line 698 of file sgcolour.h.


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