mGNCS API Reference  v1.2.0
A new control set and a new framework for MiniGUI apps
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
mWidget

Data Structures

struct  mWidgetRenderer
 Widget class's Renderer interface. More...
 
struct  mWidget
 define the mWidget members, inherit from mComponent More...
 
struct  mWidgetClass
 the VTable of mWidget, drived from mComponentClass More...
 

Macros

#define NCSCTRL_WIDGET   NCSCLASSNAME("widget")
 the name of widget control More...
 
#define NCSR_CONTINUE_MSG   FALSE
 return value, pass the message to the default window process More...
 
#define NCSR_STOP_MSG   TRUE
 return value, return directly, don't pass the message to default window process More...
 
#define NCS_NOTIFY_CODE(code)   (0xFFFF0000 | (code))
 
#define NCS_MAP_NOTIFY(code, handler)   { NCS_NOTIFY_CODE(code), (void*)(handler) }
 

Typedefs

typedef struct _NCS_WND_TEMPLATE NCS_WND_TEMPLATE
 
typedef void(* NCS_CB_ONNCCREATE) (mWidget *)
 the Callback of Event MSG_NCCREATE, which is the first message of a control More...
 
typedef BOOL(* NCS_CB_ONCREATE) (mWidget *, DWORD dwAddData)
 the callback of event MSG_CREATE More...
 
typedef BOOL(* NCS_CB_ONINITDLG) (mWidget *, HWND hFocus, DWORD dwAddData)
 the callback of event MSG_INITDIALOG, only valid in mDialogBox, when a dialog is created More...
 
typedef BOOL(* NCS_CB_ONVOID) (mWidget *, UINT message)
 the callback of events MSG_ACTIVE MSG_FONTCHANGED MSG_KEYLONGPRESS MSG_KEYALWAYSPRESS MSG_DESTROY More...
 
typedef void(* NCS_CB_ONSZCHGING) (mWidget *, const PRECT prcExpect, PRECT prcResult)
 the callback of event MSG_SIZECHANGING, when a widget's bound is changing. If you want change the widget bounds, set the prcResult, by default, copy prcExpect to prcResult More...
 
typedef BOOL(* NCS_CB_ONSZCHGED) (mWidget *, PRECT prcClient)
 the callback of event MSG_SIZECHANGED More...
 
typedef void(* NCS_CB_ONCSZCHGED) (mWidget *, int clientWidth, int clientHeight)
 the callbace of event MSG_CSIZECHANGED More...
 
typedef BOOL(* NCS_CB_ONFONTCHGING) (mWidget *, PLOGFONT logFont)
 the callback of event MSG_FONTCHANGING More...
 
typedef BOOL(* NCS_CB_ONERASEBKGND) (mWidget *, HDC hdc, const PRECT clip)
 the callback of event MSG_ERASEBKGND More...
 
typedef void(* NCS_CB_ONPAINT) (mWidget *, HDC hdc, const PCLIPRGN clipRgn)
 the callback of event MSG_PAINT More...
 
typedef BOOL(* NCS_CB_ONCLOSE) (mWidget *)
 the callback of event MSG_CLOSE More...
 
typedef BOOL(* NCS_CB_ONKEY) (mWidget *, UINT message, int code, DWORD keyStatus)
 the callback of event MSG_KEYDOWN MSG_KEYUP MSG_CHAR MSG_SYSKEYDOWN MSG_SYSKEYUP MSG_SYSCHAR More...
 
typedef BOOL(* NCS_CB_ONMOUSE) (mWidget *, UINT message, int x, int y, DWORD keyStatus)
 the callback of events MSG_LBUTTONDOWN MSG_LBUTTONUP MSG_LBUTTONDBCLK MSG_MOUSEMOVE MSG_RBUTTONDOWN MSG_RBUTTONUP MSG_RBUTTONDBCLK More...
 
typedef BOOL(* NCS_CB_ONNCMOUSE) (mWidget *, UINT message, int x, int y, int hitCode)
 the callback of events MSG_NCLBUTTONDOWN MSG_NCLBUTTONUP MSG_NCLBUTTONDBCLK MSG_NCMOUSEMOVE MSG_NCRBUTTONDOWN MSG_NCRBUTTONUP MSG_NCRBUTTONDBCLK More...
 
typedef int(* NCS_CB_ONHITTEST) (mWidget *, UINT message, int x, int y)
 the callback of events MSG_HITTEST MSG_NCHITTEST More...
 
typedef void(* NCS_CB_ONSCROLL) (mWidget *, UINT message, int code, int pos)
 the callback of events MSG_HSCROLL , MSG_VSCROLL More...
 
