mGNCS API Reference  v1.5.0
A new control set and a new framework for MiniGUI apps
mabstractbuttonpiece.h
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 /*
14  * This file is part of mGNCS, a component for MiniGUI.
15  *
16  * Copyright (C) 2008~2018, Beijing FMSoft Technologies Co., Ltd.
17  *
18  * This program is free software: you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation, either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program. If not, see <http://www.gnu.org/licenses/>.
30  *
31  * Or,
32  *
33  * As this program is a library, any link to this program must follow
34  * GNU General Public License version 3 (GPLv3). If you cannot accept
35  * GPLv3, you need to be licensed from FMSoft.
36  *
37  * If you have got a commercial license of this program, please use it
38  * under the terms and conditions of the commercial license.
39  *
40  * For more information about the commercial license, please refer to
41  * <http://www.minigui.com/blog/minigui-licensing-policy/>.
42  */
43 
44 #ifndef _MGUI_NCSCTRL_ABSTRACTBUTTONPIECEPIECE_H
45 #define _MGUI_NCSCTRL_ABSTRACTBUTTONPIECEPIECE_H
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 typedef struct _mAbstractButtonPieceClass mAbstractButtonPieceClass;
52 typedef struct _mAbstractButtonPiece mAbstractButtonPiece;
53 
54 #define mAbstractButtonPieceClassHeader(clss, superCls) \
55  mContainerPieceClassHeader(clss, superCls)
56 
57 struct _mAbstractButtonPieceClass
58 {
59  mAbstractButtonPieceClassHeader(mAbstractButtonPiece, mContainerPiece)
60 };
61 
62 MGNCS_EXPORT extern mAbstractButtonPieceClass g_stmAbstractButtonPieceCls;
63 
64 #define mAbstractButtonPieceHeader(clss) \
65  mContainerPieceHeader(clss) \
66  unsigned char flags; \
67  unsigned char state; \
68  unsigned char check_state; \
69  unsigned char revert;
70 
71 struct _mAbstractButtonPiece
72 {
73  mAbstractButtonPieceHeader(mAbstractButtonPiece)
74 };
75 
76 enum mAbstractButtonPieceStates{
77  NCS_ABP_NORMAL = 0,
78  NCS_ABP_HILIGHT,
79  NCS_ABP_PUSHED,
80  NCS_ABP_CAPTURED,
81  NCS_ABP_DISABLED
82 };
83 
84 enum mAbstractButtonPieceCheckStates {
85  NCS_ABP_UNCHECKED = 0,
86  NCS_ABP_HALFCHECKED ,
87  NCS_ABP_CHECKED
88 };
89 
90 #define NCSS_ABP_CHECKABLE 0x01
91 #define NCSS_ABP_AUTOCHECK 0x02
92 #define NCSS_ABP_3DCHECK 0x04
93 #define NCSS_ABP_DISABLE 0x08
94 #define NCSS_ABP_FLAT 0x10 // show button's as flat
95 #define NCSS_ABP_NOREPEATMSG 0x20 // disbale the auto repeat message
96 
97 
98 #define mAbstractButtonPiece_isCheckable(self) \
99  IS_BIT_SET((self)->flags, NCSS_ABP_CHECKABLE)
100 #define mAbstractButtonPiece_setCheckable(self, bcheckable) \
101  ((bcheckable)?SET_BIT((self)->flags, NCSS_ABP_CHECKABLE):CLEAR_BIT((self)->flags, NCSS_ABP_CHECKABLE))
102 
103 #define mAbstractButtonPiece_isAutoCheck(self) \
104  IS_BIT_SET((self)->flags, NCSS_ABP_AUTOCHECK)
105 #define mAbstractButtonPiece_setAutoCheck(self, bautocheck) \
106  ((bautocheck)?SET_BIT((self)->flags, NCSS_ABP_AUTOCHECK):CLEAR_BIT((self)->flags, NCSS_ABP_AUTOCHECK))
107 
108 #define mAbstractButtonPiece_is3DCheck(self) \
109  IS_BIT_SET((self)->flags, NCSS_ABP_3DCHECK)
110 #define mAbstractButtonPiece_set3DCheck(self, b3dcheck) \
111  ((b3dcheck)?SET_BIT((self)->flags, NCSS_ABP_3DCHECK):CLEAR_BIT((self)->flags, NCSS_ABP_3DCHECK))
112 
113 #define mAbstractButtonPiece_needRepeatMsg(self) \
114  !(IS_BIT_SET((self)->flags, NCSS_ABP_NOREPEATMSG))
115 #define mAbstractButtonPiece_setNoRepeatMsg(self, norepeat) \
116  ((norepeat)?SET_BIT((self)->flags, NCSS_ABP_NOREPEATMSG):CLEAR_BIT((self)->flags, NCSS_ABP_NOREPEATMSG))
117 
118 #define mAbstractButtonPiece_isEnableFlag(self) \
119  (!IS_BIT_SET((self)->flags, NCSS_ABP_DISABLE))
120 
121 #define mAbstractButtonPiece_setEnable(self, benable) \
122  ((benable)?CLEAR_BIT((self)->flags,NCSS_ABP_DISABLE):SET_BIT((self)->flags, NCSS_ABP_DISABLE))
123 
124 enum mAbstractButtonPieceProps{
125  NCSP_ABP_CHECKABLE = ABP_PROP_BEGIN,
126  NCSP_ABP_AUTOCHECK,
127  NCSP_ABP_3DCHECK,
128  NCSP_ABP_CHECKSTATE,
129  NCSP_ABP_STATE,
130  NCSP_ABP_DISABLE,
131  NCSP_ABP_FLAT,
132  NCSP_ABP_NOREPEATMSG,
133 };
134 
135 enum mAbstractButtonPieceEvent {
136  NCSN_ABP_CLICKED = ABP_EVENT_BEGIN,
137  NCSN_ABP_STATE_CHANGED,
138  NCSN_ABP_PUSHED,
139  NCSN_ABP_DISABLED //param = 0, diabled, 1 enabled
140 };
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif
147