Other Class
This chapter introduces some mGNCS non control classes. They are designed to provide for the control class to use.
mReferencedObj
mReferencedObj
The 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
mObject
mRefrencedObj
Direct child classes
mPropMenuMgr
mToolItem
mToolImage
Method of mReferencedObj
mReferencedObj
Quote 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
mReferencedObj
The class is an abstract class, and cannot be used directly.
mPopMenuMgr
mPopMenuMgr
mPopMenuMgr
stores the information of PropMenu
, and it can:
Create a
PopMenu
at any time for usePartial
MenuItem
information can be obtained to fill intoMENUITEMINFO
structure, and provide for the related functions of MiniGUI to useInheritance relation
mObject
mReferencedObj
mPopMenuMgr
Method of mPopMenuMgr
mPopMenuMgr
Method of adding a
MenuItem
tomPopMenuMgr
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
MENUITEMINFO
MTF_STRING
MTF_BITMAP
MTF_BMPSTRING
MTF_RADIOCHECK
MTF_MARKCHECK
MTF_SEPARATOR
caption of str – Item, valid when type ==
MTF_STRING
orMTF_BMPSTRING
Bit map of bmp – item, valid when type ==
MTF_BITMAP
orMTF_BMPSTRING
id of id – item, it is a must to mark an id
state – item status, same as the definition of MiniGUI
MENUITEMINFO
MFS_GRAYED
MFS_DISABLED
MFS_CHECKED
MFS_ENABLED
MFS_UNCHECKED
subMenu
- sub menu manageradd_data
– additional data of the user
return:
TRUE
orFALSE
Create 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
PopMenu
related object, which must be amWidget
or its child class, PopMenu will sendMSG_COMMAND
to 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
MenuItem
toMENUITEMINFO
params:
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
mPopMenuMgr
Refer to the example of mMenuButton
mToolImage
mToolImage
mToolImage
is the class providing images to mToolItem
. The class encapsulates all types of images for the convenience of the users to select
Inheritance relation
mObject
mReferencedObj
mToolImage
Method of mToolImage
mToolImage
The method of mToolImage
is open, and the functions provided below can be called directly.
Create new
mToolImage
object 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 callUnloadBitmap
to delete the imagebVert
: if arrangement of small images is vertical
return :
mToolImage
pointerCreate
mToolImage
object from an image file
mToolImage * ncsNewToolImageFromFile(const char *fileName, \
int cell_count, \
BOOL autoUnload, \
BOOL bVert);
Release a
mToolImage
object
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 :
mToolImage
pointerhdc : objective
DC
sentence handleidx : small image index
prc: objective rectangle
return
TRUE
orFALSE
For the users, mainly creating and deleting related functions are used, and draw function is used by ToolItem
Example of mToolImage
mToolImage
mToolItem
mToolItem
mToolItem
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
mToolItem
mToolItem
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
mToolItem
Create a
PushToolItem
void * ncsCreatePushToolItem(int id, mToolImage * img, const char * str, UINT flags);
params:
img:
mToolImage
pointer, can beNULL
str: literal pointer, can be
NULL
, but eitherimg
orstr
must not beNULL
flags: define the relation between
img
andstr
NCS_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
.RadioToolItem
is automatically grouped, starting from the first or previous separator and ending to the final or next separator, direct allRadioToolItem
are mutually excluding.Create a
ToolItem
containingmWidget
pointer
void * ncsCreateWidgetToolItem(mWidget * widget);
params
widget :
mWidget
object 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_getCheck
for 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