mGNCS API Reference  v1.2.0
A new control set and a new framework for MiniGUI apps
Macros | Typedefs | Functions
Global Object Functions

Macros

#define TYPENAME(obj)   ((obj)?(((obj)->_class)?((obj)->_class)->typeName:""):"")
 Get the class name form a Object pointer. More...
 
#define INSTANCEOF(obj, clss)   ncsInstanceOf((mObject*)(obj), (mObjectClass*)(void*)(&Class(clss)))
 A wrapper of ncsInstanceOf, just like java's instanceof. More...
 
#define CHECKOBJ(obj)   ncsIsValidObj((mObject*)obj)
 the wrapper of ncsIsValidObj More...
 
#define TYPE_CAST(Type, obj)   ((Type*)(obj))
 unsafe cast. donot check the type of class More...
 
#define SAFE_CAST(Type, obj)   TYPE_CAST(Type, ncsSafeCast((mObject*)obj,(mObjectClass*)(void*)(&(Class(Type)))))
 wrapper of ncsSafeCast, check the class type before cast. More...
 
#define SAFE_CAST_CLASS(Clss, ClssCast)   ((ClassType(ClssCast)*)(ncsSafeCastClass((mObjectClass*)Clss, (mObjectClass*)(void*)(&Class(ClssCast)))))
 the wrapper of ncsSafeCastClass More...
 

Typedefs

typedef BOOL(* NCS_CB_ONOBJEVENT) (mObject *self, mObject *sender, int eventId, DWORD param)
 The Callback of connection. More...
 

Functions

MGNCS_EXPORT mObjectnewObject (mObjectClass *_class)
 new a object instance, like new operator in C++ More...
 
MGNCS_EXPORT void deleteObject (mObject *obj)
 delete a object intance, like delete operator in C++ More...
 
MGNCS_EXPORT BOOL ncsInstanceOf (mObject *object, mObjectClass *clss)
 check an object is the class instance or not, same as instanceof operator in Java More...
 
static mObjectncsIsValidObj (mObject *obj)
 Check a pointer is a valid mObject or not. More...
 
MGNCS_EXPORT mObjectncsSafeCast (mObject *obj, mObjectClass *clss)
 safe type cast function, like the dynamic_cast operator in C++ More...
 
MGNCS_EXPORT mObjectClassncsSafeCastClass (mObjectClass *clss, mObjectClass *castCls)
 cast from a supper class to derived class type safely More...
 
MGNCS_EXPORT BOOL ncsAddEventListener (mObject *sender, mObject *listener, NCS_CB_ONOBJEVENT eventProc, int eventId)
 connect sender object to listener object More...
 
MGNCS_EXPORT BOOL ncsAddEventListeners (mObject *sender, mObject *listener, NCS_CB_ONOBJEVENT eventProc, int *eventIds)
 connect a group of events from sender to listener More...
 
MGNCS_EXPORT BOOL ncsRemoveEventListener (mObject *listener)
 remove the connections which are listened by the object More...
 
MGNCS_EXPORT BOOL ncsRemoveEventConnect (mObject *listener, mObject *source, int eventId)
 remove a special event connect More...
 
MGNCS_EXPORT BOOL ncsRemoveEventSource (mObject *sender)
 remove the connections when a sender is destroied More...
 
MGNCS_EXPORT void ncsRaiseEvent (mObject *sender, int eventId, DWORD param)
 raise an event to listeners More...
 

Detailed Description

Macro Definition Documentation

#define CHECKOBJ (   obj)    ncsIsValidObj((mObject*)obj)

the wrapper of ncsIsValidObj

See also
ncsIsValidObj

Definition at line 436 of file mobject.h.

#define INSTANCEOF (   obj,
  clss 
)    ncsInstanceOf((mObject*)(obj), (mObjectClass*)(void*)(&Class(clss)))

A wrapper of ncsInstanceOf, just like java's instanceof.

Example: Test a object is mComponentClass: INSTANCEOF(obj, mComponent)

Definition at line 416 of file mobject.h.

Referenced by ncsIsValidObj().

#define SAFE_CAST (   Type,
  obj 
)    TYPE_CAST(Type, ncsSafeCast((mObject*)obj,(mObjectClass*)(void*)(&(Class(Type)))))

wrapper of ncsSafeCast, check the class type before cast.

Note
this macro is same as dynamic_cast in C++
See also
ncsSafeCast

Definition at line 464 of file mobject.h.

#define SAFE_CAST_CLASS (   Clss,
  ClssCast 
)    ((ClassType(ClssCast)*)(ncsSafeCastClass((mObjectClass*)Clss, (mObjectClass*)(void*)(&Class(ClssCast)))))

