mGNCS API Reference  v1.2.0
A new control set and a new framework for MiniGUI apps
mnode.h
Go to the documentation of this file.
1 
42 #ifndef _MGUI_WIDGET_NODE_H
43 #define _MGUI_WIDGET_NODE_H
44 
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif /* __cplusplus */
49 
55 typedef struct _mNode mNode;
56 typedef struct _mNodeClass mNodeClass;
57 
62 #define NCSS_NODE_LTEXTRS 0x0000
63 
69 #define NCSS_NODE_SMALLICON 0x0001
70 
75 #define NCSS_NODE_LTEXTBS 0x0002
76 
81 #define NCSS_NODE_TICTACTOEMIDLET 0x0004
82 
83 #define NCSS_NODE_LAYOUT_MASK 0x00FF
84 
89 #define NCSS_NODE_HIDETEXT 0x0010
90 
95 #define NCSS_NODE_HIDEIMAGE 0x0020
96 
101 #define NCSS_NODE_DISABLED 0x0040
102 
107 #define NCSS_NODE_SHIFT 7
108 
114 typedef int (*NCS_CB_CMPNODE) (mNode *node1, mNode *node2);
115 
116 #define mNodeDataInfoHeader \
117  int style; \
118  char *text; \
119  PBITMAP image; \
120  int height; \
121  DWORD addData; \
122  mObject *parent; \
123 
124 
125 typedef struct _NCS_NODE_DATA
126 {
127  mNodeDataInfoHeader
128 }NCS_NODE_DATA;
129 
130 //status flags
131 #define NCSF_NODE_MASK 0xFFFF
132 #define NCSF_NODE_NORMAL 0x0000
133 #define NCSF_NODE_SELECTED 0x0001
134 #define NCSF_NODE_DISABLED 0x0002
135 #define NCSF_NODE_INVISIBLE 0x0004
136 #define NCSF_NODE_DEFHEIGHT 0x0008
137 
138 #define NCSF_NODE_HIDETEXT 0x0010
139 #define NCSF_NODE_HIDEIMAGE 0x0020
140 
141 typedef struct _NCS_NODE_LAYOUTOPS
142 {
143  const char name[16];
144  int style;
145  void (*paint)(mNode *self, HDC hdc, const RECT *rect, mObject *owner);
146 }NCS_NODE_LAYOUTOPS;
147 
148 #define mNodeHeader(className) \
149  mObjectHeader(className) \
150  NCS_NODE_LAYOUTOPS *layout; \
151  list_t children; \
152  list_t sibling; \
153  Uint16 flags; \
154  Uint16 count; \
155  mNodeDataInfoHeader
156 
188 struct _mNode
189 {
190  mNodeHeader(mNode)
191 };
192 
193 typedef struct _NCS_MENU_DATA
194 {
195  int nr_child;
196  struct _NCS_MENU_DATA *child;
197 
198  mNodeDataInfoHeader
199 }NCS_MENU_DATA;
200 MGNCS_EXPORT void ncsSetMenuData(mObject *self, NCS_MENU_DATA *pMenuData, int count);
201 
202 typedef struct _NCS_MENU_INFO
203 {
204  int count;
205  char *caption;
206  NCS_MENU_DATA *data;
207 }NCS_MENU_INFO;
208 MGNCS_EXPORT void ncsSetMenu(mObject *self, NCS_MENU_INFO *pMenuInfo);
209 
225 MGNCS_EXPORT mNode* ncsCreateNode(mObject *parent, const char* text,
226  PBITMAP image, int height, int style, DWORD addData);
227 
247 MGNCS_EXPORT mNode* ncsAddNode(mObject *parent, const char* text,
248  PBITMAP image, int height, int style, DWORD addData);
249 
255 {
260 
265 
270 
271  NCS_NODE_FTOTHER,
272 };
273 
274 #define mNodeClassHeader(clsName, superCls) \
275  mObjectClassHeader(clsName, superCls) \
276  BOOL (*setProperty)(clsName*, int id, DWORD value); \
277  DWORD (*getProperty)(clsName*, int id); \
278  BOOL (*computeSize)(clsName*, HDC hdc, SIZE *size); \
279  BOOL (*canAsRoot)(clsName*); \
280  int (*addNode)(clsName*, mNode *node); \
281  int (*removeNode)(clsName*, mNode *node); \
282  int (*insertNode)(clsName*, mNode *node, mNode *prev, mNode *next, int index);\
283  int (*moveNode)(clsName*, mNode *curNode, int count, mNode *prevNode); \
284  mNode* (*findNode)(mNode *self, DWORD info, int type, BOOL recursion, int startIndex);\
285  mNode* (*findNodeEx)(mNode *self, DWORD info, int type, BOOL recursion, int startIndex, \
286  int (*cb)(mNode *node, DWORD info)); \
287  void (*removeAll)(clsName*); \
288  void (*sendEvent)(clsName*, int eventId); \
289  mNode* (*getNode)(clsName*, int index); \
290  int (*indexOf)(clsName*); \
291  mNode* (*getPrev)(clsName*); \
292  mNode* (*getNext)(clsName*); \
293  BOOL (*isEnabled)(clsName*); \
294  BOOL (*isSelected)(clsName*); \
295  BOOL (*hasChildren)(clsName*); \
296  BOOL (*setText)(clsName*, const char* text); \
297  BOOL (*setImage)(clsName*, const PBITMAP image); \
298  const char* (*getText)(clsName*); \
299  PBITMAP (*getImage)(clsName*); \
300  void (*paint)(clsName*, HDC hdc, const RECT *rect, mObject *owner); \
301  int (*msgHandler)(clsName*, int msg, WPARAM wParam, LPARAM lParam, mObject *owner);
302 
403 struct _mNodeClass
404 {
405  mNodeClassHeader(mNode, mObject)
406 };
407 
408 typedef struct _mNodeEventData
409 {
410  mNode *source;
411  DWORD data;
412 }mNodeEventData;
418 {
424 
430 
436 
442 
448 };
449 
455 {
460 
465 
470 
475 
480 
485 
490 
495 
500 
505 
510 
515 
520 
525 };
526 
533 MGNCS_EXPORT extern mNodeClass g_stmNodeCls;
534 
535 /*============================================*/
536 typedef struct _mGroupNode mGroupNode;
537 typedef struct _mGroupNodeClass mGroupNodeClass;
538 
539 typedef struct _NCS_GROUPNODE_DATA
540 {
541  mNodeDataInfoHeader
542  int id;
543 }NCS_GROUPNODE_DATA;
544 
545 #define mGroupNodeHeader(className) \
546  mNodeHeader(className) \
547  int id;
548 struct _mGroupNode
549 {
550  mGroupNodeHeader(mGroupNode)
551 };
552 
553 #define mGroupNodeClassHeader(clsName, superCls) \
554  mNodeClassHeader(clsName, superCls)
555 struct _mGroupNodeClass
556 {
557  mGroupNodeClassHeader(mGroupNode, mNode)
558 };
559 
566 MGNCS_EXPORT extern mGroupNodeClass g_stmGroupNodeCls;
567 
568 MGNCS_EXPORT mNode* ncsAddGroupNode(mObject *parent, const char* text,
569  PBITMAP image, int height, int style, DWORD addData, int id);
570 
571 
572 #define NCS_CREATE_NODE(_retnode, _clstype, _parent, _text, _image, _height, _style, _add_data)\
573 do{\
574  NCS_NODE_DATA data; \
575  if (!_parent || (!INSTANCEOF(_parent, mNode) && !INSTANCEOF(_parent, mAbstractList))){ \
576  _retnode = NULL; \
577  }\
578  data.text = (char*)_text; \
579  data.image = _image; \
580  data.height = _height; \
581  data.style = _style; \
582  data.addData = _add_data; \
583  data.parent = _parent; \
584  _retnode = NEWEX(_clstype, (DWORD)&data); \
585 }while(0)
586 
587 #define NCS_ADD_NODE(_retnode, _clstype, _parent, text, image, height, style, _add_data)\
588 do {\
589  NCS_CREATE_NODE(_retnode, _clstype, _parent, text, image, height, style, _add_data);\
590  int ret = -1; \
591  if (_retnode && _parent && INSTANCEOF(_parent, mAbstractList)) {\
592  mAbstractList *list = (mAbstractList*)_parent; \
593  if (_c(list)->addNode) \
594  ret = _c(list)->addNode(list, (mNode*)_retnode); \
595  } \
596  else if (_retnode && _parent && INSTANCEOF(_parent, mNode)) { \
597  mNode *list = (mNode *)_parent; \
598  if (_c(list)->addNode) \
599  ret = _c(list)->addNode(list, (mNode*)_retnode); \
600  } \
601  if (ret < 0) { \
602  DELETE(_retnode); \
603  _retnode = NULL; \
604  }\
605 }while(0)
606 
609 #ifdef __cplusplus
610 }
611 #endif /* __cplusplus */
612 
613 #endif /* _MGUI_WIDGET_NODE_H */
614 
mNodeProp
The properties id of mNode.
Definition: mnode.h:454
ncsNodeFindType
The found information type used by findNode.
Definition: mnode.h:254
the Object struct
MGNCS_EXPORT mGroupNodeClass g_stmGroupNodeCls
The instance of mGroupNodeClass.
The virtual function table of mNodeClass.
MGNCS_EXPORT mNode * ncsAddNode(mObject *parent, const char *text, PBITMAP image, int height, int style, DWORD addData)
Create and add a new node to control according to parameter information.
The structure of mNode. It is the basic class of all nodes occur within specific controls. For example, a list can contain it.
mNodeEvent
The event id of mNode.
Definition: mnode.h:417
MGNCS_EXPORT mNode * ncsCreateNode(mObject *parent, const char *text, PBITMAP image, int height, int style, DWORD addData)
Create a new node according to parameter information.
int(* NCS_CB_CMPNODE)(mNode *node1, mNode *node2)
The callback of node comparison function.
Definition: mnode.h:114
MGNCS_EXPORT mNodeClass g_stmNodeCls
The instance of mNodeClass.