TemplateDialog Class Reference

Allows intelligent users to make attributes changeable via templates. More...

#include <tmpltdlg.h>

Inheritance diagram for TemplateDialog:

DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 TemplateDialog ()
 Required constructor for DialogManager, gives Modeless dialog and resource ID.
virtual ~TemplateDialog ()
 Destructor deletes those member variables.
virtual void Do (OpDescriptor *)
 Waste some space.
TextControlGetKeyControl () const
TextControlGetValueControl () const
StaticTextControlGetParamHintControl () const
void SetUserCanModifyQuestion (BOOL TheyAre)

Static Public Member Functions

static BOOL Init ()
 Creates an OpDescriptor for a TemplateDialog so you can make a template dialog pop up using pOpDescriptor->Invoke(). Call this before even thinking of invoking it 'cos otherwise it won't work. Somewhere in main3.cpp would be nice.
static OpState GetState (String_256 *, OpDescriptor *)
 Silliness with statics (derived classes anyone?).

Static Public Attributes

static const CDlgResID s_IDD = _R(IDD_TEMPLATE_DIALOG)
static const CDlgMode s_Mode = MODELESS

Protected Member Functions

virtual MsgResult Message (Msg *Message)
 Bog standard dispatch the message type switch statement.
virtual void OnCreate ()
 Handles a message that the dialog has just been created.
virtual void OnTextChange ()
 Responds to the user's request to add the selected template argument to the list of used properties.
virtual void OnParamChange ()
 Responds to the user's request to add the selected template argument to the list of used properties.
virtual void OnAddButtonClicked ()
 Responds to the user's request to add the selected template argument to the list of used properties.
virtual void OnRemoveButtonClicked ()
 Handles the message when the user clicks on the Remove button.
virtual void OnRemoveAllButtonClicked ()
virtual void OnUsedListHighlightChanged ()
 Handles the message that the Used Properties list box has had its highlight changed. Updates the question edit box as appropriate.
virtual void OnAvailableListHighlightChanged ()
 Handles the message that the Available Properties list box has had its highlight changed. If there wasn't a highlight before you can now press the add button.
virtual void OnAvailableListDoubleClicked ()
 Responds to the user's request to add the selected template argument to the list of used properties.
virtual void OnSelectionChange ()
 Handles a message that there's been a selection change.
virtual void OnMakeStyleClicked ()
 Responds to a request to make a style from a WizOp.
virtual void OnApplyClicked ()
 Responds to the user's request to apply the Name and Template Property attributes to the selection.
void OnAvailableSelectionChange ()
 Responds to a change to the selected item in the Available List.
void OnUsedSelectionChange ()
 Updates the state of the buttons which are determined solely by the Available properties list.
void SetDialogInitialState (BaseDocument *const pSelectedDocument)
 Handles a message that there's been a selection change.
void InitializeControls ()
 Sets up the dialog according to what attributes are applied to the selection. The cases are:.
void ReflectControlAvailability ()
void ShowInitialControlAvailablity ()
RenderableNodeEnumeratorCreateEnumerator () const
 Provides a suitable Node enumerator depending on the selection.
StyleAddNewStyle (const Style &NewStyle) const
 Support function that attempts to add the given style to the styles associated with the selected document.
BOOL BuildUsedPropertiesList ()
BOOL BuildAvailablePropertiesList (BaseDocument *const pSelectedDocument)
 Updates the state of the buttons which are determined solely by the Available properties list.
void MakePropertyUsed ()
void RemoveUsedProperty ()
void RemoveAllUsedProperties ()
BOOL CreateGadgets ()
 Support function to create the controls in the dialog. The DialogManager should do this but I haven't time.
void ApplyUsedAttributes ()
 Applies all the properties marked as used to the current selection.
AvailablePropertiesListGetAvailableProperties ()
 Data Member access.
UsedPropertiesListGetUsedProperties ()
BOOL UserCanModifyQuestion () const
WizOpsGetWizOps () const
WizOpStylesGetStyles () const

Static Protected Member Functions

static BOOL ShowCustomProperty ()
 Tells us if we should add a custom property to the Available Properties list according to preference.

Private Member Functions

 CC_DECLARE_DYNCREATE (TemplateDialog)

Private Attributes

ListControlm_pUsedListGadget
ListControlm_pAvailableListGadget
TextControlm_pQuestionGadget
StaticTextControlm_pParamHintGadget
TextControlm_pParamGadget
Buttonm_pAddButton
Buttonm_pRemoveButton
Buttonm_pRemoveAllButton
Buttonm_pApplyButton
Buttonm_pMakeStyleButton
AvailablePropertiesListm_pAvailableProperties
UsedPropertiesListm_pUsedProperties
BOOL m_UserCanModifyQuestion

Static Private Attributes

static String_32 s_PreferenceSection = TEXT("Wizard Properties")
static const UINT32 s_NumberOfPreferences = 1
static String_16 s_ShowCustom = TEXT("Show Custom")
 If TRUE, the Wizard Properties dialog will show an Available Property "Custom" through which the user can add.
static BOOL s_ShowCustomProperty = FALSE

Detailed Description

Allows intelligent users to make attributes changeable via templates.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 132 of file tmpltdlg.h.


Constructor & Destructor Documentation

TemplateDialog::TemplateDialog  ) 
 

Required constructor for DialogManager, gives Modeless dialog and resource ID.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 1951 of file tmpltdlg.cpp.

TemplateDialog::~TemplateDialog  )  [virtual]
 

