ZFFramework
 
Loading...
Searching...
No Matches
ZFUICellAdapter.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFUICellAdapter_h_
7#define _ZFI_ZFUICellAdapter_h_
8
9#include "ZFUICell.h"
11
15zfinterface ZFLIB_ZFUIWidget ZFUICellAdapter : zfextend ZFInterface {
16 ZFINTERFACE_DECLARE_WITH_CUSTOM_CTOR(ZFUICellAdapter, ZFInterface)
17
18 // ============================================================
19 // events
20public:
31 ZFEVENT(CellAdapterOnReload)
39 ZFEVENT(CellOnUpdate)
46 ZFEVENT(CellCacheOnRecycle)
47
48 // ============================================================
49 // owner state
50private:
51 ZFUIOrientation _ZFP_ZFUICellAdapter_orientation;
52public:
57
58private:
59 ZFUISize _ZFP_ZFUICellAdapter_containerSize;
60public:
65
66public:
75 ZFPROPERTY_ASSIGN(zffloat, cellSizeHint, ZFUIGlobalStyle::DefaultStyle()->itemSizeCell())
77
86
87 // ============================================================
88 // basic cell access
89public:
94 , ZFMP_IN_OPT(zfindex, atIndexOrMax, zfindexMax())
95 )
117 , ZFMP_IN(zfindex, index)
118 , ZFMP_IN(ZFUICell *, cell)
120
121public:
126 ) {
127 _ZFP_ZFUICellAdapter_orientation = orientation;
128 _ZFP_ZFUICellAdapter_containerSize = containerSize;
129 }
130
132 this->cellAdapterOnReload(atIndexOrMax);
133 }
134
136 ZF_IN zfindex atIndex
137 , ZF_IN ZFUICell *cell
138 ) {
139 this->cellOnUpdate(atIndex, cell);
140 }
141
143 return this->cellCacheOnAccess(index);
144 }
145
147 this->cellCacheOnRecycle(cell);
148 this->toObject()->observerNotify(zfself::E_CellCacheOnRecycle(), cell);
149 }
150
151 // ============================================================
152 // cell update callback
153protected:
157 virtual inline void cellAdapterOnReload(ZF_IN_OPT zfindex atIndexOrMax = zfindexMax()) {
158 this->toObject()->observerNotify(zfself::E_CellAdapterOnReload(),
159 (atIndexOrMax == zfindexMax()) ? zfnull : zfobj<v_zfindex>(atIndexOrMax).toObject());
160 }
161
164 virtual inline void cellOnUpdate(
165 ZF_IN zfindex atIndex
166 , ZF_IN ZFUICell *cell
167 ) {
168 this->toObject()->observerNotify(zfself::E_CellOnUpdate(), cell, zfobj<v_zfindex>(atIndex));
169 }
170
171 // ============================================================
172 // cache logic
173protected:
180 virtual inline zfauto cellCacheOnAccess(ZF_IN zfindex index) {
181 return zfnull;
182 }
183
193 virtual inline void cellCacheOnRecycle(ZF_IN ZFUICell *cell) {
194 }
195
196public:
198 ZFMETHOD_DECLARE_1(zfautoT<ZFUICell>, cellCacheDefaultAccess
199 , ZFMP_IN(const zfstring &, key)
203 , ZFMP_IN(const zfstring &, key)
204 , ZFMP_IN(ZFUICell *, cell)
206
207protected:
209 ZFUICellAdapter(void)
210 : _ZFP_ZFUICellAdapter_orientation(v_ZFUIOrientation::e_Top)
211 , _ZFP_ZFUICellAdapter_containerSize(ZFUISizeZero())
212 {
213 }
215};
216
218#endif // #ifndef _ZFI_ZFUICellAdapter_h_
219
#define zffinal
dummy macro shows that a method or class is designed must not to be overrided
Definition ZFCoreTypeDef_ClassType.h:63
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfpurevirtual
dummy macro shows that a method is pure virtual method
Definition ZFCoreTypeDef_ClassType.h:68
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:184
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
#define zfindexMax()
(zfindex)-1, indicate a max index value, see zfindex
Definition ZFCoreTypeDef_CoreType.h:159
_zft_zffloat zffloat
same as float, see zfindex
Definition ZFCoreTypeDef_CoreType.h:183
#define zffalse
bool false type
Definition ZFCoreTypeDef_CoreType.h:111
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZFMP_IN_OPT(ParamType, paramName, DefaultValue)
see ZFMP_IN
Definition ZFMethod.h:108
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#define ZFMETHOD_DECLARE_0(ReturnType, MethodName)
see ZFMethod
Definition ZFMethodDeclare.h:693
#define ZFMETHOD_DECLARE_2(ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMethod
Definition ZFMethodDeclare.h:1025
#define ZFMETHOD_DECLARE_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodDeclare.h:854
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
#define ZFINTERFACE_DECLARE_WITH_CUSTOM_CTOR(InterfaceName, ParentInterface,...)
see ZFINTERFACE_DECLARE
Definition ZFObjectInterface.h:94
#define zfinterface
shows the type is an interface, see ZFInterface
Definition ZFObjectInterface.h:20
#define ZFEVENT(YourEvent)
see ZFObject::observerNotify
Definition ZFObjectObserver.h:328
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:128
#define ZFPROPERTY_ON_ATTACH_DECLARE(Type, Name)
see ZFPROPERTY_ON_INIT_DECLARE
Definition ZFPropertyDeclare.h:248
abstract cell to hold content views
v_ZFUIOrientation::ZFEnumType ZFUIOrientation
see v_ZFUIOrientation
Definition ZFUITypeDef.h:1145
ZFUISize const & ZFUISizeZero(void)
(0, 0)
Definition ZFUITypeDef.h:421
#define ZFLIB_ZFUIWidget
used to export symbols
Definition ZFUIWidgetDef.h:17
virtual ZFObject * toObject(void)=0
convert to ZFObject type
virtual void cellCacheOnRecycle(ZFUICell *cell)
recycle cell or do nothing if you don't need recycle logic
Definition ZFUICellAdapter.h:193
virtual zfautoT< ZFUICell > cellAt(zfindex index)=0
access cell at index, assert fail if return null object
static zfidentity E_CellOnUpdate(void)
see ZFObject::observerNotify
virtual void cellOnUpdate(zfindex atIndex, ZFUICell *cell)
see E_CellOnUpdate
Definition ZFUICellAdapter.h:164
virtual zfindex cellCount(void)=0
cell count
static zfidentity E_CellCacheOnRecycle(void)
see ZFObject::observerNotify
void notifyCellCacheRecycle(ZFUICell *cell)
for impl to notify cell cache access
Definition ZFUICellAdapter.h:146
virtual void cellAdapterNotifyReload(zfindex atIndexOrMax=(((zfindex) -1)))
see E_CellAdapterOnReload
virtual const ZFUISize & containerSize()
container's size
virtual ZFUIOrientation orientation()
owner view's orientation
void notifyCellAdapterReload(zfindex atIndexOrMax=((zfindex) -1))
for impl to notify reload
Definition ZFUICellAdapter.h:131
virtual zffloat cellSizeAt(zfindex index, ZFUICell *cell)
check cell size at index
zfauto notifyCellCacheAccess(zfindex index)
for impl to notify cell cache access
Definition ZFUICellAdapter.h:142
virtual zffloat & cellSizeHint()
cell's hint size, use -1 to measure by cell, ZFUIGlobalStyle::itemSizeCell by default
Definition ZFUICellAdapter.h:75
virtual void cellCacheDefaultRecycle(const zfstring &key, ZFUICell *cell)
see cellCacheOnRecycle
virtual void cellAdapterOnReload(zfindex atIndexOrMax=((zfindex) -1))
see E_CellAdapterOnReload
Definition ZFUICellAdapter.h:157
virtual zfbool & cellSizeFill()
if cellSizeHint not set, whether fill cell size to containerSize, false by default
Definition ZFUICellAdapter.h:84
void notifyContainerUpdate(ZFUIOrientation orientation, const ZFUISize &containerSize)
for impl to notify state update
Definition ZFUICellAdapter.h:123
virtual zfauto cellCacheOnAccess(zfindex index)
try access cached cell, return null means no cache available, by default, no cache logic support
Definition ZFUICellAdapter.h:180
void notifyCellUpdate(zfindex atIndex, ZFUICell *cell)
for impl to notify cell update
Definition ZFUICellAdapter.h:135
static zfidentity E_CellAdapterOnReload(void)
see ZFObject::observerNotify
utility class to hold cell
Definition ZFUICell.h:21
global style for ui elements
Definition ZFUIGlobalStyle.h:15
2D size
Definition ZFUITypeDef.h:397
orientation types for UI in ZFFramework
Definition ZFUITypeDef.h:1135
a ZFObject holder which would release content object automatically when destroyed
Definition zfautoFwd.h:34
type restrict version of zfauto
Definition zfautoFwd.h:110
util class to alloc and hold ZFObject type
Definition ZFObjectAutoPtr.h:157