1 /*
2  * Copyright (C) 2009 Matthew Gates
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
17  */
18 
19 #ifndef TUINODEINT_HPP
20 #define TUINODEINT_HPP
21 
22 #include "TuiNodeEditable.hpp"
23 #include <QObject>
24 
25 //! @class TuiNodeInt
26 //! Allows navigation but also editing of an integer value.
27 class TuiNodeInt : public TuiNodeEditable
28 {
29 	Q_OBJECT
30 
31 public:
32 	//! Create a TuiNodeInt node.
33 	//! @param text the text to be displayed for this node
34 	//! @param receiver a QObject which will receive a signal when the value
35 	//! is changed
36 	//! @param method the method in the receiver which will be called when
37 	//! the value is changed.  Note that this should be passed using the
38 	//! SLOT() macro.
39 	//! @param defValue the default value for the node
40 	//! @param min the minimum acceptable value for the node
41 	//! @param max the maximum acceptable value for the node
42 	//! @param inc the increment which will be added and subtracted
43 	//! from the current value when the up and down cursors are used
44 	//! @param parent the node for the parent menu item
45 	//! @param prev the previous node in the current menu (typically
46 	//! shares the same parent)
47 	TuiNodeInt(const QString& text, QObject* receiver, const char* method, int defValue,
48 		   int min, int max, int inc, TuiNode* parent=Q_NULLPTR, TuiNode* prev=Q_NULLPTR);
49 	virtual TuiNodeResponse handleEditingKey(int key) Q_DECL_OVERRIDE;
50 	virtual QString getDisplayText() const Q_DECL_OVERRIDE;
51 
52 signals:
53 	void setValue(int b);
54 
55 private:
56 	int value;
57 	int minimum;
58 	int maximum;
59 	int increment;
60 	bool typing;
61 };
62 
63 #endif /*TUINODEINT_HPP*/
64 
65