Destructor deletes those member variables.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 1982 of file tmpltdlg.cpp.

01983 {
01984     delete m_pAvailableProperties;
01985     m_pAvailableProperties = NULL;
01986 
01987     delete m_pUsedProperties;
01988     m_pUsedProperties = NULL;
01989 
01990 
01991     delete m_pUsedListGadget;
01992     m_pUsedListGadget       = NULL;
01993 
01994     delete m_pAvailableListGadget;
01995     m_pAvailableListGadget  = NULL;
01996 
01997     delete m_pQuestionGadget;
01998     m_pQuestionGadget       = NULL;
01999 
02000     delete m_pParamHintGadget;
02001     m_pParamHintGadget      = NULL;
02002 
02003     delete m_pParamGadget;
02004     m_pParamGadget          = NULL;
02005 
02006     delete m_pAddButton;
02007     m_pAddButton            = NULL;
02008 
02009     delete m_pRemoveButton;
02010     m_pRemoveButton         = NULL;
02011 
02012     delete m_pRemoveAllButton;
02013     m_pRemoveAllButton      = NULL;
02014 
02015     delete m_pApplyButton;
02016     m_pApplyButton          = NULL;
02017 
02018     delete m_pMakeStyleButton;
02019     m_pMakeStyleButton      = NULL;
02020 }       


Member Function Documentation

Style * TemplateDialog::AddNewStyle const Style NewStyle  )  const [protected]
 

Support function that attempts to add the given style to the styles associated with the selected document.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97
Returns:
A pointer to the style to use (the one that was added) NULL if the addition failed or the Style Name already exists in the selected document's style component.

Definition at line 2980 of file tmpltdlg.cpp.

02981 {
02982     Style* pStyleToUse = NULL;
02983 
02984     WizOpStyles* const pStyles = GetStyles();
02985     if (pStyles != NULL)
02986     {
02987         // don't give them a style to use if one with the same name already exists
02988         pStyleToUse = pStyles->FindStyleFromName(NewStyle.GetName());
02989         if (pStyleToUse == NULL)
02990         {
02991             pStyleToUse = pStyles->AddStyle(NewStyle);
02992         }
02993         else
02994         {
02995             pStyleToUse = NULL;
02996         }
02997     }
02998     
02999     return pStyleToUse;
03000 }

void TemplateDialog::ApplyUsedAttributes  )  [protected]
 

Applies all the properties marked as used to the current selection.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 3059 of file tmpltdlg.cpp.

03060 {
03061     GetUsedProperties().Commit(*this);
03062 
03063     m_pApplyButton->Disable();
03064 }

BOOL TemplateDialog::BuildAvailablePropertiesList BaseDocument *const   pSelectedDocument  )  [protected]
 

Updates the state of the buttons which are determined solely by the Available properties list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2772 of file tmpltdlg.cpp.

02773 {
02774     BOOL Ok = TRUE;
02775 
02776     // Delete the last load of available properties we got when the selected document changed
02777     delete m_pAvailableProperties;
02778     m_pAvailableProperties = NULL;
02779 
02780     if (pSelectedDocument != NULL)
02781     {
02782         // Fill 'er up with template handlers aka WizOps
02783         m_pAvailableProperties = new AvailablePropertiesList();
02784     }
02785 
02786     Ok = (m_pAvailableProperties != NULL && m_pAvailableListGadget != NULL);
02787 
02788     if (Ok)
02789     {
02790         Ok = m_pAvailableProperties->Interact(*m_pAvailableListGadget);
02791     }
02792 
02793     if (Ok)
02794     {
02795         Ok = m_pAvailableProperties->AddTemplateHandlers(GetWizOps());
02796     }
02797 
02798     // ...and any styles that are hanging about
02799     if (Ok)
02800     {
02801         WizOpStyles* const pStyles = GetStyles();
02802         Ok = (pStyles != NULL);
02803 
02804         if (Ok)
02805         {
02806 #if FALSE
02807             WizOpStyle NewStyle(String_8("Style"), String_64("The shading in the trees"), 
02808                                 *GetWizOps().GetFirstWizOp(), String_8("P1"));
02809             pStyles->AddStyle(NewStyle);
02810 #endif
02811             Ok = m_pAvailableProperties->AddStyles(*pStyles);
02812         }
02813     }
02814     // ...and add a Custom Property entry
02815     if (Ok && ShowCustomProperty())
02816     {
02817         CustomProperty* pCustomProperty = new CustomProperty();
02818         if (pCustomProperty != NULL)
02819         {
02820             Ok = m_pAvailableProperties->InsertEntry(*pCustomProperty);
02821         }
02822     }
02823 
02824     if (!Ok)
02825     {
02826         delete m_pAvailableProperties;
02827         m_pAvailableProperties = NULL;
02828     }
02829 
02830     return Ok;
02831 }

BOOL TemplateDialog::BuildUsedPropertiesList  )  [protected]
 

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2843 of file tmpltdlg.cpp.

02844 {
02845     BOOL Ok = TRUE;
02846 
02847     // when the selection changes, bin the old used properties list, and start afresh
02848     delete m_pUsedProperties;
02849     m_pUsedProperties = NULL;
02850 
02851     m_pUsedProperties = new UsedPropertiesList();
02852 
02853     Ok = (m_pUsedProperties != NULL && m_pUsedListGadget != NULL);
02854 
02855     if (Ok)
02856     {
02857         Ok = m_pUsedProperties->Interact(*m_pUsedListGadget);
02858     }
02859 
02860     RenderableNodeEnumerator* pEnumerator = NULL;
02861 
02862     if (Ok)
02863     {
02864         pEnumerator = CreateEnumerator();
02865         if (pEnumerator != NULL)
02866         {
02867             Ok = m_pUsedProperties->BuildFromEnumerator(*pEnumerator);
02868         }
02869     }
02870 
02871     delete pEnumerator;
02872     pEnumerator = NULL;
02873 
02874     return Ok;
02875 }

