summaryrefslogtreecommitdiff
path: root/libqtaux
Unidiff
Diffstat (limited to 'libqtaux') (more/less context) (ignore whitespace changes)
-rw-r--r--libqtaux/libqtaux.pro6
-rw-r--r--libqtaux/ocolorbutton.cpp150
-rw-r--r--libqtaux/ocolorbutton.h80
-rw-r--r--libqtaux/ocolorpopupmenu.cpp3
-rw-r--r--libqtaux/ocolorpopupmenu.h11
5 files changed, 246 insertions, 4 deletions
diff --git a/libqtaux/libqtaux.pro b/libqtaux/libqtaux.pro
index 2f7aa91..56ccc65 100644
--- a/libqtaux/libqtaux.pro
+++ b/libqtaux/libqtaux.pro
@@ -1,23 +1,25 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qte warn_on debug 2CONFIG += qte warn_on debug
3 3
4HEADERS = qcolordialog.h \ 4HEADERS = qcolordialog.h \
5 qsplitter.h \ 5 qsplitter.h \
6 qinputdialog.h \ 6 qinputdialog.h \
7 \ 7 \
8 ocolorpopupmenu.h 8 ocolorpopupmenu.h \
9 ocolorbutton.h
9 10
10 11
11SOURCES = qcolordialog.cpp \ 12SOURCES = qcolordialog.cpp \
12 qsplitter.cpp \ 13 qsplitter.cpp \
13 qinputdialog.cpp \ 14 qinputdialog.cpp \
14 \ 15 \
15 ocolorpopupmenu.cpp 16 ocolorpopupmenu.cpp \
17 ocolorbutton.cpp
16 18
17TARGET = qtaux2 19TARGET = qtaux2
18INCLUDEPATH += $(OPIEDIR)/include 20INCLUDEPATH += $(OPIEDIR)/include
19DESTDIR = $(OPIEDIR)/lib 21DESTDIR = $(OPIEDIR)/lib
20INTERFACES = 22INTERFACES =
21 23
22 24
23include ( $(OPIEDIR)/include.pro ) 25include ( $(OPIEDIR)/include.pro )
diff --git a/libqtaux/ocolorbutton.cpp b/libqtaux/ocolorbutton.cpp
new file mode 100644
index 0000000..d2ad873
--- a/dev/null
+++ b/libqtaux/ocolorbutton.cpp
@@ -0,0 +1,150 @@
1/*
2 This file is part of the Opie Project
3 Copyright (C) Robert Griebl <sandman@handhelds.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#include "ocolorpopupmenu.h"
31#include "ocolorbutton.h"
32
33/* OPIE */
34#include <qpe/resource.h>
35
36/* QT */
37#include <qcolor.h>
38#include <qpixmap.h>
39#include <qimage.h>
40
41using namespace Opie;
42
43struct OColorButtonPrivate
44{
45 QPopupMenu *m_menu;
46 QColor m_color;
47};
48
49/**
50 * This concstructs a Color Button with @param color as the start color
51 * It'll use a OColorPopupMenu internally
52 *
53 * @param parent The parent of the Color Button
54 * @param color The color from where to start on
55 * @param name @see QObject
56 */
57OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name )
58 : QPushButton ( parent, name )
59{
60 d = new OColorButtonPrivate;
61
62 d-> m_menu = new OColorPopupMenu ( color, 0, 0 );
63 setPopup ( d-> m_menu );
64 //setPopupDelay ( 0 );
65 connect ( d-> m_menu, SIGNAL( colorSelected ( const QColor & )), this, SLOT( updateColor ( const QColor & )));
66
67 updateColor ( color );
68
69 QSize s = sizeHint ( ) + QSize ( 12, 0 );
70 setMinimumSize ( s );
71 setMaximumSize ( s. width ( ) * 2, s. height ( ));
72}
73
74/**
75 * This destructs the object
76 */
77OColorButton::~OColorButton ( )
78{
79 delete d;
80}
81
82/**
83 * @return Returns the current color of the button
84 */
85QColor OColorButton::color ( ) const
86{
87 return d-> m_color;
88}
89
90/**
91 * This method sets the color of the button
92 * @param c The color to be set.
93 */
94void OColorButton::setColor ( const QColor &c )
95{
96 updateColor ( c );
97}
98
99/**
100 * @internal
101 */
102void OColorButton::updateColor ( const QColor &c )
103{
104 d-> m_color = c;
105
106 QImage img ( 16, 16, 32 );
107 img. fill ( 0 );
108
109 int r, g, b;
110 c. rgb ( &r, &g, &b );
111
112 int w = img. width ( );
113 int h = img. height ( );
114
115 int dx = w * 20 / 100; // 15%
116 int dy = h * 20 / 100;
117
118 for ( int y = 0; y < h; y++ )
119 {
120 for ( int x = 0; x < w; x++ )
121 {
122 double alpha = 1.0;
123
124 if ( x < dx )
125 alpha *= ( double ( x + 1 ) / dx );
126 else if ( x >= w - dx )
127 alpha *= ( double ( w - x ) / dx );
128 if ( y < dy )
129 alpha *= ( double ( y + 1 ) / dy );
130 else if ( y >= h - dy )
131 alpha *= ( double ( h - y ) / dy );
132
133 int a = int ( alpha * 255.0 );
134 if ( a < 0 )
135 a = 0;
136 if ( a > 255 )
137 a = 255;
138
139 img. setPixel ( x, y, qRgba ( r, g, b, a ));
140 }
141 }
142 img. setAlphaBuffer ( true );
143
144 QPixmap pix;
145 pix. convertFromImage ( img );
146 setPixmap ( pix );
147
148 emit colorSelected ( c );
149}
150
diff --git a/libqtaux/ocolorbutton.h b/libqtaux/ocolorbutton.h
new file mode 100644
index 0000000..ca68f1f
--- a/dev/null
+++ b/libqtaux/ocolorbutton.h
@@ -0,0 +1,80 @@
1/*
2 This file is part of the Opie Project
3 Copyright (C) Robert Griebl <sandman@handhelds.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#ifndef OCOLORBUTTON_H
31#define OCOLORBUTTON_H
32
33/* QT*/
34#include <qpushbutton.h>
35
36class OColorButtonPrivate;
37class QColor;
38
39namespace Opie
40{
41
42/**
43 *
44 * @short A Button which will show a OColorPopupMenu
45 * @author Robert Griebl ( sandman@handhelds.org )
46 * @version 1.0
47 * @see QPushButton
48 */
49class OColorButton : public QPushButton
50{
51 Q_OBJECT
52public:
53 OColorButton ( QWidget *parent = 0, const QColor & = black, const char *name = 0 );
54 virtual ~OColorButton ( );
55
56 QColor color ( ) const;
57
58signals:
59 /**
60 * emitted when a color gets selected
61 */
62 void colorSelected ( const QColor & );
63
64public slots:
65 virtual void setColor ( const QColor & );
66
67protected slots:
68 /**
69 * @internal
70 */
71 virtual void updateColor ( const QColor & );
72
73private:
74 OColorButtonPrivate *d;
75};
76
77};
78
79#endif
80
diff --git a/libqtaux/ocolorpopupmenu.cpp b/libqtaux/ocolorpopupmenu.cpp
index 6a2321e..6c5f99c 100644
--- a/libqtaux/ocolorpopupmenu.cpp
+++ b/libqtaux/ocolorpopupmenu.cpp
@@ -1,135 +1,138 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net> 4              Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net>
5              Dan Williams <williamsdr@acm.org> 5              Dan Williams <williamsdr@acm.org>
6 =. 6 =.
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30 30
31*/ 31*/
32 32
33#include "ocolorpopupmenu.h" 33#include "ocolorpopupmenu.h"
34#include "qcolordialog.h" 34#include "qcolordialog.h"
35 35
36/* QT */
36#include <qaction.h> 37#include <qaction.h>
37#include <qlayout.h> 38#include <qlayout.h>
38#include <qpainter.h> 39#include <qpainter.h>
39 40
41using namespace Opie;
42
40OColorPanelButton::OColorPanelButton( const QColor& color, QWidget* parent, const char* name ) 43OColorPanelButton::OColorPanelButton( const QColor& color, QWidget* parent, const char* name )
41 : QFrame( parent, name ) 44 : QFrame( parent, name )
42{ 45{
43 m_color = color; 46 m_color = color;
44 47
45 setFixedSize( 16, 16 ); 48 setFixedSize( 16, 16 );
46 setActive( FALSE ); 49 setActive( FALSE );
47} 50}
48 51
49OColorPanelButton::~OColorPanelButton() 52OColorPanelButton::~OColorPanelButton()
50{ 53{
51} 54}
52 55
53void OColorPanelButton::setActive( bool active ) 56void OColorPanelButton::setActive( bool active )
54{ 57{
55 m_active = active; 58 m_active = active;
56 59
57 if ( m_active ) { 60 if ( m_active ) {
58 setFrameStyle( Panel | Sunken ); 61 setFrameStyle( Panel | Sunken );
59 } else { 62 } else {
60 setFrameStyle( NoFrame ); 63 setFrameStyle( NoFrame );
61 } 64 }
62} 65}
63 66
64void OColorPanelButton::enterEvent( QEvent* ) 67void OColorPanelButton::enterEvent( QEvent* )
65{ 68{
66 if ( !m_active ) { 69 if ( !m_active ) {
67 setFrameStyle( Panel | Sunken ); 70 setFrameStyle( Panel | Sunken );
68 } 71 }
69} 72}
70 73
71void OColorPanelButton::leaveEvent( QEvent* ) 74void OColorPanelButton::leaveEvent( QEvent* )
72{ 75{
73 if ( !m_active ) { 76 if ( !m_active ) {
74 setFrameStyle( NoFrame ); 77 setFrameStyle( NoFrame );
75 } 78 }
76} 79}
77 80
78void OColorPanelButton::paintEvent( QPaintEvent* e ) 81void OColorPanelButton::paintEvent( QPaintEvent* e )
79{ 82{
80 QFrame::paintEvent( e ); 83 QFrame::paintEvent( e );
81 84
82 QPainter painter; 85 QPainter painter;
83 painter.begin( this ); 86 painter.begin( this );
84 painter.fillRect( 2, 2, 12, 12, m_color ); 87 painter.fillRect( 2, 2, 12, 12, m_color );
85 painter.setPen( Qt::black ); 88 painter.setPen( Qt::black );
86 painter.drawRect( 2, 2, 12, 12 ); 89 painter.drawRect( 2, 2, 12, 12 );
87 painter.end(); 90 painter.end();
88} 91}
89 92
90void OColorPanelButton::mouseReleaseEvent( QMouseEvent* ) 93void OColorPanelButton::mouseReleaseEvent( QMouseEvent* )
91{ 94{
92 emit selected( m_color ); 95 emit selected( m_color );
93} 96}
94 97
95OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name ) 98OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name )
96 : QPopupMenu( parent, name ) 99 : QPopupMenu( parent, name )
97{ 100{
98 m_color = color; 101 m_color = color;
99 102
100 colorPanel = new QWidget( this ); 103 colorPanel = new QWidget( this );
101 104
102 colorLayout = new QGridLayout(colorPanel, 5, 6); 105 colorLayout = new QGridLayout(colorPanel, 5, 6);
103 106
104 addColor(QColor(255, 255, 255), 0, 1); 107 addColor(QColor(255, 255, 255), 0, 1);
105 addColor(QColor(192, 192, 192), 0, 2); 108 addColor(QColor(192, 192, 192), 0, 2);
106 addColor(QColor(128, 128, 128), 0, 3); 109 addColor(QColor(128, 128, 128), 0, 3);
107 addColor(QColor(64, 64, 64), 0, 4); 110 addColor(QColor(64, 64, 64), 0, 4);
108 addColor(QColor(0, 0, 0), 0, 5); 111 addColor(QColor(0, 0, 0), 0, 5);
109 112
110 addColor(QColor(255, 0, 0), 1, 0); 113 addColor(QColor(255, 0, 0), 1, 0);
111 addColor(QColor(255, 128, 0), 1, 1); 114 addColor(QColor(255, 128, 0), 1, 1);
112 addColor(QColor(255, 255, 0), 1, 2); 115 addColor(QColor(255, 255, 0), 1, 2);
113 addColor(QColor(128, 255, 0), 1, 3); 116 addColor(QColor(128, 255, 0), 1, 3);
114 addColor(QColor(0, 255, 0), 1, 4); 117 addColor(QColor(0, 255, 0), 1, 4);
115 addColor(QColor(0, 255, 128), 1, 5); 118 addColor(QColor(0, 255, 128), 1, 5);
116 119
117 addColor(QColor(128, 0, 0), 2, 0); 120 addColor(QColor(128, 0, 0), 2, 0);
118 addColor(QColor(128, 64, 0), 2, 1); 121 addColor(QColor(128, 64, 0), 2, 1);
119 addColor(QColor(128, 128, 0), 2, 2); 122 addColor(QColor(128, 128, 0), 2, 2);
120 addColor(QColor(64, 128, 0), 2, 3); 123 addColor(QColor(64, 128, 0), 2, 3);
121 addColor(QColor(0, 128, 0), 2, 4); 124 addColor(QColor(0, 128, 0), 2, 4);
122 addColor(QColor(0, 128, 64), 2, 5); 125 addColor(QColor(0, 128, 64), 2, 5);
123 126
124 addColor(QColor(0, 255, 255), 3, 0); 127 addColor(QColor(0, 255, 255), 3, 0);
125 addColor(QColor(0, 128, 255), 3, 1); 128 addColor(QColor(0, 128, 255), 3, 1);
126 addColor(QColor(0, 0, 255), 3, 2); 129 addColor(QColor(0, 0, 255), 3, 2);
127 addColor(QColor(128, 0, 255), 3, 3); 130 addColor(QColor(128, 0, 255), 3, 3);
128 addColor(QColor(255, 0, 255), 3, 4); 131 addColor(QColor(255, 0, 255), 3, 4);
129 addColor(QColor(255, 0, 128), 3, 5); 132 addColor(QColor(255, 0, 128), 3, 5);
130 133
131 addColor(QColor(0, 128, 128), 4, 0); 134 addColor(QColor(0, 128, 128), 4, 0);
132 addColor(QColor(0, 64, 128), 4, 1); 135 addColor(QColor(0, 64, 128), 4, 1);
133 addColor(QColor(0, 0, 128), 4, 2); 136 addColor(QColor(0, 0, 128), 4, 2);
134 addColor(QColor(64, 0, 128), 4, 3); 137 addColor(QColor(64, 0, 128), 4, 3);
135 addColor(QColor(128, 0, 128), 4, 4); 138 addColor(QColor(128, 0, 128), 4, 4);
diff --git a/libqtaux/ocolorpopupmenu.h b/libqtaux/ocolorpopupmenu.h
index 90cfbed..7ab3ca6 100644
--- a/libqtaux/ocolorpopupmenu.h
+++ b/libqtaux/ocolorpopupmenu.h
@@ -1,137 +1,142 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net> 4              Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net>
5              Dan Williams <williamsdr@acm.org> 5              Dan Williams <williamsdr@acm.org>
6 =. 6 =.
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30 30
31*/ 31*/
32 32
33#ifndef COLORPOPUPMENU_H 33#ifndef OCOLORPOPUPMENU_H
34#define COLORPOPUPMENU_H 34#define OCOLORPOPUPMENU_H
35
36/* QT */
35 37
36#include <qframe.h> 38#include <qframe.h>
37#include <qpopupmenu.h> 39#include <qpopupmenu.h>
38 40
39class QWidget; 41class QWidget;
40class QGridLayout; 42class QGridLayout;
41 43
44namespace Opie
45{
46
42/** 47/**
43 * @class OColorPanelButton 48 * @class OColorPanelButton
44 * @brief The OColorPanelButton class provides a button for color selection. 49 * @brief The OColorPanelButton class provides a button for color selection.
45 * 50 *
46 * @see OColorPopupMenu 51 * @see OColorPopupMenu
47 * 52 *
48 * The OColorPanelButton class provides a button for color selection. The button 53 * The OColorPanelButton class provides a button for color selection. The button
49 * is drawn with the desired color and no border. This class is used internally 54 * is drawn with the desired color and no border. This class is used internally
50 * by the OColorPopupMenu class to displaying colors in its menu. 55 * by the OColorPopupMenu class to displaying colors in its menu.
51 */ 56 */
52class OColorPanelButton : public QFrame 57class OColorPanelButton : public QFrame
53{ 58{
54 Q_OBJECT 59 Q_OBJECT
55 60
56public: 61public:
57 62
58/** 63/**
59 * @fn OColorPanelButton( const QColor& color, QWidget* parent = 0, const char* name = 0 ) 64 * @fn OColorPanelButton( const QColor& color, QWidget* parent = 0, const char* name = 0 )
60 * @brief Object constructor. 65 * @brief Object constructor.
61 * 66 *
62 * @param color Desired color. 67 * @param color Desired color.
63 * @param parent Pointer to parent of this control. 68 * @param parent Pointer to parent of this control.
64 * @param name Name of control. 69 * @param name Name of control.
65 * 70 *
66 * Constructs a new ColorPanelButton control with parent, name and desired color. 71 * Constructs a new ColorPanelButton control with parent, name and desired color.
67 */ 72 */
68 OColorPanelButton(const QColor& color, QWidget* parent = 0, const char* name = 0); 73 OColorPanelButton(const QColor& color, QWidget* parent = 0, const char* name = 0);
69 74
70/** 75/**
71 * @fn ~OColorPanelButton() 76 * @fn ~OColorPanelButton()
72 * @brief Object destructor. 77 * @brief Object destructor.
73 */ 78 */
74 ~OColorPanelButton(); 79 ~OColorPanelButton();
75 80
76/** 81/**
77 * @fn setActive( bool active ) 82 * @fn setActive( bool active )
78 * @brief Sets button selection state. 83 * @brief Sets button selection state.
79 * 84 *
80 * @param active Boolean indicator of new button state. 85 * @param active Boolean indicator of new button state.
81 * 86 *
82 * Changes button selection state. If button is selected, a highlighted border 87 * Changes button selection state. If button is selected, a highlighted border
83 * is drawn. 88 * is drawn.
84 */ 89 */
85 void setActive(bool active); 90 void setActive(bool active);
86 91
87/** 92/**
88 * @fn enterEvent( QEvent* e ) 93 * @fn enterEvent( QEvent* e )
89 * @brief Reimplemented for internal reasons. 94 * @brief Reimplemented for internal reasons.
90 * 95 *
91 * @param e Event currently being processed. 96 * @param e Event currently being processed.
92 * 97 *
93 * Reimplemented to ensure correct display of button based on whether it is 98 * Reimplemented to ensure correct display of button based on whether it is
94 * active or not. 99 * active or not.
95 */ 100 */
96 void enterEvent(QEvent* e); 101 void enterEvent(QEvent* e);
97 102
98/** 103/**
99 * @fn leaveEvent( QEvent* e ) 104 * @fn leaveEvent( QEvent* e )
100 * @brief Reimplemented for internal reasons. 105 * @brief Reimplemented for internal reasons.
101 * 106 *
102 * @param e Event currently being processed. 107 * @param e Event currently being processed.
103 * 108 *
104 * Reimplemented to ensure correct display of button based on whether it is 109 * Reimplemented to ensure correct display of button based on whether it is
105 * active or not. 110 * active or not.
106 */ 111 */
107 void leaveEvent(QEvent* e); 112 void leaveEvent(QEvent* e);
108 113
109/** 114/**
110 * @fn paintEvent( QPaintEvent* e ) 115 * @fn paintEvent( QPaintEvent* e )
111 * @brief Reimplemented for internal reasons. 116 * @brief Reimplemented for internal reasons.
112 * 117 *
113 * @param e Event currently being processed. 118 * @param e Event currently being processed.
114 * @reimp 119 * @reimp
115 * Reimplemented to ensure correct display of button. 120 * Reimplemented to ensure correct display of button.
116 */ 121 */
117 void paintEvent(QPaintEvent* e); 122 void paintEvent(QPaintEvent* e);
118 123
119/** 124/**
120 * @fn mouseReleaseEvent( QMouseEvent* e ) 125 * @fn mouseReleaseEvent( QMouseEvent* e )
121 * @brief Slot executed when button is pressed. 126 * @brief Slot executed when button is pressed.
122 * 127 *
123 * @param e Mouse event currently being processed. 128 * @param e Mouse event currently being processed.
124 * 129 *
125 * @see selected() 130 * @see selected()
126 * 131 *
127 * This slot executes when the button has been pressed. It emits the selected 132 * This slot executes when the button has been pressed. It emits the selected
128 * signal as notification that it has been pressed. 133 * signal as notification that it has been pressed.
129 */ 134 */
130 void mouseReleaseEvent(QMouseEvent* e); 135 void mouseReleaseEvent(QMouseEvent* e);
131 136
132signals: 137signals:
133 138
134/** 139/**
135 * @fn selected( const QColor& color ) 140 * @fn selected( const QColor& color )
136 * @brief Signal to indicate button has been pressed. 141 * @brief Signal to indicate button has been pressed.
137 * 142 *
@@ -159,97 +164,99 @@ private:
159 * such as a toolbar button of menu item. 164 * such as a toolbar button of menu item.
160 * 165 *
161 * The popup menu displays 30 default colors available in a grid, and also 166 * The popup menu displays 30 default colors available in a grid, and also
162 * includes an option at the bottom to display a color selection dialog box for 167 * includes an option at the bottom to display a color selection dialog box for
163 * finer color control. 168 * finer color control.
164 */ 169 */
165class OColorPopupMenu : public QPopupMenu 170class OColorPopupMenu : public QPopupMenu
166{ 171{
167 Q_OBJECT 172 Q_OBJECT
168 173
169public: 174public:
170 175
171/** 176/**
172 * @fn OColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 ) 177 * @fn OColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 )
173 * @brief Object constructor. 178 * @brief Object constructor.
174 * 179 *
175 * @param color Initial color selected in menu. 180 * @param color Initial color selected in menu.
176 * @param parent Pointer to parent of this control. 181 * @param parent Pointer to parent of this control.
177 * @param name Name of control. 182 * @param name Name of control.
178 * 183 *
179 * Constructs a new OColorPopupMenu control with parent, name and initial color selected. 184 * Constructs a new OColorPopupMenu control with parent, name and initial color selected.
180 */ 185 */
181 // FIXME add Wflags? -zecke 186 // FIXME add Wflags? -zecke
182 OColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 ); 187 OColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 );
183 188
184/** 189/**
185 * @fn ~OColorPopupMenu() 190 * @fn ~OColorPopupMenu()
186 * @brief Object destructor. 191 * @brief Object destructor.
187 */ 192 */
188 ~OColorPopupMenu(); 193 ~OColorPopupMenu();
189 194
190private: 195private:
191 class ColorPopupMenuPrivate; 196 class ColorPopupMenuPrivate;
192 ColorPopupMenuPrivate *d; 197 ColorPopupMenuPrivate *d;
193 QColor m_color; 198 QColor m_color;
194 QWidget* colorPanel; 199 QWidget* colorPanel;
195 QGridLayout* colorLayout; 200 QGridLayout* colorLayout;
196 201
197/** 202/**
198 * @fn addColor( const QColor& color, int row, int col ) 203 * @fn addColor( const QColor& color, int row, int col )
199 * @brief Adds color selection option to popup menu. 204 * @brief Adds color selection option to popup menu.
200 * 205 *
201 * @param color Color to be displayed in menu. 206 * @param color Color to be displayed in menu.
202 * @param row Row where color is to appear in menu. 207 * @param row Row where color is to appear in menu.
203 * @param col Column where color is to appear in menu. 208 * @param col Column where color is to appear in menu.
204 * 209 *
205 * Adds a color selection option to popup menu. Used internally when 210 * Adds a color selection option to popup menu. Used internally when
206 * initially constructing the menu control. 211 * initially constructing the menu control.
207 */ 212 */
208 void addColor( const QColor& color, int row, int col ); 213 void addColor( const QColor& color, int row, int col );
209 214
210signals: 215signals:
211 216
212/** 217/**
213 * @fn colorSelected( const QColor& color ) 218 * @fn colorSelected( const QColor& color )
214 * @brief Signal to indicate color chosen from the menu. 219 * @brief Signal to indicate color chosen from the menu.
215 * 220 *
216 * @param color Color selected from the menu. 221 * @param color Color selected from the menu.
217 * 222 *
218 * This signal is emitted when a color has been selected either directly from 223 * This signal is emitted when a color has been selected either directly from
219 * the menu, or chosen from the color selection dialog. 224 * the menu, or chosen from the color selection dialog.
220 */ 225 */
221 void colorSelected( const QColor& color ); 226 void colorSelected( const QColor& color );
222 227
223protected slots: 228protected slots:
224 229
225/** 230/**
226 * @fn buttonSelected( const QColor& color ) 231 * @fn buttonSelected( const QColor& color )
227 * @brief Slot to process selected color. 232 * @brief Slot to process selected color.
228 * 233 *
229 * @param color Color selected from the menu. 234 * @param color Color selected from the menu.
230 * 235 *
231 * @see colorSelected() 236 * @see colorSelected()
232 * 237 *
233 * This slot executes when a color has been selected from the menu. It performs 238 * This slot executes when a color has been selected from the menu. It performs
234 * two functions: 239 * two functions:
235 * - Emit the colorSelected signal with the color selected. 240 * - Emit the colorSelected signal with the color selected.
236 * - Hide the menu. 241 * - Hide the menu.
237 */ 242 */
238 void buttonSelected( const QColor& color ); 243 void buttonSelected( const QColor& color );
239 244
240/** 245/**
241 * @fn moreColorClicked() 246 * @fn moreColorClicked()
242 * @brief Slot to process display color selection dialog. 247 * @brief Slot to process display color selection dialog.
243 * 248 *
244 * @see colorSelected() 249 * @see colorSelected()
245 * 250 *
246 * This slot executes when the 'More...' option is selected at the bottom of the menu. 251 * This slot executes when the 'More...' option is selected at the bottom of the menu.
247 * It performs the following functions: 252 * It performs the following functions:
248 * - Constructs and executes a QColorDialog to allow finer color selection. 253 * - Constructs and executes a QColorDialog to allow finer color selection.
249 * - Emit the colorSelected signal with the color selected. 254 * - Emit the colorSelected signal with the color selected.
250 * - Hide the menu. 255 * - Hide the menu.
251 */ 256 */
252 void moreColorClicked(); 257 void moreColorClicked();
253}; 258};
254 259
260};
261
255#endif // COLORPOPUPMENUANEL_H 262#endif // COLORPOPUPMENUANEL_H