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
82 static inline const String& getDataTypeName()
87 static inline return_type fromString(
const String& str)
92 static inline String toString(pass_type val)
108 static inline const String& getDataTypeName()
113 static inline return_type fromString(
const String& str)
118 static inline String toString(pass_type val)
134 static inline const String& getDataTypeName()
139 static inline return_type fromString(
const String& str)
144 static inline String toString(pass_type val)
159 static const String& getDataTypeName()
161 static String type(
"String");
181 typedef float return_type;
182 typedef return_type safe_method_return_type;
183 typedef const float pass_type;
186 static const String& getDataTypeName()
188 static String type(
"float");
193 static inline return_type fromString(
const String& str)
196 sscanf(str.
c_str(),
" %g", &val);
204 snprintf(buff,
sizeof(buff),
"%g", val);
213 typedef double return_type;
214 typedef return_type safe_method_return_type;
215 typedef const double pass_type;
218 static const String& getDataTypeName()
220 static String type(
"double");
225 static inline return_type fromString(
const String& str)
228 sscanf(str.
c_str(),
" %lg", &val);
236 snprintf(buff,
sizeof(buff),
"%g", val);
246 typedef int return_type;
247 typedef return_type safe_method_return_type;
248 typedef const int pass_type;
251 static const String& getDataTypeName()
253 static String type(
"int");
258 static inline return_type fromString(
const String& str)
261 sscanf(str.
c_str(),
" %d", &val);
269 snprintf(buff,
sizeof(buff),
"%d", val);
279 typedef uint return_type;
280 typedef return_type safe_method_return_type;
281 typedef const uint pass_type;
284 static const String& getDataTypeName()
286 static String type(
"uint");
291 static return_type fromString(
const String& str)
294 sscanf(str.
c_str(),
" %u", &val);
302 snprintf(buff,
sizeof(buff),
"%u", val);
312 typedef uint64 return_type;
313 typedef return_type safe_method_return_type;
314 typedef const uint64 pass_type;
317 static const String& getDataTypeName()
319 static String type(
"uint64");
324 static return_type fromString(
const String& str)
327 sscanf(str.
c_str(),
" %llu", &val);
335 snprintf(buff,
sizeof(buff),
"%llu", val);
341 #if CEGUI_STRING_CLASS != CEGUI_STRING_CLASS_UNICODE
348 typedef return_type safe_method_return_type;
350 typedef String string_return_type;
352 static const String& getDataTypeName()
354 static String type(
"char");
359 static return_type fromString(
const String& str)
364 static string_return_type toString(pass_type val)
366 return String(
"") + val;
376 typedef unsigned long return_type;
377 typedef return_type safe_method_return_type;
378 typedef const unsigned long pass_type;
381 static const String& getDataTypeName()
383 static String type(
"unsigned long");
388 static return_type fromString(
const String& str)
390 unsigned long val = 0;
391 sscanf(str.
c_str(),
" %lu", &val);
399 snprintf(buff,
sizeof(buff),
"%lu", val);
409 typedef bool return_type;
410 typedef return_type safe_method_return_type;
411 typedef const bool pass_type;
414 static const String& getDataTypeName()
416 static String type(
"bool");
421 static return_type fromString(
const String& str)
423 return (str == True || str ==
"True");
428 return val ? True : False;
447 static const String& getDataTypeName()
449 static String type(
"AspectMode");
460 else if (str == Expand)
486 assert(
false &&
"Invalid aspect mode");
506 static const String& getDataTypeName()
508 static String type(
"Sizef");
516 sscanf(str.
c_str(),
" w:%g h:%g", &val.d_width, &val.d_height);
524 snprintf(buff,
sizeof(buff),
"w:%g h:%g", val.d_width, val.d_height);
539 static const String& getDataTypeName()
541 static String type(
"Vector2f");
549 sscanf(str.
c_str(),
" x:%g y:%g", &val.d_x, &val.d_y);
557 snprintf(buff,
sizeof(buff),
"x:%g y:%g", val.d_x, val.d_y);
572 static const String& getDataTypeName()
574 static String type(
"Vector3f");
582 sscanf(str.
c_str(),
" x:%g y:%g z:%g", &val.d_x, &val.d_y, &val.d_z);
590 snprintf(buff,
sizeof(buff),
"x:%g y:%g z:%g", val.d_x, val.d_y, val.d_z);
605 static const String& getDataTypeName()
607 static String type(
"Quaternion");
614 if (strchr(str.
c_str(),
'w') || strchr(str.
c_str(),
'W'))
617 sscanf(str.
c_str(),
" w:%g x:%g y:%g z:%g", &val.
d_w, &val.
d_x, &val.
d_y, &val.
d_z);
624 sscanf(str.
c_str(),
" x:%g y:%g z:%g", &x, &y, &z);
632 snprintf(buff,
sizeof(buff),
"w:%g x:%g y:%g z:%g", val.
d_w, val.
d_x, val.
d_y, val.
d_z);
647 static const String& getDataTypeName()
649 static String type(
"Rectf");
656 Rectf val(0, 0, 0, 0);
657 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);
665 snprintf(buff,
sizeof(buff),
"l:%g t:%g r:%g b:%g",
666 val.d_min.d_x, val.d_min.d_y, val.d_max.d_x, val.d_max.d_y);
678 typedef const Image*
const pass_type;
681 static const String& getDataTypeName()
683 static String type(
"Image");
688 static return_type fromString(
const String& str);
690 static string_return_type toString(pass_type val);
702 static const String& getDataTypeName()
704 static String type(
"Colour");
712 sscanf(str.
c_str(),
" %8X", &val);
720 sprintf(buff,
"%.8X", val.getARGB());
735 static const String& getDataTypeName()
737 static String type(
"ColourRect");
747 sscanf(str.
c_str(),
"%8X", &all);
751 argb_t topLeft = 0xFF000000, topRight = 0xFF000000, bottomLeft = 0xFF000000, bottomRight = 0xFF000000;
752 sscanf(str.
c_str(),
"tl:%8X tr:%8X bl:%8X br:%8X", &topLeft, &topRight, &bottomLeft, &bottomRight);
754 return ColourRect(topLeft, topRight, bottomLeft, bottomRight);
760 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());
775 static const String& getDataTypeName()
777 static String type(
"UDim");
785 sscanf(str.
c_str(),
" { %g , %g }", &ud.d_scale, &ud.d_offset);
793 snprintf(buff,
sizeof(buff),
"{%g,%g}", val.d_scale, val.d_offset);
808 static const String& getDataTypeName()
810 static String type(
"UVector2");
818 sscanf(str.
c_str(),
" { { %g , %g } , { %g , %g } }",
819 &uv.d_x.d_scale, &uv.d_x.d_offset,
820 &uv.d_y.d_scale, &uv.d_y.d_offset);
828 snprintf(buff,
sizeof(buff),
"{{%g,%g},{%g,%g}}",
829 val.d_x.d_scale, val.d_x.d_offset, val.d_y.d_scale, val.d_y.d_offset);
844 static const String& getDataTypeName()
846 static String type(
"USize");
854 sscanf(str.
c_str(),
" { { %g , %g } , { %g , %g } }",
855 &uv.d_width.d_scale, &uv.d_width.d_offset,
856 &uv.d_height.d_scale, &uv.d_height.d_offset);
864 snprintf(buff,
sizeof(buff),
"{{%g,%g},{%g,%g}}",
865 val.d_width.d_scale, val.d_width.d_offset, val.d_height.d_scale, val.d_height.d_offset);
880 static const String& getDataTypeName()
882 static String type(
"URect");
892 " { { %g , %g } , { %g , %g } , { %g , %g } , { %g , %g } }",
893 &ur.d_min.d_x.d_scale, &ur.d_min.d_x.d_offset,
894 &ur.d_min.d_y.d_scale, &ur.d_min.d_y.d_offset,
895 &ur.d_max.d_x.d_scale, &ur.d_max.d_x.d_offset,
896 &ur.d_max.d_y.d_scale, &ur.d_max.d_y.d_offset
905 snprintf(buff,
sizeof(buff),
"{{%g,%g},{%g,%g},{%g,%g},{%g,%g}}",
906 val.d_min.d_x.d_scale, val.d_min.d_x.d_offset,
907 val.d_min.d_y.d_scale, val.d_min.d_y.d_offset,
908 val.d_max.d_x.d_scale, val.d_max.d_x.d_offset,
909 val.d_max.d_y.d_scale, val.d_max.d_y.d_offset);
924 static const String& getDataTypeName()
926 static String type(
"UBox");
936 " { top: { %g , %g } , left: { %g , %g } , bottom: { %g , %g } , right: { %g , %g } }",
937 &ret.d_top.d_scale, &ret.d_top.d_offset,
938 &ret.d_left.d_scale, &ret.d_left.d_offset,
939 &ret.d_bottom.d_scale, &ret.d_bottom.d_offset,
940 &ret.d_right.d_scale, &ret.d_right.d_offset
949 snprintf(buff,
sizeof(buff),
"{top:{%g,%g},left:{%g,%g},bottom:{%g,%g},right:{%g,%g}}",
950 val.d_top.d_scale, val.d_top.d_offset,
951 val.d_left.d_scale, val.d_left.d_offset,
952 val.d_bottom.d_scale, val.d_bottom.d_offset,
953 val.d_right.d_scale, val.d_right.d_offset);
966 typedef const Font*
const pass_type;
969 static const String& getDataTypeName()
971 static String type(
"Font");
976 static return_type fromString(
const String& str);
977 static string_return_type toString(pass_type val);
982 #if defined(_MSC_VER)
983 # pragma warning(pop)