00001
00115 #ifndef INC_MGUI_COMBOBOX_H
00116 #define INC_MGUI_COMBOBOX_H
00117
00118 #ifndef INC_MGUI_CTRL_H
00119 #include <mgui/ctrl.h>
00120 #endif
00121
00122 #ifndef INC_MI32_MISTRING_H
00123 #include <mi32/mistring.h>
00124 #endif
00125
00126 #ifndef INC_MI32_INIDEFNS_H
00127 #include <mi32/inidefns.h>
00128 #endif
00129
00130 namespace MGUI {
00131
00132 #ifndef GENERATING_DOXYGEN_OUTPUT
00133 class XMLIST;
00134 #endif
00135
00136
00137
00140 class CTRL_COMBOBOX : public MGUI::CTRL {
00141 public:
00142
00143 enum STYLE {
00144 STYLE_Default = 0x00,
00145 STYLE_Sorted = 0x01
00146 };
00147
00149 CTRL_COMBOBOX (
00150 );
00151
00153 virtual ~CTRL_COMBOBOX (
00154 );
00155
00160 int AddItem (
00161 ID id,
00162 const MISTRING& string,
00163 bool resize = true
00164 );
00165
00168 void AddUnitItem (
00169 int MeasureType,
00170 int UnitID
00171 );
00172
00175 void AddUnitItems (
00176 int MeasureType,
00177 int DftUnitID = 0
00178 );
00179
00181 void Create (
00182 MGUI::LAYOUT_PANE_BASE& ParentPane,
00183 int listheight = 12,
00184 int width = 0,
00185 MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize,
00186 STYLE style = STYLE_Default
00187 );
00188
00190 void DeleteAllItems (
00191 );
00192
00194 void DeleteItem (
00195 int index
00196 );
00197
00199 void DeleteItemID (
00200 ID id
00201 );
00202
00204 int GetCount (
00205 ) const;
00206
00209 int GetIndexFromID (
00210 ID id
00211 ) const;
00212
00215 ID GetItemID (
00216 int index
00217 ) const;
00218
00221 MISTRING GetItemString (
00222 int index
00223 ) const;
00224
00227 int GetSelectedItem (
00228 ) const;
00229
00232 ID GetSelectedItemID (
00233 ) const;
00234
00237 void IniRead (
00238 INIHANDLE IniHandle,
00239 const char *IniGroup,
00240 const char *IniField,
00241 bool notify = true
00242 );
00243
00246 void IniRead (
00247 INIHANDLE IniHandle,
00248 const char *IniGroup,
00249 const char *IniField,
00250 ID dftid,
00251 bool notify
00252 );
00253
00255 void IniWrite (
00256 INIHANDLE IniHandle,
00257 const char *IniGroup,
00258 const char *IniField
00259 ) const { ::IniWrite(IniHandle,IniGroup,IniField,static_cast<INT32>(GetSelectedItemID())); }
00260
00264 int InsertItem (
00265 int index,
00266 ID id,
00267 const MISTRING& string
00268 );
00269
00271 bool IsItemSelected (
00272 int index
00273 ) const;
00274
00276 void SetDelegateOnSelection (
00277 DELEGATE_VOID_NOPARMS delegate
00278 ) { m_DelegateOnSelection = delegate; }
00279
00281 virtual void SetEnabled (
00282 bool enabled = true
00283 );
00284
00287 void SetSelectedItem (
00288 int index,
00289 bool notify = false
00290 );
00291
00295 void SetSelectedItemID (
00296 ID id,
00297 bool notify = false
00298 );
00299
00302 void SetSelectedPrevious (
00303 bool notify = false
00304 );
00305
00307 void SetSorted (
00308 bool sorted = true
00309 );
00310
00312 void SizeToContentWidth (
00313 );
00314
00315 private:
00317 virtual void v_CreateEnd ();
00318
00319 #ifndef GENERATING_DOXYGEN_OUTPUT
00320
00321 DELEGATE_VOID_NOPARMS m_DelegateOnSelection;
00322 Widget m_text;
00323 Widget m_arrowpb;
00324 XMLIST *m_pxmlist;
00325 Widget m_listshell;
00326 UINT16 m_listheight;
00327 UINT16 m_maxwidth;
00328 int m_CurrentIndex;
00329 int m_PreviousIndex;
00330
00331 static void CB_ArrowActivate (Widget, CTRL_COMBOBOX*, void*);
00332 static void CB_ListBrowseSelect (Widget, CTRL_COMBOBOX*, void*);
00333 static void EH_Shell (Widget, CTRL_COMBOBOX*, XEvent*, Boolean*);
00334
00335 void OnSelection ();
00336 void PopdownShell ();
00337 void PopupShell ();
00338 bool UpdateCurrentIndex ();
00339
00340 CTRL_COMBOBOX (const CTRL_COMBOBOX&);
00341 CTRL_COMBOBOX& operator= (const CTRL_COMBOBOX&);
00342 #endif // GENERATING_DOXYGEN_OUTPUT
00343 };
00344
00345 #ifndef GENERATING_DOXYGEN_OUTPUT
00346 DEFINE_ENUM_OP_BITWISE(MGUI::CTRL_COMBOBOX::STYLE)
00347 #endif
00348
00349
00350
00352 class FORM_COMBOBOX : public MGUI::FORM_COMPOSITE {
00353 public:
00354
00356 FORM_COMBOBOX (
00357 );
00358
00360 virtual ~FORM_COMBOBOX (
00361 );
00362
00367 int AddItem (
00368 ID id,
00369 const MISTRING& string,
00370 bool resize = true
00371 ) { return (m_combobox.AddItem(id,string,resize)); }
00372
00375 void AddUnitItem (
00376 int MeasureType,
00377 int UnitID
00378 ) { m_combobox.AddUnitItem(MeasureType,UnitID); }
00379
00382 void AddUnitItems (
00383 int MeasureType,
00384 int DftUnitID = 0
00385 ) { m_combobox.AddUnitItems(MeasureType,DftUnitID); }
00386
00388 void Create (
00389 MGUI::LAYOUT_PANE_BASE& ParentPane,
00390 const MISTRING& label,
00391 int listheight = 12,
00392 int width = 0,
00393 MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize,
00394 MGUI::CTRL_COMBOBOX::STYLE style = MGUI::CTRL_COMBOBOX::STYLE_Default,
00395 MGUI::CTRL_LABEL::STYLE labelstyle = MGUI::CTRL_LABEL::STYLE_LeftNoWrap
00396 );
00397
00399 void DeleteAllItems (
00400 ) { m_combobox.DeleteAllItems(); }
00401
00403 void DeleteItem (
00404 int index
00405 ) { m_combobox.DeleteItem(index); }
00406
00408 void DeleteItemID (
00409 ID id
00410 ) { m_combobox.DeleteItemID(id); }
00411
00413 CTRL_COMBOBOX& GetComboBox (
00414 ) { return (m_combobox); }
00415
00417 const CTRL_COMBOBOX& GetComboBox (
00418 ) const { return (m_combobox); }
00419
00421 int GetCount (
00422 ) const { return (m_combobox.GetCount()); }
00423
00426 int GetIndexFromID (
00427 ID id
00428 ) const { return (m_combobox.GetIndexFromID(id)); }
00429
00432 ID GetItemID (
00433 int index
00434 ) const { return (m_combobox.GetItemID(index)); }
00435
00438 MISTRING GetItemString (
00439 int index
00440 ) const { return (m_combobox.GetItemString(index)); }
00441
00444 MGUI::CTRL_LABEL& GetLabel (
00445 ) { return (m_label); }
00446
00449 int GetSelectedItem (
00450 ) const { return (m_combobox.GetSelectedItem()); }
00451
00454 ID GetSelectedItemID (
00455 ) const { return (m_combobox.GetSelectedItemID()); }
00456
00460 int InsertItem (
00461 int index,
00462 ID id,
00463 const MISTRING& string
00464 ) { return (m_combobox.InsertItem(index,id,string)); }
00465
00467 bool IsItemSelected (
00468 int index
00469 ) const { return (m_combobox.IsItemSelected(index)); }
00470
00472 void SetDelegateOnSelection (
00473 DELEGATE_VOID_NOPARMS delegate
00474 ) { m_combobox.SetDelegateOnSelection(delegate); }
00475
00478 void SetSelectedItem (
00479 int index,
00480 bool notify = false
00481 ) { m_combobox.SetSelectedItem(index,notify); }
00482
00486 void SetSelectedItemID (
00487 ID id,
00488 bool notify = false
00489 ) { m_combobox.SetSelectedItemID(id,notify); }
00490
00493 void SetSelectedPrevious (
00494 bool notify = false
00495 ) { m_combobox.SetSelectedPrevious(notify); }
00496
00498 void SetSorted (
00499 bool sorted = true
00500 ) { m_combobox.SetSorted(sorted); }
00501
00502 private:
00504 virtual void v_CreateEnd ();
00505
00506 #ifndef GENERATING_DOXYGEN_OUTPUT
00507
00508 MGUI::CTRL_COMBOBOX m_combobox;
00509 MGUI::CTRL_LABEL m_label;
00510
00511 FORM_COMBOBOX (const FORM_COMBOBOX&);
00512 FORM_COMBOBOX& operator= (const FORM_COMBOBOX&);
00513 #endif // GENERATING_DOXYGEN_OUTPUT
00514 };
00515
00516
00517
00518 }
00519
00520 #endif // INC_MGUI_COMBOBOX_H