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:
157
164
165 // ============================================================
166 // page property
167public:
176
177 // ============================================================
178 // page state
179public:
188
189public:
198 , ZFMP_IN(ZFUIPage *, page)
199 , ZFMP_IN_OPT(const ZFListener &, pageResultCallback, zfnull)
203 , ZFMP_IN(ZFUIPage *, page)
209
216
217 // ============================================================
218 // page life cycle
219protected:
221 virtual void pageOnCreate(void);
227 virtual void pageOnDestroy(void);
228
230 virtual inline void pageOrientationOnUpdate(void) {}
231
232 // ============================================================
233 // page ani
234public:
239
240
246
247protected:
259 virtual void pageAniOnPrepare(
260 ZF_IN ZFEnum *resumeOrPauseReason
261 , ZF_IN ZFUIPage *siblingPage
262 ) {
263 }
264
265 // ============================================================
266private:
267 ZFUIPageManager *_ZFP_ZFUIPage_pageManager;
268 ZFUIView *_ZFP_ZFUIPage_pageView;
269 zfbool _ZFP_ZFUIPage_pageCreated;
270 zfbool _ZFP_ZFUIPage_pageResumed;
271 zfbyte _ZFP_ZFUIPage_pageOrientation; // -1: not initialized, 0: port, 1: land
272 ZFAnimation *_ZFP_ZFUIPage_pageAni;
273protected:
275 ZFUIPage(void)
276 : _ZFP_ZFUIPage_pageManager(zfnull)
277 , _ZFP_ZFUIPage_pageView(zfnull)
278 , _ZFP_ZFUIPage_pageCreated(zffalse)
279 , _ZFP_ZFUIPage_pageResumed(zffalse)
280 , _ZFP_ZFUIPage_pageOrientation((zfbyte)-1)
281 , _ZFP_ZFUIPage_pageAni(zfnull)
282 {
283 }
286 virtual void objectOnDealloc(void) {
287 zfobjRetainChange(this->_ZFP_ZFUIPage_pageView, zfnull);
288 zfobjRetainChange(this->_ZFP_ZFUIPage_pageAni, zfnull);
290 }
291private:
293 friend zfclassFwd _ZFP_ZFUIPageManagerPrivate;
294};
295
296// ============================================================
297zfclassFwd _ZFP_ZFUIPageManagerPrivate;
299zfclass ZFLIB_ZFUIWidget ZFUIPageManager : zfextend ZFObject {
300 ZFOBJECT_DECLARE(ZFUIPageManager, ZFObject)
301
302 // ============================================================
303 // observers
304public:
310 ZFEVENT(ManagerOnCreate)
316 ZFEVENT(ManagerOnResume)
322 ZFEVENT(ManagerOnPause)
328 ZFEVENT(ManagerOnDestroy)
329
335 ZFEVENT(ManagerOrientationOnUpdate)
336
343 ZFEVENT(ManagerUIBlockOnUpdate)
344
345 // ============================================================
346 // page observers
347public:
349 ZFEVENT(PageOnCreate)
351 ZFEVENT(PageOnResume)
353 ZFEVENT(PageOnPause)
355 ZFEVENT(PageOnDestroy)
357 ZFEVENT(PageOrientationOnUpdate)
359 ZFEVENT(PageAniOnPrepare)
361 ZFEVENT(PageAniOnStart)
363 ZFEVENT(PageAniOnStop)
364
365 // ============================================================
366 // manager creation
367public:
387
388protected:
398 virtual void managerOnCreate(void);
400 virtual void managerOnResume(void) {}
402 virtual void managerOnPause(void) {}
404 virtual void managerOnDestroy(void);
405
407 virtual inline void managerOrientationOnUpdate(void) {}
408
409public:
414
422
423public:
438 , ZFMP_IN_OPT(ZFUIRootWindow *, rootWindow, zfnull)
446 , ZFMP_IN(ZFUIWindow *, window)
447 , ZFMP_IN_OPT(zfbool, autoHidePrev, zftrue)
449
450 // ============================================================
451 // container
452public:
472
477
478 // ============================================================
479 // manager control
480public:
490 , ZFMP_IN(zfbool, value)
496protected:
498 virtual inline void managerUIBlockOnUpdate(void) {
499 if(this->pageContainer()) {
500 this->pageContainer()->viewUIEnableTree(!this->managerUIBlock());
501 }
502 }
503
504 // ============================================================
505 // page access
506public:
525 , ZFMP_IN(zfindex, index)
535 , ZFMP_IN(ZFUIPage *, page)
537
542 , ZFMP_IN(const zfstring &, pageGroupId)
544
545 // ============================================================
546 // page management
547public:
554 , ZFMP_IN(ZFAnimation *, resumeAni)
555 , ZFMP_IN(ZFAnimation *, pauseAni)
556 , ZFMP_IN_OPT(zfbool, pauseAniHigherPriority, zffalse)
558
567 , ZFMP_IN(ZFUIPage *, page)
568 , ZFMP_IN_OPT(const ZFListener &, pageResultCallback, zfnull)
572 , ZFMP_IN(ZFUIPage *, page)
574
577 , ZFMP_IN(ZFUIPage *, page)
585 , ZFMP_IN(const zfstring &, pageGroupId)
587
590 , ZFMP_IN(ZFUIPage *, page)
592
609
616 , ZFMP_IN(const ZFListener &, callback)
622 , ZFMP_IN(const ZFListener &, callback)
628
629protected:
631 virtual void objectOnInit(void);
633 virtual void objectOnDealloc(void);
634private:
635 _ZFP_ZFUIPageManagerPrivate *d;
636 friend zfclassFwd _ZFP_ZFUIPageManagerPrivate;
637};
638
640#endif // #ifndef _ZFI_ZFUIPage_h_
641
#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:198
#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
#define zftrue
bool true type
Definition ZFCoreTypeDef_CoreType.h:107
_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:692
#define ZFMETHOD_DECLARE_2(ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMethod
Definition ZFMethodDeclare.h:1024
#define ZFMETHOD_DECLARE_3(ReturnType, MethodName, ZFMP_0, ZFMP_1, ZFMP_2)
see ZFMethod
Definition ZFMethodDeclare.h:1205
#define ZFMETHOD_DECLARE_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodDeclare.h:853
#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:138
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:122
#define ZFEVENT(YourEvent)
see ZFObject::observerNotify
Definition ZFObjectObserver.h:312
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:187
#define ZFPROPERTY_RETAIN(Type, Name,...)
declare a retain property
Definition ZFPropertyDeclare.h:103
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:120
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:297
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:259
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:163
virtual zfint & pageAniPriority()
page priority to detect for pageAni, see pageAniOnPrepare for more info
Definition ZFUIPage.h:238
virtual void objectOnDealloc(void)
override this to destroy your object
Definition ZFUIPage.h:286
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 zfanyT< ZFUIPageManager > pageManager()
owner page manager
virtual void pageOnCreate(void)
see ZFUIPage
virtual void pageCreate(ZFUIPage *page, const ZFListener &pageResultCallback=(zft_zfnull))
util to ZFUIPageManager::pageCreate
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:171
virtual zfany const & pageResult()
store page result, passed to pageResultCallback of pageCreate
Definition ZFUIPage.h:175
virtual void pageOrientationOnUpdate(void)
see E_PageOrientationOnUpdate
Definition ZFUIPage.h:230
virtual void pageReplace(ZFUIPage *page)
util to ZFUIPageManager::pageReplace
see ZFUIPage
Definition ZFUIPage.h:299
virtual void managerOrientationOnUpdate(void)
see E_ManagerOrientationOnUpdate
Definition ZFUIPage.h:407
virtual void managerOnPause(void)
see managerOnCreate
Definition ZFUIPage.h:402
virtual const ZFClass *& pageContainerClass()
see managerContainer
Definition ZFUIPage.h:476
virtual void managerCreateForWindow(ZFUIRootWindow *rootWindow=(zft_zfnull))
util method to create manager and a ZFUIWindow to manage life cycle for most case
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:474
virtual ZFUIView * pageContainer()
see managerContainer
virtual void managerPause()
see managerCreate
virtual zfindex pageRequestCount()
return count of request in queue
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 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:400
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 ZFUIWindow * managerWindow()
valid only for managerCreateForWindow
virtual zfbool managerResumed()
true if managerResume called
virtual void managerUIBlockOnUpdate(void)
see E_ManagerUIBlockOnUpdate
Definition ZFUIPage.h:498
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:88
window as a ZFUIView
Definition ZFUIWindow.h:74
util method to cast ZFObject types freely
Definition zfany.h:35
see zfany
Definition zfany.h:113