GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/sliderlist.h Lines: 0 1 0.0 %
Date: 2021-03-17 Branches: 0 0 0.0 %

Line Branch Exec Source
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
25
#include "listeners/actionlistener.h"
26
#include "listeners/mouselistener.h"
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
44
        A_DELETE_COPY(SliderList)
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
73
        int getSelected() const noexcept2 A_WARN_UNUSED
74
        { return mSelectedIndex; }
75
76
    protected:
77
        void updateLabel();
78
79
        int getMaxLabelWidth() const A_WARN_UNUSED;
80
81
        Button *mButtons[2] A_NONNULLPOINTER;
82
        Label *mLabel A_NONNULLPOINTER;
83
        ListModel *mListModel;
84
        std::string mPrevEventId;
85
        std::string mNextEventId;
86
        int mOldWidth;
87
        int mSelectedIndex;
88
};
89
90
#endif  // GUI_WIDGETS_SLIDERLIST_H