summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/oledbox.cpp274
-rw-r--r--core/applets/volumeapplet/oledbox.h51
-rw-r--r--core/applets/volumeapplet/volume.cpp2
-rw-r--r--core/applets/volumeapplet/volumeapplet.pro3
4 files changed, 3 insertions, 327 deletions
diff --git a/core/applets/volumeapplet/oledbox.cpp b/core/applets/volumeapplet/oledbox.cpp
deleted file mode 100644
index bf275a9..0000000
--- a/core/applets/volumeapplet/oledbox.cpp
+++ b/dev/null
@@ -1,274 +0,0 @@
1
2#include <qbitmap.h>
3#include <qpainter.h>
4
5#include "oledbox.h"
6
7
8#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
9
10/* XPM */
11static const char * ledborder_xpm[] = {
12"16 16 11 1",
13 " c None",
14 ".c #626562",
15 "+c #7B7D7B",
16 "@c #949594",
17 "#c #ACAEAC",
18 "$c #CDCACD",
19 "%c #CDCECD",
20 ";c #E6E6E6",
21 ">c #FFFFFF",
22 ",c #E6E2E6",
23 "'c #FFFAFF",
24" .++@@# ",
25" ...++@@##$ ",
26" .....+@##$$% ",
27" ..... #$%%% ",
28" ... %%; ",
29".... ;;;;",
30"++. ;>>",
31"+++ >>>",
32"@@@ >>>",
33"@@# >>>",
34"#### >>>>",
35" #$$ >>> ",
36" $$,,' >>>>> ",
37" ,,,''>>>>>>> ",
38" ,''>>>>>>> ",
39" '>>>>> "};
40
41
42QPixmap *OLedBox::s_border_pix = 0;
43
44#endif
45
46
47OLedBox::OLedBox ( const QColor &col, QWidget *parent, const char *name ) : QWidget ( parent, name )
48{
49 m_color = col;
50 m_on = false;
51
52 m_pix [ 0 ] = m_pix [ 1 ] = false;
53
54 setBackgroundMode ( PaletteBackground );
55
56#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
57 if ( !s_border_pix )
58 s_border_pix = new QPixmap ( ledborder_xpm );
59#endif
60}
61
62OLedBox::~OLedBox ( )
63{
64 delete m_pix [ 0 ];
65 delete m_pix [ 1 ];
66}
67
68QSize OLedBox::sizeHint ( ) const
69{
70 return QSize ( 16, 16 );
71}
72
73bool OLedBox::isOn ( ) const
74{
75 return m_on;
76}
77
78QColor OLedBox::color ( ) const
79{
80 return m_color;
81}
82
83void OLedBox::setOn ( bool b )
84{
85 if ( m_on != b ) {
86 m_on = b;
87 update ( );
88 }
89}
90
91void OLedBox::toggle ( )
92{
93 setOn ( !isOn ( ) );
94}
95
96void OLedBox::setColor ( const QColor &col )
97{
98 if ( m_color != col ) {
99 m_color = col;
100
101 delete m_pix [ 0 ];
102 delete m_pix [ 1 ];
103
104 update ( );
105 }
106}
107
108void OLedBox::mousePressEvent ( QMouseEvent *e )
109{
110 if ( e-> button ( ) == LeftButton ) {
111 m_on = !m_on;
112 update ( );
113 emit toggled ( m_on );
114 }
115}
116
117
118void OLedBox::resizeEvent ( QResizeEvent * )
119{
120 delete m_pix [ 0 ];
121 delete m_pix [ 1 ];
122
123 update ( );
124}
125
126void OLedBox::paintEvent ( QPaintEvent *e )
127{
128 int ind = m_on ? 1 : 0;
129
130 if ( !m_pix [ ind ] ) {
131 m_pix [ ind ] = new QPixmap ( size ( ));
132
133 drawLed ( m_pix [ ind ], m_on ? m_color : m_color. dark ( 300 ) );
134 }
135 if ( !e-> erased ( ))
136 erase ( );
137
138 QPainter p ( this );
139 p. drawPixmap ( 0, 0, *m_pix [ ind ] );
140}
141
142// From KDE libkdeui / led.cpp
143
144void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNKEN led lamp
145{
146 QPainter paint;
147 QColor color;
148 QBrush brush;
149 QPen pen;
150
151 pix-> fill ( black );
152
153 // First of all we want to know what area should be updated
154 // Initialize coordinates, width, and height of the LED
155 int width = pix-> width ( );
156
157 // Make sure the LED is round!
158 if ( width > pix-> height ( ))
159 width = pix-> height ( );
160 width -= 2; // leave one pixel border
161 if ( width < 0 )
162 width = 0;
163
164 // maybe we could stop HERE, if width <=0 ?
165
166 // start painting widget
167 //
168 paint.begin( pix );
169
170 // Set the color of the LED according to given parameters
171 color = col;
172
173 // Set the brush to SolidPattern, this fills the entire area
174 // of the ellipse which is drawn first
175 brush.setStyle( QBrush::SolidPattern );
176 brush.setColor( color );
177 paint.setBrush( brush ); // Assign the brush to the painter
178
179 // Draws a "flat" LED with the given color:
180 paint.drawEllipse( 1, 1, width, width );
181
182 // Draw the bright light spot of the LED now, using modified "old"
183 // painter routine taken from KDEUIs KLed widget:
184
185 // Setting the new width of the pen is essential to avoid "pixelized"
186 // shadow like it can be observed with the old LED code
187 pen.setWidth( 2 );
188
189 // shrink the light on the LED to a size about 2/3 of the complete LED
190 int pos = width / 5 + 1;
191 int light_width = width;
192 light_width *= 2;
193 light_width /= 3;
194
195 // Calculate the LEDs "light factor":
196 int light_quote = ( 130 * 2 / ( light_width ? light_width : 1 ) ) + 100;
197
198 // Now draw the bright spot on the LED:
199 while ( light_width )
200 {
201 color = color.light( light_quote ); // make color lighter
202 pen.setColor( color ); // set color as pen color
203 paint.setPen( pen ); // select the pen for drawing
204 paint.drawEllipse( pos, pos, light_width, light_width ); // draw the ellipse (circle)
205 light_width--;
206 if ( !light_width )
207 break;
208 paint.drawEllipse( pos, pos, light_width, light_width );
209 light_width--;
210 if ( !light_width )
211 break;
212 paint.drawEllipse( pos, pos, light_width, light_width );
213 pos++;
214 light_width--;
215 }
216
217 // Drawing of bright spot finished, now draw a thin border
218 // around the LED which resembles a shadow with light coming
219 // from the upper left.
220
221#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
222 paint. drawPixmap ( 0, 0, *s_border_pix );
223 paint. end ( );
224
225 pix-> setMask ( pix-> createHeuristicMask ( ));
226
227#else
228 pen.setWidth( 3 );
229 brush.setStyle( QBrush::NoBrush ); // Switch off the brush
230 paint.setBrush( brush ); // This avoids filling of the ellipse
231
232 // Set the initial color value to 200 (bright) and start
233 // drawing the shadow border at 45 (45*16 = 720).
234 int shadow_color = 200, angle;
235
236 for ( angle = 720; angle < 6480; angle += 240 )
237 {
238 color.setRgb( shadow_color, shadow_color, shadow_color );
239 pen.setColor( color );
240 paint.setPen( pen );
241 paint.drawArc( 0, 0, width+2, width+2, angle, 240 );
242 paint.drawArc( 1, 1, width, width, angle, 240 );
243 paint.drawArc( 2, 2, width-2, width-2, angle, 240 );
244 if ( angle < 2320 ) {
245 shadow_color -= 25; // set color to a darker value
246 if ( shadow_color < 100 )
247 shadow_color = 100;
248 }
249 else if ( ( angle > 2320 ) && ( angle < 5760 ) ) {
250 shadow_color += 25; // set color to a brighter value
251 if ( shadow_color > 255 )
252 shadow_color = 255;
253 }
254 else {
255 shadow_color -= 25; // set color to a darker value again
256 if ( shadow_color < 100 )
257 shadow_color = 100;
258 } // end if ( angle < 2320 )
259 } // end for ( angle = 720; angle < 6480; angle += 160 )
260 paint.end();
261 //
262 // painting done
263
264 QBitmap mask ( pix-> width ( ), pix-> height ( ), true );
265 QPainter mp ( &mask );
266 mp. setPen ( Qt::NoPen );
267 mp. setBrush ( Qt::color1 );
268 mp. drawEllipse ( 0, 0, width + 2, width + 2 );
269 mp. end ( );
270
271 pix-> setMask ( mask );
272#endif
273}
274
diff --git a/core/applets/volumeapplet/oledbox.h b/core/applets/volumeapplet/oledbox.h
deleted file mode 100644
index 4371a22..0000000
--- a/core/applets/volumeapplet/oledbox.h
+++ b/dev/null
@@ -1,51 +0,0 @@
1#ifndef __OPIE_OLED_H__
2#define __OPIE_OLED_H__
3
4#include <qwidget.h>
5#include <qcolor.h>
6
7class QPixmap;
8
9#define _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
10
11class OLedBox : public QWidget {
12 Q_OBJECT
13
14public:
15 OLedBox ( const QColor &col = red, QWidget *parent = 0, const char *name = 0 );
16 virtual ~OLedBox ( );
17
18 QColor color ( ) const;
19 bool isOn ( ) const;
20
21 virtual QSize sizeHint ( ) const;
22
23public slots:
24 void toggle ( );
25 void setOn ( bool on );
26 void setColor ( const QColor &col );
27
28signals:
29 void toggled ( bool );
30
31protected:
32 virtual void paintEvent ( QPaintEvent *e );
33 virtual void resizeEvent ( QResizeEvent *e );
34
35 virtual void mousePressEvent ( QMouseEvent *e );
36
37private:
38 void drawLed ( QPixmap *, const QColor &col );
39
40private:
41 QPixmap *m_pix [2];
42
43 QColor m_color;
44 bool m_on;
45
46 #ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
47 static QPixmap *s_border_pix;
48#endif
49};
50
51#endif
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index 6a14d07..45c106a 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -16,14 +16,14 @@
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "volume.h" 21#include "volume.h"
22#include "oledbox.h"
23 22
23#include <opie2/oledbox.h>
24#include <opie2/odevice.h> 24#include <opie2/odevice.h>
25#include <opie2/otaskbarapplet.h> 25#include <opie2/otaskbarapplet.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28#include <qpe/config.h> 28#include <qpe/config.h>
29#include <qpe/qcopenvelope_qws.h> 29#include <qpe/qcopenvelope_qws.h>
diff --git a/core/applets/volumeapplet/volumeapplet.pro b/core/applets/volumeapplet/volumeapplet.pro
index a76bafb..e118dbd 100644
--- a/core/applets/volumeapplet/volumeapplet.pro
+++ b/core/applets/volumeapplet/volumeapplet.pro
@@ -1,10 +1,11 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt plugin warn_on 2 CONFIG += qt plugin warn_on
3 HEADERS = volume.h oledbox.h 3 HEADERS = volume.h oledbox.h
4 SOURCES = volume.cpp oledbox.cpp 4 #SOURCES= volume.cpp oledbox.cpp
5 SOURCES = volume.cpp
5 TARGET = volumeapplet 6 TARGET = volumeapplet
6 DESTDIR = $(OPIEDIR)/plugins/applets 7 DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include 8INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += 9DEPENDPATH +=
9LIBS += -lqpe -lopiecore2 10LIBS += -lqpe -lopiecore2
10 VERSION = 1.0.0 11 VERSION = 1.0.0