Other Class
This chapter introduces some mGNCS non control classes. They are designed to provide for the control class to use.
mReferencedObj
mReferencedObjThe class encapsulate an automatic counting, allowing to control the life circle of the object through automatic quoting when the object is transferred.
The class is mainly used on some non control classes, such as the class of mToolItem and mPropMenuMgr etc.
Inheritance relation
mObjectmRefrencedObj
Direct child classes
mPropMenuMgrmToolItemmToolImage
Method of mReferencedObj
mReferencedObjQuote related ports, and there are two:
int addRef(mReferencedObj* self);
int release(mReferencedObj* self);addRef automatically adds 1 to the counting, and returns new counting. release will automatically reduce 1 for the counting, and returns new counting; if the counting is 0, automatically call destroy method, delete the object, including memory of the object. mReferenceObj and its derived class need to call NEW or NEWEX macro to create, because release method will call DELETE macro to release the created object. The derived class can change the release mode of the object through covering release method.
Example of mReferencedObj
mReferencedObjThe class is an abstract class, and cannot be used directly.
mPopMenuMgr
mPopMenuMgrmPopMenuMgr stores the information of PropMenu, and it can:
Create a
PopMenuat any time for usePartial
MenuIteminformation can be obtained to fill intoMENUITEMINFOstructure, and provide for the related functions of MiniGUI to useInheritance relation
mObjectmReferencedObjmPopMenuMgr
Method of mPopMenuMgr
mPopMenuMgrMethod of adding a
MenuItemtomPopMenuMgr
BOOL addItem(mPropMenuMgr *self , \
int type, \
const char * str, \
PBITMAP bmp, \
int id, \
int state, \
mPopMenuMgr *subMenu, \
DWORD add_data);Parameter
type – menu item type, same as the definition of MiniGUI
MENUITEMINFOMTF_STRINGMTF_BITMAPMTF_BMPSTRINGMTF_RADIOCHECKMTF_MARKCHECKMTF_SEPARATOR
caption of str – Item, valid when type ==
MTF_STRINGorMTF_BMPSTRINGBit map of bmp – item, valid when type ==
MTF_BITMAPorMTF_BMPSTRINGid of id – item, it is a must to mark an id
state – item status, same as the definition of MiniGUI
MENUITEMINFOMFS_GRAYEDMFS_DISABLEDMFS_CHECKEDMFS_ENABLEDMFS_UNCHECKED
subMenu- sub menu manageradd_data– additional data of the user
return:
TRUEorFALSECreate a
PopMenu, return the sentence handle of the Menu
HMENU createMenu(mPopMenuMgr *self);Automatically create and pop up a Pop Menu
void popMenu(mPopMenuMgr *self, mObject *owner);params:
owner points out
PopMenurelated object, which must be amWidgetor its child class, PopMenu will sendMSG_COMMANDto owner
return : None
Add a segmentation bar to
MenuItem
BOOL addSeparator(mPopMenuMgr * self);Get information of appointed
MenuItem
BOOL getMenuItem(mPopMenuMgr * self, int idx, MENUITEMINFO *pmii, BOOL byCommand);Fill information of appointed
MenuItemtoMENUITEMINFOparams:
idx - index or id of menuitem
pmii – output parameter
byCommand:TRUE– idx is id of menu item;FALSE– idx is index of menu item
return :
TRUE/FALSE
Example of mPopMenuMgr
mPopMenuMgrRefer to the example of mMenuButton
mToolImage
mToolImagemToolImage is the class providing images to mToolItem. The class encapsulates all types of images for the convenience of the users to select
Inheritance relation
mObjectmReferencedObjmToolImage
Method of mToolImage
mToolImageThe method of mToolImage is open, and the functions provided below can be called directly.
Create new
mToolImageobject from an image object
mToolImage * ncsNewToolImage(PBITMAP pbmp, int cell_count, BOOL autoUnload, BOOL bVert);params
pbmp : source of image
cell_count:number of small images that pbmp containsautoUnload: automatically callUnloadBitmapto delete the imagebVert: if arrangement of small images is vertical
return :
mToolImagepointerCreate
mToolImageobject from an image file
mToolImage * ncsNewToolImageFromFile(const char *fileName, \
int cell_count, \
BOOL autoUnload, \
BOOL bVert);Release a
mToolImageobject
void ncsFreeToolImage(mToolImage *mti);Draw image of appointed position managed by
mToolImage
BOOL ncsDrawToolImageCell(mToolImage *mti, HDC hdc, int idx, const RECT *prc);params:
mti :
mToolImagepointerhdc : objective
DCsentence handleidx : small image index
prc: objective rectangle
return
TRUEorFALSE
For the users, mainly creating and deleting related functions are used, and draw function is used by ToolItem
Example of mToolImage
mToolImagemToolItem
mToolItemmToolItem is the basic class of item of mToolbar. The class and its derived class are not public. Users only need to automatically create through API provided externally.
mToolbar also delete the ones automatically managing mToolItem
Type of mToolItem
mToolItemmToolItem has many child classes. In external interface, it is manifested as all kinds of types, and these definitions are as below:
enum mToolItemType{
NCS_UNKNOWNTOOLITEM = 0,
NCS_PUSHTOOLITEM,
NCS_MENUTOOLITEM,
NCS_WIDGETTOOLITEM,
NCS_SEPARATORTOOLITEM
};Type of a ToolItem can be detected through the function below
int ncsGetToolItemType(void *toolitem);Get the type of
ToolItem
The function below can rapidly detect the type of an item
BOOL ncsIsPushToolItem(void *toolitem);
BOOL ncsIsMenuToolItem(void *toolitem);
BOOL ncsIsSeparatorToolItem(void *toolitem);
BOOL ncsIsWidgetToolItem(void *toolitem);Creation and Deletion of mToolItem
mToolItemCreate a
PushToolItem
void * ncsCreatePushToolItem(int id, mToolImage * img, const char * str, UINT flags);params:
img:
mToolImagepointer, can beNULLstr: literal pointer, can be
NULL, but eitherimgorstrmust not beNULLflags: define the relation between
imgandstrNCS_TOOLITEM_FLAG_TEXT_LEFT/NCS_TOOLITEM_FLAG_TEXT_UP, the text is on the left or top, default is right or bottomNCS_TOOLITEM_FLAG_VERT, image and str are vertically arranged, and it is horizontal arrangement by default
return: item pointer
Create a Menu Tool Item
void * ncsCreateMenuToolItem(int id, \
mToolImage * img, \
const char * str, \
UINT flags, \
mPopMenuMgr * menu);Create a
MenuToolItem, parameter menu is amPopMenuMgr, and other parameters are as aboveCreate a Check Tool Item
void * ncsCreateCheckToolItem(int id, \
mToolImage * img, \
const char * str, \
UINT flags, \
int state);Parameter is same as
ncsCreatePushToolItem.Create a radio Tool Item
void * ncsCreateRadioToolItem(int id, mToolImage * img, const char * str, UINT flags);Parameter is same as
ncsCreatePushToolItem.RadioToolItemis automatically grouped, starting from the first or previous separator and ending to the final or next separator, direct allRadioToolItemare mutually excluding.Create a
ToolItemcontainingmWidgetpointer
void * ncsCreateWidgetToolItem(mWidget * widget);params
widget :
mWidgetobject pointer
return : item pointer
Create a separator
void * ncsCreateSeparatorItem(void);return item pointer
Other mToolItem Functions
mToolItem FunctionsmToolItem provides some other functions, used to operate ToolItem
Get or set ID of
ToolItem
int ncsToolItem_getId(void *self)
int ncsToolItem_setId(void *self, int id);If it cannot set or cannot get, return -1.
Get or set Check status of
CheckToolItem:
BOOL ncsToolItem_setCheck(void *self, int check_state);
int ncsToolItem_getCheck(void *self);Only valid aiming at Check/RadioToolItem. When calling
ncsToolItem_getCheckfor otherToolItem, unchecked status will be returned foreverPop up menu for
MenuToolItem
BOOL ncsToolItem_showMenu(void*self, mObject *owner);Only aim at menu Tool item, owner is a
mWidgt*object
Example of mToolItem
mToolItem<< Invisible Control Class | Table of Contents | Graphics Device Interfaces >>
Last updated