Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[0a1223]: libgui / OverViewWidget.cpp Maximize Restore History

Download this file

OverViewWidget.cpp    241 lines (225 with data), 6.4 kB

  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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#include "config.h"
#include <qpainter.h>
#include <qslider.h> // for it's sizeHint()
#include "OverViewWidget.h"
OverViewWidget::OverViewWidget(QWidget *parent, const char *name)
:QWidget(parent, name)
{
// dir = 0;
//// mparent = 0;
// grabbed = false;
// height = 0;
// this->parent = parent;
// pixmap = 0;
// redraw = false;
// slider_length = 0;
// slider_pos = 0;
// slider_width = 0;
// timer = 0;
// width = 0;
}
////*****************************************************************************
//OverViewWidget::OverViewWidget(MainWidget *parent, const char *name)
// :QWidget(parent, name)
//{
// dir = 0;
// mparent = parent;
// grabbed = false;
// height = 0;
// this->parent = parent;
// pixmap = 0;
// redraw = false;
// slider_length = 0;
// slider_pos = 0;
// slider_width = 0;
// timer = 0;
// width = 0;
//}
//*****************************************************************************
OverViewWidget::~OverViewWidget()
{
// if (pixmap) delete pixmap;
// if (timer) {
// timer->stop();
// delete timer;
// }
}
//*****************************************************************************
void OverViewWidget::mousePressEvent( QMouseEvent *e)
{
// ASSERT(e);
// if (!e) return;
//
// int x1 = (slider_length) ?
// (int)(((double)slider_pos) * width / slider_length) :
// 0;
// int x2 = (slider_length) ?
// (int)(((double)slider_width) * width / slider_length) :
// 0;
//
// if (x2 < 8) x2 = 8;
// if (e->x() > x1 + x2) {
// dir = slider_width / 2;
// if (timer) {
// timer->stop();
// delete timer;
// }
// timer = new QTimer (this);
// ASSERT(timer);
// if (!timer) return;
//
// connect (timer, SIGNAL(timeout()), this, SLOT(increase()));
// timer->start( 50);
// } else
// if (e->x() < x1) {
// dir = -slider_width / 2;
// timer = new QTimer (this);
// connect (timer, SIGNAL(timeout()), this, SLOT(increase()));
// timer->start( 50);
// } else grabbed = e->x() - x1;
}
//****************************************************************************
void OverViewWidget::increase()
{
// slider_pos += dir;
// if (slider_pos < 0) slider_pos = 0;
// if (slider_pos > slider_length - slider_width)
// slider_pos = slider_length - slider_width;
// repaint (false);
// emit valueChanged (slider_pos);
}
//****************************************************************************
void OverViewWidget::mouseReleaseEvent( QMouseEvent *)
{
// grabbed = false;
// if (timer) {
// timer->stop();
// delete timer;
// timer = 0;
// }
}
//****************************************************************************
void OverViewWidget::mouseMoveEvent( QMouseEvent *e)
{
// ASSERT(e);
// ASSERT(width);
// if (!e) return;
// if (!width) return;
//
// if (grabbed) {
// int pos = e->x() - grabbed;
// if (pos < 0) pos = 0;
// if (pos > width) pos = width;
// slider_pos = (int)(((double) slider_length) * pos / width);
// if (slider_pos > slider_length - slider_width)
// slider_pos = slider_length - slider_width;
// repaint (false);
// emit valueChanged (slider_pos);
// }
}
//*****************************************************************************
void OverViewWidget::refresh()
{
// redraw = true;
// repaint (false);
}
//*****************************************************************************
void OverViewWidget::setRange(int new_pos, int new_width, int new_length)
{
// if ( (new_pos != slider_pos) ||
// (slider_length != new_length) ||
// (slider_width != new_width) ) {
// if ( (slider_length == new_length) && (slider_width == new_width) ) {
// slider_pos = new_pos;
// repaint(false);
// } else {
// slider_pos = new_pos;
// slider_width = new_width;
// slider_length = new_length;
// refresh();
// }
// }
}
//*****************************************************************************
void OverViewWidget::setValue(int newval)
{
// if (slider_pos != newval) {
// slider_pos = newval;
// repaint (false);
// }
}
//*****************************************************************************
void OverViewWidget::paintEvent (QPaintEvent *)
{
// QPainter p;
// ///if pixmap has to be resized ...
// if ((rect().height() != height) || (rect().width() != width) || redraw) {
// redraw = false;
// height = rect().height();
// width = rect().width();
//
// if (pixmap) delete pixmap;
// pixmap = new QPixmap (size());
// ASSERT(pixmap);
// if (!pixmap) return;
//
// pixmap->fill (colorGroup().background());
//
// p.begin (pixmap);
// p.setPen (colorGroup().midlight());
//
//// if (mparent) {
//// unsigned char *overview = mparent->getOverView(width);
//// if (overview) {
//// for (int i = 0; i < width; i++)
//// p.drawLine(i, height - (((int)overview[i])*height) / 128,
//// i, height);
//// delete overview;
//// }
//// }
//
// p.end ();
// }
// if (pixmap) bitBlt (this, 0, 0, pixmap);
//
// p.begin (this);
//
// int x1 = (slider_length) ?
// (int)(((double)slider_pos) * width / slider_length) :
// 0;
// int x2 = (slider_length) ?
// (int)(((double)slider_width) * width / slider_length) :
// 0;
// if (x2 < 8) x2 = 8; //so there is at least something
//
// p.setPen (colorGroup().light());
// p.drawLine (0, 0, width, 0);
// p.drawLine (0, 0, 0, height);
//
// p.drawLine (x1, 0, x1 + x2, 0);
// p.drawLine (x1, 0, x1, height);
// p.drawLine (x1 + 1, 0, x1 + 1, height);
// p.setBrush (colorGroup().background());
// p.drawRect (x1, 0, x2, height);
// p.setPen (colorGroup().dark());
// p.drawLine (1, height - 1, width, height - 1);
// p.drawLine (width - 1, 1, width - 1, height - 1);
//
// p.drawLine (x1 + 1, height - 2, x1 + x2, height - 2);
// p.drawLine (x1 + x2, 1, x1 + x2, height);
// p.drawLine (x1 + x2 - 1, 1, x1 + x2 - 1, height);
//
// p.end ();
}
//*****************************************************************************
const QSize OverViewWidget::minimumSize()
{
return QSize(30, 30);
}
//*****************************************************************************
const QSize OverViewWidget::sizeHint()
{
return minimumSize();
}
//*****************************************************************************
//*****************************************************************************