00001
00091 #ifndef INC_MGUI_FORMLIST_H
00092 #define INC_MGUI_FORMLIST_H
00093
00094 #ifndef INC_MGUI_CTRL_H
00095 #include <mgui/ctrl.h>
00096 #endif
00097
00098 #ifndef INC_MGUI_KEYCODE_H
00099 #include <mgui/keycode.h>
00100 #endif
00101
00102 #ifndef INC_MGUI_POINTERBUTTON_H
00103 #include <mgui/pointerbutton.h>
00104 #endif
00105
00106 #ifndef INC_MI32_MISTRING_H
00107 #include <mi32/mistring.h>
00108 #endif
00109
00110 #ifndef INC_MI32_COLOR_H
00111 #include <mi32/color.h>
00112 #endif
00113
00114
00115 #ifndef GENERATING_DOXYGEN_OUTPUT
00116 namespace MGD {
00117 class CONTEXT;
00118 }
00119 struct LPOINT2D;
00120 #endif
00121
00122
00123 namespace MGUI {
00124
00125
00132 class FORM_LIST : public MGUI::FORM_COMPOSITE {
00133 #ifndef GENERATING_DOXYGEN_OUTPUT
00134 private:
00135 class PRIV;
00136 #endif // GENERATING_DOXYGEN_OUTPUT
00137
00138 public:
00139
00141 enum LISTSTYLE {
00142 LISTSTYLE_NoSelect = 0x00000000,
00143 LISTSTYLE_SelectSingle = 0x00000001,
00144 LISTSTYLE_SelectMulti = 0x00000002,
00145 LISTSTYLE_WidthInPixels = 0x00000004,
00146 LISTSTYLE_HeightInPixels = 0x00000008,
00147 LISTSTYLE_UseCommonBackground = 0x00000010,
00148 LISTSTYLE_NoFrame = 0x00000020,
00149 LISTSTYLE_NoHeading = 0x00000040,
00150 LISTSTYLE_NoScrollH = 0x00000080,
00151 LISTSTYLE_NoScrollV = 0x00000100,
00152 LISTSTYLE_NoScrollBars = LISTSTYLE_NoScrollH | LISTSTYLE_NoScrollV,
00153 LISTSTYLE_NoSort = 0x00000200,
00154 LISTSTYLE_NoToolTips = 0x00000400,
00155 LISTSTYLE_UseIcons = 0x00000800,
00156 LISTSTYLE_ShowItemSeparators = 0x00001000,
00157 LISTSTYLE_ShowFieldSeparators = 0x00002000,
00158 LISTSTYLE_ShowColumnSeparators = 0x00004000,
00159 LISTSTYLE_UseSelectButtons = 0x00008000,
00160 LISTSTYLE_AllowReorderFields = 0x00010000,
00161 LISTSTYLE_AllowShowHideFields = 0x00020000,
00162 LISTSTYLE_NoSaveWidth = 0x00040000,
00163 LISTSTYLE_NoSaveHeight = 0x00080000,
00164 LISTSTYLE_NoSaveSize = LISTSTYLE_NoSaveWidth | LISTSTYLE_NoSaveHeight,
00165 LISTSTYLE_NoMultiColumn = 0x00100000,
00166 LISTSTYLE_ToggleSelect = 0x00200000,
00167 LISTSTYLE_AllowMultiColumnDetails = 0x00400000,
00168 LISTSTYLE_NoFitToContent = 0x00800000,
00169 };
00170
00172 enum FIELDSTYLE {
00173 FIELDSTYLE_AlignLeft = 0x0000,
00174 FIELDSTYLE_AlignRight = 0x0001,
00175 FIELDSTYLE_AlignCenter = 0x0002,
00176 FIELDSTYLE_AlignMask = 0x0003,
00177 FIELDSTYLE_AllowEdit = 0x0004,
00178 FIELDSTYLE_NoSort = 0x0008,
00179 FIELDSTYLE_NoResize = 0x0010,
00180 FIELDSTYLE_NoShowHide = 0x0020,
00181 FIELDSTYLE_InitHidden = 0x0100,
00182 FIELDSTYLE_InitSortDescending = 0x0200,
00183 FIELDSTYLE_IconTextRight = 0x0400,
00184 FIELDSTYLE_IconRight = 0x0800,
00185
00186
00187 };
00188
00189 enum VIEWMODE {
00190 VIEWMODE_List = 0,
00191 VIEWMODE_Details = 1,
00192 VIEWMODE_COUNT
00193 };
00194
00196 enum EDITMODE {
00197 EDITMODE_InsertEnd,
00198 EDITMODE_SelectAll,
00199 EDITMODE_Clear
00200 };
00201
00203 enum FIELDWIDTH {
00204 FIELDWIDTH_HeadingOnly = 0,
00205 FIELDWIDTH_HeadingAndData = -1,
00206 FIELDWIDTH_DataOnly = -2,
00207 FIELDWIDTH_AsAdded = -3,
00208 };
00209
00211 enum COLORUSE {
00212 COLORUSE_HeadingBackground = 0,
00213 COLORUSE_HeadingText,
00214 COLORUSE_HeadingSeparator,
00215 COLORUSE_HeadingShadowDark,
00216 COLORUSE_HeadingShadowLight,
00217 COLORUSE_ItemBackgroundNormal,
00218 COLORUSE_ItemBackgroundSelected,
00219 COLORUSE_ItemTextNormal,
00220 COLORUSE_ItemTextSelected,
00221 COLORUSE_ItemSeparator,
00222 COLORUSE_FieldSeparator,
00223 COLORUSE_ColumnSeparator,
00224 COLORUSE_COUNT
00225 };
00226
00227 enum ENSUREVISIBLE {
00228 ENSUREVISIBLE_ScrollMinimum = 0,
00229 ENSUREVISIBLE_Beginning = 1,
00230 ENSUREVISIBLE_NearBeginning = 2,
00231 ENSUREVISIBLE_NearEnd = 3,
00232 ENSUREVISIBLE_End = 4,
00233 ENSUREVISIBLE_PartialOK = 9
00234 };
00235
00237 class DISPINFO {
00238 public:
00239
00240 DISPINFO () :
00241 m_IconID(ICONID__NONE)
00242 { }
00243
00244 ~DISPINFO() {}
00245
00246 MISTRING m_text;
00247 ICONID m_IconID;
00248 };
00249
00251 class CUSTOMDRAW {
00252 public:
00254 const COLOR& GetColorBackground (
00255 ) const { return (m_ColorBackground); }
00257 const COLOR& GetColorText (
00258 ) const { return (m_ColorText); }
00260 int GetFieldNum (
00261 ) const { return (m_fieldnum); }
00262 MGD::CONTEXT* GetGC (
00263 ) const { return (m_gc); }
00265 int GetItemNum (
00266 ) const { return (m_itemnum); }
00268 const LRECT2D& GetRect (
00269 ) const { return (m_rect); }
00271 bool HasSetColorBackground (
00272 ) const { return (m_ChangedColorBackground); }
00274 bool HasSetColorText (
00275 ) const { return (m_ChangedColorText); }
00277 void SetColorBackground (
00278 const COLOR& color
00279 ) { m_ColorBackground = color; m_ChangedColorBackground = true; }
00281 void SetColorText (
00282 const COLOR& color
00283 ) { m_ColorText = color; m_ChangedColorText = true; }
00285 void SetRect (
00286 const LRECT2D& rect
00287 ) { m_rect = rect; }
00288 private:
00289 #ifndef GENERATING_DOXYGEN_OUTPUT
00290 friend class FORM_LIST::PRIV;
00291
00292 int m_itemnum;
00293 int m_fieldnum;
00294 LRECT2D m_rect;
00295 COLOR m_ColorBackground;
00296 COLOR m_ColorText;
00297 bool m_ChangedColorBackground;
00298 bool m_ChangedColorText;
00299 MGD::CONTEXT *m_gc;
00300
00301 CUSTOMDRAW (int itemnum, int fieldnum, MGD::CONTEXT *gc);
00302 ~CUSTOMDRAW ();
00303 #endif
00304 };
00305
00308 typedef fastdelegate::FastDelegate<bool(int itemnum, int fieldnum, const MGUI::POINT&, MGUI::POINTERBUTTON, MGUI::KEYSTATE)> DELEGATE_ONPOINTER;
00309
00312 typedef fastdelegate::FastDelegate<bool(int itemnum, int fieldnum, const MGUI::POINT&, MGUI::KEYSTATE, MGUI::KEYCODE)> DELEGATE_ONKEY;
00313
00316 typedef fastdelegate::FastDelegate<bool(int itemnum, int fieldnum, MISTRING&)> DELEGATE_ONEDIT;
00317
00319 typedef fastdelegate::FastDelegate<bool(int itemnum, int fieldnum)> DELEGATE_ONFIELD;
00320
00323 typedef fastdelegate::FastDelegate<bool(CUSTOMDRAW& customdraw)> DELEGATE_ONCUSTOMDRAW;
00324
00326 typedef fastdelegate::FastDelegate<void(int itemnum, int fieldnum, DISPINFO&)> DELEGATE_ONGETDISPINFO;
00327
00330 typedef fastdelegate::FastDelegate<int(int itemnum1, int itemnum2, int fieldnum)> DELEGATE_ONCOMPARE;
00331
00333 typedef fastdelegate::FastDelegate<void(int width, int height)> DELEGATE_ONSIZE;
00334
00336 typedef fastdelegate::FastDelegate<bool(int itemnum, int fieldnum, MGUI::CTRL_TOOLTIP&)> DELEGATE_ONTOOLTIP;
00337
00339 typedef fastdelegate::FastDelegate<bool(int itemnum, int fieldnum, MGUI::CTRL_TOOLTIP&, const MGUI::POINT&)> DELEGATE_ONTOOLTIPPOINT;
00340
00342 FORM_LIST ();
00343
00345 virtual ~FORM_LIST ();
00346
00351 int AddField (
00352 const MISTRING& label,
00353 FIELDSTYLE style = FIELDSTYLE_AlignLeft,
00354 int DisplayWidth = FIELDWIDTH_HeadingOnly,
00355 const char *IniKey = 0
00356 );
00357
00360 int AppendItem (
00361 const MISTRING& string
00362 );
00363
00366 void ComputeFieldDisplayWidth (
00367 int fieldnum,
00368 FIELDWIDTH mode
00369 );
00370
00373 bool ComputeRelativePoint (
00374 int itemnum,
00375 int fieldnum,
00376 const MGUI::POINT& ptCanvas,
00377 MGUI::POINT& ptRelative
00378 ) const;
00379
00384 void Create (
00385 MGUI::LAYOUT_PANE_BASE& ParentPane,
00386 int height,
00387 int width,
00388 LISTSTYLE style = LISTSTYLE_NoSelect,
00389 VIEWMODE ViewMode = VIEWMODE_Details,
00390 MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_Expand
00391 );
00392
00394 void DeleteAllFields (
00395 );
00396
00398 void DeleteAllItems (
00399 ) { SetItemCount(0); }
00400
00403 void DeleteField (
00404 int fieldnum
00405 );
00406
00408 void DeleteItem (
00409 int itemnum
00410 );
00411
00413 void DeleteItemByID (
00414 ID id
00415 ) { DeleteItem(FindItemByID(id)); }
00416
00418 void DeselectAllItems (
00419 bool notify = true
00420 );
00421
00424 bool DlgShowHideFields (
00425 MDLGPARENT dlgparent
00426 );
00427
00430 bool EditItem (
00431 int itemnum,
00432 int fieldnum,
00433 EDITMODE editmode = EDITMODE_InsertEnd
00434 );
00435
00437 void EnsureVisible (
00438 int itemnum,
00439 int fieldnum = -1,
00440 ENSUREVISIBLE mode = ENSUREVISIBLE_ScrollMinimum
00441 );
00442
00445 int FindItemByID (
00446 ID id
00447 ) const;
00448
00451 int FindItemByID (
00452 const void *id
00453 ) const { return (FindItemByID(reinterpret_cast<ID>(id))); }
00454
00456 void FlashItem (
00457 int itemnum,
00458 int numtimes = 1
00459 ) const;
00460
00462 const COLOR& GetColor (
00463 COLORUSE use
00464 ) const;
00465
00467 int GetFieldCount (
00468 ) const;
00469
00471 void GetFieldDisplayOrderDetails (
00472 SIMPLE_ARRAY<int>& DisplayOrder
00473 ) const;
00474
00476 int GetFieldDisplayWidth (
00477 int fieldnum
00478 ) const;
00479
00482 MISTRING GetFieldLabel (
00483 int fieldnum
00484 ) const;
00485
00487 int GetFirstVisibleItem (
00488 ) const;
00489
00491 int GetItemCount (
00492 ) const;
00493
00495 MGUI::ID GetItemID (
00496 int itemnum
00497 ) const;
00498
00500 MISTRING GetItemText (
00501 int itemnum,
00502 int fieldnum
00503 ) const;
00504
00506 MGUI::CTRL& GetMenuParent (
00507 ) const;
00508
00511 int GetNextSelectedItem (
00512 int startitem = -1
00513 ) const;
00514
00516 int GetNumVisibleRows (
00517 ) const;
00518
00520 int GetSelectedCount (
00521 ) const;
00522
00524 const LPOINT2D& GetSize (
00525 ) const;
00526
00528 int GetRowHeight (
00529 ) const;
00530
00533 bool HasSorted (
00534 ) const;
00535
00537 bool HasSortFields (
00538 ) const;
00539
00542 int InsertItem (
00543 int pos,
00544 const MISTRING& string
00545 );
00546
00549 bool IsFieldSortAscending (
00550 int fieldnum
00551 ) const;
00552
00554 bool IsFieldVisible (
00555 int fieldnum,
00556 VIEWMODE ViewMode = VIEWMODE_COUNT
00557 ) const;
00558
00561 bool IsItemSelected (
00562 int itemnum
00563 ) const;
00564
00569 void LockLayout (
00570 FORM_LIST& ListLockTo
00571 );
00572
00574 void Redraw (
00575 );
00576
00578 void RedrawDisable (
00579 );
00580
00583 void RedrawEnable (
00584 );
00585
00587 void RedrawItem (
00588 int itemnum
00589 );
00590
00592 void RedrawItems (
00593 int firstitemnum,
00594 int lastitemnum
00595 );
00596
00598 void SaveLayout (
00599 ) const;
00600
00605 void SetColor (
00606 COLORUSE use,
00607 const COLOR& color
00608 );
00609
00612 void SetIconSize (
00613 int IconSize
00614 );
00615
00618 void SetFieldDisplayOrderDetails (
00619 const SIMPLE_ARRAY<int>& FieldOrder
00620 );
00621
00624 void SetFieldDisplayWidth (
00625 int fieldnum,
00626 int width
00627 );
00628
00630 void SetFieldLabel (
00631 int fieldnum,
00632 const MISTRING& label
00633 );
00634
00637 void SetFieldVisible (
00638 int fieldnum,
00639 bool visible
00640 );
00641
00643 void SetDelegateOnChangeLayout (
00644 DELEGATE_VOID_NOPARMS delegate
00645 );
00646
00648 void SetDelegateOnChangeOrder (
00649 DELEGATE_VOID_NOPARMS delegate
00650 );
00651
00656 void SetDelegateOnChangeSelection (
00657 DELEGATE_VOID_INT32 delegate
00658 );
00659
00662 void SetDelegateOnCompare (
00663 DELEGATE_ONCOMPARE delegate
00664 );
00665
00667 void SetDelegateOnDrawItem (
00668 DELEGATE_ONCUSTOMDRAW delegate
00669 );
00670
00672 void SetDelegateOnEditBegin (
00673 DELEGATE_ONEDIT delegate
00674 );
00675
00677 void SetDelegateOnEditCancel (
00678 DELEGATE_ONFIELD delegate
00679 );
00680
00682 void SetDelegateOnEditEnd (
00683 DELEGATE_ONEDIT delegate
00684 );
00685
00687 void SetDelegateOnFieldCompare (
00688 int fieldnum,
00689 DELEGATE_ONCOMPARE delegate
00690 );
00691
00693 void SetDelegateOnGetDispInfo (
00694 DELEGATE_ONGETDISPINFO delegate
00695 );
00696
00698 void SetDelegateOnKeyPress (
00699 DELEGATE_ONKEY delegate
00700 );
00701
00703 void SetDelegateOnLeftButtonDoubleClick (
00704 DELEGATE_ONPOINTER delegate
00705 );
00706
00709 void SetDelegateOnPointerButtonDown (
00710 DELEGATE_ONPOINTER delegate
00711 );
00712
00715 void SetDelegateOnPointerButtonUp (
00716 DELEGATE_ONPOINTER delegate
00717 );
00718
00720 void SetDelegateOnSize (
00721 DELEGATE_ONSIZE delegate
00722 );
00723
00725 void SetDelegateOnToolTip (
00726 DELEGATE_ONTOOLTIP delegate
00727 );
00728
00730 void SetDelegateOnToolTipPoint (
00731 DELEGATE_ONTOOLTIPPOINT delegate
00732 );
00733
00736 void SetIniKey (
00737 const char *IniKey,
00738 const char *IniGroup = 0
00739 );
00740
00742 ERRVALUE SetItemCount (
00743 int NumItems
00744 );
00745
00747 ERRVALUE SetItemID (
00748 int itemnum,
00749 ID id
00750 );
00751
00753 ERRVALUE SetItemIcon (
00754 int itemnum,
00755 ICONID iconid
00756 );
00757
00759 void SetItemSelected (
00760 int itemnum,
00761 bool selected = true,
00762 bool notify = true
00763 );
00764
00766 void SetItemText (
00767 int itemnum,
00768 int fieldnum,
00769 const MISTRING& string
00770 );
00771
00773 void SetRowHeight (
00774 int RowHeight,
00775 VIEWMODE ViewMode = VIEWMODE_List
00776 );
00777
00779 void SetViewMode (
00780 VIEWMODE ViewMode
00781 );
00782
00786 void Sort (
00787 );
00788
00791 void Sort (
00792 int fieldnum,
00793 bool bAscending = true
00794 );
00795
00797 void Sort (
00798 const SIMPLE_ARRAY<int>& FieldNums,
00799 const SIMPLE_ARRAY<bool>& FieldsAscending
00800 );
00801
00802 private:
00803 #ifndef GENERATING_DOXYGEN_OUTPUT
00804
00805 friend class PRIV;
00806 PRIV *m_pPriv;
00807
00808
00809 FORM_LIST (const FORM_LIST&);
00810 FORM_LIST& operator= (const FORM_LIST&);
00811
00812 #endif // GENERATING_DOXYGEN_OUTPUT
00813
00814 };
00815
00816 #ifndef GENERATING_DOXYGEN_OUTPUT
00817 DEFINE_ENUM_OP_BITWISE(MGUI::FORM_LIST::LISTSTYLE)
00818 DEFINE_ENUM_OP_BITWISE(MGUI::FORM_LIST::FIELDSTYLE)
00819 #endif
00820
00821
00822
00823 }
00824
00825 #endif // INC_MGUI_FORMLIST_H