summaryrefslogtreecommitdiffstats
path: root/kstars/kstars/timeunitbox.h
blob: d93ec215c613d3cb561da5dacfe8b334d01865d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/***************************************************************************
                          timeunitbox.h  -  description
                             -------------------
    begin                : Sat Apr 27 2002
    copyright            : (C) 2002 by Jason Harris
    email                : kstars@30doradus.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef TIMEUNITBOX_H
#define TIMEUNITBOX_H

#include <tqvbox.h>
#include <tqwidget.h>

#define ALLUNITS 8
#define DAYUNITS 5

/**@class TimeUnitBox 
	*A pair of buttons, arranged one above the other, labeled "+"/"-".  These buttons 
	*are to be paired with the TimeSpinBox widget.  Their function is to provide 
	*a way to cycle through the possible time steps using larger intervals than the up/down
	*buttons of the TimeSpinBox.  For example, say the Spinbox currently shows a timestep of 
	*"1 sec".  Increasing the timestep with the spinbox up-button will change it to
	*"2 sec", while using the "+" button of this widget will change it to "1 min".
	*
	*The idea is that these "outer" buttons always change to the next even unit of time.
	*
	*@note this widget is not to be used on its own; it is combined with the TimeSpinBox 
	*widget to form the TimeStepBox composite widget. 
	*@short provides a second set of up/down buttons for TimeStepBox.
	*@author Jason Harris
	*@version 1.0
	*/

class TQPushButton;

class TimeUnitBox : public TQVBox {
   Q_OBJECT
  
public:
	/**Constructor*/
	TimeUnitBox(TQWidget *parent=0, const char *name=0, bool daysonly = false);
	/**Destructor (empty)*/
	~TimeUnitBox();
	/**@return the value of UnitStep for the current spinbox value() */
	int unitValue();

	/**@short the same as unitValue, except you can get the UnitStep for any value, not just the current one.
		*@return the value of UnitStep for the index value given as an argument.
		*/
	int getUnitValue( int );

	/**Set the value which describes which time-unit is displayed in the TimeSpinBox.
		*@p value the new value
		*/
	void setValue( int value ) { Value = value; }
	/**@return the internal value describing the time-unit of the TimeSpinBox.
		*/
	int value() const { return Value; }

	/**Set the minimum value for the internal time-unit value
		*/
	void setMinValue( int minValue ) { MinimumValue = minValue; }
	/**Set the maximum value for the internal time-unit value
		*/
	void setMaxValue( int maxValue ) { MaximumValue = maxValue; }

	/**@return the minimum value for the internal time-unit value
		*/
	int minValue() const { return MinimumValue; }
	/**@return the maximum value for the internal time-unit value
		*/
	int maxValue() const { return MaximumValue; }

	bool daysOnly() const { return DaysOnly; }
	void setDaysOnly( bool daysonly );

signals:
	void valueChanged(int);

private slots:
	/**Increment the internal time-unit value
		*/
	void increase();
	/**Decrement the internal time-unit value
		*/
	void decrease();

private:
	bool DaysOnly;
	TQPushButton *UpButton, *DownButton;
	int MinimumValue, MaximumValue, Value, UnitStep[ ALLUNITS ];
};

#endif