-
Notifications
You must be signed in to change notification settings - Fork 1
/
Activity_Indicator.hh
203 lines (156 loc) · 4.57 KB
/
Activity_Indicator.hh
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/* Activity_Indicator
HiROC CVS ID: $Id: Activity_Indicator.hh,v 1.6 2011/11/27 00:06:03 castalia Exp $
Copyright (C) 2010-2011 Arizona Board of Regents on behalf of the
Planetary Image Research Laboratory, Lunar and Planetary Laboratory at
the University of Arizona.
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License, version 2.1,
as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*******************************************************************************/
#ifndef HiView_Activity_Indicator_hh
#define HiView_Activity_Indicator_hh
#include <QWidget>
#include <QMutex>
// Forward references.
class QSize;
class QColor;
class QPixmap;
class QTimer;
class QPaintEvent;
class QMouseEvent;
namespace UA
{
namespace HiRISE
{
class Activity_Indicator
: public QWidget
{
// Qt Object declaration.
Q_OBJECT
public:
/*==============================================================================
Constants
*/
//! Class identification name with source code version and date.
static const char* const
ID;
//! State conditions.
enum
{
STATE_OFF,
STATE_1,
STATE_2,
TOTAL_STATE_CONDITIONS
};
/*==============================================================================
Constructors
*/
explicit Activity_Indicator (int size = 0, QWidget* parent = NULL);
explicit Activity_Indicator (QWidget* parent);
~Activity_Indicator ();
/*==============================================================================
Accessors
*/
static void default_indicator_size (int size);
static int default_indicator_size ()
{return Default_Indicator_Size;}
Activity_Indicator& indicator_size (int size);
inline int indicator_size () const
{return Indicator_Size;}
inline QSize button_size () const
{return QSize (Indicator_Size >> 1, Indicator_Size >> 1);}
virtual QSize sizeHint () const;
static void default_start_delay (int delay);
static int default_start_delay ()
{return Default_Start_Delay;}
Activity_Indicator& start_delay (int delay);
inline int start_delay () const
{return Start_Delay;}
static void default_update_interval (int interval);
static int default_update_interval ()
{return Default_Update_Interval;}
Activity_Indicator& update_interval (int interval);
inline int update_interval () const
{return Update_Interval;}
static void default_interval_degrees (int degrees);
static int default_interval_degrees ()
{return Default_Interval_Degrees;}
Activity_Indicator& interval_degrees (int degrees);
inline int interval_degrees () const
{return Interval_Degrees;}
static void default_state_color (int condition, QColor color);
static QColor default_state_color (int condition);
Activity_Indicator& state_color (int condition, QColor color);
QColor state_color (int condition) const;
inline int state () const
{return State;}
/*==============================================================================
Qt signals
*/
signals:
void state_changed
(int old_condition, int new_condition);
void button_clicked (int condition);
/*==============================================================================
Qt slots
*/
public slots:
void state (int condition);
void cancel ();
private slots:
void interval ();
/*==============================================================================
Event Handlers
*/
protected:
virtual void paintEvent (QPaintEvent* event);
virtual void mousePressEvent (QMouseEvent* event);
virtual void mouseReleaseEvent (QMouseEvent* event);
/*==============================================================================
Helpers
*/
protected:
QPixmap* indicator ();
void set_indicator_state
(QPixmap* pixmap, int condition, bool pressed = false);
private:
void initialize ();
/*==============================================================================
Data Members
*/
private:
static int
Default_Indicator_Size,
Default_Start_Delay,
Default_Update_Interval,
Default_Interval_Degrees;
int
Indicator_Size,
Start_Delay,
Update_Interval,
Interval_Degrees;
static QColor
Default_State_Color[];
QColor
*State_Color;
QPixmap
*Indicator;
QTimer
*Update_Timer;
int
State;
int
Progress;
QMutex
State_Lock;
};
} // namespace HiRISE
} // namespace UA
#endif