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 74 class PropertyHelper<const T>
77 typedef typename PropertyHelper<T>::return_type return_type;
78 typedef typename PropertyHelper<T>::safe_method_return_type safe_method_return_type;
79 typedef typename PropertyHelper<T>::pass_type pass_type;
80 typedef typename PropertyHelper<T>::string_return_type string_return_type;
82 static inline const String& getDataTypeName()
84 return PropertyHelper<T>::getDataTypeName();
87 static inline return_type fromString(
const String& str)
89 return PropertyHelper<T>::fromString(str);
92 static inline String toString(pass_type val)
94 return PropertyHelper<T>::toString(val);
100 class PropertyHelper<const T&>
103 typedef typename PropertyHelper<T>::return_type return_type;
104 typedef typename PropertyHelper<T>::safe_method_return_type safe_method_return_type;
105 typedef typename PropertyHelper<T>::pass_type pass_type;
106 typedef typename PropertyHelper<T>::string_return_type string_return_type;
108 static inline const String& getDataTypeName()
110 return PropertyHelper<T>::getDataTypeName();
113 static inline return_type fromString(
const String& str)
115 return PropertyHelper<T>::fromString(str);
118 static inline String toString(pass_type val)
120 return PropertyHelper<T>::toString(val);
126 class PropertyHelper<const T*>
129 typedef typename PropertyHelper<T*>::return_type return_type;
130 typedef typename PropertyHelper<T*>::safe_method_return_type safe_method_return_type;
131 typedef typename PropertyHelper<T*>::pass_type pass_type;
132 typedef typename PropertyHelper<T*>::string_return_type string_return_type;
134 static inline const String& getDataTypeName()
136 return PropertyHelper<T>::getDataTypeName();
139 static inline return_type fromString(
const String& str)
141 return PropertyHelper<T*>::fromString(str);
144 static inline String toString(pass_type val)
146 return PropertyHelper<T*>::toString(val);
151 class PropertyHelper<String>
154 typedef const String& return_type;
155 typedef String safe_method_return_type;
156 typedef const String& pass_type;
157 typedef const String& string_return_type;
159 static const String& getDataTypeName()
161 static String type(
"String");
166 static inline return_type fromString(
const String& str)
171 static inline string_return_type toString(pass_type val)
178 class PropertyHelper<float>
181 typedef float return_type;
182 typedef return_type safe_method_return_type;
183 typedef const float pass_type;
184 typedef String string_return_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);
201 static inline string_return_type toString(pass_type val)
204 snprintf(buff,
sizeof(buff),
"%g", val);
210 class PropertyHelper<double>
213 typedef double return_type;
214 typedef return_type safe_method_return_type;
215 typedef const double pass_type;
216 typedef String string_return_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);
233 static inline string_return_type toString(pass_type val)
236 snprintf(buff,
sizeof(buff),
"%g", val);
243 class PropertyHelper<int>
246 typedef int return_type;
247 typedef return_type safe_method_return_type;
248 typedef const int pass_type;
249 typedef String string_return_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);
266 static inline string_return_type toString(pass_type val)
269 snprintf(buff,
sizeof(buff),
"%d", val);
276 class PropertyHelper<uint>
279 typedef uint return_type;
280 typedef return_type safe_method_return_type;
281 typedef const uint pass_type;
282 typedef String string_return_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);
299 static string_return_type toString(pass_type val)
302 snprintf(buff,
sizeof(buff),
"%u", val);
309 class PropertyHelper<uint64>
312 typedef uint64 return_type;
313 typedef return_type safe_method_return_type;
314 typedef const uint64 pass_type;
315 typedef String string_return_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);
332 static string_return_type toString(pass_type val)
335 snprintf(buff,
sizeof(buff),
"%llu", val);
341 #if CEGUI_STRING_CLASS != CEGUI_STRING_CLASS_UNICODE 344 class PropertyHelper<String::value_type>
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;
373 class PropertyHelper<unsigned long>
376 typedef unsigned long return_type;
377 typedef return_type safe_method_return_type;
378 typedef const unsigned long pass_type;
379 typedef String string_return_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);
396 static string_return_type toString(pass_type val)
399 snprintf(buff,
sizeof(buff),
"%lu", val);
406 class CEGUIEXPORT PropertyHelper<bool>
409 typedef bool return_type;
410 typedef return_type safe_method_return_type;
411 typedef const bool pass_type;
412 typedef const String& string_return_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");
426 static string_return_type toString(pass_type val)
428 return val ? True : False;
443 typedef return_type safe_method_return_type;
445 typedef String string_return_type;
447 static const String& getDataTypeName()
449 static String type(
"AspectMode");
454 static return_type fromString(
const String& str)
460 else if (str == Expand)
470 static string_return_type toString(pass_type val)
486 assert(
false &&
"Invalid aspect mode");
498 class PropertyHelper<Sizef >
501 typedef Sizef return_type;
502 typedef return_type safe_method_return_type;
503 typedef const Sizef& pass_type;
504 typedef String string_return_type;
506 static const String& getDataTypeName()
508 static String type(
"Sizef");
513 static return_type fromString(
const String& str)
516 sscanf(str.c_str(),
" w:%g h:%g", &val.d_width, &val.d_height);
521 static string_return_type toString(pass_type val)
524 snprintf(buff,
sizeof(buff),
"w:%g h:%g", val.d_width, val.d_height);
531 class PropertyHelper<Vector2f >
534 typedef Vector2f return_type;
535 typedef return_type safe_method_return_type;
536 typedef const Vector2f& pass_type;
537 typedef String string_return_type;
539 static const String& getDataTypeName()
541 static String type(
"Vector2f");
546 static return_type fromString(
const String& str)
549 sscanf(str.c_str(),
" x:%g y:%g", &val.d_x, &val.d_y);
554 static string_return_type toString(pass_type val)
557 snprintf(buff,
sizeof(buff),
"x:%g y:%g", val.d_x, val.d_y);
564 class PropertyHelper<Vector3f >
567 typedef Vector3f return_type;
568 typedef return_type safe_method_return_type;
569 typedef const Vector3f& pass_type;
570 typedef String string_return_type;
572 static const String& getDataTypeName()
574 static String type(
"Vector3f");
579 static return_type fromString(
const String& str)
581 Vector3f val(0, 0, 0);
582 sscanf(str.c_str(),
" x:%g y:%g z:%g", &val.d_x, &val.d_y, &val.d_z);
587 static string_return_type toString(pass_type val)
590 snprintf(buff,
sizeof(buff),
"x:%g y:%g z:%g", val.d_x, val.d_y, val.d_z);
597 class PropertyHelper<Quaternion>
600 typedef Quaternion return_type;
601 typedef return_type safe_method_return_type;
602 typedef const Quaternion& pass_type;
603 typedef String string_return_type;
605 static const String& getDataTypeName()
607 static String type(
"Quaternion");
612 static return_type fromString(
const String& str)
614 if (strchr(str.c_str(),
'w') || strchr(str.c_str(),
'W'))
616 Quaternion val(1, 0, 0, 0);
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);
629 static string_return_type toString(pass_type val)
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);
639 class PropertyHelper<Rectf >
642 typedef Rectf return_type;
643 typedef return_type safe_method_return_type;
644 typedef const Rectf& pass_type;
645 typedef String string_return_type;
647 static const String& getDataTypeName()
649 static String type(
"Rectf");
654 static return_type fromString(
const String& str)
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);
662 static string_return_type toString(pass_type val)
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);
673 class CEGUIEXPORT PropertyHelper<Image*>
676 typedef const Image* return_type;
677 typedef return_type safe_method_return_type;
678 typedef const Image*
const pass_type;
679 typedef String string_return_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);
694 class PropertyHelper<Colour>
697 typedef Colour return_type;
698 typedef return_type safe_method_return_type;
699 typedef const Colour& pass_type;
700 typedef String string_return_type;
702 static const String& getDataTypeName()
704 static String type(
"Colour");
709 static return_type fromString(
const String& str)
712 sscanf(str.c_str(),
" %8X", &val);
717 static string_return_type toString(pass_type val)
720 sprintf(buff,
"%.8X", val.getARGB());
727 class PropertyHelper<ColourRect>
730 typedef ColourRect return_type;
731 typedef return_type safe_method_return_type;
732 typedef const ColourRect& pass_type;
733 typedef String string_return_type;
735 static const String& getDataTypeName()
737 static String type(
"ColourRect");
742 static return_type fromString(
const String& str)
744 if (str.length() == 8)
747 sscanf(str.c_str(),
"%8X", &all);
748 return ColourRect(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);
757 static string_return_type toString(pass_type val)
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());
767 class PropertyHelper<UDim>
770 typedef UDim return_type;
771 typedef return_type safe_method_return_type;
772 typedef const UDim& pass_type;
773 typedef String string_return_type;
775 static const String& getDataTypeName()
777 static String type(
"UDim");
782 static return_type fromString(
const String& str)
785 sscanf(str.c_str(),
" { %g , %g }", &ud.d_scale, &ud.d_offset);
790 static string_return_type toString(pass_type val)
793 snprintf(buff,
sizeof(buff),
"{%g,%g}", val.d_scale, val.d_offset);
800 class PropertyHelper<UVector2>
803 typedef UVector2 return_type;
804 typedef return_type safe_method_return_type;
805 typedef const UVector2& pass_type;
806 typedef String string_return_type;
808 static const String& getDataTypeName()
810 static String type(
"UVector2");
815 static return_type fromString(
const String& str)
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);
825 static string_return_type toString(pass_type val)
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);
836 class PropertyHelper<USize>
839 typedef USize return_type;
840 typedef return_type safe_method_return_type;
841 typedef const USize& pass_type;
842 typedef String string_return_type;
844 static const String& getDataTypeName()
846 static String type(
"USize");
851 static return_type fromString(
const String& str)
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);
861 static string_return_type toString(pass_type val)
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);
872 class PropertyHelper<URect>
875 typedef URect return_type;
876 typedef return_type safe_method_return_type;
877 typedef const URect& pass_type;
878 typedef String string_return_type;
880 static const String& getDataTypeName()
882 static String type(
"URect");
887 static return_type fromString(
const String& str)
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
902 static string_return_type toString(pass_type val)
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);
916 class PropertyHelper<UBox>
919 typedef UBox return_type;
920 typedef return_type safe_method_return_type;
921 typedef const UBox& pass_type;
922 typedef String string_return_type;
924 static const String& getDataTypeName()
926 static String type(
"UBox");
931 static return_type fromString(
const String& str)
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
946 static string_return_type toString(pass_type val)
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);
961 class CEGUIEXPORT PropertyHelper<Font*>
964 typedef const Font* return_type;
965 typedef return_type safe_method_return_type;
966 typedef const Font*
const pass_type;
967 typedef String string_return_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) AspectMode
How aspect ratio should be maintained.
Definition: cegui/include/CEGUI/Size.h:45
static Quaternion eulerAnglesDegrees(float x, float y, float z)
constructs a quaternion from euler angles in degrees
Definition: cegui/src/Quaternion.cpp:70
Main namespace for Crazy Eddie's GUI Library.
Definition: cegui/include/CEGUI/Affector.h:42
uint32 argb_t
32 bit ARGB representation of a colour.
Definition: cegui/include/CEGUI/Colour.h:38
Definition: cegui/include/CEGUI/Size.h:58
Definition: cegui/include/CEGUI/Size.h:53
Ignores the target aspect (default)
Definition: cegui/include/CEGUI/Size.h:48
utf32 value_type
Basic 'code point' type used for String (utf32)
Definition: cegui/include/CEGUI/String.h:69
String class used within the GUI system.
Definition: cegui/include/CEGUI/String.h:62