MyGUI 3.4.1
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>
12#include <cstring>
13#include <iostream>
14
15namespace MyGUI
16{
17
19 {
20 enum Enum
21 {
25 MAX
26 };
27
29 mValue(MAX)
30 {
31 }
32
33 WidgetStyle(Enum _value) :
34 mValue(_value)
35 {
36 }
37
38 static WidgetStyle parse(const std::string& _value)
39 {
40 WidgetStyle type;
41 int value = 0;
42 while (true)
43 {
44 const char* name = type.getValueName(value);
45 if (strcmp(name, "") == 0 || name == _value)
46 break;
47 value++;
48 }
49 type.mValue = (Enum)value;
50 return type;
51 }
52
53 friend bool operator == (WidgetStyle const& a, WidgetStyle const& b)
54 {
55 return a.mValue == b.mValue;
56 }
57
58 friend bool operator != (WidgetStyle const& a, WidgetStyle const& b)
59 {
60 return a.mValue != b.mValue;
61 }
62
63 friend std::ostream& operator << (std::ostream& _stream, const WidgetStyle& _value)
64 {
65 _stream << _value.getValueName(_value.mValue);
66 return _stream;
67 }
68
69 friend std::istream& operator >> (std::istream& _stream, WidgetStyle& _value)
70 {
71 std::string value;
72 _stream >> value;
73 _value = parse(value);
74 return _stream;
75 }
76
77 std::string print() const
78 {
79 return getValueName(mValue);
80 }
81
82 int getValue() const
83 {
84 return mValue;
85 }
86
87 private:
88 const char* getValueName(int _index) const
89 {
90 static const char* values[MAX + 1] = { "Child", "Popup", "Overlapped", "" };
91 return values[(_index < MAX && _index >= 0) ? _index : MAX];
92 }
93
94 private:
95 Enum mValue;
96 };
97
98} // namespace MyGUI
99
100#endif // MYGUI_WIDGET_STYLE_H_
#define MYGUI_EXPORT
bool operator==(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
bool operator!=(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
WidgetStyle(Enum _value)
std::string print() const
static WidgetStyle parse(const std::string &_value)