mGNCS API Reference  v1.5.0
A new control set and a new framework for MiniGUI apps
mpairpiece.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_PAIRPIECE_H
45 #define _MGUI_NCSCTRL_PAIRPIECE_H
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 typedef struct _mPairPieceClass mPairPieceClass;
52 typedef struct _mPairPiece mPairPiece;
53 
54 #define mPairPieceClassHeader(clss, superCls) \
55  mLayoutPieceClassHeader(clss, superCls)
56 
57 struct _mPairPieceClass
58 {
59  mPairPieceClassHeader(mPairPiece, mLayoutPiece)
60 };
61 
62 MGNCS_EXPORT extern mPairPieceClass g_stmPairPieceCls;
63 
64 #define mPairPieceHeader(clss) \
65  mLayoutPieceHeader(clss) \
66  DWORD flags; \
67  mHotPiece *first; \
68  mHotPiece *second;
69 
70 struct _mPairPiece
71 {
72  mPairPieceHeader(mPairPiece)
73 };
74 
75 #define NCS_PAIRPIECE_DIRECTION_MASK 0x80000000
76 #define NCS_PAIRPIECE_FIRST_MASK 0x40000000
77 #define NCS_PAIRPIECE_SIZE_TYPE_MASK 0x30000000
78 #define NCS_PAIRPIECE_SIZE_MASK 0x00000FFF
79 #define NCS_PAIRPIECE_SPACE_MASK 0x0FF00000
80 #define NCS_PAIRPIECE_MARGIN_MASK 0x000FF000
81 
82 #define mPairPiece_setVert(self) ((self)->flags |= NCS_PAIRPIECE_DIRECTION_MASK)
83 #define mPairPiece_setHorz(self) ((self)->flags &= ~NCS_PAIRPIECE_DIRECTION_MASK)
84 #define mPairPiece_isVert(self) ((self)->flags & NCS_PAIRPIECE_DIRECTION_MASK)
85 
86 #define mPairPiece_setReverse(self) ((self)->flags |= NCS_PAIRPIECE_FIRST_MASK)
87 #define mPairPiece_cancelReverse(self) ((self)->flags &= ~NCS_PAIRPIECE_FIRST_MASK)
88 #define mPairPiece_reversed(self) ((self)->flags & NCS_PAIRPIECE_FIRST_MASK)
89 //#define mPairPiece_getFirst(self) (((self)->flags&NCS_PAIRPIECE_FIRST_MASK)?self->second:self->first)
90 #define mPairPiece_getFirst(self) ((self)->first)
91 //#define mPairPiece_getSecond(self) (((self)->flags&NCS_PAIRPIECE_FIRST_MASK)?self->first:self->second)
92 #define mPairPiece_getSecond(self) ((self)->second)
93 #define mPairPiece_setFirst(self, piece) do{ \
94  if(((self)->flags&NCS_PAIRPIECE_FIRST_MASK)) \
95  (self)->second=(piece); \
96  else \
97  (self)->first=(piece); \
98 }while(0)
99 
100 #define mPairPiece_setSecond(self, piece) do{ \
101  if(((self)->flags&NCS_PAIRPIECE_FIRST_MASK)) \
102  (self)->first=(piece); \
103  else \
104  (self)->second=(piece); \
105 }while(0)
106 
107 
108 
109 enum mPairPieceSizeType{
110  NCS_PAIRPIECE_ST_FIXED = NCS_LAYOUTPIECE_ST_FIXED,
111  NCS_PAIRPIECE_ST_PERCENT = NCS_LAYOUTPIECE_ST_PERCENT,
112  NCS_PAIRPIECE_ST_AUTO = NCS_LAYOUTPIECE_ST_AUTO
113 };
114 
115 #define SET_BIT_VALUE(dword, value, mask,offset) ((dword) = ((dword)& (~(mask))) | (((value)<<(offset))&mask))
116 #define GET_BIT_VALUE(dword, mask, offset) (((dword)&(mask))>>(offset))
117 
118 #define mPairPiece_setFirstSizeType(self, type) SET_BIT_VALUE(self->flags, type, NCS_PAIRPIECE_SIZE_TYPE_MASK,28)
119 #define mPairPiece_getFirstSizeType(self) GET_BIT_VALUE(self->flags, NCS_PAIRPIECE_SIZE_TYPE_MASK, 28)
120 #define mPairPiece_setFirstSize(self, size) (self->flags = (self->flags&(~NCS_PAIRPIECE_SIZE_MASK))|((size)&NCS_PAIRPIECE_SIZE_MASK))
121 #define mPairPiece_getFirstSize(self) (int)(self->flags&NCS_PAIRPIECE_SIZE_MASK)
122 
123 #define mPairPiece_setSpace(self, space) SET_BIT_VALUE(self->flags, space, NCS_PAIRPIECE_SPACE_MASK, 20)
124 #define mPairPiece_getSpace(self) (int)GET_BIT_VALUE(self->flags, NCS_PAIRPIECE_SPACE_MASK, 20)
125 
126 #define mPairPiece_setMargin(self, margin) SET_BIT_VALUE(self->flags, margin, NCS_PAIRPIECE_MARGIN_MASK, 12)
127 #define mPairPiece_getMargin(self) (int)GET_BIT_VALUE(self->flags, NCS_PAIRPIECE_MARGIN_MASK, 12)
128 
129 enum mPairPieceProps{
130  NCSP_PAIRPIECE_SECOND_AS_FIRST = PAIRPIECE_PROP_BEGIN,
131  NCSP_PAIRPIECE_FIRST_SIZE_TYPE,
132  NCSP_PAIRPIECE_FIRST_SIZE,
133  NCSP_PAIRPIECE_FIRST,
134  NCSP_PAIRPIECE_SECOND,
135  NCSP_PAIRPIECE_DIRECTION = PIECECOMM_PROP_DIRECTION,
136  NCSP_PAIRPIECE_SPACE = PIECECOMM_PROP_SPACE,
137  NCSP_PAIRPIECE_MARGIN = PIECECOMM_PROP_MARGIN
138 };
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif
145