MyGUI 3.2.0

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

- File List
- Globals

MyGUI_ResizingPolicy.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_RESIZING_POLICY_H__
23 #define __MYGUI_RESIZING_POLICY_H__
24
25 #include "MyGUI_Prerequest.h"
26
27 namespace MyGUI
28 {
29
30 struct MYGUI_EXPORT ResizingPolicy
31 {
32 enum Enum
33 {
34 Auto,
35 Fixed,
36 Fill,
37 MAX
38 };
39
40 ResizingPolicy(Enum _value = MAX) :
41 value(_value)
42 {
43 }
44
45 static ResizingPolicy parse(const std::string& _value)
46 {
47 ResizingPolicy type;
48 int value = 0;
49 while (true)
50 {
51 const char* name = type.getValueName(value);
52 if (strcmp(name, "") == 0 || name == _value)
53 break;
54 value++;
55 }
56 type.value = Enum(value);
57 return type;
58 }
59
60 friend bool operator == (ResizingPolicy const& a, ResizingPolicy const& b)
61 {
62 return a.value == b.value;
63 }
64
65 friend bool operator != (ResizingPolicy const& a, ResizingPolicy const& b)
66 {
67 return a.value != b.value;
68 }
69
70 friend std::ostream& operator << (std::ostream& _stream, const ResizingPolicy& _value)
71 {
72 _stream << _value.getValueName(_value.value);
73 return _stream;
74 }
75
76 friend std::istream& operator >> (std::istream& _stream, ResizingPolicy& _value)
77 {
78 std::string value;
79 _stream >> value;
80 _value = parse(value);
81 return _stream;
82 }
83
84 std::string print() const
85 {
86 return getValueName(value);
87 }
88
89 private:
90 const char* getValueName(int _index) const
91 {
92 static const char* values[MAX + 1] = { "Auto", "Fixed", "Fill", "" };
93 return values[(_index < MAX && _index >= 0) ? _index : MAX];
94 }
95
96 private:
97 Enum value;
98 };
99
100 } // namespace MyGUI
101
102 #endif // __MYGUI_RESIZING_POLICY_H__
MyGUI::FontCodeType::Enum
Enum
Definition: MyGUI_FontData.h:33
MyGUI::ResizingPolicy::print
std::string print() const
Definition: MyGUI_ResizingPolicy.h:84
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::operator==
bool operator==(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
Definition: MyGUI_UString.h:1046
MyGUI::ResizingPolicy::Fixed
Definition: MyGUI_ResizingPolicy.h:35
MyGUI::ResizingPolicy::Auto
Definition: MyGUI_ResizingPolicy.h:34
MyGUI::ResizingPolicy::ResizingPolicy
ResizingPolicy(Enum _value=MAX)
Definition: MyGUI_ResizingPolicy.h:40
MyGUI::ResizingPolicy::Fill
Definition: MyGUI_ResizingPolicy.h:36
MyGUI::ResizingPolicy
Definition: MyGUI_ResizingPolicy.h:30
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:120
MyGUI::ResizingPolicy::parse
static ResizingPolicy parse(const std::string &_value)
Definition: MyGUI_ResizingPolicy.h:45
MyGUI::ResizingPolicy::Enum
Enum
Definition: MyGUI_ResizingPolicy.h:32