MyGUI
3.4.2
Main Page
Related Pages
Namespaces
Data Structures
Files
Examples
File List
Globals
MyGUIEngine
include
MyGUI_FlowDirection.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_FLOW_DIRECTION_H_
8
#define MYGUI_FLOW_DIRECTION_H_
9
10
#include "
MyGUI_Prerequest.h
"
11
#include <string>
12
#include <string.h>
13
#include <iostream>
14
15
namespace
MyGUI
16
{
17
18
struct
MYGUI_EXPORT
FlowDirection
19
{
20
enum
Enum
21
{
22
LeftToRight
,
23
RightToLeft
,
24
TopToBottom
,
25
BottomToTop
,
26
MAX
27
};
28
29
FlowDirection
(
Enum
_value = LeftToRight) :
30
mValue(_value)
31
{
32
}
33
34
static
FlowDirection
parse
(
const
std::string& _value)
35
{
36
FlowDirection
type;
37
int
value = 0;
38
while
(
true
)
39
{
40
const
char
* name = type.getValueName(value);
41
if
(strcmp(name,
""
) == 0 || name == _value)
break
;
42
value++;
43
}
44
type.mValue = (
Enum
)value;
45
return
type;
46
}
47
48
bool
isHorizontal
()
const
49
{
50
return
mValue == LeftToRight || mValue == RightToLeft;
51
}
52
53
bool
isVertical
()
const
54
{
55
return
!isHorizontal();
56
}
57
58
friend
bool
operator == (
FlowDirection
const
& a,
FlowDirection
const
& b)
59
{
60
return
a.mValue == b.mValue;
61
}
62
63
friend
bool
operator != (
FlowDirection
const
& a,
FlowDirection
const
& b)
64
{
65
return
a.mValue != b.mValue;
66
}
67
68
friend
std::ostream& operator << ( std::ostream& _stream,
const
FlowDirection
& _value )
69
{
70
_stream << _value.getValueName(_value.mValue);
71
return
_stream;
72
}
73
74
friend
std::istream& operator >> ( std::istream& _stream,
FlowDirection
& _value )
75
{
76
std::string value;
77
_stream >> value;
78
_value = parse(value);
79
return
_stream;
80
}
81
82
std::string
print
()
const
83
{
84
return
getValueName(mValue);
85
}
86
87
int
getValue
()
const
88
{
89
return
mValue;
90
}
91
92
private
:
93
const
char
* getValueName(
int
_index)
const
94
{
95
static
const
char
* values[MAX + 1] = {
"LeftToRight"
,
"RightToLeft"
,
"TopToBottom"
,
"BottomToTop"
,
""
};
96
return
values[(_index < MAX && _index >= 0) ? _index : MAX];
97
}
98
99
private
:
100
Enum
mValue;
101
};
102
103
}
// namespace MyGUI
104
105
#endif
// MYGUI_FLOW_DIRECTION_H_
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition
MyGUI_Platform.h:77
MyGUI_Prerequest.h
MyGUI::FontCodeType::Enum
Enum
Definition
MyGUI_FontData.h:20
MyGUI
Definition
MyGUI_ActionController.h:15
MyGUI::FlowDirection
Definition
MyGUI_FlowDirection.h:19
MyGUI::FlowDirection::print
std::string print() const
Definition
MyGUI_FlowDirection.h:82
MyGUI::FlowDirection::isVertical
bool isVertical() const
Definition
MyGUI_FlowDirection.h:53
MyGUI::FlowDirection::getValue
int getValue() const
Definition
MyGUI_FlowDirection.h:87
MyGUI::FlowDirection::parse
static FlowDirection parse(const std::string &_value)
Definition
MyGUI_FlowDirection.h:34
MyGUI::FlowDirection::FlowDirection
FlowDirection(Enum _value=LeftToRight)
Definition
MyGUI_FlowDirection.h:29
MyGUI::FlowDirection::Enum
Enum
Definition
MyGUI_FlowDirection.h:21
MyGUI::FlowDirection::TopToBottom
@ TopToBottom
Definition
MyGUI_FlowDirection.h:24
MyGUI::FlowDirection::RightToLeft
@ RightToLeft
Definition
MyGUI_FlowDirection.h:23
MyGUI::FlowDirection::BottomToTop
@ BottomToTop
Definition
MyGUI_FlowDirection.h:25
MyGUI::FlowDirection::LeftToRight
@ LeftToRight
Definition
MyGUI_FlowDirection.h:22
MyGUI::FlowDirection::isHorizontal
bool isHorizontal() const
Definition
MyGUI_FlowDirection.h:48
Generated by
1.12.0