Crazy Eddie's GUI System  ${CEGUI_VERSION}
required.h
1 /***********************************************************************
2  created: 16/3/2005
3  author: Tomas Lindquist Olsen
4 
5  purpose: Header that includes the necessary stuff needed for the Lua bindings
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 #include "CEGUI/CEGUI.h"
30 #include "CEGUI/ScriptModules/Lua/ScriptModule.h"
31 #include "CEGUI/ScriptModules/Lua/Functor.h"
32 #include "CEGUI/RenderingContext.h"
33 #include "CEGUI/RenderingWindow.h"
34 #include "CEGUI/GeometryBuffer.h"
35 #include "CEGUI/Vertex.h"
36 #include "CEGUI/RenderEffect.h"
37 #include "CEGUI/PropertyHelper.h"
38 #include <fstream>
39 
40 #define __operator_increment operator++
41 #define __operator_decrement operator--
42 #define __operator_dereference operator*
43 
44 #define LuaFunctorSubscribeEvent CEGUI::LuaFunctor::SubscribeEvent
45 
46 //This is used to keep compilers happy
47 #define CEGUIDeadException(e) &
48 
49 #if defined(_MSC_VER) && !defined(snprintf)
50 # define snprintf _snprintf
51 #endif
52 
53 // map the utf8string funcs to c-string funcs
54 #define tolua_pushutf8string(x,y) tolua_pushstring(x,y)
55 #define tolua_isutf8string tolua_isstring
56 #define tolua_isutf8stringarray tolua_isstringarray
57 #define tolua_pushfieldutf8string(L,lo,idx,s) tolua_pushfieldstring(L, lo, idx, s)
58 #define tolua_toutf8string tolua_tostring
59 #define tolua_tofieldutf8string tolua_tofieldstring
60 
61 typedef CEGUI::String string;
62 typedef CEGUI::encoded_char* utf8string;
63 
64 namespace CEGUI
65 {
66 
67 /*************************************************************************
68  Helper class to enable us to represent an Event::Connection object
69  (which is actually a RefCounted<BoundSlot> object)
70 *************************************************************************/
72 {
73  RefCounted<BoundSlot> d_slot;
74 
75 public:
77  bool connected() const;
78  void disconnect();
79 };
80 
81 /*************************************************************************
82  Functions for getting Thumb range pairs as two return values
83 *************************************************************************/
84 void ceguiLua_Thumb_getHorzRange(Thumb* wnd, float* min, float* max);
85 void ceguiLua_Thumb_getVertRange(Thumb* wnd, float* min, float* max);
86 
87 
88 /*************************************************************************
89  Functions for creating list box items
90 *************************************************************************/
91 ListboxTextItem* ceguiLua_createListboxTextItem(const String& text, uint item_id, void* item_data, bool disabled, bool auto_delete);
92 
93 /*************************************************************************
94 Functions for creating tree items
95 *************************************************************************/
96 TreeItem* ceguiLua_createTreeItem(const String& text, uint item_id, void* item_data, bool disabled, bool auto_delete);
97 
98 /************************************************************************
99  Stuff needed to make the iterators work
100 *************************************************************************/
110 typedef ImageManager::ImagePair ImagePair;
111 
112 template <typename T>
113 inline PropertyIterator ceguiLua_getPropertyIterator(const T* self)
114 {
115  return static_cast<const PropertySet*>(self)->getPropertyIterator();
116 }
117 
118 template <typename T>
119 inline EventIterator ceguiLua_getEventIterator(const T* self)
120 {
121  return static_cast<const EventSet*>(self)->getEventIterator();
122 }
123 
124 
125 /************************************************************************
126  OutStream
127 *************************************************************************/
128 typedef std::ofstream FileStream;
129 void ceguiLua_FileStream_open(FileStream*, const char* filename);
130 
131 
132 /************************************************************************
133  wrapper class for PropertyHelper to de-templatise it.
134 *************************************************************************/
136 {
137 public:
138  static float stringToFloat(const String& str);
139  static unsigned int stringToUint(const String& str);
140  static bool stringToBool(const String& str);
141  static Sizef stringToSize(const String& str);
142  static Vector2f stringToVector2(const String& str);
143  static Rectf stringToRect(const String& str);
144  static const Image* stringToImage(const String& str);
145  static Colour stringToColour(const String& str);
146  static ColourRect stringToColourRect(const String& str);
147  static UDim stringToUDim(const String& str);
148  static UVector2 stringToUVector2(const String& str);
149  static USize stringToUSize(const String& str);
150  static URect stringToURect(const String& str);
151  static AspectMode stringToAspectMode(const String& str);
152 
153  static String floatToString(float val);
154  static String uintToString(unsigned int val);
155  static String boolToString(bool val);
156  static String sizeToString(const Sizef& val);
157  static String vector2ToString(const Vector2f& val);
158  static String rectToString(const Rectf& val);
159  static String imageToString(const Image* val);
160  static String colourToString(const Colour& val);
161  static String colourRectToString(const ColourRect& val);
162  static String udimToString(const UDim& val);
163  static String uvector2ToString(const UVector2& val);
164  static String usizeToString(const USize& val);
165  static String urectToString(const URect& val);
166  static String aspectModeToString(AspectMode val);
167 };
168 
169 }
170 
171 // the binding file generates alot of
172 // warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
173 #if defined(_MSC_VER)
174 # pragma warning(disable : 4800)
175 #endif
176 
AspectMode
How aspect ratio should be maintained.
Definition: cegui/include/CEGUI/Size.h:45
Interface for Image.
Definition: cegui/include/CEGUI/Image.h:158
Main namespace for Crazy Eddie's GUI Library.
Definition: cegui/include/CEGUI/Affector.h:42
iterator for vectors
Definition: cegui/include/CEGUI/IteratorBase.h:287
Definition: required.h:71
Class that holds details of colours for the four corners of a rectangle.
Definition: cegui/include/CEGUI/ColourRect.h:43
Base class for tree items.
Definition: cegui/include/CEGUI/widgets/TreeItem.h:57
Class that contains a collection of Property objects.
Definition: cegui/include/CEGUI/PropertySet.h:56
Base class for Thumb widget.
Definition: cegui/include/CEGUI/widgets/Thumb.h:55
struct used to hold mapping information required to create a falagard based window.
Definition: cegui/include/CEGUI/WindowFactoryManager.h:70
utf8 encoded_char
encoded char signifies that it's a char (8bit) with encoding (in this case utf8)
Definition: cegui/include/CEGUI/String.h:50
Class used for textual items in a list box.
Definition: cegui/include/CEGUI/widgets/ListboxTextItem.h:42
Definition: required.h:135
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
Dimension that has both a relative 'scale' portion and and absolute 'offset' portion.
Definition: cegui/include/CEGUI/UDim.h:92
std::pair< Image *, ImageFactory * > ImagePair
One entry in the image container.
Definition: cegui/include/CEGUI/ImageManager.h:190
String class used within the GUI system.
Definition: cegui/include/CEGUI/String.h:62