Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
TplWindowRendererProperty.h
1 /***********************************************************************
2  created: 27/08/2011
3  author: Hans Mackowiak
4 
5  purpose:
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _TplWindowRendererProperty_h_
30 #define _TplWindowRendererProperty_h_
31 
32 #include "CEGUI/TplProperty.h"
33 
34 // Start of CEGUI namespace section
35 namespace CEGUI
36 {
37 
38 template<class C, typename T>
40 {
41 public:
43  const String& name, const String& help, const String& origin,
44  typename TplProperty<C, T>::Setter setter,
45  typename TplProperty<C, T>::GetterFunctor getter,
46  typename TplProperty<C, T>::Helper::pass_type defaultValue = T(),
47  bool writesXML = true) :
48 
49  TplProperty<C, T>(name, help, origin,
50  setter, getter,
51  defaultValue, writesXML)
52  {}
53 
54  virtual Property* clone() const
55  {
56  return CEGUI_NEW_AO TplWindowRendererProperty<C, T>(*this);
57  }
58 
59 protected:
63  {
64  C* instance = static_cast<C*>(
65  static_cast<const Window*>(receiver)->getWindowRenderer());
66 
67  CEGUI_CALL_MEMBER_FN(*instance, this->d_setter)(value);
68  }
69 
72  getNative_impl(const PropertyReceiver* receiver) const
73  {
74  const C* instance = static_cast<const C*>(
75  static_cast<const Window*>(receiver)->getWindowRenderer());
76 
77  return this->d_getter(instance);
78  }
79 };
80 
90 #define CEGUI_DEFINE_WINDOW_RENDERER_PROPERTY(class_type, property_native_type, name, help, setter, getter, default_value)\
91 {\
92  static ::CEGUI::TplWindowRendererProperty<class_type, property_native_type> sProperty(\
93  name, help, TypeName, setter, getter, default_value);\
94  \
95  this->registerProperty(&sProperty);\
96 }
97 
98 
110 #define CEGUI_DEFINE_WINDOW_RENDERER_PROPERTY_NO_XML(class_type, property_native_type, name, help, setter, getter, default_value)\
111 {\
112  static ::CEGUI::TplWindowRendererProperty<class_type, property_native_type> sProperty(\
113  name, help, TypeName, setter, getter, default_value, false);\
114  \
115  this->registerProperty(&sProperty,true);\
116 }
117 } // End of CEGUI namespace section
118 
119 #endif // end of guard _TplWindowRendererProperty_h_