00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef _AX_CONTROLLER_SIMPLE_H_
00013 #define _AX_CONTROLLER_SIMPLE_H_
00014
00015
00016
00017
00018
00019 #include "wx/listctrl.h"
00020 #include "ax/ax_menu.h"
00021
00022
00023
00024
00025 #ifdef __WXMAC__
00026 #define axUSE_GENERIC_LISTCTRL 1
00027 #else
00028 #define axUSE_GENERIC_LISTCTRL 0
00029 #endif
00030
00031 #if axUSE_GENERIC_LISTCTRL
00032 #include "wx/generic/listctrl.h"
00033 #define AxListCtrlClass wxGenericListCtrl
00034 #else
00035 #define AxListCtrlClass wxListCtrl
00036 #endif
00037
00038 class AxSimpleMenuController;
00039
00048 #if axUSE_GENERIC_LISTCTRL
00049 class AxMenuListCtrl: public wxGenericListCtrl
00050 #else
00051 class AxMenuListCtrl: public wxListCtrl
00052 #endif
00053 {
00054 DECLARE_CLASS( AxMenuListCtrl )
00055 DECLARE_EVENT_TABLE()
00056
00057 public:
00058
00059
00060 AxMenuListCtrl() { Init(); }
00061
00062 AxMenuListCtrl(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_REPORT);
00063 ~AxMenuListCtrl();
00064
00065 void SetController(AxSimpleMenuController* controller) { m_controller = controller; }
00066
00067 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_REPORT);
00068
00069 void Init();
00070
00072 virtual bool RefreshMenu(AxMenu* menu);
00073
00075 virtual bool UpdateMenuItem(AxMenu* menu, AxMenuItem* item);
00076
00078 virtual bool SetMenuItemData(wxListItem& info, AxMenuItem* item);
00079
00081 virtual bool SetMenuSelection(AxMenuItem* menuItem);
00082
00084 virtual AxMenuItem* GetMenuSelection() const;
00085
00087 void SetSelection(long sel, bool select);
00088
00090 int GetSelection() const;
00091
00093 virtual bool IdleProcessing();
00094
00095 void OnSelect(wxListEvent& event);
00096 void OnActivate(wxListEvent& event);
00097 void OnSize(wxSizeEvent& event);
00098 void OnChar(wxKeyEvent& event);
00099
00100
00101 protected:
00102 AxSimpleMenuController* m_controller;
00103 AxMenu* m_menu;
00104 int m_toActivate;
00105 };
00106
00116 class AxSimpleMenuController: public AxMenuController
00117 {
00118 DECLARE_CLASS( AxSimpleMenuController )
00119
00120 public:
00121
00122
00123 AxSimpleMenuController(AxMenuListCtrl* listCtrl = NULL, wxTextCtrl* textCtrl = NULL)
00124 { Init(); m_listCtrl = listCtrl; m_textCtrl = textCtrl; }
00125 ~AxSimpleMenuController();
00126
00127
00128
00129 void Init();
00130
00132 virtual bool RefreshMenu(AxMenu* menu, AxNavigationHint hint);
00133
00135 virtual bool SetMenuSelection(AxMenuItem* menuItem);
00136
00138 virtual bool UpdateMenuItem(AxMenuItem* item);
00139
00141 virtual bool SetTitle(const wxString& title);
00142
00144 virtual AxMenuItem* GetMenuSelection() const;
00145
00147 virtual bool BeginModal();
00148
00150 virtual bool EndModal();
00151
00153 virtual bool IdleProcessing();
00154
00156 virtual bool SetMenuFocus();
00157
00158 AxMenuListCtrl* GetListCtrl() const { return m_listCtrl; }
00159 wxTextCtrl* GetTextCtrl() const { return m_textCtrl; }
00160
00161 void SetListCtrl(AxMenuListCtrl* listCtrl) { m_listCtrl = listCtrl; }
00162 void SetTextCtrl(wxTextCtrl* textCtrl) { m_textCtrl = textCtrl; }
00163 protected:
00164
00165 AxMenuListCtrl* m_listCtrl;
00166 wxTextCtrl* m_textCtrl;
00167 };
00168
00169 #endif
00170