mGNCS API Reference
v1.5.0
A new control set and a new framework for MiniGUI apps
|
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
540 typedef BOOL (*NCS_CB_ONCREATE)(
mWidget*, DWORD dwAddData);
555 typedef BOOL (*NCS_CB_ONINITDLG)(
mWidget*, HWND hFocus, DWORD dwAddData);
567 typedef BOOL (*NCS_CB_ONVOID)(
mWidget*, UINT message);
579 typedef void (*NCS_CB_ONSZCHGING)(
mWidget*,
const PRECT prcExpect, PRECT prcResult);
594 typedef BOOL (*NCS_CB_ONSZCHGED)(
mWidget*,PRECT prcClient);
607 typedef void (*NCS_CB_ONCSZCHGED)(
mWidget*,
int clientWidth,
int clientHeight);
620 typedef BOOL (*NCS_CB_ONFONTCHGING)(
mWidget*, PLOGFONT logFont);
633 typedef BOOL (*NCS_CB_ONERASEBKGND)(
mWidget*, HDC hdc,
const PRECT clip);
643 typedef void (*NCS_CB_ONPAINT)(
mWidget*, HDC hdc,
const PCLIPRGN clipRgn);
652 typedef BOOL (*NCS_CB_ONCLOSE)(
mWidget*);
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);
696 typedef BOOL (*NCS_CB_ONNCMOUSE)(
mWidget*, UINT message,
int x,
int y,
int hitCode);
708 typedef int (*NCS_CB_ONHITTEST)(
mWidget*, UINT message,
int x,
int y);
719 typedef void (*NCS_CB_ONSCROLL)(
mWidget*, UINT message,
int code,
int pos);
731 typedef BOOL (*NCS_CB_ONCMD)(
mWidget*,
int id,
int nc, HWND hCtrl);
740 typedef void (*NCS_CB_WIDGET_ONTIMER)(
mWidget*,
int id, DWORD count);
753 typedef int (*NCS_CB_ONMSG)(
mWidget*, UINT message, WPARAM wParam, LPARAM lParam);
763 typedef void (*NCS_CB_NOTIFY)(
mWidget*,
int id,
int ncCode, DWORD addData);
771 #define NCS_NOTIFY_CODE(code) (0xFFFF0000 | (code))
776 #define NCS_MAP_NOTIFY(code, handler) { NCS_NOTIFY_CODE(code), (void*)(handler) }
782 void mWidget_releaseCapturedHotPiece(
void);
786 void mWidget_releaseHoveringFocus(
void);
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;
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;
1168 const char* class_name;
1173 const char* caption;
1184 const char* font_name;
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);
the component member define
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
struct _NCS_CREATE_NOTIFY_INFO NCS_CREATE_NOTIFY_INFO
MGNCS_EXPORT mWidget * ncsCreateMainWindowIndirect(const NCS_MNWND_TEMPLATE *tmpl, HWND hHost)
create a main window from a template
struct _NCS_MNWND_TEMPLATE NCS_MNWND_TEMPLATE
static mWidget * ncsGetChildObj(HWND hwnd, int id)
Get the child object pointer of window.
MGNCS_EXPORT mWidgetClass * ncsGetMainWndClass(const char *className)
Get a Main window Class by className.
struct _NCS_RDR_ELEMENT NCS_RDR_ELEMENT
struct _NCS_MAIN_CREATE_INFO NCS_MAIN_CREATE_INFO
static mWidget * ncsObjFromHandle(HWND hwnd)
Get a Object from window handle.
MGNCS_EXPORT void ncsNotifyParentEx(mWidget *self, int code, DWORD addData)
raise a notification event
struct _NCS_PROP_ENTRY NCS_PROP_ENTRY
MGNCS_EXPORT DWORD ncsGetProperty(HWND hWnd, int id)
get control's property
MGNCS_EXPORT BOOL ncsSetFont(HWND hWnd, const char *fontName)
set control's font
static mWidget * ncsGetParentObj(HWND hwnd)
Get the parent object pointer of window.
MGNCS_EXPORT mWidget * ncsCreateWindowIndirect(const NCS_WND_TEMPLATE *tmpl, HWND hParent)
create a mComponent by NCS_WND_TEMPLATE,
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
NCS_CREATE_INFO * create_info
NCS_RDR_ELEMENT * elements
struct _NCS_RDR_INFO NCS_RDR_INFO
MGNCS_EXPORT BOOL ncsSetProperty(HWND hWnd, int id, DWORD value)
set control's property
#define _c(ths)
the marco get the class of a object