TemplateDialog::CC_DECLARE_DYNCREATE TemplateDialog   )  [private]
 

RenderableNodeEnumerator * TemplateDialog::CreateEnumerator  )  const [protected]
 

Provides a suitable Node enumerator depending on the selection.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 3028 of file tmpltdlg.cpp.

03029 {
03030     RenderableNodeEnumerator* pEnumerator = NULL;
03031 
03032     SelRange* const pSelRange = GetApplication()->FindSelection();
03033 
03034     if (pSelRange != NULL && !pSelRange->IsEmpty())
03035     {
03036         pEnumerator = new RangeEnumerator(pSelRange);
03037     }
03038     else if (pSelRange != NULL && pSelRange->IsEmpty())
03039     {
03040         // If there's no selection the AttrUser's need to be applied to the Document (maybe)
03041 //      pEnumerator = new DocPseudoEnumerator(Document::GetSelected());
03042     }
03043 
03044     return pEnumerator;
03045 }

BOOL TemplateDialog::CreateGadgets  )  [protected]
 

Support function to create the controls in the dialog. The DialogManager should do this but I haven't time.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 3165 of file tmpltdlg.cpp.

03166 {
03167     m_pUsedListGadget = new ListControl(this, _R(IDC_TMLPTDLG_USED));
03168 
03169     m_pAvailableListGadget = new ListControl(this, _R(IDC_TMLPTDLG_AVAILABLE));
03170 
03171     m_pQuestionGadget = new TextControl(this, _R(IDC_TMLPTDLG_QUESTION));
03172 
03173     m_pParamHintGadget = new StaticTextControl(this, _R(IDC_TMPLTDLG_PARAM_TEXT));
03174 
03175     m_pParamGadget = new TextControl(this, _R(IDC_TMPLTDLG_PARAM));
03176 
03177     m_pAddButton = new Button(this, _R(IDC_TMPLTDLG_ADD));
03178 
03179     m_pRemoveButton = new Button(this, _R(IDC_TMPLTDLG_REMOVE));
03180 
03181     m_pRemoveAllButton = new Button(this, _R(IDC_TMPLTDLG_REMOVE_ALL));
03182 
03183     m_pApplyButton = new Button(this, IDOK);
03184 
03185     m_pMakeStyleButton = new Button(this, _R(IDC_TMPLTDLG_MAKE_STYLE));
03186 
03187     return (m_pUsedListGadget != NULL && m_pAvailableListGadget != NULL &&
03188             m_pQuestionGadget != NULL && m_pParamHintGadget != NULL && m_pParamGadget != NULL && 
03189             m_pAddButton != NULL && m_pRemoveButton != NULL && m_pRemoveAllButton != NULL &&
03190             m_pApplyButton != NULL &&
03191             m_pMakeStyleButton != NULL
03192             );
03193 }

void TemplateDialog::Do OpDescriptor  )  [virtual]
 

Waste some space.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Reimplemented from Operation.

Definition at line 2034 of file tmpltdlg.cpp.

02035 {
02036     // We're called when the menu item / button is clicked: once to open the dialog, once
02037     // to close it. This is pseudo model isn't it and rather silly.
02038     if (g_TheOneTemplateDialogInTheEntireUniverse == NULL)
02039     {
02040         // First time so stick the dialog on the screen
02041         if (Create())
02042         {
02043             g_TheOneTemplateDialogInTheEntireUniverse = this;
02044 
02045             Open();
02046         }
02047         else
02048         {
02049             End();
02050         }
02051     }
02052     else
02053     {
02054         // Clicked button / menu to close the dialog
02055         g_TheOneTemplateDialogInTheEntireUniverse->Close();
02056         g_TheOneTemplateDialogInTheEntireUniverse->End();
02057 
02058         End();      // throw away the TemplateDialog that was created for this Do()
02059 
02060         g_TheOneTemplateDialogInTheEntireUniverse = NULL;
02061     }
02062 }

AvailablePropertiesList & TemplateDialog::GetAvailableProperties  )  [protected]
 

Data Member access.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 3082 of file tmpltdlg.cpp.

03083 {
03084     // This static dummy object is used for returning in the ERROR2 case
03085     // The original used to return a ptr to a local variable, which is a tad dangerous.
03086     // This solution is not ideal, because there's a permanent instance of an object
03087     // that will probably never be used.
03088     static AvailablePropertiesList DummyList;
03089 
03090     ERROR2IF(m_pAvailableProperties == NULL, DummyList, "NULL Member");
03091     return *m_pAvailableProperties;
03092 }

TextControl & TemplateDialog::GetKeyControl  )  const
 

Definition at line 3108 of file tmpltdlg.cpp.

03109 {
03110     ASSERT(m_pParamGadget != NULL);
03111 
03112     return *m_pParamGadget;
03113 }

StaticTextControl & TemplateDialog::GetParamHintControl  )  const
 

Definition at line 3123 of file tmpltdlg.cpp.

