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 #define snprintf _snprintf
79 static inline const String& getDataTypeName()
84 static inline return_type fromString(
const String& str)
89 static inline String toString(pass_type val)
105 static inline const String& getDataTypeName()
110 static inline return_type fromString(
const String& str)
115 static inline String toString(pass_type val)
131 static inline const String& getDataTypeName()
136 static inline return_type fromString(
const String& str)
141 static inline String toString(pass_type val)
156 static const String& getDataTypeName()
158 static String type(
"String");
178 typedef float return_type;
179 typedef return_type safe_method_return_type;
180 typedef const float pass_type;
183 static const String& getDataTypeName()
185 static String type(
"float");
190 static inline return_type fromString(
const String& str)
193 sscanf(str.
c_str(),
" %g", &val);
201 snprintf(buff,
sizeof(buff),
"%g", val);
210 typedef double return_type;
211 typedef return_type safe_method_return_type;
212 typedef const double pass_type;
215 static const String& getDataTypeName()
217 static String type(
"double");
222 static inline return_type fromString(
const String& str)
225 sscanf(str.
c_str(),
" %lg", &val);
233 snprintf(buff,
sizeof(buff),
"%g", val);
243 typedef int return_type;
244 typedef return_type safe_method_return_type;
245 typedef const int pass_type;
248 static const String& getDataTypeName()
250 static String type(
"int");
255 static inline return_type fromString(
const String& str)
258 sscanf(str.
c_str(),
" %d", &val);
266 snprintf(buff,
sizeof(buff),
"%d", val);
276 typedef uint return_type;
277 typedef return_type safe_method_return_type;
278 typedef const uint pass_type;
281 static const String& getDataTypeName()
283 static String type(
"uint");
288 static return_type fromString(
const String& str)
291 sscanf(str.
c_str(),
" %u", &val);
299 snprintf(buff,
sizeof(buff),
"%u", val);
309 typedef uint64 return_type;
310 typedef return_type safe_method_return_type;
311 typedef const uint64 pass_type;
314 static const String& getDataTypeName()
316 static String type(
"uint64");
321 static return_type fromString(
const String& str)
324 sscanf(str.
c_str(),
" %llu", &val);
332 snprintf(buff,
sizeof(buff),
"%llu", val);
338 #if CEGUI_STRING_CLASS != CEGUI_STRING_CLASS_UNICODE
345 typedef return_type safe_method_return_type;
347 typedef String string_return_type;
349 static const String& getDataTypeName()
351 static String type(
"char");
356 static return_type fromString(
const String& str)
361 static string_return_type toString(pass_type val)
363 return String(
"") + val;
373 typedef unsigned long return_type;
374 typedef return_type safe_method_return_type;
375 typedef const unsigned long pass_type;
378 static const String& getDataTypeName()
380 static String type(
"unsigned long");
385 static return_type fromString(
const String& str)
387 unsigned long val = 0;
388 sscanf(str.
c_str(),
" %lu", &val);
396 snprintf(buff,
sizeof(buff),
"%lu", val);
406 typedef bool return_type;
407 typedef return_type safe_method_return_type;
408 typedef const bool pass_type;
411 static const String& getDataTypeName()
413 static String type(
"bool");
418 static return_type fromString(
const String& str)
420 return (str ==
"True" || str ==
"true");
427 static String True(
"True");
428 static String False(
"False");
430 return val ? True : False;
443 static const String& getDataTypeName()
445 static String type(
"AspectMode");
456 else if (str ==
"Expand")
482 assert(
false &&
"Invalid aspect mode");
497 static const String& getDataTypeName()
499 static String type(
"Sizef");
507 sscanf(str.
c_str(),
" w:%g h:%g", &val.d_width, &val.d_height);
515 snprintf(buff,
sizeof(buff),
"w:%g h:%g", val.d_width, val.d_height);
530 static const String& getDataTypeName()
532 static String type(
"Vector2f");
540 sscanf(str.
c_str(),
" x:%g y:%g", &val.d_x, &val.d_y);
548 snprintf(buff,
sizeof(buff),
"x:%g y:%g", val.d_x, val.d_y);
563 static const String& getDataTypeName()
565 static String type(
"Vector3f");
573 sscanf(str.
c_str(),
" x:%g y:%g z:%g", &val.d_x, &val.d_y, &val.d_z);
581 snprintf(buff,
sizeof(buff),
"x:%g y:%g z:%g", val.d_x, val.d_y, val.d_z);
596 static const String& getDataTypeName()
598 static String type(
"Quaternion");
605 if (strchr(str.
c_str(),
'w') || strchr(str.
c_str(),
'W'))
608 sscanf(str.
c_str(),
" w:%g x:%g y:%g z:%g", &val.
d_w, &val.
d_x, &val.
d_y, &val.
d_z);
615 sscanf(str.
c_str(),
" x:%g y:%g z:%g", &x, &y, &z);
623 snprintf(buff,
sizeof(buff),
"w:%g x:%g y:%g z:%g", val.
d_w, val.
d_x, val.
d_y, val.
d_z);
638 static const String& getDataTypeName()
640 static String type(
"Rectf");
647 Rectf val(0, 0, 0, 0);
648 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);
656 snprintf(buff,
sizeof(buff),
"l:%g t:%g r:%g b:%g",
657 val.d_min.d_x, val.d_min.d_y, val.d_max.d_x, val.d_max.d_y);
669 typedef const Image*
const pass_type;
672 static const String& getDataTypeName()
674 static String type(
"Image");
679 static return_type fromString(
const String& str);
681 static string_return_type toString(pass_type val);
693 static const String& getDataTypeName()
695 static String type(
"Colour");
703 sscanf(str.
c_str(),
" %8X", &val);
711 sprintf(buff,
"%.8X", val.getARGB());
726 static const String& getDataTypeName()
728 static String type(
"ColourRect");
738 sscanf(str.
c_str(),
"%8X", &all);
742 argb_t topLeft = 0xFF000000, topRight = 0xFF000000, bottomLeft = 0xFF000000, bottomRight = 0xFF000000;
743 sscanf(str.
c_str(),
"tl:%8X tr:%8X bl:%8X br:%8X", &topLeft, &topRight, &bottomLeft, &bottomRight);
745 return ColourRect(topLeft, topRight, bottomLeft, bottomRight);
751 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());
766 static const String& getDataTypeName()
768 static String type(
"UDim");
776 sscanf(str.
c_str(),
" { %g , %g }", &ud.d_scale, &ud.d_offset);
784 snprintf(buff,
sizeof(buff),
"{%g,%g}", val.d_scale, val.d_offset);
799 static const String& getDataTypeName()
801 static String type(
"UVector2");
809 sscanf(str.
c_str(),
" { { %g , %g } , { %g , %g } }",
810 &uv.d_x.d_scale, &uv.d_x.d_offset,
811 &uv.d_y.d_scale, &uv.d_y.d_offset);
819 snprintf(buff,
sizeof(buff),
"{{%g,%g},{%g,%g}}",
820 val.d_x.d_scale, val.d_x.d_offset, val.d_y.d_scale, val.d_y.d_offset);
835 static const String& getDataTypeName()
837 static String type(
"USize");
845 sscanf(str.
c_str(),
" { { %g , %g } , { %g , %g } }",
846 &uv.d_width.d_scale, &uv.d_width.d_offset,
847 &uv.d_height.d_scale, &uv.d_height.d_offset);
855 snprintf(buff,
sizeof(buff),
"{{%g,%g},{%g,%g}}",
856 val.d_width.d_scale, val.d_width.d_offset, val.d_height.d_scale, val.d_height.d_offset);
871 static const String& getDataTypeName()
873 static String type(
"URect");
883 " { { %g , %g } , { %g , %g } , { %g , %g } , { %g , %g } }",
884 &ur.d_min.d_x.d_scale, &ur.d_min.d_x.d_offset,
885 &ur.d_min.d_y.d_scale, &ur.d_min.d_y.d_offset,
886 &ur.d_max.d_x.d_scale, &ur.d_max.d_x.d_offset,
887 &ur.d_max.d_y.d_scale, &ur.d_max.d_y.d_offset
896 snprintf(buff,
sizeof(buff),
"{{%g,%g},{%g,%g},{%g,%g},{%g,%g}}",
897 val.d_min.d_x.d_scale, val.d_min.d_x.d_offset,
898 val.d_min.d_y.d_scale, val.d_min.d_y.d_offset,
899 val.d_max.d_x.d_scale, val.d_max.d_x.d_offset,
900 val.d_max.d_y.d_scale, val.d_max.d_y.d_offset);
915 static const String& getDataTypeName()
917 static String type(
"UBox");
927 " { top: { %g , %g } , left: { %g , %g } , bottom: { %g , %g } , right: { %g , %g } }",
928 &ret.d_top.d_scale, &ret.d_top.d_offset,
929 &ret.d_left.d_scale, &ret.d_left.d_offset,
930 &ret.d_bottom.d_scale, &ret.d_bottom.d_offset,
931 &ret.d_right.d_scale, &ret.d_right.d_offset
940 snprintf(buff,
sizeof(buff),
"{top:{%g,%g},left:{%g,%g},bottom:{%g,%g},right:{%g,%g}}",
941 val.d_top.d_scale, val.d_top.d_offset,
942 val.d_left.d_scale, val.d_left.d_offset,
943 val.d_bottom.d_scale, val.d_bottom.d_offset,
944 val.d_right.d_scale, val.d_right.d_offset);
957 typedef const Font*
const pass_type;
960 static const String& getDataTypeName()
962 static String type(
"Font");
967 static return_type fromString(
const String& str);
968 static string_return_type toString(pass_type val);
973 #endif // end of guard _CEGUIPropertyHelper_h_