/usr/include/wx-3.0/wx/xtiprop.h is in wx3.0-headers 3.0.2-1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | /////////////////////////////////////////////////////////////////////////////
// Name: wx/xtiprop.h
// Purpose: XTI properties
// Author: Stefan Csomor
// Modified by: Francesco Montorsi
// Created: 27/07/03
// Copyright: (c) 1997 Julian Smart
// (c) 2003 Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _XTIPROP_H_
#define _XTIPROP_H_
#include "wx/defs.h"
#if wxUSE_EXTENDED_RTTI
#include "wx/xti.h"
#include "wx/any.h"
/*
class WXDLLIMPEXP_BASE wxObject;
class WXDLLIMPEXP_BASE wxClassInfo;
class WXDLLIMPEXP_BASE wxDynamicClassInfo;
*/
class WXDLLIMPEXP_BASE wxHashTable;
class WXDLLIMPEXP_BASE wxHashTable_Node;
class WXDLLIMPEXP_BASE wxEvent;
class WXDLLIMPEXP_BASE wxEvtHandler;
// ----------------------------------------------------------------------------
// Property Accessors
//
// wxPropertySetter/Getter/CollectionGetter/CollectionAdder are all property
// accessors which are managed by wxPropertyAccessor class which in turn is
// handled by wxPropertyInfo.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxPropertySetter
{
public:
wxPropertySetter( const wxString name ) { m_name = name; }
virtual ~wxPropertySetter() {}
virtual void Set( wxObject *object, const wxAny &variantValue ) const = 0;
const wxString& GetName() const { return m_name; }
private:
wxString m_name;
};
class WXDLLIMPEXP_BASE wxPropertyGetter
{
public:
wxPropertyGetter( const wxString name ) { m_name = name; }
virtual ~wxPropertyGetter() {}
virtual void Get( const wxObject *object, wxAny& result) const = 0;
const wxString& GetName() const { return m_name; }
private:
wxString m_name;
};
class WXDLLIMPEXP_BASE wxPropertyCollectionGetter
{
public:
wxPropertyCollectionGetter( const wxString name ) { m_name = name; }
virtual ~wxPropertyCollectionGetter() {}
virtual void Get( const wxObject *object, wxAnyList& result) const = 0;
const wxString& GetName() const { return m_name; }
private:
wxString m_name;
};
template<typename coll_t> void WXDLLIMPEXP_BASE \
wxCollectionToVariantArray( const coll_t& coll, wxAnyList& result );
class WXDLLIMPEXP_BASE wxPropertyCollectionAdder
{
public:
wxPropertyCollectionAdder( const wxString name ) { m_name = name; }
virtual ~wxPropertyCollectionAdder() {}
virtual void Add( wxObject *object, const wxAny &variantValue ) const= 0;
const wxString& GetName() const { return m_name; }
private:
wxString m_name;
};
#define wxPROPERTY_SETTER( property, Klass, valueType, setterMethod ) \
class wxPropertySetter##property : public wxPropertySetter \
{ \
public: \
wxINFUNC_CLASS_TYPE_FIX(Klass) \
wxPropertySetter##property() : wxPropertySetter( wxT(#setterMethod) ) {} \
virtual ~wxPropertySetter##property() {} \
\
void Set( wxObject *object, const wxAny &variantValue ) const \
{ \
Klass *obj = dynamic_cast<Klass*>(object); \
valueType tempobj; \
if ( variantValue.GetAs(&tempobj) ) \
obj->setterMethod(tempobj); \
else \
obj->setterMethod(*wxANY_AS(variantValue, valueType*)); \
} \
};
#define wxPROPERTY_GETTER( property, Klass, valueType, gettermethod ) \
class wxPropertyGetter##property : public wxPropertyGetter \
{ \
public: \
wxINFUNC_CLASS_TYPE_FIX(Klass) \
wxPropertyGetter##property() : wxPropertyGetter( wxT(#gettermethod) ) {} \
virtual ~wxPropertyGetter##property() {} \
\
void Get( const wxObject *object, wxAny &result) const \
{ \
const Klass *obj = dynamic_cast<const Klass*>(object); \
result = wxAny( obj->gettermethod() ); \
} \
};
#define wxPROPERTY_COLLECTION_ADDER( property, Klass, valueType, addermethod ) \
class wxPropertyCollectionAdder##property : public wxPropertyCollectionAdder \
{ \
public: \
wxINFUNC_CLASS_TYPE_FIX(Klass) \
wxPropertyCollectionAdder##property() : wxPropertyCollectionAdder( wxT(#addermethod) ) {} \
virtual ~wxPropertyCollectionAdder##property() {} \
\
void Add( wxObject *object, const wxAny &variantValue ) const \
{ \
Klass *obj = dynamic_cast<Klass*>(object); \
valueType tempobj; \
if ( variantValue.GetAs(&tempobj) ) \
obj->addermethod(tempobj); \
else \
obj->addermethod(*wxANY_AS(variantValue, valueType*)); \
} \
};
#define wxPROPERTY_COLLECTION_GETTER( property, Klass, valueType, gettermethod ) \
class wxPropertyCollectionGetter##property : public wxPropertyCollectionGetter \
{ \
public: \
wxINFUNC_CLASS_TYPE_FIX(Klass) \
wxPropertyCollectionGetter##property() : wxPropertyCollectionGetter( wxT(#gettermethod) ) {} \
virtual ~wxPropertyCollectionGetter##property() {} \
\
void Get( const wxObject *object, wxAnyList &result) const \
{ \
const Klass *obj = dynamic_cast<const Klass*>(object); \
wxCollectionToVariantArray( obj->gettermethod(), result ); \
} \
};
class WXDLLIMPEXP_BASE wxPropertyAccessor
{
public:
wxPropertyAccessor( wxPropertySetter *setter, wxPropertyGetter *getter,
wxPropertyCollectionAdder *adder, wxPropertyCollectionGetter *collectionGetter )
{ m_setter = setter; m_getter = getter; m_adder = adder;
m_collectionGetter = collectionGetter; }
virtual ~wxPropertyAccessor() {}
// Setting a simple property (non-collection)
virtual void SetProperty(wxObject *object, const wxAny &value) const
{
if ( m_setter )
m_setter->Set( object, value );
else
wxLogError( wxGetTranslation("SetProperty called w/o valid setter") );
}
// Getting a simple property (non-collection)
virtual void GetProperty(const wxObject *object, wxAny &result) const
{
if ( m_getter )
m_getter->Get( object, result );
else
wxLogError( wxGetTranslation("GetProperty called w/o valid getter") );
}
// Adding an element to a collection property
virtual void AddToPropertyCollection(wxObject *object, const wxAny &value) const
{
if ( m_adder )
m_adder->Add( object, value );
else
wxLogError( wxGetTranslation("AddToPropertyCollection called w/o valid adder") );
}
// Getting a collection property
virtual void GetPropertyCollection( const wxObject *obj, wxAnyList &result) const
{
if ( m_collectionGetter )
m_collectionGetter->Get( obj, result);
else
wxLogError( wxGetTranslation("GetPropertyCollection called w/o valid collection getter") );
}
virtual bool HasSetter() const { return m_setter != NULL; }
virtual bool HasCollectionGetter() const { return m_collectionGetter != NULL; }
virtual bool HasGetter() const { return m_getter != NULL; }
virtual bool HasAdder() const { return m_adder != NULL; }
virtual const wxString& GetCollectionGetterName() const
{ return m_collectionGetter->GetName(); }
virtual const wxString& GetGetterName() const
{ return m_getter->GetName(); }
virtual const wxString& GetSetterName() const
{ return m_setter->GetName(); }
virtual const wxString& GetAdderName() const
{ return m_adder->GetName(); }
protected:
wxPropertySetter *m_setter;
wxPropertyCollectionAdder *m_adder;
wxPropertyGetter *m_getter;
wxPropertyCollectionGetter* m_collectionGetter;
};
class WXDLLIMPEXP_BASE wxGenericPropertyAccessor : public wxPropertyAccessor
{
public:
wxGenericPropertyAccessor( const wxString &propName );
virtual ~wxGenericPropertyAccessor();
void RenameProperty( const wxString& WXUNUSED_UNLESS_DEBUG(oldName),
const wxString& newName )
{
wxASSERT( oldName == m_propertyName ); m_propertyName = newName;
}
virtual bool HasSetter() const { return true; }
virtual bool HasGetter() const { return true; }
virtual bool HasAdder() const { return false; }
virtual bool HasCollectionGetter() const { return false; }
virtual const wxString& GetGetterName() const
{ return m_getterName; }
virtual const wxString& GetSetterName() const
{ return m_setterName; }
virtual void SetProperty(wxObject *object, const wxAny &value) const;
virtual void GetProperty(const wxObject *object, wxAny &value) const;
// Adding an element to a collection property
virtual void AddToPropertyCollection(wxObject *WXUNUSED(object),
const wxAny &WXUNUSED(value)) const
{
wxLogError( wxGetTranslation("AddToPropertyCollection called on a generic accessor") );
}
// Getting a collection property
virtual void GetPropertyCollection( const wxObject *WXUNUSED(obj),
wxAnyList &WXUNUSED(result)) const
{
wxLogError ( wxGetTranslation("GetPropertyCollection called on a generic accessor") );
}
private:
struct wxGenericPropertyAccessorInternal;
wxGenericPropertyAccessorInternal* m_data;
wxString m_propertyName;
wxString m_setterName;
wxString m_getterName;
};
typedef long wxPropertyInfoFlags;
enum
{
// will be removed in future releases
wxPROP_DEPRECATED = 0x00000001,
// object graph property, will be streamed with priority (after constructor properties)
wxPROP_OBJECT_GRAPH = 0x00000002,
// this will only be streamed out and in as enum/set, the internal representation
// is still a long
wxPROP_ENUM_STORE_LONG = 0x00000004,
// don't stream out this property, needed eg to avoid streaming out children
// that are always created by their parents
wxPROP_DONT_STREAM = 0x00000008
};
// ----------------------------------------------------------------------------
// Property Support
//
// wxPropertyInfo is used to inquire of the property by name. It doesn't
// provide access to the property, only information about it. If you
// want access, look at wxPropertyAccessor.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxPropertyInfo
{
friend class /* WXDLLIMPEXP_BASE */ wxDynamicClassInfo;
public:
wxPropertyInfo(wxPropertyInfo* &iter,
wxClassInfo* itsClass,
const wxString& name,
const wxString& typeName,
wxPropertyAccessor *accessor,
wxAny dv,
wxPropertyInfoFlags flags = 0,
const wxString& helpString = wxEmptyString,
const wxString& groupString = wxEmptyString) :
m_itsClass(itsClass),
m_name(name),
m_typeInfo(NULL),
m_typeName(typeName),
m_collectionElementTypeInfo(NULL),
m_accessor(accessor),
m_defaultValue(dv),
m_flags(flags),
m_helpString(helpString),
m_groupString(groupString)
{
Insert(iter);
}
wxPropertyInfo(wxPropertyInfo* &iter,
wxClassInfo* itsClass,
const wxString& name,
wxEventSourceTypeInfo* type,
wxPropertyAccessor *accessor,
wxAny dv,
wxPropertyInfoFlags flags = 0,
const wxString& helpString = wxEmptyString,
const wxString& groupString = wxEmptyString) :
m_itsClass(itsClass),
m_name(name),
m_typeInfo(type),
m_collectionElementTypeInfo(NULL),
m_accessor(accessor),
m_defaultValue(dv),
m_flags(flags),
m_helpString(helpString),
m_groupString(groupString)
{
Insert(iter);
}
wxPropertyInfo(wxPropertyInfo* &iter,
wxClassInfo* itsClass, const wxString& name,
const wxString& collectionTypeName,
const wxString& elementTypeName,
wxPropertyAccessor *accessor,
wxPropertyInfoFlags flags = 0,
const wxString& helpString = wxEmptyString,
const wxString& groupString = wxEmptyString) :
m_itsClass(itsClass),
m_name(name),
m_typeInfo(NULL),
m_typeName(collectionTypeName),
m_collectionElementTypeInfo(NULL),
m_collectionElementTypeName(elementTypeName),
m_accessor(accessor),
m_flags(flags),
m_helpString(helpString),
m_groupString(groupString)
{
Insert(iter);
}
~wxPropertyInfo()
{ Remove(); }
// return the class this property is declared in
const wxClassInfo* GetDeclaringClass() const { return m_itsClass; }
// return the name of this property
const wxString& GetName() const { return m_name; }
// returns the flags of this property
wxPropertyInfoFlags GetFlags() const { return m_flags; }
// returns the short help string of this property
const wxString& GetHelpString() const { return m_helpString; }
// returns the group string of this property
const wxString& GetGroupString() const { return m_groupString; }
// return the element type info of this property (for collections, otherwise NULL)
const wxTypeInfo * GetCollectionElementTypeInfo() const
{
if ( m_collectionElementTypeInfo == NULL )
m_collectionElementTypeInfo = wxTypeInfo::FindType(m_collectionElementTypeName);
return m_collectionElementTypeInfo;
}
// return the type info of this property
const wxTypeInfo * GetTypeInfo() const
{
if ( m_typeInfo == NULL )
m_typeInfo = wxTypeInfo::FindType(m_typeName);
return m_typeInfo;
}
// return the accessor for this property
wxPropertyAccessor* GetAccessor() const { return m_accessor; }
// returns NULL if this is the last property of this class
wxPropertyInfo* GetNext() const { return m_next; }
// returns the default value of this property, its kind may be wxT_VOID if it is not valid
wxAny GetDefaultValue() const { return m_defaultValue; }
private:
// inserts this property at the end of the linked chain which begins
// with "iter" property.
void Insert(wxPropertyInfo* &iter);
// removes this property from the linked chain of the m_itsClass properties.
void Remove();
wxClassInfo* m_itsClass;
wxString m_name;
mutable wxTypeInfo* m_typeInfo;
wxString m_typeName;
mutable wxTypeInfo* m_collectionElementTypeInfo;
wxString m_collectionElementTypeName;
wxPropertyAccessor* m_accessor;
wxAny m_defaultValue;
wxPropertyInfoFlags m_flags;
wxString m_helpString;
wxString m_groupString;
wxPropertyInfo* m_next;
// FIXME: what's this comment about??
// string representation of the default value
// to be assigned by the designer to the property
// when the component is dropped on the container.
};
// stl is giving problems when forwarding declarations, therefore we define it as a subclass
WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMapBase,
class WXDLLIMPEXP_BASE );
class WXDLLIMPEXP_BASE wxPropertyInfoMap : public wxPropertyInfoMapBase {
};
WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxAny, wxStringToAnyHashMapBase,
class WXDLLIMPEXP_BASE );
class WXDLLIMPEXP_FWD_BASE wxStringToAnyHashMap : public wxStringToAnyHashMapBase {
};
#define wxBEGIN_PROPERTIES_TABLE(theClass) \
wxPropertyInfo *theClass::GetPropertiesStatic() \
{ \
typedef theClass class_t; \
static wxPropertyInfo* first = NULL;
#define wxEND_PROPERTIES_TABLE() \
return first; }
#define wxHIDE_PROPERTY( pname ) \
static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \
wxT(#pname), typeid(void).name(), NULL, wxAny(), wxPROP_DONT_STREAM, \
wxEmptyString, wxEmptyString );
#define wxPROPERTY( pname, type, setter, getter, defaultValue, flags, help, group) \
wxPROPERTY_SETTER( pname, class_t, type, setter ) \
static wxPropertySetter##pname _setter##pname; \
wxPROPERTY_GETTER( pname, class_t, type, getter ) \
static wxPropertyGetter##pname _getter##pname; \
static wxPropertyAccessor _accessor##pname( &_setter##pname, \
&_getter##pname, NULL, NULL ); \
static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \
wxT(#pname), typeid(type).name(), &_accessor##pname, \
wxAny(defaultValue), flags, group, help );
#define wxPROPERTY_FLAGS( pname, flags, type, setter, getter,defaultValue, \
pflags, help, group) \
wxPROPERTY_SETTER( pname, class_t, type, setter ) \
static wxPropertySetter##pname _setter##pname; \
wxPROPERTY_GETTER( pname, class_t, type, getter ) \
static wxPropertyGetter##pname _getter##pname; \
static wxPropertyAccessor _accessor##pname( &_setter##pname, \
&_getter##pname, NULL, NULL ); \
static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \
wxT(#pname), typeid(flags).name(), &_accessor##pname, \
wxAny(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group );
#define wxREADONLY_PROPERTY( pname, type, getter,defaultValue, flags, help, group) \
wxPROPERTY_GETTER( pname, class_t, type, getter ) \
static wxPropertyGetter##pname _getter##pname; \
static wxPropertyAccessor _accessor##pname( NULL, &_getter##pname, NULL, NULL ); \
static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \
wxT(#pname), typeid(type).name(),&_accessor##pname, \
wxAny(defaultValue), flags, help, group );
#define wxREADONLY_PROPERTY_FLAGS( pname, flags, type, getter,defaultValue, \
pflags, help, group) \
wxPROPERTY_GETTER( pname, class_t, type, getter ) \
static wxPropertyGetter##pname _getter##pname; \
static wxPropertyAccessor _accessor##pname( NULL, &_getter##pname, NULL, NULL ); \
static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \
wxT(#pname), typeid(flags).name(),&_accessor##pname, \
wxAny(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group );
#define wxPROPERTY_COLLECTION( pname, colltype, addelemtype, adder, getter, \
flags, help, group ) \
wxPROPERTY_COLLECTION_ADDER( pname, class_t, addelemtype, adder ) \
static wxPropertyCollectionAdder##pname _adder##pname; \
wxPROPERTY_COLLECTION_GETTER( pname, class_t, colltype, getter ) \
static wxPropertyCollectionGetter##pname _collectionGetter##pname; \
static wxPropertyAccessor _accessor##pname( NULL, NULL,&_adder##pname, \
&_collectionGetter##pname ); \
static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \
wxT(#pname), typeid(colltype).name(),typeid(addelemtype).name(), \
&_accessor##pname, flags, help, group );
#define wxREADONLY_PROPERTY_COLLECTION( pname, colltype, addelemtype, getter, \
flags, help, group) \
wxPROPERTY_COLLECTION_GETTER( pname, class_t, colltype, getter ) \
static wxPropertyCollectionGetter##pname _collectionGetter##pname; \
static wxPropertyAccessor _accessor##pname( NULL, NULL, NULL, \
&_collectionGetter##pname ); \
static wxPropertyInfo _propertyInfo##pname( first,class_t::GetClassInfoStatic(), \
wxT(#pname), typeid(colltype).name(),typeid(addelemtype).name(), \
&_accessor##pname, flags, help, group );
#define wxEVENT_PROPERTY( name, eventType, eventClass ) \
static wxEventSourceTypeInfo _typeInfo##name( eventType, wxCLASSINFO( eventClass ) ); \
static wxPropertyInfo _propertyInfo##name( first,class_t::GetClassInfoStatic(), \
wxT(#name), &_typeInfo##name, NULL, wxAny() );
#define wxEVENT_RANGE_PROPERTY( name, eventType, lastEventType, eventClass ) \
static wxEventSourceTypeInfo _typeInfo##name( eventType, lastEventType, \
wxCLASSINFO( eventClass ) ); \
static wxPropertyInfo _propertyInfo##name( first, class_t::GetClassInfoStatic(), \
wxT(#name), &_typeInfo##name, NULL, wxAny() );
// ----------------------------------------------------------------------------
// Implementation Helper for Simple Properties
// ----------------------------------------------------------------------------
#define wxIMPLEMENT_PROPERTY(name, type) \
private: \
type m_##name; \
public: \
void Set##name( type const & p) { m_##name = p; } \
type const & Get##name() const { return m_##name; }
#endif // wxUSE_EXTENDED_RTTI
#endif // _XTIPROP_H_
|