03124 {
03125     ASSERT(m_pParamHintGadget != NULL);
03126 
03127     return *m_pParamHintGadget;
03128 }

OpState TemplateDialog::GetState String_256 ,
OpDescriptor
[static]
 

Silliness with statics (derived classes anyone?).

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 1910 of file tmpltdlg.cpp.

01911 {
01912     OpState OpSt;
01913 
01914     if (g_TheOneTemplateDialogInTheEntireUniverse != NULL)
01915     {
01916         OpSt.Ticked = TRUE;
01917     }
01918 
01919     return OpSt;
01920 }

WizOpStyles * TemplateDialog::GetStyles  )  const [protected]
 

Definition at line 3130 of file tmpltdlg.cpp.

03131 {
03132     WizOpStyles* pStyles = NULL;
03133 
03134     BaseDocument* pDoc = Document::GetSelected();
03135     if (pDoc != NULL)
03136     {
03137         pStyles = (WizOpStyles*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(WizOpStyles));
03138     }
03139 
03140     return pStyles;
03141 }

UsedPropertiesList & TemplateDialog::GetUsedProperties  )  [protected]
 

Definition at line 3095 of file tmpltdlg.cpp.

03096 {
03097     // This static dummy object is used for returning in the ERROR2 case
03098     // The original used to return a ptr to a local variable, which is a tad dangerous.
03099     // This solution is not ideal, because there's a permanent instance of an object
03100     // that will probably never be used.
03101     static UsedPropertiesList DummyList;
03102 
03103     ERROR2IF(m_pUsedProperties == NULL, DummyList, "NULL Member");
03104     return *m_pUsedProperties;
03105 }

TextControl & TemplateDialog::GetValueControl  )  const
 

Definition at line 3116 of file tmpltdlg.cpp.

03117 {
03118     ASSERT(m_pQuestionGadget != NULL);
03119 
03120     return *m_pQuestionGadget;
03121 }

WizOps & TemplateDialog::GetWizOps  )  const [protected]
 

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 3012 of file tmpltdlg.cpp.

03013 {
03014     return ::GetWizOps();
03015 }

BOOL TemplateDialog::Init void   )  [static]
 

Creates an OpDescriptor for a TemplateDialog so you can make a template dialog pop up using pOpDescriptor->Invoke(). Call this before even thinking of invoking it 'cos otherwise it won't work. Somewhere in main3.cpp would be nice.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97
Returns:
FALSE if it fails

Reimplemented from SimpleCCObject.

Definition at line 1862 of file tmpltdlg.cpp.

01863 {
01864     BOOL Ok = TRUE;
01865 
01866     Ok = OpRemoveAttributeFromSelection::Declare();
01867 
01868 
01869     Ok |= RegisterOpDescriptor(
01870                 0,                                  // Tool ID
01871                 _R(IDS_TEMPLATE_DIALOG),                // String resouirce ID
01872                 CC_RUNTIME_CLASS(TemplateDialog),   // Runtime class
01873                 OPTOKEN_TEMPLATEDLG,                // Token string
01874                 TemplateDialog::GetState,           // GetState function
01875                 0, // is now helpless _R(IDH_Command_Wizard_Properties),        // Help ID
01876                 _R(IDBBL_TEMPLATE_DIALOG),              // Bubble ID
01877                 _R(IDD_BARCONTROLSTORE),                // Resource ID
01878                 _R(IDC_TMPLTDLG),                       // Control ID
01879                 SYSTEMBAR_UTILITIES,                // Bar ID
01880                 TRUE,                               // Recieve system messages (and button msgs)
01881                 FALSE,                              // Smart duplicate operation
01882                 TRUE,                               // Clean operation
01883                 NULL,                               // No vertical counterpart
01884                 NULL,                               // String to say only one instance allowed
01885                 (   DONT_GREY_WHEN_SELECT_INSIDE | 
01886                     GREY_WHEN_NO_CURRENT_DOC)
01887             );  
01888     
01889     Ok |= NameDialog::Init();
01890 
01891     Ok |= Camelot.DeclareSection(s_PreferenceSection, s_NumberOfPreferences);
01892     Ok |= Camelot.DeclarePref(s_PreferenceSection, s_ShowCustom, &s_ShowCustomProperty );
01893 
01894     return Ok;                  
01895 }   

void TemplateDialog::InitializeControls  )  [protected]
 

Sets up the dialog according to what attributes are applied to the selection. The cases are:.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2539 of file tmpltdlg.cpp.

02540 {
02541     // Fill the right-hand one with applied user attributes
02542     BuildUsedPropertiesList();
02543 
02544     ShowInitialControlAvailablity();
02545 }

void TemplateDialog::MakePropertyUsed  )  [protected]
 

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2886 of file tmpltdlg.cpp.

02887 {
02888     ENSURE_THIS();
02889 
02890     const UINT32 OrignalEntries = GetUsedProperties().GetNumberOfEntries(); // should be Notified really
02891 
02892     // Get the selected template handler in the available properties list
02893     VisibleListIterator Iterator = GetAvailableProperties().SelectionBegin();
02894     while (Iterator != GetAvailableProperties().End())
02895     {
02896         //  and add a new entry in the used list
02897         AvailableProperty& PropertyToUse = (AvailableProperty&)*Iterator;
02898         ENSURE_KIND((&PropertyToUse), AvailableProperty);
02899 
02900         GetUsedProperties().AddAvailableProperty(PropertyToUse);
02901         ++Iterator;
02902     }
02903 
02904     // if we actually added something then enable the Apply button
02905     if (GetUsedProperties().GetNumberOfEntries() > OrignalEntries)
02906     {
02907         m_pApplyButton->Enable();       // should be Notified really
02908         m_pRemoveAllButton->Enable();   // should be Notified really
02909     }
02910 
02911     // disable the Make Style button 'cos we don't have a working attribute now
02912     m_pMakeStyleButton->Disable();
02913     m_pAddButton->Disable();
02914 }

