GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/shortcutcontainer.h Lines: 3 6 50.0 %
Date: 2018-09-20 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2007-2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2018  The ManaPlus Developers
6
 *
7
 *  This file is part of The ManaPlus Client.
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#ifndef GUI_WIDGETS_SHORTCUTCONTAINER_H
24
#define GUI_WIDGETS_SHORTCUTCONTAINER_H
25
26
#include "gui/widgets/widget.h"
27
28
#include "listeners/mouselistener.h"
29
#include "listeners/widgetlistener.h"
30
31
class Image;
32
class ImageCollection;
33
class Skin;
34
35
/**
36
 * A generic shortcut container.
37
 *
38
 * \ingroup GUI
39
 */
40
class ShortcutContainer notfinal : public Widget,
41
                                   public WidgetListener,
42
                                   public MouseListener
43
{
44
    public:
45
        A_DELETE_COPY(ShortcutContainer)
46
47
        /**
48
         * Destructor.
49
         */
50
        ~ShortcutContainer() override;
51
52
        /**
53
         * Invoked when a widget changes its size. This is used to determine
54
         * the new height of the container.
55
         */
56
        void widgetResized(const Event &event) override final;
57
58
        void widgetMoved(const Event& event) override final;
59
60
        /**
61
         * Handles mouse when dragged.
62
         */
63
        void mouseDragged(MouseEvent &event A_UNUSED) override
64
        {
65
        }
66
67
        /**
68
         * Handles mouse when pressed.
69
         */
70
        void mousePressed(MouseEvent &event A_UNUSED) override
71
        {
72
        }
73
74
        /**
75
         * Handles mouse release.
76
         */
77
        void mouseReleased(MouseEvent &event A_UNUSED) override
78
        {
79
        }
80
81
        int getMaxItems() const noexcept2 A_WARN_UNUSED
82
1
        { return mMaxItems; }
83
84
        int getBoxWidth() const noexcept2 A_WARN_UNUSED
85
1
        { return mBoxWidth; }
86
87
        int getBoxHeight() const noexcept2 A_WARN_UNUSED
88
1
        { return mBoxHeight; }
89
90
        void drawBackground(Graphics *const g) A_NONNULL(2);
91
92
        void safeDrawBackground(Graphics *const g) A_NONNULL(2);
93
94
        virtual void setSkin(const Widget2 *const widget,
95
                             Skin *const skin);
96
97
    protected:
98
        /**
99
         * Constructor. Initializes the shortcut container.
100
         */
101
        explicit ShortcutContainer(Widget2 *const widget);
102
103
        /**
104
         * Gets the index from the grid provided the point is in an item box.
105
         *
106
         * @param pointX X coordinate of the point.
107
         * @param pointY Y coordinate of the point.
108
         * @return index on success, -1 on failure.
109
         */
110
        int getIndexFromGrid(const int pointX,
111
                             const int pointY) const A_WARN_UNUSED;
112
113
        Image *mBackgroundImg;
114
        Skin *mSkin;
115
        static float mAlpha;
116
117
        unsigned mMaxItems;
118
        int mBoxWidth;
119
        int mBoxHeight;
120
        int mGridWidth;
121
        int mGridHeight;
122
        int mImageOffsetX;
123
        int mImageOffsetY;
124
        int mTextOffsetX;
125
        int mTextOffsetY;
126
        ImageCollection *mVertexes;
127
};
128
129
#endif  // GUI_WIDGETS_SHORTCUTCONTAINER_H