ZFFramework
 
Loading...
Searching...
No Matches
ZFUIPage.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFUIPage_h_
7#define _ZFI_ZFUIPage_h_
8
9#include "ZFUIWidgetDef.h"
11
16 ZFENUM_VALUE(ByManagerResume)
17 ZFENUM_VALUE(ByRequest)
18 ZFENUM_VALUE(FromBackground)
20 ZFENUM_VALUE_REGISTER(ByManagerResume)
21 ZFENUM_VALUE_REGISTER(ByRequest)
22 ZFENUM_VALUE_REGISTER(FromBackground)
25
30 ZFENUM_VALUE(ByManagerPause)
31 ZFENUM_VALUE(ToBackground)
32 ZFENUM_VALUE(BeforeDestroy)
34 ZFENUM_VALUE_REGISTER(ByManagerPause)
35 ZFENUM_VALUE_REGISTER(ToBackground)
36 ZFENUM_VALUE_REGISTER(BeforeDestroy)
39
40// ============================================================
80zfclass ZFLIB_ZFUIWidget ZFUIPage : zfextend ZFObject {
82
83 // ============================================================
84 // observers
85public:
91 ZFEVENT(PageOnCreate)
99 ZFEVENT(PageOnResume)
107 ZFEVENT(PageOnPause)
113 ZFEVENT(PageOnDestroy)
114
120 ZFEVENT(PageOrientationOnUpdate)
121
131 ZFEVENT(PageAniOnPrepare)
132
141 ZFEVENT(PageAniOnStart)
150 ZFEVENT(PageAniOnStop)
151
152 // ============================================================
153 // page manager
154public:
156 virtual zfanyT<ZFUIPageManager> pageManager(void) {
157 return this->_ZFP_ZFUIPage_pageManager;
158 }
159
166
167 // ============================================================
168 // page property
169public:
178
179 // ============================================================
180 // page state
181public:
190
191public:
200 , ZFMP_IN(ZFUIPage *, page)
201 , ZFMP_IN_OPT(const ZFListener &, pageResultCallback, zfnull)
205 , ZFMP_IN(ZFUIPage *, page)
211
218
219 // ============================================================
220 // page life cycle
221protected:
223 virtual void pageOnCreate(void);
229 virtual void pageOnDestroy(void);
230
232 virtual inline void pageOrientationOnUpdate(void) {}
233
234 // ============================================================
235 // page ani
236public:
241
242
248
249protected:
261 virtual void pageAniOnPrepare(
262 ZF_IN ZFEnum *resumeOrPauseReason
263 , ZF_IN ZFUIPage *siblingPage
264 ) {
265 }
266
267 // ============================================================
268private:
269 ZFUIPageManager *_ZFP_ZFUIPage_pageManager;
270 ZFUIView *_ZFP_ZFUIPage_pageView;
271 zfbool _ZFP_ZFUIPage_pageCreated;
272 zfbool _ZFP_ZFUIPage_pageResumed;
273 zfbyte _ZFP_ZFUIPage_pageOrientation; // -1: not initialized, 0: port, 1: land
274 ZFAnimation *_ZFP_ZFUIPage_pageAni;
275protected:
277 ZFUIPage(void)
278 : _ZFP_ZFUIPage_pageManager(zfnull)
279 , _ZFP_ZFUIPage_pageView(zfnull)
280 , _ZFP_ZFUIPage_pageCreated(zffalse)
281 , _ZFP_ZFUIPage_pageResumed(zffalse)
282 , _ZFP_ZFUIPage_pageOrientation((zfbyte)-1)
283 , _ZFP_ZFUIPage_pageAni(zfnull)
284 {
285 }
288 virtual void objectOnDealloc(void) {
289 zfobjRetainChange(this->_ZFP_ZFUIPage_pageView, zfnull);
290 zfobjRetainChange(this->_ZFP_ZFUIPage_pageAni, zfnull);
292 }
293private:
295 friend zfclassFwd _ZFP_ZFUIPageManagerPrivate;
296};
297
298// ============================================================
299zfclassFwd _ZFP_ZFUIPageManagerPrivate;
301zfclass ZFLIB_ZFUIWidget ZFUIPageManager : zfextend ZFObject {
302 ZFOBJECT_DECLARE(ZFUIPageManager, ZFObject)
303
304 // ============================================================
305 // observers
306public:
312 ZFEVENT(ManagerOnCreate)
318 ZFEVENT(ManagerOnResume)
324 ZFEVENT(ManagerOnPause)
330 ZFEVENT(ManagerOnDestroy)
331
337 ZFEVENT(ManagerOrientationOnUpdate)
338
345 ZFEVENT(ManagerUIBlockOnUpdate)
346
347 // ============================================================
348 // page observers
349public:
351 ZFEVENT(PageOnCreate)
353 ZFEVENT(PageOnResume)
355 ZFEVENT(PageOnPause)
357 ZFEVENT(PageOnDestroy)
359 ZFEVENT(PageOrientationOnUpdate)
361 ZFEVENT(PageAniOnPrepare)
363 ZFEVENT(PageAniOnStart)
365 ZFEVENT(PageAniOnStop)
366
367 // ============================================================
368 // manager creation
369public:
389
390protected:
400 virtual void managerOnCreate(void);
402 virtual void managerOnResume(void) {}
404 virtual void managerOnPause(void) {}
406 virtual void managerOnDestroy(void);
407
409 virtual inline void managerOrientationOnUpdate(void) {}
410
411public:
416
424
425public:
438 , ZFMP_IN_OPT(ZFUIRootWindow *, rootWindow, zfnull)
442
443 // ============================================================
444 // container
445public:
465
470
471 // ============================================================
472 // manager control
473public:
483 , ZFMP_IN(zfbool, value)
489protected:
491 virtual inline void managerUIBlockOnUpdate(void) {
492 if(this->pageContainer()) {
493 this->pageContainer()->viewUIEnableTree(!this->managerUIBlock());
494 }
495 }
496
497 // ============================================================
498 // page access
499public:
518 , ZFMP_IN(zfindex, index)
528 , ZFMP_IN(ZFUIPage *, page)
530
535 , ZFMP_IN(const zfstring &, pageGroupId)
537
538 // ============================================================
539 // page management
540public:
547 , ZFMP_IN(ZFAnimation *, resumeAni)
548 , ZFMP_IN(ZFAnimation *, pauseAni)
549 , ZFMP_IN_OPT(zfbool, pauseAniHigherPriority, zffalse)
551
560 , ZFMP_IN(ZFUIPage *, page)
561 , ZFMP_IN_OPT(const ZFListener &, pageResultCallback, zfnull)
565 , ZFMP_IN(ZFUIPage *, page)
567
570 , ZFMP_IN(ZFUIPage *, page)
578 , ZFMP_IN(const zfstring &, pageGroupId)
580
583 , ZFMP_IN(ZFUIPage *, page)
585
602
609 , ZFMP_IN(const ZFListener &, callback)
615 , ZFMP_IN(const ZFListener &, callback)
621
622protected:
624 virtual void objectOnInit(void);
626 virtual void objectOnDealloc(void);
627private:
628 _ZFP_ZFUIPageManagerPrivate *d;
629 friend zfclassFwd _ZFP_ZFUIPageManagerPrivate;
630};
631
633#endif // #ifndef _ZFI_ZFUIPage_h_
634
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfoverride
dummy macro shows that method override parent's method
Definition ZFCoreTypeDef_ClassType.h:58
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:184
#define zfclassFwd
forward declaration of a class type
Definition ZFCoreTypeDef_ClassType.h:31
_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
_ZFT_t_zfint zfint
same as int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:165
#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_t_zfbyte zfbyte
8-bit unsigned value, see zfindex
Definition ZFCoreTypeDef_CoreType.h:194
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZFENUM_SEPARATOR()
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:158
#define ZFENUM_VALUE_REGISTER(Value)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:168
#define ZFENUM_REG(ZFLIB_, EnumName,...)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:186
#define ZFENUM_VALUE(Value)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:151
#define ZFENUM_BEGIN(ZFLIB_, EnumName)
macros to define reflectable enum type
Definition ZFEnumDeclare.h:147
#define ZFENUM_END(ZFLIB_, EnumName)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:172
#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_3(ReturnType, MethodName, ZFMP_0, ZFMP_1, ZFMP_2)
see ZFMethod
Definition ZFMethodDeclare.h:1206
#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 zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_DECLARE_WITH_CUSTOM_CTOR(ChildClass, SuperClass,...)
declare object which allow custom constructor
Definition ZFObjectDeclare.h:142
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:126
#define ZFEVENT(YourEvent)
see ZFObject::observerNotify
Definition ZFObjectObserver.h:316
void zfobjRetainChange(T_ZFObject &obj, T_ZFObject2 const &v)
util to release property's old value, retain new value, then set to property
Definition ZFObjectRetain.h:324
#define ZFPROPERTY_RETAIN(Type, Name,...)
declare a retain property
Definition ZFPropertyDeclare.h:103
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:127
v_ZFUIPageResumeReason::ZFEnumType ZFUIPageResumeReason
see v_ZFUIPageResumeReason
Definition ZFUIPage.h:23
v_ZFUIPagePauseReason::ZFEnumType ZFUIPagePauseReason
see v_ZFUIPagePauseReason
Definition ZFUIPage.h:37
global header for ZFUIWidget module
#define ZFLIB_ZFUIWidget
used to export symbols
Definition ZFUIWidgetDef.h:17
base class of all animation
Definition ZFAnimation.h:22
light weight array
Definition ZFCoreArray.h:342
abstract base class of all enum type of ZFFramework
Definition ZFEnum.h:38
listener as ZFCallback, mostly used by ZFObject::observerNotify
Definition ZFObjectObserver.h:30
virtual void objectOnDealloc(void)
override this to destroy your object
abstract page similar to Android's Activity
Definition ZFUIPage.h:80
virtual zfbool pageCreated()
true if page created (true after pageOnCreate called)
virtual void pageOnPause(ZFUIPagePauseReason reason)
see ZFUIPage
virtual void pageAniOnPrepare(ZFEnum *resumeOrPauseReason, ZFUIPage *siblingPage)
called to prepare page animation
Definition ZFUIPage.h:261
virtual zfbool isLandscape()
whether the page is considered landscape
virtual void pageOnDestroy(void)
see ZFUIPage
virtual const ZFClass *& pageViewClass()
pageView's class, must set before base page's pageOnCreate
Definition ZFUIPage.h:165
virtual zfint & pageAniPriority()
page priority to detect for pageAni, see pageAniOnPrepare for more info
Definition ZFUIPage.h:240
virtual void objectOnDealloc(void)
override this to destroy your object
Definition ZFUIPage.h:288
virtual void pageAni(ZFAnimation *pageAni)
see pageAniOnPrepare
virtual zfbool pageResumed()
true if page resumed (true after pageOnResume called)
virtual void pageDestroy()
util to ZFUIPageManager::pageDestroy
virtual void pageOnCreate(void)
see ZFUIPage
virtual void pageCreate(ZFUIPage *page, const ZFListener &pageResultCallback=(zft_zfnull))
util to ZFUIPageManager::pageCreate
virtual zfanyT< ZFUIPageManager > pageManager(void)
owner page manager
Definition ZFUIPage.h:156
virtual ZFUIView * pageView()
the page's container view, ensured not null
virtual void pageOnResume(ZFUIPageResumeReason reason)
see ZFUIPage
virtual void pageResume()
util to ZFUIPageManager::pageResume
virtual zfstring & pageGroupId()
page group id, see ZFUIPageManager::pageResumeForGroupId for more info
Definition ZFUIPage.h:173
virtual zfany const & pageResult()
store page result, passed to pageResultCallback of pageCreate
Definition ZFUIPage.h:177
virtual void pageOrientationOnUpdate(void)
see E_PageOrientationOnUpdate
Definition ZFUIPage.h:232
virtual void pageReplace(ZFUIPage *page)
util to ZFUIPageManager::pageReplace
see ZFUIPage
Definition ZFUIPage.h:301
virtual void managerOrientationOnUpdate(void)
see E_ManagerOrientationOnUpdate
Definition ZFUIPage.h:409
virtual void managerOnPause(void)
see managerOnCreate
Definition ZFUIPage.h:404
virtual const ZFClass *& pageContainerClass()
see managerContainer
Definition ZFUIPage.h:469
virtual void managerResume()
see managerCreate
virtual zfindex pageCount()
page count of this page manager
virtual void pageRequestCancel(const ZFListener &callback)
remove callback for pageRequest
virtual zfbool isLandscape()
whether the manager is considered landscape
virtual void managerOnCreate(void)
for subclass to do actual works
virtual ZFCoreArray< ZFUIPage * > & pageList()
directly access the page list
virtual const ZFClass *& managerContainerClass()
see managerContainer
Definition ZFUIPage.h:467
virtual ZFUIView * pageContainer()
see managerContainer
virtual void managerPause()
see managerCreate
virtual zfindex pageRequestCount()
return count of request in queue
virtual ZFUIWindow * managerCreateForWindow(ZFUIRootWindow *rootWindow=(zft_zfnull))
util method to create manager and a ZFUIWindow to manage life cycle for most case
virtual void pageReplace(ZFUIPage *page)
util to destroy current and create new page
virtual void pageCreate(ZFUIPage *page, const ZFListener &pageResultCallback=(zft_zfnull))
create and resume page
virtual void pageResume(ZFUIPage *page)
resume page
virtual zfanyT< ZFUIPage > pageAt(zfindex index)
page at index
virtual ZFUIWindow * managerOwnerWindow()
valid only for managerCreateForWindow
virtual void pageAniOverride(ZFAnimation *resumeAni, ZFAnimation *pauseAni, zfbool pauseAniHigherPriority=(_ZFT_t_zffalse))
override animation for next page management, can be called more than once to override sequently,...
virtual void managerOnDestroy(void)
see managerOnCreate
virtual zfindex pageIndex(ZFUIPage *page)
find page index
virtual void managerDestroy()
see managerCreate
virtual void managerOnResume(void)
see managerOnCreate
Definition ZFUIPage.h:402
virtual void managerUIBlock(zfbool value)
enable or disable manager's user interaction
virtual void pageMoveEnd()
see pageMoveBegin
virtual void pageRequest(const ZFListener &callback)
add a page request to queue, used to ensure execute order when mixed with page management (pageCreate...
virtual zfanyT< ZFUIPage > currentPage()
return foreground page or null if no page
virtual void objectOnDealloc(void)
override this to destroy your object
virtual ZFUIView * managerContainer()
container view of this page manager
virtual void pageMoveBegin()
advanced page stack management
virtual zfbool managerCreated()
true if managerCreate called
virtual zfbool managerResumed()
true if managerResume called
virtual void managerUIBlockOnUpdate(void)
see E_ManagerUIBlockOnUpdate
Definition ZFUIPage.h:491
virtual ZFCoreArray< ZFUIPage * > pageListForGroupId(const zfstring &pageGroupId)
find page by ZFUIPage::pageGroupId
virtual void managerCreate()
manually create the manager
virtual void pageDestroy(ZFUIPage *page)
destroy page
virtual zfindex managerUIBlockCount()
see managerUIBlock
virtual void objectOnInit(void)
override this to init your object
virtual void pageResumeForGroupId(const zfstring &pageGroupId)
resume multiple page for group id
root native window
Definition ZFUIRootWindow.h:34
base class of all UI views
Definition ZFUIView.h:90
window as a ZFUIView
Definition ZFUIWindow.h:49
util method to cast ZFObject types freely
Definition zfany.h:35
see zfany
Definition zfany.h:113