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