include/ax/ax_controller_standard.h

Go to the documentation of this file.
00001 
00002 // Name:        ax_controller_standard.h
00003 // Purpose:     Standard menu controller, using a list control.
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_CONTROLLER_STANDARD_H_
00013 #define _AX_CONTROLLER_STANDARD_H_
00014 
00015 /*
00016  * Includes
00017  */
00018 
00019 #include "wx/listctrl.h"
00020 #include "ax/ax_menu.h"
00021 
00022 // Native wxListCtrl on Mac has a few problems. So for now, explicitly
00023 // use wxGenericListCtrl on Mac.
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 AxStandardMenuController;
00039 class AxVisualSettings;
00040 
00049 #if axUSE_GENERIC_LISTCTRL
00050 class AxMenuListCtrl: public wxGenericListCtrl
00051 #else
00052 class AxMenuListCtrl: public wxListCtrl
00053 #endif
00054 {
00055     DECLARE_CLASS( AxMenuListCtrl )
00056     DECLARE_EVENT_TABLE()
00057 
00058 public:
00059 // Constructors
00060 
00061     AxMenuListCtrl() { Init(); }
00062 
00063     AxMenuListCtrl(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_REPORT);
00064     ~AxMenuListCtrl();
00065 
00066     void SetController(AxStandardMenuController* controller) { m_controller = controller; }
00067 
00068     bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_REPORT);
00069 
00070     void Init();
00071 
00073     virtual bool RefreshMenu(AxMenu* menu);
00074 
00076     virtual bool UpdateMenuItem(AxMenu* menu, AxMenuItem* item);
00077 
00079     virtual bool SetMenuItemData(wxListItem& info, AxMenuItem* item);
00080 
00082     virtual bool SetMenuSelection(AxMenuItem* menuItem);
00083 
00085     virtual AxMenuItem* GetMenuSelection() const;
00086 
00088     void SetSelection(long sel, bool select);
00089 
00091     int GetSelection() const;
00092 
00094     virtual bool IdleProcessing();
00095 
00097     virtual bool ApplySettings(int hints, const AxVisualSettings& settings);
00098 
00099     void OnSelect(wxListEvent& event);
00100     void OnActivate(wxListEvent& event);
00101     void OnSize(wxSizeEvent& event);
00102     void OnChar(wxKeyEvent& event);
00103     // void OnIdle(wxIdleEvent& event);
00104 
00105 protected:
00106     AxStandardMenuController* m_controller;
00107     AxMenu*                 m_menu;
00108     int                     m_toActivate;
00109 };
00110 
00120 class AxStandardMenuController: public AxMenuController
00121 {
00122     DECLARE_CLASS( AxStandardMenuController )
00123 
00124 public:
00125 // Constructors
00126 
00127     AxStandardMenuController(AxMenuListCtrl* listCtrl = NULL, wxTextCtrl* textCtrl = NULL)
00128     { Init(); m_listCtrl = listCtrl; m_textCtrl = textCtrl; }
00129     ~AxStandardMenuController();
00130 
00131 // Operations
00132 
00133     void Init();
00134 
00136     virtual bool RefreshMenu(AxMenu* menu, AxNavigationHint hint);
00137 
00139     virtual bool SetMenuSelection(AxMenuItem* menuItem);
00140 
00142     virtual bool UpdateMenuItem(AxMenuItem* item);
00143 
00145     virtual bool SetTitle(const wxString& title);
00146 
00148     virtual AxMenuItem* GetMenuSelection() const;
00149 
00151     virtual bool BeginModal();
00152 
00154     virtual bool EndModal();
00155 
00157     virtual bool IdleProcessing();
00158 
00160     virtual bool SetMenuFocus();
00161 
00163     virtual bool UpdateAppearance(int hints);
00164 
00165     AxMenuListCtrl* GetListCtrl() const { return m_listCtrl; }
00166     wxTextCtrl* GetTextCtrl() const { return m_textCtrl; }
00167 
00168     void SetListCtrl(AxMenuListCtrl* listCtrl) { m_listCtrl = listCtrl; }
00169     void SetTextCtrl(wxTextCtrl* textCtrl) { m_textCtrl = textCtrl; }
00170 protected:
00171 
00172     AxMenuListCtrl* m_listCtrl;
00173     wxTextCtrl*     m_textCtrl;
00174 };
00175 
00176 #endif
00177     // _AX_CONTROLLER_STANDARD_H_

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