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

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2011-2017  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
21
#ifndef GUI_WIDGETS_SLIDERLIST_H
22
#define GUI_WIDGETS_SLIDERLIST_H
23
24
#include "listeners/actionlistener.h"
25
#include "listeners/mouselistener.h"
26
27
#include "gui/widgets/container.h"
28
29
#include "localconsts.h"
30
31
class Button;
32
class Label;
33
class ListModel;
34
35
class SliderList final : public Container,
36
                         public ActionListener,
37
                         public MouseListener
38
{
39
    public:
40
        SliderList(const Widget2 *const widget,
41
                   ListModel *const listModel);
42
43
        A_DELETE_COPY(SliderList)
44
45
        ~SliderList();
46
47
        void postInit2(ActionListener *const listener,
48
                       const std::string &eventId);
49
50
        void updateAlpha();
51
52
        void mouseWheelMovedUp(MouseEvent& event) override final;
53
54
        void mouseWheelMovedDown(MouseEvent& event) override final;
55
56
        void resize();
57
58
        void draw(Graphics *const graphics) override final A_NONNULL(2);
59
60
        void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
61
62
        void action(const ActionEvent &event) override final;
63
64
        void setSelectedString(const std::string &str);
65
66
        std::string getSelectedString() const A_WARN_UNUSED;
67
68
        void setSelected(const int idx);
69
70
        void adjustSize();
71
72
        int getSelected() const noexcept2 A_WARN_UNUSED
73
        { return mSelectedIndex; }
74
75
    protected:
76
        void updateLabel();
77
78
        int getMaxLabelWidth() const A_WARN_UNUSED;
79
80
        Button *mButtons[2] A_NONNULLPOINTER;
81
        Label *mLabel A_NONNULLPOINTER;
82
        ListModel *mListModel;
83
        std::string mPrevEventId;
84
        std::string mNextEventId;
85
        int mOldWidth;
86
        int mSelectedIndex;
87
};
88
89
#endif  // GUI_WIDGETS_SLIDERLIST_H