mGNCS4Touch API Reference  v1.5.0
A set of mGNCS-compliant controls for devices with a touch screen.
mpanelpiece.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  * \file
15  * \author FMSoft
16  * \date
17  *
18  \verbatim
19 
20  This file is part of mGNCS4Touch, one of MiniGUI components.
21 
22  Copyright (C) 2008-2018 FMSoft (http://www.fmsoft.cn).
23 
24  This program is free software: you can redistribute it and/or modify
25  it under the terms of the GNU General Public License as published by
26  the Free Software Foundation, either version 3 of the License, or
27  (at your option) any later version.
28 
29  This program is distributed in the hope that it will be useful,
30  but WITHOUT ANY WARRANTY; without even the implied warranty of
31  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32  GNU General Public License for more details.
33 
34  You should have received a copy of the GNU General Public License
35  along with this program. If not, see <http://www.gnu.org/licenses/>.
36 
37  Or,
38 
39  As this program is a library, any link to this program must follow
40  GNU General Public License version 3 (GPLv3). If you cannot accept
41  GPLv3, you need to be licensed from FMSoft.
42 
43  If you have got a commercial license of this program, please use it
44  under the terms and conditions of the commercial license.
45 
46  For more information about the commercial license, please refer to
47  <http://www.minigui.com/blog/minigui-licensing-policy/>.
48 
49  \endverbatim
50 */
51 
52 #ifndef _MGNCS_PANELPIECE_H
53 #define _MGNCS_PANELPIECE_H
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif /* __cplusplus */
58 
59 #include <mgplus/mgplus.h>
60 #include <mgeff/mgeff.h>
61 
62 //delete object
63 #define HOTPIECE_RELEASE(self) \
64  if (self) { \
65  --(self->objRefCount); \
66  if (self->objRefCount <= 0) { \
67  DELPIECE((mHotPiece*)self); \
68  } \
69  }
70 
71 extern int s_totalObjRef;
72 extern int s_totalPieceRef;
73 
74 //#define DBG_REF
75 #ifdef DBG_REF
76 #define DBG_REFLOG(s, s1, s2, s3) fprintf(stderr, s, s1, __FUNCTION__, __LINE__, s2, s3);
77 #else
78 #define DBG_REFLOG(s, s1, s2, s3)
79 #endif
80 #define ADDREF(self) do { DBG_REFLOG("ADDREF %p, %s:%d objRefCount = %d, s_totalObjRef = %d.\n", self, self->objRefCount, ++s_totalObjRef); \
81  _c(self)->addRef(self);\
82  }while(0)
83 #define UNREF(self) do { if (NULL != self) {\
84  DBG_REFLOG("UNREF %p, %s:%d objRefCount = %d, s_totalObjRef = %d\n", self, self->objRefCount, --s_totalObjRef); \
85  self->objStatus |= NCSF_OBJECT_TODEL; \
86  _c(self)->release(self);\
87  }\
88  }while(0)
89 
90 #define ADDREFPIECE(self) do { DBG_REFLOG("ADDREFPIECE %p, %s:%d objRefCount = %d, s_totalPieceRef = %d.\n", self, self->objRefCount, ++s_totalPieceRef); \
91  _c(self)->addRef(self);\
92  }while(0)
93 #define UNREFPIECE(self) do { if (NULL != self) { \
94  DBG_REFLOG("UNREFPIECE %p, %s:%d objRefCount = %d, s_totalPieceRef = %d\n", self, self->objRefCount, --s_totalPieceRef); \
95  self->objStatus |= NCSF_OBJECT_TODEL; \
96  HOTPIECE_RELEASE(self);\
97  } \
98 }while(0);
99 
100 #define MSG_PANELPIECE_LOCKED (MSG_USER + 0x3042)
101 
102 typedef struct _POINTF
103 {
104  float xf;
105  float yf;
106 } POINTF;
107 
108 enum mPanelPieceProp
109 {
110  NCSP_PANEL_CLIPRECT = USER_PIECE_PROP_BEGIN + 200,
111 };
112 
113 
114 typedef struct _mPanelPiece mPanelPiece;
115 typedef struct _mPanelPieceClass mPanelPieceClass;
116 
117 #define mPanelPieceHeader(clss) \
118  mStaticPieceHeader(clss) \
119  BOOL isTopPanel; \
120  BOOL shouldResetPaintMode; \
121  mAbstractItemManager *itemManager; \
122  list_t eventHandlers; \
123  mShapeTransRoundPiece* bkgndPiece; \
124  mHotPiece* hovering_piece; \
125  mLayoutManager *layout; \
126  mWidget* owner; \
127  BOOL update_flag; \
128  MGEFF_ANIMATION update_anim; \
129  MGEFF_ANIMATION animgrp; \
130  DWORD addData; \
131  RECT clipRect; \
132  RECT invalidRect;
133 
134 struct _mPanelPiece
135 {
136  mPanelPieceHeader(mPanelPiece)
137 };
138 
139 typedef int (*NCS_PIECE_EVENT_HANDLER)(mHotPiece *, int message, WPARAM, LPARAM, mObject *owner);
140 
141 #define mPanelPieceClassHeader(clss, superCls) \
142  mStaticPieceClassHeader(clss, superCls) \
143  mPieceItem* (*addContent)(clss*, mHotPiece*, int, int); \
144  mPieceItem* (*addContentToLayout)(clss*, mHotPiece*); \
145  void (*enableChildCache)(clss*, mHotPiece*, BOOL); \
146  BOOL (*updateChildCache)(clss*, mHotPiece*); \
147  void (*addContentFinished)(clss*); \
148  BOOL (*delContent)(clss*, mHotPiece*); \
149  void (*clearContents)(clss*); \
150  void (*reLayout)(clss*); \
151  void (*setLayoutManager)(clss*, mLayoutManager *layout);\
152  void (*appendEventHandler)(clss *, int message, NCS_PIECE_EVENT_HANDLER); \
153  void (*delEventHandler)(clss *, int); \
154  void (*clearEventHandler)(clss *); \
155  mPieceItem* (*searchItem)(clss*, mHotPiece*); \
156  void (*setClipRect)(clss *, mPieceItem*); \
157  mHotPiece *(*childAt)(clss *, int, int); \
158  mAbstractItemManager* (*createItemManager)(clss*); \
159  mPieceItem* (*createItemNode)(clss*, mHotPiece*, int, int); \
160  void (*initItemNode)(clss*, mPieceItem*, mHotPiece*); \
161  void (*movePiece)(clss*, mHotPiece*, int, int); \
162  void (*scalePiece)(clss*, mHotPiece*, float, float); \
163  void (*rotatePiece)(clss*, mHotPiece*, float, int, int, int); \
164  void (*setPieceAlpha)(clss*, mHotPiece*, int); \
165  MGEFF_ANIMATION (*movePieceWithAnimation)(clss*, mHotPiece*, int, int, int, enum EffMotionType); \
166  MGEFF_ANIMATION (*scalePieceWithAnimation)(clss*, mHotPiece*, float, float, int, enum EffMotionType); \
167  MGEFF_ANIMATION (*rotatePieceWithAnimation)(clss*, mHotPiece*, float, int, int, int, int, enum EffMotionType); \
168  MGEFF_ANIMATION (*setPieceAlphaWithAnimation)(clss*, mHotPiece*, int, int, enum EffMotionType); \
169  void (*setOwner)(clss*, mWidget*); \
170  mWidget *(*getOwner)(clss*); \
171  void (*animationSyncRunAndDelete)(clss *self, MGEFF_ANIMATION); \
172  void (*animationAsyncRun)(clss *self, MGEFF_ANIMATION, int keepalive); \
173  mShapeTransRoundPiece* (*getBkgndPiece)(clss *); \
174  void (*invalidatePiece)(clss *, mHotPiece *piece, const RECT *rc, BOOL reserveCache); \
175  void (*setBkgndPiece)(clss *, mShapeTransRoundPiece*);
176 
177 struct _mPanelPieceClass
178 {
179  mPanelPieceClassHeader(mPanelPiece, mStaticPiece)
180 };
181 
182 MGNCS_EXPORT extern mPanelPieceClass g_stmPanelPieceCls;
183 
184 
185 // global functions
186 extern void PanelPiece_invalidatePiece(mHotPiece *piece, const RECT *rc);
187 extern void PanelPiece_update(mHotPiece *piece, BOOL fErase);
188 extern mPanelPiece *PanelPiece_getTopPanel(mHotPiece *self);
189 
190 #define PanelPiece_isTopPanel(self) \
191  ( ( (self)->parent == NULL ) && ( (self)->owner != NULL ) )
192 
193 #ifdef __cplusplus
194 }
195 #endif /* __cplusplus */
196 
197 #endif /* _MGNCS_PANELPIECE_H */