00001
00027 #ifndef INC_MGUI_LISTBOX_H
00028 #define INC_MGUI_LISTBOX_H
00029
00030 #ifndef INC_MGUI_CTRL_H
00031 #include <mgui/ctrl.h>
00032 #endif
00033
00034 #ifndef INC_MI32_INIDEFNS_H
00035 #include <mi32/inidefns.h>
00036 #endif
00037
00038 namespace MGUI {
00039
00040 #ifndef GENERATING_DOXYGEN_OUTPUT
00041 class XMLIST;
00042 #endif
00043
00044
00048 class CTRL_LISTBOX : public MGUI::CTRL {
00049 public:
00050
00052 enum STYLE {
00053 STYLE_Default = 0x00,
00054 STYLE_Sorted = 0x01,
00055 STYLE_MultiSelect = 0x02,
00056 STYLE_ExtendedSelect = 0x04,
00057 STYLE_ResizeIfPossible = 0x08,
00058 STYLE_ExpandIfNeeded = 0x10
00059 };
00060
00062 CTRL_LISTBOX ();
00063
00065 virtual ~CTRL_LISTBOX ();
00066
00071 int AddItem (
00072 ID id,
00073 const MISTRING& string,
00074 bool resize = true
00075 );
00076
00078 void Create (
00079 MGUI::LAYOUT_PANE_BASE& ParentPane,
00080 int height = 5,
00081 int width = 0,
00082 MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_Expand,
00083 STYLE style = STYLE_Default
00084 );
00085
00087 void DeleteAllItems ();
00088
00090 void DeleteItem (
00091 int index
00092 );
00093
00095 void DeleteItemID (
00096 ID id
00097 );
00098
00101 void DeselectAllItems ();
00102
00104 int GetCount () const;
00105
00108 int GetIndexFromID (
00109 ID id
00110 ) const;
00111
00114 ID GetItemID (
00115 int index
00116 ) const;
00117
00120 MISTRING GetItemString (
00121 int index
00122 ) const;
00123
00126 int GetSelectedCount () const;
00127
00130 int GetSelectedItem () const;
00131
00134 ID GetSelectedItemID () const;
00135
00137 ERRVALUE GetSelectedItems (
00138 SIMPLE_ARRAY<int>& items
00139 ) const;
00140
00142 int GetTopIndex () const;
00143
00146 void IniRead (
00147 INIHANDLE IniHandle,
00148 const char *IniGroup,
00149 const char *IniField,
00150 bool notify = true
00151 );
00152
00154 void IniWrite (
00155 INIHANDLE IniHandle,
00156 const char *IniGroup,
00157 const char *IniField
00158 ) const { ::IniWrite(IniHandle,IniGroup,IniField,static_cast<INT32>(GetSelectedItemID())); }
00159
00163 int InsertItem (
00164 int index,
00165 ID id,
00166 const MISTRING& string
00167 );
00168
00170 bool IsItemSelected (
00171 int index
00172 ) const;
00173
00175 void SetDelegateOnChangeSelection (
00176 DELEGATE_VOID_NOPARMS delegate
00177 ) { m_DelegateOnChangeSelection = delegate; }
00178
00180 void SetDelegateOnDoubleClick (
00181 DELEGATE_VOID_NOPARMS delegate
00182 ) { m_DelegateOnDoubleClick = delegate; }
00183
00186 void SetItemSelected (
00187 int index,
00188 bool select = true
00189 );
00190
00194 void SetSelectedItem (
00195 int index
00196 );
00197
00201 void SetSelectedItemID (
00202 ID id
00203 );
00204
00206 void SetTopIndex (
00207 int index
00208 );
00209
00210 private:
00211 #ifndef GENERATING_DOXYGEN_OUTPUT
00212
00213 DELEGATE_VOID_NOPARMS m_DelegateOnChangeSelection;
00214 DELEGATE_VOID_NOPARMS m_DelegateOnDoubleClick;
00215
00216 XMLIST *m_pxmlist;
00217 static void CB_ChangeSelection (Widget, CTRL_LISTBOX*, void*);
00218 static void CB_DoubleClick (Widget, CTRL_LISTBOX*, void*);
00219
00220 void OnChangeSelection ();
00221 void OnDoubleClick ();
00222
00223 CTRL_LISTBOX (const CTRL_LISTBOX&);
00224 CTRL_LISTBOX& operator= (const CTRL_LISTBOX&);
00225 #endif // GENERATING_DOXYGEN_OUTPUT
00226
00227 };
00228
00229 #ifndef GENERATING_DOXYGEN_OUTPUT
00230 DEFINE_ENUM_OP_BITWISE(MGUI::CTRL_LISTBOX::STYLE)
00231 #endif
00232
00233
00234
00235 }
00236
00237 #endif // INC_MGUI_LISTBOX_H