MsgResult TemplateDialog::Message Msg pMessage  )  [protected, virtual]
 

Bog standard dispatch the message type switch statement.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97
Parameters:
pMessage,: The message that DialogManager may or may not send us [INPUTS]
Returns:
DialogOp::MsgResult

Reimplemented from DialogOp.

Definition at line 2079 of file tmpltdlg.cpp.

02080 {
02081     if (IS_OUR_DIALOG_MSG(pMessage))
02082     {
02083         DialogMsg* const pDialogMsg = ((DialogMsg*) pMessage); 
02084     
02085         switch (pDialogMsg->DlgMsg)
02086         {
02087             case DIM_TEXT_CHANGED:
02088                 // just respond to changes to the question
02089                 // should use Notify really
02090                 switch (pDialogMsg->GadgetID)
02091                 {
02092                     case _R(IDC_TMLPTDLG_QUESTION):
02093                         // Make sure we don't respond to the changes we make internally
02094                         OnTextChange();
02095                         break;
02096 
02097                     case _R(IDC_TMPLTDLG_PARAM):
02098                         OnParamChange();
02099                         break;
02100                 }
02101 
02102                 break;
02103 
02104             case DIM_SELECTION_CHANGED_COMMIT:  // who named this???
02105                 if (pDialogMsg->GadgetID == _R(IDC_TMLPTDLG_AVAILABLE))
02106                 {
02107                     OnAvailableListDoubleClicked();
02108                 }
02109                 break;
02110                 
02111             case DIM_LFT_BN_CLICKED:
02112                 switch(pDialogMsg->GadgetID)
02113                 {
02114                     case _R(IDC_TMPLTDLG_ADD):
02115                         OnAddButtonClicked();                   
02116                         break;
02117 
02118                     case _R(IDC_TMPLTDLG_REMOVE):
02119                         OnRemoveButtonClicked();
02120                         break;
02121 
02122                     case _R(IDC_TMPLTDLG_REMOVE_ALL):
02123                         OnRemoveAllButtonClicked();
02124                         break;
02125 
02126                     case _R(IDC_TMPLTDLG_MAKE_STYLE):
02127                         OnMakeStyleClicked();
02128                         break;
02129                 }
02130                 break;
02131 
02132             case DIM_SELECTION_CHANGED: 
02133                 // NB: This means Messrs Mouse & Keyboard have manipulated one of the list boxes.
02134                 // It doesn't mean the selection has changed!
02135                 if (pDialogMsg->GadgetID == _R(IDC_TMLPTDLG_AVAILABLE))
02136                 {
02137                     OnAvailableListHighlightChanged();
02138                 }
02139                 else if (pDialogMsg->GadgetID == _R(IDC_TMLPTDLG_USED))
02140                 {
02141                     OnUsedListHighlightChanged();
02142                 }
02143                 break;
02144 
02145             case DIM_CREATE:
02146                 OnCreate();
02147                 break;
02148 
02149             case DIM_COMMIT:
02150                 OnApplyClicked();
02151                 break;
02152 
02153             case DIM_CANCEL:    
02154                 Close();           
02155                 End();
02156                 g_TheOneTemplateDialogInTheEntireUniverse = NULL;
02157                 break;
02158         }
02159     }
02160     else if (MESSAGE_IS_A(pMessage, SelChangingMsg))
02161     {
02162         if ( ((SelChangingMsg*)pMessage)->State == SelChangingMsg::SELECTIONCHANGED )
02163             OnSelectionChange();
02164     }
02165     else if (MESSAGE_IS_A(pMessage, DocChangingMsg))
02166     {
02167         // Look out for the selected document changing
02168         DocChangingMsg::DocState State = ((DocChangingMsg*)pMessage)->State;
02169         if (State == DocChangingMsg::SELCHANGED)
02170         {
02171             SetDialogInitialState(((DocChangingMsg*)pMessage)->pNewDoc);
02172         }
02173     }
02174     else if (MESSAGE_IS_A(pMessage, StylesMessage))
02175     {
02176         // We're sent one of these when the styles are added to (not by us)
02177 
02178         // Make sure they're the styles we've got displayed that are changing
02179         if (&(((StylesMessage*)pMessage)->GetStylesChanging()) == GetStyles())
02180         {
02181             SetDialogInitialState(Document::GetSelected());
02182         }
02183     }
02184         
02185     return DialogOp::Message(pMessage);
02186 } 

void TemplateDialog::OnAddButtonClicked  )  [protected, virtual]
 

Responds to the user's request to add the selected template argument to the list of used properties.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2330 of file tmpltdlg.cpp.

02331 {
02332     // For each selected item in the Available list add the appropriate attribute
02333     MakePropertyUsed();
02334 
02335     // And throw away the keyboard focus
02336     DialogManager::DefaultKeyboardFocus();
02337 }

void TemplateDialog::OnApplyClicked  )  [protected, virtual]
 

Responds to the user's request to apply the Name and Template Property attributes to the selection.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2478 of file tmpltdlg.cpp.

