ZFFramework
 
Loading...
Searching...
No Matches
ZFUIRootWindow.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFUIRootWindow_h_
7#define _ZFI_ZFUIRootWindow_h_
8
9#include "ZFUIRootView.h"
11
20ZFEVENT_GLOBAL(ZFLIB_ZFUIKit, MainWindowOnAttach)
22
23// ============================================================
25zfclassFwd _ZFP_ZFUIRootWindowPrivate;
34zffinal zfclass ZFLIB_ZFUIKit ZFUIRootWindow : zfextend ZFObject {
35 ZFOBJECT_DECLARE(ZFUIRootWindow, ZFObject)
36
37 // ============================================================
38 // observer events
39public:
46 ZFEVENT(WindowOnCreate)
52 ZFEVENT(WindowOnDestroy)
58 ZFEVENT(WindowOnResume)
64 ZFEVENT(WindowOnPause)
71 ZFEVENT(WindowOnRotate)
78 ZFEVENT(WindowMarginOnUpdate)
79
87 ZFEVENT(WindowOnKeyEvent)
88
89public:
107 static zfautoT<ZFUIRootWindow> nativeWindowEmbed(ZF_IN ZFUIRootWindowEmbedImpl *embedImpl);
108
113
121
130 , ZFMP_IN(void *, nativeParent)
132
147 , ZFMP_IN(void *, nativeParent)
148 , ZFMP_IN(const zfstring &, rootWindowName)
154 , ZFMP_IN(const zfstring &, rootWindowName)
156
157public:
170 , ZFMP_IN(ZFUIRootWindow *, window)
187
192 , ZFMP_IN(ZFUIRootWindow *, window)
198
199public:
209
210public:
220 void _ZFP_ZFUIRootWindow_windowMargin(ZF_IN const ZFUIMargin &windowMargin);
221protected:
225 virtual void windowMarginOnUpdate(ZF_IN const ZFUIMargin &windowMarginOld);
226
227 ZFOBJECT_PRIVATE_ALLOC("can only be created by ZFUIRootWindow::modalWindowShow")
228protected:
230 virtual void objectOnInit(void);
232 virtual void objectOnInitFinish(void);
234 virtual void objectOnDeallocPrepare(void);
236 virtual void objectOnDealloc(void);
237
238public:
247
248public:
274
275public:
290
296
297public:
320
321public:
326
334
335public:
336 zffinal ZFUIRect _ZFP_ZFUIRootWindow_measureWindow(ZF_IN const ZFUIRect &rootRefRect);
337 zffinal void _ZFP_ZFUIRootWindow_onCreate(ZF_IN void *nativeWindow);
338 zffinal void _ZFP_ZFUIRootWindow_onDestroy(void);
339 zffinal void _ZFP_ZFUIRootWindow_onResume(void);
340 zffinal void _ZFP_ZFUIRootWindow_onPause(void);
341 zffinal void _ZFP_ZFUIRootWindow_onRotate(void);
342 zffinal void _ZFP_ZFUIRootWindow_layoutUpdate(void);
343 zffinal void _ZFP_ZFUIRootWindow_keyEvent(ZF_IN ZFUIKeyEvent *event) {
345 }
346
347private:
348 _ZFP_ZFUIRootWindowPrivate *d;
349};
350
351// ============================================================
355zfinterface ZFLIB_ZFUIKit ZFUIRootWindowEmbedImpl : zfextend ZFInterface {
356 ZFINTERFACE_DECLARE_WITH_CUSTOM_CTOR(ZFUIRootWindowEmbedImpl, ZFInterface)
357
358public:
359 zfanyT<ZFUIRootWindow> _ZFP_ownerZFUIRootWindow;
364 return this->_ZFP_ownerZFUIRootWindow;
365 }
366
367public:
369 ZFUIRootWindowEmbedImpl(void) : _ZFP_ownerZFUIRootWindow(zfnull) {}
371
372 // ============================================================
373public:
377 virtual void nativeWindowOnCleanup(ZF_IN ZFUIRootWindow *rootWindow) {
378 }
379
387 ZF_IN ZFUIRootWindow *rootWindow
388 , ZF_OUT_OPT void *&nativeParentView
394
402 virtual void modalWindowHide(
403 ZF_IN ZFUIRootWindow *owner
404 , ZF_IN ZFUIRootWindow *toHide
406
411 virtual void layoutParamOnInit(ZF_IN ZFUIRootWindow *rootWindow) {
412 }
413
416 virtual void layoutParamOnUpdate(ZF_IN ZFUIRootWindow *rootWindow) {
417 }
418
425
430 ZF_IN ZFUIRootWindow *rootWindow
431 , ZF_IN const ZFUIOrientationFlags &flags
432 ) {
433 }
434
435 // ============================================================
436 // callbacks that implementations must notify
437public:
446 ZF_IN ZFUIRootWindow *rootWindow
447 , ZF_IN const ZFUIRect &rootRefRect
448 , ZF_IN const ZFUIMargin &windowMargin
449 ) {
450 rootWindow->_ZFP_ZFUIRootWindow_windowMargin(windowMargin);
451 return rootWindow->_ZFP_ZFUIRootWindow_measureWindow(rootRefRect);
452 }
453
457 ZF_IN ZFUIRootWindow *rootWindow
458 , ZF_IN void *nativeWindow
459 ) {
460 rootWindow->_ZFP_ZFUIRootWindow_onCreate(nativeWindow);
461 }
462
466 rootWindow->_ZFP_ZFUIRootWindow_onDestroy();
467 }
468
473 rootWindow->_ZFP_ZFUIRootWindow_onResume();
474 }
475
480 rootWindow->_ZFP_ZFUIRootWindow_onPause();
481 }
482
486 rootWindow->_ZFP_ZFUIRootWindow_onRotate();
487 }
488
492 ZF_IN ZFUIRootWindow *rootWindow
493 , ZF_IN ZFUIKeyEvent *event
494 ) {
495 rootWindow->_ZFP_ZFUIRootWindow_keyEvent(event);
496 }
497};
498
500#endif // #ifndef _ZFI_ZFUIRootWindow_h_
501
#define ZF_OUT_OPT
dummy macro that shows the param used as optional output
Definition ZFCoreTypeDef_ClassType.h:196
#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 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
#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(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_STATIC_0(ReturnType, MethodName)
see ZFMethod
Definition ZFMethodDeclare.h:708
#define ZFMETHOD_DECLARE_STATIC_2(ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMethod
Definition ZFMethodDeclare.h:1042
#define ZFMETHOD_DECLARE_STATIC_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodDeclare.h:870
#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_END(NameSpace)
end namespace
Definition ZFNamespace.h:60
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
#define ZF_NAMESPACE_BEGIN(NameSpace)
begin namespace
Definition ZFNamespace.h:40
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:126
#define ZFOBJECT_PRIVATE_ALLOC(...)
mark this object can not be allocated directly
Definition ZFObjectDeclare.h:245
#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:310
#define ZFEVENT_GLOBAL(ZFLIB_, YourEvent)
declare a observer event in global scope, see ZFEVENT
Definition ZFObjectObserver.h:351
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:128
#define ZFPROPERTY_ON_UPDATE_DECLARE(Type, Name)
see ZFPROPERTY_ON_INIT_DECLARE
Definition ZFPropertyDeclare.h:238
#define ZFLIB_ZFUIKit
used to export symbols
Definition ZFUIKitDef.h:16
root view for holding a ZFUIView's tree
v_ZFUIOrientation::ZFEnumType ZFUIOrientation
see v_ZFUIOrientation
Definition ZFUITypeDef.h:1145
void observerNotify(zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
notify the observer with eventId
key event for ui elements
Definition ZFUIKeyEvent.h:17
base class of all layout param in ZFUIView
Definition ZFUIViewType.h:123
margin
Definition ZFUITypeDef.h:147
see v_ZFUIOrientation, ZFUIOrientationFlagsToString, ZFUIOrientationFlagsFromString
Definition ZFUITypeDef.h:1145
2D rectangle
Definition ZFUITypeDef.h:636
root view for holding a ZFUIView's tree
Definition ZFUIRootView.h:20
impl for ZFUIRootWindow::nativeWindowEmbed
Definition ZFUIRootWindow.h:355
virtual void nativeWindowRootViewOnAdd(ZFUIRootWindow *rootWindow, void *&nativeParentView)=0
called to add root view to native window container
virtual void layoutParamOnInit(ZFUIRootWindow *rootWindow)
called to update suggested window layout param, fill with no margin by default
Definition ZFUIRootWindow.h:411
void notifyOnRotate(ZFUIRootWindow *rootWindow)
implementation must call this to notify when window rotate
Definition ZFUIRootWindow.h:485
virtual zfautoT< ZFUIRootWindow > modalWindowShow(ZFUIRootWindow *owner)=0
see ZFUIRootWindow::modalWindowShow
ZFUIRect notifyMeasureWindow(ZFUIRootWindow *rootWindow, const ZFUIRect &rootRefRect, const ZFUIMargin &windowMargin)
implementation must call this method to measure window's frame, and layout window using the result fr...
Definition ZFUIRootWindow.h:445
virtual ZFUIOrientation windowOrientation(ZFUIRootWindow *rootWindow)
see ZFUIRootWindow::windowOrientation
Definition ZFUIRootWindow.h:422
void notifyOnDestroy(ZFUIRootWindow *rootWindow)
implementation must call this to notify before window destroy
Definition ZFUIRootWindow.h:465
virtual void nativeWindowOnCleanup(ZFUIRootWindow *rootWindow)
called when owner ZFUIRootWindow is about to destroy
Definition ZFUIRootWindow.h:377
virtual void nativeWindowRootViewOnRemove(ZFUIRootWindow *rootWindow)=0
called to remove root view to native window container
void notifyOnCreate(ZFUIRootWindow *rootWindow, void *nativeWindow)
implementation must call this to notify after window create
Definition ZFUIRootWindow.h:456
void notifyKeyEvent(ZFUIRootWindow *rootWindow, ZFUIKeyEvent *event)
implementation must call this to notify key event
Definition ZFUIRootWindow.h:491
zfanyT< ZFUIRootWindow > const & ownerZFUIRootWindow(void)
the attached ZFUIRootWindow
Definition ZFUIRootWindow.h:363
void notifyOnPause(ZFUIRootWindow *rootWindow)
implementation must call this to notify before window pause, note that rotate a window should not not...
Definition ZFUIRootWindow.h:479
virtual void layoutParamOnUpdate(ZFUIRootWindow *rootWindow)
called when window layout param changed
Definition ZFUIRootWindow.h:416
virtual void windowOrientationFlags(ZFUIRootWindow *rootWindow, const ZFUIOrientationFlags &flags)
see ZFUIRootWindow::windowOrientationFlags, impl should have v_ZFUIOrientation::e_Top as init value
Definition ZFUIRootWindow.h:429
void notifyOnResume(ZFUIRootWindow *rootWindow)
implementation must call this to notify after window resume, note that rotate a window should not not...
Definition ZFUIRootWindow.h:472
virtual void modalWindowHide(ZFUIRootWindow *owner, ZFUIRootWindow *toHide)=0
see ZFUIRootWindow::modalWindowHide
root native window
Definition ZFUIRootWindow.h:34
static void keyWindow(ZFUIRootWindow *window)
default window that ZFUIWindow would attach to, set null to use mainWindow
virtual void windowMarginOnUpdate(const ZFUIMargin &windowMarginOld)
see E_WindowMarginOnUpdate
virtual void * nativeWindow()
access the internal native window
virtual void modalWindowHide()
finish and destroy self as a modal window
virtual void objectOnInitFinish(void)
called after objectOnInit, safe to call virtual functions here
virtual zfbool nativeWindowIsCreated()
true if sys window created
virtual void objectOnDeallocPrepare(void)
called before objectOnDealloc, safe to call virtual functions here
static zfautoT< ZFUIRootWindow > nativeWindowEmbedNativeView(void *nativeParent)
default impl to attach window to native view
virtual void objectOnDealloc(void)
override this to destroy your object
static zfbool mainWindowAttached()
whether mainWindow has attached
virtual zfanyT< ZFUIRootWindow > modalWindowOwner()
get self's owner if self is a showing modal window
virtual ZFUIOrientation windowOrientation()
get current orientation
static zfanyT< ZFUIRootWindow > mainWindow()
get application's main window
static zfidentity E_WindowOnKeyEvent(void)
see ZFObject::observerNotify
virtual zfanyT< ZFUIRootView > rootView()
access the root view of the window
static void nativeWindowEmbedNativeViewCleanup(const zfstring &rootWindowName)
remove window attached by nativeWindowEmbedNativeView
virtual zfbool nativeWindowIsResumed()
true if sys window resumed
virtual void nativeWindowEmbedImplDestroy()
util to destroy the window created by nativeWindowEmbed
virtual zfautoT< ZFUIRootWindow > modalWindowShow()
show a new modal window, may or may not show immediately, may have different behavior on different im...
virtual void objectOnInit(void)
override this to init your object
virtual zfanyT< ZFUIRootWindow > modalWindowShowing()
get self's current showing modal window
static void mainWindowRegister(ZFUIRootWindow *window)
manually register main window, must be called before accessing mainWindow
virtual const ZFUIMargin & windowMargin()
native window margin according to impl
virtual zfbool & preferFullscreen()
whether prefer fullscreen
Definition ZFUIRootWindow.h:294
virtual ZFUIRootWindowEmbedImpl * nativeWindowEmbedImpl(void)
see nativeWindowEmbed
static zfautoT< ZFUIRootWindow > nativeWindowEmbed(ZFUIRootWindowEmbedImpl *embedImpl)
used to embed ZFUIRootWindow to existing UI framework
virtual zfanyT< ZFUILayoutParam > layoutParam()
get window's layout param, fill parent by default
virtual const ZFUISize & windowSize()
native window's size
virtual void windowOrientationFlags(const ZFUIOrientationFlags &windowOrientationFlags)
set supported orientation, orientation may or may not change immediately
2D size
Definition ZFUITypeDef.h:397
@ e_Top
Top(1 << 1)
Definition ZFUITypeDef.h:1137
see zfany
Definition zfany.h:109
type restrict version of zfauto
Definition zfautoFwd.h:113
Definition ZFApp.h:13