ManaPlus
src
gui
widgets
setupquickitem.cpp
Go to the documentation of this file.
1
/*
2
* The ManaPlus Client
3
* Copyright (C) 2011-2019 The ManaPlus Developers
4
* Copyright (C) 2019-2021 Andrei Karas
5
*
6
* This file is part of The ManaPlus Client.
7
*
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#include "
gui/widgets/setupquickitem.h
"
23
24
#include "
gui/widgets/button.h
"
25
#include "
gui/widgets/horizontcontainer.h
"
26
#include "
gui/widgets/label.h
"
27
#include "
gui/widgets/vertcontainer.h
"
28
29
#include "
gui/widgets/tabs/setuptabscroll.h
"
30
31
#include "
debug.h
"
32
33
SetupQuickItem::SetupQuickItem
(
const
std::string &
restrict
description,
34
SetupTabScroll
*
restrict
const
parent,
35
const
std::string &
restrict
eventName,
36
const
ModifierGetFuncPtr
getFunc,
37
const
ModifierChangeFuncPtr
changeFunc) :
38
SetupItem
(
""
, description,
""
, parent, eventName,
MainConfig_false
),
39
GameModifierListener
(),
40
mHorizont(
nullptr
),
41
mButton(
nullptr
),
42
mLabel(
nullptr
),
43
mGetFunc(getFunc),
44
mChangeFunc(changeFunc)
45
{
46
mValueType
=
VSTR
;
47
createControls
();
48
}
49
50
SetupQuickItem::~SetupQuickItem
()
51
{
52
mHorizont
=
nullptr
;
53
mWidget
=
nullptr
;
54
mButton
=
nullptr
;
55
}
56
57
void
SetupQuickItem::save
()
58
{
59
}
60
61
void
SetupQuickItem::cancel
(
const
std::string &eventName
A_UNUSED
)
62
{
63
}
64
65
void
SetupQuickItem::externalUpdated
(
const
std::string &eventName
A_UNUSED
)
66
{
67
}
68
69
void
SetupQuickItem::rereadValue
()
70
{
71
}
72
73
void
SetupQuickItem::createControls
()
74
{
75
mHorizont
=
new
HorizontContainer
(
this
, 32, 2);
76
77
mWidget
=
new
Button
(
this
,
78
">"
,
79
mEventName
+
"_CHANGE"
,
80
BUTTON_SKIN
,
81
nullptr
);
82
mLabel
=
new
Label
(
this
, std::string());
83
mLabel
->
setToolTip
(
mDescription
);
84
mLabel
->
adjustSize
();
85
86
mHorizont
->
add
(
mWidget
, 5);
87
mHorizont
->
add
(
mLabel
);
88
89
mParent
->
getContainer
()->
add2
(
mHorizont
,
true
, 4);
90
mParent
->
addControl
(
this
);
91
mWidget
->
addActionListener
(
this
);
92
toWidget
();
93
}
94
95
void
SetupQuickItem::fromWidget
()
96
{
97
}
98
99
void
SetupQuickItem::toWidget
()
100
{
101
mLabel
->
setCaption
(
mGetFunc
());
102
mLabel
->
adjustSize
();
103
}
104
105
void
SetupQuickItem::action
(
const
ActionEvent
&event)
106
{
107
if
(event.
getId
() ==
mEventName
+
"_CHANGE"
)
108
{
109
// need change game modifier
110
mChangeFunc
(
true
);
111
toWidget
();
112
}
113
}
114
115
void
SetupQuickItem::apply
(
const
std::string &eventName
A_UNUSED
)
116
{
117
}
118
119
void
SetupQuickItem::gameModifiersChanged
()
120
{
121
toWidget
();
122
}
button.h
BUTTON_SKIN
const std::string BUTTON_SKIN
Definition:
button.h:89
ActionEvent
Definition:
actionevent.h:98
ActionEvent::getId
const std::string & getId() const
Definition:
actionevent.h:122
Button
Definition:
button.h:102
GameModifierListener
Definition:
gamemodifierlistener.h:30
HorizontContainer
Definition:
horizontcontainer.h:41
HorizontContainer::add
void add(Widget *const widget)
Definition:
horizontcontainer.cpp:42
Label
Definition:
label.h:91
Label::adjustSize
void adjustSize()
Definition:
label.cpp:200
Label::setCaption
void setCaption(const std::string &caption)
Definition:
label.cpp:264
SetupItem
Definition:
setupitem.h:53
SetupItem::mWidget
Widget * mWidget
Definition:
setupitem.h:143
SetupItem::mParent
SetupTabScroll * mParent
Definition:
setupitem.h:135
SetupItem::mDescription
std::string mDescription
Definition:
setupitem.h:131
SetupItem::VSTR
@ VSTR
Definition:
setupitem.h:58
SetupItem::mValueType
int mValueType
Definition:
setupitem.h:147
SetupItem::mEventName
std::string mEventName
Definition:
setupitem.h:137
SetupQuickItem::toWidget
void toWidget()
Definition:
setupquickitem.cpp:99
SetupQuickItem::fromWidget
void fromWidget()
Definition:
setupquickitem.cpp:95
SetupQuickItem::~SetupQuickItem
~SetupQuickItem()
Definition:
setupquickitem.cpp:50
SetupQuickItem::externalUpdated
void externalUpdated(const std::string &eventName)
Definition:
setupquickitem.cpp:65
SetupQuickItem::mGetFunc
ModifierGetFuncPtr mGetFunc
Definition:
setupquickitem.h:76
SetupQuickItem::mHorizont
HorizontContainer * mHorizont
Definition:
setupquickitem.h:73
SetupQuickItem::mChangeFunc
ModifierChangeFuncPtr mChangeFunc
Definition:
setupquickitem.h:77
SetupQuickItem::createControls
void createControls()
Definition:
setupquickitem.cpp:73
SetupQuickItem::mButton
Button * mButton
Definition:
setupquickitem.h:74
SetupQuickItem::save
void save()
Definition:
setupquickitem.cpp:57
SetupQuickItem::action
void action(const ActionEvent &event)
Definition:
setupquickitem.cpp:105
SetupQuickItem::apply
void apply(const std::string &eventName)
Definition:
setupquickitem.cpp:115
SetupQuickItem::rereadValue
void rereadValue()
Definition:
setupquickitem.cpp:69
SetupQuickItem::mLabel
Label * mLabel
Definition:
setupquickitem.h:75
SetupQuickItem::gameModifiersChanged
void gameModifiersChanged()
Definition:
setupquickitem.cpp:119
SetupQuickItem::cancel
void cancel(const std::string &eventName)
Definition:
setupquickitem.cpp:61
SetupQuickItem::SetupQuickItem
SetupQuickItem(const std::string &description, SetupTabScroll *const parent, const std::string &eventName, ModifierGetFuncPtr getFunc, ModifierChangeFuncPtr changeFunc)
Definition:
setupquickitem.cpp:33
SetupTabScroll
Definition:
setuptabscroll.h:34
SetupTabScroll::addControl
void addControl(SetupItem *const widget)
Definition:
setuptabscroll.cpp:74
SetupTabScroll::getContainer
VertContainer * getContainer() const
Definition:
setuptabscroll.h:46
ToolTipListener::setToolTip
void setToolTip(const std::string &str)
Definition:
tooltiplistener.h:38
VertContainer::add2
void add2(Widget *const widget, const bool resizable, const int spacing)
Definition:
vertcontainer.cpp:51
Widget::addActionListener
void addActionListener(ActionListener *const actionListener)
Definition:
widget.cpp:252
debug.h
horizontcontainer.h
label.h
restrict
#define restrict
Definition:
localconsts.h:165
nullptr
#define nullptr
Definition:
localconsts.h:45
A_UNUSED
#define A_UNUSED
Definition:
localconsts.h:160
MainConfig_false
const bool MainConfig_false
Definition:
mainconfig.h:30
setupquickitem.h
ModifierGetFuncPtr
std::string(* ModifierGetFuncPtr)()
Definition:
setupquickitem.h:34
ModifierChangeFuncPtr
void(* ModifierChangeFuncPtr)(const bool forward)
Definition:
setupquickitem.h:35
setuptabscroll.h
vertcontainer.h
Generated on Wed Mar 17 2021 19:19:06 for ManaPlus by
1.9.1