summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-04 01:24:34 (UTC)
committer wimpie <wimpie>2005-01-04 01:24:34 (UTC)
commitf7e9672b6064a7c4ac7e485c292e6192263b271a (patch) (side-by-side diff)
tree0e2955e6c9d49e9d57559ac73f07e67143c70b41
parent937acd0b191564bace4da11cbf6c912a6f2300cf (diff)
downloadopie-f7e9672b6064a7c4ac7e485c292e6192263b271a.zip
opie-f7e9672b6064a7c4ac7e485c292e6192263b271a.tar.gz
opie-f7e9672b6064a7c4ac7e485c292e6192263b271a.tar.bz2
oledbox is now in libopie2/opieui
Diffstat (more/less context) (show 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 @@
-
-#include <qbitmap.h>
-#include <qpainter.h>
-
-#include "oledbox.h"
-
-
-#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
-
-/* XPM */
-static const char * ledborder_xpm[] = {
-"16 16 11 1",
-" c None",
-". c #626562",
-"+ c #7B7D7B",
-"@ c #949594",
-"# c #ACAEAC",
-"$ c #CDCACD",
-"% c #CDCECD",
-"; c #E6E6E6",
-"> c #FFFFFF",
-", c #E6E2E6",
-"' c #FFFAFF",
-" .++@@# ",
-" ...++@@##$ ",
-" .....+@##$$% ",
-" ..... #$%%% ",
-" ... %%; ",
-".... ;;;;",
-"++. ;>>",
-"+++ >>>",
-"@@@ >>>",
-"@@# >>>",
-"#### >>>>",
-" #$$ >>> ",
-" $$,,' >>>>> ",
-" ,,,''>>>>>>> ",
-" ,''>>>>>>> ",
-" '>>>>> "};
-
-
-QPixmap *OLedBox::s_border_pix = 0;
-
-#endif
-
-
-OLedBox::OLedBox ( const QColor &col, QWidget *parent, const char *name ) : QWidget ( parent, name )
-{
- m_color = col;
- m_on = false;
-
- m_pix [ 0 ] = m_pix [ 1 ] = false;
-
- setBackgroundMode ( PaletteBackground );
-
-#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
- if ( !s_border_pix )
- s_border_pix = new QPixmap ( ledborder_xpm );
-#endif
-}
-
-OLedBox::~OLedBox ( )
-{
- delete m_pix [ 0 ];
- delete m_pix [ 1 ];
-}
-
-QSize OLedBox::sizeHint ( ) const
-{
- return QSize ( 16, 16 );
-}
-
-bool OLedBox::isOn ( ) const
-{
- return m_on;
-}
-
-QColor OLedBox::color ( ) const
-{
- return m_color;
-}
-
-void OLedBox::setOn ( bool b )
-{
- if ( m_on != b ) {
- m_on = b;
- update ( );
- }
-}
-
-void OLedBox::toggle ( )
-{
- setOn ( !isOn ( ) );
-}
-
-void OLedBox::setColor ( const QColor &col )
-{
- if ( m_color != col ) {
- m_color = col;
-
- delete m_pix [ 0 ];
- delete m_pix [ 1 ];
-
- update ( );
- }
-}
-
-void OLedBox::mousePressEvent ( QMouseEvent *e )
-{
- if ( e-> button ( ) == LeftButton ) {
- m_on = !m_on;
- update ( );
- emit toggled ( m_on );
- }
-}
-
-
-void OLedBox::resizeEvent ( QResizeEvent * )
-{
- delete m_pix [ 0 ];
- delete m_pix [ 1 ];
-
- update ( );
-}
-
-void OLedBox::paintEvent ( QPaintEvent *e )
-{
- int ind = m_on ? 1 : 0;
-
- if ( !m_pix [ ind ] ) {
- m_pix [ ind ] = new QPixmap ( size ( ));
-
- drawLed ( m_pix [ ind ], m_on ? m_color : m_color. dark ( 300 ) );
- }
- if ( !e-> erased ( ))
- erase ( );
-
- QPainter p ( this );
- p. drawPixmap ( 0, 0, *m_pix [ ind ] );
-}
-
-// From KDE libkdeui / led.cpp
-
-void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNKEN led lamp
-{
- QPainter paint;
- QColor color;
- QBrush brush;
- QPen pen;
-
- pix-> fill ( black );
-
- // First of all we want to know what area should be updated
- // Initialize coordinates, width, and height of the LED
- int width = pix-> width ( );
-
- // Make sure the LED is round!
- if ( width > pix-> height ( ))
- width = pix-> height ( );
- width -= 2; // leave one pixel border
- if ( width < 0 )
- width = 0;
-
- // maybe we could stop HERE, if width <=0 ?
-
- // start painting widget
- //
- paint.begin( pix );
-
- // Set the color of the LED according to given parameters
- color = col;
-
- // Set the brush to SolidPattern, this fills the entire area
- // of the ellipse which is drawn first
- brush.setStyle( QBrush::SolidPattern );
- brush.setColor( color );
- paint.setBrush( brush ); // Assign the brush to the painter
-
- // Draws a "flat" LED with the given color:
- paint.drawEllipse( 1, 1, width, width );
-
- // Draw the bright light spot of the LED now, using modified "old"
- // painter routine taken from KDEUIs KLed widget:
-
- // Setting the new width of the pen is essential to avoid "pixelized"
- // shadow like it can be observed with the old LED code
- pen.setWidth( 2 );
-
- // shrink the light on the LED to a size about 2/3 of the complete LED
- int pos = width / 5 + 1;
- int light_width = width;
- light_width *= 2;
- light_width /= 3;
-
- // Calculate the LEDs "light factor":
- int light_quote = ( 130 * 2 / ( light_width ? light_width : 1 ) ) + 100;
-
- // Now draw the bright spot on the LED:
- while ( light_width )
- {
- color = color.light( light_quote ); // make color lighter
- pen.setColor( color ); // set color as pen color
- paint.setPen( pen ); // select the pen for drawing
- paint.drawEllipse( pos, pos, light_width, light_width ); // draw the ellipse (circle)
- light_width--;
- if ( !light_width )
- break;
- paint.drawEllipse( pos, pos, light_width, light_width );
- light_width--;
- if ( !light_width )
- break;
- paint.drawEllipse( pos, pos, light_width, light_width );
- pos++;
- light_width--;
- }
-
- // Drawing of bright spot finished, now draw a thin border
- // around the LED which resembles a shadow with light coming
- // from the upper left.
-
-#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
- paint. drawPixmap ( 0, 0, *s_border_pix );
- paint. end ( );
-
- pix-> setMask ( pix-> createHeuristicMask ( ));
-
-#else
- pen.setWidth( 3 );
- brush.setStyle( QBrush::NoBrush ); // Switch off the brush
- paint.setBrush( brush ); // This avoids filling of the ellipse
-
- // Set the initial color value to 200 (bright) and start
- // drawing the shadow border at 45 (45*16 = 720).
- int shadow_color = 200, angle;
-
- for ( angle = 720; angle < 6480; angle += 240 )
- {
- color.setRgb( shadow_color, shadow_color, shadow_color );
- pen.setColor( color );
- paint.setPen( pen );
- paint.drawArc( 0, 0, width+2, width+2, angle, 240 );
- paint.drawArc( 1, 1, width, width, angle, 240 );
- paint.drawArc( 2, 2, width-2, width-2, angle, 240 );
- if ( angle < 2320 ) {
- shadow_color -= 25; // set color to a darker value
- if ( shadow_color < 100 )
- shadow_color = 100;
- }
- else if ( ( angle > 2320 ) && ( angle < 5760 ) ) {
- shadow_color += 25; // set color to a brighter value
- if ( shadow_color > 255 )
- shadow_color = 255;
- }
- else {
- shadow_color -= 25; // set color to a darker value again
- if ( shadow_color < 100 )
- shadow_color = 100;
- } // end if ( angle < 2320 )
- } // end for ( angle = 720; angle < 6480; angle += 160 )
- paint.end();
- //
- // painting done
-
- QBitmap mask ( pix-> width ( ), pix-> height ( ), true );
- QPainter mp ( &mask );
- mp. setPen ( Qt::NoPen );
- mp. setBrush ( Qt::color1 );
- mp. drawEllipse ( 0, 0, width + 2, width + 2 );
- mp. end ( );
-
- pix-> setMask ( mask );
-#endif
-}
-
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 @@
-#ifndef __OPIE_OLED_H__
-#define __OPIE_OLED_H__
-
-#include <qwidget.h>
-#include <qcolor.h>
-
-class QPixmap;
-
-#define _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
-
-class OLedBox : public QWidget {
- Q_OBJECT
-
-public:
- OLedBox ( const QColor &col = red, QWidget *parent = 0, const char *name = 0 );
- virtual ~OLedBox ( );
-
- QColor color ( ) const;
- bool isOn ( ) const;
-
- virtual QSize sizeHint ( ) const;
-
-public slots:
- void toggle ( );
- void setOn ( bool on );
- void setColor ( const QColor &col );
-
-signals:
- void toggled ( bool );
-
-protected:
- virtual void paintEvent ( QPaintEvent *e );
- virtual void resizeEvent ( QResizeEvent *e );
-
- virtual void mousePressEvent ( QMouseEvent *e );
-
-private:
- void drawLed ( QPixmap *, const QColor &col );
-
-private:
- QPixmap *m_pix [2];
-
- QColor m_color;
- bool m_on;
-
-#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
- static QPixmap *s_border_pix;
-#endif
-};
-
-#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
@@ -21,4 +21,4 @@
#include "volume.h"
-#include "oledbox.h"
+#include <opie2/oledbox.h>
#include <opie2/odevice.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
@@ -3,3 +3,4 @@ CONFIG += qt plugin warn_on
HEADERS = volume.h oledbox.h
-SOURCES = volume.cpp oledbox.cpp
+#SOURCES = volume.cpp oledbox.cpp
+SOURCES = volume.cpp
TARGET = volumeapplet