GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/inttextfield.h Lines: 1 1 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_INTTEXTFIELD_H
24
#define GUI_WIDGETS_INTTEXTFIELD_H
25
26
#include "enums/simpletypes/enable.h"
27
28
#include "gui/widgets/textfield.h"
29
30
/**
31
 * TextBox which only accepts numbers as input.
32
 */
33
68
class IntTextField final : public TextField
34
{
35
    public:
36
        /**
37
         * Constructor, sets default value.
38
         */
39
        explicit IntTextField(const Widget2 *const widget,
40
                              const int def = 0,
41
                              const int min = 0,
42
                              const int max = 0,
43
                              const Enable enabled = Enable_true,
44
                              const int width = 0);
45
46
        A_DELETE_COPY(IntTextField)
47
48
        /**
49
         * Sets the minimum and maximum values of the text box.
50
         */
51
        void setRange(const int minimum, const int maximum);
52
53
        /**
54
         * Returns the value in the text box.
55
         */
56
        int getValue() const A_WARN_UNUSED;
57
58
        /**
59
         * Reset the field to the default value.
60
         */
61
        void reset();
62
63
        /**
64
         * Set the value of the text box to the specified value.
65
         */
66
        void setValue(const int value);
67
68
        /**
69
         * Set the default value of the text box to the specified value.
70
         */
71
        void setDefaultValue(const int value);
72
73
        /**
74
         * Responds to key presses.
75
         */
76
        void keyPressed(KeyEvent &event) override final;
77
78
    private:
79
        int mMin;            /**< Minimum value */
80
        int mMax;            /**< Maximum value */
81
        int mDefault;        /**< Default value */
82
        int mValue;          /**< Current value */
83
};
84
85
#endif  // GUI_WIDGETS_INTTEXTFIELD_H