MyGUI 3.2.2

MyGUI_WidgetStyle.h
Go to the documentation of this file.
1 /*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7 #ifndef MYGUI_WIDGET_STYLE_H_
8 #define MYGUI_WIDGET_STYLE_H_
9
10 #include "MyGUI_Prerequest.h"
11 #include <string.h>
12
13 namespace MyGUI
14 {
15
16 struct MYGUI_EXPORT WidgetStyle
17 {
18 enum Enum
19 {
20 Child,
21 Popup,
22 Overlapped,
23 MAX
24 };
25
26 WidgetStyle() :
27 mValue(MAX)
28 {
29 }
30
31 WidgetStyle(Enum _value) :
32 mValue(_value)
33 {
34 }
35
36 static WidgetStyle parse(const std::string& _value)
37 {
38 WidgetStyle type;
39 int value = 0;
40 while (true)
41 {
42 const char* name = type.getValueName(value);
43 if (strcmp(name, "") == 0 || name == _value)
44 break;
45 value++;
46 }
47 type.mValue = (Enum)value;
48 return type;
49 }
50
51 friend bool operator == (WidgetStyle const& a, WidgetStyle const& b)
52 {
53 return a.mValue == b.mValue;
54 }
55
56 friend bool operator != (WidgetStyle const& a, WidgetStyle const& b)
57 {
58 return a.mValue != b.mValue;
59 }
60
61 friend std::ostream& operator << (std::ostream& _stream, const WidgetStyle& _value)
62 {
63 _stream << _value.getValueName(_value.mValue);
64 return _stream;
65 }
66
67 friend std::istream& operator >> (std::istream& _stream, WidgetStyle& _value)
68 {
69 std::string value;
70 _stream >> value;
71 _value = parse(value);
72 return _stream;
73 }
74
75 std::string print() const
76 {
77 return getValueName(mValue);
78 }
79
80 int getValue() const
81 {
82 return mValue;
83 }
84
85 private:
86 const char* getValueName(int _index) const
87 {
88 static const char* values[MAX + 1] = { "Child", "Popup", "Overlapped", "" };
89 return values[(_index < MAX && _index >= 0) ? _index : MAX];
90 }
91
92 private:
93 Enum mValue;
94 };
95
96 } // namespace MyGUI
97
98 #endif // MYGUI_WIDGET_STYLE_H_
MyGUI::FontCodeType::Enum
Enum
Definition: MyGUI_FontData.h:18
MyGUI::WidgetStyle::getValue
int getValue() const
Definition: MyGUI_WidgetStyle.h:80
MyGUI::WidgetStyle::Overlapped
Definition: MyGUI_WidgetStyle.h:22
MyGUI_Prerequest.h
MyGUI::operator!=
bool operator!=(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
Definition: MyGUI_UString.h:1048
MyGUI::WidgetStyle::parse
static WidgetStyle parse(const std::string &_value)
Definition: MyGUI_WidgetStyle.h:36
MyGUI::operator==
bool operator==(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
Definition: MyGUI_UString.h:1045
MyGUI::WidgetStyle::print
std::string print() const
Definition: MyGUI_WidgetStyle.h:75
MyGUI::WidgetStyle::WidgetStyle
WidgetStyle()
Definition: MyGUI_WidgetStyle.h:26
MyGUI
Definition: MyGUI_ActionController.h:14
MyGUI::WidgetStyle::WidgetStyle
WidgetStyle(Enum _value)
Definition: MyGUI_WidgetStyle.h:31
MyGUI::WidgetStyle::Child
Definition: MyGUI_WidgetStyle.h:20
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:103
MyGUI::WidgetStyle
Definition: MyGUI_WidgetStyle.h:16
MyGUI::WidgetStyle::Popup
Definition: MyGUI_WidgetStyle.h:21
MyGUI::WidgetStyle::Enum
Enum
Definition: MyGUI_WidgetStyle.h:18