typedef BOOL(* NCS_CB_ONCMD) (mWidget *, int id, int nc, HWND hCtrl)
 the callback of event MSG_COMMAND More...
 
typedef void(* NCS_CB_WIDGET_ONTIMER) (mWidget *, int id, DWORD count)
 the callback of event MSG_TIMER More...
 
typedef int(* NCS_CB_ONMSG) (mWidget *, UINT message, WPARAM wParam, LPARAM lParam)
 the callback of a common message event More...
 
typedef void(* NCS_CB_NOTIFY) (mWidget *, int id, int ncCode, DWORD addData)
 the callback of all notification event More...
 

Enumerations

Functions

void mWidget_captureHotPiece (mWidget *self, mObject *hotpice)
 

Variables

MGNCS_EXPORT mWidgetClass g_stmWidgetCls
 the instance of mWigetClass More...
 

Detailed Description

Macro Definition Documentation

#define NCS_MAP_NOTIFY (   code,
  handler 
)    { NCS_NOTIFY_CODE(code), (void*)(handler) }

Map a notification event into a handler

Definition at line 764 of file mwidget.h.

#define NCS_NOTIFY_CODE (   code)    (0xFFFF0000 | (code))

Add a speical flags into a notification code, so that the NCS can distinguish notification events from message events

Definition at line 759 of file mwidget.h.

#define NCSCTRL_WIDGET   NCSCLASSNAME("widget")

the name of widget control

Definition at line 67 of file mwidget.h.

#define NCSR_CONTINUE_MSG   FALSE

return value, pass the message to the default window process

See also
NCSR_STOP_MSG

Definition at line 492 of file mwidget.h.

#define NCSR_STOP_MSG   TRUE

return value, return directly, don't pass the message to default window process

See also
NCSR_CONTINUE_MSG

Definition at line 500 of file mwidget.h.

Typedef Documentation

void(* NCS_CB_NOTIFY)(mWidget *, int id, int ncCode, DWORD param)

the callback of all notification event

Parameters
mWidget* the sender pointer
ncCodethe notification code of event
paramthe param of notify message

Definition at line 751 of file mwidget.h.

BOOL(* NCS_CB_ONCLOSE)(mWidget *)

the callback of event MSG_CLOSE

Parameters
mWidget*the sender pointer
Returns
NCSR_CONTINUE_MSG, NCSR_STOP_MSG

Definition at line 640 of file mwidget.h.

BOOL(* NCS_CB_ONCMD)(mWidget *, int id, int nc, HWND hCtrl)

the callback of event MSG_COMMAND

Parameters
mWidget*the sender pointer
idthe child(control or menuitem) id
ncthe notification code of child
hCtrlthe child's handle ( or 0 if child is a menuitem)
Returns
NCSR_CONTINUE_MSG, NCSR_STOP_MSG

Definition at line 719 of file mwidget.h.

BOOL(* NCS_CB_ONCREATE)(mWidget *, DWORD dwAddData)

the callback of event MSG_CREATE

Parameters
mWidget* the event sender's pointer
dwAddDatathe additional data when create this window, passed by ncscreatewindow, ncscreatewindowindirect, ncscreatemainwindow ncscreatemainwindowindirect
Returns
True - allow NCS create control continue; FALSE - abort the creating
See also
ncsCreateWindow, ncsCreateWindowIndirect, ncsCreateMainWindow, ncsCreateMainWindowIndirect

Definition at line 528 of file mwidget.h.

void(* NCS_CB_ONCSZCHGED)(mWidget *, int clientWidth, int clientHeight)

the callbace of event MSG_CSIZECHANGED

This is the last message when changing a widget bounds

Parameters
mWidget* sender pointer
clientWidththe new width of sender's client
clientHeightthe new height of sender's client

Definition at line 595 of file mwidget.h.

BOOL(* NCS_CB_ONERASEBKGND)(mWidget *, HDC hdc, const PRECT clip)

the callback of event MSG_ERASEBKGND

Parameters
mWidget* the sender pointer
hdcthe DC of background, hdc may be 0, so you shoud check it, and call GetClientDC or GetDC when hdc == 0
clipthe area should to be erased. clip may be equal NULL, so, call GetWindowRect, or GetClientRect when clip == NULL
Returns
NCSR_CONTINUE_MSG, NCSR_STOP_MSG

Definition at line 621 of file mwidget.h.

BOOL(* NCS_CB_ONFONTCHGING)(mWidget *, PLOGFONT logFont)

the callback of event MSG_FONTCHANGING

This event is called when SetWindowFont is called

