File: qwt__dial_8cpp-source.html

package info (click to toggle)
libqwt 4.2.0-4.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 9,832 kB
  • ctags: 5,512
  • sloc: cpp: 22,973; ansic: 244; makefile: 66
file content (805 lines) | stat: -rw-r--r-- 49,185 bytes parent folder | download | duplicates (5)
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Qwt User&apos;s Guide: qwt_dial.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.8 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<h1>qwt_dial.cpp</h1><pre class="fragment"><div>00001 <span class="comment">/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************</span>
00002 <span class="comment"> * Qwt Widget Library</span>
00003 <span class="comment"> * Copyright (C) 1997   Josef Wilgen</span>
00004 <span class="comment"> * Copyright (C) 2002   Uwe Rathmann</span>
00005 <span class="comment"> *</span>
00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span>
00008 <span class="comment"> *****************************************************************************/</span>
00009 
00010 <span class="preprocessor">#include &lt;math.h&gt;</span>
00011 <span class="preprocessor">#include &lt;qpainter.h&gt;</span>
00012 <span class="preprocessor">#include &lt;qpixmap.h&gt;</span>
00013 <span class="preprocessor">#include &lt;qevent.h&gt;</span>
00014 <span class="preprocessor">#include "<a class="code" href="qwt__math_8h.html">qwt_math.h</a>"</span>
00015 <span class="preprocessor">#include "qwt_paint_buffer.h"</span>
00016 <span class="preprocessor">#include "qwt_painter.h"</span>
00017 <span class="preprocessor">#include "qwt_dial_needle.h"</span>
00018 <span class="preprocessor">#include "qwt_dial.h"</span>
00019 
00020 <span class="keywordtype">double</span> QwtDial::d_previousDir = -1.0;
00021 
<a name="l00027"></a><a class="code" href="class_qwt_dial_scale_draw.html#a0">00027</a> <a class="code" href="class_qwt_dial_scale_draw.html#a0">QwtDialScaleDraw::QwtDialScaleDraw</a>(<a class="code" href="class_qwt_dial.html">QwtDial</a> *parent):
00028     d_parent(parent),
00029     d_penWidth(1),
00030     d_visibleLabels(TRUE)
00031 {
00032 }
00033 
<a name="l00043"></a><a class="code" href="class_qwt_dial_scale_draw.html#a2">00043</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial_scale_draw.html#a2">QwtDialScaleDraw::showLabels</a>(<span class="keywordtype">bool</span> enable)
00044 {
00045     d_visibleLabels = enable;
00046 }
00047 
<a name="l00052"></a><a class="code" href="class_qwt_dial_scale_draw.html#a3">00052</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_dial_scale_draw.html#a3">QwtDialScaleDraw::visibleLabels</a>()<span class="keyword"> const</span>
00053 <span class="keyword"></span>{
00054     <span class="keywordflow">return</span> d_visibleLabels;
00055 }
00056 
<a name="l00064"></a><a class="code" href="class_qwt_dial_scale_draw.html#a4">00064</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial_scale_draw.html#a4">QwtDialScaleDraw::setPenWidth</a>(uint penWidth)
00065 {
00066     d_penWidth = penWidth;
00067 }
00068 
<a name="l00073"></a><a class="code" href="class_qwt_dial_scale_draw.html#a5">00073</a> uint <a class="code" href="class_qwt_dial_scale_draw.html#a5">QwtDialScaleDraw::penWidth</a>()<span class="keyword"> const</span>
00074 <span class="keyword"></span>{
00075     <span class="keywordflow">return</span> d_penWidth;
00076 }
00077 
<a name="l00085"></a><a class="code" href="class_qwt_dial_scale_draw.html#a1">00085</a> QString <a class="code" href="class_qwt_dial_scale_draw.html#a1">QwtDialScaleDraw::label</a>(<span class="keywordtype">double</span> value)<span class="keyword"> const</span>
00086 <span class="keyword"></span>{
00087     <span class="keywordflow">if</span> ( !d_visibleLabels )
00088         <span class="keywordflow">return</span> QString::null;
00089 
00090     <span class="keywordflow">if</span> ( d_parent == NULL )
00091         <span class="keywordflow">return</span> <a class="code" href="class_qwt_scale_draw.html#a30">QwtScaleDraw::label</a>(value);
00092 
00093     <span class="keywordflow">return</span> d_parent-&gt;<a class="code" href="class_qwt_dial.html#b9">scaleLabel</a>(value);
00094 }
00095 
<a name="l00107"></a><a class="code" href="class_qwt_dial.html#a0">00107</a> <a class="code" href="class_qwt_dial.html#a0">QwtDial::QwtDial</a>(QWidget* parent, <span class="keyword">const</span> <span class="keywordtype">char</span>* name):
00108         <a class="code" href="class_qwt_slider_base.html">QwtSliderBase</a>(Qt::Horizontal, parent, name, 
00109             Qt::WRepaintNoErase|Qt::WResizeNoErase),
00110     d_visibleBackground(FALSE),
00111     d_frameShadow(Sunken),
00112     d_lineWidth(0),
00113     d_mode(RotateNeedle),
00114     d_origin(90.0),
00115     d_minScaleArc(0.0),
00116     d_maxScaleArc(0.0),
00117     d_scaleDraw(0),
00118     d_maxMajIntv(36),
00119     d_maxMinIntv(10),
00120     d_scaleStep(0.0),
00121     d_needle(0)
00122 {
00123     setBackgroundMode(NoBackground);
00124     setFocusPolicy(QWidget::TabFocus);
00125 
00126     QPalette p = palette();
00127     <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i &lt; QPalette::NColorGroups; i++ )
00128     {
00129         <span class="keyword">const</span> QPalette::ColorGroup cg = (QPalette::ColorGroup)i;
00130 
00131         <span class="comment">// Base: background color of the circle inside the frame.</span>
00132         <span class="comment">// Foreground: background color of the circle inside the scale</span>
00133 
00134         p.setColor(cg, QColorGroup::Foreground, 
00135             p.color(cg, QColorGroup::Base));
00136     }
00137     setPalette(p);
00138 
00139     d_scaleDraw = <span class="keyword">new</span> <a class="code" href="class_qwt_dial_scale_draw.html">QwtDialScaleDraw</a>(<span class="keyword">this</span>);
00140     d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a6">setGeometry</a>(0, 0, 0, QwtScaleDraw::Round);
00141 
00142     <a class="code" href="class_qwt_dial.html#a13">setScaleArc</a>(0.0, 360.0); <span class="comment">// scale as a full circle</span>
00143     <a class="code" href="class_qwt_dbl_range.html#a2">setRange</a>(0.0, 360.0, 1.0, 10); <span class="comment">// degrees as deafult</span>
00144 }
00145 
<a name="l00147"></a><a class="code" href="class_qwt_dial.html#a1">00147</a> <a class="code" href="class_qwt_dial.html#a1">QwtDial::~QwtDial</a>() 
00148 {
00149     <span class="keyword">delete</span> d_scaleDraw;
00150     <span class="keyword">delete</span> d_needle;
00151 }
00152 
<a name="l00161"></a><a class="code" href="class_qwt_dial.html#a5">00161</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#a5">QwtDial::showBackground</a>(<span class="keywordtype">bool</span> show)
00162 {
00163     <span class="keywordflow">if</span> ( d_visibleBackground != show )
00164     {
00165         d_visibleBackground = show;
00166 
00167         <span class="keywordflow">if</span> ( d_visibleBackground )
00168             clearMask();
00169         <span class="keywordflow">else</span>
00170             setMask(QRegion(<a class="code" href="class_qwt_dial.html#a23">boundingRect</a>(), QRegion::Ellipse));
00171 
00172         update();
00173     }
00174 }
00175 
<a name="l00181"></a><a class="code" href="class_qwt_dial.html#a4">00181</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_dial.html#a4">QwtDial::hasVisibleBackground</a>()<span class="keyword"> const </span>
00182 <span class="keyword"></span>{ 
00183     <span class="keywordflow">return</span> d_visibleBackground; 
00184 }
00185 
<a name="l00191"></a><a class="code" href="class_qwt_dial.html#a2">00191</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#a2">QwtDial::setFrameShadow</a>(Shadow shadow)
00192 {
00193     <span class="keywordflow">if</span> ( shadow != d_frameShadow )
00194     {
00195         d_frameShadow = shadow;
00196         <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_dial.html#a7">lineWidth</a>() &gt; 0 )
00197             update();
00198     }
00199 }
00200 
<a name="l00206"></a><a class="code" href="class_qwt_dial.html#a3">00206</a> <a class="code" href="class_qwt_dial.html#w8">QwtDial::Shadow</a> <a class="code" href="class_qwt_dial.html#a3">QwtDial::frameShadow</a>()<span class="keyword"> const </span>
00207 <span class="keyword"></span>{ 
00208     <span class="keywordflow">return</span> d_frameShadow; 
00209 }
00210 
<a name="l00217"></a><a class="code" href="class_qwt_dial.html#a6">00217</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#a6">QwtDial::setLineWidth</a>(<span class="keywordtype">int</span> lineWidth)
00218 {
00219     <span class="keywordflow">if</span> ( lineWidth &lt; 0 )
00220         lineWidth = 0;
00221 
00222     <span class="keywordflow">if</span> ( d_lineWidth != lineWidth )
00223     {
00224         d_lineWidth = lineWidth;
00225         update();
00226     }
00227 }
00228 
<a name="l00234"></a><a class="code" href="class_qwt_dial.html#a7">00234</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_dial.html#a7">QwtDial::lineWidth</a>()<span class="keyword"> const </span>
00235 <span class="keyword"></span>{ 
00236     <span class="keywordflow">return</span> d_lineWidth; 
00237 }
00238 
<a name="l00243"></a><a class="code" href="class_qwt_dial.html#a24">00243</a> QRect <a class="code" href="class_qwt_dial.html#a24">QwtDial::contentsRect</a>()<span class="keyword"> const</span>
00244 <span class="keyword"></span>{
00245     <span class="keyword">const</span> <span class="keywordtype">int</span> lw = <a class="code" href="class_qwt_dial.html#a7">lineWidth</a>();
00246 
00247     QRect r = <a class="code" href="class_qwt_dial.html#a23">boundingRect</a>();
00248     <span class="keywordflow">if</span> ( lw &gt; 0 )
00249     {
00250         r.setRect(r.x() + lw, r.y() + lw, 
00251             r.width() - 2 * lw, r.height() - 2 * lw);
00252     }
00253     <span class="keywordflow">return</span> r;
00254 }
00255 
<a name="l00260"></a><a class="code" href="class_qwt_dial.html#a23">00260</a> QRect <a class="code" href="class_qwt_dial.html#a23">QwtDial::boundingRect</a>()<span class="keyword"> const</span>
00261 <span class="keyword"></span>{
00262     <span class="keyword">const</span> <span class="keywordtype">int</span> radius = QMIN(width(), height()) / 2;
00263 
00264     QRect r(0, 0, 2 * radius, 2 * radius);
00265     r.moveCenter(rect().center());
00266     <span class="keywordflow">return</span> r;
00267 }
00268 
<a name="l00273"></a><a class="code" href="class_qwt_dial.html#a25">00273</a> QRect <a class="code" href="class_qwt_dial.html#a25">QwtDial::scaleContentsRect</a>()<span class="keyword"> const</span>
00274 <span class="keyword"></span>{
00275     <span class="keyword">const</span> QPen scalePen(colorGroup().text(), 0, Qt::NoPen);
00276 
00277     <span class="keywordtype">int</span> scaleDist = 0;
00278     <span class="keywordflow">if</span> ( d_scaleDraw )
00279     {
00280         scaleDist = QMAX(
00281             d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a18">maxWidth</a>(scalePen, fontMetrics()),
00282             d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a19">maxHeight</a>(scalePen, fontMetrics()));
00283         scaleDist++; <span class="comment">// margin</span>
00284     }
00285 
00286     <span class="keyword">const</span> QRect rect = <a class="code" href="class_qwt_dial.html#a24">contentsRect</a>();
00287     <span class="keywordflow">return</span> QRect(rect.x() + scaleDist, rect.y() + scaleDist,
00288         rect.width() - 2 * scaleDist, rect.height() - 2 * scaleDist);
00289 }
00290 
<a name="l00306"></a><a class="code" href="class_qwt_dial.html#a8">00306</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#a8">QwtDial::setMode</a>(Mode mode)
00307 {   
00308     <span class="keywordflow">if</span> ( mode != d_mode )
00309     {
00310         d_mode = mode;
00311         update(); 
00312     }
00313 }       
00314 
<a name="l00329"></a><a class="code" href="class_qwt_dial.html#a9">00329</a> <a class="code" href="class_qwt_dial.html#w10">QwtDial::Mode</a> <a class="code" href="class_qwt_dial.html#a9">QwtDial::mode</a>()<span class="keyword"> const</span>
00330 <span class="keyword"></span>{
00331     <span class="keywordflow">return</span> d_mode;
00332 }
00333 
<a name="l00344"></a><a class="code" href="class_qwt_dial.html#a10">00344</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#a10">QwtDial::setWrapping</a>(<span class="keywordtype">bool</span> wrapping)
00345 {
00346     <a class="code" href="class_qwt_dbl_range.html#a7">setPeriodic</a>(wrapping);
00347 } 
00348 
<a name="l00357"></a><a class="code" href="class_qwt_dial.html#a11">00357</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_dial.html#a11">QwtDial::wrapping</a>()<span class="keyword"> const</span>
00358 <span class="keyword"></span>{
00359     <span class="keywordflow">return</span> <a class="code" href="class_qwt_dbl_range.html#a8">periodic</a>();
00360 }
00361 
<a name="l00363"></a><a class="code" href="class_qwt_dial.html#b1">00363</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b1">QwtDial::resizeEvent</a>(QResizeEvent *e)
00364 {
00365     QWidget::resizeEvent(e);
00366 
00367     <span class="keywordflow">if</span> ( !<a class="code" href="class_qwt_dial.html#a4">hasVisibleBackground</a>() )
00368         setMask(QRegion(<a class="code" href="class_qwt_dial.html#a23">boundingRect</a>(), QRegion::Ellipse));
00369 }
00370 
<a name="l00372"></a><a class="code" href="class_qwt_dial.html#b0">00372</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b0">QwtDial::paintEvent</a>(QPaintEvent *e)
00373 {
00374     <span class="keyword">const</span> QRect &amp;ur = e-&gt;rect();
00375     <span class="keywordflow">if</span> ( ur.isValid() )
00376     {
00377         <a class="code" href="class_qwt_paint_buffer.html">QwtPaintBuffer</a> paintBuffer(<span class="keyword">this</span>, ur);
00378 
00379         QPainter *painter = paintBuffer.<a class="code" href="class_qwt_paint_buffer.html#a5">painter</a>();
00380 
00381         <a class="code" href="class_qwt_dial.html#b4">drawContents</a>(painter);
00382         <a class="code" href="class_qwt_dial.html#b3">drawFrame</a>(painter);
00383 
00384         <span class="keywordflow">if</span> ( hasFocus() )
00385             <a class="code" href="class_qwt_dial.html#b5">drawFocusIndicator</a>(painter);
00386     }
00387 }
00388 
<a name="l00394"></a><a class="code" href="class_qwt_dial.html#b5">00394</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b5">QwtDial::drawFocusIndicator</a>(QPainter *painter)<span class="keyword"> const</span>
00395 <span class="keyword"></span>{
00396     <span class="keywordflow">if</span> ( !<a class="code" href="class_qwt_slider_base.html#a9">isReadOnly</a>() )
00397     {
00398         QRect focusRect = <a class="code" href="class_qwt_dial.html#a24">contentsRect</a>();
00399 
00400         <span class="keyword">const</span> <span class="keywordtype">int</span> margin = 2;
00401         focusRect.setRect( 
00402             focusRect.x() + margin,
00403             focusRect.y() + margin,
00404             focusRect.width() - 2 * margin,
00405             focusRect.height() - 2 * margin);
00406 
00407         QColor color = colorGroup().color(QColorGroup::Base);
00408         <span class="keywordflow">if</span> (color.isValid())
00409         {
00410             <span class="keywordtype">int</span> h, s, v;
00411             color.hsv(&amp;h, &amp;s, &amp;v);
00412             color = (v &gt; 128) ? Qt::gray.dark(120) : Qt::gray.light(120);
00413         }
00414         <span class="keywordflow">else</span>
00415             color = Qt::darkGray;
00416 
00417         painter-&gt;save();
00418         painter-&gt;setBrush(Qt::NoBrush);
00419         painter-&gt;setPen(QPen(color, 0, Qt::DotLine));
00420         painter-&gt;drawEllipse(focusRect);
00421         painter-&gt;restore();
00422     }
00423 }
00424 
<a name="l00431"></a><a class="code" href="class_qwt_dial.html#b3">00431</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b3">QwtDial::drawFrame</a>(QPainter *painter)
00432 {
00433     <span class="keyword">const</span> <span class="keywordtype">int</span> lw = <a class="code" href="class_qwt_dial.html#a7">lineWidth</a>();
00434     <span class="keyword">const</span> <span class="keywordtype">int</span> off = (lw + 1) % 2;
00435 
00436     QRect r = <a class="code" href="class_qwt_dial.html#a23">boundingRect</a>();
00437     r.setRect(r.x() + lw / 2 - off, r.y() + lw / 2 - off,
00438         r.width() - lw + off + 1, r.height() - lw + off + 1);
00439 
00440     <span class="keywordflow">if</span> ( lw &gt; 0 )
00441     {
00442         <span class="keywordflow">switch</span>(d_frameShadow)
00443         {
00444             <span class="keywordflow">case</span> QwtDial::Raised:
00445                 <a class="code" href="class_qwt_painter.html#e21">QwtPainter::drawRoundFrame</a>(painter, r, 
00446                     lw, colorGroup(), FALSE);
00447                 <span class="keywordflow">break</span>;
00448             <span class="keywordflow">case</span> QwtDial::Sunken:
00449                 <a class="code" href="class_qwt_painter.html#e21">QwtPainter::drawRoundFrame</a>(painter, r, 
00450                     lw, colorGroup(), TRUE);
00451                 <span class="keywordflow">break</span>;
00452             <span class="keywordflow">default</span>: <span class="comment">// Plain</span>
00453             {
00454                 painter-&gt;save();
00455                 painter-&gt;setPen(QPen(Qt::black, lw));
00456                 painter-&gt;setBrush(Qt::NoBrush);
00457                 painter-&gt;drawEllipse(r);
00458                 painter-&gt;restore();
00459             }
00460         }
00461     }
00462 }
00463 
<a name="l00475"></a><a class="code" href="class_qwt_dial.html#b4">00475</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b4">QwtDial::drawContents</a>(QPainter *painter)<span class="keyword"> const</span>
00476 <span class="keyword"></span>{
00477     <span class="keywordflow">if</span> ( backgroundMode() == NoBackground || 
00478         colorGroup().brush(QColorGroup::Base) != 
00479             colorGroup().brush(QColorGroup::Background) )
00480     {
00481         <span class="comment">// Dont use QPainter::drawEllipse. There are some pixels</span>
00482         <span class="comment">// different compared to the region in the mask, leaving</span>
00483         <span class="comment">// them in background color.</span>
00484 
00485         painter-&gt;save();
00486         painter-&gt;setPen(Qt::NoPen);
00487         painter-&gt;setBrush(colorGroup().brush(QColorGroup::Base));
00488 
00489         <span class="comment">// Even if we want to fill the contentsRect only, we fill the</span>
00490         <span class="comment">// complete boundingRect. The frame will be painted later</span>
00491         <span class="comment">// above, but we want to have the base color below it</span>
00492         <span class="comment">// because round objects doesnt cover all pixels.</span>
00493 
00494         QRect br = <a class="code" href="class_qwt_dial.html#a23">boundingRect</a>();
00495 <span class="preprocessor">#if QT_VERSION &lt; 300</span>
00496 <span class="preprocessor"></span><span class="preprocessor">#ifdef _WS_WIN32_</span>
00497 <span class="preprocessor"></span>        <span class="comment">// Qt-230-NC draws ellipses not as nicely as Qt-2.3.x on X Windows</span>
00498         br.setTop(br.top()-1);
00499         br.setLeft(br.left()-1);
00500         br.setBottom(br.bottom()+1);
00501         br.setRight(br.right()+1);
00502 <span class="preprocessor">#endif</span>
00503 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00504 <span class="preprocessor"></span>        painter-&gt;setClipRegion(QRegion(painter-&gt;xForm(br), QRegion::Ellipse));
00505         painter-&gt;drawRect(br);
00506         painter-&gt;restore();
00507     }
00508 
00509 
00510     <span class="keyword">const</span> QRect insideScaleRect = <a class="code" href="class_qwt_dial.html#a25">scaleContentsRect</a>();
00511     <span class="keywordflow">if</span> ( colorGroup().brush(QColorGroup::Foreground) !=
00512         colorGroup().brush(QColorGroup::Base) )
00513     {
00514         painter-&gt;save();
00515         painter-&gt;setPen(Qt::NoPen);
00516         painter-&gt;setBrush(colorGroup().brush(QColorGroup::Foreground));
00517 
00518         painter-&gt;setClipRegion(
00519             QRegion(painter-&gt;xForm(insideScaleRect), QRegion::Ellipse));
00520         painter-&gt;drawRect(insideScaleRect);
00521         painter-&gt;restore();
00522     }
00523 
00524     <span class="keyword">const</span> QPoint center = insideScaleRect.center();
00525     <span class="keyword">const</span> <span class="keywordtype">int</span> radius = insideScaleRect.width() / 2;
00526 
00527     painter-&gt;save();
00528     <a class="code" href="class_qwt_dial.html#b7">drawScaleContents</a>(painter, center, radius);
00529     painter-&gt;restore();
00530 
00531     <span class="keywordtype">double</span> direction = d_origin;
00532 
00533     <span class="keywordflow">if</span> (<a class="code" href="class_qwt_slider_base.html#a10">isValid</a>())
00534     {
00535         direction = d_origin + d_minScaleArc;
00536         <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_dbl_range.html#a11">maxValue</a>() &gt; <a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>() &amp;&amp; d_maxScaleArc &gt; d_minScaleArc )
00537         {
00538             <span class="keyword">const</span> <span class="keywordtype">double</span> ratio = 
00539                 (<a class="code" href="class_qwt_dbl_range.html#a6">value</a>() - <a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>()) / (<a class="code" href="class_qwt_dbl_range.html#a11">maxValue</a>() - <a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>());
00540             direction += ratio * (d_maxScaleArc - d_minScaleArc);
00541         }
00542 
00543         <span class="keywordflow">if</span> ( direction &gt;= 360.0 )
00544             direction -= 360.0;
00545     }
00546 
00547     <span class="keywordtype">double</span> <a class="code" href="class_qwt_dial.html#a19">origin</a> = d_origin;
00548     <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_dial.html#a9">mode</a>() == RotateScale )
00549     {
00550         origin -= direction - d_origin;
00551         direction = d_origin;
00552     }
00553 
00554     painter-&gt;save();
00555     <a class="code" href="class_qwt_dial.html#b6">drawScale</a>(painter, center, radius, origin, d_minScaleArc, d_maxScaleArc);
00556     painter-&gt;restore();
00557 
00558     <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_slider_base.html#a10">isValid</a>() )
00559     {
00560         QPalette::ColorGroup cg;
00561         <span class="keywordflow">if</span> ( isEnabled() )
00562             cg = hasFocus() ? QPalette::Active : QPalette::Inactive;
00563         <span class="keywordflow">else</span>
00564             cg = QPalette::Disabled;
00565 
00566         painter-&gt;save();
00567         <a class="code" href="class_qwt_dial.html#b8">drawNeedle</a>(painter, center, radius, direction, cg);
00568         painter-&gt;restore();
00569     }
00570 }
00571 
<a name="l00584"></a><a class="code" href="class_qwt_dial.html#b8">00584</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b8">QwtDial::drawNeedle</a>(QPainter *painter, <span class="keyword">const</span> QPoint &amp;center, 
00585     <span class="keywordtype">int</span> radius, <span class="keywordtype">double</span> direction, QPalette::ColorGroup cg)<span class="keyword"> const</span>
00586 <span class="keyword"></span>{
00587     <span class="keywordflow">if</span> ( d_needle )
00588     {
00589         direction = 360.0 - direction; <span class="comment">// counter clockwise</span>
00590         d_needle-&gt;<a class="code" href="class_qwt_dial_needle.html#a2">draw</a>(painter, center, radius, direction, cg);
00591     }
00592 }
00593 
<a name="l00606"></a><a class="code" href="class_qwt_dial.html#b6">00606</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b6">QwtDial::drawScale</a>(QPainter *painter, <span class="keyword">const</span> QPoint &amp;center,
00607     <span class="keywordtype">int</span> radius, <span class="keywordtype">double</span> origin, <span class="keywordtype">double</span> minArc, <span class="keywordtype">double</span> maxArc)<span class="keyword"> const</span>
00608 <span class="keyword"></span>{
00609     <span class="keywordflow">if</span> ( d_scaleDraw == NULL )
00610         <span class="keywordflow">return</span>;
00611 
00612     origin -= 270.0; <span class="comment">// hardcoded origin of QwtScaleDraw</span>
00613 
00614     <span class="keywordtype">double</span> angle = maxArc - minArc;
00615     <span class="keywordflow">if</span> ( angle &gt; 360.0 )
00616         angle = fmod(angle, 360.0);
00617 
00618     minArc += origin;
00619     <span class="keywordflow">if</span> ( minArc &lt; -360.0 )
00620         minArc = fmod(minArc, 360.0);
00621     
00622     maxArc = minArc + angle;
00623     <span class="keywordflow">if</span> ( maxArc &gt; 360.0 )
00624     {
00625         <span class="comment">// QwtScaleDraw::setAngleRange accepts only values</span>
00626         <span class="comment">// in the range [-360.0..360.0]</span>
00627         minArc -= 360.0;
00628         maxArc -= 360.0;
00629     }
00630     
00631     painter-&gt;setFont(font());
00632     painter-&gt;setPen(QPen(colorGroup().text(), d_scaleDraw-&gt;<a class="code" href="class_qwt_dial_scale_draw.html#a5">penWidth</a>()));
00633 
00634     d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a11">setAngleRange</a>(minArc, maxArc);
00635     d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a6">setGeometry</a>(
00636         center.x() - radius + 1, 
00637         center.y() - radius + 1,
00638         2 * radius, QwtScaleDraw::Round);
00639 
00640     d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a29">draw</a>(painter);
00641 }
00642 
<a name="l00643"></a><a class="code" href="class_qwt_dial.html#b7">00643</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b7">QwtDial::drawScaleContents</a>(QPainter *, 
00644     <span class="keyword">const</span> QPoint &amp;, <span class="keywordtype">int</span>)<span class="keyword"> const</span>
00645 <span class="keyword"></span>{
00646     <span class="comment">// empty default implementation</span>
00647 }
00648 
<a name="l00659"></a><a class="code" href="class_qwt_dial.html#a20">00659</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#a20">QwtDial::setNeedle</a>(<a class="code" href="class_qwt_dial_needle.html">QwtDialNeedle</a> *needle)
00660 {
00661     <span class="keywordflow">if</span> ( needle != d_needle )
00662     {
00663         <span class="keywordflow">if</span> ( d_needle )
00664             <span class="keyword">delete</span> d_needle;
00665 
00666         d_needle = needle;
00667         update();
00668     }
00669 }
00670 
<a name="l00675"></a><a class="code" href="class_qwt_dial.html#a21">00675</a> <span class="keyword">const</span> <a class="code" href="class_qwt_dial_needle.html">QwtDialNeedle</a> *<a class="code" href="class_qwt_dial.html#a21">QwtDial::needle</a>()<span class="keyword"> const </span>
00676 <span class="keyword"></span>{ 
00677     <span class="keywordflow">return</span> d_needle; 
00678 }
00679 
<a name="l00684"></a><a class="code" href="class_qwt_dial.html#a22">00684</a> <a class="code" href="class_qwt_dial_needle.html">QwtDialNeedle</a> *<a class="code" href="class_qwt_dial.html#a21">QwtDial::needle</a>() 
00685 { 
00686     <span class="keywordflow">return</span> d_needle; 
00687 }
00688 
<a name="l00690"></a><a class="code" href="class_qwt_dial.html#b11">00690</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b11">QwtDial::rangeChange</a>()
00691 {
00692     <a class="code" href="class_qwt_dial.html#b10">updateScale</a>();
00693 }
00694 
<a name="l00699"></a><a class="code" href="class_qwt_dial.html#b10">00699</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b10">QwtDial::updateScale</a>()
00700 {
00701     <span class="keywordflow">if</span> ( d_scaleDraw )
00702     {
00703         d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a2">setScale</a>(<a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>(), <a class="code" href="class_qwt_dbl_range.html#a11">maxValue</a>(),
00704             d_maxMajIntv, d_maxMinIntv, d_scaleStep);
00705     }
00706 }
00707 
<a name="l00713"></a><a class="code" href="class_qwt_dial.html#a28">00713</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#a28">QwtDial::setScaleDraw</a>(<a class="code" href="class_qwt_dial_scale_draw.html">QwtDialScaleDraw</a> *scaleDraw)
00714 {
00715     <span class="keywordflow">if</span> ( scaleDraw != d_scaleDraw )
00716     {
00717         <span class="keywordflow">if</span> ( d_scaleDraw )
00718             <span class="keyword">delete</span> d_scaleDraw;
00719     
00720         d_scaleDraw = scaleDraw;
00721         <a class="code" href="class_qwt_dial.html#b10">updateScale</a>();
00722         update();
00723     }
00724 }
00725 
<a name="l00730"></a><a class="code" href="class_qwt_dial.html#a12">00730</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#a12">QwtDial::setScale</a>(<span class="keywordtype">int</span> maxMajIntv, <span class="keywordtype">int</span> maxMinIntv, <span class="keywordtype">double</span> step)
00731 {
00732     d_maxMajIntv = maxMajIntv;
00733     d_maxMinIntv = maxMinIntv;
00734     d_scaleStep = step;
00735 
00736     <a class="code" href="class_qwt_dial.html#b10">updateScale</a>();
00737 }
00738 
<a name="l00754"></a><a class="code" href="class_qwt_dial.html#a14">00754</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#a14">QwtDial::setScaleOptions</a>(<span class="keywordtype">int</span> options)
00755 {
00756     <span class="keywordflow">if</span> ( options == 0 )
00757         <a class="code" href="class_qwt_dial.html#a28">setScaleDraw</a>(NULL);
00758 
00759     <span class="keywordflow">if</span> ( d_scaleDraw == NULL )
00760         <span class="keywordflow">return</span>;
00761 
00762     <span class="keywordtype">int</span> flags = d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a5">options</a>();
00763     <span class="keywordflow">if</span> ( options &amp; ScaleBackbone )
00764         flags |= QwtScaleDraw::Backbone;
00765     <span class="keywordflow">else</span>
00766         flags &amp;= ~<a class="code" href="class_qwt_scale_draw.html">QwtScaleDraw</a>::Backbone;
00767     d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a4">setOptions</a>(flags);
00768 
00769     <span class="keywordflow">if</span> ( !(options &amp; ScaleTicks) )
00770         d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a15">setTickLength</a>(0, 0, 0);
00771 
00772     d_scaleDraw-&gt;<a class="code" href="class_qwt_dial_scale_draw.html#a2">showLabels</a>(options &amp; ScaleLabel);
00773 }
00774 
<a name="l00776"></a><a class="code" href="class_qwt_dial.html#a15">00776</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#a15">QwtDial::setScaleTicks</a>(<span class="keywordtype">int</span> minLen, <span class="keywordtype">int</span> medLen, 
00777     <span class="keywordtype">int</span> majLen, <span class="keywordtype">int</span> penWidth)
00778 {
00779     <span class="keywordflow">if</span> ( d_scaleDraw )
00780     {
00781         d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a15">setTickLength</a>(minLen, medLen, majLen);
00782         d_scaleDraw-&gt;<a class="code" href="class_qwt_dial_scale_draw.html#a4">setPenWidth</a>(penWidth);
00783     }
00784 }
00785 
<a name="l00789"></a><a class="code" href="class_qwt_dial.html#b9">00789</a> QString <a class="code" href="class_qwt_dial.html#b9">QwtDial::scaleLabel</a>(<span class="keywordtype">double</span> value)<span class="keyword"> const</span>
00790 <span class="keyword"></span>{
00791 <span class="preprocessor">#if 1</span>
00792 <span class="preprocessor"></span>    <span class="keywordflow">if</span> ( value == -0 )
00793         value = 0;
00794 <span class="preprocessor">#endif</span>
00795 <span class="preprocessor"></span>
00796     QString text;
00797     text.sprintf(<span class="stringliteral">"%g"</span>, value);
00798 
00799     <span class="keywordflow">return</span> text;
00800 }
00801 
<a name="l00810"></a><a class="code" href="class_qwt_dial.html#a18">00810</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#a18">QwtDial::setOrigin</a>(<span class="keywordtype">double</span> origin)
00811 {
00812     d_origin = origin;
00813     update();
00814 }
00815 
<a name="l00822"></a><a class="code" href="class_qwt_dial.html#a19">00822</a> <span class="keywordtype">double</span> <a class="code" href="class_qwt_dial.html#a19">QwtDial::origin</a>()<span class="keyword"> const</span>
00823 <span class="keyword"></span>{
00824     <span class="keywordflow">return</span> d_origin;
00825 }
00826 
<a name="l00833"></a><a class="code" href="class_qwt_dial.html#a13">00833</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#a13">QwtDial::setScaleArc</a>(<span class="keywordtype">double</span> minArc, <span class="keywordtype">double</span> maxArc)
00834 {
00835     <span class="keywordflow">if</span> ( minArc != 360.0 &amp;&amp; minArc != -360.0 )
00836         minArc = fmod(minArc, 360.0);
00837     <span class="keywordflow">if</span> ( maxArc != 360.0 &amp;&amp; maxArc != -360.0 )
00838         maxArc = fmod(maxArc, 360.0);
00839 
00840     d_minScaleArc = QMIN(minArc, maxArc);
00841     d_maxScaleArc = QMAX(minArc, maxArc);
00842     <span class="keywordflow">if</span> ( d_maxScaleArc - d_minScaleArc &gt; 360.0 )
00843         d_maxScaleArc = d_minScaleArc + 360.0;
00844     
00845     update();
00846 }
00847 
<a name="l00849"></a><a class="code" href="class_qwt_dial.html#b12">00849</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b12">QwtDial::valueChange</a>()
00850 {
00851     update();
00852     <a class="code" href="class_qwt_slider_base.html#b1">QwtSliderBase::valueChange</a>();
00853 }
00854 
<a name="l00858"></a><a class="code" href="class_qwt_dial.html#a26">00858</a> QSize <a class="code" href="class_qwt_dial.html#a26">QwtDial::sizeHint</a>()<span class="keyword"> const</span>
00859 <span class="keyword"></span>{
00860     <span class="keywordtype">int</span> sh = 0;
00861     <span class="keywordflow">if</span> ( d_scaleDraw )
00862         sh = d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a22">minHeight</a>( QPen(), fontMetrics() );
00863 
00864     <span class="keyword">const</span> <span class="keywordtype">int</span> d = 6 * sh + 2 * <a class="code" href="class_qwt_dial.html#a7">lineWidth</a>();
00865     
00866     <span class="keywordflow">return</span> QSize( d, d );
00867 }
00868 
<a name="l00874"></a><a class="code" href="class_qwt_dial.html#a27">00874</a> QSize <a class="code" href="class_qwt_dial.html#a27">QwtDial::minimumSizeHint</a>()<span class="keyword"> const</span>
00875 <span class="keyword"></span>{   
00876     <span class="keywordtype">int</span> sh = 0;
00877     <span class="keywordflow">if</span> ( d_scaleDraw )
00878         sh = d_scaleDraw-&gt;<a class="code" href="class_qwt_scale_draw.html#a22">minHeight</a>( QPen(), fontMetrics() );
00879 
00880     <span class="keyword">const</span> <span class="keywordtype">int</span> d = 3 * sh + 2 * <a class="code" href="class_qwt_dial.html#a7">lineWidth</a>();
00881     
00882     <span class="keywordflow">return</span> QSize( d, d );
00883 }
00884 
00885 <span class="keyword">static</span> <span class="keywordtype">double</span> line2Radians(<span class="keyword">const</span> QPoint &amp;p1, <span class="keyword">const</span> QPoint &amp;p2)
00886 {
00887     <span class="keyword">const</span> QPoint p = p2 - p1;
00888 
00889     <span class="keywordtype">double</span> angle;
00890     <span class="keywordflow">if</span> ( p.x() == 0 )
00891         angle = ( p.y() &lt;= 0 ) ? M_PI_2 : 3 * M_PI_2;
00892     <span class="keywordflow">else</span>
00893     {
00894         angle = atan(<span class="keywordtype">double</span>(-p.y()) / double(p.x()));
00895         <span class="keywordflow">if</span> ( p.x() &lt; 0 )
00896             angle += M_PI;
00897         <span class="keywordflow">if</span> ( angle &lt; 0.0 )
00898             angle += 2 * M_PI;
00899     }
00900     <span class="keywordflow">return</span> 360.0 - angle * 180.0 / M_PI;
00901 }
00902 
<a name="l00909"></a><a class="code" href="class_qwt_dial.html#b13">00909</a> <span class="keywordtype">double</span> <a class="code" href="class_qwt_dial.html#b13">QwtDial::getValue</a>(<span class="keyword">const</span> QPoint &amp;pos)
00910 {
00911     <span class="keywordflow">if</span> ( d_maxScaleArc == d_minScaleArc || <a class="code" href="class_qwt_dbl_range.html#a11">maxValue</a>() == <a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>() )
00912         <span class="keywordflow">return</span> <a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>();
00913 
00914     <span class="keywordtype">double</span> dir = line2Radians(rect().center(), pos) - d_origin;
00915     <span class="keywordflow">if</span> ( dir &lt; 0.0 )
00916         dir += 360.0;
00917 
00918     <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_dial.html#a9">mode</a>() == RotateScale )
00919         dir = 360.0 - dir;
00920 
00921     <span class="comment">// The position might be in the area that is outside the scale arc.</span>
00922     <span class="comment">// We need the range of the scale if it was a complete circle.</span>
00923 
00924     <span class="keyword">const</span> <span class="keywordtype">double</span> completeCircle = 360.0 / (d_maxScaleArc - d_minScaleArc) 
00925         * (<a class="code" href="class_qwt_dbl_range.html#a11">maxValue</a>() - <a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>());
00926 
00927     <span class="keywordtype">double</span> posValue = <a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>() + completeCircle * dir / 360.0;
00928 
00929     <span class="keywordflow">if</span> ( d_scrollMode == ScrMouse )
00930     {
00931         <span class="keywordflow">if</span> ( d_previousDir &gt;= 0.0 ) <span class="comment">// valid direction</span>
00932         {
00933             <span class="comment">// We have to find out whether the mouse is moving</span>
00934             <span class="comment">// clock or counter clockwise</span>
00935 
00936             <span class="keywordtype">bool</span> clockWise = FALSE;
00937 
00938             <span class="keyword">const</span> <span class="keywordtype">double</span> angle = dir - d_previousDir;
00939             <span class="keywordflow">if</span> ( (angle &gt;= 0.0 &amp;&amp; angle &lt;= 180.0) || angle &lt; -180.0 )
00940                 clockWise = TRUE;
00941 
00942             <span class="keywordflow">if</span> ( clockWise )
00943             {
00944                 <span class="keywordflow">if</span> ( dir &lt; d_previousDir &amp;&amp; d_mouseOffset &gt; 0.0 )
00945                 {
00946                     <span class="comment">// We passed 360 -&gt; 0</span>
00947                     d_mouseOffset -= completeCircle;    
00948                 }
00949 
00950                 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_dial.html#a11">wrapping</a>() )
00951                 {
00952                     <span class="keywordflow">if</span> ( posValue - d_mouseOffset &gt; <a class="code" href="class_qwt_dbl_range.html#a11">maxValue</a>() )
00953                     {
00954                         <span class="comment">// We passed maxValue and the value will be set</span>
00955                         <span class="comment">// to minValue. We have to adjust the d_mouseOffset.</span>
00956 
00957                         d_mouseOffset = posValue - <a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>();
00958                     }
00959                 }
00960                 <span class="keywordflow">else</span>
00961                 {
00962                     <span class="keywordflow">if</span> ( posValue - d_mouseOffset &gt; <a class="code" href="class_qwt_dbl_range.html#a11">maxValue</a>() ||
00963                         <a class="code" href="class_qwt_dbl_range.html#a6">value</a>() == <a class="code" href="class_qwt_dbl_range.html#a11">maxValue</a>() )
00964                     {
00965                         <span class="comment">// We fix the value at maxValue by adjusting</span>
00966                         <span class="comment">// the mouse offset.</span>
00967 
00968                         d_mouseOffset = posValue - <a class="code" href="class_qwt_dbl_range.html#a11">maxValue</a>();
00969                     }
00970                 }
00971             }
00972             <span class="keywordflow">else</span>
00973             {
00974                 <span class="keywordflow">if</span> ( dir &gt; d_previousDir &amp;&amp; d_mouseOffset &lt; 0.0 )
00975                 {
00976                     <span class="comment">// We passed 0 -&gt; 360 </span>
00977                     d_mouseOffset += completeCircle;    
00978                 }
00979 
00980                 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_dial.html#a11">wrapping</a>() )
00981                 {
00982                     <span class="keywordflow">if</span> ( posValue - d_mouseOffset &lt; <a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>() )
00983                     {
00984                         <span class="comment">// We passed minValue and the value will be set</span>
00985                         <span class="comment">// to maxValue. We have to adjust the d_mouseOffset.</span>
00986 
00987                         d_mouseOffset = posValue - <a class="code" href="class_qwt_dbl_range.html#a11">maxValue</a>();
00988                     }
00989                 }
00990                 <span class="keywordflow">else</span>
00991                 {
00992                     <span class="keywordflow">if</span> ( posValue - d_mouseOffset &lt; <a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>() ||
00993                         <a class="code" href="class_qwt_dbl_range.html#a6">value</a>() == <a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>() )
00994                     {
00995                         <span class="comment">// We fix the value at minValue by adjusting</span>
00996                         <span class="comment">// the mouse offset.</span>
00997 
00998                         d_mouseOffset = posValue - <a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>();
00999                     }
01000                 }
01001             }
01002         }
01003         d_previousDir = dir;
01004     }
01005 
01006     <span class="keywordflow">return</span> posValue;
01007 }
01008 
<a name="l01012"></a><a class="code" href="class_qwt_dial.html#b14">01012</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b14">QwtDial::getScrollMode</a>(<span class="keyword">const</span> QPoint &amp;p, <span class="keywordtype">int</span> &amp;scrollMode, <span class="keywordtype">int</span> &amp;direction)
01013 {
01014     direction = 0;
01015     scrollMode = ScrNone;
01016 
01017     <span class="keyword">const</span> QRegion region(<a class="code" href="class_qwt_dial.html#a24">contentsRect</a>(), QRegion::Ellipse);
01018     <span class="keywordflow">if</span> ( region.contains(p) &amp;&amp; p != rect().center() )
01019     {
01020         scrollMode = ScrMouse;
01021         d_previousDir = -1.0;
01022     }
01023 }
01024 
<a name="l01044"></a><a class="code" href="class_qwt_dial.html#b2">01044</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_dial.html#b2">QwtDial::keyPressEvent</a>(QKeyEvent *e)
01045 {
01046     <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_slider_base.html#a9">isReadOnly</a>() )
01047     {
01048 <span class="preprocessor">#if QT_VERSION &gt;= 300</span>
01049 <span class="preprocessor"></span>        e-&gt;ignore();
01050 <span class="preprocessor">#endif</span>
01051 <span class="preprocessor"></span>        <span class="keywordflow">return</span>;
01052     }
01053 
01054     <span class="keywordflow">if</span> ( !<a class="code" href="class_qwt_slider_base.html#a10">isValid</a>() )
01055         <span class="keywordflow">return</span>;
01056 
01057     <span class="keywordtype">double</span> previous = <a class="code" href="class_qwt_dbl_range.html#b2">prevValue</a>();
01058     <span class="keywordflow">switch</span> ( e-&gt;key() )
01059     {
01060         <span class="keywordflow">case</span> Qt::Key_Down:
01061         <span class="keywordflow">case</span> Qt::Key_Left:
01062             <a class="code" href="class_qwt_dbl_range.html#a14">QwtDblRange::incValue</a>(-1);
01063             <span class="keywordflow">break</span>;
01064         <span class="keywordflow">case</span> Qt::Key_Prior:
01065             <a class="code" href="class_qwt_dbl_range.html#a14">QwtDblRange::incValue</a>(-<a class="code" href="class_qwt_dbl_range.html#a13">pageSize</a>());
01066             <span class="keywordflow">break</span>;
01067         <span class="keywordflow">case</span> Qt::Key_Home:
01068             <a class="code" href="class_qwt_slider_base.html#i0">setValue</a>(<a class="code" href="class_qwt_dbl_range.html#a12">minValue</a>());
01069             <span class="keywordflow">break</span>;
01070 
01071         <span class="keywordflow">case</span> Qt::Key_Up:
01072         <span class="keywordflow">case</span> Qt::Key_Right:
01073             <a class="code" href="class_qwt_dbl_range.html#a14">QwtDblRange::incValue</a>(1);
01074             <span class="keywordflow">break</span>;
01075         <span class="keywordflow">case</span> Qt::Key_Next:
01076             <a class="code" href="class_qwt_dbl_range.html#a14">QwtDblRange::incValue</a>(<a class="code" href="class_qwt_dbl_range.html#a13">pageSize</a>());
01077             <span class="keywordflow">break</span>;
01078         <span class="keywordflow">case</span> Qt::Key_End:
01079             <a class="code" href="class_qwt_slider_base.html#i0">setValue</a>(<a class="code" href="class_qwt_dbl_range.html#a11">maxValue</a>());
01080             <span class="keywordflow">break</span>;
01081         <span class="keywordflow">default</span>:;
01082 <span class="preprocessor">#if QT_VERSION &gt;= 300</span>
01083 <span class="preprocessor"></span>            e-&gt;ignore();
01084 <span class="preprocessor">#endif</span>
01085 <span class="preprocessor"></span>    }
01086 
01087     <span class="keywordflow">if</span> (<a class="code" href="class_qwt_dbl_range.html#a6">value</a>() != previous)
01088         emit <a class="code" href="class_qwt_slider_base.html#l3">sliderMoved</a>(<a class="code" href="class_qwt_dbl_range.html#a6">value</a>());
01089 }
01090 
</div></pre><hr size="1"><address style="align: right;"><small>Generated on Tue Nov 16 21:12:20 2004 for Qwt User's Guide by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address>
</body>
</html>