29 #ifndef _CEGUIPropertyHelper_h_
30 #define _CEGUIPropertyHelper_h_
32 #include "CEGUI/String.h"
33 #include "CEGUI/Size.h"
34 #include "CEGUI/Vector.h"
35 #include "CEGUI/Quaternion.h"
36 #include "CEGUI/Colour.h"
37 #include "CEGUI/ColourRect.h"
38 #include "CEGUI/UDim.h"
39 #include "CEGUI/Rect.h"
47 # pragma warning(push)
48 # pragma warning(disable : 4996)
52 #define snprintf _snprintf
57 #if __USE_MINGW_ANSI_STDIO != 1
58 #warning __USE_MINGW_ANSI_STDIO must be set to 1 for sscanf and snprintf to work with 64bit integers
61 #pragma GCC diagnostic push
65 #pragma GCC diagnostic ignored "-Wformat"
66 #pragma GCC diagnostic ignored "-Wformat-extra-args"
96 static inline const String& getDataTypeName()
101 static inline return_type fromString(
const String& str)
106 static inline String toString(pass_type val)
122 static inline const String& getDataTypeName()
127 static inline return_type fromString(
const String& str)
132 static inline String toString(pass_type val)
148 static inline const String& getDataTypeName()
153 static inline return_type fromString(
const String& str)
158 static inline String toString(pass_type val)
173 static const String& getDataTypeName()
175 static String type(
"String");
180 static inline return_type fromString(
const String& str)
185 static inline string_return_type toString(pass_type val)
195 typedef float return_type;
196 typedef return_type safe_method_return_type;
197 typedef const float pass_type;
200 static const String& getDataTypeName()
202 static String type(
"float");
207 static inline return_type fromString(
const String& str)
210 sscanf(str.
c_str(),
" %g", &val);
215 static inline string_return_type toString(pass_type val)
218 snprintf(buff,
sizeof(buff),
"%g", val);
227 typedef double return_type;
228 typedef return_type safe_method_return_type;
229 typedef const double pass_type;
232 static const String& getDataTypeName()
234 static String type(
"double");
239 static inline return_type fromString(
const String& str)
242 sscanf(str.
c_str(),
" %lg", &val);
247 static inline string_return_type toString(pass_type val)
250 snprintf(buff,
sizeof(buff),
"%g", val);
260 typedef int return_type;
261 typedef return_type safe_method_return_type;
262 typedef const int pass_type;
265 static const String& getDataTypeName()
267 static String type(
"int");
272 static inline return_type fromString(
const String& str)
275 sscanf(str.
c_str(),
" %d", &val);
280 static inline string_return_type toString(pass_type val)
283 snprintf(buff,
sizeof(buff),
"%d", val);
293 typedef uint return_type;
294 typedef return_type safe_method_return_type;
295 typedef const uint pass_type;
298 static const String& getDataTypeName()
300 static String type(
"uint");
305 static return_type fromString(
const String& str)
308 sscanf(str.
c_str(),
" %u", &val);
313 static string_return_type toString(pass_type val)
316 snprintf(buff,
sizeof(buff),
"%u", val);
326 typedef uint64 return_type;
327 typedef return_type safe_method_return_type;
328 typedef const uint64 pass_type;
331 static const String& getDataTypeName()
333 static String type(
"uint64");
338 static return_type fromString(
const String& str)
341 sscanf(str.
c_str(),
" %llu", &val);
346 static string_return_type toString(pass_type val)
349 snprintf(buff,
sizeof(buff),
"%llu", val);
355 #if CEGUI_STRING_CLASS != CEGUI_STRING_CLASS_UNICODE
362 typedef return_type safe_method_return_type;
364 typedef String string_return_type;
366 static const String& getDataTypeName()
368 static String type(
"char");
373 static return_type fromString(
const String& str)
378 static string_return_type toString(pass_type val)
380 return String(
"") + val;
390 typedef unsigned long return_type;
391 typedef return_type safe_method_return_type;
392 typedef const unsigned long pass_type;
395 static const String& getDataTypeName()
397 static String type(
"unsigned long");
402 static return_type fromString(
const String& str)
404 unsigned long val = 0;
405 sscanf(str.
c_str(),
" %lu", &val);
410 static string_return_type toString(pass_type val)
413 snprintf(buff,
sizeof(buff),
"%lu", val);
423 typedef bool return_type;
424 typedef return_type safe_method_return_type;
425 typedef const bool pass_type;
428 static const String& getDataTypeName()
430 static String type(
"bool");
435 static return_type fromString(
const String& str)
437 return (str == True || str ==
"True");
440 static string_return_type toString(pass_type val)
442 return val ? True : False;
461 static const String& getDataTypeName()
463 static String type(
"AspectMode");
468 static return_type fromString(
const String& str)
474 else if (str == Expand)
484 static string_return_type toString(pass_type val)
500 assert(
false &&
"Invalid aspect mode");
520 static const String& getDataTypeName()
522 static String type(
"Sizef");
527 static return_type fromString(
const String& str)
530 sscanf(str.
c_str(),
" w:%g h:%g", &val.d_width, &val.d_height);
535 static string_return_type toString(pass_type val)
538 snprintf(buff,
sizeof(buff),
"w:%g h:%g", val.d_width, val.d_height);
553 static const String& getDataTypeName()
555 static String type(
"Vector2f");
560 static return_type fromString(
const String& str)
563 sscanf(str.
c_str(),
" x:%g y:%g", &val.d_x, &val.d_y);
568 static string_return_type toString(pass_type val)
571 snprintf(buff,
sizeof(buff),
"x:%g y:%g", val.d_x, val.d_y);
586 static const String& getDataTypeName()
588 static String type(
"Vector3f");
593 static return_type fromString(
const String& str)
596 sscanf(str.
c_str(),
" x:%g y:%g z:%g", &val.d_x, &val.d_y, &val.d_z);
601 static string_return_type toString(pass_type val)
604 snprintf(buff,
sizeof(buff),
"x:%g y:%g z:%g", val.d_x, val.d_y, val.d_z);
619 static const String& getDataTypeName()
621 static String type(
"Quaternion");
626 static return_type fromString(
const String& str)
628 if (strchr(str.
c_str(),
'w') || strchr(str.
c_str(),
'W'))
631 sscanf(str.
c_str(),
" w:%g x:%g y:%g z:%g", &val.
d_w, &val.
d_x, &val.
d_y, &val.
d_z);
638 sscanf(str.
c_str(),
" x:%g y:%g z:%g", &x, &y, &z);
643 static string_return_type toString(pass_type val)
646 snprintf(buff,
sizeof(buff),
"w:%g x:%g y:%g z:%g", val.
d_w, val.
d_x, val.
d_y, val.
d_z);
661 static const String& getDataTypeName()
663 static String type(
"Rectf");
668 static return_type fromString(
const String& str)
670 Rectf val(0, 0, 0, 0);
671 sscanf(str.
c_str(),
" l:%g t:%g r:%g b:%g", &val.d_min.d_x, &val.d_min.d_y, &val.d_max.d_x, &val.d_max.d_y);
676 static string_return_type toString(pass_type val)
679 snprintf(buff,
sizeof(buff),
"l:%g t:%g r:%g b:%g",
680 val.d_min.d_x, val.d_min.d_y, val.d_max.d_x, val.d_max.d_y);
692 typedef const Image*
const pass_type;
695 static const String& getDataTypeName()
697 static String type(
"Image");
702 static return_type fromString(
const String& str);
704 static string_return_type toString(pass_type val);
716 static const String& getDataTypeName()
718 static String type(
"Colour");
723 static return_type fromString(
const String& str)
726 sscanf(str.
c_str(),
" %8X", &val);
731 static string_return_type toString(pass_type val)
734 sprintf(buff,
"%.8X", val.getARGB());
749 static const String& getDataTypeName()
751 static String type(
"ColourRect");
756 static return_type fromString(
const String& str)
761 sscanf(str.
c_str(),
"%8X", &all);
765 argb_t topLeft = 0xFF000000, topRight = 0xFF000000, bottomLeft = 0xFF000000, bottomRight = 0xFF000000;
766 sscanf(str.
c_str(),
"tl:%8X tr:%8X bl:%8X br:%8X", &topLeft, &topRight, &bottomLeft, &bottomRight);
768 return ColourRect(topLeft, topRight, bottomLeft, bottomRight);
771 static string_return_type toString(pass_type val)
774 sprintf(buff,
"tl:%.8X tr:%.8X bl:%.8X br:%.8X", val.d_top_left.getARGB(), val.d_top_right.getARGB(), val.d_bottom_left.getARGB(), val.
d_bottom_right.getARGB());
789 static const String& getDataTypeName()
791 static String type(
"UDim");
796 static return_type fromString(
const String& str)
799 sscanf(str.
c_str(),
" { %g , %g }", &ud.d_scale, &ud.d_offset);
804 static string_return_type toString(pass_type val)
807 snprintf(buff,
sizeof(buff),
"{%g,%g}", val.d_scale, val.d_offset);
822 static const String& getDataTypeName()
824 static String type(
"UVector2");
829 static return_type fromString(
const String& str)
832 sscanf(str.
c_str(),
" { { %g , %g } , { %g , %g } }",
833 &uv.d_x.d_scale, &uv.d_x.d_offset,
834 &uv.d_y.d_scale, &uv.d_y.d_offset);
839 static string_return_type toString(pass_type val)
842 snprintf(buff,
sizeof(buff),
"{{%g,%g},{%g,%g}}",
843 val.d_x.d_scale, val.d_x.d_offset, val.d_y.d_scale, val.d_y.d_offset);
858 static const String& getDataTypeName()
860 static String type(
"USize");
865 static return_type fromString(
const String& str)
868 sscanf(str.
c_str(),
" { { %g , %g } , { %g , %g } }",
869 &uv.d_width.d_scale, &uv.d_width.d_offset,
870 &uv.d_height.d_scale, &uv.d_height.d_offset);
875 static string_return_type toString(pass_type val)
878 snprintf(buff,
sizeof(buff),
"{{%g,%g},{%g,%g}}",
879 val.d_width.d_scale, val.d_width.d_offset, val.d_height.d_scale, val.d_height.d_offset);
894 static const String& getDataTypeName()
896 static String type(
"URect");
901 static return_type fromString(
const String& str)
906 " { { %g , %g } , { %g , %g } , { %g , %g } , { %g , %g } }",
907 &ur.d_min.d_x.d_scale, &ur.d_min.d_x.d_offset,
908 &ur.d_min.d_y.d_scale, &ur.d_min.d_y.d_offset,
909 &ur.d_max.d_x.d_scale, &ur.d_max.d_x.d_offset,
910 &ur.d_max.d_y.d_scale, &ur.d_max.d_y.d_offset
916 static string_return_type toString(pass_type val)
919 snprintf(buff,
sizeof(buff),
"{{%g,%g},{%g,%g},{%g,%g},{%g,%g}}",
920 val.d_min.d_x.d_scale, val.d_min.d_x.d_offset,
921 val.d_min.d_y.d_scale, val.d_min.d_y.d_offset,
922 val.d_max.d_x.d_scale, val.d_max.d_x.d_offset,
923 val.d_max.d_y.d_scale, val.d_max.d_y.d_offset);
938 static const String& getDataTypeName()
940 static String type(
"UBox");
945 static return_type fromString(
const String& str)
950 " { top: { %g , %g } , left: { %g , %g } , bottom: { %g , %g } , right: { %g , %g } }",
951 &ret.d_top.d_scale, &ret.d_top.d_offset,
952 &ret.d_left.d_scale, &ret.d_left.d_offset,
953 &ret.d_bottom.d_scale, &ret.d_bottom.d_offset,
954 &ret.d_right.d_scale, &ret.d_right.d_offset
960 static string_return_type toString(pass_type val)
963 snprintf(buff,
sizeof(buff),
"{top:{%g,%g},left:{%g,%g},bottom:{%g,%g},right:{%g,%g}}",
964 val.d_top.d_scale, val.d_top.d_offset,
965 val.d_left.d_scale, val.d_left.d_offset,
966 val.d_bottom.d_scale, val.d_bottom.d_offset,
967 val.d_right.d_scale, val.d_right.d_offset);
980 typedef const Font*
const pass_type;
983 static const String& getDataTypeName()
985 static String type(
"Font");
990 static return_type fromString(
const String& str);
991 static string_return_type toString(pass_type val);
997 #pragma GCC diagnostic pop
1000 #if defined(_MSC_VER)
1001 #pragma warning(pop)
AspectMode
How aspect ratio should be maintained.
Definition: Size.h:45
Colour d_bottom_right
ColourRect component colours.
Definition: ColourRect.h:222
float d_w
imaginary part
Definition: Quaternion.h:257
Interface for Image.
Definition: Image.h:158
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
float d_y
y component of the vector part
Definition: Quaternion.h:261
float d_x
x component of the vector part
Definition: Quaternion.h:259
size_type length(void) const
Returns the size of the String in code points.
Definition: String.h:621
uint32 argb_t
32 bit ARGB representation of a colour.
Definition: Colour.h:38
Class that holds details of colours for the four corners of a rectangle.
Definition: ColourRect.h:43
float d_z
z component of the vector part
Definition: Quaternion.h:263
static Quaternion eulerAnglesDegrees(float x, float y, float z)
constructs a quaternion from euler angles in degrees
const char * c_str(void) const
Returns contents of the String as a null terminated string of utf8 encoded data.
Definition: String.h:1143
Class encapsulating the 'Unified Box' - this is usually used for margin.
Definition: UDim.h:247
Class that encapsulates a typeface.
Definition: Font.h:58
static const CEGUI::String Shrink
Definitions of the possible values represented as Strings.
Definition: PropertyHelper.h:506
static const CEGUI::String True
Definitions of the possible values represented as Strings.
Definition: PropertyHelper.h:446
Helper class used to convert various data types to and from the format expected in Property strings...
Definition: ForwardRefs.h:84
Class representing colour values within the system.
Definition: Colour.h:44
utf32 value_type
Basic 'code point' type used for String (utf32)
Definition: String.h:69
Dimension that has both a relative 'scale' portion and and absolute 'offset' portion.
Definition: UDim.h:92
Class to represent rotation, avoids Gimbal lock.
Definition: Quaternion.h:67
Ignores the target aspect (default)
Definition: Size.h:48
String class used within the GUI system.
Definition: String.h:62