mGNCS API Reference  v1.5.0
A new control set and a new framework for MiniGUI apps
mtoolitem.h
Go to the documentation of this file.
1 //
3 // IMPORTANT NOTICE
4 //
5 // The following open source license statement does not apply to any
6 // entity in the Exception List published by FMSoft.
7 //
8 // For more information, please visit:
9 //
10 // https://www.fmsoft.cn/exception-list
11 //
13 
54 #ifndef _MG_MINIMTOOLITEM_H_
55 #define _MG_MINIMTOOLITEM_H_
56 
57 #ifdef __cplusplus
58 extern "C"{
59 #endif
60 
72  NCS_UNKNOWNTOOLITEM = 0,
73  NCS_PUSHTOOLITEM,
74  NCS_MENUTOOLITEM,
75  NCS_WIDGETTOOLITEM,
76  NCS_SEPARATORTOOLITEM
77 };
78 
79 typedef struct _mToolImage{
80  PBITMAP pbmp;
81  unsigned char flags;
82  unsigned char cell_count;
83  unsigned short ref;
84 }mToolImage;
85 
86 #define TOOLIMGF_UNLOAD 0x01
87 #define TOOLIMGF_VERTCELL 0x02 //the image of cell a vert arranged
88 
99 MGNCS_EXPORT mToolImage * ncsNewToolImage(PBITMAP pbmp, int cell_count, BOOL autoUnload, BOOL bVert);
110 MGNCS_EXPORT mToolImage * ncsNewToolImageFromFile(const char *fileName, int cell_count, BOOL autoUnload, BOOL bVert);
116 MGNCS_EXPORT void ncsFreeToolImage(mToolImage *mti);
117 //BOOL ncsGetToolImageCell(mToolImage *mti, int idx, RECT *prc);
127 MGNCS_EXPORT BOOL ncsDrawToolImageCell(mToolImage *mti, HDC hdc, int idx, const RECT *prc);
128 
150 };
151 
156 #define NCS_TOOLITEM_FLAG_TEXT_LEFT 0x01
157 
162 #define NCS_TOOLITEM_FLAG_TEXT_UP NCS_TOOLITEM_FLAG_TEXT_LEFT
163 
167 #define NCS_TOOLITEM_FLAG_VERT 0x02
168 
169 #define NCS_TOOLITEM_LABEL_TEXT_LEFT 0x10
170 #define NCS_TOOLITEM_LABEL_TEXT_RIGHT 0x20
171 #define NCS_TOOLITEM_LABEL_TEXT_CENTER 0x40
172 
173 #define NCS_TOOLITEM_LABEL_TEXT_TOP 0x80
174 #define NCS_TOOLITEM_LABEL_TEXT_BOTTOM 0x100
175 #define NCS_TOOLITEM_LABEL_TEXT_VCENTER 0x200
176 
189 MGNCS_EXPORT void* ncsCreatePushToolItem(int id, mToolImage *img, const char* str, UINT flags);
190 
191 
196 MGNCS_EXPORT BOOL ncsInitToolItems(void);
197 
213 MGNCS_EXPORT void* ncsCreateMenuToolItem(int id, mToolImage *img, const char* str, UINT flags, mPopMenuMgr *menu);
214 
219 #define NCS_TOOLITEM_UNCHECKED 0x00
220 
224 #define NCS_TOOLITEM_CHECKED 0x01
225 
241 MGNCS_EXPORT void* ncsCreateCheckToolItem(int id, mToolImage *img, const char* str, UINT flags, int state);
257 MGNCS_EXPORT void* ncsCreateRadioToolItem(int id, mToolImage *img, const char* str, UINT flags);
258 
267 MGNCS_EXPORT void* ncsCreateWidgetToolItem(mWidget* widget);
268 
275 MGNCS_EXPORT void* ncsCreateSeparatorItem(void);
276 
286 MGNCS_EXPORT int ncsGetToolItemType(void *toolitem);
287 
295 MGNCS_EXPORT BOOL ncsIsPushToolItem(void *toolitem);
303 MGNCS_EXPORT BOOL ncsIsMenuToolItem(void *toolitem);
311 MGNCS_EXPORT BOOL ncsIsSeparatorToolItem(void *toolitem);
319 MGNCS_EXPORT BOOL ncsIsWidgetToolItem(void *toolitem);
320 
322 
329 MGNCS_EXPORT int ncsToolItem_getId(void *self);
338 MGNCS_EXPORT int ncsToolItem_setId(void *self, int id);
347 MGNCS_EXPORT BOOL ncsToolItem_setCheck(void *self, int check_state);
355 MGNCS_EXPORT int ncsToolItem_getCheck(void *self);
356 
366 MGNCS_EXPORT BOOL ncsToolItem_showMenu(void*self, mObject *owner);
367 
368 
380 MGNCS_EXPORT mObject* ncsNewToolItem(int id, mObjectClass* _class, DWORD param);
381 
382 #define NEWTOOLITEM(id, Object, param) \
383  (Object*)(ncsNewToolItem((id), (mObjectClass*)&Class(Object), (DWORD)(param)))
384 
394 MGNCS_EXPORT void ncsFreeToolItem(mObject* obj);
395 
396 #define FREETOOLITEM(obj) \
397  ncsFreeToolItem((mObject*)(obj))
398 
401 #ifdef __cplusplus
402  }
403 #endif
404 
405 #endif /* _MG_MINIMTOOLITEM_H_ */
mObject
the Object struct
ncsInitToolItems
MGNCS_EXPORT BOOL ncsInitToolItems(void)
initialize tool items
ncsIsSeparatorToolItem
MGNCS_EXPORT BOOL ncsIsSeparatorToolItem(void *toolitem)
check the toolitem is separator tool item or not
ncsToolItem_setCheck
MGNCS_EXPORT BOOL ncsToolItem_setCheck(void *self, int check_state)
set the check state of toolitem
ncsIsPushToolItem
MGNCS_EXPORT BOOL ncsIsPushToolItem(void *toolitem)
check the toolitem is push item or not
ncsNewToolImageFromFile
MGNCS_EXPORT mToolImage * ncsNewToolImageFromFile(const char *fileName, int cell_count, BOOL autoUnload, BOOL bVert)
create a tool image from file,
ncsCreateSeparatorItem
MGNCS_EXPORT void * ncsCreateSeparatorItem(void)
create separator item
ncsToolItem_setId
MGNCS_EXPORT int ncsToolItem_setId(void *self, int id)
get the id of toolitem
ncsNewToolItem
MGNCS_EXPORT mObject * ncsNewToolItem(int id, mObjectClass *_class, DWORD param)
new a tool item object
mToolItemType
mToolItemType
define the type of toolitem
Definition: mtoolitem.h:71
ncsDrawToolImageCell
MGNCS_EXPORT BOOL ncsDrawToolImageCell(mToolImage *mti, HDC hdc, int idx, const RECT *prc)
draw a sub image from toolimage to hdc
mToolItemEvent
mToolItemEvent
define the event code of tool item
Definition: mtoolitem.h:133
ncsToolItem_showMenu
MGNCS_EXPORT BOOL ncsToolItem_showMenu(void *self, mObject *owner)
show the menu of MenuToolItem
mObjectClass
the basic object class of NCS
ncsToolItem_getId
MGNCS_EXPORT int ncsToolItem_getId(void *self)
get the id of toolitem
ncsFreeToolImage
MGNCS_EXPORT void ncsFreeToolImage(mToolImage *mti)
free the toolimage
ncsFreeToolItem
MGNCS_EXPORT void ncsFreeToolItem(mObject *obj)
free the tool item object
mWidget
define the mWidget members, inherit from mComponent
NCSN_TOOLITEM_SHOWMENU
@ NCSN_TOOLITEM_SHOWMENU
Definition: mtoolitem.h:145
ncsIsWidgetToolItem
MGNCS_EXPORT BOOL ncsIsWidgetToolItem(void *toolitem)
check the toolitem is widget tool item or not
mPopMenuMgr
the members of mPropMenuMgr
NCSN_TOOLITEM_CLICKED
@ NCSN_TOOLITEM_CLICKED
Definition: mtoolitem.h:137
ncsToolItem_getCheck
MGNCS_EXPORT int ncsToolItem_getCheck(void *self)
get the check state of toolitem
ncsGetToolItemType
MGNCS_EXPORT int ncsGetToolItemType(void *toolitem)
get the type of item
NCSN_TOOLITEM_PUSHED
@ NCSN_TOOLITEM_PUSHED
Definition: mtoolitem.h:141
ncsCreateWidgetToolItem
MGNCS_EXPORT void * ncsCreateWidgetToolItem(mWidget *widget)
create a toolitem which include a mWidget object
NCSN_TOOLITEM_STATE_CHANGED
@ NCSN_TOOLITEM_STATE_CHANGED
Definition: mtoolitem.h:149
ncsNewToolImage
MGNCS_EXPORT mToolImage * ncsNewToolImage(PBITMAP pbmp, int cell_count, BOOL autoUnload, BOOL bVert)
create a tool image for tool item
ncsIsMenuToolItem
MGNCS_EXPORT BOOL ncsIsMenuToolItem(void *toolitem)
check the toolitem is menu tool item or not