00001
00017 #ifndef INC_MGUI_MENUBTN_H
00018 #define INC_MGUI_MENUBTN_H
00019
00020 #ifndef INC_MGUI_CTRL_H
00021 #include <mgui/ctrl.h>
00022 #endif
00023
00024 #ifndef INC_MI32_MILIST_H
00025 #include <mi32/milist.h>
00026 #endif
00027
00028
00029 namespace MGUI {
00030
00032 class CTRL_MENUBUTTON : public MGUI::CTRL {
00033 public:
00034
00036 enum ITEMSTYLE {
00037 ITEMSTYLE_Normal = 0,
00038 ITEMSTYLE_Toggle = 0x00000001
00039 };
00040
00041 enum STYLE {
00042 STYLE_Normal = 0,
00043 STYLE_NoBorder = 0x00000001,
00044 STYLE_HighlightOnEnter = 0x00000002,
00045 STYLE_LargeButton = 0x00000004
00046 };
00047
00049 CTRL_MENUBUTTON (
00050 ) : m_menu(0), m_toppixel(0), m_bottompixel(0), m_bMenuMapped(false)
00051 { }
00052
00054 virtual ~CTRL_MENUBUTTON (
00055 );
00056
00064 ID AddItem (
00065 ID id,
00066 const MISTRING& label,
00067 ITEMSTYLE style = ITEMSTYLE_Normal
00068 );
00069
00071 void Create (
00072 MGUI::LAYOUT_PANE_BASE& ParentPane,
00073 const MISTRING& label,
00074 STYLE style = STYLE_Normal,
00075 MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize
00076 );
00077
00079 void Create (
00080 MGUI::LAYOUT_PANE_BASE& ParentPane,
00081 ICONID iconid,
00082 const MISTRING& tooltip,
00083 STYLE style = STYLE_Normal,
00084 int iconsize = 0
00085 );
00086
00088 bool GetItemState (
00089 ID id
00090 ) const;
00091
00093 int GetNumItems () const;
00094
00096 void RemoveAllItems ();
00097
00099 void RemoveItemByID (
00100 ID id
00101 );
00102
00104 void RemoveItemByIndex (
00105 int indx
00106 );
00107
00109 void SetDelegateOnSelection (
00110 DELEGATE_VOID_ID delegate
00111 ) { m_DelegateOnSelection = delegate; }
00112
00114 void SetItemEnabled (
00115 ID id,
00116 bool enabled = true
00117 );
00118
00120 void SetItemState (
00121 ID id,
00122 bool state
00123 );
00124
00125 protected:
00126
00129 virtual void OnMenuPopup (
00130 );
00131
00134 virtual void OnSelection (
00135 ID id
00136 );
00137
00138 private:
00139 #ifndef GENERATING_DOXYGEN_OUTPUT
00140
00141 struct ITEM {
00142 ID m_id;
00143 Widget m_widget;
00144 };
00145
00146 DELEGATE_VOID_ID m_DelegateOnSelection;
00147 MILIST<ITEM>m_items;
00148 Widget m_menu;
00149 MPIXEL m_toppixel;
00150 MPIXEL m_bottompixel;
00151 bool m_bMenuMapped;
00152
00153 static void CB_Select (Widget, CTRL_MENUBUTTON*, void*);
00154 static void CB_MenuPopup (Widget, CTRL_MENUBUTTON*, void*);
00155 static void EH_Highlight (Widget, CTRL_MENUBUTTON*, void*, void*);
00156
00157 bool CreateIcon (
00158 LAYOUT_PANE_BASE& ParentPane,
00159 ICONID iconid,
00160 const char *name,
00161 STYLE style,
00162 int iconsize
00163 );
00164
00165 void CreateWidget (
00166 LAYOUT_PANE_BASE& ParentPane,
00167 XTARGS& args,
00168 const char *name,
00169 STYLE style
00170 );
00171
00172 Widget GetItemWidget (
00173 ID id
00174 ) const;
00175
00176 CTRL_MENUBUTTON (const CTRL_MENUBUTTON&);
00177 CTRL_MENUBUTTON& operator= (const CTRL_MENUBUTTON&);
00178 #endif // GENERATING_DOXYGEN_OUTPUT
00179 };
00180
00181 #ifndef GENERATING_DOXYGEN_OUTPUT
00182 DEFINE_ENUM_OP_BITWISE(MGUI::CTRL_MENUBUTTON::ITEMSTYLE)
00183 DEFINE_ENUM_OP_BITWISE(MGUI::CTRL_MENUBUTTON::STYLE)
00184 #endif
00185
00186 }
00187
00188 #endif // INC_MGUI_MENUBTN_H