42 #ifndef _MGUI_NCSCTRL_WIDGET_H 43 #define _MGUI_NCSCTRL_WIDGET_H 52 #define TOWIDGET(x) ((mWidget *)x) 53 #define TOWIDGETCLASS(x) ((mWidgetClass *)x) 55 #define RendererType(className) className##Renderer 67 #define NCSCTRL_WIDGET NCSCLASSNAME("widget") 70 typedef struct _mWidget
mWidget;
83 #define mWidgetRendererHeader(clsName, parentClass) \ 84 const char* rdr_name; \ 86 void (*class_init)(RendererType(clsName)* rdr); \ 87 RendererType(parentClass) *ptrParentClass; \ 88 BOOL (*init_self)(RendererType(clsName) *rdr); \ 89 void (*uninit_self)(RendererType(clsName) *rdr); \ 92 void (*drawFocusFrame)(clsName*, HDC, const RECT* ); \ 93 BOOL (*drawBkground)(clsName*, HDC, const RECT*); \ 94 void (*draw3dbox)(clsName*, HDC, const RECT*, DWORD,DWORD); \ 95 void (*drawCheckbox)(clsName*, HDC, const RECT*, DWORD); \ 96 void (*drawRadio)(clsName*, HDC, const RECT*, DWORD); \ 97 void (*drawArrow)(clsName*, HDC, const RECT*, int arrow,DWORD, DWORD); \ 98 void (*drawItem)(clsName*, HDC, const RECT*, DWORD); 138 #define NCSR_STATUS(flag) ((flag)&0xFFFF) 276 struct _mWidgetRenderer {
281 #define NCSSPEC_OBJ_CONTENT MAX_USER_SPECIAL_KEY + 1 283 #define mWidgetHeader(clsName) \ 284 mComponentHeader(clsName) \ 286 RendererType(clsName) *renderer; \ 288 ImageDrawInfo bkimg; \ 314 #define mWidgetClassHeader(clsName, parentClass) \ 315 mComponentClassHeader(clsName, parentClass) \ 317 mObject * (*createBody)(clsName*); \ 318 LRESULT (*wndProc)(clsName* , UINT, WPARAM, LPARAM); \ 319 BOOL (*callUserHandler)(clsName* self, void *handler, \ 320 UINT message, WPARAM wParam, LPARAM lParam, LRESULT *pRet); \ 321 BOOL (*onCreate)(clsName*, LPARAM); \ 322 BOOL (*addChildren)(clsName*, NCS_WND_TEMPLATE* children,int count); \ 323 void (*onPaint)(clsName*, HDC, const PCLIPRGN pClip); \ 324 int (*onLButtonDown)(clsName*, int x, int y, DWORD keyFlags); \ 325 int (*onLButtonUp)(clsName*, int x, int y, DWORD keyFlags); \ 326 int (*onMouseMove)(clsName*, int x, int y, DWORD keyFlags); \ 327 int (*onKeyDown)(clsName*, int scancode, DWORD keyFlags); \ 328 int (*onKeyUp)(clsName*, int scancode, DWORD keyFlags); \ 329 int (*onSizeChanged)(clsName*, RECT* rtClient); \ 330 BOOL (*onEraseBkgnd)(clsName*, HDC hdc, const RECT* invRect); \ 332 BOOL (*refresh)(clsName *); 366 #define SET_DLGCODE(code) _class->dlgCode = (code); 438 #define NCSS_NOTIFY (0x1) 440 #define IsNotify(self) \ 441 (GetWindowStyle(self->hwnd)&NCSS_NOTIFY) 443 #define NCSS_WIDGET_SHIFT 1 449 #define NCSS_EX_UNNEEDIME 0x1 492 #define NCSR_CONTINUE_MSG FALSE 500 #define NCSR_STOP_MSG TRUE 655 typedef BOOL (*
NCS_CB_ONKEY)(mWidget*, UINT message,
int code, DWORD keyStatus);
670 typedef BOOL(*
NCS_CB_ONMOUSE)(mWidget*, UINT message,
int x,
int y, DWORD keyStatus);
741 typedef int (*
NCS_CB_ONMSG)(mWidget*, UINT message, WPARAM wParam, LPARAM lParam);
759 #define NCS_NOTIFY_CODE(code) (0xFFFF0000 | (code)) 764 #define NCS_MAP_NOTIFY(code, handler) { NCS_NOTIFY_CODE(code), (void*)(handler) } 769 mObject * mWidget_getCapturedHotPiece(mWidget *
self);
770 void mWidget_releaseCapturedHotPiece(
void);
772 void mWidget_setHoveringFocus(mWidget *
self,
mObject *hotpiece);
773 mObject * mWidget_getHoveringFocus(mWidget *
self);
774 void mWidget_releaseHoveringFocus(
void);
776 void mWidget_setInputFocus(mWidget *
self,
mObject *hotpiece);
777 mObject * mWidget_getInputFocus(mWidget *
self);
778 void mWidget_releaseInputFocus(
void);
780 #ifdef _MGNCS_GUIBUILDER_SUPPORT 783 #define NCSP_DEFAULT_CONTENT 10000 810 MGNCS_EXPORT BOOL
ncsSetFont (HWND hWnd,
const char *fontName);
908 typedef struct _NCS_CREATE_INFO{
955 const char* font_name;
961 NCS_CREATE_NOTIFY_INFO * notify_info;
998 MGNCS_EXPORT mWidget*
ncsCreateWindow (
const char *className,
const char *caption, DWORD style, DWORD exStyle, \
999 int id,
int x,
int y,
int w,
int h, HWND parent, \
1067 DWORD style, DWORD exStyle, \
1068 int id,
int x,
int y,
int w,
int h, HWND host, \
1069 HICON hIcon, HMENU hMenu,
1123 const char* font_name;
1129 NCS_CREATE_NOTIFY_INFO * notify_info;
1156 const char* class_name;
1161 const char* caption;
1172 const char* font_name;
1178 NCS_CREATE_NOTIFY_INFO * notify_info;
1222 #define ncsNotifyParent(self, code) ncsNotifyParentEx((mWidget*)(self), code, 0) 1235 return (mWidget*)(GetWindowAdditionalData2(hwnd));
1251 return (mWidget*)(
self?
_c(
self)->getChild(
self,
id):NULL);
1283 return _c(widget)->dlgCode;
1287 return (DWORD)SendMessage(hwnd, MSG_GETDLGCODE, 0, 0);
1297 #define ncsDeleteWidget(self) ncsDestroyWindow(self, 0) 1300 #define NCS_FETCH_MSGBINDINFO(sender, param, lParam) do{ \ 1301 void ** __tmp = (void**)(lParam); \ 1303 register DWORD* __param = (DWORD*)(void*)&(param); \ 1304 register void** __sender = (void**)(void*)&(sender); \ 1305 *__param = (DWORD)__tmp[0]; \ 1306 *__sender = __tmp[1]; \ 1311 MGNCS_EXPORT BOOL ncsBindEventsToMessage(
mObject *sender, HWND hwnd_listener, UINT message,
int* event_ids);
1312 MGNCS_EXPORT BOOL ncsBindEventToMessage(
mObject* sender, HWND hwnd_listener, UINT message,
int event_ids);
1313 MGNCS_EXPORT
void ncsRemoveBindWindow(HWND hwnd_listener);
1314 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,