mGNCS API Reference  v1.5.0
A new control set and a new framework for MiniGUI apps
mlistview.h
Go to the documentation of this file.
1 //
3 // IMPORTANT NOTICE
4 //
5 // The following open source license statement does not apply to any
6 // entity in the Exception List published by FMSoft.
7 //
8 // For more information, please visit:
9 //
10 // https://www.fmsoft.cn/exception-list
11 //
13 
54 #ifdef _MGNCSCTRL_LISTVIEW
55 
56 #ifndef _MGUI_CTRL_LISTV_H
57 #define _MGUI_CTRL_LISTV_H
58 
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif /* __cplusplus */
63 
69 typedef struct _mListView mListView;
70 typedef struct _mListViewClass mListViewClass;
71 typedef struct _mListViewRenderer mListViewRenderer;
72 
77 typedef enum
78 {
80  NCSID_LISTV_IR_PARENT,
82  NCSID_LISTV_IR_FIRSTCHILD,
84  NCSID_LISTV_IR_LASTCHILD,
86  NCSID_LISTV_IR_NEXTSIBLING,
88  NCSID_LISTV_IR_PREVSIBLING,
89 }ncsListVIRType;
90 
95 #define NCSF_LSTHDR_LEFTALIGN (0x00<<NCSF_LSTCLM_SHIFT)
96 
101 #define NCSF_LSTHDR_TOPALIGN (0x00<<NCSF_LSTCLM_SHIFT)
102 
107 #define NCSF_LSTHDR_RIGHTALIGN (0x01<<NCSF_LSTCLM_SHIFT)
108 
113 #define NCSF_LSTHDR_CENTERALIGN (0x02<<NCSF_LSTCLM_SHIFT)
114 
119 #define NCSF_LSTHDR_BOTTOMALIGN (0x04<<NCSF_LSTCLM_SHIFT)
120 
125 #define NCSF_LSTHDR_VCENTERALIGN (0x08<<NCSF_LSTCLM_SHIFT)
126 
131 #define NCSF_LSTHDR_VALIGNMASK (0x0C<<NCSF_LSTCLM_SHIFT)
132 
137 #define NCSF_LSTHDR_SHIFT (NCSF_LSTCLM_SHIFT+4)
138 
143 typedef enum
144 {
146  NCSID_LISTV_FT_ADDDATA,
148  NCSID_LISTV_FT_TEXT,
149 }ncsListVFindType;
150 
154 typedef struct _NCS_LISTV_FINDINFO
155 {
157  ncsListVFindType type;
158 
160  HITEM parent;
161 
163  int startIdx;
164 
166  union {
168  struct {
169  /* The number of searching column. */
170  int size;
171  /* The text of searching column */
172  char **text;
173  }string;
175  DWORD addData;
176  }data;
177 }NCS_LISTV_FINDINFO;
178 
182 typedef struct _NCS_LISTV_CLMINFO
183 {
185  int index;
187  int width;
189  char *text;
191  DWORD image;
206  DWORD flags;
207  NCS_CB_LISTV_CMPCLM pfnCmp;
208 
209  /*
210  * \sa ncsLstClmSortType
211  */
212  ncsLstClmSortType sort;
213 } NCS_LISTV_CLMINFO;
214 
218 typedef struct _NCS_LISTV_ITEMDATA
219 {
221  int row;
223  int col;
225  char* text;
227  int textColor;
228 
235  DWORD flags;
237  DWORD image;
238 }NCS_LISTV_ITEMDATA;
239 
243 typedef struct _NCS_LISTV_ITEMINFO
244 {
246  int index;
248  int retPos;
250  HITEM parent;
252  int height;
259  int flags;
261  HICON foldIcon;
263  HICON unfoldIcon;
265  int dataSize;
267  NCS_LISTV_ITEMDATA *data;
269  DWORD addData;
270 }NCS_LISTV_ITEMINFO;
271 
273 typedef void (*NCS_CB_LISTV_DRAWHDRBK)(mListView *self, HITEM hHdr, HDC hdc, RECT *rcDraw);
275 typedef void (*NCS_CB_LISTV_DRAWHDR)(mListView *self, HITEM hHdr, HDC hdc, RECT *rcDraw);
276 
277 typedef void (*NCS_CB_DRAWITEMBK)(mListView *self, HITEM hItem, HDC hdc, RECT *rcDraw);
279 typedef struct _NCS_CB_LISTV_CSTMHDROPS
280 {
282  NCS_CB_LISTV_DRAWHDRBK pfnDrawHdrBk;
284  NCS_CB_LISTV_DRAWHDR pfnDrawHdrItem;
285 } NCS_CB_LISTV_CSTMHDROPS;
286 
287 
288 #define NCSSPEC_LISTV_HDR MAX_USER_SPECIAL_KEY + 2000
289 
290 typedef struct _NCS_LISTV_CLMRD{
291  const char* text;
292  const char* image_file;
293  DWORD width;
294  DWORD flags;
295 }NCS_LISTV_CLMRD;
296 
297 MGNCS_EXPORT extern const unsigned char gListVColumnRecordTypes[];
298 
303 #define NCSCTRL_LISTVIEW NCSCLASSNAME("listview")
304 
309 #define NCSS_LISTV_NOTIFY NCSS_NOTIFY
310 
315 #define NCSS_LISTV_LOOP NCSS_ITEMV_LOOP
316 
320 #define NCSS_LISTV_MULTIPLE NCSS_ITEMV_MULTIPLE
321 
326 #define NCSS_LISTV_SINGLE NCSS_ITEMV_SINGLE
327 
332 #define NCSS_LISTV_CHECKBOX (0x0001<<NCSS_ITEMV_SHIFT)
333 
339 #define NCSS_LISTV_AUTOCHECK (0x0002<<NCSS_ITEMV_SHIFT)
340 
345 #define NCSS_LISTV_AUTOCHECKBOX \
346  (NCSS_LISTV_CHECKBOX | NCSS_LISTV_AUTOCHECK)
347 
352 #define NCSS_LISTV_TREE (0x0004<<NCSS_ITEMV_SHIFT)
353 
358 #define NCSS_LISTV_WITHICON (0x0008<<NCSS_ITEMV_SHIFT)
359 
364 #define NCSS_LISTV_SORT (0x0010<<NCSS_ITEMV_SHIFT)
365 
370 #define NCSS_LISTV_NOHDRDRAG (0x0020<<NCSS_ITEMV_SHIFT)
371 
376 #define NCSS_LISTV_SHIFT (NCSS_ITEMV_SHIFT + 6)
377 
378 #define mListViewHeader(className) \
379  mItemViewHeader(className) \
380  NCS_CB_LISTV_DRAWHDRBK drawHdrBk; \
381  NCS_CB_LISTV_DRAWHDR drawHdrItem;\
382  NCS_CB_DRAWITEMBK drawItemBk; \
383  NCS_CB_DRAWITEM drawSubItem;\
384  mItemManager *hdrList; \
385  mListItem *rootItem; \
386  ncsLstClmSortType sort; \
387  int curCol; \
388  int gridLineWidth; \
389  int gridLineColor; \
390  NCS_CB_LISTV_CMPCLM pfnSort; \
391  int hdrH; \
392  int hdrW; \
393  int dragedHead; \
394  int dragX; \
395  mListColumn *clickedHead; \
396  DWORD status;
397 
432 struct _mListView
433 {
434  mListViewHeader(mListView)
435 };
436 
437 #define mListViewClassHeader(clsName, parentClass) \
438  mItemViewClassHeader(clsName, parentClass) \
439  NCS_CB_DRAWITEMBK (*setItemBkDraw)(clsName*, NCS_CB_DRAWITEMBK func);\
440  NCS_CB_DRAWITEM (*setSubItemDraw)(clsName*, NCS_CB_DRAWITEM func); \
441  HITEM (*getRelatedItem)(clsName*,HITEM hItem,ncsListVIRType type); \
442  void (*setBackground)(clsName*,int row,int col,int *color); \
443  void (*setForeground)(clsName*,int row,int col,int *color); \
444  int (*getBackground)(clsName*,int row,int col,int *color); \
445  int (*getForeground)(clsName*,int row,int col,int *color); \
446  void (*sort)(clsName*, NCS_CB_LISTV_CMPCLM func, int col, ncsLstClmSortType sort);\
447  void (*setCustomDrawHeader)(clsName*, NCS_CB_LISTV_CSTMHDROPS *func);\
448  BOOL (*setItemInfo)(clsName*, NCS_LISTV_ITEMDATA *info); \
449  BOOL (*getItemInfo)(clsName*, NCS_LISTV_ITEMDATA *info); \
450  const char* (*getItemText)(clsName*, int row, int col); \
451  int (*getItemTextLen)(clsName*, int row, int col); \
452  BOOL (*setItemText)(clsName*, int row, int col, const char* str); \
453  void (*setSortDirection)(clsName*, ncsLstClmSortType direction); \
454  ncsLstClmSortType (*getSortDirection)(clsName*); \
455  HITEM (*findItem)(clsName*, NCS_LISTV_FINDINFO *info); \
456  mListColumn* (*getColumn)(clsName*, int index); \
457  int (*getColumnIndex)(clsName*, mListColumn *column); \
458  int (*getColumnWidth)(clsName*, int index); \
459  void (*setColumnWidth)(clsName*, int index, int width); \
460  int (*getColumnCount)(clsName*); \
461  mListColumn* (*getSortColumn)(clsName*); \
462  void (*setSortColumn)(clsName*, mListColumn* column); \
463  void (*showColumn)(clsName*, mListColumn *column); \
464  BOOL (*delColumn)(clsName*, int index); \
465  BOOL (*addColumn)(clsName*, NCS_LISTV_CLMINFO *info); \
466  HITEM (*addItem)(clsName*, NCS_LISTV_ITEMINFO *info); \
467  BOOL (*setHeadText)(clsName*, int col, const char* text); \
468  HITEM (*getChildItem)(clsName*, HITEM parent,int index); \
469  int (*getChildCount)(clsName*, HITEM hItem); \
470  int (*foldItem)(clsName*, HITEM hItem, BOOL fold);
471 
472 
612 struct _mListViewClass
613 {
614  mListViewClassHeader(mListView, mItemView)
615 };
616 
617 #define mListViewRendererHeader(clsName, parentClass) \
618  mItemViewRendererHeader(clsName, parentClass) \
619  void (*drawHeader) (clsName *self, HDC hdc, const RECT* pRect, \
620  DWORD color, int flag); \
621  void (*drawFold) (clsName *self, HDC hdc, const RECT* pRect, \
622  DWORD color, HICON icon, int status, int next);
623 
637 struct _mListViewRenderer {
638  mListViewRendererHeader(mListView, mItemView)
639 };
640 
645 enum mListViewProp
646 {
648  NCSP_LISTV_DEFITEMHEIGHT = NCSP_ITEMV_DEFITEMHEIGHT,
650  NCSP_LISTV_ROWCOUNT = NCSP_ITEMV_ITEMCOUNT,
652  NCSP_LISTV_HDRHEIGHT = NCSP_ITEMV_MAX + 1,
654  NCSP_LISTV_HDRWIDTH,
656  NCSP_LISTV_HDRVISIBLE,
658  NCSP_LISTV_SORTCOLUMN,
660  NCSP_LISTV_GRIDLINEWIDTH,
662  NCSP_LISTV_GRIDLINECOLOR,
664  NCSP_LISTV_COLCOUNT,
666  NCSP_LISTV_MAX,
667 };
668 
673 enum mListViewNotify
674 {
676  NCSN_LISTV_CLICKED = NCSN_ITEMV_CLICKED,
678  NCSN_LISTV_SELCHANGED = NCSN_ITEMV_SELCHANGED,
680  NCSN_LISTV_ITEMRDOWN = NCSN_ITEMV_MAX + 1,
682  NCSN_LISTV_ITEMRUP,
684  NCSN_LISTV_HDRRDOWN,
686  NCSN_LISTV_HDRRUP,
688  NCSN_LISTV_ITEMDBCLK,
690  NCSN_LISTV_FOLDITEM,
692  NCSN_LISTV_UNFOLDITEM,
694  NCSN_LISTV_MAX
695 };
696 
703 MGNCS_EXPORT extern mListViewClass g_stmListViewCls;
706 #ifdef __cplusplus
707 }
708 #endif /* __cplusplus */
709 
710 #endif /* _MGUI_CTRL_LISTV_H */
711 #endif //_MGNCSCTRL_LISTVIEW
HITEM
GHANDLE HITEM
The handle of item widget.
Definition: mitem.h:75
mItemView
The structure of mItemView control, which derived from mScrollWidget. It is the abstract superclass o...
NCSN_ITEMV_CLICKED
@ NCSN_ITEMV_CLICKED
Definition: mitemview.h:585
ncsLstClmSortType
ncsLstClmSortType
The sort type.
Definition: mlistcolumn.h:74
NCSN_ITEMV_SELCHANGED
@ NCSN_ITEMV_SELCHANGED
Definition: mitemview.h:595
NCSP_ITEMV_MAX
@ NCSP_ITEMV_MAX
Definition: mitemview.h:574
NCSP_ITEMV_ITEMCOUNT
@ NCSP_ITEMV_ITEMCOUNT
Definition: mitemview.h:570
NCS_CB_LISTV_CMPCLM
int(* NCS_CB_LISTV_CMPCLM)(HITEM nItem1, HITEM nItem2, NCS_LSTCLM_SORTDATA *sortData)
The callback of comparison column function.
Definition: mlistcolumn.h:120
NCSP_ITEMV_DEFITEMHEIGHT
@ NCSP_ITEMV_DEFITEMHEIGHT
Definition: mitemview.h:565
NCSN_ITEMV_MAX
@ NCSN_ITEMV_MAX
Definition: mitemview.h:615