ZFFramework
 
Loading...
Searching...
No Matches
ZFUIView Class Reference

base class of all UI views More...

#include <ZFUIView.h>

Inheritance diagram for ZFUIView:
ZFStyle ZFObject ZFStyleable ZFSerializable ZFCopyable ZFInterface ZFInterface ZFInterface ZFUIAutoLayout ZFUIButton ZFUICell ZFUICellView ZFUIDrawableView ZFUIFlowLayout ZFUIImageView ZFUILinearLayout ZFUINativeViewWrapper ZFUIRootView ZFUIScrollView ZFUITextEdit ZFUITextView ZFUIViewLayout ZFUIWebView ZFUIWindow

Public Types

enum  
 
- Public Types inherited from ZFStyle
enum  
 
- Public Types inherited from ZFObject
enum  
 

Public Member Functions

virtual const ZFClassclassData (void)
 get instance's class info
 
virtual void serializableRefLayoutParam (ZFUILayoutParam *serializableRefLayoutParam)
 store ref layout param for this view for reducing serialization output size
 
virtual ZFUILayoutParamserializableRefLayoutParam (void)
 see serializableRefLayoutParam
 
virtual zfstringviewId ()
 used to identify a view, empty by default
 
virtual void viewId (zfstring const &propertyValue)
 see viewId
 
virtual zfboolvisible ()
 visible or not, zftrue by default
 
virtual void visible (zfbool const &propertyValue)
 see visible
 
virtual zfbool viewTreeInWindow ()
 true if added to ZFUISysWindow
 
virtual zfbool viewTreeVisible ()
 true only if added to ZFUISysWindow and all of parents are visible
 
virtual zffloatalpha ()
 view's alpha, 1 by default
 
virtual void alpha (zffloat const &propertyValue)
 see alpha
 
