Crazy Eddie's GUI System  ${CEGUI_VERSION}
python_CEGUI.h
1 #include <vector>
2 #include <string>
3 #include <map>
4 #include <iostream>
5 
6 #include "CEGUI/CEGUI.h"
7 #include "CEGUI/falagard/XMLEnumHelper.h"
8 
9 namespace boost
10 {
11  /*
12  * Workaround that allows users to inherit CEGUI classes with methods
13  * that deal with strings (almost all classes)
14  *
15  * The situation:
16  * boost python can't recognize boost::ref(const CEGUI::String&) and doesn't
17  * auto convert it to python unicode string. This works for all types that are
18  * registered normally (CEGUI::String is always converted, the class is unknown
19  * in python).
20  *
21  * The solution:
22  * Make an overloaded version of boost::ref that just returns what it gets.
23  *
24  * Is this horrible?
25  * YES!
26  */
27  inline const CEGUI::String& ref(const CEGUI::String& v)
28  {
29  return v;
30  }
31 }
32 
33 namespace CEGUI
34 {
35 
37 {
38 public:
39  static float stringToFloat(const String& str)
40  {
42  }
43  static unsigned int stringToUint(const String& str)
44  {
46  }
47  static bool stringToBool(const String& str)
48  {
50  }
51  static Sizef stringToSize(const String& str)
52  {
54  }
55  static Vector2f stringToVector2(const String& str)
56  {
58  }
59  static Rectf stringToRect(const String& str)
60  {
62  }
63  static const Image* stringToImage(const String& str)
64  {
66  }
67  static Colour stringToColour(const String& str)
68  {
70  }
71  static ColourRect stringToColourRect(const String& str)
72  {
74  }
75  static UDim stringToUDim(const String& str)
76  {
78  }
79  static UVector2 stringToUVector2(const String& str)
80  {
82  }
83  static URect stringToURect(const String& str)
84  {
86  }
87  static UBox stringToUBox(const String& str)
88  {
90  }
91 
92  static String floatToString(float val)
93  {
95  }
96  static String uintToString(unsigned int val)
97  {
99  }
100  static String boolToString(bool val)
101  {
102  return PropertyHelper<bool>::toString(val);
103  }
104  static String sizeToString(const Sizef& val)
105  {
107  }
108  static String vector2ToString(const Vector2f& val)
109  {
111  }
112  static String rectToString(const Rectf& val)
113  {
115  }
116  static String imageToString(const Image* val)
117  {
119  }
120  static String colourToString(const Colour& val)
121  {
123  }
124  static String colourRectToString(const ColourRect& val)
125  {
127  }
128  static String udimToString(const UDim& val)
129  {
130  return PropertyHelper<UDim>::toString(val);
131  }
132  static String uvector2ToString(const UVector2& val)
133  {
135  }
136  static String urectToString(const URect& val)
137  {
139  }
140  static String uboxToString(const UBox& val)
141  {
142  return PropertyHelper<UBox>::toString(val);
143  }
144 };
145 
146 
148 {
149 public:
150  static VerticalFormatting stringToVertFormat(const String& str)
151  {
153  }
154  static HorizontalFormatting stringToHorzFormat(const String& str)
155  {
157  }
158  static VerticalAlignment stringToVertAlignment(const String& str)
159  {
161  }
162  static HorizontalAlignment stringToHorzAlignment(const String& str)
163  {
165  }
166  static DimensionType stringToDimensionType(const String& str)
167  {
169  }
170  static VerticalTextFormatting stringToVertTextFormat(const String& str)
171  {
173  }
174  static HorizontalTextFormatting stringToHorzTextFormat(const String& str)
175  {
177  }
178  static FontMetricType stringToFontMetricType(const String& str)
179  {
181  }
182  static DimensionOperator stringToDimensionOperator(const String& str)
183  {
185  }
186  static FrameImageComponent stringToFrameImageComponent(const String& str)
187  {
189  }
190  static ChildEventAction stringToChildEventAction(const String& str)
191  {
193  }
194 
195  static String vertFormatToString(VerticalFormatting val)
196  {
198  }
199  static String horzFormatToString(HorizontalFormatting val)
200  {
202  }
203  static String vertAlignmentToString(VerticalAlignment val)
204  {
206  }
207  static String horzAlignmentToString(HorizontalAlignment val)
208  {
210  }
211  static String dimensionTypeToString(DimensionType val)
212  {
214  }
215  static String vertTextFormatToString(VerticalTextFormatting val)
216  {
218  }
219  static String horzTextFormatToString(HorizontalTextFormatting val)
220  {
222  }
223  static String fontMetricTypeToString(FontMetricType val)
224  {
226  }
227  static String dimensionOperatorToString(DimensionOperator val)
228  {
230  }
231  static String frameImageComponentToString(FrameImageComponent val)
232  {
234  }
235  static String childEventActionToStringn(ChildEventAction val)
236  {
238  }
239 };
240 
241 }
242 
243 // First we create a magic namespace to hold all our aliases
244 namespace pyplusplus
245 {
246  namespace aliases
247  {
248  typedef ::CEGUI::RefCounted< CEGUI::FormattedRenderedString > RefCountedFormattedRenderedString;
249 
250  typedef ::CEGUI::NamedXMLResourceManager<CEGUI::Font, CEGUI::Font_xmlHandler> NamedXMLResourceManagerFont;
251  typedef ::CEGUI::NamedXMLResourceManager<CEGUI::Scheme, CEGUI::Scheme_xmlHandler> NamedXMLResourceManagerScheme;
252 
253  typedef ::CEGUI::Vector2<float> Vector2;
254  typedef ::CEGUI::Vector3<float> Vector3;
255  typedef ::CEGUI::Size<float> Size;
256  typedef ::CEGUI::Rect<float> Rect;
257  typedef ::CEGUI::Vector2<CEGUI::UDim> UVector2;
258  typedef ::CEGUI::Rect<CEGUI::UDim> URect;
259  typedef ::CEGUI::Size<CEGUI::UDim> USize;
260 
261  typedef std::vector<CEGUI::ListboxItem*
262  CEGUI_VECTOR_ALLOC(CEGUI::ListboxItem*)> ListBoxItemPtrVector;
263  // typedef std::vector<CEGUI::Scheme::AliasMapping> AliasMappingVector;
264  typedef std::vector<CEGUI::PropertyInitialiser
265  CEGUI_VECTOR_ALLOC(CEGUI::PropertyInitialiser)> PropertyInitialiserVector;
266  // typedef std::vector<CEGUI::Scheme::FalagardMapping> FalagardMappingVector;
267  // typedef std::vector<CEGUI::Scheme::LoadableUIElement> LoadableUIElementVector;
268  // typedef std::vector<CEGUI::Scheme::UIElementFactory> UIElementFactoryVector;
269  // typedef std::vector<CEGUI::Scheme::UIModule> UIModuleVector;
270 
271  typedef ::CEGUI::Event::Connection Connection;
272  typedef ::CEGUI::Event::Subscriber Subscriber;
273  typedef ::CEGUI::EventSet::EventIterator EventIterator;
274 
275  typedef ::CEGUI::FontManager::FontIterator FontIterator;
276  typedef ::CEGUI::ImageManager::ImageIterator ImageIterator;
277  typedef ::CEGUI::PropertySet::PropertyIterator PropertyIterator;
278  typedef ::CEGUI::Scheme::LoadableUIElementIterator LoadableUIElementIterator;
279  typedef ::CEGUI::SchemeManager::SchemeIterator SchemeIterator;
280  typedef ::CEGUI::WindowFactoryManager::WindowFactoryIterator WindowFactoryIterator;
281  typedef ::CEGUI::WindowFactoryManager::TypeAliasIterator TypeAliasIterator;
282  typedef ::CEGUI::WindowFactoryManager::FalagardMappingIterator FalagardMappingIterator;
283  typedef ::CEGUI::WindowManager::WindowIterator WindowIterator;
284  typedef ::CEGUI::WidgetLookFeel::PropertyDefinitionIterator PropertyDefinitionIterator;
285 
286  typedef std::pair<float, float> StdPairFloatFloat;
287  typedef std::pair<CEGUI::String, CEGUI::String> StdPairCEGUIStringString;
288  typedef std::pair<CEGUI::Image*, CEGUI::ImageFactory*> StdPairCEGUIImageImageFactory;
289 
290  typedef std::map<std::string, std::string
291  CEGUI_MAP_ALLOC(std::string, std::string)> StringMap;
292  typedef std::vector<std::string
293  CEGUI_VECTOR_ALLOC(std::string)> StringVector;
294 
295  typedef CEGUI::Singleton<CEGUI::AnimationManager> SingletonAnimationManager;
296  typedef CEGUI::Singleton<CEGUI::Logger> SingletonLogger;
297  typedef CEGUI::Singleton<CEGUI::FontManager> SingletonFontManager;
298  typedef CEGUI::Singleton<CEGUI::GlobalEventSet> SingletonGlobalEventSet;
299  typedef CEGUI::Singleton<CEGUI::ImageManager> SingletonImageManager;
300  typedef CEGUI::Singleton<CEGUI::MouseCursor> SingletonMouseCursor;
301  typedef CEGUI::Singleton<CEGUI::RenderEffectManager> SingletonRenderEffectManager;
302  typedef CEGUI::Singleton<CEGUI::SchemeManager> SingletonSchemeManager;
303  typedef CEGUI::Singleton<CEGUI::System> SingletonSystem;
304  typedef CEGUI::Singleton<CEGUI::WidgetLookManager> SingletonWidgetLookManager;
305  typedef CEGUI::Singleton<CEGUI::WindowFactoryManager> SingletonWindowFactoryManager;
306  typedef CEGUI::Singleton<CEGUI::WindowManager> SingletonWindowManager;
307  typedef CEGUI::Singleton<CEGUI::WindowRendererManager> SingletonWindowRendererManager;
308 
309  typedef unsigned int Group;
310  typedef std::map<CEGUI::String, CEGUI::String, CEGUI::StringFastLessCompare
311  CEGUI_MAP_ALLOC(CEGUI::String, CEGUI::String)> ResourceGroupMap;
312  typedef CEGUI::RefCounted<CEGUI::BoundSlot> Connection;
313  typedef CEGUI::SubscriberSlot Subscriber;
314  typedef std::multimap<Group, Connection
315  CEGUI_MULTIMAP_ALLOC(Group, Connection)> SlotContainer;
316  typedef std::map<CEGUI::String, CEGUI::Event*, CEGUI::StringFastLessCompare
317  CEGUI_MAP_ALLOC(CEGUI::String, CEGUI::String)> EventMap;
318  typedef std::map<CEGUI::String, CEGUI::Font*, CEGUI::StringFastLessCompare
319  CEGUI_MAP_ALLOC(CEGUI::String, CEGUI::Font*)> FontRegistry;
320  typedef std::pair<CEGUI::Window*, bool> WindowStackEntry;
321  typedef std::vector<WindowStackEntry
322  CEGUI_VECTOR_ALLOC(WindowStackEntry)> WindowStack;
323  typedef std::map<CEGUI::String, CEGUI::Property*, CEGUI::StringFastLessCompare
324  CEGUI_MAP_ALLOC(CEGUI::String, CEGUI::Property*)> PropertyRegistry;
325  typedef std::map<CEGUI::String, CEGUI::String, CEGUI::StringFastLessCompare
326  CEGUI_MAP_ALLOC(CEGUI::String, CEGUI::String)> UserStringMap;
327  typedef std::set<CEGUI::String, CEGUI::StringFastLessCompare> StringSet;
328  typedef std::vector<CEGUI::String
329  CEGUI_VECTOR_ALLOC(CEGUI::String)> TargetTypeStack;
330  typedef std::map<CEGUI::String, CEGUI::Window*, CEGUI::StringFastLessCompare
331  CEGUI_MAP_ALLOC(CEGUI::String, CEGUI::Window*)> WindowRegistry;
332  typedef std::vector<CEGUI::Window*
333  CEGUI_VECTOR_ALLOC(CEGUI::Window*)> WindowVector;
334  typedef std::vector<CEGUI::Property*
335  CEGUI_VECTOR_ALLOC(CEGUI::Property*)> PropertyList;
336  typedef std::map<CEGUI::String, CEGUI::WindowRendererFactory*, CEGUI::StringFastLessCompare
337  CEGUI_MAP_ALLOC(CEGUI::String, CEGUI::WindowRendererFactory*)> WR_Registry;
338  typedef std::map<CEGUI::String, CEGUI::String, CEGUI::StringFastLessCompare
339  CEGUI_MAP_ALLOC(CEGUI::String, CEGUI::String)> AttributeMap;
340  }
341 }
342 
343 // then we exposed everything needed (and more) to ensure GCCXML makes them visible to Py++
344 //
345 
346 // this is a gcc-only workaround, don't do this at build time
347 #ifdef __GCCXML__
348 
349 namespace python_CEGUI
350 {
351  namespace details
352  {
353  inline void instantiate()
354  {
355  sizeof( ::std::pair<float, float>);
358 
369  sizeof( ::CEGUI::String::iterator );
370  sizeof( ::CEGUI::Vector2< float > );
371  sizeof( ::CEGUI::Vector3< float > );
372  sizeof( ::CEGUI::Size< float > );
373  sizeof( ::CEGUI::Rect< float > );
377 
378  sizeof( ::std::pair<float, float> );
379  sizeof( ::std::pair<CEGUI::String, CEGUI::String> );
380  sizeof( ::std::pair<CEGUI::Image*, CEGUI::ImageFactory*> );
381 
382  // seems that doing an sizeof ( ::CEGUI::EventSet::Iterator ); doesn't expose the class :(
385  //sizeof( CEGUI::ConstMapIterator<std::map<CEGUI::String, CEGUI::Window*, CEGUI::StringFastLessCompare CEGUI_MAP_ALLOC(CEGUI::String, CEGUI::Window*) > > );
400  //sizeof( CEGUI::ConstVectorIterator<std::vector<CEGUI::PropertyInitialiser CEGUI_VECTOR_ALLOC(CEGUI::PropertyInitialiser) > > );
408  }
409  }
410 }
411 
412 #endif
413 
Definition: python_CEGUI.h:36
Functor that can be used as comparator in a std::map with String keys. It&#39;s faster than using the def...
Definition: cegui/include/CEGUI/String.h:5579
Definition: python_CEGUI.h:147
Class that encapsulates a single layer of imagery.
Definition: cegui/include/CEGUI/falagard/LayerSpecification.h:45
Base-class for WindowRendererFactory.
Definition: cegui/include/CEGUI/WindowRenderer.h:237
Definition: python_CEGUI.h:9
regular iterator for String.
Definition: cegui/include/CEGUI/String.h:98
VerticalFormatting
Enumeration of possible values to indicate the vertical formatting to be used for an image component...
Definition: cegui/include/CEGUI/falagard/Enums.h:58
Class used as a three dimensional vector.
Definition: cegui/include/CEGUI/ForwardRefs.h:123
Interface for Image.
Definition: cegui/include/CEGUI/Image.h:158
Main namespace for Crazy Eddie&#39;s GUI Library.
Definition: cegui/include/CEGUI/Affector.h:42
ConstMapIterator< ImageMap > ImageIterator
ConstBaseIterator type definition.
Definition: cegui/include/CEGUI/ImageManager.h:198
DimensionOperator
Enumeration of values representing mathematical operations on dimensions.
Definition: cegui/include/CEGUI/falagard/Enums.h:122
ConstMapIterator< ObjectRegistry > SchemeIterator
Definition of SchemeIterator type.
Definition: cegui/include/CEGUI/SchemeManager.h:64
iterator for vectors
Definition: cegui/include/CEGUI/IteratorBase.h:287
Class that holds details of colours for the four corners of a rectangle.
Definition: cegui/include/CEGUI/ColourRect.h:43
SubscriberSlot class which is used when subscribing to events.
Definition: cegui/include/CEGUI/SubscriberSlot.h:51
HorizontalTextFormatting
Enumeration of possible values to indicate the horizontal formatting to be used for a text component...
Definition: cegui/include/CEGUI/falagard/Enums.h:95
Class that holds information about a property and it&#39;s required initial value.
Definition: cegui/include/CEGUI/falagard/PropertyInitialiser.h:40
CEGUI::SubscriberSlot Subscriber
Subscriber object type. This is now just a typedef to SubscriberSlot, the use of the name Event::Subs...
Definition: cegui/include/CEGUI/Event.h:76
Class encapsulating the &#39;Unified Box&#39; - this is usually used for margin.
Definition: cegui/include/CEGUI/UDim.h:247
Definition: cegui/include/CEGUI/Singleton.h:55
Class that encapsulates a typeface.
Definition: cegui/include/CEGUI/Font.h:58
RefCounted< BoundSlot > Connection
Connection object. This is a thin &#39;smart pointer&#39; wrapper around the actual BoundSlot that represents...
Definition: cegui/include/CEGUI/Event.h:68
DimensionType
Enumeration of possible values to indicate what a given dimension represents.
Definition: cegui/include/CEGUI/falagard/Enums.h:39
Definition: cegui/include/CEGUI/falagard/XMLEnumHelper.h:37
VerticalTextFormatting
Enumeration of possible values to indicate the vertical formatting to be used for a text component...
Definition: cegui/include/CEGUI/falagard/Enums.h:84
HorizontalFormatting
Enumeration of possible values to indicate the horizontal formatting to be used for an image componen...
Definition: cegui/include/CEGUI/falagard/Enums.h:71
FrameImageComponent
Enumeration of values referencing available images forming a frame component.
Definition: cegui/include/CEGUI/falagard/Enums.h:135
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: cegui/include/CEGUI/Window.h:149
Base class for list box items.
Definition: cegui/include/CEGUI/widgets/ListboxItem.h:51
Helper class used to convert various data types to and from the format expected in Property strings...
Definition: cegui/include/CEGUI/ForwardRefs.h:84
Class representing colour values within the system.
Definition: cegui/include/CEGUI/Colour.h:44
iterator class for maps
Definition: cegui/include/CEGUI/IteratorBase.h:196
ChildEventAction
Enumeration of actions a WidgetLook can take in response to some event firing on a child WidgetCompon...
Definition: cegui/include/CEGUI/falagard/Enums.h:154
Definition: python_CEGUI.h:244
Defines an &#39;event&#39; which can be subscribed to by interested parties.
Definition: cegui/include/CEGUI/Event.h:57
Dimension that has both a relative &#39;scale&#39; portion and and absolute &#39;offset&#39; portion.
Definition: cegui/include/CEGUI/UDim.h:92
An abstract class that defines the interface to access object properties by name. ...
Definition: cegui/include/CEGUI/Property.h:60
VerticalAlignment
Enumerated type used when specifying vertical alignments for Element.
Definition: cegui/include/CEGUI/Element.h:130
ConstMapIterator< ObjectRegistry > FontIterator
ConstBaseIterator type definition.
Definition: cegui/include/CEGUI/FontManager.h:189
FontMetricType
Enumeration of possible values to indicate a particular font metric.
Definition: cegui/include/CEGUI/falagard/Enums.h:111
HorizontalAlignment
Enumerated type used when specifying horizontal alignments for Element.
Definition: cegui/include/CEGUI/Element.h:52
String class used within the GUI system.
Definition: cegui/include/CEGUI/String.h:62