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
@@ -36,8 +36,16 @@
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 )
@@ -47,3 +55,3 @@ OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *n
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 );
@@ -59,2 +67,5 @@ OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *n
59 67
68/**
69 * This destructs the object
70 */
60OColorButton::~OColorButton ( ) 71OColorButton::~OColorButton ( )
@@ -64,2 +75,5 @@ OColorButton::~OColorButton ( )
64 75
76/**
77 * @return Returns the current color of the button
78 */
65QColor OColorButton::color ( ) const 79QColor OColorButton::color ( ) const
@@ -69,2 +83,6 @@ QColor OColorButton::color ( ) const
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 )
@@ -74,2 +92,5 @@ void OColorButton::setColor ( const QColor &c )
74 92
93/**
94 * @internal
95 */
75void OColorButton::updateColor ( const QColor &c ) 96void OColorButton::updateColor ( const QColor &c )
@@ -77,15 +98,15 @@ void OColorButton::updateColor ( const QColor &c )
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++ ) {
@@ -102,3 +123,3 @@ void OColorButton::updateColor ( const QColor &c )
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 );
@@ -116,3 +137,3 @@ void OColorButton::updateColor ( const QColor &c )
116 pix. convertFromImage ( img ); 137 pix. convertFromImage ( img );
117 setPixmap ( pix ); 138 setPixmap ( pix );
118 139