Parameters
mWidget* then sender pointer
logFontthe logic font would be set to sender
Returns
TRUE - tell the SetWindowFont continue set the font, FALSE - abort SetWindowFont

Definition at line 608 of file mwidget.h.

int(* NCS_CB_ONHITTEST)(mWidget *, UINT message, int x, int y)

the callback of events MSG_HITTEST MSG_NCHITTEST

Parameters
mWidget* the sender pointer
messagethe event code
xthe x-coordinate of hit point
ythe y-coordinate of hit point
Returns
int hit code

Definition at line 696 of file mwidget.h.

BOOL(* NCS_CB_ONINITDLG)(mWidget *, HWND hFocus, DWORD dwAddData)

the callback of event MSG_INITDIALOG, only valid in mDialogBox, when a dialog is created

Parameters
mWidget* the sender pointer of event
hFocusthe focus window when dialog is created
dwAddDatathe additional data passed by ncscreatewindow, ncscreatewindowindirect, ncscreatemainwindow ncscreatemainwindowindirect
Returns
True - allow dialog continue; FALSE - abort the dialog
See also
ncsCreateWindow, ncsCreateWindowIndirect, ncsCreateMainWindow, ncsCreateMainWindowIndirect

Definition at line 543 of file mwidget.h.

BOOL(* NCS_CB_ONKEY)(mWidget *, UINT message, int code, DWORD keyStatus)

the callback of event MSG_KEYDOWN MSG_KEYUP MSG_CHAR MSG_SYSKEYDOWN MSG_SYSKEYUP MSG_SYSCHAR

Parameters
mWidget* the sender pointer
messageevent code, distinguish the events
codethe scancode (MSG_KEYDOWN MSG_KEYUP MSG_SYSKEYDOWN MSG_SYSKEYUP) or ascii code (MSG_CHAR MSG_SYSCHAR)
keyStatusThe shift key status when this message occurred
Returns
NCSR_CONTINUE_MSG, NCSR_STOP_MSG

Definition at line 655 of file mwidget.h.

BOOL(* NCS_CB_ONMOUSE)(mWidget *, UINT message, int x, int y, DWORD keyStatus)

the callback of events MSG_LBUTTONDOWN MSG_LBUTTONUP MSG_LBUTTONDBCLK MSG_MOUSEMOVE MSG_RBUTTONDOWN MSG_RBUTTONUP MSG_RBUTTONDBCLK

Parameters
mWidget* sender pointer
messagethe event code
xthe x-coordinate of mouse
ythe y-coordinate of mouse
keyStatusThe shift key status when this message occurred.
Returns
NCSR_CONTINUE_MSG, NCSR_STOP_MSG

Definition at line 670 of file mwidget.h.

int(* NCS_CB_ONMSG)(mWidget *, UINT message, WPARAM wParam, LPARAM lParam)

the callback of a common message event

Parameters
mWidget* sender pointer
messagethe event code
wParamthe wParam of message event
lParamthe lParam of message event
Returns
int - this value will be as the finally return value of event, and none default processing would be called

Definition at line 741 of file mwidget.h.

typedef void(* NCS_CB_ONNCCREATE)(mWidget *)

the Callback of Event MSG_NCCREATE, which is the first message of a control

Parameters
mWidget*the event sender's pointer
Returns
none

Definition at line 512 of file mwidget.h.

BOOL(* NCS_CB_ONNCMOUSE)(mWidget *, UINT message, int x, int y, int hitCode)

the callback of events MSG_NCLBUTTONDOWN MSG_NCLBUTTONUP MSG_NCLBUTTONDBCLK MSG_NCMOUSEMOVE MSG_NCRBUTTONDOWN MSG_NCRBUTTONUP MSG_NCRBUTTONDBCLK

Parameters
mWidget* the sender pointer
messagethe event code
xthe x-coordinate of mouse
ythe y-coordinate of mouse
hitCodethe hit code
Returns
NCSR_CONTINUE_MSG, NCSR_STOP_MSG

Definition at line 684 of file mwidget.h.

void(* NCS_CB_ONPAINT)(mWidget *, HDC hdc, const PCLIPRGN clip_rgn)

the callback of event MSG_PAINT

Parameters
mWidget* sender pointer
hdcthe DC for painting
clip_rgninvlidate region

Definition at line 631 of file mwidget.h.

void(* NCS_CB_ONSCROLL)(mWidget *, UINT message, int code, int pos)

the callback of events MSG_HSCROLL , MSG_VSCROLL

Parameters
mWidget* the sender pointer
messagethe event code
ncthe scrolling code, see MSG_HSCROLL and MSG_VSCROOL in MiniGUI

