54 #ifndef _MGUI_NCSCTRL_WIDGET_H 55 #define _MGUI_NCSCTRL_WIDGET_H 64 #define TOWIDGET(x) ((mWidget *)x) 65 #define TOWIDGETCLASS(x) ((mWidgetClass *)x) 67 #define RendererType(className) className##Renderer 79 #define NCSCTRL_WIDGET NCSCLASSNAME("widget") 82 typedef struct _mWidget
mWidget;
95 #define mWidgetRendererHeader(clsName, parentClass) \ 96 const char* rdr_name; \ 98 void (*class_init)(RendererType(clsName)* rdr); \ 99 RendererType(parentClass) *ptrParentClass; \ 100 BOOL (*init_self)(RendererType(clsName) *rdr); \ 101 void (*uninit_self)(RendererType(clsName) *rdr); \ 104 void (*drawFocusFrame)(clsName*, HDC, const RECT* ); \ 105 BOOL (*drawBkground)(clsName*, HDC, const RECT*); \ 106 void (*draw3dbox)(clsName*, HDC, const RECT*, DWORD,DWORD); \ 107 void (*drawCheckbox)(clsName*, HDC, const RECT*, DWORD); \ 108 void (*drawRadio)(clsName*, HDC, const RECT*, DWORD); \ 109 void (*drawArrow)(clsName*, HDC, const RECT*, int arrow,DWORD, DWORD); \ 110 void (*drawItem)(clsName*, HDC, const RECT*, DWORD); 150 #define NCSR_STATUS(flag) ((flag)&0xFFFF) 288 struct _mWidgetRenderer {
293 #define NCSSPEC_OBJ_CONTENT MAX_USER_SPECIAL_KEY + 1 295 #define mWidgetHeader(clsName) \ 296 mComponentHeader(clsName) \ 298 RendererType(clsName) *renderer; \ 300 ImageDrawInfo bkimg; \ 326 #define mWidgetClassHeader(clsName, parentClass) \ 327 mComponentClassHeader(clsName, parentClass) \ 329 mObject * (*createBody)(clsName*); \ 330 LRESULT (*wndProc)(clsName* , UINT, WPARAM, LPARAM); \ 331 BOOL (*callUserHandler)(clsName* self, void *handler, \ 332 UINT message, WPARAM wParam, LPARAM lParam, LRESULT *pRet); \ 333 BOOL (*onCreate)(clsName*, LPARAM); \ 334 BOOL (*addChildren)(clsName*, NCS_WND_TEMPLATE* children,int count); \ 335 void (*onPaint)(clsName*, HDC, const PCLIPRGN pClip); \ 336 int (*onLButtonDown)(clsName*, int x, int y, DWORD keyFlags); \ 337 int (*onLButtonUp)(clsName*, int x, int y, DWORD keyFlags); \ 338 int (*onMouseMove)(clsName*, int x, int y, DWORD keyFlags); \ 339 int (*onKeyDown)(clsName*, int scancode, DWORD keyFlags); \ 340 int (*onKeyUp)(clsName*, int scancode, DWORD keyFlags); \ 341 int (*onSizeChanged)(clsName*, RECT* rtClient); \ 342 BOOL (*onEraseBkgnd)(clsName*, HDC hdc, const RECT* invRect); \ 344 BOOL (*refresh)(clsName *); 378 #define SET_DLGCODE(code) _class->dlgCode = (code); 450 #define NCSS_NOTIFY (0x1) 452 #define IsNotify(self) \ 453 (GetWindowStyle(self->hwnd)&NCSS_NOTIFY) 455 #define NCSS_WIDGET_SHIFT 1 461 #define NCSS_EX_UNNEEDIME 0x1 504 #define NCSR_CONTINUE_MSG FALSE 512 #define NCSR_STOP_MSG TRUE 667 typedef BOOL (*
NCS_CB_ONKEY)(mWidget*, UINT message,
int code, DWORD keyStatus);
682 typedef BOOL(*
NCS_CB_ONMOUSE)(mWidget*, UINT message,
int x,
int y, DWORD keyStatus);
753 typedef int (*
NCS_CB_ONMSG)(mWidget*, UINT message, WPARAM wParam, LPARAM lParam);
771 #define NCS_NOTIFY_CODE(code) (0xFFFF0000 | (code)) 776 #define NCS_MAP_NOTIFY(code, handler) { NCS_NOTIFY_CODE(code), (void*)(handler) } 781 mObject * mWidget_getCapturedHotPiece(mWidget *
self);
782 void mWidget_releaseCapturedHotPiece(
void);
784 void mWidget_setHoveringFocus(mWidget *
self,
mObject *hotpiece);
785 mObject * mWidget_getHoveringFocus(mWidget *
self);
786 void mWidget_releaseHoveringFocus(
void);
788 void mWidget_setInputFocus(mWidget *
self,
mObject *hotpiece);
789 mObject * mWidget_getInputFocus(mWidget *
self);
790 void mWidget_releaseInputFocus(
void);
792 #ifdef _MGNCS_GUIBUILDER_SUPPORT 795 #define NCSP_DEFAULT_CONTENT 10000 822 MGNCS_EXPORT BOOL
ncsSetFont (HWND hWnd,
const char *fontName);
920 typedef struct _NCS_CREATE_INFO{
967 const char* font_name;
973 NCS_CREATE_NOTIFY_INFO * notify_info;
1010 MGNCS_EXPORT mWidget*
ncsCreateWindow (
const char *className,
const char *caption, DWORD style, DWORD exStyle, \
1011 int id,
int x,
int y,
int w,
int h, HWND parent, \
1079 DWORD style, DWORD exStyle, \
1080 int id,
int x,
int y,
int w,
int h, HWND host, \
1081 HICON hIcon, HMENU hMenu,
1135 const char* font_name;
1141 NCS_CREATE_NOTIFY_INFO * notify_info;
1168 const char* class_name;
1173 const char* caption;
1184 const char* font_name;
1190 NCS_CREATE_NOTIFY_INFO * notify_info;
1234 #define ncsNotifyParent(self, code) ncsNotifyParentEx((mWidget*)(self), code, 0) 1247 return (mWidget*)(GetWindowAdditionalData2(hwnd));
1263 return (mWidget*)(
self?
_c(
self)->getChild(
self,
id):NULL);
1295 return _c(widget)->dlgCode;
1299 return (DWORD)SendMessage(hwnd, MSG_GETDLGCODE, 0, 0);
1309 #define ncsDeleteWidget(self) ncsDestroyWindow(self, 0) 1312 #define NCS_FETCH_MSGBINDINFO(sender, param, lParam) do{ \ 1313 void ** __tmp = (void**)(lParam); \ 1315 register DWORD* __param = (DWORD*)(void*)&(param); \ 1316 register void** __sender = (void**)(void*)&(sender); \ 1317 *__param = (DWORD)__tmp[0]; \ 1318 *__sender = __tmp[1]; \ 1323 MGNCS_EXPORT BOOL ncsBindEventsToMessage(
mObject *sender, HWND hwnd_listener, UINT message,
int* event_ids);
1324 MGNCS_EXPORT BOOL ncsBindEventToMessage(
mObject* sender, HWND hwnd_listener, UINT message,
int event_ids);
1325 MGNCS_EXPORT
void ncsRemoveBindWindow(HWND hwnd_listener);
1326 MGNCS_EXPORT
void ncsRemoveBindMessage(HWND hwnd_listener, UINT message,
mObject* sender,
int event_id);
MGNCS_EXPORT BOOL ncsSetFont(HWND hWnd, const char *fontName)
set control's font
static mWidget * ncsGetChildObj(HWND hwnd, int id)
Get the child object pointer of window.
MGNCS_EXPORT DWORD ncsGetProperty(HWND hWnd, int id)
get control's property
MGNCS_EXPORT void ncsNotifyParentEx(mWidget *self, int code, DWORD addData)
raise a notification event
struct _NCS_RDR_INFO NCS_RDR_INFO
static mWidget * ncsGetParentObj(HWND hwnd)
Get the parent object pointer of window.
NCS_RDR_ELEMENT * elements
struct _NCS_RDR_ELEMENT NCS_RDR_ELEMENT
MGNCS_EXPORT mWidget * ncsCreateMainWindowIndirect(const NCS_MNWND_TEMPLATE *tmpl, HWND hHost)
create a main window from a template
#define _c(ths)
the marco get the class of a object
struct _NCS_PROP_ENTRY NCS_PROP_ENTRY
MGNCS_EXPORT BOOL ncsSetProperty(HWND hWnd, int id, DWORD value)
set control's property
struct _NCS_MNWND_TEMPLATE NCS_MNWND_TEMPLATE
struct _NCS_CREATE_NOTIFY_INFO NCS_CREATE_NOTIFY_INFO
struct _NCS_MAIN_CREATE_INFO NCS_MAIN_CREATE_INFO
static DWORD ncsGetDlgCode(HWND hwnd)
Get the dialog code of a NCS window.
MGNCS_EXPORT void ncsDestroyWindow(mWidget *self, DWORD endCode)
delete the widget window created by ncs.
MGNCS_EXPORT mWidget * ncsCreateMainWindow(const char *className, const char *caption, DWORD style, DWORD exStyle, int id, int x, int y, int w, int h, HWND host, HICON hIcon, HMENU hMenu, NCS_PROP_ENTRY *props, NCS_RDR_INFO *rdrInfo, NCS_EVENT_HANDLER *handlers, DWORD addData)
create a NCS main window
the component member define
static mWidget * ncsObjFromHandle(HWND hwnd)
Get a Object from window handle.
NCS_CREATE_INFO * create_info
MGNCS_EXPORT mWidgetClass * ncsGetMainWndClass(const char *className)
Get a Main window Class by className.
MGNCS_EXPORT mWidget * ncsCreateWindow(const char *className, const char *caption, DWORD style, DWORD exStyle, int id, int x, int y, int w, int h, HWND parent, NCS_PROP_ENTRY *props, NCS_RDR_INFO *rdrInfo, NCS_EVENT_HANDLER *handlers, DWORD addData)
create a NCS widget
MGNCS_EXPORT mWidget * ncsCreateWindowIndirect(const NCS_WND_TEMPLATE *tmpl, HWND hParent)
create a mComponent by NCS_WND_TEMPLATE,