42 #ifndef _MGUI_NCSCTRL_CMPT_H 43 #define _MGUI_NCSCTRL_CMPT_H 61 #define MAXLEN_CLASSNAME 31 67 #define NCSCLASSNAME(name) name _MGNCS_CLASS_SUFFIX 69 #define BEGIN_CMPT_CLASS(clss, superCls) \ 70 static const char comp_##clss##_class_name[] = (#clss _MGNCS_CLASS_SUFFIX) ; \ 71 BEGIN_MINI_CLASS(clss, superCls) \ 72 _class->className = comp_##clss##_class_name + 1; 74 #define END_CMPT_CLASS END_MINI_CLASS 78 typedef struct _mBindProp mBindProp;
81 typedef void (*PFreeSpecificData)(DWORD key, DWORD value);
83 #define MAX_USER_SPECIAL_KEY 0x80000000L 88 #define mComponentClassHeader(clss, superCls) \ 89 mObjectClassHeader(clss, superCls) \ 90 const char* className; \ 91 clss * (*createComponent)(mComponent* parent, ClassType(clss)*, DWORD addValue); \ 92 WNDPROC _window_proc ; \ 93 BOOL (*setProperty)(clss *self, int id, DWORD value); \ 94 DWORD (*getProperty)(clss *self, int id); \ 95 int (*setId)(clss *self, int id); \ 96 int (*getId)(clss *self); \ 97 mComponent* (*getReleated)(clss*self, int releated); \ 98 mComponent* (*setReleated)(clss *self, mComponent* comp, int releated); \ 99 mComponent* (*getChild)(clss* self, int id); \ 100 void (*removeChild)(clss* self, mComponent* child); \ 101 PUBLIC DWORD (*getPropertyByPath)(clss* self, int *id_path); \ 102 PUBLIC BOOL (*setPropertyByPath)(clss* self, int *id_path, DWORD value); \ 103 PUBLIC BOOL (*addEventListenerByPath)(clss* self, int *id_path, mObject* listener, NCS_CB_ONOBJEVENT on_event); \ 104 PUBLIC BOOL (*addBindPropByPath)(clss* self, int *id_path, int event_id, int prop_type, int flags, mBindProp *prop, int bind_type); \ 105 PUBLIC BOOL (*queryByPath)(clss* self, int *id_path, DWORD *pret, ...); \ 106 PUBLIC BOOL (*vqueryByPath)(clss* self, int *id_path, DWORD* pret, va_list va); \ 107 PUBLIC BOOL (*isMainObj)(clss* self); \ 108 BOOL (*setSpecificData)(clss* self, DWORD key, DWORD value, PFreeSpecificData freeSpecific); \ 109 DWORD (*getSpecificData)(clss* self, DWORD key, BOOL *pOk); 241 struct _mComponentClass {
249 #define IDPATH_END -1 252 #define IDPATH_PARENT -3 253 #define IDPATH_MAINPARENT -4 254 #define IDPATH_ROOT -5 256 #define ISVALID_IDPATH(id_path) \ 257 ((id_path) && (id_path)[0] != IDPATH_END) 259 #define IDPATH_ISOBJ(id_path) \ 260 ((id_path)[1] != IDPATH_END) 262 #define BYPATHFUNCEX(baseclass, base_check, err_ret, func, finaly_func_ex, ...) do{ \ 264 if(!ISVALID_IDPATH(id_path)) \ 266 while(IDPATH_ISOBJ(id_path)) { \ 267 if(id_path[0] == IDPATH_ME){ \ 270 } else if(id_path[0] == IDPATH_PARENT) \ 271 cmp = _c(self)->getReleated(self, NCS_CMPT_PARENT); \ 272 else if(id_path[0] == IDPATH_MAINPARENT) \ 273 cmp = ncsCompGetMainParent((mComponent*)self); \ 274 else if(id_path[0] == IDPATH_ROOT) \ 275 cmp = ncsCompGetRoot((mComponent*)self); \ 277 cmp = _c(self)->getChild(self, id_path[0]); \ 278 if(!cmp && base_check(cmp,baseclass)) return err_ret; \ 279 return _c(baseclass*)->func((baseclass*)cmp, ++id_path, ##__VA_ARGS__); \ 281 finaly_func_ex(self, id_path[0], ##__VA_ARGS__); \ 284 #define BYPATHFUNC(baseclass, base_check,err_ret, func, final_func, ...) \ 285 BYPATHFUNCEX(baseclass, base_check,err_ret, func, return (_c(self)->final_func), ##__VA_ARGS__) 287 #define IDPATH_NOBASECHECK(cmp, baseclass) 1 320 typedef struct _mSpecificDataNode {
323 PFreeSpecificData freeSpecific;
324 struct _mSpecificDataNode* next;
327 #define mComponentHeader(clss) \ 328 mObjectHeader(clss) \ 329 NCS_EVENT_HANDLER_NODE * event_handlers; \ 330 mSpecificDataNode* specificHead; 471 #define ISCLASS(class_name, clssName) ncsIsClass((const char*)(class_name), (mComponentClass*)(&Class(clssName))) 482 MGNCS_EXPORT BOOL
ncsIsChildClass(
const char* childClassName,
const char* parentClassName);
513 MGNCS_EXPORT
mComponentClass * ncsClassFromMagicNum(DWORD magic_num, BOOL check,
const char* class_name);
517 #define MGNCS_REGISTER_COMPONENT_EX(className, dwStyle, dwExStyle, idCursor, idBkColor) \ 518 do {if(!ncsRegisterComponent((mComponentClass*)MGNCS_INIT_CLASS(className), \ 519 dwStyle, dwExStyle, idCursor, idBkColor)) \ 520 return FALSE;}while(0) 523 #define MGNCS_REGISTER_COMPONENT(className) \ 524 MGNCS_REGISTER_COMPONENT_EX(className, \ 525 WS_NONE, WS_EX_NONE, IDC_ARROW, WE_BGC_WINDOW) 527 #define MGNCS_UNREG_COMPONENT(clssName) \ 528 UnregisterWindowClass(Class(clssName).className) 530 #define NCS_SET_PROP(self, id, value) \ 531 _c(self)->setProperty(self, (id), (value)) 532 #define NCS_GET_PROP(self, id) \ 533 _c(self)->getProperty(self, (id)) struct _NCS_EVENT_HANDLER_NODE NCS_EVENT_HANDLER_NODE
ncsComponentReleated
The releation between components.
MGNCS_EXPORT mComponentClass g_stmComponentCls
the singleton of mComponentClass
struct _NCS_EVENT_HANDLER_NODE * next
MGNCS_EXPORT void * ncsSetComponentHandler(mComponent *comp, UINT message, void *handler)
set the component handler
the first child component
MGNCS_EXPORT void * ncsGetComponentHandler(mComponent *comp, UINT message)
get an event callback
MGNCS_EXPORT void ncsSetComponentHandlers(mComponent *comp, NCS_EVENT_HANDLER *handlers, int count)
set an array of event handlers
struct _NCS_EVENT_HANDLER NCS_EVENT_HANDLER
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
MGNCS_EXPORT BOOL ncsIsClass(const char *className, mComponentClass *clss)
check a class name is a special class type or not
the basic class of components, windows. Drived by mObjectClass
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...
MGNCS_EXPORT mComponentClass * ncsGetComponentClass(const char *className, BOOL check)
Get a mComponentClass instance from MiniGUI.
mComponentQueryCmd
queryByPath and vqueryByPath's cmd_id
MGNCS_EXPORT BOOL ncsComponentConnectEvents(mComponent *comps, NCS_EVENT_CONNECT_INFO *connects, int counts)
connect the events between parent and its children, used by ncsCreateMainWindowIndirectFromID ...
BOOL(* NCS_CB_ONOBJEVENT)(mObject *self, mObject *sender, int eventId, DWORD param)
The Callback of connection.
struct _NCS_EVENT_CONNECT_INFO NCS_EVENT_CONNECT_INFO