30 #ifndef _CEGUIPropertyHelper_h_
31 #define _CEGUIPropertyHelper_h_
33 #include "CEGUI/String.h"
34 #include "CEGUI/Size.h"
35 #include "CEGUI/Vector.h"
36 #include "CEGUI/Quaternion.h"
37 #include "CEGUI/Colour.h"
38 #include "CEGUI/ColourRect.h"
39 #include "CEGUI/UDim.h"
40 #include "CEGUI/Rect.h"
48 # pragma warning(push)
49 # pragma warning(disable : 4996)
53 #define snprintf _snprintf
84 static inline const String& getDataTypeName()
89 static inline return_type fromString(
const String& str)
94 static inline String toString(pass_type val)
110 static inline const String& getDataTypeName()
115 static inline return_type fromString(
const String& str)
120 static inline String toString(pass_type val)
136 static inline const String& getDataTypeName()
141 static inline return_type fromString(
const String& str)
146 static inline String toString(pass_type val)
161 static const String& getDataTypeName()
163 static String type(
"String");
183 typedef float return_type;
184 typedef return_type safe_method_return_type;
185 typedef const float pass_type;
188 static const String& getDataTypeName()
190 static String type(
"float");
195 static inline return_type fromString(
const String& str)
198 sscanf(str.
c_str(),
" %g", &val);
206 snprintf(buff,
sizeof(buff),
"%g", val);
215 typedef double return_type;
216 typedef return_type safe_method_return_type;
217 typedef const double pass_type;
220 static const String& getDataTypeName()
222 static String type(
"double");
227 static inline return_type fromString(
const String& str)
230 sscanf(str.
c_str(),
" %lg", &val);
238 snprintf(buff,
sizeof(buff),
"%g", val);
248 typedef int return_type;
249 typedef return_type safe_method_return_type;
250 typedef const int pass_type;
253 static const String& getDataTypeName()
255 static String type(
"int");
260 static inline return_type fromString(
const String& str)
263 sscanf(str.
c_str(),
" %d", &val);
271 snprintf(buff,
sizeof(buff),
"%d", val);
281 typedef uint return_type;
282 typedef return_type safe_method_return_type;
283 typedef const uint pass_type;
286 static const String& getDataTypeName()
288 static String type(
"uint");
293 static return_type fromString(
const String& str)
296 sscanf(str.
c_str(),
" %u", &val);
304 snprintf(buff,
sizeof(buff),
"%u", val);
314 typedef uint64 return_type;
315 typedef return_type safe_method_return_type;
316 typedef const uint64 pass_type;
319 static const String& getDataTypeName()
321 static String type(
"uint64");
326 static return_type fromString(
const String& str)
329 sscanf(str.
c_str(),
" %llu", &val);
337 snprintf(buff,
sizeof(buff),
"%llu", val);
343 #if CEGUI_STRING_CLASS != CEGUI_STRING_CLASS_UNICODE
350 typedef return_type safe_method_return_type;
352 typedef String string_return_type;
354 static const String& getDataTypeName()
356 static String type(
"char");
361 static return_type fromString(
const String& str)
366 static string_return_type toString(pass_type val)
368 return String(
"") + val;
378 typedef unsigned long return_type;
379 typedef return_type safe_method_return_type;
380 typedef const unsigned long pass_type;
383 static const String& getDataTypeName()
385 static String type(
"unsigned long");
390 static return_type fromString(
const String& str)
392 unsigned long val = 0;
393 sscanf(str.
c_str(),
" %lu", &val);
401 snprintf(buff,
sizeof(buff),
"%lu", val);
411 typedef bool return_type;
412 typedef return_type safe_method_return_type;
413 typedef const bool pass_type;
416 static const String& getDataTypeName()
418 static String type(
"bool");
423 static return_type fromString(
const String& str)
425 return (str ==
"True" || str ==
"true");
432 static String True(
"True");
433 static String False(
"False");
435 return val ? True : False;
448 static const String& getDataTypeName()
450 static String type(
"AspectMode");
461 else if (str ==
"Expand")
487 assert(
false &&
"Invalid aspect mode");
502 static const String& getDataTypeName()
504 static String type(
"Sizef");
512 sscanf(str.
c_str(),
" w:%g h:%g", &val.d_width, &val.d_height);
520 snprintf(buff,
sizeof(buff),
"w:%g h:%g", val.d_width, val.d_height);
535 static const String& getDataTypeName()
537 static String type(
"Vector2f");
545 sscanf(str.
c_str(),
" x:%g y:%g", &val.d_x, &val.d_y);
553 snprintf(buff,
sizeof(buff),
"x:%g y:%g", val.d_x, val.d_y);
568 static const String& getDataTypeName()
570 static String type(
"Vector3f");
578 sscanf(str.
c_str(),
" x:%g y:%g z:%g", &val.d_x, &val.d_y, &val.d_z);
586 snprintf(buff,
sizeof(buff),
"x:%g y:%g z:%g", val.d_x, val.d_y, val.d_z);
601 static const String& getDataTypeName()
603 static String type(
"Quaternion");
610 if (strchr(str.
c_str(),
'w') || strchr(str.
c_str(),
'W'))
613 sscanf(str.
c_str(),
" w:%g x:%g y:%g z:%g", &val.
d_w, &val.
d_x, &val.
d_y, &val.
d_z);
620 sscanf(str.
c_str(),
" x:%g y:%g z:%g", &x, &y, &z);
628 snprintf(buff,
sizeof(buff),
"w:%g x:%g y:%g z:%g", val.
d_w, val.
d_x, val.
d_y, val.
d_z);
643 static const String& getDataTypeName()
645 static String type(
"Rectf");
652 Rectf val(0, 0, 0, 0);
653 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);
661 snprintf(buff,
sizeof(buff),
"l:%g t:%g r:%g b:%g",
662 val.d_min.d_x, val.d_min.d_y, val.d_max.d_x, val.d_max.d_y);
674 typedef const Image*
const pass_type;
677 static const String& getDataTypeName()
679 static String type(
"Image");
684 static return_type fromString(
const String& str);
686 static string_return_type toString(pass_type val);
698 static const String& getDataTypeName()
700 static String type(
"Colour");
708 sscanf(str.
c_str(),
" %8X", &val);
716 sprintf(buff,
"%.8X", val.getARGB());
731 static const String& getDataTypeName()
733 static String type(
"ColourRect");
743 sscanf(str.
c_str(),
"%8X", &all);
747 argb_t topLeft = 0xFF000000, topRight = 0xFF000000, bottomLeft = 0xFF000000, bottomRight = 0xFF000000;
748 sscanf(str.
c_str(),
"tl:%8X tr:%8X bl:%8X br:%8X", &topLeft, &topRight, &bottomLeft, &bottomRight);
750 return ColourRect(topLeft, topRight, bottomLeft, bottomRight);
756 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());
771 static const String& getDataTypeName()
773 static String type(
"UDim");
781 sscanf(str.
c_str(),
" { %g , %g }", &ud.d_scale, &ud.d_offset);
789 snprintf(buff,
sizeof(buff),
"{%g,%g}", val.d_scale, val.d_offset);
804 static const String& getDataTypeName()
806 static String type(
"UVector2");
814 sscanf(str.
c_str(),
" { { %g , %g } , { %g , %g } }",
815 &uv.d_x.d_scale, &uv.d_x.d_offset,
816 &uv.d_y.d_scale, &uv.d_y.d_offset);
824 snprintf(buff,
sizeof(buff),
"{{%g,%g},{%g,%g}}",
825 val.d_x.d_scale, val.d_x.d_offset, val.d_y.d_scale, val.d_y.d_offset);
840 static const String& getDataTypeName()
842 static String type(
"USize");
850 sscanf(str.
c_str(),
" { { %g , %g } , { %g , %g } }",
851 &uv.d_width.d_scale, &uv.d_width.d_offset,
852 &uv.d_height.d_scale, &uv.d_height.d_offset);
860 snprintf(buff,
sizeof(buff),
"{{%g,%g},{%g,%g}}",
861 val.d_width.d_scale, val.d_width.d_offset, val.d_height.d_scale, val.d_height.d_offset);
876 static const String& getDataTypeName()
878 static String type(
"URect");
888 " { { %g , %g } , { %g , %g } , { %g , %g } , { %g , %g } }",
889 &ur.d_min.d_x.d_scale, &ur.d_min.d_x.d_offset,
890 &ur.d_min.d_y.d_scale, &ur.d_min.d_y.d_offset,
891 &ur.d_max.d_x.d_scale, &ur.d_max.d_x.d_offset,
892 &ur.d_max.d_y.d_scale, &ur.d_max.d_y.d_offset
901 snprintf(buff,
sizeof(buff),
"{{%g,%g},{%g,%g},{%g,%g},{%g,%g}}",
902 val.d_min.d_x.d_scale, val.d_min.d_x.d_offset,
903 val.d_min.d_y.d_scale, val.d_min.d_y.d_offset,
904 val.d_max.d_x.d_scale, val.d_max.d_x.d_offset,
905 val.d_max.d_y.d_scale, val.d_max.d_y.d_offset);
920 static const String& getDataTypeName()
922 static String type(
"UBox");
932 " { top: { %g , %g } , left: { %g , %g } , bottom: { %g , %g } , right: { %g , %g } }",
933 &ret.d_top.d_scale, &ret.d_top.d_offset,
934 &ret.d_left.d_scale, &ret.d_left.d_offset,
935 &ret.d_bottom.d_scale, &ret.d_bottom.d_offset,
936 &ret.d_right.d_scale, &ret.d_right.d_offset
945 snprintf(buff,
sizeof(buff),
"{top:{%g,%g},left:{%g,%g},bottom:{%g,%g},right:{%g,%g}}",
946 val.d_top.d_scale, val.d_top.d_offset,
947 val.d_left.d_scale, val.d_left.d_offset,
948 val.d_bottom.d_scale, val.d_bottom.d_offset,
949 val.d_right.d_scale, val.d_right.d_offset);
962 typedef const Font*
const pass_type;
965 static const String& getDataTypeName()
967 static String type(
"Font");
972 static return_type fromString(
const String& str);
973 static string_return_type toString(pass_type val);
978 #if defined(_MSC_VER)
979 # pragma warning(pop)
982 #endif // end of guard _CEGUIPropertyHelper_h_