6#ifndef _ZFI_ZFStyleable_h_
7#define _ZFI_ZFStyleable_h_
109 ZF_IN ZFStyleable *from
110 ,
ZF_IN ZFStyleable *to
117 ZF_IN ZFStyleable *from
118 ,
ZF_IN ZFStyleable *to
141#define _ZFP_ZFStyleableDefault_level ZFLevelZFFrameworkHigh
143typedef void (*_ZFP_ZFStyleableDefaultDeleteCallback)(
ZF_IN void *instance);
146 _ZFP_ZFStyleableDefaultDeleteCallbackHolder(
147 ZF_IN _ZFP_ZFStyleableDefaultDeleteCallback deleteCallback
148 ,
ZF_IN void *instance
150 : deleteCallback(deleteCallback)
154 ~_ZFP_ZFStyleableDefaultDeleteCallbackHolder(
void) {
155 if(this->deleteCallback && this->instance) {
156 this->deleteCallback(this->instance);
160 _ZFP_ZFStyleableDefaultDeleteCallback deleteCallback;
164#define _ZFP_ZFSTYLE_DEFAULT_DECLARE(YourStyle) \
166 zfclass _ZFP_StyleDef_##YourStyle; \
169 static zfanyT<YourStyle> DefaultStyle(void); \
171 static void _ZFP_StyleDefU(ZF_IN YourStyle *newInstance); \
172 static ZFObject *&_ZFP_StyleDefC(void); \
173 static void _ZFP_StyleDefD(ZF_IN void *instance); \
175#define _ZFP_ZFSTYLE_DEFAULT_DEFINE(YourStyle) \
176 zfclass YourStyle::_ZFP_StyleDef_##YourStyle : zfextend YourStyle { \
177 ZFOBJECT_DECLARE(_ZFP_StyleDef_##YourStyle, YourStyle) \
180 virtual zfbool styleableIsDefaultStyle(void) { \
184 zfanyT<YourStyle> YourStyle::DefaultStyle(void) { \
185 static void **holder = _ZFP_ZFStyleableDefaultRefAccess(#YourStyle); \
186 if(*holder == zfnull) { \
187 ZFCoreMutexLocker(); \
188 if(ZFFrameworkStateCheck(_ZFP_ZFStyleableDefault_level) == ZFFrameworkStateNotAvailable) { \
191 zfauto obj = _ZFP_StyleDef_##YourStyle::ClassData()->newInstance(); \
192 if(obj != zfnull) { \
193 zfself::_ZFP_StyleDefU(obj.to<YourStyle *>()); \
196 return (YourStyle *)(*holder); \
198 ZFMETHOD_USER_REGISTER_DETAIL_0(YourStyle, \
199 public, ZFMethodTypeStatic, s, \
200 zfanyT<YourStyle>, DefaultStyle) { \
201 return YourStyle::DefaultStyle(); \
203 void YourStyle::_ZFP_StyleDefU(ZF_IN YourStyle *newInstance) { \
204 if(ZFFrameworkStateCheck(_ZFP_ZFStyleableDefault_level) == ZFFrameworkStateNotAvailable) { \
207 void **holder = _ZFP_ZFStyleableDefaultRefAccess(#YourStyle); \
208 if(*holder == (void *)newInstance) { \
211 ZFObject *&cleanerRef = _ZFP_StyleDefC(); \
212 zfauto cleanerOld = cleanerRef; \
213 cleanerRef = zfnull; \
214 if(newInstance != zfnull) { \
215 *holder = (void *)zfobjRetain(newInstance); \
216 zfobj<ZFValue> cleanerRefTmp(*holder, YourStyle::_ZFP_StyleDefD); \
217 cleanerRef = cleanerRefTmp; \
218 ZFObjectGlobalInstanceAdd(cleanerRef, _ZFP_ZFStyleableDefault_level); \
220 if(cleanerOld != zfnull) { \
221 ZFObjectGlobalInstanceRemove(cleanerOld, _ZFP_ZFStyleableDefault_level); \
222 *holder = (void *)newInstance; \
225 ZFObject *&YourStyle::_ZFP_StyleDefC(void) { \
226 static ZFObject *_cleaner = zfnull; \
229 void YourStyle::_ZFP_StyleDefD(ZF_IN void *instance) { \
230 YourStyle::_ZFP_StyleDefC() = zfnull; \
231 void **holder = _ZFP_ZFStyleableDefaultRefAccess(#YourStyle); \
233 zfobjRelease((YourStyle *)instance); \
268#define ZFSTYLE_DEFAULT_DECLARE(YourStyle) \
269 _ZFP_ZFSTYLE_DEFAULT_DECLARE(YourStyle)
271#define ZFSTYLE_DEFAULT_DEFINE(YourStyle) \
272 _ZFP_ZFSTYLE_DEFAULT_DEFINE(YourStyle)
291#define ZFSTYLE_DEFAULT_AUTO_COPY() \
292 ZFINTERFACE_ON_INIT_DECLARE() { \
293 if(!this->styleableIsDefaultStyle()) { \
294 zfanyT<ZFStyleable> defaultStyle = this->defaultStyle(); \
295 if(defaultStyle != zfnull) { \
296 this->copyFrom(defaultStyle); \
297 ZFStyleDefaultApplyAutoCopy(this); \
447#define ZFStyleUpdateBlock() _ZFP_ZFStyleUpdateBlock ZFUniqueName(_ZFP_ZFStyleUpdateBlock)
450 _ZFP_ZFStyleUpdateBlock(
void) {
453 ~_ZFP_ZFStyleUpdateBlock(
void) {
506#define ZFSTYLE_DECODER_DEFINE(registerSig, decodeAction, ...) \
507 _ZFP_ZFSTYLE_DECODER_DEFINE(registerSig, decodeAction, ##__VA_ARGS__)
508#define _ZFP_ZFSTYLE_DECODER_DEFINE(registerSig, decodeAction, ...) \
509 ZF_STATIC_REGISTER_INIT(ZFStyleDecoder_##registerSig) { \
510 _ZFP_ZFStyleDecoderRegister(zftext(#registerSig), zfself::_ZFP_decode); \
512 ZF_STATIC_REGISTER_DESTROY(ZFStyleDecoder_##registerSig) { \
513 _ZFP_ZFStyleDecoderUnregister(zftext(#registerSig)); \
515 static zfbool _ZFP_decode( \
517 , ZF_IN const zfstring &styleKey \
519 decodeAction __VA_ARGS__ \
521 ZF_STATIC_REGISTER_END(ZFStyleDecoder_##registerSig)
522typedef zfbool (*_ZFP_ZFStyleDecoder)(
528 ,
ZF_IN _ZFP_ZFStyleDecoder decoder
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define zffinal
dummy macro shows that a method or class is designed must not to be overrided
Definition ZFCoreTypeDef_ClassType.h:63
#define zfclassLikePOD
shows the class is not a POD type, but you may use it like a POD except memset it to 0
Definition ZFCoreTypeDef_ClassType.h:41
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:191
#define ZF_OUT
dummy macro that shows the param used as required output
Definition ZFCoreTypeDef_ClassType.h:199
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:207
#define zfclassFwd
forward declaration of a class type
Definition ZFCoreTypeDef_ClassType.h:31
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_zft_zffloat zffloat
same as float, see zfindex
Definition ZFCoreTypeDef_CoreType.h:183
#define zffalse
bool false type
Definition ZFCoreTypeDef_CoreType.h:111
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#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:123
#define ZFIMPLEMENT_DECLARE(ImplementedInterfaces,...)
see ZFINTERFACE_DECLARE
Definition ZFObjectInterface.h:169
#define zfimplement
shows class implement from interface, see ZFInterface
Definition ZFObjectInterface.h:24
#define zfinterface
shows the type is an interface, see ZFInterface
Definition ZFObjectInterface.h:20
#define ZFINTERFACE_DECLARE(InterfaceName, ParentInterface,...)
see ZFInterface
Definition ZFObjectInterface.h:100
observer types for ZFObject
#define ZFEVENT_GLOBAL(ZFLIB_, YourEvent)
declare a observer event in global scope, see ZFEVENT
Definition ZFObjectObserver.h:357
ZFCoreArray< zfauto > ZFStyleGetAllValue(void)
see ZFStyleGetAll
Definition ZFStyleable.h:424
void ZFStyleSet(const zfstring &styleKey, ZFStyleable *styleValue)
used to store style holder
void ZFStyleRemoveAll(void)
remove all styles, see ZFStyleSet
void ZFStyleGetAllKeyT(ZFCoreArray< zfstring > &styleKey)
see ZFStyleGetAll
void ZFStyleUpdateBegin()
see ZFStyleSet
void ZFStyleGetAllValueT(ZFCoreArray< zfauto > &styleValue)
see ZFStyleGetAll
zfauto ZFStyleGet(const zfstring &styleKey)
see ZFStyleSet
ZFCoreArray< zfstring > ZFStyleGetAllKey(void)
see ZFStyleGetAll
Definition ZFStyleable.h:414
void ZFStyleUpdateEnd()
see ZFStyleSet
void ZFStyleDefaultApplyAutoCopy(ZFStyleable *style)
util method to setup automatically copy style from ZFStyleable::defaultStyle if its property value ch...
void ZFStyleGetAll(ZFCoreArray< zfstring > &styleKey, ZFCoreArray< zfauto > &styleValue)
get all styles, for debug use only, see ZFStyleSet
light weight array
Definition ZFCoreArray.h:348
base class of all objects
Definition ZFObjectCore.h:195
info for a property for ZFObject, see ZFPROPERTY_RETAIN for more info
Definition ZFProperty.h:27
styleable element that can apply style from another object
Definition ZFStyleable.h:29
const zfstring & styleKey(void)
see ZFStyleSet
ZFCoreArray< const ZFProperty * > styleablePropertyGetAll(void)
return a list of styleable property, for debug use only
virtual zfbool styleableIsDefaultStyle(void)
true if this object is defaultStyle
Definition ZFStyleable.h:56
virtual zfanyT< ZFStyleable > defaultStyle(void)
return default style of this instance
zfbool progressUpdate(ZFStyleable *from, ZFStyleable *to, zffloat progress)
update object according to progress
void styleablePropertyGetAllT(ZFCoreArray< const ZFProperty * > &ret)
return a list of styleable property, for debug use only
virtual void styleableOnCopyFrom(ZFObject *anotherStyleable)
for subclass to achieve custom style copy step, called by copyFrom, see ZFStyleable
virtual zfautoT< ZFStyleable > copy(void)
return a copy of this object
virtual void copyFrom(ZFObject *anotherStyleable)
copy from another object
void propStyle(const zfstring &propertyName, const zfstring &styleKey)
see ZFStyleSet
const zfstring & propStyle(const zfstring &propertyName)
see ZFStyleSet
virtual void styleableOnCopyPropertyFrom(ZFObject *anotherStyleable, const ZFProperty *property)
copy property with styleable logic
virtual zfbool progressOnUpdate(ZFStyleable *from, ZFStyleable *to, zffloat progress)
see progressUpdate
Definition ZFStyleable.h:116
void styleKey(const zfstring &styleKey)
see ZFStyleSet
see zfany
Definition zfany.h:113
a ZFObject holder which would release content object automatically when destroyed
Definition zfautoFwd.h:34
type restrict version of zfauto
Definition zfautoFwd.h:108