MyGUI
3.0.1
Main Page
Related Pages
Namespaces
Data Structures
Files
Examples
File List
Globals
MyGUIEngine
src
MyGUI_MenuItem.cpp
Go to the documentation of this file.
1
7
/*
8
This file is part of MyGUI.
9
10
MyGUI is free software: you can redistribute it and/or modify
11
it under the terms of the GNU Lesser General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
14
15
MyGUI is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU Lesser General Public License for more details.
19
20
You should have received a copy of the GNU Lesser General Public License
21
along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22
*/
23
#include "
MyGUI_Precompiled.h
"
24
#include "
MyGUI_MenuItem.h
"
25
#include "
MyGUI_SkinManager.h
"
26
#include "
MyGUI_SubWidgetManager.h
"
27
28
namespace
MyGUI
29
{
30
31
MenuItem::MenuItem
() :
32
mOwner(
nullptr
)
33
{
34
}
35
36
void
MenuItem::_initialise
(
WidgetStyle
_style,
const
IntCoord
& _coord,
Align
_align,
ResourceSkin
* _info,
Widget
* _parent,
ICroppedRectangle
* _croppedParent,
IWidgetCreator
* _creator,
const
std::string& _name)
37
{
38
Base::_initialise
(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
39
40
Widget
* parent =
getParent
();
41
MYGUI_ASSERT
(parent,
"MenuItem must have parent MenuCtrl"
);
42
if
(!parent->
isType
<
MenuCtrl
>())
43
{
44
Widget
* client = parent;
45
parent = client->
getParent
();
46
MYGUI_ASSERT
(parent,
"MenuItem must have parent MenuCtrl"
);
47
MYGUI_ASSERT
(parent->
getClientWidget
() == client,
"MenuItem must have parent MenuCtrl"
);
48
MYGUI_ASSERT
(parent->
isType
<
MenuCtrl
>(),
"MenuItem must have parent MenuCtrl"
);
49
}
50
mOwner = parent->
castType
<
MenuCtrl
>();
51
52
initialiseWidgetSkin
(_info);
53
54
// нам нуженфокус клавы
55
this->
mNeedKeyFocus
=
true
;
56
}
57
58
MenuItem::~MenuItem
()
59
{
60
shutdownWidgetSkin
();
61
mOwner->
_notifyDeleteItem
(
this
);
62
}
63
64
Widget
*
MenuItem::baseCreateWidget
(
WidgetStyle
_style,
const
std::string& _type,
const
std::string& _skin,
const
IntCoord
& _coord,
Align
_align,
const
std::string& _layer,
const
std::string& _name)
65
{
66
Widget
* widget =
Base::baseCreateWidget
(_style, _type, _skin, _coord, _align, _layer, _name);
67
MenuCtrl
* child = widget->
castType
<
MenuCtrl
>(
false
);
68
if
(child) mOwner->
_wrapItemChild
(
this
, child);
69
return
widget;
70
}
71
72
void
MenuItem::baseChangeWidgetSkin
(
ResourceSkin
* _info)
73
{
74
shutdownWidgetSkin
();
75
Button::baseChangeWidgetSkin
(_info);
76
initialiseWidgetSkin
(_info);
77
}
78
79
void
MenuItem::initialiseWidgetSkin
(
ResourceSkin
* _info)
80
{
81
}
82
83
void
MenuItem::shutdownWidgetSkin
()
84
{
85
}
86
87
void
MenuItem::onMouseButtonPressed(
int
_left,
int
_top,
MouseButton
_id)
88
{
89
Base::onMouseButtonPressed
(_left, _top, _id);
90
}
91
92
void
MenuItem::onMouseButtonReleased(
int
_left,
int
_top, MouseButton _id)
93
{
94
Base::onMouseButtonReleased
(_left, _top, _id);
95
}
96
97
void
MenuItem::setCaption
(
const
UString
& _value)
98
{
99
Button::setCaption
(_value);
100
mOwner->
_notifyUpdateName
(
this
);
101
}
102
103
const
UString
&
MenuItem::getItemName
()
104
{
105
return
mOwner->
getItemName
(
this
);
106
}
107
108
void
MenuItem::setItemName
(
const
UString
& _value)
109
{
110
mOwner->
setItemName
(
this
, _value);
111
}
112
113
void
MenuItem::setItemData
(
Any
_data)
114
{
115
mOwner->
setItemData
(
this
, _data);
116
}
117
118
void
MenuItem::removeItem
()
119
{
120
mOwner->
removeItem
(
this
);
121
}
122
123
void
MenuItem::setItemId
(
const
std::string& _id)
124
{
125
mOwner->
setItemId
(
this
, _id);
126
}
127
128
const
std::string&
MenuItem::getItemId
()
129
{
130
return
mOwner->
getItemId
(
this
);
131
}
132
133
size_t
MenuItem::getItemIndex
()
134
{
135
return
mOwner->
getItemIndex
(
this
);
136
}
137
138
MenuCtrl
*
MenuItem::createItemChild
()
139
{
140
return
mOwner->
createItemChild
(
this
);
141
}
142
143
void
MenuItem::setItemType
(
MenuItemType
_type)
144
{
145
mOwner->
setItemType
(
this
, _type);
146
}
147
148
MenuItemType
MenuItem::getItemType
()
149
{
150
return
mOwner->
getItemType
(
this
);
151
}
152
153
void
MenuItem::setItemChildVisible
(
bool
_visible)
154
{
155
mOwner->
setItemChildVisible
(
this
, _visible);
156
}
157
158
MenuCtrl
*
MenuItem::getItemChild
()
159
{
160
return
mOwner->
getItemChild
(
this
);
161
}
162
163
void
MenuItem::setProperty
(
const
std::string& _key,
const
std::string& _value)
164
{
165
if
(_key ==
"MenuItem_Id"
)
setItemId
(_value);
166
else
if
(_key ==
"MenuItem_Type"
)
setItemType
(utility::parseValue<MenuItemType>(_value));
167
else
168
{
169
Base::setProperty
(_key, _value);
170
return
;
171
}
172
eventChangeProperty
(
this
, _key, _value);
173
}
174
175
}
// namespace MyGUI
Generated by
1.8.1.2