mGNCS API Reference
v1.5.0
A new control set and a new framework for MiniGUI apps
|
Go to the documentation of this file.
54 #ifndef _MGUI_NCSCTRL_CMPT_H
55 #define _MGUI_NCSCTRL_CMPT_H
73 #define MAXLEN_CLASSNAME 31
79 #define NCSCLASSNAME(name) name _MGNCS_CLASS_SUFFIX
81 #define BEGIN_CMPT_CLASS(clss, superCls) \
82 static const char comp_##clss##_class_name[] = (#clss _MGNCS_CLASS_SUFFIX) ; \
83 BEGIN_MINI_CLASS(clss, superCls) \
84 _class->className = comp_##clss##_class_name + 1;
86 #define END_CMPT_CLASS END_MINI_CLASS
90 typedef struct _mBindProp mBindProp;
93 typedef void (*PFreeSpecificData)(DWORD key, DWORD value);
95 #define MAX_USER_SPECIAL_KEY 0x80000000L
100 #define mComponentClassHeader(clss, superCls) \
101 mObjectClassHeader(clss, superCls) \
102 const char* className; \
103 clss * (*createComponent)(mComponent* parent, ClassType(clss)*, DWORD addValue); \
104 WNDPROC _window_proc ; \
105 BOOL (*setProperty)(clss *self, int id, DWORD value); \
106 DWORD (*getProperty)(clss *self, int id); \
107 int (*setId)(clss *self, int id); \
108 int (*getId)(clss *self); \
109 mComponent* (*getReleated)(clss*self, int releated); \
110 mComponent* (*setReleated)(clss *self, mComponent* comp, int releated); \
111 mComponent* (*getChild)(clss* self, int id); \
112 void (*removeChild)(clss* self, mComponent* child); \
113 PUBLIC DWORD (*getPropertyByPath)(clss* self, int *id_path); \
114 PUBLIC BOOL (*setPropertyByPath)(clss* self, int *id_path, DWORD value); \
115 PUBLIC BOOL (*addEventListenerByPath)(clss* self, int *id_path, mObject* listener, NCS_CB_ONOBJEVENT on_event); \
116 PUBLIC BOOL (*addBindPropByPath)(clss* self, int *id_path, int event_id, int prop_type, int flags, mBindProp *prop, int bind_type); \
117 PUBLIC BOOL (*queryByPath)(clss* self, int *id_path, DWORD *pret, ...); \
118 PUBLIC BOOL (*vqueryByPath)(clss* self, int *id_path, DWORD* pret, va_list va); \
119 PUBLIC BOOL (*isMainObj)(clss* self); \
120 BOOL (*setSpecificData)(clss* self, DWORD key, DWORD value, PFreeSpecificData freeSpecific); \
121 DWORD (*getSpecificData)(clss* self, DWORD key, BOOL *pOk);
253 struct _mComponentClass {
261 #define IDPATH_END -1
264 #define IDPATH_PARENT -3
265 #define IDPATH_MAINPARENT -4
266 #define IDPATH_ROOT -5
268 #define ISVALID_IDPATH(id_path) \
269 ((id_path) && (id_path)[0] != IDPATH_END)
271 #define IDPATH_ISOBJ(id_path) \
272 ((id_path)[1] != IDPATH_END)
274 #define BYPATHFUNCEX(baseclass, base_check, err_ret, func, finaly_func_ex, ...) do{ \
276 if(!ISVALID_IDPATH(id_path)) \
278 while(IDPATH_ISOBJ(id_path)) { \
279 if(id_path[0] == IDPATH_ME){ \
282 } else if(id_path[0] == IDPATH_PARENT) \
283 cmp = _c(self)->getReleated(self, NCS_CMPT_PARENT); \
284 else if(id_path[0] == IDPATH_MAINPARENT) \
285 cmp = ncsCompGetMainParent((mComponent*)self); \
286 else if(id_path[0] == IDPATH_ROOT) \
287 cmp = ncsCompGetRoot((mComponent*)self); \
289 cmp = _c(self)->getChild(self, id_path[0]); \
290 if(!cmp && base_check(cmp,baseclass)) return err_ret; \
291 return _c(baseclass*)->func((baseclass*)cmp, ++id_path, ##__VA_ARGS__); \
293 finaly_func_ex(self, id_path[0], ##__VA_ARGS__); \
296 #define BYPATHFUNC(baseclass, base_check,err_ret, func, final_func, ...) \
297 BYPATHFUNCEX(baseclass, base_check,err_ret, func, return (_c(self)->final_func), ##__VA_ARGS__)
299 #define IDPATH_NOBASECHECK(cmp, baseclass) 1
332 typedef struct _mSpecificDataNode {
335 PFreeSpecificData freeSpecific;
336 struct _mSpecificDataNode* next;
339 #define mComponentHeader(clss) \
340 mObjectHeader(clss) \
341 NCS_EVENT_HANDLER_NODE * event_handlers; \
342 mSpecificDataNode* specificHead;
483 #define ISCLASS(class_name, clssName) ncsIsClass((const char*)(class_name), (mComponentClass*)(&Class(clssName)))
494 MGNCS_EXPORT BOOL
ncsIsChildClass(
const char* childClassName,
const char* parentClassName);
525 MGNCS_EXPORT
mComponentClass * ncsClassFromMagicNum(DWORD magic_num, BOOL check,
const char* class_name);
529 #define MGNCS_REGISTER_COMPONENT_EX(className, dwStyle, dwExStyle, idCursor, idBkColor) \
530 do {if(!ncsRegisterComponent((mComponentClass*)MGNCS_INIT_CLASS(className), \
531 dwStyle, dwExStyle, idCursor, idBkColor)) \
532 return FALSE;}while(0)
535 #define MGNCS_REGISTER_COMPONENT(className) \
536 MGNCS_REGISTER_COMPONENT_EX(className, \
537 WS_NONE, WS_EX_NONE, IDC_ARROW, WE_BGC_WINDOW)
539 #define MGNCS_UNREG_COMPONENT(clssName) \
540 UnregisterWindowClass(Class(clssName).className)
542 #define NCS_SET_PROP(self, id, value) \
543 _c(self)->setProperty(self, (id), (value))
544 #define NCS_GET_PROP(self, id) \
545 _c(self)->getProperty(self, (id))
the component member define
MGNCS_EXPORT BOOL ncsIsChildClass(const char *childClassName, const char *parentClassName)
check a class name is derived class of a special class
@ NCS_CMPT_PREV
prev sliding component
MGNCS_EXPORT void * ncsSetComponentHandler(mComponent *comp, UINT message, void *handler)
set the component handler
struct _NCS_EVENT_HANDLER NCS_EVENT_HANDLER
MGNCS_EXPORT mComponentClass g_stmComponentCls
the singleton of mComponentClass
MGNCS_EXPORT mComponentClass * ncsGetComponentClass(const char *className, BOOL check)
Get a mComponentClass instance from MiniGUI.
@ NCS_CMPT_CHILDREN
the first child component
MGNCS_EXPORT BOOL ncsIsClass(const char *className, mComponentClass *clss)
check a class name is a special class type or not
MGNCS_EXPORT void ncsSetComponentHandlers(mComponent *comp, NCS_EVENT_HANDLER *handlers, int count)
set an array of event handlers
ncsComponentReleated
The releation between components.
MGNCS_EXPORT BOOL ncsComponentConnectEvents(mComponent *comps, NCS_EVENT_CONNECT_INFO *connects, int counts)
connect the events between parent and its children, used by ncsCreateMainWindowIndirectFromID
@ NCS_CMPT_PARENT
the parent component
struct _NCS_EVENT_CONNECT_INFO NCS_EVENT_CONNECT_INFO
MGNCS_EXPORT BOOL ncsRegisterComponent(mComponentClass *compCls, DWORD dwStyle, DWORD dwExStyle, int idCursor, int idBkColor)
register a component class into MiniGUI, so that ncsCreateWindow and ncsCreateWindow can find a mComp...
struct _NCS_EVENT_HANDLER_NODE * next
@ NCS_CMPT_NEXT
next sliding component
mComponentQueryCmd
queryByPath and vqueryByPath's cmd_id
the basic class of components, windows. Drived by mObjectClass
MGNCS_EXPORT void * ncsGetComponentHandler(mComponent *comp, UINT message)
get an event callback
struct _NCS_EVENT_HANDLER_NODE NCS_EVENT_HANDLER_NODE