02479 {
02480     GetUsedProperties().RemoveSelection();  // this ensures the shown question is updated
02481 
02482     ApplyUsedAttributes();
02483     
02484     //And throw away the keyboard focus
02485     DialogManager::DefaultKeyboardFocus();
02486 }

void TemplateDialog::OnAvailableListDoubleClicked  )  [protected, virtual]
 

Responds to the user's request to add the selected template argument to the list of used properties.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2310 of file tmpltdlg.cpp.

02311 {
02312     MakePropertyUsed();
02313 
02314     //And throw away the keyboard focus
02315     DialogManager::DefaultKeyboardFocus();
02316 }

void TemplateDialog::OnAvailableListHighlightChanged  )  [protected, virtual]
 

Handles the message that the Available Properties list box has had its highlight changed. If there wasn't a highlight before you can now press the add button.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes, mostly Graham's Web/Hot/URL/Link Dialog)
Date:
09/06/97

Definition at line 2438 of file tmpltdlg.cpp.

02439 {
02440     OnAvailableSelectionChange();
02441 
02442     // And throw away the keyboard focus
02443     DialogManager::DefaultKeyboardFocus();
02444 }

void TemplateDialog::OnAvailableSelectionChange  )  [protected]
 

Responds to a change to the selected item in the Available List.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 2594 of file tmpltdlg.cpp.

02595 {
02596     VOID_ENSURE_NOT_NULL(m_pAddButton);
02597 
02598     if (m_pAddButton != NULL)
02599     {
02600         // Remove the selection from the selected list. This will remove any question / param 
02601         // so they can be used to add new entries
02602         if (GetUsedProperties().GetNumberOfSelectedEntries() > 0)
02603         {
02604             GetUsedProperties().RemoveSelection();
02605         }
02606 
02607         GetAvailableProperties().OnSelectionChange(*this);
02608 
02609         // should use a Notify for this...
02610         if (GetAvailableProperties().GetNumberOfSelectedEntries() > 0)
02611         {
02612             m_pAddButton->Enable();
02613         }
02614         else
02615         {
02616             m_pAddButton->Disable();
02617         }
02618     }
02619 
02620     VOID_ENSURE_NOT_NULL(m_pMakeStyleButton);
02621 
02622     if (m_pMakeStyleButton != NULL)
02623     {
02624         // ensure the style button is disabled
02625         m_pMakeStyleButton->Disable();
02626     }
02627 
02628 }

void TemplateDialog::OnCreate  )  [protected, virtual]
 

Handles a message that the dialog has just been created.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2199 of file tmpltdlg.cpp.

02200 {
02201     CreateGadgets();
02202 
02203     // Set up the dialog in its initial state
02204     SetDialogInitialState(Document::GetSelected());
02205 
02206     // And put the keyboard focus in the available properties list
02207     SetKeyboardFocus(_R(IDC_TMLPTDLG_AVAILABLE));
02208 }

void TemplateDialog::OnMakeStyleClicked  )  [protected, virtual]
 

Responds to a request to make a style from a WizOp.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2388 of file tmpltdlg.cpp.

02389 {   
02390     // (should probably do this somewhere else - GOD this is ugly)
02391     AvailableProperty* const pSelectedProperty = (AvailableProperty*)GetAvailableProperties().GetFirstSelectedEntry();
02392     if (pSelectedProperty != NULL)
02393     {
02394         // Invoke a dialog for the name
02395         NameDialogParam StyleNameParam;
02396         if (NameDialog::Invoke(StyleNameParam))     // returns TRUE if they didn't cancel
02397         {
02398             // if so create a new style
02399             Style* pNewStyle = pSelectedProperty->MakeStyle(StyleNameParam.GetNameEntered());
02400             if (pNewStyle != NULL)
02401             {
02402                 WizOpStyle* pStyleToUse = (WizOpStyle*)AddNewStyle(*pNewStyle);
02403                 if (pStyleToUse != NULL)
02404                 {
02405                     GetAvailableProperties().AddStyle(*pStyleToUse);
02406                     pSelectedProperty->Hide();
02407                 }
02408 
02409                 // AddNewStyle creates a copy, so we can bin this
02410                 delete pNewStyle;
02411                 pNewStyle = NULL;
02412             }
02413             // disable the Make Style button 'cos we don't have a working attribute now
02414             m_pMakeStyleButton->Disable();
02415             m_pAddButton->Disable();
02416         }
02417     }
02418 
02419     // And throw away the keyboard focus
02420     DialogManager::DefaultKeyboardFocus();
02421 }

void TemplateDialog::OnParamChange  )  [protected, virtual]
 

Responds to the user's request to add the selected template argument to the list of used properties.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97
Notes: The order of events should go: m_pParamGadget->OnChange() Notify(this) this->OnParamChange() but we'll bodge it a bit & go directly here 'cos DialogOp's a bit of a mess at the moment.

Definition at line 2286 of file tmpltdlg.cpp.

02287 {
02288 /*
02289     if (UserCanModifyQuestion())
02290     {
02291         // bit bodgy this...
02292         m_pApplyButton->Enable();
02293         SetUserCanModifyQuestion(FALSE);    // well they can but who cares now?
02294     }
02295 */
02296 }

void TemplateDialog::OnRemoveAllButtonClicked  )  [protected, virtual]
 

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2369 of file tmpltdlg.cpp.

02370 {   
02371     RemoveAllUsedProperties();
02372 
02373     // And throw away the keyboard focus
02374     DialogManager::DefaultKeyboardFocus();
02375 }

