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