ZFFramework
 
Loading...
Searching...
No Matches
ZFUIImage.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFUIImage_h_
7#define _ZFI_ZFUIImage_h_
8
9#include "ZFUIGlobalStyle.h"
11
12// ============================================================
13// ZFUIImage
14zfclassFwd _ZFP_ZFUIImagePrivate;
31 ZFOBJECT_DECLARE(ZFUIImage, ZFStyle)
32
33
38 ZFEVENT(ImageScaleOnUpdate)
39
45 ZFEVENT(ImageStateOnUpdate)
46
47protected:
50 ZF_IN const ZFSerializableData &serializableData
51 , ZF_OUT_OPT zfstring *outErrorHint = zfnull
52 , ZF_OUT_OPT ZFSerializableData *outErrorPos = zfnull
53 );
56 ZF_IN_OUT ZFSerializableData &serializableData
57 , ZF_OUT_OPT zfstring *outErrorHint = zfnull
58 , ZF_IN_OPT ZFSerializable *refOwner = zfnull
59 );
60
61protected:
63 virtual void styleableOnCopyFrom(ZF_IN ZFObject *anotherStyleable);
64
65 // ============================================================
66 // property
67public:
85
92
105
106 // ============================================================
107 // image state
108public:
127
138 , ZFMP_IN(const ZFListener &, callback)
142 , ZFMP_IN(const ZFListener &, callback)
162 , ZFMP_IN(const ZFListener &, impl)
168 , ZFMP_IN(ZFUIImage *, imageState)
170
171 // ============================================================
172 // other
173 ZFOBJECT_PRIVATE_ALLOC("can only be created by ZFUIImageLoadXxx series")
174protected:
176 virtual void objectOnInit(void);
178 virtual void objectOnDealloc(void);
180 virtual void objectOnInitFinish(void);
182 virtual void objectOnDeallocPrepare(void);
183
185 virtual ZFCompareResult objectCompareValueImpl(ZF_IN ZFObject *anotherObj);
186protected:
191 ZF_IN const ZFProperty *property
192 , ZF_IN const void *oldValue
193 );
194
195public:
200
201public:
202 zffinal void _ZFP_ZFUIImage_imageScaleOnUpdate(void);
203protected:
205 virtual void imageScaleOnUpdate(void) {
207 }
208
210 virtual void imageStateOnUpdate(void) {
212 }
213
214 // ============================================================
215 // internal methods
216public:
222 ZFMETHOD_DECLARE_2(void, nativeImage
223 , ZFMP_IN(void *, nativeImage)
224 , ZFMP_IN_OPT(zfbool, retainNativeImage, zftrue)
226
227public:
230 , ZFMP_IN(const zfstring &, typeName)
236 , ZFMP_IN(const ZFSerializableData &, serializableData)
247 , ZFMP_IN(const ZFListener &, impl)
251
254 , ZFMP_IN(zfbool, disable)
258
259private:
260 _ZFP_ZFUIImagePrivate *d;
261 friend zfclassFwd _ZFP_ZFUIImagePrivate;
262};
263
264// ============================================================
265typedef zfbool (*_ZFP_ZFUIImageSerializeFromCallback)(
266 ZF_IN_OUT ZFUIImage *image
267 , ZF_IN const ZFSerializableData &imageData
268 , ZF_OUT_OPT zfstring *outErrorHint /* = zfnull */
269 , ZF_OUT_OPT ZFSerializableData *outErrorPos /* = zfnull */
270 );
271
272extern ZFLIB_ZFUIKit void _ZFP_ZFUIImageSerializeTypeRegister(
273 ZF_IN const zfstring &name
274 , ZF_IN _ZFP_ZFUIImageSerializeFromCallback fromCallback
275 );
276extern ZFLIB_ZFUIKit void _ZFP_ZFUIImageSerializeTypeUnregister(ZF_IN const zfstring &name);
308#define ZFUIIMAGE_SERIALIZE_TYPE_DEFINE(registerSig, typeName) \
309 static zfbool _ZFP_ZFUIImageSerializeFromCallback_##registerSig(ZF_IN_OUT ZFUIImage *ret, \
310 ZF_IN const ZFSerializableData &serializableData, \
311 ZF_OUT_OPT zfstring *outErrorHint /* = zfnull */, \
312 ZF_OUT_OPT ZFSerializableData *outErrorPos /* = zfnull */); \
313 ZF_GLOBAL_INITIALIZER_INIT_WITH_LEVEL(ZFUIImageSerializeReg_##registerSig, ZFLevelZFFrameworkHigh) { \
314 _ZFP_ZFUIImageSerializeTypeRegister(typeName, _ZFP_ZFUIImageSerializeFromCallback_##registerSig); \
315 } \
316 ZF_GLOBAL_INITIALIZER_DESTROY(ZFUIImageSerializeReg_##registerSig) { \
317 _ZFP_ZFUIImageSerializeTypeUnregister(typeName); \
318 } \
319 ZF_GLOBAL_INITIALIZER_END(ZFUIImageSerializeReg_##registerSig) \
320 static zfbool _ZFP_ZFUIImageSerializeFromCallback_##registerSig(ZF_IN_OUT ZFUIImage *ret, \
321 ZF_IN const ZFSerializableData &serializableData, \
322 ZF_OUT_OPT zfstring *outErrorHint /* = zfnull */, \
323 ZF_OUT_OPT ZFSerializableData *outErrorPos /* = zfnull */)
324
335
337#define ZFSerializableKeyword_ZFUIImage_imageType "imageType"
339#define ZFSerializableKeyword_ZFUIImage_imageBin "imageBin"
340
341// ============================================================
353
355#endif // #ifndef _ZFI_ZFUIImage_h_
356
#define ZF_OUT_OPT
dummy macro that shows the param used as optional output
Definition ZFCoreTypeDef_ClassType.h:192
#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 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:180
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:184
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:196
#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 zftrue
bool true type
Definition ZFCoreTypeDef_CoreType.h:107
_zft_zffloat zffloat
same as float, see zfindex
Definition ZFCoreTypeDef_CoreType.h:183
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
ZFCompareResult
compare result of two ZFObjects
Definition ZFCoreTypeDef_OtherType.h:28
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZFENUM_SEPARATOR()
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:158
#define ZFENUM_VALUE_REGISTER(Value)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:168
#define ZFENUM_REG(ZFLIB_, EnumName,...)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:186
#define ZFENUM_VALUE(Value)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:151
#define ZFENUM_BEGIN(ZFLIB_, EnumName)
macros to define reflectable enum type
Definition ZFEnumDeclare.h:147
#define ZFENUM_END(ZFLIB_, EnumName)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:172
#define ZFMP_IN_OPT(ParamType, paramName, DefaultValue)
see ZFMP_IN
Definition ZFMethod.h:108
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#define ZFMETHOD_DECLARE_0(ReturnType, MethodName)
see ZFMethod
Definition ZFMethodDeclare.h:693
#define ZFMETHOD_DECLARE_2(ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMethod
Definition ZFMethodDeclare.h:1025
#define ZFMETHOD_DECLARE_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodDeclare.h:854
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_DECLARE(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 ZFEVENT(YourEvent)
see ZFObject::observerNotify
Definition ZFObjectObserver.h:328
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:128
#define ZFPROPERTY_ON_ATTACH_DECLARE(Type, Name)
see ZFPROPERTY_ON_INIT_DECLARE
Definition ZFPropertyDeclare.h:248
global style for ui elements
v_ZFUIImageStateImplAction::ZFEnumType ZFUIImageStateImplAction
see v_ZFUIImageStateImplAction
Definition ZFUIImage.h:351
void ZFUIImageSerializeTypeGetAllT(ZFCoreArray< zfstring > &ret)
see ZFUIImageSerializeTypeGetAll
ZFCoreArray< zfstring > ZFUIImageSerializeTypeGetAll(void)
usually for debug use only
Definition ZFUIImage.h:330
#define ZFLIB_ZFUIKit
used to export symbols
Definition ZFUIKitDef.h:16
light weight array
Definition ZFCoreArray.h:331
listener as ZFCallback, mostly used by ZFObject::observerNotify
Definition ZFObjectObserver.h:30
void observerNotify(zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
notify the observer with eventId
info for a property for ZFObject, see ZFPROPERTY_RETAIN for more info
Definition ZFProperty.h:28
ZFSerializable's data container, see ZFSerializable.
Definition ZFSerializableData.h:74
virtual void * nativeImage()
get native image object
virtual zfautoT< ZFUIImage > imageStateUpdate()
see imageState
virtual void imageSerializeType(const zfstring &typeName)
see ZFUIIMAGE_SERIALIZE_TYPE_DEFINE
virtual ZFCompareResult objectCompareValueImpl(ZFObject *anotherObj)
see objectCompareValue
virtual void objectOnInitFinish(void)
called after objectOnInit, safe to call virtual functions here
virtual zfbool serializableOnSerializeToData(ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializable *refOwner=zft_zfnull)
corresponding to serializableOnSerializeFromData, return whether the task is success,...
virtual void objectInfoImplAppend(zfstring &ret)
see objectInfo
virtual void styleableOnCopyFrom(ZFObject *anotherStyleable)
for subclass to achieve custom style copy step, called by styleableCopyFrom, see ZFStyleable
virtual void imageStateImpl(const ZFListener &impl)
for impl to implement stateful image logic
virtual const ZFUISize & imageSize()
get size of the image
virtual void imageSerializeData(const ZFSerializableData &serializableData)
see ZFUIIMAGE_SERIALIZE_TYPE_DEFINE
virtual void imageScaleOnUpdate(void)
see E_ImageScaleOnUpdate
Definition ZFUIImage.h:205
virtual zffloat const & imageScaleFixed()
util method to access actual scale
virtual const ZFUISize & imageSizeFixed()
get raw size of the image without scale (in pixel unit)
virtual void imageSerializeDataGetter(const ZFListener &impl)
see ZFUIIMAGE_SERIALIZE_TYPE_DEFINE
virtual void objectPropertyValueOnUpdate(const ZFProperty *property, const void *oldValue)
see E_ObjectPropertyValueOnUpdate
virtual void imageStateAttach(const ZFListener &callback)
for impl to attach image state update observer
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 s...
virtual void imageStateDetach(const ZFListener &callback)
see imageStateAttach
virtual void objectOnDealloc(void)
override this to destroy your object
static zfidentity E_ImageStateOnUpdate(void)
see ZFObject::observerNotify
static zfidentity E_ImageScaleOnUpdate(void)
see ZFObject::observerNotify
virtual void objectOnDeallocPrepare(void)
called before objectOnDealloc, safe to call virtual functions here
virtual zfautoT< ZFUIImage > imageState()
return current image state
virtual void imageSerializeDisable(zfbool disable)
see ZFSerializeDisable
virtual ZFUIMargin & imageNinePatch()
nine patch described by a margin value, disabled if zero margin or margin exceeds image size
Definition ZFUIImage.h:84
virtual void imageStateOnUpdate(void)
see E_ImageStateOnUpdate
Definition ZFUIImage.h:210
virtual void objectOnInit(void)
override this to init your object
virtual zffloat & imageScale()
image's scale, 1 by default
Definition ZFUIImage.h:78
virtual void imageStateImplNotifyUpdate(ZFUIImage *imageState)
see imageStateImpl
margin
Definition ZFUITypeDef.h:147
2D size
Definition ZFUITypeDef.h:397
type restrict version of zfauto
Definition zfautoFwd.h:110