void TemplateDialog::OnRemoveButtonClicked  )  [protected, virtual]
 

Handles the message when the user clicks on the Remove button.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2350 of file tmpltdlg.cpp.

02351 {
02352     RemoveUsedProperty();
02353 
02354     // And throw away the keyboard focus
02355     DialogManager::DefaultKeyboardFocus();
02356 }

void TemplateDialog::OnSelectionChange  )  [protected, virtual]
 

Handles a message that there's been a selection change.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes, mostly Graham's Web/Hot/URL/Link Dialog)
Date:
09/06/97

Definition at line 2499 of file tmpltdlg.cpp.

02500 {   
02501     //Put the dialog into its initial state
02502     InitializeControls();
02503 }

void TemplateDialog::OnTextChange  )  [protected, virtual]
 

Responds to the user's request to add the selected template argument to the list of used properties.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2222 of file tmpltdlg.cpp.

02223 {
02224     // if we're modifying a question, that means it's a Used Property, so
02225     // allow them to Apply the change
02226     if (UserCanModifyQuestion())
02227     {
02228         // bit bodgy this...
02229         m_pApplyButton->Enable();
02230         SetUserCanModifyQuestion(FALSE);    // well they can but who cares now?
02231     }
02232     else
02233     {
02234         // If we've got one Available Property selected we might want to
02235         // allow them to make a style of it
02236 
02237         BOOL ShouldEnableMakeStyle = FALSE;
02238 
02239         if (GetAvailableProperties().GetNumberOfSelectedEntries() == 1)
02240         {
02241             String_256 Question;
02242             VOID_ENSURE_NOT_NULL(m_pQuestionGadget);
02243             if (m_pQuestionGadget != NULL)
02244             {
02245                 m_pQuestionGadget->RetrieveText(&Question);
02246             }
02247 
02248             AvailableProperty* pSelectedEntry = (AvailableProperty*)GetAvailableProperties().GetFirstSelectedEntry();
02249             if (pSelectedEntry != NULL)
02250             {
02251                 ShouldEnableMakeStyle = pSelectedEntry->CanBecomeStyle() && !Question.IsEmpty();
02252             }
02253         }
02254 
02255         if (ShouldEnableMakeStyle)
02256         {
02257             m_pMakeStyleButton->Enable();
02258         }
02259         else
02260         {
02261             m_pMakeStyleButton->Disable();
02262         }
02263     }
02264 
02265 }

void TemplateDialog::OnUsedListHighlightChanged  )  [protected, virtual]
 

Handles the message that the Used Properties list box has had its highlight changed. Updates the question edit box as appropriate.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes, mostly Graham's Web/Hot/URL/Link Dialog)
Date:
09/06/97

Definition at line 2458 of file tmpltdlg.cpp.

02459 {
02460     OnUsedSelectionChange();
02461 
02462     // And throw away the keyboard focus
02463     DialogManager::DefaultKeyboardFocus();
02464 }

void TemplateDialog::OnUsedSelectionChange  )  [protected]
 

Updates the state of the buttons which are determined solely by the Available properties list.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 2684 of file tmpltdlg.cpp.

02685 {
02686     VOID_ENSURE_NOT_NULL(m_pRemoveButton);
02687     VOID_ENSURE_NOT_NULL(m_pRemoveAllButton);
02688     VOID_ENSURE_NOT_NULL(m_pMakeStyleButton);
02689     VOID_ENSURE_NOT_NULL(m_pAddButton);
02690 
02691     if (m_pRemoveButton != NULL && m_pRemoveAllButton != NULL && m_pMakeStyleButton != NULL &&
02692         m_pAddButton != NULL)
02693     {
02694         // Remove the selection from the available list
02695         if (GetAvailableProperties().GetNumberOfSelectedEntries() > 0)
02696         {
02697             GetAvailableProperties().RemoveSelection();
02698             m_pMakeStyleButton->Disable();
02699             m_pAddButton->Disable();
02700         }
02701 
02702         GetUsedProperties().OnSelectionChange(*this);
02703 
02704         // Can only remove selected items
02705         if (GetUsedProperties().GetNumberOfSelectedEntries() > 0)
02706         {
02707             m_pRemoveButton->Enable();
02708         }
02709         else
02710         {
02711             m_pRemoveButton->Disable();
02712         }
02713 
02714         // Whenever there's anything in the used list, enable the Remove All Button
02715         if (GetUsedProperties().GetNumberOfEntries() > 0)
02716         {
02717             m_pRemoveAllButton->Enable();
02718         }
02719         else
02720         {
02721             m_pRemoveAllButton->Disable();
02722         }
02723     }
02724 }

void TemplateDialog::ReflectControlAvailability  )  [protected]
 

void TemplateDialog::RemoveAllUsedProperties  )  [protected]
 

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 2951 of file tmpltdlg.cpp.

02952 {
02953     ENSURE_THIS();
02954 
02955     GetUsedProperties().DeleteAllEntries();
02956 
02957     m_pApplyButton->Enable();   // should be Notified really
02958 
02959     m_pRemoveButton->Disable(); // should be Notified really
02960 
02961     m_pRemoveAllButton->Disable();  // should be Notified really
02962 }

void TemplateDialog::RemoveUsedProperty  )  [protected]
 

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 2926 of file tmpltdlg.cpp.