Definition at line 707 of file mwidget.h.

BOOL(* NCS_CB_ONSZCHGED)(mWidget *, PRECT prcClient)

the callback of event MSG_SIZECHANGED

This callback is called after a widget's bound changed if you want change the client size of the sender, reset the prcClient

Parameters
mWidget* the sender pointer
prcClientIN & OUT param, the client bound of the sender
Returns
TRUE - the prcClient is changed, FALSE - prcClient is not changed

Definition at line 582 of file mwidget.h.

void(* NCS_CB_ONSZCHGING)(mWidget *, const PRECT prcExpect, PRECT prcResult)

the callback of event MSG_SIZECHANGING, when a widget's bound is changing. If you want change the widget bounds, set the prcResult, by default, copy prcExpect to prcResult

Parameters
mWidget* the sender pointer
prcExpectthe excepted bound, IN param
prcResultthe resulted bound, OUT param,

Definition at line 567 of file mwidget.h.

BOOL(* NCS_CB_ONVOID)(mWidget *, UINT message)

the callback of events MSG_ACTIVE MSG_FONTCHANGED MSG_KEYLONGPRESS MSG_KEYALWAYSPRESS MSG_DESTROY

Parameters
mWidget* the pointer of sender
messagethe event code, indicate the event
Returns
NCSR_CONTINUE_MSG, NCSR_STOP_MSG except MSG_DESTROY, the return value woulbe be ignored

Definition at line 555 of file mwidget.h.

void(* NCS_CB_WIDGET_ONTIMER)(mWidget *, int id, DWORD count)

the callback of event MSG_TIMER

Parameters
mWidget*the sender pointer
idthe id of timer
countthe total tick count of timer

Definition at line 728 of file mwidget.h.

See also
_NCS_WND_TEMPLATE

Definition at line 76 of file mwidget.h.

Enumeration Type Documentation

the notification code of mWidget

Enumerator
NCSN_WIDGET_CLICKED 

send by a widget is cliced by left button

NCSN_WIDGET_DBCLICKED 

send by a widget is double cliced by left button

NCSN_WIDGET_ENABLED 

send by a widget is enabled

NCSN_WIDGET_DISABLED 

send by a widget is disabled

Definition at line 456 of file mwidget.h.

the properties id of mWidget

Enumerator
NCSP_WIDGET_RDR 

Set the renderer class name.

  • Type : const char*
  • WriteOnly
  • Repaint all the control
NCSP_WIDGET_TEXT 

Set the widget 's text, same as SetWindowText.

  • Type : const char*
  • WritedOnly
  • Repaint the text of widget
NCSP_WIDGET_BKIMAGE 

Set the widget's back image.

  • Type : PBITMAP
  • ReadWirte
  • Repaint the background when set it
NCSP_WIDGET_BKIMAGE_MODE 

Set the widget's back image mode.

  • Type : int
    • NCS_DM_NORMAL
    • NCS_DM_SCALED
    • DrawMode_Title
  • ReadWrite
  • Repaint the background when set it
NCSP_WIDGET_BKIMAGE_FILE 

Set the widget's back image from file.

  • Type : const char*, file name of image
  • WriteOnly
  • Repaint the background when set it
Note
widget will load a PBITMAP from the file, and release it automatically

Definition at line 384 of file mwidget.h.

the arrow define of renderer

Enumerator
NCSR_ARROW_LEFT 

indiate a left arrow

NCSR_ARROW_RIGHT 

indiate a right arrow

NCSR_ARROW_UP 

indiate a up arrow

NCSR_ARROW_DOWN 

indiate a down arrow

Definition at line 166 of file mwidget.h.

the flag defines of renderer

Enumerator
NCSRF_INNERFRAME 

indicate that draw a inner frame box or shape

NCSRF_FILL 

indicate that fill a box or other shape

NCSRF_FRAME 

indicate that draw a box or other shape with a frame

Definition at line 144 of file mwidget.h.

define the renderer state of widget

Enumerator
NCSRS_NORMAL 

normal state

NCSRS_HIGHLIGHT 

higlight state

NCSRS_SIGNIFICANT 

significant state

NCSRS_SELECTED 

a box or item is selected

NCSRS_HALFSELECTED 

half selected state

NCSRS_DISABLE 

disable state

Definition at line 104 of file mwidget.h.

Function Documentation

void mWidget_captureHotPiece ( mWidget self,
mObject hotpice 
)

public static function

Variable Documentation

g_stmWidgetCls

the instance of mWigetClass

See also
mWidgetClass