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

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2004-2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2017  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_SHOPLISTBOX_H
24
#define GUI_WIDGETS_SHOPLISTBOX_H
25
26
#include "gui/widgets/listbox.h"
27
28
#include "enums/gui/shoplistboxtype.h"
29
30
class ShopItems;
31
32
/**
33
 * A list box, meant to be used inside a scroll area. Same as the Guichan list
34
 * box except this one doesn't have a background, instead completely relying
35
 * on the scroll area. It also adds selection listener functionality.
36
 *
37
 * \ingroup GUI
38
 */
39
20
class ShopListBox final : public ListBox
40
{
41
    public:
42
        /**
43
         * Constructor.
44
         */
45
        ShopListBox(const Widget2 *const widget,
46
                    ListModel *const listModel,
47
                    const ShopListBoxTypeT type);
48
49
        /**
50
         * Constructor with shopitems
51
         */
52
        ShopListBox(const Widget2 *const widget,
53
                    ListModel *const listModel,
54
                    ShopItems *const shopListModel,
55
                    const ShopListBoxTypeT type);
56
57
        A_DELETE_COPY(ShopListBox)
58
59
        /**
60
         * Draws the list box.
61
         */
62
        void draw(Graphics *const graphics) override final A_NONNULL(2);
63
64
        void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
65
66
        /**
67
         * gives information about the current player's money
68
         */
69
        void setPlayersMoney(const int money);
70
71
        /**
72
         * Adjust List draw size
73
         */
74
        void adjustSize() override final;
75
76
        /**
77
         * Set on/off the disabling of too expensive items.
78
         * (Good for selling mode.)
79
         */
80
        void setPriceCheck(const bool check);
81
82
        void mouseMoved(MouseEvent &event) override final;
83
84
        void mouseReleased(MouseEvent& event) override final;
85
86
        void mouseExited(MouseEvent& event) override final;
87
88
        void setProtectItems(bool p)
89
8
        { mProtectItems = p; }
90
91
        void setType(const ShopListBoxTypeT type)
92
        { mType = type; }
93
94
        ShopListBoxTypeT getType() const
95
        { return mType; }
96
97
    private:
98
        int mPlayerMoney;
99
100
        /**
101
         * Keeps another pointer to the same listModel, permitting to
102
         * use the ShopItems specific functions.
103
         */
104
        ShopItems *mShopItems;
105
106
        Color mWarningColor;
107
        ShopListBoxTypeT mType;
108
109
        bool mPriceCheck;
110
        bool mProtectItems;
111
};
112
113
#endif  // GUI_WIDGETS_SHOPLISTBOX_H