MyGUI 3.2.0

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

MyGUI_WidgetStyle.h
Go to the documentation of this file.
1
6 /*
7 This file is part of MyGUI.
8
9 MyGUI is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 MyGUI is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_WIDGET_STYLE_H__
23 #define __MYGUI_WIDGET_STYLE_H__
24
25 #include "MyGUI_Prerequest.h"
26 #include <string.h>
27
28 namespace MyGUI
29 {
30
31 struct MYGUI_EXPORT WidgetStyle
32 {
33 enum Enum
34 {
35 Child,
36 Popup,
37 Overlapped,
38 MAX
39 };
40
41 WidgetStyle() :
42 value(MAX)
43 {
44 }
45
46 WidgetStyle(Enum _value) :
47 value(_value)
48 {
49 }
50
51 static WidgetStyle parse(const std::string& _value)
52 {
53 WidgetStyle type;
54 int value = 0;
55 while (true)
56 {
57 const char* name = type.getValueName(value);
58 if (strcmp(name, "") == 0 || name == _value)
59 break;
60 value++;
61 }
62 type.value = (Enum)value;
63 return type;
64 }
65
66 friend bool operator == (WidgetStyle const& a, WidgetStyle const& b)
67 {
68 return a.value == b.value;
69 }
70
71 friend bool operator != (WidgetStyle const& a, WidgetStyle const& b)
72 {
73 return a.value != b.value;
74 }
75
76 friend std::ostream& operator << (std::ostream& _stream, const WidgetStyle& _value)
77 {
78 _stream << _value.getValueName(_value.value);
79 return _stream;
80 }
81
82 friend std::istream& operator >> (std::istream& _stream, WidgetStyle& _value)
83 {
84 std::string value;
85 _stream >> value;
86 _value = parse(value);
87 return _stream;
88 }
89
90 std::string print() const
91 {
92 return getValueName(value);
93 }
94
95 private:
96 const char* getValueName(int _index) const
97 {
98 static const char* values[MAX + 1] = { "Child", "Popup", "Overlapped", "" };
99 return values[(_index < MAX && _index >= 0) ? _index : MAX];
100 }
101
102 private:
103 Enum value;
104 };
105
106 } // namespace MyGUI
107
108 #endif // __MYGUI_WIDGET_STYLE_H__
MyGUI::FontCodeType::Enum
Enum
Definition: MyGUI_FontData.h:33
MyGUI::WidgetStyle::Overlapped
Definition: MyGUI_WidgetStyle.h:37
MyGUI_Prerequest.h
MyGUI::operator!=
bool operator!=(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
Definition: MyGUI_UString.h:1049
MyGUI::WidgetStyle::parse
static WidgetStyle parse(const std::string &_value)
Definition: MyGUI_WidgetStyle.h:51
MyGUI::operator==
bool operator==(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
Definition: MyGUI_UString.h:1046
MyGUI::WidgetStyle::WidgetStyle
WidgetStyle()
Definition: MyGUI_WidgetStyle.h:41
MyGUI::WidgetStyle::print
std::string print() const
Definition: MyGUI_WidgetStyle.h:90
MyGUI::WidgetStyle::WidgetStyle
WidgetStyle(Enum _value)
Definition: MyGUI_WidgetStyle.h:46
MyGUI::WidgetStyle::Child
Definition: MyGUI_WidgetStyle.h:35
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:120
MyGUI::WidgetStyle
Definition: MyGUI_WidgetStyle.h:31
MyGUI::WidgetStyle::Popup
Definition: MyGUI_WidgetStyle.h:36
MyGUI::WidgetStyle::Enum
Enum
Definition: MyGUI_WidgetStyle.h:33