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 )
104 , ZFMP_IN(zfindex, index)
119 , ZFMP_IN(zfindex, index)
120 , ZFMP_IN(ZFUICell *, cell)
122
123public:
128 ) {
129 _ZFP_ZFUICellAdapter_orientation = orientation;
130 _ZFP_ZFUICellAdapter_containerSize = containerSize;
131 }
132
134 this->cellAdapterOnReload(atIndexOrMax);
135 }
136
138 ZF_IN zfindex atIndex
139 , ZF_IN ZFUICell *cell
140 ) {
141 this->cellOnUpdate(atIndex, cell);
142 }
143
145 return this->cellCacheOnAccess(index);
146 }
147
149 this->cellCacheOnRecycle(cell);
150 this->toObject()->observerNotify(zfself::E_CellCacheOnRecycle(), ZFArgs().param0(cell));
151 }
152
153 // ============================================================
154 // cell update callback
155protected:
159 virtual inline void cellAdapterOnReload(ZF_IN_OPT zfindex atIndexOrMax = zfindexMax()) {
160 this->toObject()->observerNotify(zfself::E_CellAdapterOnReload(), ZFArgs().param0((atIndexOrMax == zfindexMax()) ? zfnull : zfobj<v_zfindex>(atIndexOrMax).toObject()));
161 }
162
165 virtual inline void cellOnUpdate(
166 ZF_IN zfindex atIndex
167 , ZF_IN ZFUICell *cell
168 ) {
169 this->toObject()->observerNotify(zfself::E_CellOnUpdate(), ZFArgs().param0(cell).param1(zfobj<v_zfindex>(atIndex)));
170 }
171
172 // ============================================================
173 // cache logic
174protected:
181 virtual inline zfauto cellCacheOnAccess(ZF_IN zfindex index) {
182 return zfnull;
183 }
184
194 virtual inline void cellCacheOnRecycle(ZF_IN ZFUICell *cell) {
195 }
196
197public:
199 ZFMETHOD_DECLARE_1(zfautoT<ZFUICell>, cellCacheDefaultAccess
200 , ZFMP_IN(const zfstring &, key)
204 , ZFMP_IN(const zfstring &, key)
205 , ZFMP_IN(ZFUICell *, cell)
207
208protected:
210 ZFUICellAdapter(void)
211 : _ZFP_ZFUICellAdapter_orientation(v_ZFUIOrientation::e_Top)
212 , _ZFP_ZFUICellAdapter_containerSize(ZFUISizeZero())
213 {
214 }
216};
217
219#endif // #ifndef _ZFI_ZFUICellAdapter_h_
220
#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 ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:198
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:202
_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:692
#define ZFMETHOD_DECLARE_2(ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMethod
Definition ZFMethodDeclare.h:1024
#define ZFMETHOD_DECLARE_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodDeclare.h:853
#define ZFMETHOD_INTERFACE_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodInterfaceDeclare.h:145
#define ZFMETHOD_INTERFACE_0(ReturnType, MethodName)
see ZFMethod
Definition ZFMethodInterfaceDeclare.h:68
#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:93
#define zfinterface
shows the type is an interface, see ZFInterface
Definition ZFObjectInterface.h:20
#define ZFEVENT(YourEvent)
see ZFObject::observerNotify
Definition ZFObjectObserver.h:312
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:120
#define ZFPROPERTY_ON_ATTACH_DECLARE(Type, Name)
see ZFPROPERTY_ON_INIT_DECLARE
Definition ZFPropertyDeclare.h:233
abstract cell to hold content views
v_ZFUIOrientation::ZFEnumType ZFUIOrientation
see v_ZFUIOrientation
Definition ZFUITypeDef.h:1153
ZFUISize const & ZFUISizeZero(void)
(0, 0)
Definition ZFUITypeDef.h:421
#define ZFLIB_ZFUIWidget
used to export symbols
Definition ZFUIWidgetDef.h:17
listener data used by ZFListener
Definition ZFArgs.h:20
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:194
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:165
static zfidentity E_CellCacheOnRecycle(void)
see ZFObject::observerNotify
void notifyCellCacheRecycle(ZFUICell *cell)
for impl to notify cell cache access
Definition ZFUICellAdapter.h:148
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:133
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:144
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:159
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:125
virtual zfauto cellCacheOnAccess(zfindex index)
try access cached cell, return null means no cache available, by default, no cache logic support
Definition ZFUICellAdapter.h:181
void notifyCellUpdate(zfindex atIndex, ZFUICell *cell)
for impl to notify cell update
Definition ZFUICellAdapter.h:137
virtual zfindex cellCount()=0
cell count
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:1143
a ZFObject holder which would release content object automatically when destroyed
Definition zfautoFwd.h:34
type restrict version of zfauto
Definition zfautoFwd.h:108
util class to alloc and hold ZFObject type
Definition ZFObjectAutoPtr.h:72