MyGUI 3.2.0

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

- File List
- Globals

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