1 #ifndef _GridCtrl_GridDisplay_h_
2 #define _GridCtrl_GridDisplay_h_
3 
4 #define  IMAGEFILE <GridCtrl/GridCtrl.iml>
5 #define  IMAGECLASS GridImg
6 #include <Draw/iml_header.h>
7 
8 #define BIT(x) (1 << x)
9 #define BIT_ALL (0xFFFFFFFF)
10 
11 class GridCtrl;
12 
13 namespace GD
14 {
15 	enum
16 	{
17 		CURSOR    = BIT(0),
18 		SELECT    = BIT(1),
19 		LIVE      = BIT(2),
20 		FOCUS     = BIT(3),
21 		READONLY  = BIT(4),
22 		FOUND     = BIT(5),
23 		MARKED    = CURSOR | SELECT | LIVE | READONLY | FOUND,
24 		HIGHLIGHT = BIT(6),
25 		EVEN      = BIT(7),
26 		ODD       = BIT(8),
27 		LEFT      = BIT(9),
28 		RIGHT     = BIT(10),
29 		TOP       = BIT(11),
30 		BOTTOM    = BIT(12),
31 		HCENTER   = BIT(13),
32 		VCENTER   = BIT(14),
33 		HPOS      = BIT(15),
34 		VPOS      = BIT(16),
35 		WRAP      = BIT(17),
36 		CHAMELEON = BIT(18),
37 		NOTEXT    = BIT(19),
38 		BOLDKEY   = BIT(20),
39 		BOLDVALUE = BIT(21),
40 		HALIGN    = LEFT | RIGHT | HCENTER,
41 		VALIGN    = TOP | BOTTOM | VCENTER,
42 		ALIGN     = HALIGN | VALIGN
43 	};
44 }
45 
46 class GridDisplay
47 {
48 	public:
49 
50 		Image	leftImg;
51 		Image	rightImg;
52 		Image   centerImg;
53 		Image	bgImg;
54 		Image   hdrhigh;
55 
56 		bool	reverse_sort_icon;
57 
58 		int 	align;
59 		int		lm, rm, tm, bm;
60 		int     theme;
61 
62 		int 	col, row;
63 
64 		GridCtrl *parent;
65 
GridDisplay()66 		GridDisplay()
67 		{
68 			SetDefault();
69 		}
70 
71 		Size real_size;
72 
73 		void SetDefault();
74 
~GridDisplay()75 		virtual ~GridDisplay() {};
76 
SetLeftImage(const Image & img)77 		void SetLeftImage(const Image &img)			    { leftImg = img;               }
SetRightImage(const Image & img)78 		void SetRightImage(const Image &img)		    { rightImg = img;              }
SetCenterImage(const Image & img)79 		void SetCenterImage(const Image &img)		    { centerImg = img;  	       }
SetBgImage(Image & img)80 		void SetBgImage(Image &img)					    { bgImg = img;    	           }
81 		void SetTextAlign(int al = GD::TOP | GD::LEFT)  { align = al;                  }
82 		void SetHorzMargin(int left = 4, int right = 4) { lm = left; rm = right;  	   }
83 		void SetVertMargin(int top = 0, int bottom = 0) { tm = top;  bm = bottom;      }
84 		void ReverseSortIcon(bool b = true)				{ reverse_sort_icon = b;       }
85 		void SetTheme(int th = 6);
GetThemeCount()86 		int  GetThemeCount()                            { return 7;                    }
IsFixedRow()87 		bool IsFixedRow()                               { return row < 0;              }
IsFixedCol()88 		bool IsFixedCol()                               { return col < 0;              }
89 
90 		WString GetStdConvertedValue(const Value &v) const;
91 		int GetLinesCount(int cx, const wchar* s, const Font& font, bool wrap);
92 
93 		void DrawText(Draw &w, int mx, int x, int y, int cx, int cy, int align,
94 					  const wchar *s, const Font &font, const Color &fg, const Color &bg,
95 					  bool found = false, int fs = 0, int fe = 0, bool wrap = false);
96 
97 		virtual void Paint(Draw &w, int x, int y, int cx, int cy, const Value &val, dword style,
98 				           Color &fg, Color &bg, Font &fnt, bool found = false, int fs = 0, int fe = 0);
99 
100 		virtual void PaintFixed(Draw &w, bool firstx, bool firsty, int x, int y, int cx, int cy, const Value &val, dword style, Font &fnt,
101 								bool indicator = false, bool moved = false,
102 								int sortmode = 0, int sortcol = -1, int sortcnt = 0, bool horizontal = true);
103 
104 };
105 
106 struct GridDisplayCtrl : GridDisplay, StaticRect
107 {};
108 
109 GridDisplay& StdGridDisplay();
110 
111 #endif
112