ManaPlus
sliderlist.h
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 #ifndef GUI_WIDGETS_SLIDERLIST_H
23 #define GUI_WIDGETS_SLIDERLIST_H
24 
27 
28 #include "gui/widgets/container.h"
29 
30 #include "localconsts.h"
31 
32 class Button;
33 class Label;
34 class ListModel;
35 
36 class SliderList final : public Container,
37  public ActionListener,
38  public MouseListener
39 {
40  public:
41  SliderList(const Widget2 *const widget,
42  ListModel *const listModel);
43 
45 
46  ~SliderList() override final;
47 
48  void postInit2(ActionListener *const listener,
49  const std::string &eventId);
50 
51  void updateAlpha();
52 
53  void mouseWheelMovedUp(MouseEvent& event) override final;
54 
55  void mouseWheelMovedDown(MouseEvent& event) override final;
56 
57  void resize();
58 
59  void draw(Graphics *const graphics) override final A_NONNULL(2);
60 
61  void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
62 
63  void action(const ActionEvent &event) override final;
64 
65  void setSelectedString(const std::string &str);
66 
67  std::string getSelectedString() const A_WARN_UNUSED;
68 
69  void setSelected(const int idx);
70 
71  void adjustSize();
72 
74  { return mSelectedIndex; }
75 
76  protected:
77  void updateLabel();
78 
79  int getMaxLabelWidth() const A_WARN_UNUSED;
80 
84  std::string mPrevEventId;
85  std::string mNextEventId;
86  int mOldWidth;
88 };
89 
90 #endif // GUI_WIDGETS_SLIDERLIST_H
Definition: button.h:102
Definition: label.h:91
int getMaxLabelWidth() const
Definition: sliderlist.cpp:233
void resize()
Definition: sliderlist.cpp:109
void action(const ActionEvent &event)
Definition: sliderlist.cpp:168
void mouseWheelMovedUp(MouseEvent &event)
Definition: sliderlist.cpp:97
int mSelectedIndex
Definition: sliderlist.h:87
std::string mPrevEventId
Definition: sliderlist.h:84
void safeDraw(Graphics *const graphics)
Definition: sliderlist.cpp:133
void mouseWheelMovedDown(MouseEvent &event)
Definition: sliderlist.cpp:103
void setSelectedString(const std::string &str)
Definition: sliderlist.cpp:190
Label * mLabel
Definition: sliderlist.h:82
std::string mNextEventId
Definition: sliderlist.h:85
Button * mButtons[2]
Definition: sliderlist.h:81
int getSelected() const
Definition: sliderlist.h:73
void updateLabel()
Definition: sliderlist.cpp:146
void setSelected(const int idx)
Definition: sliderlist.cpp:213
SliderList(const Widget2 *const widget, ListModel *const listModel)
Definition: sliderlist.cpp:39
void adjustSize()
Definition: sliderlist.cpp:227
std::string getSelectedString() const
Definition: sliderlist.cpp:205
void draw(Graphics *const graphics)
Definition: sliderlist.cpp:120
int mOldWidth
Definition: sliderlist.h:86
void updateAlpha()
Definition: sliderlist.cpp:91
void postInit2(ActionListener *const listener, const std::string &eventId)
Definition: sliderlist.cpp:56
ListModel * mListModel
Definition: sliderlist.h:83
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULL(...)
Definition: localconsts.h:168
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53