00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __MYGUI_WIDGET_TYPE_H__
00024 #define __MYGUI_WIDGET_TYPE_H__
00025
00026 #include "MyGUI_Prerequest.h"
00027 #include <string.h>
00028
00029 namespace MyGUI
00030 {
00031
00032 struct MYGUI_EXPORT WidgetStyle
00033 {
00034 enum Enum
00035 {
00036 Child,
00037 Popup,
00038 Overlapped,
00039 MAX
00040 };
00041
00042 static WidgetStyle parse(const std::string& _value)
00043 {
00044 WidgetStyle type;
00045 int value = 0;
00046 while (true)
00047 {
00048 const char * name = type.getValueName(value);
00049 if (strcmp(name, "") == 0 || name == _value) break;
00050 value++;
00051 }
00052 type.value = (Enum)value;
00053 return type;
00054 }
00055
00056 WidgetStyle() : value(MAX) { }
00057 WidgetStyle(Enum _value) : value(_value) { }
00058
00059 friend bool operator == (WidgetStyle const& a, WidgetStyle const& b) { return a.value == b.value; }
00060 friend bool operator != (WidgetStyle const& a, WidgetStyle const& b) { return a.value != b.value; }
00061
00062 friend std::ostream& operator << ( std::ostream& _stream, const WidgetStyle& _value )
00063 {
00064 _stream << _value.getValueName(_value.value);
00065 return _stream;
00066 }
00067
00068 friend std::istream& operator >> ( std::istream& _stream, WidgetStyle& _value )
00069 {
00070 std::string value;
00071 _stream >> value;
00072 _value = WidgetStyle::parse(value);
00073 return _stream;
00074 }
00075
00076 std::string print() const { return getValueName(value); }
00077
00078 private:
00079 const char * getValueName(int _index) const
00080 {
00081 static const char * values[MAX + 1] = { "Child", "Popup", "Overlapped", "" };
00082 return values[(_index < MAX && _index >= 0) ? _index : MAX];
00083 }
00084
00085 private:
00086 Enum value;
00087 };
00088
00089 }
00090
00091 #endif // __MYGUI_WIDGET_TYPE_H__