00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef _AX_ACTIVATOR_H_
00013 #define _AX_ACTIVATOR_H_
00014
00040
00041
00042
00043
00044
00045
00046
00047
00048 class AxMenuItem;
00049 class AxMenu;
00050 class AxMenuItemData;
00051 class AxResource;
00052 class AxMenuController;
00053
00063 class AxActivator: public wxEvtHandler
00064 {
00065 DECLARE_CLASS( AxActivator )
00066
00067 public:
00068
00069
00070 AxActivator(AxMenuItem* item = NULL) { Init(); m_menuItem = item; }
00071 ~AxActivator() {}
00072
00073
00074
00075 void Init() { m_menuItem = NULL; }
00076 void Copy(const AxActivator& activator) { m_menuItem = activator.m_menuItem; }
00077
00078 virtual AxActivator* Clone() const = 0;
00079
00081 virtual AxMenu* Activate(AxMenuController* controller, AxMenuItem* item) = 0;
00082
00085 virtual bool Reactivate(AxMenuController* WXUNUSED(controller), AxMenuItem* WXUNUSED(item)) { return false; }
00086
00088 virtual bool Select(AxMenuController* controller, AxMenuItem* item);
00089
00091 virtual bool BeforeDisplay(AxMenuController* controller, AxMenuItem* item);
00092
00094 virtual bool UpdateUI(AxMenuController* controller, AxMenuItem* item);
00095
00097 AxMenuItem* GetMenuItem() const { return m_menuItem; }
00098 void SetMenuItem(AxMenuItem* item) { m_menuItem = item; }
00099
00100 protected:
00101 AxMenuItem* m_menuItem;
00102 };
00103
00113 class AxEventActivator: public AxActivator
00114 {
00115 DECLARE_DYNAMIC_CLASS( AxEventActivator )
00116
00117 public:
00118
00119
00120 AxEventActivator() { Init(); }
00121 AxEventActivator(const AxEventActivator& activator) { Init(); Copy(activator); }
00122
00123 AxEventActivator(AxMenuItem* item, wxEvtHandler* sink, long eventId)
00124 { Init(); m_menuItem = item; m_sink = sink; m_eventId = eventId; }
00125 ~AxEventActivator() {}
00126
00127
00128
00129 void Init() { m_sink = NULL; m_eventId = -1; }
00130
00131 void Copy(const AxEventActivator& activator);
00132
00133 virtual AxActivator* Clone() const { return new AxEventActivator(*this); }
00134
00135 virtual AxMenu* Activate(AxMenuController* controller, AxMenuItem* item);
00136
00137 wxEvtHandler* GetEventSink() const { return m_sink; }
00138 void SetEventSink(wxEvtHandler* sink) { m_sink = sink; }
00139
00140 long GetEventId() const { return m_eventId; }
00141 void SetEventId(long eventId) { m_eventId = eventId; }
00142
00143 protected:
00144 wxEvtHandler* m_sink;
00145 long m_eventId;
00146 };
00147
00156 class AxUpActivator: public AxActivator
00157 {
00158 DECLARE_DYNAMIC_CLASS( AxUpActivator )
00159
00160 public:
00161
00162
00163 AxUpActivator() { Init(); }
00164 AxUpActivator(const AxUpActivator& activator) { Init(); Copy(activator); }
00165
00166 ~AxUpActivator() {}
00167
00168
00169
00170 void Init() { }
00171
00172 virtual AxActivator* Clone() const { return new AxUpActivator(*this); }
00173
00174 void Copy(const AxUpActivator& activator);
00175
00176 virtual AxMenu* Activate(AxMenuController* controller, AxMenuItem* item);
00177
00178 protected:
00179 };
00180
00194 class AxAutoUpdateActivator: public AxActivator
00195 {
00196 public:
00197
00198 DECLARE_CLASS( AxAutoUpdateActivator )
00199
00200 public:
00201
00202
00203 AxAutoUpdateActivator() { Init(); }
00204
00205 AxAutoUpdateActivator(
00206 const wxString& labelSpec,
00207 const wxString& descriptionSpec);
00208
00209 AxAutoUpdateActivator(const AxAutoUpdateActivator& activator) { Init(); Copy(activator); }
00210
00211 void Init();
00212
00213 void Copy(const AxAutoUpdateActivator& activator);
00214
00215
00216
00220 virtual wxString CreateString(const wxString& spec, bool isLabel) = 0;
00221
00222
00223
00225 virtual bool BeforeDisplay(AxMenuController* controller, AxMenuItem* item);
00226
00228 virtual bool UpdateUI(AxMenuController* controller, AxMenuItem* item);
00229
00231 bool UpdateItem(AxMenuController* controller, AxMenuItem* item);
00232
00234 const wxString& GetLabelSpec() const { return m_labelSpec; }
00235
00237 void SetLabelSpec(const wxString& spec) { m_labelSpec = spec; }
00238
00240 const wxString& GetDescriptionSpec() const { return m_descriptionSpec; }
00241
00243 void SetDescriptionSpec(const wxString& spec) { m_descriptionSpec = spec; }
00244
00245 protected:
00246 wxString m_labelSpec;
00247 wxString m_descriptionSpec;
00248 };
00249
00250 #endif
00251