mnode.h

Go to the documentation of this file.
00001 
00026 #ifndef _MGUI_WIDGET_NODE_H
00027 #define _MGUI_WIDGET_NODE_H
00028  
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif  /* __cplusplus */
00033 
00039 typedef struct _mNode mNode;
00040 typedef struct _mNodeClass mNodeClass;
00041 
00046 #define NCSS_NODE_LTEXTRS           0x0000
00047 
00053 #define NCSS_NODE_SMALLICON         0x0001
00054 
00059 #define NCSS_NODE_LTEXTBS           0x0002
00060 
00065 #define NCSS_NODE_TICTACTOEMIDLET   0x0004
00066 
00067 #define NCSS_NODE_LAYOUT_MASK       0x00FF
00068 
00073 #define NCSS_NODE_HIDETEXT          0x0010
00074 
00079 #define NCSS_NODE_HIDEIMAGE         0x0020
00080 
00085 #define NCSS_NODE_DISABLED          0x0040
00086 
00091 #define NCSS_NODE_SHIFT             7
00092 
00098 typedef int (*NCS_CB_CMPNODE) (mNode *node1, mNode *node2);
00099 
00100 #define mNodeDataInfoHeader \
00101     int     style;      \
00102     char    *text;      \
00103     PBITMAP image;      \
00104     int     height;     \
00105     DWORD   addData;    \
00106     mObject *parent;    \
00107     
00108 
00109 typedef struct _NCS_NODE_DATA
00110 {
00111     mNodeDataInfoHeader
00112 }NCS_NODE_DATA;
00113 
00114 //status flags
00115 #define NCSF_NODE_MASK              0xFFFF
00116 #define NCSF_NODE_NORMAL            0x0000
00117 #define NCSF_NODE_SELECTED          0x0001
00118 #define NCSF_NODE_DISABLED          0x0002
00119 #define NCSF_NODE_INVISIBLE         0x0004
00120 #define NCSF_NODE_DEFHEIGHT         0x0008
00121 
00122 #define NCSF_NODE_HIDETEXT          0x0010
00123 #define NCSF_NODE_HIDEIMAGE         0x0020
00124 
00125 typedef struct _NCS_NODE_LAYOUTOPS
00126 {
00127     const char name[16];
00128     int style;
00129     void (*paint)(mNode *self, HDC hdc, const RECT *rect, mObject *owner);
00130 }NCS_NODE_LAYOUTOPS;
00131 
00132 #define mNodeHeader(className)  \
00133         mObjectHeader(className)    \
00134     NCS_NODE_LAYOUTOPS *layout; \
00135     list_t  children;           \
00136     list_t  sibling;            \
00137     Uint16  flags;              \
00138     Uint16  count;              \
00139     mNodeDataInfoHeader
00140 
00172 struct _mNode
00173 {
00174         mNodeHeader(mNode)
00175 };
00176 
00177 typedef struct _NCS_MENU_DATA
00178 {
00179     int     nr_child;
00180     struct _NCS_MENU_DATA   *child;
00181 
00182     mNodeDataInfoHeader
00183 }NCS_MENU_DATA;
00184 MGNCS_EXPORT void ncsSetMenuData(mObject *self, NCS_MENU_DATA *pMenuData, int count);
00185 
00186 typedef struct _NCS_MENU_INFO
00187 {
00188     int     count; 
00189     char    *caption;
00190     NCS_MENU_DATA *data;
00191 }NCS_MENU_INFO;
00192 MGNCS_EXPORT void ncsSetMenu(mObject *self, NCS_MENU_INFO *pMenuInfo);
00193 
00209 MGNCS_EXPORT mNode* ncsCreateNode(mObject *parent, const char* text, 
00210         PBITMAP image, int height, int style, DWORD addData);
00211 
00231 MGNCS_EXPORT mNode* ncsAddNode(mObject *parent, const char* text, 
00232         PBITMAP image, int height, int style, DWORD addData);
00233 
00238 enum ncsNodeFindType
00239 {
00243     NCS_NODE_FTSTRING,
00244 
00248     NCS_NODE_FTDATA,
00249 
00253     NCS_NODE_FTIMAGE,
00254 
00255     NCS_NODE_FTOTHER,
00256 };
00257 
00258 #define mNodeClassHeader(clsName, superCls)             \
00259         mObjectClassHeader(clsName, superCls)               \
00260         BOOL (*setProperty)(clsName*, int id, DWORD value); \
00261         DWORD (*getProperty)(clsName*, int id);             \
00262     BOOL (*computeSize)(clsName*, HDC hdc, SIZE *size); \
00263     BOOL (*canAsRoot)(clsName*);                        \
00264     int (*addNode)(clsName*, mNode *node);              \
00265     int (*removeNode)(clsName*, mNode *node);           \
00266     int (*insertNode)(clsName*, mNode *node, mNode *prev, mNode *next, int index);\
00267     int (*moveNode)(clsName*, mNode *curNode, int count, mNode *prevNode);  \
00268     mNode* (*findNode)(mNode *self, DWORD info, int type, BOOL recursion, int startIndex);\
00269     mNode* (*findNodeEx)(mNode *self, DWORD info, int type, BOOL recursion, int startIndex, \
00270             int (*cb)(mNode *node, DWORD info));        \
00271     void (*removeAll)(clsName*);                        \
00272     void (*sendEvent)(clsName*, int eventId);           \
00273     mNode* (*getNode)(clsName*, int index);             \
00274     int (*indexOf)(clsName*);                           \
00275     mNode* (*getPrev)(clsName*);                        \
00276     mNode* (*getNext)(clsName*);                        \
00277     BOOL (*isEnabled)(clsName*);                        \
00278     BOOL (*isSelected)(clsName*);                       \
00279     BOOL (*hasChildren)(clsName*);                      \
00280     BOOL (*setText)(clsName*, const char* text);        \
00281     BOOL (*setImage)(clsName*, const PBITMAP image);    \
00282     const char* (*getText)(clsName*);                   \
00283     PBITMAP (*getImage)(clsName*);                      \
00284     void (*paint)(clsName*, HDC hdc, const RECT *rect, mObject *owner);  \
00285         int (*msgHandler)(clsName*, int msg, WPARAM wParam, LPARAM lParam, mObject *owner);
00286     
00387 struct _mNodeClass
00388 {
00389         mNodeClassHeader(mNode, mObject)
00390 };
00391 
00392 typedef struct _mNodeEventData
00393 {
00394     mNode *source;
00395     DWORD data;
00396 }mNodeEventData;
00401 enum mNodeEvent
00402 {
00407     NCSE_NODE_CONTENTCHANGED = 1, 
00408 
00413     NCSE_NODE_HEIGHTCHANGED,
00414 
00419     NCSE_NODE_REFRESH,   
00420 
00425     NCSE_NODE_NODEADDED,  
00426 
00431     NCSE_NODE_NODEDELETED, 
00432 };
00433 
00438 enum mNodeProp
00439 {
00443     NCSP_NODE_HEIGHT = 1,
00444 
00448     NCSP_NODE_TEXT,
00449 
00453     NCSP_NODE_IMAGE,
00454 
00458     NCSP_NODE_ADDDATA,
00459 
00463     NCSP_NODE_ENABLED,
00464 
00468     NCSP_NODE_SELECTED,
00469 
00473     NCSP_NODE_PARENTNODE,
00474 
00478     NCSP_NODE_FIRSTCHILD,
00479 
00483     NCSP_NODE_LASTCHILD,
00484 
00488     NCSP_NODE_CHILDRENCOUNT,
00489 
00493     NCSP_NODE_LAYOUT,
00494 
00498     NCSP_NODE_HIDETEXT,
00499 
00503     NCSP_NODE_HIDEIMAGE,
00504 
00508         NCSP_NODE_MAX,
00509 };
00510 
00517 MGNCS_EXPORT extern mNodeClass g_stmNodeCls;
00518 
00519 /*============================================*/
00520 typedef struct _mGroupNode mGroupNode;
00521 typedef struct _mGroupNodeClass mGroupNodeClass;
00522 
00523 typedef struct _NCS_GROUPNODE_DATA
00524 {
00525     mNodeDataInfoHeader
00526     int id;
00527 }NCS_GROUPNODE_DATA;
00528 
00529 #define mGroupNodeHeader(className)  \
00530         mNodeHeader(className)      \
00531     int id;
00532 struct _mGroupNode
00533 {
00534         mGroupNodeHeader(mGroupNode)
00535 };
00536 
00537 #define mGroupNodeClassHeader(clsName, superCls)    \
00538         mNodeClassHeader(clsName, superCls)
00539 struct _mGroupNodeClass
00540 {
00541         mGroupNodeClassHeader(mGroupNode, mNode)
00542 };
00543 
00550 MGNCS_EXPORT extern mGroupNodeClass g_stmGroupNodeCls;
00551 
00552 MGNCS_EXPORT mNode* ncsAddGroupNode(mObject *parent, const char* text, 
00553         PBITMAP image, int height, int style, DWORD addData, int id);
00554 
00555 
00556 #define NCS_CREATE_NODE(_retnode, _clstype, _parent, _text, _image, _height, _style, _add_data)\
00557 do{\
00558     NCS_NODE_DATA data;         \
00559     if (!_parent || (!INSTANCEOF(_parent, mNode) && !INSTANCEOF(_parent, mAbstractList))){  \
00560         _retnode = NULL;        \
00561     }\
00562     data.text = (char*)_text;   \
00563     data.image = _image;        \
00564     data.height = _height;      \
00565     data.style = _style;        \
00566     data.addData = _add_data;   \
00567     data.parent = _parent;      \
00568     _retnode = NEWEX(_clstype, (DWORD)&data);  \
00569 }while(0)
00570 
00571 #define NCS_ADD_NODE(_retnode, _clstype, _parent, text, image, height, style, _add_data)\
00572 do {\
00573     NCS_CREATE_NODE(_retnode, _clstype, _parent, text, image, height, style, _add_data);\
00574     int ret = -1;               \
00575     if (_retnode && _parent && INSTANCEOF(_parent, mAbstractList)) {\
00576         mAbstractList *list = (mAbstractList*)_parent;              \
00577         if (_c(list)->addNode)                                      \
00578             ret = _c(list)->addNode(list, (mNode*)_retnode);              \
00579     }                           \
00580     else if (_retnode && _parent && INSTANCEOF(_parent, mNode)) {   \
00581         mNode *list = (mNode *)_parent;                             \
00582         if (_c(list)->addNode)                                      \
00583             ret = _c(list)->addNode(list, (mNode*)_retnode);              \
00584     }                           \
00585     if (ret < 0) {              \
00586         DELETE(_retnode);        \
00587         _retnode = NULL;         \
00588     }\
00589 }while(0)
00590 
00593 #ifdef __cplusplus
00594 }
00595 #endif  /* __cplusplus */
00596 
00597 #endif /* _MGUI_WIDGET_NODE_H */
00598 
Generated on Fri Jun 10 11:18:06 2011 for New Control Set V1.0.0 API Reference by  doxygen 1.6.3