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