Otclient
14/8/2020
uitranslator.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to deal
6
* in the Software without restriction, including without limitation the rights
7
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
* copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
* THE SOFTWARE.
21
*/
22
23
#include "
uitranslator.h
"
24
#include <
framework/stdext/string.h
>
25
#include <boost/algorithm/string.hpp>
26
27
Fw::AlignmentFlag
Fw::translateAlignment
(std::string aligment)
28
{
29
boost::to_lower(aligment);
30
boost::erase_all(aligment,
" "
);
31
if
(aligment ==
"topleft"
)
32
return
Fw::AlignTopLeft
;
33
else
if
(aligment ==
"topright"
)
34
return
Fw::AlignTopRight
;
35
else
if
(aligment ==
"bottomleft"
)
36
return
Fw::AlignBottomLeft
;
37
else
if
(aligment ==
"bottomright"
)
38
return
Fw::AlignBottomRight
;
39
else
if
(aligment ==
"left"
)
40
return
Fw::AlignLeftCenter
;
41
else
if
(aligment ==
"right"
)
42
return
Fw::AlignRightCenter
;
43
else
if
(aligment ==
"top"
)
44
return
Fw::AlignTopCenter
;
45
else
if
(aligment ==
"bottom"
)
46
return
Fw::AlignBottomCenter
;
47
else
if
(aligment ==
"center"
)
48
return
Fw::AlignCenter
;
49
return
Fw::AlignNone
;
50
}
51
52
Fw::AnchorEdge
Fw::translateAnchorEdge
(std::string anchorEdge)
53
{
54
boost::to_lower(anchorEdge);
55
boost::erase_all(anchorEdge,
" "
);
56
if
(anchorEdge ==
"left"
)
57
return
Fw::AnchorLeft
;
58
else
if
(anchorEdge ==
"right"
)
59
return
Fw::AnchorRight
;
60
else
if
(anchorEdge ==
"top"
)
61
return
Fw::AnchorTop
;
62
else
if
(anchorEdge ==
"bottom"
)
63
return
Fw::AnchorBottom
;
64
else
if
(anchorEdge ==
"horizontalcenter"
)
65
return
Fw::AnchorHorizontalCenter
;
66
else
if
(anchorEdge ==
"verticalcenter"
)
67
return
Fw::AnchorVerticalCenter
;
68
return
Fw::AnchorNone
;
69
}
70
71
Fw::WidgetState
Fw::translateState
(std::string state)
72
{
73
boost::to_lower(state);
74
boost::trim
(state);
75
if
(state ==
"active"
)
76
return
Fw::ActiveState
;
77
else
if
(state ==
"focus"
)
78
return
Fw::FocusState
;
79
else
if
(state ==
"hover"
)
80
return
Fw::HoverState
;
81
else
if
(state ==
"pressed"
)
82
return
Fw::PressedState
;
83
else
if
(state ==
"checked"
)
84
return
Fw::CheckedState
;
85
else
if
(state ==
"disabled"
)
86
return
Fw::DisabledState
;
87
else
if
(state ==
"on"
)
88
return
Fw::OnState
;
89
else
if
(state ==
"first"
)
90
return
Fw::FirstState
;
91
else
if
(state ==
"middle"
)
92
return
Fw::MiddleState
;
93
else
if
(state ==
"last"
)
94
return
Fw::LastState
;
95
else
if
(state ==
"alternate"
)
96
return
Fw::AlternateState
;
97
else
if
(state ==
"dragging"
)
98
return
Fw::DraggingState
;
99
else
if
(state ==
"hidden"
)
100
return
Fw::HiddenState
;
101
return
Fw::InvalidState
;
102
}
103
104
Fw::AutoFocusPolicy
Fw::translateAutoFocusPolicy
(std::string policy)
105
{
106
boost::to_lower(policy);
107
boost::trim
(policy);
108
if
(policy ==
"first"
)
109
return
Fw::AutoFocusFirst
;
110
else
if
(policy ==
"last"
)
111
return
Fw::AutoFocusLast
;
112
return
Fw::AutoFocusNone
;
113
}
Fw::FirstState
@ FirstState
Definition:
const.h:276
Fw::FocusState
@ FocusState
Definition:
const.h:270
trim
#define trim(x)
Definition:
lbitlib.cpp:193
Fw::AlignBottomCenter
@ AlignBottomCenter
Definition:
const.h:207
Fw::ActiveState
@ ActiveState
Definition:
const.h:269
Fw::WidgetState
WidgetState
Definition:
const.h:266
Fw::AnchorRight
@ AnchorRight
Definition:
const.h:216
Fw::AlignCenter
@ AlignCenter
Definition:
const.h:208
string.h
Fw::DraggingState
@ DraggingState
Definition:
const.h:280
Fw::AlignBottomRight
@ AlignBottomRight
Definition:
const.h:203
Fw::AlignTopLeft
@ AlignTopLeft
Definition:
const.h:200
uitranslator.h
Fw::AnchorEdge
AnchorEdge
Definition:
const.h:211
Fw::AnchorLeft
@ AnchorLeft
Definition:
const.h:215
Fw::HoverState
@ HoverState
Definition:
const.h:271
Fw::AutoFocusLast
@ AutoFocusLast
Definition:
const.h:231
Fw::AlignBottomLeft
@ AlignBottomLeft
Definition:
const.h:202
Fw::MiddleState
@ MiddleState
Definition:
const.h:277
Fw::AlignTopCenter
@ AlignTopCenter
Definition:
const.h:206
Fw::AutoFocusFirst
@ AutoFocusFirst
Definition:
const.h:230
Fw::AlignNone
@ AlignNone
Definition:
const.h:193
Fw::translateAutoFocusPolicy
AutoFocusPolicy translateAutoFocusPolicy(std::string policy)
Definition:
uitranslator.cpp:104
Fw::OnState
@ OnState
Definition:
const.h:275
Fw::AnchorNone
@ AnchorNone
Definition:
const.h:212
Fw::AnchorTop
@ AnchorTop
Definition:
const.h:213
Fw::AlignmentFlag
AlignmentFlag
Definition:
const.h:192
Fw::PressedState
@ PressedState
Definition:
const.h:272
Fw::AlignLeftCenter
@ AlignLeftCenter
Definition:
const.h:204
Fw::AlternateState
@ AlternateState
Definition:
const.h:279
Fw::DisabledState
@ DisabledState
Definition:
const.h:273
Fw::InvalidState
@ InvalidState
Definition:
const.h:267
Fw::translateAlignment
AlignmentFlag translateAlignment(std::string aligment)
Definition:
uitranslator.cpp:27
Fw::AlignTopRight
@ AlignTopRight
Definition:
const.h:201
Fw::translateAnchorEdge
AnchorEdge translateAnchorEdge(std::string anchorEdge)
Definition:
uitranslator.cpp:52
Fw::CheckedState
@ CheckedState
Definition:
const.h:274
Fw::HiddenState
@ HiddenState
Definition:
const.h:281
Fw::AnchorVerticalCenter
@ AnchorVerticalCenter
Definition:
const.h:217
Fw::AnchorBottom
@ AnchorBottom
Definition:
const.h:214
Fw::translateState
WidgetState translateState(std::string state)
Definition:
uitranslator.cpp:71
Fw::AutoFocusPolicy
AutoFocusPolicy
Definition:
const.h:228
Fw::AlignRightCenter
@ AlignRightCenter
Definition:
const.h:205
Fw::LastState
@ LastState
Definition:
const.h:278
Fw::AutoFocusNone
@ AutoFocusNone
Definition:
const.h:229
Fw::AnchorHorizontalCenter
@ AnchorHorizontalCenter
Definition:
const.h:218
src
framework
ui
uitranslator.cpp
Generated by
1.8.17
For more information visit
https://forum.opentibia.dev/