mGNCS API Reference  v1.5.0
A new control set and a new framework for MiniGUI apps
Macros | 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...
 

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 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

◆ CHECKOBJ

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

the wrapper of ncsIsValidObj

See also
ncsIsValidObj

Definition at line 448 of file mobject.h.

◆ INSTANCEOF

#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 428 of file mobject.h.

◆ SAFE_CAST

#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 476 of file mobject.h.

◆ SAFE_CAST_CLASS

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

the wrapper of ncsSafeCastClass

Definition at line 494 of file mobject.h.

◆ TYPE_CAST

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

unsafe cast. donot check the type of class

Definition at line 467 of file mobject.h.

◆ TYPENAME

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

Get the class name form a Object pointer.

Definition at line 405 of file mobject.h.

Function Documentation

◆ deleteObject()

void deleteObject ( mObject obj)

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

Parameters
obj- the object want to delete

◆ ncsAddEventListeners()

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

◆ ncsInstanceOf()

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

◆ ncsIsValidObj()

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 438 of file mobject.h.

References INSTANCEOF.

◆ ncsRaiseEvent()

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

◆ ncsRemoveEventConnect()

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

◆ ncsRemoveEventListener()

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

◆ ncsRemoveEventSource()

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

◆ ncsSafeCast()

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

◆ newObject()

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