the wrapper of ncsSafeCastClass

Definition at line 482 of file mobject.h.

#define TYPE_CAST (   Type,
  obj 
)    ((Type*)(obj))

unsafe cast. donot check the type of class

Definition at line 455 of file mobject.h.

#define TYPENAME (   obj)    ((obj)?(((obj)->_class)?((obj)->_class)->typeName:""):"")

Get the class name form a Object pointer.

Definition at line 393 of file mobject.h.

Typedef Documentation

typedef BOOL(* NCS_CB_ONOBJEVENT)(mObject *self, mObject *sender, int eventId, DWORD param)

The Callback of connection.

Note
For widgets, only support notification
Parameters
selfThe listener pointer
senderThe sender of event
eventIdthe id of event
paramthe param of event
Returns
TRUE - continue dispatch the event; FALSE - stop the event.

Definition at line 499 of file mobject.h.

Function Documentation

void deleteObject ( mObject obj)

delete a object intance, like delete operator in C++

Parameters
obj- the object want to delete

Referenced by initObjectArgs().

BOOL ncsAddEventListener ( mObject sender,
mObject listener,
NCS_CB_ONOBJEVENT  eventProc,
int  eventId 
)

connect sender object to listener object

Parameters
senderThe sender of event
listenerThe listener of event
eventProcThe processing callback of event
eventIdThe id of event
Returns
TRUE - Sucessed, FALSE - Failed
See also
ncsAddEventListener, ncsAddEventListeners, NCS_CB_ONOBJEVENT
MGNCS_EXPORT BOOL ncsAddEventListeners ( mObject sender,
mObject listener,
NCS_CB_ONOBJEVENT  eventProc,
int *  eventIds 
)

connect a group of events from sender to listener

BOOL ncsAddEventListeners(mObject sender, \ mObject listener, \ NCS_CB_ONOBJEVENT eventProc, \ int* eventIds);

Parameters
senderThe sender of events
listenerThe listener of events
eventProcThe processing callback of events
eventIdsThe id array of events, end by 0
Returns
TRUE - Sucessed, FALSE - Failed
See also
ncsAddEventListener, ncsAddEventListeners, NCS_CB_ONOBJEVENT
BOOL ncsInstanceOf ( mObject object,
mObjectClass clss 
)

check an object is the class instance or not, same as instanceof operator in Java

Parameters
object- the pointer of object being to test
clss- the pointer of class for test
Returns
TRUE - object is instance of clss, FALSE - not
static inline mObject * ncsIsValidObj ( mObject obj)
inlinestatic

Check a pointer is a valid mObject or not.

Parameters
obj- the excpeted object pointer
Returns
mObject * the pointer of obj or other NULL if obj is an invalid mObject pointer

Definition at line 426 of file mobject.h.

References INSTANCEOF.

void ncsRaiseEvent ( mObject sender,
int  event_id,
DWORD  param 
)

raise an event to listeners

Note
it will call the callback of NCS_CB_ONOBJEVENT add by ncsAddEventListeners, or ncsAddEventListener
Parameters
senderevent sender
event_idthe id of event
paramthe event param
See also
NCS_CB_ONOBJEVENT, ncsAddEventListener, ncsAddEventListeners
BOOL ncsRemoveEventConnect ( mObject listener,
mObject source,
int  event 
)

remove a special event connect

Parameters
listenerthe listener object
sourcethe source object
eventthe special event want to remove
BOOL ncsRemoveEventListener ( mObject listener)

remove the connections which are listened by the object

Note
this function is called when a listener is destroied
Parameters
listenerthe object pointer of listener
Returns
TRUE - sucessed; FALSE - failed
BOOL ncsRemoveEventSource ( mObject sender)

remove the connections when a sender is destroied

Note
this function is called when a sender is destroied
Parameters
senderthe sender of events
Returns
TRUE - sucessed; FALSE - failed
mObject * ncsSafeCast ( mObject obj,
mObjectClass clss 
)

safe type cast function, like the dynamic_cast operator in C++

Parameters
obj- the mObject pointer being casted
clss- the target type to cast
Returns
mObject * - the object pointer if cast safe, NULL otherwise
See also
ncsInstanceOf
mObjectClass * ncsSafeCastClass ( mObjectClass clss,
mObjectClass castCls 
)

cast from a supper class to derived class type safely

Parameters
clss- the supper type class pointer
castCls- the derived class type pointer
Note
use SAFE_CAST_CLASS
Returns
mObjectClass * - the pointer of clss if cast safe, otherwise NULL
mObject * newObject ( mObjectClass _class)

new a object instance, like new operator in C++

Parameters
_class- the class of the object
Returns
the new pointer of object

Referenced by initObjectArgs().