summaryrefslogtreecommitdiff
path: root/libopie/ocolorbutton.cpp
Unidiff
Diffstat (limited to 'libopie/ocolorbutton.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ocolorbutton.cpp45
1 files changed, 33 insertions, 12 deletions
diff --git a/libopie/ocolorbutton.cpp b/libopie/ocolorbutton.cpp
index ddb6c4f..113a77a 100644
--- a/libopie/ocolorbutton.cpp
+++ b/libopie/ocolorbutton.cpp
@@ -35,10 +35,18 @@
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36 36
37class OColorButtonPrivate { 37struct OColorButtonPrivate {
38public: 38 QPopupMenu *m_menu;
39 QPopupMenu *m_menu; 39 QColor m_color;
40 QColor m_color;
41}; 40};
42 41
42
43/**
44 * This concstructs a Color Button with @param color as the start color
45 * It'll use a OColorPopupMenu internally
46 *
47 * @param parent The parent of the Color Button
48 * @param color The color from where to start on
49 * @param name @see QObject
50 */
43OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name ) 51OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name )
44 : QPushButton ( parent, name ) 52 : QPushButton ( parent, name )
@@ -46,5 +54,5 @@ OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *n
46 d = new OColorButtonPrivate; 54 d = new OColorButtonPrivate;
47 55
48 d-> m_menu = new ColorPopupMenu ( color, 0, 0 ); 56 d-> m_menu = new OColorPopupMenu ( color, 0, 0 );
49 setPopup ( d-> m_menu ); 57 setPopup ( d-> m_menu );
50 //setPopupDelay ( 0 ); 58 //setPopupDelay ( 0 );
@@ -58,4 +66,7 @@ OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *n
58} 66}
59 67
68/**
69 * This destructs the object
70 */
60OColorButton::~OColorButton ( ) 71OColorButton::~OColorButton ( )
61{ 72{
@@ -63,4 +74,7 @@ OColorButton::~OColorButton ( )
63} 74}
64 75
76/**
77 * @return Returns the current color of the button
78 */
65QColor OColorButton::color ( ) const 79QColor OColorButton::color ( ) const
66{ 80{
@@ -68,4 +82,8 @@ QColor OColorButton::color ( ) const
68} 82}
69 83
84/**
85 * This method sets the color of the button
86 * @param c The color to be set.
87 */
70void OColorButton::setColor ( const QColor &c ) 88void OColorButton::setColor ( const QColor &c )
71{ 89{
@@ -73,20 +91,23 @@ void OColorButton::setColor ( const QColor &c )
73} 91}
74 92
93/**
94 * @internal
95 */
75void OColorButton::updateColor ( const QColor &c ) 96void OColorButton::updateColor ( const QColor &c )
76{ 97{
77 d-> m_color = c; 98 d-> m_color = c;
78 99
79 QImage img ( 16, 16, 32 ); 100 QImage img ( 16, 16, 32 );
80 img. fill ( 0 ); 101 img. fill ( 0 );
81 102
82 int r, g, b; 103 int r, g, b;
83 c. rgb ( &r, &g, &b ); 104 c. rgb ( &r, &g, &b );
84 105
85 int w = img. width ( ); 106 int w = img. width ( );
86 int h = img. height ( ); 107 int h = img. height ( );
87 108
88 int dx = w * 20 / 100; // 15% 109 int dx = w * 20 / 100; // 15%
89 int dy = h * 20 / 100; 110 int dy = h * 20 / 100;
90 111
91 for ( int y = 0; y < h; y++ ) { 112 for ( int y = 0; y < h; y++ ) {
92 for ( int x = 0; x < w; x++ ) { 113 for ( int x = 0; x < w; x++ ) {
@@ -101,5 +122,5 @@ void OColorButton::updateColor ( const QColor &c )
101 else if ( y >= h - dy ) 122 else if ( y >= h - dy )
102 alpha *= ( double ( h - y ) / dy ); 123 alpha *= ( double ( h - y ) / dy );
103 124
104 int a = int ( alpha * 255.0 ); 125 int a = int ( alpha * 255.0 );
105 if ( a < 0 ) 126 if ( a < 0 )
@@ -115,5 +136,5 @@ void OColorButton::updateColor ( const QColor &c )
115 QPixmap pix; 136 QPixmap pix;
116 pix. convertFromImage ( img ); 137 pix. convertFromImage ( img );
117 setPixmap ( pix ); 138 setPixmap ( pix );
118 139
119 emit colorSelected ( c ); 140 emit colorSelected ( c );