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:
219
220public:
230 void _ZFP_ZFUIRootWindow_windowMargin(ZF_IN const ZFUIMargin &windowMargin);
231protected:
235 virtual void windowMarginOnUpdate(ZF_IN const ZFUIMargin &windowMarginOld);
236
237 ZFOBJECT_PRIVATE_ALLOC("can only be created by ZFUIRootWindow::modalWindowShow")
238protected:
240 virtual void objectOnInit(void);
242 virtual void objectOnInitFinish(void);
244 virtual void objectOnDeallocPrepare(void);
246 virtual void objectOnDealloc(void);
247
248public:
257
258public:
284
285public:
300
306
307public:
330
331public:
336
344
345public:
346 zffinal ZFUIRect _ZFP_ZFUIRootWindow_measureWindow(ZF_IN const ZFUIRect &rootRefRect);
347 zffinal void _ZFP_ZFUIRootWindow_onCreate(ZF_IN void *nativeWindow);
348 zffinal void _ZFP_ZFUIRootWindow_onDestroy(void);
349 zffinal void _ZFP_ZFUIRootWindow_onResume(void);
350 zffinal void _ZFP_ZFUIRootWindow_onPause(void);
351 zffinal void _ZFP_ZFUIRootWindow_onRotate(void);
352 zffinal void _ZFP_ZFUIRootWindow_layoutUpdate(void);
353 zffinal void _ZFP_ZFUIRootWindow_keyEvent(ZF_IN ZFUIKeyEvent *event) {
355 }
356
357private:
358 _ZFP_ZFUIRootWindowPrivate *d;
359};
360
361// ============================================================
365zfinterface ZFLIB_ZFUIKit ZFUIRootWindowEmbedImpl : zfextend ZFInterface {
366 ZFINTERFACE_DECLARE_WITH_CUSTOM_CTOR(ZFUIRootWindowEmbedImpl, ZFInterface)
367
368public:
369 zfanyT<ZFUIRootWindow> _ZFP_ownerZFUIRootWindow;
374 return this->_ZFP_ownerZFUIRootWindow;
375 }
376
377public:
379 ZFUIRootWindowEmbedImpl(void) : _ZFP_ownerZFUIRootWindow(zfnull) {}
381
382 // ============================================================
383public:
387 virtual void nativeWindowOnCleanup(ZF_IN ZFUIRootWindow *rootWindow) {
388 }
389
397 ZF_IN ZFUIRootWindow *rootWindow
398 , ZF_OUT_OPT void *&nativeParentView
404
412 virtual void modalWindowHide(
413 ZF_IN ZFUIRootWindow *owner
414 , ZF_IN ZFUIRootWindow *toHide
416
421 virtual void layoutParamOnInit(ZF_IN ZFUIRootWindow *rootWindow) {
422 }
423
426 virtual void layoutParamOnUpdate(ZF_IN ZFUIRootWindow *rootWindow) {
427 }
428
435
440 ZF_IN ZFUIRootWindow *rootWindow
441 , ZF_IN const ZFUIOrientationFlags &flags
442 ) {
443 }
444
448 virtual void windowColor(
449 ZF_IN ZFUIRootWindow *rootWindow
450 , ZF_IN const ZFUIColor &color
451 ) {
452 rootWindow->rootView()->bgColor(color);
453 }
454
455 // ============================================================
456 // callbacks that implementations must notify
457public:
466 ZF_IN ZFUIRootWindow *rootWindow
467 , ZF_IN const ZFUIRect &rootRefRect
468 , ZF_IN const ZFUIMargin &windowMargin
469 ) {
470 rootWindow->_ZFP_ZFUIRootWindow_windowMargin(windowMargin);
471 return rootWindow->_ZFP_ZFUIRootWindow_measureWindow(rootRefRect);
472 }
473
477 ZF_IN ZFUIRootWindow *rootWindow
478 , ZF_IN void *nativeWindow
479 ) {
480 rootWindow->_ZFP_ZFUIRootWindow_onCreate(nativeWindow);
481 }
482
486 rootWindow->_ZFP_ZFUIRootWindow_onDestroy();
487 }
488
493 rootWindow->_ZFP_ZFUIRootWindow_onResume();
494 }
495
500 rootWindow->_ZFP_ZFUIRootWindow_onPause();
501 }
502
506 rootWindow->_ZFP_ZFUIRootWindow_onRotate();
507 }
508
512 ZF_IN ZFUIRootWindow *rootWindow
513 , ZF_IN ZFUIKeyEvent *event
514 ) {
515 rootWindow->_ZFP_ZFUIRootWindow_keyEvent(event);
516 }
517};
518
520#endif // #ifndef _ZFI_ZFUIRootWindow_h_
521
#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:316
#define ZFEVENT_GLOBAL(ZFLIB_, YourEvent)
declare a observer event in global scope, see ZFEVENT
Definition ZFObjectObserver.h:357
#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
_zft_ZFUIColor ZFUIColor
color with AARRGGBB format
Definition ZFUITypeDef.h:1184
ZFUIColor const & ZFUIColorZero(void)
zero color
Definition ZFUITypeDef.h:1188
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:365
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:421
void notifyOnRotate(ZFUIRootWindow *rootWindow)
implementation must call this to notify when window rotate
Definition ZFUIRootWindow.h:505
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:465
virtual ZFUIOrientation windowOrientation(ZFUIRootWindow *rootWindow)
see ZFUIRootWindow::windowOrientation
Definition ZFUIRootWindow.h:432
void notifyOnDestroy(ZFUIRootWindow *rootWindow)
implementation must call this to notify before window destroy
Definition ZFUIRootWindow.h:485
virtual void nativeWindowOnCleanup(ZFUIRootWindow *rootWindow)
called when owner ZFUIRootWindow is about to destroy
Definition ZFUIRootWindow.h:387
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:476
void notifyKeyEvent(ZFUIRootWindow *rootWindow, ZFUIKeyEvent *event)
implementation must call this to notify key event
Definition ZFUIRootWindow.h:511
virtual void windowColor(ZFUIRootWindow *rootWindow, const ZFUIColor &color)
called when ZFUIRootWindow::windowColor changed
Definition ZFUIRootWindow.h:448
zfanyT< ZFUIRootWindow > const & ownerZFUIRootWindow(void)
the attached ZFUIRootWindow
Definition ZFUIRootWindow.h:373
void notifyOnPause(ZFUIRootWindow *rootWindow)
implementation must call this to notify before window pause, note that rotate a window should not not...
Definition ZFUIRootWindow.h:499
virtual void layoutParamOnUpdate(ZFUIRootWindow *rootWindow)
called when window layout param changed
Definition ZFUIRootWindow.h:426
virtual void windowOrientationFlags(ZFUIRootWindow *rootWindow, const ZFUIOrientationFlags &flags)
see ZFUIRootWindow::windowOrientationFlags, impl should have v_ZFUIOrientation::e_Top as init value
Definition ZFUIRootWindow.h:439
void notifyOnResume(ZFUIRootWindow *rootWindow)
implementation must call this to notify after window resume, note that rotate a window should not not...
Definition ZFUIRootWindow.h:492
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 ZFUIColor & windowColor()
window background color, ZFUIColorZero by default
Definition ZFUIRootWindow.h:217
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:304
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:113
type restrict version of zfauto
Definition zfautoFwd.h:108
Definition ZFApp.h:13