aboutsummaryrefslogtreecommitdiff
path: root/src/lib/FL/WidgetPDial.fl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/FL/WidgetPDial.fl')
-rw-r--r--src/lib/FL/WidgetPDial.fl131
1 files changed, 131 insertions, 0 deletions
diff --git a/src/lib/FL/WidgetPDial.fl b/src/lib/FL/WidgetPDial.fl
new file mode 100644
index 0000000..5b7ec05
--- /dev/null
+++ b/src/lib/FL/WidgetPDial.fl
@@ -0,0 +1,131 @@
1# data file for the Fltk User Interface Designer (fluid)
2version 1.0105
3header_name {.h}
4code_name {.cc}
5decl {//Copyright (c) 2003-2005 Nasca Octavian Paul} {}
6
7decl {//License: GNU GPL version 2 or later} {}
8
9decl {\#include <FL/Fl_Dial.H>} {public
10}
11
12decl {\#include <FL/fl_draw.H>} {public
13}
14
15decl {\#include <stdio.h>} {public
16}
17
18decl {\#include <math.h>} {public
19}
20
21class WidgetPDial {: {public Fl_Dial}
22} {
23 Function {WidgetPDial(int x,int y, int w, int h, const char *label=0):Fl_Dial(x,y,w,h,label)} {} {
24 code {oldvalue=0.0;} {}
25 }
26 Function {handle(int event)} {return_type int
27 } {
28 code {double dragsize,v,min=minimum(),max=maximum();
29int my;
30
31switch (event){
32case FL_PUSH:oldvalue=value();
33case FL_DRAG:
34 my=-(Fl::event_y()-y()-h()/2);
35
36 dragsize=200.0;
37 if (Fl::event_state(FL_BUTTON1)==0) dragsize*=10;
38 v=oldvalue+my/dragsize*(max-min);
39 if (v<min) v=min;
40 else if (v>max) v=max;
41
42 //printf("%d %g %g\\n",my,v,oldvalue);
43 value(v);
44 value_damage();
45 if (this->when()!=0) do_callback();
46 return(1);
47 break;
48case FL_RELEASE:
49 if (this->when()==0) do_callback();
50 return(1);
51 break;
52};
53return(0);} {selected
54 }
55 }
56 Function {drawgradient(int cx,int cy,int sx,double m1,double m2)} {return_type void
57 } {
58 code {for (int i=(int)(m1*sx);i<(int)(m2*sx);i++){
59 double tmp=1.0-pow(i*1.0/sx,2.0);
60 pdialcolor(140+(int) (tmp*90),140+(int)(tmp*90),140+(int) (tmp*100));
61 fl_arc(cx+sx/2-i/2,cy+sx/2-i/2,i,i,0,360);
62};} {}
63 }
64 Function {draw()} {} {
65 code {int cx=x(),cy=y(),sx=w(),sy=h();
66
67
68//clears the button face
69pdialcolor(190,190,200);
70fl_pie(cx-1,cy-1,sx+2,sy+2,0,360);
71
72//Draws the button face (gradinet)
73drawgradient(cx,cy,sx,0.5,1.0);
74
75double val=(value()-minimum())/(maximum()-minimum());
76
77//draws the scale
78pdialcolor(220,220,250);
79double a1=angle1(),a2=angle2();
80for (int i=0;i<12;i++){
81 double a=-i/12.0*360.0-val*(a2-a1)-a1;
82 fl_pie(cx,cy,sx,sy,a+270-3,a+3+270);
83};
84
85drawgradient(cx,cy,sx,0.0,0.75);
86
87//draws the value
88double a=-(a2-a1)*val-a1;
89
90
91
92
93
94//draws the max and min points
95pdialcolor(0,100,200);
96int xp=(int)(cx+sx/2.0+sx/2.0*sin(angle1()/180.0*3.141592));
97int yp=(int)(cy+sy/2.0+sy/2.0*cos(angle1()/180.0*3.141592));
98fl_pie(xp-2,yp-2,4,4,0,360);
99
100xp=(int)(cx+sx/2.0+sx/2.0*sin(angle2()/180.0*3.141592));
101yp=(int)(cy+sy/2.0+sy/2.0*cos(angle2()/180.0*3.141592));
102fl_pie(xp-2,yp-2,4,4,0,360);
103
104
105
106
107
108fl_push_matrix();
109
110 fl_translate(cx+sx/2,cy+sy/2);
111 fl_rotate(a-90.0);
112
113 fl_translate(sx/2,0);
114
115
116 fl_begin_polygon();
117 pdialcolor(0,0,0);
118 fl_vertex(-10,-4);
119 fl_vertex(-10,4);
120 fl_vertex(0,0);
121 fl_end_polygon();
122
123
124fl_pop_matrix();} {}
125 }
126 Function {pdialcolor(int r,int g,int b)} {} {
127 code {if (active_r()) fl_color(r,g,b);
128 else fl_color(160-(160-r)/3,160-(160-b)/3,160-(160-b)/3);} {}
129 }
130 decl {double oldvalue;} {}
131}