mGNCS API Reference  v1.2.0
A new control set and a new framework for MiniGUI apps
mlistview.h
Go to the documentation of this file.
1 
42 #ifdef _MGNCSCTRL_LISTVIEW
43 
44 #ifndef _MGUI_CTRL_LISTV_H
45 #define _MGUI_CTRL_LISTV_H
46 
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif /* __cplusplus */
51 
57 typedef struct _mListView mListView;
58 typedef struct _mListViewClass mListViewClass;
59 typedef struct _mListViewRenderer mListViewRenderer;
60 
65 typedef enum
66 {
68  NCSID_LISTV_IR_PARENT,
70  NCSID_LISTV_IR_FIRSTCHILD,
72  NCSID_LISTV_IR_LASTCHILD,
74  NCSID_LISTV_IR_NEXTSIBLING,
76  NCSID_LISTV_IR_PREVSIBLING,
77 }ncsListVIRType;
78 
83 #define NCSF_LSTHDR_LEFTALIGN (0x00<<NCSF_LSTCLM_SHIFT)
84 
89 #define NCSF_LSTHDR_TOPALIGN (0x00<<NCSF_LSTCLM_SHIFT)
90 
95 #define NCSF_LSTHDR_RIGHTALIGN (0x01<<NCSF_LSTCLM_SHIFT)
96 
101 #define NCSF_LSTHDR_CENTERALIGN (0x02<<NCSF_LSTCLM_SHIFT)
102 
107 #define NCSF_LSTHDR_BOTTOMALIGN (0x04<<NCSF_LSTCLM_SHIFT)
108 
113 #define NCSF_LSTHDR_VCENTERALIGN (0x08<<NCSF_LSTCLM_SHIFT)
114 
119 #define NCSF_LSTHDR_VALIGNMASK (0x0C<<NCSF_LSTCLM_SHIFT)
120 
125 #define NCSF_LSTHDR_SHIFT (NCSF_LSTCLM_SHIFT+4)
126 
131 typedef enum
132 {
134  NCSID_LISTV_FT_ADDDATA,
136  NCSID_LISTV_FT_TEXT,
137 }ncsListVFindType;
138 
142 typedef struct _NCS_LISTV_FINDINFO
143 {
145  ncsListVFindType type;
146 
148  HITEM parent;
149 
151  int startIdx;
152 
154  union {
156  struct {
157  /* The number of searching column. */
158  int size;
159  /* The text of searching column */
160  char **text;
161  }string;
163  DWORD addData;
164  }data;
165 }NCS_LISTV_FINDINFO;
166 
170 typedef struct _NCS_LISTV_CLMINFO
171 {
173  int index;
175  int width;
177  char *text;
179  DWORD image;
194  DWORD flags;
195  NCS_CB_LISTV_CMPCLM pfnCmp;
196 
197  /*
198  * \sa ncsLstClmSortType
199  */
200  ncsLstClmSortType sort;
201 } NCS_LISTV_CLMINFO;
202 
206 typedef struct _NCS_LISTV_ITEMDATA
207 {
209  int row;
211  int col;
213  char* text;
215  int textColor;
216 
223  DWORD flags;
225  DWORD image;
226 }NCS_LISTV_ITEMDATA;
227 
231 typedef struct _NCS_LISTV_ITEMINFO
232 {
234  int index;
236  int retPos;
238  HITEM parent;
240  int height;
247  int flags;
249  HICON foldIcon;
251  HICON unfoldIcon;
253  int dataSize;
255  NCS_LISTV_ITEMDATA *data;
257  DWORD addData;
258 }NCS_LISTV_ITEMINFO;
259 
261 typedef void (*NCS_CB_LISTV_DRAWHDRBK)(mListView *self, HITEM hHdr, HDC hdc, RECT *rcDraw);
263 typedef void (*NCS_CB_LISTV_DRAWHDR)(mListView *self, HITEM hHdr, HDC hdc, RECT *rcDraw);
264 
265 typedef void (*NCS_CB_DRAWITEMBK)(mListView *self, HITEM hItem, HDC hdc, RECT *rcDraw);
267 typedef struct _NCS_CB_LISTV_CSTMHDROPS
268 {
270  NCS_CB_LISTV_DRAWHDRBK pfnDrawHdrBk;
272  NCS_CB_LISTV_DRAWHDR pfnDrawHdrItem;
273 } NCS_CB_LISTV_CSTMHDROPS;
274 
275 
276 #define NCSSPEC_LISTV_HDR MAX_USER_SPECIAL_KEY + 2000
277 
278 typedef struct _NCS_LISTV_CLMRD{
279  const char* text;
280  const char* image_file;
281  DWORD width;
282  DWORD flags;
283 }NCS_LISTV_CLMRD;
284 
285 MGNCS_EXPORT extern const unsigned char gListVColumnRecordTypes[];
286 
291 #define NCSCTRL_LISTVIEW NCSCLASSNAME("listview")
292 
297 #define NCSS_LISTV_NOTIFY NCSS_NOTIFY
298 
303 #define NCSS_LISTV_LOOP NCSS_ITEMV_LOOP
304 
308 #define NCSS_LISTV_MULTIPLE NCSS_ITEMV_MULTIPLE
309 
314 #define NCSS_LISTV_SINGLE NCSS_ITEMV_SINGLE
315 
320 #define NCSS_LISTV_CHECKBOX (0x0001<<NCSS_ITEMV_SHIFT)
321 
327 #define NCSS_LISTV_AUTOCHECK (0x0002<<NCSS_ITEMV_SHIFT)
328 
333 #define NCSS_LISTV_AUTOCHECKBOX \
334  (NCSS_LISTV_CHECKBOX | NCSS_LISTV_AUTOCHECK)
335 
340 #define NCSS_LISTV_TREE (0x0004<<NCSS_ITEMV_SHIFT)
341 
346 #define NCSS_LISTV_WITHICON (0x0008<<NCSS_ITEMV_SHIFT)
347 
352 #define NCSS_LISTV_SORT (0x0010<<NCSS_ITEMV_SHIFT)
353 
358 #define NCSS_LISTV_NOHDRDRAG (0x0020<<NCSS_ITEMV_SHIFT)
359 
364 #define NCSS_LISTV_SHIFT (NCSS_ITEMV_SHIFT + 6)
365 
366 #define mListViewHeader(className) \
367  mItemViewHeader(className) \
368  NCS_CB_LISTV_DRAWHDRBK drawHdrBk; \
369  NCS_CB_LISTV_DRAWHDR drawHdrItem;\
370  NCS_CB_DRAWITEMBK drawItemBk; \
371  NCS_CB_DRAWITEM drawSubItem;\
372  mItemManager *hdrList; \
373  mListItem *rootItem; \
374  ncsLstClmSortType sort; \
375  int curCol; \
376  int gridLineWidth; \
377  int gridLineColor; \
378  NCS_CB_LISTV_CMPCLM pfnSort; \
379  int hdrH; \
380  int hdrW; \
381  int dragedHead; \
382  int dragX; \
383  mListColumn *clickedHead; \
384  DWORD status;
385 
420 struct _mListView
421 {
422  mListViewHeader(mListView)
423 };
424 
425 #define mListViewClassHeader(clsName, parentClass) \
426  mItemViewClassHeader(clsName, parentClass) \
427  NCS_CB_DRAWITEMBK (*setItemBkDraw)(clsName*, NCS_CB_DRAWITEMBK func);\
428  NCS_CB_DRAWITEM (*setSubItemDraw)(clsName*, NCS_CB_DRAWITEM func); \
429  HITEM (*getRelatedItem)(clsName*,HITEM hItem,ncsListVIRType type); \
430  void (*setBackground)(clsName*,int row,int col,int *color); \
431  void (*setForeground)(clsName*,int row,int col,int *color); \
432  int (*getBackground)(clsName*,int row,int col,int *color); \
433  int (*getForeground)(clsName*,int row,int col,int *color); \
434  void (*sort)(clsName*, NCS_CB_LISTV_CMPCLM func, int col, ncsLstClmSortType sort);\
435  void (*setCustomDrawHeader)(clsName*, NCS_CB_LISTV_CSTMHDROPS *func);\
436  BOOL (*setItemInfo)(clsName*, NCS_LISTV_ITEMDATA *info); \
437  BOOL (*getItemInfo)(clsName*, NCS_LISTV_ITEMDATA *info); \
438  const char* (*getItemText)(clsName*, int row, int col); \
439  int (*getItemTextLen)(clsName*, int row, int col); \
440  BOOL (*setItemText)(clsName*, int row, int col, const char* str); \
441  void (*setSortDirection)(clsName*, ncsLstClmSortType direction); \
442  ncsLstClmSortType (*getSortDirection)(clsName*); \
443  HITEM (*findItem)(clsName*, NCS_LISTV_FINDINFO *info); \
444  mListColumn* (*getColumn)(clsName*, int index); \
445  int (*getColumnIndex)(clsName*, mListColumn *column); \
446  int (*getColumnWidth)(clsName*, int index); \
447  void (*setColumnWidth)(clsName*, int index, int width); \
448  int (*getColumnCount)(clsName*); \
449  mListColumn* (*getSortColumn)(clsName*); \
450  void (*setSortColumn)(clsName*, mListColumn* column); \
451  void (*showColumn)(clsName*, mListColumn *column); \
452  BOOL (*delColumn)(clsName*, int index); \
453  BOOL (*addColumn)(clsName*, NCS_LISTV_CLMINFO *info); \
454  HITEM (*addItem)(clsName*, NCS_LISTV_ITEMINFO *info); \
455  BOOL (*setHeadText)(clsName*, int col, const char* text); \
456  HITEM (*getChildItem)(clsName*, HITEM parent,int index); \
457  int (*getChildCount)(clsName*, HITEM hItem); \
458  int (*foldItem)(clsName*, HITEM hItem, BOOL fold);
459 
460 
600 struct _mListViewClass
601 {
602  mListViewClassHeader(mListView, mItemView)
603 };
604 
605 #define mListViewRendererHeader(clsName, parentClass) \
606  mItemViewRendererHeader(clsName, parentClass) \
607  void (*drawHeader) (clsName *self, HDC hdc, const RECT* pRect, \
608  DWORD color, int flag); \
609  void (*drawFold) (clsName *self, HDC hdc, const RECT* pRect, \
610  DWORD color, HICON icon, int status, int next);
611 
625 struct _mListViewRenderer {
626  mListViewRendererHeader(mListView, mItemView)
627 };
628 
633 enum mListViewProp
634 {
636  NCSP_LISTV_DEFITEMHEIGHT = NCSP_ITEMV_DEFITEMHEIGHT,
638  NCSP_LISTV_ROWCOUNT = NCSP_ITEMV_ITEMCOUNT,
640  NCSP_LISTV_HDRHEIGHT = NCSP_ITEMV_MAX + 1,
642  NCSP_LISTV_HDRWIDTH,
644  NCSP_LISTV_HDRVISIBLE,
646  NCSP_LISTV_SORTCOLUMN,
648  NCSP_LISTV_GRIDLINEWIDTH,
650  NCSP_LISTV_GRIDLINECOLOR,
652  NCSP_LISTV_COLCOUNT,
654  NCSP_LISTV_MAX,
655 };
656 
661 enum mListViewNotify
662 {
664  NCSN_LISTV_CLICKED = NCSN_ITEMV_CLICKED,
666  NCSN_LISTV_SELCHANGED = NCSN_ITEMV_SELCHANGED,
668  NCSN_LISTV_ITEMRDOWN = NCSN_ITEMV_MAX + 1,
670  NCSN_LISTV_ITEMRUP,
672  NCSN_LISTV_HDRRDOWN,
674  NCSN_LISTV_HDRRUP,
676  NCSN_LISTV_ITEMDBCLK,
678  NCSN_LISTV_FOLDITEM,
680  NCSN_LISTV_UNFOLDITEM,
682  NCSN_LISTV_MAX
683 };
684 
691 MGNCS_EXPORT extern mListViewClass g_stmListViewCls;
694 #ifdef __cplusplus
695 }
696 #endif /* __cplusplus */
697 
698 #endif /* _MGUI_CTRL_LISTV_H */
699 #endif //_MGNCSCTRL_LISTVIEW
GHANDLE HITEM
The handle of item widget.
Definition: mitem.h:63
ncsLstClmSortType
The sort type.
Definition: mlistcolumn.h:62
The structure of mItemView control, which derived from mScrollWidget. It is the abstract superclass o...
int(* NCS_CB_LISTV_CMPCLM)(HITEM nItem1, HITEM nItem2, NCS_LSTCLM_SORTDATA *sortData)
The callback of comparison column function.
Definition: mlistcolumn.h:108