virtual zfboolviewUIEnable ()
 whether the view should receive user interaction (doesn't affect children, see viewUIEnableTree)
 
virtual void viewUIEnable (zfbool const &propertyValue)
 see viewUIEnable
 
virtual zfboolviewUIEnableTree ()
 whether the view as well as all its children should receive user interaction, see viewUIEnable
 
virtual void viewUIEnableTree (zfbool const &propertyValue)
 see viewUIEnableTree
 
virtual zfbool viewUIEnableFixed ()
 true if viewUIEnable and all of parents are viewUIEnableTree
 
virtual zfbool viewUIEnableTreeFixed ()
 true if viewUIEnableTree and all of parents are viewUIEnableTree
 
virtual zfboolmouseHoverEnable ()
 whether enable mouse hover event, see ZFUIView::viewEventOnMouseEvent, false by default
 
virtual void mouseHoverEnable (zfbool const &propertyValue)
 see mouseHoverEnable
 
virtual zfboolfocusable ()
 whether the view can be focused, false by default
 
virtual void focusable (zfbool const &propertyValue)
 see focusable
 
virtual zfboolfocusObtainWhenClick ()
 whether try to obtain focus when clicked down, true by default
 
virtual void focusObtainWhenClick (zfbool const &propertyValue)
 see focusObtainWhenClick
 
virtual ZFUIRect const & viewFrame ()
 the view's frame
 
virtual void viewFrame (ZFUIRect const &viewFrame)
 see viewFrame
 
virtual const ZFUIRectviewFramePrev ()
 previous viewFrame
 
virtual zfbool viewFrameOverrided ()
 true if viewFrame changed by user, use viewFrameReset to reset
 
virtual void viewFrameReset ()
 see viewFrame
 
virtual zffloat x ()
 see viewFrame
 
virtual void x (zffloat const &propertyValue)
 see viewFrame
 
virtual zffloat y ()
 see viewFrame
 
virtual void y (zffloat const &propertyValue)
 see viewFrame
 
virtual zffloat width ()
 see viewFrame
 
virtual void width (zffloat const &propertyValue)
 see viewFrame
 
virtual zffloat height ()
 see viewFrame
 
virtual void height (zffloat const &propertyValue)
 see viewFrame
 
virtual zffloat centerX ()
 see viewFrame
 
virtual void centerX (zffloat const &propertyValue)
 see viewFrame
 
virtual zffloat centerY ()
 see viewFrame
 
virtual void centerY (zffloat const &propertyValue)
 see viewFrame
 
virtual void viewSizeFixed (const ZFUISize &size)
 util method to set fixed size, by setting both of viewSizeMin and viewSizeMax
 
virtual void viewSizeFixed (zffloat width, zffloat height)
 see viewSizeFixed
 
virtual ZFUISizeviewSizeMin ()
 min size, ZFUISizeZero by default
 
virtual void viewSizeMin (ZFUISize const &propertyValue)
 see viewSizeMin
 
virtual ZFUISizeviewSizeMax ()
 max size, negative value means not set, ZFUISizeInvalid by default
 
virtual void viewSizeMax (ZFUISize const &propertyValue)
 see viewSizeMax
 
virtual ZFUIColorbgColor ()
 background color, ZFUIColorZero by default
 
virtual void bgColor (ZFUIColor const &propertyValue)
 see bgColor
 
virtual zffloattranslateX ()
 see transformAvailable
 
virtual void translateX (zffloat const &propertyValue)
 see translateX
 
virtual zffloattranslateY ()
 see transformAvailable
 
virtual void translateY (zffloat const &propertyValue)
 see translateY
 
virtual zffloattranslateZ ()
 see transformAvailable
 
virtual void translateZ (zffloat const &propertyValue)
 see translateZ
 
virtual zffloatscaleX ()
 see transformAvailable
 
virtual void scaleX (zffloat const &propertyValue)
 see scaleX
 
virtual zffloatscaleY ()
 see transformAvailable
 
virtual void scaleY (zffloat const &propertyValue)
 see scaleY
 
virtual zffloatscaleZ ()
 see transformAvailable
 
virtual void scaleZ (zffloat const &propertyValue)
 see scaleZ
 
virtual zffloatrotateX ()
 see transformAvailable
 
virtual void rotateX (zffloat const &propertyValue)
 see rotateX
 
virtual zffloatrotateY ()
 see transformAvailable
 
virtual void rotateY (zffloat const &propertyValue)
 see rotateY
 
virtual zffloatrotateZ ()
 see transformAvailable
 
virtual void rotateZ (zffloat const &propertyValue)
 see rotateZ
 
virtual void bind (ZFObject *owner, const zfstring &propertyName)
 util method to bind this view to owner's property, and auto setup viewId if not set
 
virtual void bindEvent (const zfstring &eventName, ZFObject *owner, const zfstring &methodName)
 util method to bind this view's event to owner's method
 
virtual void bindEvent (zfidentity eventId, ZFObject *owner, const zfstring &methodName)
 util method to bind this view's event to owner's method, see bindEvent
 
virtual void * nativeImplView ()
 native implementation view
 
virtual zfbool nativeImplViewRequireVirtualIndex ()
 whether the nativeImplView cost one virtualIndex
 
virtual const ZFUIMarginnativeImplViewMargin ()
 inner margin between ZFUIView and the internal nativeImplView
 
virtual void nativeImplViewMarginUpdate ()
 see nativeImplViewMargin, layoutRequest if the final value actually changed
 
virtual const ZFUIRectnativeImplViewFrame ()
 frame of nativeImplView
 
virtual ZFUIMarginnativeImplViewMarginCustom ()
 see nativeImplViewMargin, ZFUIMarginZero by default
 
virtual void nativeImplViewMarginCustom (ZFUIMargin const &propertyValue)
 see nativeImplViewMarginCustom
 
virtual void * nativeView ()
 native container view
 
virtual zfbool focused ()
 whether the view currently focused
 
virtual void focusRequest (zfbool focus)
 request to obtain or resign focus, result can be checked by focused
 
virtual zfanyT< ZFUIViewfocusFind ()
 recursively to find focused child, take care of performance
 
virtual zfanyT< ZFUIViewparent ()
 parent view or null if none
 
virtual void removeFromParent ()
 remove this view from parent or do nothing if no parent
 
virtual zffloatUIScale ()
 UI scale for view tree.
 
virtual void UIScale (zffloat const &propertyValue)
 see UIScale
 
virtual zffloat UIScaleInherited ()
 see UIScale
 
virtual zffloat UIScaleForImpl ()
 see UIScale
 
virtual zffloat UIScaleForPixel ()
 see UIScale
 
virtual zffloat UIScaleFixed ()
 see UIScale
 
virtual zfautoT< ZFUILayoutParamlayoutParamCreate ()
 create layout param, calling layoutParamClass to create instance and layoutParamOnUpdate to update
 
virtual void layoutParam (ZFUILayoutParam *layoutParam)
 manually set layout param
 
virtual zfanyT< ZFUILayoutParamlayoutParam ()
 get self's layout param, valid only while the view has parent
 
virtual void layoutRequest ()
 set need layout
 
virtual zfbool layoutRequested ()
 true if need layout
 
virtual zfbool layouting ()
 true if currently being layouted
 
virtual const ZFUISizelayoutMeasure (const ZFUISize &sizeHint, const ZFUISizeParam &sizeParam)
 measure the view
 
virtual const ZFUISizelayoutMeasuredSize ()
 get measured size, invalid if not measured
 
virtual void layoutIfNeed ()
 force to layout if need
 
virtual ZFUIPoint layoutChildOffset ()
 get child offset to this view
 
virtual zfanyT< ZFUIViewchildFindById (const zfstring &viewId, zfbool findRecursively=(_ZFT_t_zftrue), zfbool includeInternalViews=(_ZFT_t_zffalse))
 find view by viewId, return the view or null if not found
 
virtual zfanyT< ZFUIViewchildFindByClass (const ZFClass *cls, zfbool findRecursively=(_ZFT_t_zftrue), zfbool includeInternalViews=(_ZFT_t_zffalse))
 find view by class, return the view or null if not found
 
virtual zfauto childForEach (const ZFListener &impl, zfbool findRecursively=(_ZFT_t_zftrue), zfbool includeInternalViews=(_ZFT_t_zffalse))
 call custom impl for each child
 
virtual zfanyT< ZFUILayoutParamchildWithParam (ZFUIView *view, ZFUILayoutParam *layoutParam, zfindex atIndex=(((zfindex) -1)))
 add view with layout param, param must be created by layoutParamCreate
 
zfanyT< ZFUILayoutParamchild (const zfany &view, zfindex atIndex=((zfindex) -1))
 add child and return child's layoutParam, see childWithParam
 
virtual void childRemove (ZFUIView *view)
 remove view or do nothing if view isn't added to this view
 
virtual void childRemoveAt (zfindex index)
 remove view at index or assert fail if index out of range
 
virtual void childRemoveAll ()
 remove all child view
 
virtual void childMove (zfindex fromIndex, zfindex toIndexOrIndexMax)
 move view, make toIndexOrIndexMax as zfindexMax() to move to top most, and 0 to bottom most, do nothing if index invalid or have no change
 
virtual void childMove (ZFUIView *child, zfindex toIndexOrIndexMax)
 see childMove
 
virtual void childReplaceAt (zfindex atIndex, ZFUIView *toReplace)
 replace child at index, assert fail if index out of range or view to replace already has parent
 
virtual zfindex childCount ()
 get child view count
 
virtual zfanyT< ZFUIViewchildAt (zfindex index)
 get child view at index or assert fail if out of range
 
virtual zfindex childFind (ZFUIView *view)
 return index of view or zfindexMax() if not child of this view
 
virtual ZFCoreArray< zfautoT< ZFUIView > > childArray ()
 get the child view array
 
virtual ZFUIViewChildLayer viewLayer ()
 this view belongs to which layer of parent, valid only if parent is not null
 
virtual ZFCoreArray< zfautoT< ZFUIView > > childRawArray ()
 return all children including internal views, see childArray
 
virtual zfanyT< ZFUILayoutParaminternalImplViewAdd (ZFUIView *view, ZFUILayoutParam *layoutParam=(zft_zfnull), zfbool addAsTopMost=(_ZFT_t_zftrue))
 see internalBgViewAdd
 
virtual void internalImplViewRemove (ZFUIView *view)
 see internalBgViewAdd
 
virtual ZFCoreArray< zfautoT< ZFUIView > > internalImplViewArray ()
 see internalBgViewAdd
 
virtual zfanyT< ZFUILayoutParaminternalBgViewAdd (ZFUIView *view, ZFUILayoutParam *layoutParam=(zft_zfnull), zfbool addAsTopMost=(_ZFT_t_zftrue))
 internal view which is independent from normal view
 
virtual void internalBgViewRemove (ZFUIView *view)
 see internalBgViewAdd
 
virtual ZFCoreArray< zfautoT< ZFUIView > > internalBgViewArray ()
 usually for debug use only, try to avoid use this in your app for other purpose
 
virtual zfanyT< ZFUILayoutParaminternalFgViewAdd (ZFUIView *view, ZFUILayoutParam *layoutParam=(zft_zfnull), zfbool addAsTopMost=(_ZFT_t_zftrue))
 see internalBgViewAdd
 
virtual void internalFgViewRemove (ZFUIView *view)
 see internalBgViewAdd
 
virtual ZFCoreArray< zfautoT< ZFUIView > > internalFgViewArray ()
 see internalBgViewAdd
 
virtual void internalViewAutoSerializeTagAdd (const zfstring &tag)
 used to apply auto serialize logic to internal views
 
virtual void internalViewAutoSerializeTagRemove (const zfstring &tag)
 see internalViewAutoSerializeTagAdd
 
virtual void internalViewAutoSerializeTagRemoveAll ()
 see internalViewAutoSerializeTagAdd
 
virtual void internalViewAutoSerializeTagGetAllT (ZFCoreArray< zfstring > &ret)
 see internalViewAutoSerializeTagAdd
 
virtual ZFCoreArray< zfstringinternalViewAutoSerializeTagGetAll ()
 see internalViewAutoSerializeTagAdd
 
virtual void viewEventSend (ZFUIEvent *event)
 directly send a event, use with caution
 
- Public Member Functions inherited from ZFObject
zfindex objectRetainCount (void)
 return the object's retain count
 
void objectInfoOfInstanceT (zfstring &ret)
 see objectInfoOfInstance
 
zfstring objectInfoOfInstance (void)
 return a short string describe the object instance
 
void objectInfoT (zfstring &ret)
 see objectInfo
 
zfstring objectInfo (void)
 return object info
 
zfidentity objectHash (void)
 get hash of this object
 
ZFCompareResult objectCompare (ZFObject *anotherObj)
 compare with anotherObj
 
ZFCompareResult objectCompareValue (ZFObject *anotherObj)
 explicitly compare object by logical value, see objectCompare
 
virtual zfauto invoke (const zfstring &methodName)
 util method to perform ZFDI_invoke, do nothing if fail
 
virtual zfauto invoke (const zfstring &methodName, ZFObject *param0, ZFObject *param1=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param2=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param3=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param4=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param5=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param6=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param7=((ZFObject *const &) _ZFP_ZFMP_DEF))
 util method to perform ZFDI_invoke, do nothing if fail
 
virtual zfbool invokeT (zfauto &ret, zfstring *errorHint, const zfstring &methodName, ZFObject *param0=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param1=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param2=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param3=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param4=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param5=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param6=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param7=((ZFObject *const &) _ZFP_ZFMP_DEF))
 util method to perform ZFDI_invoke, do nothing if fail
 
virtual zfauto invokeDetail (const zfstring &methodName, const ZFCoreArray< zfauto > &params, zfbool *success=zft_zfnull, zfstring *errorHint=zft_zfnull)
 util method to perform ZFDI_invoke, do nothing if fail
 
zfbool objectTagExist (void)
 see objectTag, true if this object has tag, and tag can be checked by objectTagGetAllKeyValue
 
void objectTag (const zfstring &key, ZFObject *tag)
 used to hold a object for app's use, auto retained
 
zfany objectTag (const zfstring &key)
 see objectTag
 
void objectTagGetAllKeyValue (ZFCoreArray< zfstring > &allKey, ZFCoreArray< zfauto > &allValue)
 get all key value
 
void objectTagRemove (const zfstring &key)
 remove tag, same as set tag to null
 
zfauto objectTagRemoveAndGet (const zfstring &key)
 remove tag, return removed tag or null if not exist
 
void objectTagRemoveAll (void)
 remove all tag
 
void observerAdd (zfidentity eventId, const ZFListener &observer, ZFLevel observerLevel=ZFLevelAppNormal)
 see observerNotify
 
void observerAddForOnce (zfidentity eventId, const ZFListener &observer, ZFLevel observerLevel=ZFLevelAppNormal)
 see observerNotify
 
void observerRemove (zfidentity eventId, const ZFListener &callback)
 see observerNotify
 
void observerRemoveAll (zfidentity eventId)
 see observerNotify
 
void observerRemoveAll (void)
 see observerNotify
 
zfbool observerHasAdd (void)
 true if any observer has been added
 
zfbool observerHasAdd (zfidentity eventId)
 true if any observer with eventId has been added
 
void observerNotify (zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
 notify the observer with eventId
 
void observerNotifyWithSender (ZFObject *customSender, zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
 see observerNotify
 
void observerNotifyReversely (zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
 see observerNotify
 
void observerNotifyReverselyWithSender (ZFObject *customSender, zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
 see observerNotify
 
ZFObserverobserverHolder (void)
 access the internal observer holder
 
void on (const zfstring &eventName, const ZFListener &observer, ZFLevel observerLevel=ZFLevelAppNormal)
 util to observerAdd
 
void on (zfidentity eventId, const ZFListener &observer, ZFLevel observerLevel=ZFLevelAppNormal)
 util to observerAdd
 
void onInit (const ZFListener &impl)
 util for script to achieve chained call
 
void onDealloc (const ZFListener &impl)
 util for script to achieve chained call
 
zfbool objectInstanceStateCheck (ZFObjectInstanceState state)
 object instance's state
 
zfbool objectInitRunning (void)
 util method to check whether ZFObjectInstanceStateOnInit or ZFObjectInstanceStateOnInitFinish running
 
zfbool objectDeallocRunning (void)
 util method to check whether ZFObjectInstanceStateOnDeallocPrepare or ZFObjectInstanceStateOnDealloc running
 
virtual zfbool objectIsInternal (void)
 whether this object is internal object or its class is ZFClass::classIsInternal
 
virtual zfbool objectIsInternalPrivate (void)
 whether this object is internal private object or its class is ZFClass::classIsInternalPrivate
 
- Public Member Functions inherited from ZFStyleable
virtual zfanyT< ZFStyleabledefaultStyle (void)
 return default style of this instance
 
void styleableCopyFrom (ZFObject *anotherStyleable)
 copy style from another styleable, see ZFStyleable
 
virtual zfbool styleableIsDefaultStyle (void)
 true if this object is defaultStyle
 
void styleablePropertyGetAllT (ZFCoreArray< const ZFProperty * > &ret)
 return a list of styleable property, for debug use only
 
ZFCoreArray< const ZFProperty * > styleablePropertyGetAll (void)
 return a list of styleable property, for debug use only
 
void styleKey (const zfstring &styleKey)
 see ZFStyleSet
 
const zfstringstyleKey (void)
 see ZFStyleSet
 
void propStyle (const zfstring &propertyName, const zfstring &styleKey)
 see ZFStyleSet
 
const zfstringpropStyle (const zfstring &propertyName)
 see ZFStyleSet
 
- Public Member Functions inherited from ZFInterface
virtual ZFObjecttoObject (void)=0
 convert to ZFObject type
 
- Public Member Functions inherited from ZFSerializable
zfbool serializable (void)
 true if object is currently serializable, see ZFSerializable
 
zfbool serializeFromData (const ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull)
 serialize from data, see ZFSerializable
 
zfbool serializeToData (ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializable *refOwner=zft_zfnull)
 serialize to data, see ZFSerializable
 
zfbool serializeFromString (const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull)
 serialize from string, return false by default
 
zfbool serializeToString (zfstring &ret, zfstring *errorHint=zft_zfnull)
 see serializeFromString
 
void serializablePropertyTypeGetAll (ZFCoreArray< const ZFProperty * > &notSerializableProperty, ZFCoreArray< const ZFProperty * > &serializableProperty, ZFCoreArray< const ZFProperty * > &embededProperty)
 return a list of each type of property, for debug use only
 
zfstring serializablePropertyTypeInfo (void)
 return info of serializablePropertyTypeGetAll, for debug use only
 
void serializableGetAllSerializablePropertyT (ZFCoreArray< const ZFProperty * > &ret)
 see serializableGetAllSerializableProperty
 
ZFCoreArray< const ZFProperty * > serializableGetAllSerializableProperty (void)
 get all serializable property, usually for debug only, see serializableOnCheckPropertyType
 
void serializableGetAllSerializableEmbededPropertyT (ZFCoreArray< const ZFProperty * > &ret)
 see serializableGetAllSerializableEmbededProperty
 
ZFCoreArray< const ZFProperty * > serializableGetAllSerializableEmbededProperty (void)
 get all serializable embeded property, usually for debug only, see serializableOnCheckPropertyType
 
virtual void serializableInfoT (zfstring &ret)
 get info as a serializable
 
virtual zfstring serializableInfo (void)
 see serializableInfoT
 
- Public Member Functions inherited from ZFCopyable
zfautoT< ZFCopyablecopy (void)
 return a copy of this object
 
void copyFrom (ZFObject *anotherObj)
 see copy, anotherObj must be same type as this object (by classData), otherwise, do nothing
 

Static Public Member Functions

static const ZFClassClassData (void)
 get class info
 
static zfanyT< ZFUIViewDefaultStyle (void)
 
static zfidentity E_ViewTreeInWindowOnUpdate (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewTreeVisibleOnUpdate (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewChildOnUpdate (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewChildOnAdd (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewChildOnRemove (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewOnAddToParent (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewOnRemoveFromParent (void)
 see ZFObject::observerNotify
 
static zfidentity E_UIScaleOnUpdate (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewFocusOnUpdate (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewOnEvent (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewLayoutOnLayoutRequest (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewLayoutOnMeasure (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewLayoutOnLayoutPrepare (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewLayoutOnLayout (void)
 see ZFObject::observerNotify
 
static zfidentity E_ViewLayoutOnLayoutFinish (void)
 see ZFObject::observerNotify
 
static zfidentity E_NativeImplViewMarginOnUpdate (void)
 see ZFObject::observerNotify
 
static ZFUITransformFlags transformAvailable ()
 whether transform is supported
 
- Static Public Member Functions inherited from ZFStyle
static const ZFClassClassData (void)
 get class info
 
- Static Public Member Functions inherited from ZFObject
static const ZFClassClassData (void)
 get class info
 
static zfidentity E_ObjectBeforeAlloc (void)
 see ZFObject::observerNotify
 
static zfidentity E_ObjectAfterAlloc (void)
 see ZFObject::observerNotify
 
static zfidentity E_ObjectBeforeDealloc (void)
 see ZFObject::observerNotify
 
static zfidentity E_ObjectPropertyValueOnUpdate (void)
 see ZFObject::observerNotify
 
static zfidentity E_ObjectPropertyValueOnReset (void)
 see ZFObject::observerNotify
 
- Static Public Member Functions inherited from ZFStyleable
static const ZFClassClassData (void)
 get class info
 
- Static Public Member Functions inherited from ZFInterface
static const ZFClassClassData (void)
 get class info
 
- Static Public Member Functions inherited from ZFSerializable
static const ZFClassClassData (void)
 get class info
 
- Static Public Member Functions inherited from ZFCopyable
static const ZFClassClassData (void)
 get class info
 

Protected Types

typedef ZFStyle zfsuper
 class ref to super
 
typedef ZFUIView zfself
 class ref to self
 
- Protected Types inherited from ZFStyle
typedef ZFObject zfsuper
 class ref to super
 
typedef ZFStyle zfself
 class ref to self
 
- Protected Types inherited from ZFObject
typedef _ZFP_Obj_Base zfsuper
 class ref to super
 
typedef ZFObject zfself
 class ref to self
 
- Protected Types inherited from ZFStyleable
typedef ZFInterface zfsuper
 typedef for super (always ZFInterface for an interface type)
 
typedef ZFStyleable zfself
 typedef for self
 
- Protected Types inherited from ZFInterface
typedef _ZFP_ObjI_Base zfsuper
 typedef for super (always ZFInterface for an interface type)
 
typedef ZFInterface zfself
 typedef for self
 
- Protected Types inherited from ZFSerializable
typedef ZFInterface zfsuper
 typedef for super (always ZFInterface for an interface type)
 
typedef ZFSerializable zfself
 typedef for self
 
- Protected Types inherited from ZFCopyable
typedef ZFInterface zfsuper
 typedef for super (always ZFInterface for an interface type)
 
typedef ZFCopyable zfself
 typedef for self
 

Protected Member Functions

virtual zfbool serializableOnSerializeFromData (const ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull)
 for serializable data that has "category" attribute, ZFSerializable would ignore it and leave it to subclass to resolve, see ZFSerializable
 
virtual zfbool serializableOnSerializeToData (ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializable *refOwner=zft_zfnull)
 corresponding to serializableOnSerializeFromData, return whether the task is success, see ZFSerializable
 
virtual zfbool serializableOnCheckNeedSerializeChildren (void)
 whether we should serialize all children
 
virtual void objectOnInit (void)
 override this to init your object
 
virtual void objectOnDealloc (void)
 override this to destroy your object
 
virtual void objectOnDeallocPrepare (void)
 called before objectOnDealloc, safe to call virtual functions here
 
virtual void objectInfoImplAppend (zfstring &ret)
 see objectInfo
 
virtual void nativeImplView (void *nativeImplView, ZFUIViewNativeImplViewDeleteCallback nativeImplViewDeleteCallback, zfbool nativeImplViewRequireVirtualIndex)
 see nativeImplView
 
virtual void nativeImplViewMarginImplUpdate (ZFUIMargin &nativeImplViewMargin)
 see nativeImplViewMargin, subclass must call super and "append" to existing margin
 
virtual void nativeImplViewMarginOnUpdate (void)
 see E_NativeImplViewMarginOnUpdate
 
virtual void nativeImplViewOnLayout (ZFUIRect &ret, const ZFUIRect &bounds, const ZFUIMargin &nativeImplViewMargin)
 called to layout nativeImplView
 
virtual void implChildOnAdd (ZFUIView *child, zfindex virtualIndex, ZFUIViewChildLayer childLayer, zfindex childLayerIndex)
 called to add or remove view to impl
 
virtual void implChildOnRemove (ZFUIView *child, zfindex virtualIndex, ZFUIViewChildLayer childLayer, zfindex childLayerIndex)
 see implChildOnAdd, implChildOnRemoveAllForDealloc
 
virtual void implChildOnRemoveAllForDealloc (void)
 called to remove all children during parent dealloc for performance
 
virtual void focusOnUpdate (void)
 see E_ViewFocusOnUpdate
 
virtual void UIScaleOnUpdate (void)
 see UIScale, ensured called only when scale value actually changed
 
virtual const ZFClasslayoutParamClass (void)
 see layoutParamCreate
 
virtual void layoutParamOnUpdate (ZFUILayoutParam *layoutParam)
 see layoutParamCreate
 
virtual void layoutOnLayoutRequest (void)
 called during layoutRequest
 
virtual void layoutOnMeasure (ZFUISize &ret, const ZFUISize &sizeHint, const ZFUISizeParam &sizeParam)
 called by layoutMeasure to decide the view's size
 
virtual void layoutOnMeasureFinish (ZFUISize &measuredSize, const ZFUISize &sizeHint, const ZFUISizeParam &sizeParam)
 see E_ViewLayoutOnMeasure
 
virtual void layoutOnLayoutPrepare (const ZFUIRect &bounds)
 see E_ViewLayoutOnLayoutPrepare
 
virtual void layoutOnLayout (const ZFUIRect &bounds)
 called by viewFrame to layout the view and children
 
virtual void layoutOnLayoutFinish (const ZFUIRect &bounds)
 see E_ViewLayoutOnLayoutFinish
 
virtual void layoutChildOffsetOnUpdate (ZFUIPoint &ret)
 see layoutChildOffset
 
virtual void viewTreeInWindowOnUpdate (void)
 see E_ViewTreeInWindowOnUpdate
 
virtual void viewTreeVisibleOnUpdate (void)
 see E_ViewTreeVisibleOnUpdate
 
virtual void viewChildOnUpdate (void)
 see E_ViewChildOnUpdate
 
virtual void viewChildOnAdd (ZFUIView *child, ZFUIViewChildLayer childLayer)
 see E_ViewChildOnAdd
 
virtual void viewChildOnRemove (ZFUIView *child, ZFUIViewChildLayer childLayer)
 see E_ViewChildOnRemove
 
virtual void viewOnAddToParent (ZFUIView *parent)
 see E_ViewOnAddToParent
 
virtual void viewOnRemoveFromParent (ZFUIView *parent)
 see E_ViewOnRemoveFromParent
 
virtual zfbool internalViewShouldLayout (ZFUIView *internalView)
 called to check whether the internal view should be layouted using default layout logic, return true by default
 
virtual void internalViewOnLayout (const ZFUIRect &bounds)
 see internalBgViewAdd
 
virtual void viewEventOnEvent (ZFUIEvent *event)
 notified when a ZFUIEvent occurred
 
virtual void viewEventOnMouseEvent (ZFUIMouseEvent *mouseEvent)
 called when mouse event occurred
 
virtual void viewEventOnKeyEvent (ZFUIKeyEvent *keyEvent)
 called when key occurred
 
virtual void viewEventOnKeyEventResolveFocus (ZFUIKeyEvent *keyEvent)
 called by viewEventOnKeyEvent to resolve focus move key event
 
virtual void viewEventOnWheelEvent (ZFUIWheelEvent *wheelEvent)
 called when wheel event occurred
 
virtual void styleableOnCopyFrom (ZFObject *anotherStyleable)
 for a view, copy style would also copy all of it's children
 
virtual void observerOnAdd (zfidentity eventId)
 called when add first observer
 
virtual void observerOnRemove (zfidentity eventId)
 called when remove last observer
 
- Protected Member Functions inherited from ZFStyle
virtual void copyableOnCopyFrom (ZFObject *anotherObj)
 called by copy to copy contents from anotherObj
 
- Protected Member Functions inherited from ZFObject
virtual void objectInfoImpl (zfstring &ret)
 see objectInfo
 
virtual zfidentity objectHashImpl (void)
 see objectHash
 
virtual ZFCompareResult objectCompareImpl (ZFObject *anotherObj)
 see objectCompare
 
virtual ZFCompareResult objectCompareValueImpl (ZFObject *anotherObj)
 see objectCompareValue
 
virtual void observerOnEvent (const ZFArgs &zfargs)
 notified when observerNotify
 
virtual void objectOnInitFinish (void)
 called after objectOnInit, safe to call virtual functions here
 
virtual void objectOnRetain (void)
 called to retain object
 
virtual void objectOnRelease (void)
 called to release object
 
virtual void objectPropertyValueOnUpdate (const ZFProperty *property, const void *oldValue)
 see E_ObjectPropertyValueOnUpdate
 
virtual void objectPropertyValueOnReset (const ZFProperty *property)
 see E_ObjectPropertyValueOnReset
 
- Protected Member Functions inherited from ZFStyleable
virtual void styleableOnCopyPropertyFrom (ZFObject *anotherStyleable, const ZFProperty *property)
 copy property with styleable logic
 
- Protected Member Functions inherited from ZFSerializable
virtual ZFSerializablePropertyType serializableOnCheckPropertyType (const ZFProperty *property)
 check the property type that serializable should do what while serializing
 
virtual zfbool serializableOnCheck (void)
 see serializable
 
virtual zfbool serializableOnSerializePropertyFromData (const ZFSerializableData &propertyData, const ZFProperty *property, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull)
 see serializableOnCheckPropertyType, usually you have no need to override this method, see ZFSerializable
 
virtual zfbool serializableOnSerializePropertyToData (ZFSerializableData &ownerData, const ZFProperty *property, zfstring *outErrorHint=zft_zfnull, ZFSerializable *refOwner=zft_zfnull)
 see serializableOnCheckPropertyType, usually you have no need to override this method, see ZFSerializable
 
virtual zfbool serializableOnSerializeEmbededPropertyFromData (const ZFSerializableData &propertyData, const ZFProperty *property, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull)
 see serializableOnCheckPropertyType, usually you have no need to override this method, see ZFSerializable
 
virtual zfbool serializableOnSerializeEmbededPropertyToData (ZFSerializableData &ownerData, const ZFProperty *property, ZFSerializable *refOwner, zfstring *outErrorHint=zft_zfnull)
 see serializableOnCheckPropertyType, usually you have no need to override this method, see ZFSerializable
 
virtual zfbool serializableOnSerializeFromString (const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull)
 see serializeFromString
 
virtual zfbool serializableOnSerializeToString (zfstring &ret, zfstring *errorHint=zft_zfnull)
 see serializeFromString
 

Detailed Description

base class of all UI views

ZFUIView has these layer of views:

  • internal impl view: for subclass to add views behind native impl view
  • internal native view: for impl to achieve different functions, internal use only
  • internal background view: for subclass to add background views
  • normal view: common children views
  • internal foreground view: for subclass to add foreground views

all view layer is implemented internally by simple view management

ZFUIView is serializable and styleable, see ZFSerializable and ZFStyleable for more info, all property and normal children views would be serialized and styled automatically, but internal views must be processed by subclass manually

serializable data:

<ViewClass>
// optional, see #internalViewAutoSerializeTagAdd
<ChildClass category="internalImplView" >
// optional, see #internalViewAutoSerializeTagAdd
<ChildClass category="internalBgView" >
</ChildClass>
// optional, see #internalViewAutoSerializeTagAdd
<ChildClass category="internalFgView" >
</ChildClass>
<ChildClass category="child" >
// layout param for parent, optional
<LayoutParamClass category="layoutParam" ... />
</ChildClass>
... // all children
</ViewClass>

by default, internal views won't be serialized automatically, except matches these condition:


ADVANCED:
we allow add native view to ZFUIView environment, for how to, refer to ZFUINativeViewWrapper
we also allow add ZFUIView to native view, for how to, refer to ZFUISysWindow::nativeWindowEmbed

Member Function Documentation

◆ classData()

◆ DefaultStyle()

static zfanyT< ZFUIView > ZFUIView::DefaultStyle ( void )
static


default style for ZFUIView

◆ E_ViewTreeInWindowOnUpdate()

static zfidentity ZFUIView::E_ViewTreeInWindowOnUpdate ( void )
static

see ZFObject::observerNotify

called when viewTreeInWindow changed

◆ E_ViewTreeVisibleOnUpdate()

static zfidentity ZFUIView::E_ViewTreeVisibleOnUpdate ( void )
static

see ZFObject::observerNotify

called when viewTreeVisible changed

◆ E_ViewChildOnUpdate()

static zfidentity ZFUIView::E_ViewChildOnUpdate ( void )
static

see ZFObject::observerNotify

called when child added or removed or order changed, may be normal child or internal child

◆ E_ViewChildOnAdd()

static zfidentity ZFUIView::E_ViewChildOnAdd ( void )
static

see ZFObject::observerNotify

called when child added to this view, param0 is the child, param1 is ZFUIViewChildLayer

◆ E_ViewChildOnRemove()

static zfidentity ZFUIView::E_ViewChildOnRemove ( void )
static

see ZFObject::observerNotify

called when child removed from this view, param0 is the child, param1 is ZFUIViewChildLayer

◆ E_ViewOnAddToParent()

static zfidentity ZFUIView::E_ViewOnAddToParent ( void )
static

see ZFObject::observerNotify

called when this view added to parent, param0 is the parent added to

◆ E_ViewOnRemoveFromParent()

static zfidentity ZFUIView::E_ViewOnRemoveFromParent ( void )
static

see ZFObject::observerNotify

param0 is the parent removed from

◆ E_UIScaleOnUpdate()

static zfidentity ZFUIView::E_UIScaleOnUpdate ( void )
static

see ZFObject::observerNotify

called when this view or parent view's UIScale or UIScaleFixed changed

◆ E_ViewFocusOnUpdate()

static zfidentity ZFUIView::E_ViewFocusOnUpdate ( void )
static

see ZFObject::observerNotify

called when view's focus state changed, both obtain or resign

◆ E_ViewOnEvent()

static zfidentity ZFUIView::E_ViewOnEvent ( void )
static

◆ E_ViewLayoutOnLayoutRequest()

static zfidentity ZFUIView::E_ViewLayoutOnLayoutRequest ( void )
static

see ZFObject::observerNotify

called when layoutRequest called

◆ E_ViewLayoutOnMeasure()

static zfidentity ZFUIView::E_ViewLayoutOnMeasure ( void )
static

see ZFObject::observerNotify

param0 is a ZFUIViewMeasureResult, you may change the measured size to override the measure result

◆ E_ViewLayoutOnLayoutPrepare()

static zfidentity ZFUIView::E_ViewLayoutOnLayoutPrepare ( void )
static

see ZFObject::observerNotify

viewFrame would be updated before this method, use viewFramePrev if necessary, you may safely modify children's layoutParam during this method

◆ E_ViewLayoutOnLayout()

static zfidentity ZFUIView::E_ViewLayoutOnLayout ( void )
static

see ZFObject::observerNotify

called to do actual layout steps
param0 would be a v_zfbool init with false, set to true to bypass default layout impl

◆ E_ViewLayoutOnLayoutFinish()

static zfidentity ZFUIView::E_ViewLayoutOnLayoutFinish ( void )
static

see ZFObject::observerNotify

called when layout finished, typically you should not modify layoutParam during this event

◆ E_NativeImplViewMarginOnUpdate()

static zfidentity ZFUIView::E_NativeImplViewMarginOnUpdate ( void )
static

see ZFObject::observerNotify

called when nativeImplViewMarginUpdate and value differs from old

◆ serializableRefLayoutParam()

virtual void ZFUIView::serializableRefLayoutParam ( ZFUILayoutParam * serializableRefLayoutParam)
virtual

store ref layout param for this view for reducing serialization output size

if set, while serializing this view's layout param, the ref one would be used as reference object to filter out contents that didn't change (see ZFSerializable::serializeToData)
by default, all children would have it's parent's default layout param (layoutParamCreate) as the ref layout param, during adding to parent

◆ serializableOnSerializeFromData()

virtual zfbool ZFUIView::serializableOnSerializeFromData ( const ZFSerializableData & serializableData,
zfstring * outErrorHint = zft_zfnull,
ZFSerializableData * outErrorPos = zft_zfnull )
protectedvirtual

for serializable data that has "category" attribute, ZFSerializable would ignore it and leave it to subclass to resolve, see ZFSerializable

while overriding this method, you should call super first, and then check whether super has resolved the data
if subclass should resolve the category, you should mark data as resolved and return whether resolve success
if not, subclass should leave the data unresoved and return true

Reimplemented from ZFSerializable.

Reimplemented in ZFUIAutoLayout, and ZFUIListView.

◆ serializableOnSerializeToData()

virtual zfbool ZFUIView::serializableOnSerializeToData ( ZFSerializableData & serializableData,
zfstring * outErrorHint = zft_zfnull,
ZFSerializable * refOwner = zft_zfnull )
protectedvirtual

corresponding to serializableOnSerializeFromData, return whether the task is success, see ZFSerializable

Reimplemented from ZFSerializable.

Reimplemented in ZFUIListView.

◆ serializableOnCheckNeedSerializeChildren()

virtual zfbool ZFUIView::serializableOnCheckNeedSerializeChildren ( void )
inlineprotectedvirtual

whether we should serialize all children

by default, ZFUIView would serialize all normal child views, for some adapter view it may be not necessary, you may override this method to disable the auto serialization of child views

Reimplemented in ZFUIListView.

◆ viewId()

virtual zfstring & ZFUIView::viewId ( )
inlinevirtual

used to identify a view, empty by default

this is useful when you want to find a view from a complicated view tree, see ZFUIView::childFindById

Note
it's OK that two view have same view id, however it's recommended to make it unique

◆ viewTreeInWindow()

virtual zfbool ZFUIView::viewTreeInWindow ( )
virtual

◆ viewTreeVisible()

virtual zfbool ZFUIView::viewTreeVisible ( )
virtual

true only if added to ZFUISysWindow and all of parents are visible

see E_ViewTreeVisibleOnUpdate

◆ viewFrame()

virtual ZFUIRect const & ZFUIView::viewFrame ( )
virtual

the view's frame

typicall, this property would be updated automatically by parent's layoutOnLayout, but you may also change this property manually, for example, to achieve custom animation logic, if you do so, the frame would be kept and parent's layout logic would be ignored, until you call viewFrameReset

◆ transformAvailable()

static ZFUITransformFlags ZFUIView::transformAvailable ( )
static

whether transform is supported

basic 2D transform:

3D transform:

when setting transform which is not supported, it's ensured nothing happen, but the property value is ensured to be updated

◆ bind()

virtual void ZFUIView::bind ( ZFObject * owner,
const zfstring & propertyName )
virtual

util method to bind this view to owner's property, and auto setup viewId if not set

useful in script to build view tree quickly:

:classBegin('MyView', 'ZFUIView')
:property('ZFUIView', '_myChild')
:onInit(function(zfargs)
---@type MyView
local owner = zfargs:sender()
owner
... // other view tree
:child(ZFUIView():bind(owner, '_myChild')
... // other view tree
)
-- now the property can be accessed
owner:_myChild()
end)
:classEnd()
util class to dynamic register class/method/property
Definition ZFDynamicRegisterUtil.h:56
void onInit(const ZFListener &impl)
util for script to achieve chained call
Definition ZFObjectCore.h:648
zfanyT< ZFUILayoutParam > child(const zfany &view, zfindex atIndex=((zfindex) -1))
add child and return child's layoutParam, see childWithParam
virtual void bind(ZFObject *owner, const zfstring &propertyName)
util method to bind this view to owner's property, and auto setup viewId if not set

◆ bindEvent()

virtual void ZFUIView::bindEvent ( const zfstring & eventName,
ZFObject * owner,
const zfstring & methodName )
virtual

util method to bind this view's event to owner's method

useful in script to build view tree quickly:

:classBegin('MyView', 'ZFUIView')
:onInit(function(zfargs)
---@type MyView
local owner = zfargs:sender()
owner
... // other view tree
:child(ZFUIButtonBasic():bindEvent('ButtonOnClick', owner, '_myOnClick')
... // other view tree
)
end)
:method('void', '_myOnClick', ZFMP(), function(zfargs)
...
end)
:classEnd()
util for ZFDynamic::method
Definition ZFMethodDynamicRegister.h:197
basic button, see ZFUIButton
Definition ZFUIButtonBasic.h:33
virtual void bindEvent(const zfstring &eventName, ZFObject *owner, const zfstring &methodName)
util method to bind this view's event to owner's method

see ZFObject::on for event name search logic

the owner's method's return value would be ignored, and params can be

  • method with no params
  • exactly one param with v_ZFArgs type, which was the zfargs from the source event
  • exactly two param with ZFObject type (or sub class of ZFObject), which was the param0 and param1 from the source event

note, when multiple method matches, which one to use would not be ensured, try to prevent that

◆ objectOnInit()

virtual void ZFUIView::objectOnInit ( void )
protectedvirtual

override this to init your object

subclass must call superclass's objectOnInit before any other code if override
you may also declare objectOnInit with params like this:

zfclass Parent : ... {
...
protected:
virtual void objectOnInit(void) {...};
};
zfclass Child : Parent {
protected:
// override all parent's objectOnInit is also required,
// because of function hiding of C++
virtual void objectOnInit(void) {
}
// custom init entry
virtual void objectOnInit(Params...) {
// your extra init steps
...
}
};
#define zfoverride
dummy macro shows that method override parent's method
Definition ZFCoreTypeDef_ClassType.h:58
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
virtual void objectOnInit(void)
override this to init your object
virtual void objectOnInit(void)
override this to init your object
Warning
objectOnInit and objectOnDealloc is called as a virtual function, take good care of other virtual function call, use zfself::func() instead of this->func() if necessary, or use objectOnInitFinish/objectOnDeallocPrepare, or declare your own constructor with ZFOBJECT_DECLARE_WITH_CUSTOM_CTOR
Note
(ZFTAG_LIMITATION) due to limitations of C++, if your parent type declared objectOnInit with different params, and your child type want to override part of those objectOnInit, then your child type must also override all objectOnInit that parent declared, otherwise, some may be hidden
for objects that designed not to be allocated by user, you should use ZFOBJECT_PRIVATE_ALLOC, typically usage:
zfclass MyObject : zfextend ZFObject {
ZFOBJECT_DECLARE(MyObject, ZFObject)
ZFOBJECT_PRIVATE_ALLOC("should be created by MyObject::instanceForXxx only")
public:
static zfauto instanceForXxx(xxx) {
// can only be allocated by reflection
}
};
static void func(void) {
// MyObject *obj = zfAlloc(MyObject); // would compile error
zfauto obj = MyObject::instanceForXxx(xxx); // OK
}
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#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
zfauto newInstance(void) const
make a new instance of ZFObject dynamically, which is described by ZFClass
static const ZFClass * ClassData(void)
get class info
Definition ZFUIView.h:94
a ZFObject holder which would release content object automatically when destroyed
Definition zfautoFwd.h:34

Reimplemented from ZFObject.

Reimplemented in ZFUIAutoLayout, ZFUIButton, ZFUIButtonBasic, ZFUICellViewBasic, ZFUIDrawableView, ZFUIImageView, ZFUIListView, ZFUINativeViewWrapper, ZFUIOnScreenKeyboardAutoFitLayout, ZFUIScrollView, ZFUITextEdit, ZFUITextEditWidget, ZFUITextView, ZFUIWebView, and ZFUIWindow.

◆ objectOnDealloc()

virtual void ZFUIView::objectOnDealloc ( void )
protectedvirtual

override this to destroy your object

subclass must call superclass's objectOnDealloc after any other code if override
see objectOnInit for more info

Reimplemented from ZFObject.

Reimplemented in ZFUIAutoLayout, ZFUIButton, ZFUIButtonBasic, ZFUICellViewBasic, ZFUIListView, ZFUIOnScreenKeyboardAutoFitLayout, ZFUIScrollView, ZFUITextEdit, ZFUITextEditWidget, ZFUITextView, ZFUIWebView, and ZFUIWindow.

◆ objectOnDeallocPrepare()

virtual void ZFUIView::objectOnDeallocPrepare ( void )
protectedvirtual

called before objectOnDealloc, safe to call virtual functions here

usually used to cleanup resources attached to this object other than self's internal resources

Note
it's ensured safe to retain the object while deallocating, but it's not ensured objectOnDeallocPrepare would only called once for each instance

Reimplemented from ZFObject.

Reimplemented in ZFUIImageView, ZFUIListView, ZFUIScrollView, and ZFUIWebView.

◆ objectInfoImplAppend()

virtual void ZFUIView::objectInfoImplAppend ( zfstring & ret)
protectedvirtual

◆ nativeImplView() [1/2]

virtual void * ZFUIView::nativeImplView ( )
virtual

native implementation view

first child of nativeView, layout below all other child views, for internal implementation use only, for example, a ImageView's implementation may use native view and set it as internalNativeView
subclass must not override parent, if really necessary, use internalBgViewAdd
use with caution

See also
nativeView

Reimplemented in ZFUINativeViewWrapper.

◆ nativeImplViewMargin()

virtual const ZFUIMargin & ZFUIView::nativeImplViewMargin ( )
virtual

inner margin between ZFUIView and the internal nativeImplView

use nativeImplViewMarginUpdate to update this value, and it's ensured to be called during ZFObject::objectOnInitFinish
subclass should override nativeImplViewMarginImplUpdate to implement custom margin, and manually call nativeImplViewMarginUpdate if necessary
this value can also be controlled by app level code by nativeImplViewMarginCustom

◆ nativeImplView() [2/2]

virtual void ZFUIView::nativeImplView ( void * nativeImplView,
ZFUIViewNativeImplViewDeleteCallback nativeImplViewDeleteCallback,
zfbool nativeImplViewRequireVirtualIndex )
protectedvirtual

see nativeImplView

Reimplemented in ZFUINativeViewWrapper.

◆ nativeImplViewMarginImplUpdate()

virtual void ZFUIView::nativeImplViewMarginImplUpdate ( ZFUIMargin & nativeImplViewMargin)
inlineprotectedvirtual

see nativeImplViewMargin, subclass must call super and "append" to existing margin

Reimplemented in ZFUIImageView, and ZFUITextEditWidget.

◆ nativeImplViewMarginOnUpdate()

virtual void ZFUIView::nativeImplViewMarginOnUpdate ( void )
inlineprotectedvirtual

◆ nativeImplViewOnLayout()

virtual void ZFUIView::nativeImplViewOnLayout ( ZFUIRect & ret,
const ZFUIRect & bounds,
const ZFUIMargin & nativeImplViewMargin )
inlineprotectedvirtual

called to layout nativeImplView

Reimplemented in ZFUIImageView.

◆ implChildOnAdd()

virtual void ZFUIView::implChildOnAdd ( ZFUIView * child,
zfindex virtualIndex,
ZFUIViewChildLayer childLayer,
zfindex childLayerIndex )
protectedvirtual

called to add or remove view to impl

subclass may override this method to add child to other container
to implement this, you must implement all these methods:

Reimplemented in ZFUIScrollView.

◆ implChildOnRemove()

virtual void ZFUIView::implChildOnRemove ( ZFUIView * child,
zfindex virtualIndex,
ZFUIViewChildLayer childLayer,
zfindex childLayerIndex )
protectedvirtual

◆ implChildOnRemoveAllForDealloc()

virtual void ZFUIView::implChildOnRemoveAllForDealloc ( void )
protectedvirtual

called to remove all children during parent dealloc for performance

for normal children management, each child would be removed one by one and fire child change event when childRemoveAll, which is not necessary during parent dealloc (which may cause performance issue), so we use this method to remove all children directly during parent dealloc to improve performance

Reimplemented in ZFUIScrollView.

◆ nativeView()

virtual void * ZFUIView::nativeView ( )
virtual

native container view

the actual type of this is defined by implementation, and it's not recommended to use in your application

for how to add ZFUIView to native view, please refer to ZFUIView
for how to add native view to ZFUIView, please refer to ZFUINativeViewWrapper
for how to access native implementation, please refer to nativeImplView

◆ focusRequest()

virtual void ZFUIView::focusRequest ( zfbool focus)
virtual

request to obtain or resign focus, result can be checked by focused

only focused view can receive key events

◆ focusOnUpdate()

virtual void ZFUIView::focusOnUpdate ( void )
inlineprotectedvirtual

see E_ViewFocusOnUpdate

Reimplemented in ZFUITextEdit.

◆ removeFromParent()

virtual void ZFUIView::removeFromParent ( )
virtual

remove this view from parent or do nothing if no parent

can remove normal child view or internal view

◆ UIScale()

virtual zffloat & ZFUIView::UIScale ( )
inlinevirtual

UI scale for view tree.

ZFUIView use a special scale logic to adapt various screen sizes, which contain these scale values:

  • app scale:
    app's custom scale, accessed by UIScale, 1 by default
    you may change this view to apply scale for entire view tree, every child view may have different scale setting, the final scale can be accessed by UIScaleInherited
  • impl scale:
    accessed by UIScaleForImpl, it's value depends on impl
    automatically changed while adding a ZFUIView to native view, can not be changed by app
  • fixed scale:
    accessed by UIScaleFixed, always equal to (UIScaleInherited * UIScale * UIScaleForImpl)
    all size unit would be applied with this value before passing to implementations, can not be changed by app
  • impl physical scale:
    accessed by UIScaleForPixel, it's value depends on impl
    to access final pixel size: view's size * UIScaleInherited * UIScale * UIScaleForPixel

in general:

  • for app:
    usually you have no need to worry about scales, all elements can be assigned as fixed size, such as 48 for a button's height and 21 for a small textView's height, it will be scaled automatically while rendering to different size's or DPI's devices
    you may use UIScale to control custom scale logic
  • for implementation:
    you have no need to worry about element's logical size, everything would be scaled to desired size unit depending on the scale value that impl returned


since scale may affect impl's pixel size, size-related property should be flushed manually while scale changed, subclass should override UIScaleOnUpdate to update them, which would be called if UIScaleFixed really changed
UIScale usually used for scale for entire view tree, all layout and touch position would be scaled properly, however, changing UIScale for a deep view tree may consume much time
for temporarily scale, typically for animation, use scaleX instead

◆ UIScaleOnUpdate()

virtual void ZFUIView::UIScaleOnUpdate ( void )
protectedvirtual

see UIScale, ensured called only when scale value actually changed

after this method, E_UIScaleOnUpdate would be fired

Reimplemented in ZFUITextEdit, and ZFUITextView.

◆ layoutParamClass()

virtual const ZFClass * ZFUIView::layoutParamClass ( void )
protectedvirtual

see layoutParamCreate

you should override this method to declare your layout param class

Reimplemented in ZFUIAutoLayout, ZFUIFlowLayout, ZFUIGridLayout, and ZFUILinearLayout.

◆ layoutParam() [1/2]

virtual void ZFUIView::layoutParam ( ZFUILayoutParam * layoutParam)
virtual

manually set layout param

this method can be called even if this view has no parent, the layout param would be serialized while serializing the view itself
while adding to another container view with different layout param type, a new layout param would be created and applied style from the existing one

◆ layoutParam() [2/2]

virtual zfanyT< ZFUILayoutParam > ZFUIView::layoutParam ( )
virtual

get self's layout param, valid only while the view has parent

return null if the view has no parent, automatically invoke the view's layoutRequest if the layout param's property changed

◆ layoutMeasure()

virtual const ZFUISize & ZFUIView::layoutMeasure ( const ZFUISize & sizeHint,
const ZFUISizeParam & sizeParam )
virtual

measure the view

call layoutOnMeasure to see the needed size for this view
note that internal views won't be measured

See also
layoutMeasuredSize

◆ layoutChildOffset()

virtual ZFUIPoint ZFUIView::layoutChildOffset ( )
virtual

get child offset to this view

for views that have offset logic (typically scroll views), use this method to access the offset to its parent, child's viewFrame plus this offset should be the actual offset to parent's edge
subclass should override layoutChildOffsetOnUpdate to supply this value

◆ layoutOnMeasure()

virtual void ZFUIView::layoutOnMeasure ( ZFUISize & ret,
const ZFUISize & sizeHint,
const ZFUISizeParam & sizeParam )
inlineprotectedvirtual

called by layoutMeasure to decide the view's size

you may override without call super to supply your own layout logic

note that we doesn't ensure layoutOnMeasure would be called during layout steps, only layout that has wrap content features may call layoutMeasure to calculate children's size

sizeHint means the max size child should reach, see ZFUISizeType for more info

return a negative value means the view doesn't care about size

Note
there's some repeatly work that layoutMeasure would have done for you, you should not repeat it again for performance:
  • filter out the case that both sizeParam are fixed or fill parent
  • apply sizeHint by ZFUILayoutParam::sizeHintApply
  • fix result size in range [viewSizeMin, viewSizeMax]
for impl views (such as text view), you should manually take care of nativeImplViewMargin during measure and layout steps

Reimplemented in ZFUIAutoLayout, ZFUIButtonBasic, ZFUICell, ZFUICellView, ZFUIFlowLayout, ZFUIImageView, ZFUILinearLayout, ZFUINativeViewWrapper, ZFUIOnScreenKeyboardAutoFitLayout, ZFUIRootView, ZFUIScrollLayout, ZFUITextEdit, ZFUITextView, and ZFUIViewLayout.

◆ layoutOnLayoutPrepare()

virtual void ZFUIView::layoutOnLayoutPrepare ( const ZFUIRect & bounds)
inlineprotectedvirtual

◆ layoutOnLayout()

virtual void ZFUIView::layoutOnLayout ( const ZFUIRect & bounds)
protectedvirtual

called by viewFrame to layout the view and children

it's valid for subclass to override without calling zfsuper::layoutOnLayout, which means subclass would override all layout steps in parent

note that we doesn't ensure layoutOnMeasure would be called before layoutOnLayout

Reimplemented in ZFUIAutoLayout, ZFUIFlowLayout, ZFUILinearLayout, ZFUIListView, ZFUIRootView, and ZFUIScrollView.

◆ layoutOnLayoutFinish()

virtual void ZFUIView::layoutOnLayoutFinish ( const ZFUIRect & bounds)
inlineprotectedvirtual

◆ layoutChildOffsetOnUpdate()

virtual void ZFUIView::layoutChildOffsetOnUpdate ( ZFUIPoint & ret)
inlineprotectedvirtual

see layoutChildOffset

Reimplemented in ZFUIScrollView.

◆ childForEach()

virtual zfauto ZFUIView::childForEach ( const ZFListener & impl,
zfbool findRecursively = (_ZFT_t_zftrue),
zfbool includeInternalViews = (_ZFT_t_zffalse) )
virtual

call custom impl for each child

the impl's sender would be the owner parent view that calling this method, param0 would be each child being checking, impl should set ZFArgs::eventFiltered if process done, and may set ZFArgs::result which would return as return value of this method

◆ childWithParam()

virtual zfanyT< ZFUILayoutParam > ZFUIView::childWithParam ( ZFUIView * view,
ZFUILayoutParam * layoutParam,
zfindex atIndex = (((zfindex) -1)) )
virtual

add view with layout param, param must be created by layoutParamCreate

if layoutParam is null (by default), create new one by layoutParamCreate
if layoutParam is type of layoutParamClass and not null, it would be used directly, otherwise, a new layout param would be created and source layout param would be copied to the newly created layout param

◆ childMove()

virtual void ZFUIView::childMove ( zfindex fromIndex,
zfindex toIndexOrIndexMax )
virtual

move view, make toIndexOrIndexMax as zfindexMax() to move to top most, and 0 to bottom most, do nothing if index invalid or have no change

assert fail if fromIndex out of range, or toIndexOrIndexMax isn't zfindexMax() and out of range
moving a view would cause layoutRequest being called

◆ viewLayer()

virtual ZFUIViewChildLayer ZFUIView::viewLayer ( )
virtual

this view belongs to which layer of parent, valid only if parent is not null

would be v_ZFUIViewChildLayer::e_Normal if no parent

◆ childRawArray()

virtual ZFCoreArray< zfautoT< ZFUIView > > ZFUIView::childRawArray ( )
virtual

return all children including internal views, see childArray

children are ensured ordered by (impl, bg, normal, fg) views

◆ viewTreeVisibleOnUpdate()

virtual void ZFUIView::viewTreeVisibleOnUpdate ( void )
protectedvirtual

◆ viewChildOnAdd()

virtual void ZFUIView::viewChildOnAdd ( ZFUIView * child,
ZFUIViewChildLayer childLayer )
protectedvirtual

see E_ViewChildOnAdd

Reimplemented in ZFUIListView.

◆ viewChildOnRemove()

virtual void ZFUIView::viewChildOnRemove ( ZFUIView * child,
ZFUIViewChildLayer childLayer )
protectedvirtual

see E_ViewChildOnRemove

Reimplemented in ZFUIAutoLayout, and ZFUIListView.

◆ viewOnAddToParent()

virtual void ZFUIView::viewOnAddToParent ( ZFUIView * parent)
protectedvirtual

see E_ViewOnAddToParent

Reimplemented in ZFUIRootView, and ZFUIWindow.

◆ viewOnRemoveFromParent()

virtual void ZFUIView::viewOnRemoveFromParent ( ZFUIView * parent)
protectedvirtual

see E_ViewOnRemoveFromParent

Reimplemented in ZFUIRootView, and ZFUIWindow.

◆ internalBgViewAdd()

virtual zfanyT< ZFUILayoutParam > ZFUIView::internalBgViewAdd ( ZFUIView * view,
ZFUILayoutParam * layoutParam = (zft_zfnull),
zfbool addAsTopMost = (_ZFT_t_zftrue) )
virtual

internal view which is independent from normal view

we have these layers in ZFUIView module:

  • internal impl view
  • internal background view
  • normal view
  • internal foreground view

each layer is independent and has the same interface to add or remove view
to make the interfaces cleaner, the internal ones are named with "internalBgView" and "internalFgView" as pre-fix, such as internalBgViewAdd and internalBgViewRemove (considering the child and childRemove)

internal views has no measure steps, its size always depends on parent's size

◆ internalViewAutoSerializeTagAdd()

virtual void ZFUIView::internalViewAutoSerializeTagAdd ( const zfstring & tag)
virtual

used to apply auto serialize logic to internal views

by default, internal views won't be serialized automatically, you may make it available by:

  • have internal view's viewId set
  • have same id set by this method

while serializing, if an internal view with same id already exists, we would copy style from serialize data to the existing one instead

◆ internalViewShouldLayout()

virtual zfbool ZFUIView::internalViewShouldLayout ( ZFUIView * internalView)
inlineprotectedvirtual

called to check whether the internal view should be layouted using default layout logic, return true by default

Reimplemented in ZFUIButtonBasic, ZFUICellView, ZFUITextEdit, and ZFUITextEditWidget.

◆ internalViewOnLayout()

virtual void ZFUIView::internalViewOnLayout ( const ZFUIRect & bounds)
protectedvirtual

◆ viewEventOnEvent()

virtual void ZFUIView::viewEventOnEvent ( ZFUIEvent * event)
protectedvirtual

notified when a ZFUIEvent occurred

default behavior is to dispatch event depends on event type
you may override without call super's method, to override the event
you should update ZFUIEvent::eventResolved if resolved

◆ viewEventOnMouseEvent()

virtual void ZFUIView::viewEventOnMouseEvent ( ZFUIMouseEvent * mouseEvent)
protectedvirtual

called when mouse event occurred

due to some limitations, we doesn't support intercept mouse event, event dispatch logic depends on implementation, you may use native view to achieve if necessary

mouse hover event would only be fired if mouseHoverEnable

by default, this method would simply resolve the event if this view is enabled, you may override without call super's method, to override the event

Reimplemented in ZFUIButton, and ZFUIScrollView.

◆ viewEventOnKeyEvent()

virtual void ZFUIView::viewEventOnKeyEvent ( ZFUIKeyEvent * keyEvent)
protectedvirtual

called when key occurred

due to some limitations, we doesn't support intercept key event, event dispatch logic depends on implementation, you may use native view to achieve if necessary

by default, this method would call viewEventOnKeyEventResolveFocus to achieve focus move, you may override without call super's method, to override the event
the event would be dispatched from child to parent, util it's resolved

Reimplemented in ZFUIButton, and ZFUITextEdit.

◆ viewEventOnKeyEventResolveFocus()

virtual void ZFUIView::viewEventOnKeyEventResolveFocus ( ZFUIKeyEvent * keyEvent)
protectedvirtual

called by viewEventOnKeyEvent to resolve focus move key event

this method would call ZFUIViewFocusResolveKeyEvent to achieve focus move, you may override without call super's method, to override the event

◆ viewEventOnWheelEvent()

virtual void ZFUIView::viewEventOnWheelEvent ( ZFUIWheelEvent * wheelEvent)
protectedvirtual

called when wheel event occurred

due to some limitations, we doesn't support intercept wheel event, event dispatch logic depends on implementation, you may use native view to achieve if necessary

the event would be dispatched from child to parent, util it's resolved

Reimplemented in ZFUIScrollView.

◆ styleableOnCopyFrom()

virtual void ZFUIView::styleableOnCopyFrom ( ZFObject * anotherStyleable)
protectedvirtual

for a view, copy style would also copy all of it's children

Reimplemented from ZFStyleable.

Reimplemented in ZFUIAutoLayout.

◆ observerOnAdd()

virtual void ZFUIView::observerOnAdd ( zfidentity eventId)
protectedvirtual

called when add first observer

Reimplemented from ZFObject.

◆ observerOnRemove()

virtual void ZFUIView::observerOnRemove ( zfidentity eventId)
protectedvirtual

called when remove last observer

Reimplemented from ZFObject.


The documentation for this class was generated from the following file: