00001
00051 #ifndef INC_MI32_MIGRID_H
00052 #define INC_MI32_MIGRID_H
00053
00054 #ifndef INC_MI32_MGD2_H
00055 #include <mi32/mgd2.h>
00056 #endif
00057
00058 #ifndef INC_MI32_MEMPOOL_H
00059 #include <mi32/mempool.h>
00060 #endif
00061
00062 #ifndef INC_MGUI_TOOLTIP_H
00063 #include <mgui/tooltip.h>
00064 #endif
00065
00066 #ifndef INC_MGUI_MENU_H
00067 #include <mgui/menu.h>
00068 #endif
00069
00070 #ifndef INC_MI32_UCSTRING_H
00071 #include <mi32/ucstring.h>
00072 #endif
00073
00074 #ifndef INC_MI32_XDEFNS_H
00075 #include <mi32/xdefns.h>
00076 #endif
00077
00078
00079 #ifndef GENERATING_DOXYGEN_OUTPUT
00080 class MIGRIDCELL;
00081 class MIGRIDCTRL;
00082 class MIGRIDEDITHANDLE;
00083 class DBEDIT;
00084 class DBEDIT_TDATA;
00085 namespace MGUI {
00086 class IMAGELIST;
00087 class CTRL_TOOLTIP;
00088 }
00089 namespace MGD {
00090 class IMAGELIST;
00091 class DEVICE_X;
00092 }
00093 #endif
00094
00095
00101
00102 class MIGRIDCELL {
00103 public:
00104 enum ALIGNMENT {
00105 ALIGN_Left = 0,
00106 ALIGN_Right,
00107 ALIGN_Center
00108 };
00109
00110 enum BORDER {
00111 BORDER_None = 0x0000,
00112 BORDER_LThin = 0x0001,
00113 BORDER_TThin = 0x0002,
00114 BORDER_RThin = 0x0004,
00115 BORDER_BThin = 0x0008,
00116 BORDER_Thin = 0x000F,
00117 BORDER_LMedium = 0x0010,
00118 BORDER_TMedium = 0x0020,
00119 BORDER_RMedium = 0x0040,
00120 BORDER_BMedium = 0x0080,
00121 BORDER_Medium = 0x00FF,
00122 BORDER_LThick = 0x0100,
00123 BORDER_TThick = 0x0200,
00124 BORDER_RThick = 0x0400,
00125 BORDER_BThick = 0x0800,
00126 BORDER_Thick = 0x0FFF,
00127 BORDER_Left = 0x0111,
00128 BORDER_Top = 0x0222,
00129 BORDER_Right = 0x0444,
00130 BORDER_Bottom = 0x0888,
00131 BORDER_Recessed = 0x1000,
00132 BORDER_Raised = 0x2000
00133 };
00134
00135
00136 enum PROPERTY {
00137 PROP_None = 0x00000000,
00138 PROP_Text = 0x00000001,
00139 PROP_FGColor = 0x00000002,
00140 PROP_BGColor = 0x00000004,
00141 PROP_BorderStyle = 0x00000008,
00142 PROP_Alignment = 0x00000010,
00143 PROP_DecimalPlaces= 0x00000020,
00144 PROP_ReadOnly = 0x00000040,
00145 PROP_DataType = 0x00000080,
00146 PROP_Param = 0x00000100,
00147 PROP_CellType = 0x00000200,
00148 PROP_CellTypeEx = 0x00000400,
00149 PROP_Label = 0x00000800,
00150 PROP_FGHColor = 0x00001000,
00151 PROP_BGHColor = 0x00002000,
00152 PROP_Bool = 0x00004000,
00153 PROP_MaxLen = 0x00008000,
00154 PROP_Icon = 0x00010000,
00155 PROP_All = 0xFFFFFFFF
00156 };
00157
00158 enum DATATYPE {
00159 DATATYPE_String,
00160 DATATYPE_Number,
00161 DATATYPE_Bool,
00162 DATATYPE_Time,
00163 DATATYPE_Currency,
00164 DATATYPE_Color
00165 };
00166
00209 enum CELLTYPE {
00210 CELLTYPE_Text = 0,
00211 CELLTYPE_Button = 1,
00212 CELLTYPE_DropDown = 2,
00213 CELLTYPE_Icon = 3,
00214 CELLTYPE_IconButton = 4,
00215 CELLTYPE_BigText = 5,
00216 CELLTYPE_PopUp = 6,
00217 CELLTYPE_Color = 7
00218 };
00219
00222 enum {
00223 CELLTYPEEX_Toggle = 0x00000001,
00224 CELLTYPEEX_Disabled = 0x00000002
00225 };
00226
00227
00228
00230 MIGRIDCELL (
00231 );
00232
00234 MIGRIDCELL (
00235 const MIGRIDCELL&
00236 );
00237
00239 ~MIGRIDCELL(
00240 );
00241
00242
00243
00245 MIGRIDCELL& operator=(
00246 const MIGRIDCELL&
00247 );
00248
00249
00250
00252 void ClearAll (
00253 );
00254
00256 void ClearProperty (
00257 PROPERTY p
00258 );
00259
00263 ALIGNMENT GetAlignment (
00264 ) const {
00265 return (m_set & PROP_Alignment) ? m_Alignment : ALIGN_Left;
00266 }
00267
00269 const COLOR& GetBackColor (
00270 ) const {
00271 return (m_set & PROP_BGColor) ? m_BGColor : s_black;
00272 }
00273
00275 const COLOR& GetBackColorHilighted (
00276 ) const {
00277 return (m_set & PROP_BGHColor) ? m_BGHColor : GetBackColor();
00278 }
00279
00281 bool GetBool (
00282 ) const
00283 {
00284 return (m_set & PROP_Bool) ? m_bState : false;
00285 }
00286
00290 BORDER GetBorder (
00291 ) const {
00292 return (m_set & PROP_BorderStyle) ? m_BorderStyle : BORDER_Thin;
00293 }
00294
00300 CELLTYPE GetCellType (
00301 ) const {
00302 return (m_set & PROP_CellType) ? m_CellType : CELLTYPE_Text;
00303 }
00304
00308 int GetCellTypeEx (
00309 ) const {
00310 return (m_set & PROP_CellTypeEx) ? m_nCellTypeEx : 0;
00311 }
00312
00316 DATATYPE GetDataType (
00317 ) const {
00318 return (m_set & PROP_DataType) ? m_DataType : DATATYPE_String;
00319 }
00320
00324 const COLOR& GetForeColor (
00325 ) const {
00326 return (m_set & PROP_FGColor) ? m_FGColor : s_black;
00327 }
00328
00334 const COLOR& GetForeColorHilighted (
00335 ) const {
00336 return (m_set & PROP_FGHColor) ? m_FGHColor : GetBackColor();
00337 }
00338
00346 int GetIconIndex (
00347 ) const {
00348 return (m_set & PROP_Icon) ? m_IconIndex : -1;
00349 }
00350
00355 const MIUNICODE* GetLabelText (
00356 ) const {
00357 return (m_set & PROP_Label) ? m_Label : NULL;
00358 }
00359
00360
00364 int GetMaxLen (
00365 ) const {
00366 return (m_set & PROP_MaxLen) ? m_nMaxLen : -1;
00367 }
00368
00375 double GetNumber (
00376 ) const;
00377
00381 int GetNumberPlaces (
00382 ) const {
00383 return (m_set & PROP_DecimalPlaces) ? m_nPlaces : 0;
00384 }
00385
00386
00388 void* GetParam (
00389 ) const {
00390 return (m_set & PROP_Param) ? m_pParam : NULL;
00391 }
00392
00394 bool GetReadOnly (
00395 ) const {
00396 return (m_set & PROP_ReadOnly) ? m_bReadOnly : false;
00397 }
00398
00402 const MIUNICODE* GetText (
00403 ) const {
00404 static MIUNICODE EmptyString = 0;
00405 return ((m_set & PROP_Text) && m_str) ? m_str : &EmptyString;
00406 }
00407
00411 MIUNICODE* GetTextCopy (
00412 ) const {
00413 return ((m_set & PROP_Text) && m_str) ? ucstrdup(m_str) : strtoucdup("");
00414 }
00415
00419 bool IsEmpty (
00420 ) const {
00421 if (!(m_set & PROP_Text)) return (false);
00422 return (m_str[0] == 0);
00423 }
00424
00425
00429 bool HasProperty (
00430 PROPERTY property
00431 ) const {
00432 return ((m_set & property) != PROP_None);
00433 }
00434
00436 void SetAlignment (
00437 ALIGNMENT alignment
00438 );
00439
00441 void SetBackColor (
00442 const COLOR& color
00443 );
00444
00446 void SetBackColorHilighted (
00447 const COLOR& color
00448 );
00449
00453 void SetBool (
00454 bool state
00455 );
00456
00458 void SetBorder (
00459 BORDER border
00460 );
00461
00466 void SetCellType (
00467 CELLTYPE type
00468 );
00469
00471 void SetCellTypeEx (
00472 INT32 val
00473 );
00474
00476 void SetDataType (
00477 DATATYPE type
00478 );
00479
00481 void SetForeColor (
00482 const COLOR& color
00483 );
00484
00486 void SetForeColorHilighted (
00487 const COLOR& color
00488 );
00489
00497 void SetIconIndex (
00498 int icon
00499 );
00500
00523 void SetLabelText (
00524 const MIUNICODE*
00525 );
00526
00530 void SetLabelText (
00531 const char*
00532 );
00533
00537 void SetMaxLen (
00538 int num
00539 );
00540
00544 void SetNumber (
00545 double num
00546 );
00547
00549 void SetNumberDecimals (
00550 int num
00551 );
00552
00554 void SetParam (
00555 void* ptr
00556 );
00557
00559 void SetReadOnly (
00560 bool state
00561 );
00562
00564 void SetText (
00565 const MIUNICODE*
00566 );
00567
00572 void MergeProperties (
00573 const MIGRIDCELL& cell,
00574 bool bBlendColors = false,
00575 PROPERTY mask = PROP_All
00576 );
00577
00578 private:
00579 #ifndef GENERATING_DOXYGEN_OUTPUT
00580
00581
00582
00583 void SetProperty (
00584 PROPERTY prop
00585 ) {
00586 m_set = static_cast<PROPERTY>((UINT32)prop | (UINT32)m_set);
00587 }
00588
00597
00598 PROPERTY m_set;
00599 MIUNICODE* m_str;
00600 MIUNICODE* m_Label;
00601 COLOR m_BGColor;
00602 COLOR m_FGColor;
00603 COLOR m_BGHColor;
00604 COLOR m_FGHColor;
00605 BORDER m_BorderStyle;
00606 ALIGNMENT m_Alignment;
00607 DATATYPE m_DataType;
00608 CELLTYPE m_CellType;
00609 INT32 m_nCellTypeEx;
00610 bool m_bReadOnly;
00611 bool m_bState;
00612 int m_nPlaces;
00613 void* m_pParam;
00614 int m_nMaxLen;
00615 int m_IconIndex;
00616
00617 static const COLOR s_black;
00618 #endif // GENERATING_DOXYGEN_OUTPUT
00619 };
00620
00621
00622 #ifndef GENERATING_DOXYGEN_OUTPUT
00623 DEFINE_ENUM_OP_BITWISE(MIGRIDCELL::BORDER)
00624 DEFINE_ENUM_OP_BITWISE(MIGRIDCELL::PROPERTY)
00625 #endif
00626
00627
00631 struct MIGRIDCUSTOMDRAW {
00633 MIGRIDCUSTOMDRAW (
00634 const MIGRIDCELL&,
00635 const LRECT2D&,
00636 MIGRIDCTRL&,
00637 MGD::CONTEXT*
00638 );
00639
00640 MIGRIDCUSTOMDRAW (
00641 const MIGRIDCUSTOMDRAW& rhs
00642 );
00643
00644 LRECT2D rect;
00645 COLOR BackgroundColor;
00646 COLOR TextColor;
00647 const MIGRIDCELL& cell;
00648 bool ChangedBackgroundColor;
00649 bool ChangedTextColor;
00650 MGD::CONTEXT* gc;
00651 bool bSelected;
00652 bool bHasFocus;
00653 MIGRIDCTRL* pCtrl;
00654 };
00655
00656
00662
00665 class MIGRIDCELLTYPE {
00666 public:
00667
00668
00669
00671 MIGRIDCELLTYPE (
00672 ) :
00673 m_bDeleteWithGrid(false)
00674 {
00675 }
00676
00678 virtual ~MIGRIDCELLTYPE (
00679 ) {
00680 }
00681
00682
00683
00684
00686 virtual void v_Draw (
00687 int row,
00688 int col,
00689 MIGRIDCUSTOMDRAW& dd
00690 );
00691
00696 virtual MIGRIDEDITHANDLE* v_StartEdit (
00697 MIGRIDCTRL* pCtrl,
00698 int col,
00699 int row,
00700 const LRECT2D& rect,
00701 const LPOINT2D* point,
00702 const MIGRIDCELL& cell,
00703 int key = 0
00704 );
00705
00711 virtual void v_OnDClicked (
00712 int col,
00713 int row,
00714 const LRECT2D& rect,
00715 const LPOINT2D& point,
00716 bool* pbProcessed,
00717 MIGRIDCTRL* pCtrl,
00718 UINT32 state
00719 );
00720
00722 virtual void v_OnLClicked (
00723 int col,
00724 int row,
00725 bool bIsDown,
00726 const LRECT2D& rect,
00727 const LPOINT2D& point,
00728 bool* pbProcessed,
00729 MIGRIDCTRL* pCtrl,
00730 UINT32 state
00731 );
00732
00734 virtual void v_OnRClicked (
00735 int col,
00736 int row,
00737 bool bIsDown,
00738 const LRECT2D& rect,
00739 const LPOINT2D& point,
00740 bool* pbProcessed,
00741 MIGRIDCTRL* pCtrl,
00742 UINT32 state
00743 );
00744
00746 bool GetDeleteWithGrid (
00747 ) const {
00748 return (m_bDeleteWithGrid);
00749 }
00750
00752 void SetDeleteWithGrid (
00753 bool state
00754 ) {
00755 m_bDeleteWithGrid = state;
00756 }
00757
00759 static void SetDefaultColors (
00760 MGD::PIXEL ShadowPixelLight,
00761 MGD::PIXEL ShadowPixelDark,
00762 MGD::PIXEL FocusRectPixel,
00763 MGD::PIXEL BackgroundPixel
00764 ) {
00765 s_ShadowPixelLight = ShadowPixelLight;
00766 s_ShadowPixelDark = ShadowPixelDark;
00767 s_FocusRectPixel = FocusRectPixel;
00768 s_BackgroundPixel = BackgroundPixel;
00769 }
00770
00771 protected:
00773 virtual void v_DrawBackground (
00774 const MIGRIDCUSTOMDRAW& drawdata
00775 );
00776
00778 virtual void v_DrawBorder (
00779 const MIGRIDCUSTOMDRAW& drawdata
00780 );
00781
00785 void DrawBorder (
00786 const MIGRIDCUSTOMDRAW& drawdata,
00787 MIGRIDCELL::BORDER border
00788 );
00789
00793 virtual void v_DrawButton (
00794 const MIGRIDCUSTOMDRAW& drawdata,
00795 bool bPressed,
00796 bool bTracking = false
00797 );
00798
00803 virtual void v_DrawText (
00804 const MIGRIDCUSTOMDRAW& drawdata,
00805 const MIUNICODE* str = 0
00806 );
00807
00809 void TrackButton (
00810 MIGRIDCTRL* pCtrl,
00811 int col,
00812 int row,
00813 const MIGRIDCELL& cell,
00814 const LRECT2D& rect,
00815 const LPOINT2D& point,
00816 bool bInitialState
00817 );
00818
00822 virtual void v_OnButtonPress (
00823 MIGRIDCTRL* pCtrl,
00824 int col,
00825 int row,
00826 const MIGRIDCELL& cell,
00827 const LRECT2D& rect
00828 );
00829
00833 static MGD::PIXEL s_ShadowPixelLight;
00834 static MGD::PIXEL s_ShadowPixelDark;
00835 static MGD::PIXEL s_FocusRectPixel;
00836 static MGD::PIXEL s_BackgroundPixel;
00837
00838 private:
00839 #ifndef GENERATING_DOXYGEN_OUTPUT
00840 #ifdef X_NATIVE
00841 static void EH_TrackButtonEventHndler (
00842 Widget da,
00843 void *ehdata,
00844 XEvent *event,
00845 Boolean *ContToDispatch
00846 );
00847 #endif
00848
00849 bool m_bDeleteWithGrid;
00850 friend class MIGRIDCTRL;
00851 #endif // GENERATING_DOXYGEN_OUTPUT
00852 };
00853
00859
00867 class MIGRIDEDITHANDLE : public MIGRIDCELL {
00868 public:
00869
00870
00871
00873 MIGRIDEDITHANDLE (
00874 MIGRIDCTRL* pCtrl,
00875 int col,
00876 int row,
00877 const LRECT2D& rect,
00878 const MIGRIDCELL& cell
00879 ) :
00880 MIGRIDCELL(cell),
00881 m_pCtrl(pCtrl),
00882 m_rect(rect),
00883 m_col(col),
00884 m_row(row)
00885 {
00886 }
00887
00892 virtual ~MIGRIDEDITHANDLE (
00893 );
00894
00895
00896
00902 MDLGPARENT GetTextControl (
00903 ) const { return v_GetTextControl(); }
00904
00908 bool Update (
00909 ) { return v_Update(); }
00910
00912 void Move (
00913 const LRECT2D& rect
00914 ) { v_Move(rect); }
00915
00916 protected:
00917
00923 virtual MDLGPARENT v_GetTextControl (
00924 ) const {
00925 return NULL;
00926 }
00927
00929 virtual void v_Move (
00930 const LRECT2D&
00931 ) {
00932 }
00933
00937 virtual bool v_Update (
00938 ) {
00939 return true;
00940 }
00941
00943 void SendMouseEvent (
00944 Widget widget,
00945 int EventCode,
00946 const LPOINT2D* point
00947 );
00948
00949 MIGRIDCTRL* m_pCtrl;
00950 LRECT2D m_rect;
00951 int m_col;
00952 int m_row;
00953 };
00954
00955
00969
00970 class MIGRIDCTRL {
00971 public:
00972
00973 enum SECTION {
00974 SECTION_None = 0,
00975 SECTION_Grid =1,
00976 SECTION_TopHeading,
00977 SECTION_SideHeading,
00978 SECTION_CornerButton,
00979 SECTION_HScroll,
00980 SECTION_VScroll,
00981 SECTION_Tab,
00982 SECTION_ColBorder,
00983 SECTION_RowBorder
00984 };
00985
00986 enum SCROLLMODE {
00987 SCROLLMODE_Normal,
00988 SCROLLMODE_Tracking
00989 };
00990
00992 enum CELLSTATE {
00993 CELLSTATE_None = 0x0000,
00994 CELLSTATE_Button = 0x0001,
00995 CELLSTATE_Shift = 0x0002,
00996 CELLSTATE_Control = 0x0004
00997 };
00998
01000 enum MOVEMENT {
01001 MOVE_Increment = 0,
01002 MOVE_Decrement,
01003 MOVE_PageUp,
01004 MOVE_PageDown,
01005 MOVE_Top,
01006 MOVE_Bottom
01007 };
01008
01009 struct SORTDATA {
01010 MIGRIDCTRL* m_this;
01011 int* m_cols;
01012 int m_NumCols;
01013 int m_bAscending;
01014 };
01015
01017 static void Test (
01018 DBEDIT* ddata,
01019 DBEDIT_TDATA* tdata
01020 );
01021
01022
01023
01025 MIGRIDCTRL (
01026 );
01027
01028
01029
01031 virtual ~MIGRIDCTRL (
01032 );
01033
01034
01035
01043 MIGRIDCELL::CELLTYPE AddCellType (
01044 MIGRIDCELLTYPE* ptype,
01045 bool bDeleteInGridsDestructor = false
01046 );
01047
01051 int AppendCol (
01052 );
01053
01055 int AppendRow (
01056 );
01057
01059 int ClearSelections (
01060 );
01061
01062 #ifdef X_NATIVE
01063 int Create (
01064 Widget parent,
01065 Arg *arg,
01066 int n
01067 );
01068 #endif
01069
01070 void DeleteAllItems (
01071 ) {
01072
01073 SetNumberRows(0);
01074 }
01075
01077 int DeleteCol (
01078 int col
01079 );
01080
01081 void DeleteItem (
01082 int row
01083 ) {
01084
01085 DeleteRow(row);
01086 }
01087
01089 int DeleteRow (
01090 int row
01091 );
01092
01094 int EditCancel (
01095 );
01096
01104 void EditFinish (
01105 MIGRIDEDITHANDLE* handle = NULL,
01106 bool bAborting = false
01107 );
01108
01110 void EditFinish (
01111 int col,
01112 int row,
01113 const MIGRIDCELL& cell
01114 );
01115
01117 int EnableColSwapping (
01118 bool bEnable = true
01119 );
01120
01122 int EnableMenu (
01123 bool bEnable = true
01124 );
01125
01130 void EnableUpdate (
01131 bool enable = true
01132 );
01133
01136 void EnsureVisible (
01137 int row,
01138 int col,
01139 bool bPartialOK = false
01140 );
01141
01142 int FindItemByData (
01143 PTRINT data
01144 ) const {
01145 return (FindItemByData((const void*)data));
01146 }
01147
01150 int FindItemByData (
01151 const void* data
01152 ) const;
01153
01156 int GetAbsoluteCellFromPoint (
01157 int x,
01158 int y,
01159 int* ptcol,
01160 int* ptrow
01161 ) const;
01162
01166 int GetBottomRow (
01167 ) const;
01168
01174 int GetCell (
01175 int col,
01176 int row,
01177 MIGRIDCELL* pCell
01178 ) const;
01179
01180
01185 int GetCell (
01186 int col,
01187 int row,
01188 MIGRIDCELL** ppCell
01189 ) const;
01190
01200 int GetCellIndirect (
01201 int col,
01202 int row,
01203 MIGRIDCELL* pCell,
01204 MIGRIDCELL::PROPERTY properties = MIGRIDCELL::PROP_All
01205 );
01206
01208 int GetCellRect (
01209 int col,
01210 int row,
01211 LRECT2D* rect
01212 ) const;
01213
01220 int GetColDefault (
01221 int col,
01222 MIGRIDCELL* pCell
01223 ) const;
01224
01230 int GetColTranslation (
01231 int VisualColumnNumber
01232 ) const;
01233
01234
01237 ERRVALUE GetColumnOrderArray (
01238 SIMPLE_ARRAY<INT32>&
01239 ) const;
01240
01244 int GetColWidth (
01245 int col,
01246 int* width
01247 ) const;
01248
01252 int GetColWidth (
01253 int col
01254 ) const;
01255
01259 int GetColumnWidth (
01260 int col
01261 ) const {
01262 return (GetColWidth(col));
01263 }
01264
01266 int GetCountPerPage (
01267 ) const;
01268
01272 int GetCurrentCol (
01273 ) const;
01274
01278 int GetCurrentRow (
01279 ) const;
01280
01286 int GetCurrentTab (
01287 ) const {
01288 return 0;
01289 }
01290
01291 #ifdef X_NATIVE
01295 Widget GetForm() const {
01296 return (m_wMainForm);
01297 }
01298 #endif
01299
01303 int GetGridDefault (
01304 MIGRIDCELL* pCell
01305 ) const;
01306
01310 int GetHeadingDefault (
01311 MIGRIDCELL* pCell
01312 ) const;
01313
01317 int GetHSHeight (
01318 ) const;
01319
01320
01324 const MGUI::IMAGELIST* GetImageList() const {
01325 return (m_ImageList);
01326 }
01327
01329 PTRUINT GetItemData (
01330 int row,
01331 int col = 0
01332 ) const {
01333 return (reinterpret_cast<PTRUINT>(GetItemDataPtr(row, col)));
01334 }
01335
01337 void* GetItemDataPtr (
01338 int row,
01339 int col = 0
01340 ) const;
01341
01349 int GetLeftCol (
01350 ) const;
01351
01357 int GetNextSelectedItem (
01358 int row
01359 ) const;
01360
01364 int GetNumberCols (
01365 ) const;
01366
01370 int GetNumberRows (
01371 ) const;
01372
01373 int GetItemCount (
01374 ) const {
01375 return (GetNumberRows());
01376 }
01377
01385 int GetRightCol (
01386 ) const;
01387
01393 int GetRowHeight (
01394 int row
01395 ) const;
01396
01397 int GetSelectedCount() const {
01398 return (m_SelectedCells.GetNumItems());
01399 }
01400
01404 const SIMPLE_ARRAY<LPOINT2D>& GetSelectedItems (
01405 ) const {
01406 return (m_SelectedCells);
01407 }
01408
01412 int GetSideHeadingWidth (
01413 ) const;
01414
01418 void GetSize (
01419 LPOINT2D& size
01420 ) const;
01421
01425 int GetTopHeadingHeight (
01426 ) const;
01427
01431 int GetTopRow (
01432 ) const;
01433
01437 int GetVSWidth (
01438 ) const;
01439
01443 int GotoCell (
01444 int col,
01445 int row
01446 );
01447
01453 int GotoCol (
01454 int col
01455 ) {
01456 return (GotoCell(col, GetCurrentRow()));
01457 }
01458
01464 int GotoRow (
01465 int row
01466 ) {
01467 return (GotoCell(GetCurrentCol(), row));
01468 }
01469
01471 int HideCurrentCell (
01472 ) {
01473 return (GotoCell(-1,-1));
01474 }
01475
01479 int InsertCol (
01480 int col
01481 );
01482
01484 int InsertColumn (
01485 int col,
01486 const MIUNICODE* string,
01487 MIGRIDCELL::ALIGNMENT alignment,
01488 int width = -1
01489 );
01490
01492 int InsertRow (
01493 int row
01494 );
01495
01499 bool IsSelected (
01500 int col,
01501 int row
01502 ) const;
01503
01510 int LockColumns (
01511 int cols
01512 );
01513
01520 int LockRows (
01521 int rows
01522 );
01523
01527 int MoveColPosition (
01528 int fromCol,
01529 int toCol,
01530 bool insertBefore
01531 );
01532
01538 int MoveCurrentCol (
01539 MOVEMENT movement
01540 );
01541
01545 int MoveCurrentRow (
01546 MOVEMENT movement
01547 );
01548
01557 virtual bool v_OnCanColSwap (
01558 int fromCol,
01559 int toCol
01560 );
01561
01565 virtual bool v_OnCanMove (
01566 int oldcol,
01567 int oldrow,
01568 int newcol,
01569 int newrow
01570 );
01571
01573 virtual bool v_OnCanSizeCol (
01574 int col
01575 );
01576
01578 virtual bool v_OnCanSizeRow (
01579 int row
01580 );
01581
01583 virtual bool v_OnCanSizeSideHdg (
01584 );
01585
01587 virtual bool v_OnCanSizeTopHdg (
01588 );
01589
01591 virtual void v_OnCellChange (
01592 int oldcol,
01593 int oldrow,
01594 int newcol,
01595 int newrow
01596 );
01597
01603 virtual bool v_OnCellTypeNotify (
01604 MIGRIDCELL::CELLTYPE celltype,
01605 int col,
01606 int row,
01607 INT32 msg,
01608 CELLSTATE param
01609 );
01610
01612 virtual void v_OnColChange (
01613 int oldcol,
01614 int newcol
01615 );
01616
01622 virtual void v_OnColSized (
01623 int col,
01624 int* width
01625 );
01626
01633 virtual void v_OnColSizing (
01634 int col,
01635 int* width
01636 );
01637
01648 virtual void v_OnDClicked (
01649 int col,
01650 int row,
01651 LRECT2D* rect,
01652 LPOINT2D* point,
01653 bool* pbProcessed,
01654 UINT32 state
01655 );
01656
01660 virtual bool v_OnDrawItem (
01661 int row,
01662 int col,
01663 MIGRIDCUSTOMDRAW& drawdata
01664 );
01665
01673 virtual bool v_OnEditContinue (
01674 int oldcol,
01675 int oldrow,
01676 int* newcol,
01677 int* newrow
01678 );
01679
01689 virtual bool v_OnEditFinish (
01690 int col,
01691 int row,
01692 MDLGPARENT TextControl,
01693 const MIUNICODE* string
01694 );
01695
01699 virtual bool v_OnEditFinish (
01700 int col,
01701 int row,
01702 const MIGRIDCELL& cell
01703 );
01704
01711 virtual bool v_OnEditStart (
01712 int col,
01713 int row
01714 );
01715
01727 virtual bool v_OnEditVerify (
01728 int col,
01729 int row,
01730 MDLGPARENT TextControl,
01731 const MIUNICODE* str
01732 );
01733
01739 virtual void v_OnGetCell (
01740 int col,
01741 int row,
01742 MIGRIDCELL* cell,
01743 MIGRIDCELL::PROPERTY mask = MIGRIDCELL::PROP_All
01744 );
01745
01746
01754 virtual bool v_OnHint (
01755 int col,
01756 int row,
01757 SECTION section,
01758 MGUI::CTRL_TOOLTIP& tooltip
01759 );
01760
01764 virtual bool v_OnHScrollHint (
01765 int col,
01766 MISTRING&
01767 );
01768
01774 virtual int v_OnItemCompare (
01775 UINT32 item1,
01776 UINT32 item2,
01777 const SORTDATA* sortdata
01778 );
01779
01782 virtual bool v_OnItemSelect (
01783 int row,
01784 int col
01785 );
01786
01791 virtual bool v_OnItemUnselect (
01792 int row,
01793 int col
01794 );
01795
01799 virtual void v_OnKillFocus (
01800 SECTION section
01801 );
01802
01809 virtual void v_OnLClicked (
01810 int col,
01811 int row,
01812 bool bIsMouseDown,
01813 LRECT2D* rect,
01814 LPOINT2D* point,
01815 bool* pbProcessed,
01816 UINT32 state
01817 );
01818
01820 virtual void v_OnLeftColChange (
01821 int oldcol,
01822 int newcol
01823 );
01824
01829 virtual void v_OnMenuCommand (
01830 int col,
01831 int row,
01832 SECTION section,
01833 int item
01834 );
01835
01845 virtual bool v_OnMenuStart (
01846 int col,
01847 int row,
01848 SECTION section,
01849 MGUI::MENU& menu
01850 );
01851
01861 virtual void v_OnRClicked (
01862 int col,
01863 int row,
01864 bool bIsMouseDown,
01865 LRECT2D* rect,
01866 LPOINT2D* point,
01867 bool* pbProcessed,
01868 UINT32 state
01869 );
01870
01872 virtual void v_OnRowChange (
01873 int oldrow,
01874 int newrow
01875 );
01876
01878 virtual void v_OnRowSized (
01879 int row,
01880 int* height
01881 );
01882
01884 virtual void v_OnRowSizing (
01885 int row,
01886 int* height
01887 );
01888
01890 virtual void v_OnSetCell (
01891 int col,
01892 int row,
01893 MIGRIDCELL* pCell
01894 );
01895
01897 virtual void v_OnSetFocus (
01898 SECTION section
01899 );
01900
01902 virtual void v_OnSetup (
01903 );
01904
01909 virtual void v_OnSideHeadingDClicked (
01910 int col,
01911 int row,
01912 LRECT2D* pRect,
01913 LPOINT2D* pPoint,
01914 bool* pbProcessed
01915 );
01916
01921 virtual void v_OnSideHeadingLClicked (
01922 int col,
01923 int row,
01924 bool bIsMouseDown,
01925 LRECT2D* pRect,
01926 LPOINT2D* pPoint,
01927 bool* pbProcessed
01928 );
01929
01936 virtual void v_OnSideHeadingRClicked (
01937 int col,
01938 int row,
01939 bool bIsMouseDown,
01940 LRECT2D* pRect,
01941 LPOINT2D* pPoint,
01942 bool* pbProcessed
01943 );
01944
01948 virtual void v_OnSize (
01949 int ntype,
01950 int width,
01951 int height
01952 );
01953
01954
01959 virtual void v_OnTopHeadingDClicked (
01960 int col,
01961 int row,
01962 LRECT2D* pRect,
01963 LPOINT2D* pPoint,
01964 bool* pbProcessed
01965 );
01966
01971 virtual void v_OnTopHeadingLClicked (
01972 int col,
01973 int row,
01974 bool bIsMouseDown,
01975 LRECT2D* pRect,
01976 LPOINT2D* pPoint,
01977 bool* pbProcessed
01978 );
01979
01986 virtual void v_OnTopHeadingRClicked (
01987 int col,
01988 int row,
01989 bool bIsMouseDown,
01990 LRECT2D* pRect,
01991 LPOINT2D* pPoint,
01992 bool* pbProcessed
01993 );
01994
01998 virtual bool v_OnVScrollHint (
01999 int row,
02000 MISTRING&
02001 );
02002
02004 int RedrawAll (
02005 );
02006
02008 int RedrawCell (
02009 int col,
02010 int row
02011 );
02012
02014 int RedrawCol (
02015 int col
02016 );
02017
02019 int RedrawRow (
02020 int row
02021 );
02022
02024 int Select (
02025 int col,
02026 int row
02027 );
02028
02030 int Unselect (
02031 int col,
02032 int row
02033 );
02034
02036 int SelectRange (
02037 int startcol,
02038 int startrow,
02039 int endcol,
02040 int endrow
02041 );
02042
02044 int Set3DHeight (
02045 int height
02046 );
02047
02053 int SetBallisticDelay (
02054 int millsec
02055 );
02056
02058 int SetCell (
02059 int col,
02060 int row,
02061 const MIGRIDCELL& pCell
02062 );
02063
02065 int SetColDefault (
02066 int col,
02067 const MIGRIDCELL& Cell
02068 );
02069
02071 int SetColTranslation (
02072 int VisualColumnNumber,
02073 int RealColumnNumber
02074 );
02075
02077 int SetColWidth (
02078 int col,
02079 int width
02080 );
02081
02083 int SetDefColWidth (
02084 int width
02085 );
02086
02090 int SetDefRowHeight (
02091 int height
02092 );
02093
02095 int SetGridDefault (
02096 const MIGRIDCELL& Cell
02097 );
02098
02100 int SetHeadingDefault (
02101 const MIGRIDCELL& Cell
02102 );
02103
02107 int SetHighlightRow (
02108 bool bWholeRow
02109 );
02110
02114 int SetHScrollMode (
02115 SCROLLMODE mode
02116 );
02117
02119 int SetHSHeight (
02120 int height
02121 );
02122
02128 void SetImageList (
02129 MGUI::IMAGELIST* ImageList,
02130 bool MakeACopy = true
02131 );
02132
02133
02140 void SetItemData (
02141 int row,
02142 int col,
02143 PTRUINT data
02144 ) {
02145 SetItemDataPtr(row, col, (void*)data);
02146 }
02147
02154 void SetItemData (
02155 int row,
02156 PTRUINT data
02157 ) {
02158 SetItemDataPtr(row, 0, (void*)data);
02159 }
02160
02167 void SetItemDataPtr (
02168 int row,
02169 int col,
02170 void* data
02171 );
02172
02179 void SetItemDataPtr (
02180 int row,
02181 void* data
02182 ) {
02183 SetItemDataPtr(row, 0, data);
02184 }
02185
02187 int SetLeftCol (
02188 int col
02189 );
02190
02192 int SetMargin (
02193 int pixels
02194 );
02195
02197 int SetMultiSelectMode (
02198 bool bEnable
02199 );
02200
02204 int SetNumberCols (
02205 int cols
02206 );
02207
02209 int SetNumberRows (
02210 int rows
02211 );
02212
02214 int SetRowDefault (
02215 int col,
02216 const MIGRIDCELL& Cell
02217 );
02218
02220 int SetRowHeight (
02221 int row,
02222 int height
02223 );
02224
02229 int SetSideHeadingColWidth (
02230 int col,
02231 int width
02232 );
02233
02238 int SetSideHeadingNumCols (
02239 int cols
02240 );
02241
02243 int SetSideHeadingWidth (
02244 int width
02245 );
02246
02250 void SetSize (
02251 const LPOINT2D& size
02252 );
02253
02254
02261 int SetTopHeadingRowHeight (
02262 int row,
02263 int height
02264 );
02265
02271 int SetTopHeadingNumRows (
02272 int rows
02273 );
02274
02278 int SetTopHeadingHeight (
02279 int height
02280 );
02281
02283 int SetTopRow (
02284 int row
02285 );
02286
02288 int SetUniformRowHeight (
02289 bool bUniform
02290 );
02291
02295 int SetUserSizingMode (
02296 bool bAllowResize
02297 );
02298
02302 int SetVScrollMode (
02303 SCROLLMODE mode
02304 );
02305
02307 int SetVSWidth (
02308 int width
02309 );
02310
02319 int SortBy (
02320 int* pCols,
02321 int num,
02322 bool bAscending
02323 );
02324
02326 int SortBy (
02327 int col,
02328 bool bAscending
02329 ) {
02330 return (SortBy(&col, 1, bAscending));
02331 }
02332
02334 int StartEdit (
02335 );
02336
02338 int StartEdit (
02339 int key
02340 );
02341
02343 int StartEdit (
02344 int col,
02345 int row,
02346 int key
02347 );
02348
02353 int StartMenu (
02354 int col,
02355 int row,
02356 LPOINT2D* point,
02357 SECTION section
02358 );
02359
02362 void SwapRows (
02363 INT32 row1,
02364 INT32 row2
02365 );
02366
02368 int UseHints (
02369 bool bUseHints = true
02370 );
02371
02373 int UseHScrollHints (
02374 bool bUseHints = true
02375 );
02376
02378 int UseVScrollHints (
02379 bool bUseHints = true
02380 );
02381
02382 #ifdef X_NATIVE
02384 Widget GetDA (
02385 int col,
02386 int row
02387 ) const {
02388 return GetDrawingAreaData(col, row).m_widget;
02389 }
02390 #endif
02391
02393 MGD::CONTEXT* GetGC (
02394 int col,
02395 int row
02396 ) const {
02397 return GetDrawingAreaData(col, row).m_gc;
02398 }
02399
02401 MGD::CONTEXT* GetDAGC (
02402 int col,
02403 int row
02404 ) const {
02405 return GetDrawingAreaData(col, row).m_dagc;
02406 }
02407
02409 void SetGCExclusive (
02410 MGD::CONTEXT* gc
02411 ) {
02412 m_GCExclusive = gc;
02413 }
02414
02416 void SetHideFocus (
02417 bool hide
02418 ) {
02419 m_bHideFocus = hide;
02420 };
02421
02422
02424 private:
02425 #ifndef GENERATING_DOXYGEN_OUTPUT
02426
02427
02428 enum DRAGACTION {
02429 DRAG_None = 0,
02430 DRAG_ColBorder,
02431 DRAG_RowBorder,
02432 DRAG_ColHeading,
02433 DRAG_RowHeading,
02434 DRAG_MultiSelect
02435 };
02436
02437 static int HeapSortSwap (
02438 INT32 rec1,
02439 INT32 rec2,
02440 void *vdata
02441 );
02442
02443 static int HeapSortCompare (
02444 INT32 rec1,
02445 INT32 rec2,
02446 void *vdata
02447 );
02448
02450 MIGRIDCTRL (
02451 const MIGRIDCTRL&
02452 );
02453
02455 MIGRIDCTRL& operator=(
02456 const MIGRIDCTRL&
02457 );
02458
02459
02460 class ROWDATA {
02461 public:
02462 int m_height;
02463 int m_ystart;
02464 MIGRIDCELL* m_pStyle;
02465 MIGRIDCELL** m_pHeading;
02466 MIGRIDCELL** m_pCellData;
02467 };
02468
02469 class COLDATA {
02470 public:
02471 int m_width;
02472 int m_xstart;
02473 int m_orderVtoR;
02474 int m_orderRtoV;
02475 MIGRIDCELL** m_pHeading;
02476 MIGRIDCELL* m_pStyle;
02477 };
02478
02479 class TOOLTIPDATA : public MGUI::CTRL_TOOLTIP {
02480 public:
02481 TOOLTIPDATA();
02482 ~TOOLTIPDATA();
02483
02484 MIGRIDCTRL *m_pCtrl;
02485 bool m_bDataTipShowing;
02486 bool m_bEnabled;
02487 #ifdef X_NATIVE
02488 Widget m_widget;
02489 #endif
02490 private:
02491 virtual bool v_OnShowRequest(int x, int y);
02492 };
02493
02494 struct DADATA {
02495 DADATA();
02496 ~DADATA();
02497
02498 void CBExpose(MIGRIDCTRL*);
02499 void CBResize(MIGRIDCTRL*);
02500 void DrawLineToDA(int x1, int y1, int x2, int y2);
02501 void DrawRectToDA(const LRECT2D&);
02502 void EraseDirtyArea();
02503
02504 MGD::DEVICE_X* m_gdisp;
02505 MGD::CONTEXT* m_gc;
02506 MGD::DEVICE_X* m_dagdisp;
02507 MGD::CONTEXT* m_dagc;
02508 TOOLTIPDATA m_tip;
02509 int m_height;
02510 int m_width;
02511 bool m_bDirty;
02512 LRECT2D m_DirtyArea;
02513 #ifdef X_NATIVE
02514 Widget m_widget;
02515 Display* m_xdisp;
02516 GC m_xgc;
02517 Pixmap m_pixmap;
02518 #endif
02519 };
02520
02521 void OnContextMenuCommand(MGUI::ID, bool);
02522
02523 #ifdef X_NATIVE
02524 static void CBT_ToolTipPopUp(void *cbdata, XtIntervalId *IntervalID);
02525 static void CB_ContextMenu(Widget, void*, void*);
02526 static void CB_Expose(Widget, MIGRIDCTRL*, void*);
02527 static void CB_Resize(Widget, MIGRIDCTRL*, void*);
02528 static void CB_HSB(Widget, MIGRIDCTRL*, void*);
02529 static void CB_VSB(Widget, MIGRIDCTRL*, void*);
02530 static void EH_MouseDown(Widget, MIGRIDCTRL*, XEvent*, Boolean*);
02531 static void EH_MouseUp(Widget, MIGRIDCTRL*, XEvent*, Boolean*);
02532 static void EH_MouseMove(Widget, MIGRIDCTRL*, XEvent*, Boolean*);
02533 static void EH_KeyPress(Widget, MIGRIDCTRL*, XEvent*, Boolean*);
02534 static void EH_SBTip(Widget, MIGRIDCTRL*, XEvent*, Boolean*);
02535 static void EH_DATip(Widget, MIGRIDCTRL*, XEvent*, Boolean*);
02536 static void EH_Resize(Widget, MIGRIDCTRL*, XEvent*, Boolean*);
02537 #endif
02538
02539 void BeginUpdate();
02540 void EndUpdate();
02541 void Blit();
02542
02543 #ifdef X_NATIVE
02546 int GetAbsoluteCellFromPoint (
02547 Widget widget,
02548 int x,
02549 int y,
02550 int* ptcol,
02551 int* ptrow
02552 ) const;
02553 #endif
02554
02555 int GetPrevCol (
02556 int col
02557 ) const;
02558
02559 int GetNextCol (
02560 int col
02561 ) const;
02562
02563 MIGRIDCELLTYPE* GetCellType (
02564 int col,
02565 int row
02566 );
02567
02568 #ifdef X_NATIVE
02569 DADATA* GetDrawingAreaData (
02570 Widget widget
02571 );
02572 #endif
02573
02574 DADATA* GetDrawingAreaData (
02575 int col,
02576 int row
02577 );
02578
02579 const DADATA& GetDrawingAreaData (
02580 int col,
02581 int row
02582 ) const;
02583
02584
02587
02588 LPOINT2D m_CurFocus;
02589 LPOINT2D m_DataSize;
02590 LPOINT2D m_UpperLeft;
02591 LPOINT2D m_DefaultCellSize;
02592
02593 SIMPLE_ARRAY<LPOINT2D> m_SelectedCells;
02594 int m_nLeftCol;
02595 int m_nRightCol;
02596 int m_nBottomRow;
02597 int m_nTopRow;
02598 int m_nRows;
02599 int m_nCols;
02600 MGUI::MENU *m_pMenu;
02601 SECTION m_ContextMenuSection;
02602 LPOINT2D m_ContextMenuCell;
02603 LPOINT2D m_MouseDownPoint;
02604 LPOINT2D m_MouseLastPoint;
02605 int m_nDrag;
02606 int m_CurrentCursor;
02607
02608 ROWDATA* m_pRowData;
02609 COLDATA* m_pColData;
02610
02611 #ifdef X_NATIVE
02612 Time m_MouseDownTime;
02613 int m_MultiClickTime;
02614 #endif
02615
02616 bool m_bRecomputeSizesH;
02617 bool m_bRecomputeSizesV;
02618 bool m_bAllowColSwapping;
02619 bool m_bAllowContextMenu;
02620 bool m_bAllowCellResize;
02621 bool m_bHilightRow;
02622 bool m_bMultiSelect;
02623 bool m_bUniformRowHeight;
02624 int m_nInternalUpdate;
02625 int m_nDisableUpdates;
02626 bool m_bNeedUpdate;
02627 bool m_bHideFocus;
02628 bool m_bInButton1Event;
02629
02630 int m_nTopHeadings;
02631 int* m_nTopHeadingHeight;
02632 int m_nTopHeadingTotalHeight;
02633
02634 int m_nSideHeadings;
02635 int* m_nSideHeadingWidth;
02636 int m_nSideHeadingTotalWidth;
02637 MIGRIDCELL** m_pSideHeadingStyle;
02638 MIGRIDCELL** m_pTopHeadingStyle;
02639
02640 int m_n3Dheight;
02641 DRAGACTION m_DragAction;
02642
02643 MIGRIDCELL m_GridDefault;
02644 MIGRIDCELL m_HeadingDefault;
02645
02646 MGD::PIXEL m_ShadowPixelLight;
02647 MGD::PIXEL m_ShadowPixelDark;
02648 MGD::PIXEL m_FocusRectPixel;
02649 MGD::PIXEL m_BackgroundPixel;
02650 #ifdef X_NATIVE
02651 Widget m_wMainForm;
02652 Widget m_wVSB;
02653 Widget m_wHSB;
02654 Widget m_wPopup;
02655 #endif
02656
02657 MIGRIDEDITHANDLE* m_pEditHandle;
02658 MIGRIDCELLTYPE** m_pCellTypes;
02659 int m_nCellTypes;
02660
02661 TOOLTIPDATA m_VSBTip;
02662 TOOLTIPDATA m_HSBTip;
02663
02664 DADATA m_DAGrid;
02665 DADATA m_DATop;
02666 DADATA m_DASide;
02667 MGD::CONTEXT* m_GCExclusive;
02668 LRECT2D m_GridClipRect;
02669 bool m_bClipGrid;
02670
02671 SCROLLMODE m_VScrollMode;
02672 SCROLLMODE m_HScrollMode;
02673
02674 MGUI::IMAGELIST* m_ImageList;
02675 bool m_bWeOwnImageList;
02676 MEMPOOL m_MemPool;
02677
02678 friend struct DADATA;
02679 #endif // GENERATING_DOXYGEN_OUTPUT
02680 };
02681
02682 #ifndef GENERATING_DOXYGEN_OUTPUT
02683 DEFINE_ENUM_OP_BITWISE(MIGRIDCTRL::CELLSTATE)
02684 #endif
02685
02686
02687
02688 #endif // INC_MI32_MIGRID_H