02927 {
02928     ENSURE_THIS();
02929 
02930     GetUsedProperties().DeleteSelectedEntries();
02931 
02932     m_pApplyButton->Enable();   // should be Notified really
02933 
02934     m_pRemoveButton->Disable(); // should be Notified really
02935 
02936     if (GetUsedProperties().GetNumberOfEntries() == 0)
02937     {
02938         m_pRemoveAllButton->Disable();  // should be Notified really
02939     }
02940 }

void TemplateDialog::SetDialogInitialState BaseDocument *const   pSelectedDocument  )  [protected]
 

Handles a message that there's been a selection change.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes, mostly Graham's Web/Hot/URL/Link Dialog)
Date:
09/06/97

Definition at line 2516 of file tmpltdlg.cpp.

02517 {   
02518     m_UserCanModifyQuestion = FALSE;
02519 
02520     // Fill the left-hand list box with the available WizOps / Styles & a Custom property
02521     BuildAvailablePropertiesList(pSelectedDocument);
02522 
02523     // Set the controls up in their correct initial state
02524     InitializeControls();
02525 }

void TemplateDialog::SetUserCanModifyQuestion BOOL  TheyAre  ) 
 

Definition at line 3149 of file tmpltdlg.cpp.

03150 {
03151     m_UserCanModifyQuestion = TheyCan;
03152 }

BOOL TemplateDialog::ShowCustomProperty  )  [static, protected]
 

Tells us if we should add a custom property to the Available Properties list according to preference.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
Date:
09/06/97

Definition at line 1934 of file tmpltdlg.cpp.

01935 {
01936     return s_ShowCustomProperty;
01937 }

void TemplateDialog::ShowInitialControlAvailablity  )  [protected]
 

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Definition at line 2556 of file tmpltdlg.cpp.

02557 {
02558     m_pQuestionGadget->Disable();
02559     m_pParamGadget->Disable();
02560 
02561     m_pAddButton->Disable();
02562     m_pRemoveButton->Disable();
02563     m_pRemoveAllButton->Disable();
02564 
02565     m_pMakeStyleButton->Disable();
02566 
02567     m_pApplyButton->Disable();
02568 
02569     // if nothing's selected don't let them click on it
02570     SelRange* const pSelRange = GetApplication()->FindSelection();
02571     if (pSelRange != NULL && pSelRange->IsEmpty())
02572     {
02573         m_pAvailableListGadget->Disable();
02574         m_pUsedListGadget->Disable();
02575     }
02576     else
02577     {
02578         m_pAvailableListGadget->Enable();
02579         m_pUsedListGadget->Enable();
02580     }
02581 }

BOOL TemplateDialog::UserCanModifyQuestion  )  const [protected]
 

Definition at line 3144 of file tmpltdlg.cpp.

03145 {
03146     return m_UserCanModifyQuestion;
03147 }


Member Data Documentation

Button* TemplateDialog::m_pAddButton [private]
 

Definition at line 219 of file tmpltdlg.h.

Button* TemplateDialog::m_pApplyButton [private]
 

Definition at line 222 of file tmpltdlg.h.

ListControl* TemplateDialog::m_pAvailableListGadget [private]
 

Definition at line 215 of file tmpltdlg.h.

AvailablePropertiesList* TemplateDialog::m_pAvailableProperties [private]
 

Definition at line 225 of file tmpltdlg.h.

Button* TemplateDialog::m_pMakeStyleButton [private]
 

Definition at line 223 of file tmpltdlg.h.

TextControl* TemplateDialog::m_pParamGadget [private]
 

Definition at line 218 of file tmpltdlg.h.

StaticTextControl* TemplateDialog::m_pParamHintGadget [private]
 

Definition at line 217 of file tmpltdlg.h.

TextControl* TemplateDialog::m_pQuestionGadget [private]
 

Definition at line 216 of file tmpltdlg.h.

Button* TemplateDialog::m_pRemoveAllButton [private]
 

Definition at line 221 of file tmpltdlg.h.

Button* TemplateDialog::m_pRemoveButton [private]
 

Definition at line 220 of file tmpltdlg.h.

ListControl* TemplateDialog::m_pUsedListGadget [private]
 

Definition at line 214 of file tmpltdlg.h.

UsedPropertiesList* TemplateDialog::m_pUsedProperties [private]
 

Definition at line 226 of file tmpltdlg.h.

BOOL TemplateDialog::m_UserCanModifyQuestion [private]
 

Definition at line 229 of file tmpltdlg.h.

const CDlgResID TemplateDialog::s_IDD = _R(IDD_TEMPLATE_DIALOG) [static]
 

Definition at line 209 of file tmpltdlg.h.

const CDlgMode TemplateDialog::s_Mode = MODELESS [static]
 

Definition at line 210 of file tmpltdlg.h.

const UINT32 TemplateDialog::s_NumberOfPreferences = 1 [static, private]
 

Definition at line 233 of file tmpltdlg.h.

String_32 TemplateDialog::s_PreferenceSection = TEXT("Wizard Properties") [static, private]
 

Definition at line 232 of file tmpltdlg.h.

String_16 TemplateDialog::s_ShowCustom = TEXT("Show Custom") [static, private]
 

If TRUE, the Wizard Properties dialog will show an Available Property "Custom" through which the user can add.

Preference: Show Custom Section: Wizard Properties Range: TRUE or FALSE

Definition at line 235 of file tmpltdlg.h.

BOOL TemplateDialog::s_ShowCustomProperty = FALSE [static, private]
 

Definition at line 236 of file tmpltdlg.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:01:41 2007 for Camelot by  doxygen 1.4.4