include/ax/ax_menu_choice.h

Go to the documentation of this file.
00001 
00002 // Name:        ax_menu_choice.h
00003 // Purpose:     Modal choice menu class
00004 // Author:      Julian Smart
00005 // Modified by:
00006 // Created:     2009-03-20
00007 // RCS-ID:
00008 // Copyright:   (c) Julian Smart
00009 // Licence:     New BSD License
00011 
00012 #ifndef _AX_MENU_CHOICE_H_
00013 #define _AX_MENU_CHOICE_H_
00014 
00015 class AxChoiceMenuItem;
00016 
00017 /*
00018  * Includes
00019  */
00020 
00021 #include "ax/ax_menu.h"
00022 #include "ax/ax_activator.h"
00023 #include "ax/ax_validator.h"
00024 #include "ax/ax_menu_modal.h"
00025  
00035 class AxModalChoiceMenu: public AxModalMenu
00036 {
00037     DECLARE_CLASS( AxModalChoiceMenu )
00038 
00039 public:
00040 // Constructors
00041 
00042     AxModalChoiceMenu() { Init(); }
00043 
00044     AxModalChoiceMenu(AxMenuController* controller, AxMenuItem* item,
00045         const wxString& menuLabel,
00046         const wxString& description,
00047         const wxArrayString& labels,
00048         const wxArrayString& ids,
00049         const wxArrayString& descriptions,
00050         const wxString& defaultId = wxEmptyString);
00051     
00052     ~AxModalChoiceMenu() {}
00053 
00054 // Operations
00055 
00056     void Init() {}
00057 
00058 protected:
00059 
00060 };
00061 
00071 class AxChoiceMenuActivator: public AxActivator
00072 {
00073 public:
00074     
00075     DECLARE_DYNAMIC_CLASS( AxChoiceMenuActivator )
00076 
00077 public:
00078 // Constructors
00079 
00080     AxChoiceMenuActivator(AxModalChoiceMenu* menu = NULL) { Init(); m_choiceMenu = menu; }
00081     AxChoiceMenuActivator(const AxChoiceMenuActivator& activator) { Init(); Copy(activator); }
00082 
00083 // Operations
00084 
00085     void Init() { m_choiceMenu = NULL; }
00086 
00087     void Copy(const AxChoiceMenuActivator& activator);
00088 
00089     virtual AxActivator* Clone() const { return new AxChoiceMenuActivator(*this); }
00090 
00091     virtual AxMenu* Activate(AxMenuController* controller, AxMenuItem* item);
00092 
00093     AxModalChoiceMenu* GetModalChoiceMenu() const { return m_choiceMenu; }
00094     void SetModalChoiceMenu(AxModalChoiceMenu* menu) { m_choiceMenu = menu; }
00095 
00096 protected:
00097     AxModalChoiceMenu*        m_choiceMenu;
00098 };
00099 
00109 class AxChoiceActivator: public AxAutoUpdateActivator
00110 {
00111 public:
00112     
00113     DECLARE_DYNAMIC_CLASS( AxChoiceActivator )
00114 
00115 public:
00116 // Constructors
00117 
00118     AxChoiceActivator() { Init(); }
00119 
00120     AxChoiceActivator(
00121         const wxString& labelSpec,
00122         const wxString& descriptionSpec);
00123 
00124     AxChoiceActivator(const AxChoiceActivator& activator) { Init(); Copy(activator); }
00125 
00126     void Init();
00127 
00128     void Copy(const AxChoiceActivator& activator);
00129 
00130     virtual AxActivator* Clone() const { return new AxChoiceActivator(* this); }
00131 
00133     virtual AxMenu* Activate(AxMenuController* controller, AxMenuItem* item);
00134 
00136     virtual wxString CreateString(const wxString& spec, bool isLabel);
00137 
00138     AxChoiceMenuItem* GetChoiceMenuItem() const;
00139 
00140 protected:
00141 };
00142 
00157 class AxChoiceMenuItem: public AxMenuItem
00158 {
00159     DECLARE_DYNAMIC_CLASS( AxChoiceMenuItem )
00160 
00161 public:
00162 // Constructors
00163 
00164     AxChoiceMenuItem(const AxChoiceMenuItem& item) { Copy(item); }
00165     AxChoiceMenuItem() {}
00166     AxChoiceMenuItem(const wxString& label, const wxString& description,
00167         const wxString& id,
00168         const wxArrayString& labels,
00169         const wxArrayString& ids,
00170         const wxArrayString& descriptions,
00171         int selection = 0);
00172     bool Create(const wxString& label, const wxString& description,
00173         const wxString& id,
00174         const wxArrayString& labels,
00175         const wxArrayString& ids,
00176         const wxArrayString& descriptions,
00177         int selection = 0);
00178 
00179     void Init();
00180 
00181     void Copy(const AxChoiceMenuItem& item);
00182 
00183     virtual AxMenuItem* Clone() const { return new AxChoiceMenuItem(* this); }
00184 
00186     wxString GetSelectionLabel() const;
00187 
00189     wxString GetSelectionId() const;
00190 
00192     int GetSelection() const { return m_selection; }
00193 
00195     virtual void SetSelection(int i);
00196 
00198     virtual void SetSelectionByLabel(const wxString& label);
00199 
00201     virtual void SetSelectionById(const wxString& id);
00202 
00204     virtual wxString CreateString(const wxString& spec, bool isLabel);
00205 
00206     void SetLabels(const wxArrayString& labels) { m_labels = labels; }
00207     const wxArrayString& GetLabels() const { return m_labels; }
00208     
00209     void SetIds(const wxArrayString& ids) { m_ids = ids; }
00210     const wxArrayString& GetIds() const { return m_ids; }
00211     
00212     void SetDescriptions(const wxArrayString& descriptions) { m_descriptions = descriptions; }
00213     const wxArrayString& GetDescriptions() const { return m_descriptions; }
00214 
00216     void SetLabelSpec(const wxString& spec);
00217 
00219     wxString GetLabelSpec() const;
00220 
00222     void SetDescriptionSpec(const wxString& spec);
00223 
00225     wxString GetDescriptionSpec() const;
00226 
00227 protected:
00228     wxArrayString m_labels;
00229     wxArrayString m_ids;
00230     wxArrayString m_descriptions;
00231     int           m_selection;
00232 };
00233 
00241 class AxChoiceValidator: public AxValidator
00242 {
00243     DECLARE_DYNAMIC_CLASS( AxChoiceValidator )
00244 
00245 public:
00246 // Constructors
00247 
00248     AxChoiceValidator(const AxChoiceValidator& validator) { Init(); Copy(validator); }
00249     AxChoiceValidator(wxString* ptr) { Init(); m_stringPtr = ptr; }
00250     AxChoiceValidator(int* ptr) { Init(); m_intPtr = ptr; }
00251     AxChoiceValidator() { Init(); }
00252     ~AxChoiceValidator() {}
00253 
00254 // Operations
00255 
00256     void Copy(const AxChoiceValidator& validator)
00257     {
00258         AxValidator::Copy(validator);
00259 
00260         m_stringPtr = validator.m_stringPtr;
00261         m_intPtr = validator.m_intPtr;
00262     }
00263 
00264     virtual AxValidator* Clone() const { return new AxChoiceValidator(*this); }
00265 
00267     virtual bool TransferDataFromMenu();
00268 
00270     virtual bool TransferDataToMenu();
00271 
00273     void Init() { m_stringPtr = NULL; m_intPtr = NULL; }
00274 
00275 protected:
00276     wxString*   m_stringPtr;
00277     int*        m_intPtr;
00278 };
00279 
00280 
00281 #endif
00282     // _AX_MENU_CHOICE_H_

Generated on Wed May 6 19:20:18 2009 for AxTk by  doxygen 1.5.1