author | mickeyl <mickeyl> | 2004-01-15 13:59:58 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-15 13:59:58 (UTC) |
commit | dde789ef19fa3a3913805e452ac1e3400688e8a0 (patch) (unidiff) | |
tree | a33a0ce31750ad56cfd3362585d4e7b32ca0a456 /libqtaux | |
parent | 3c74c5343a8432c494ace71d94cca354c01ef1d3 (diff) | |
download | opie-dde789ef19fa3a3913805e452ac1e3400688e8a0.zip opie-dde789ef19fa3a3913805e452ac1e3400688e8a0.tar.gz opie-dde789ef19fa3a3913805e452ac1e3400688e8a0.tar.bz2 |
more libopie1 --> libopie2 with namespace cleanups and code layout cleanups
-rw-r--r-- | libqtaux/libqtaux.pro | 6 | ||||
-rw-r--r-- | libqtaux/ocolorbutton.cpp | 150 | ||||
-rw-r--r-- | libqtaux/ocolorbutton.h | 80 | ||||
-rw-r--r-- | libqtaux/ocolorpopupmenu.cpp | 3 | ||||
-rw-r--r-- | libqtaux/ocolorpopupmenu.h | 11 |
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 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on debug | 2 | CONFIG += qte warn_on debug |
3 | 3 | ||
4 | HEADERS = qcolordialog.h \ | 4 | HEADERS = 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 | ||
11 | SOURCES = qcolordialog.cpp \ | 12 | SOURCES = 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 | ||
17 | TARGET = qtaux2 | 19 | TARGET = qtaux2 |
18 | INCLUDEPATH += $(OPIEDIR)/include | 20 | INCLUDEPATH += $(OPIEDIR)/include |
19 | DESTDIR = $(OPIEDIR)/lib | 21 | DESTDIR = $(OPIEDIR)/lib |
20 | INTERFACES = | 22 | INTERFACES = |
21 | 23 | ||
22 | 24 | ||
23 | include ( $(OPIEDIR)/include.pro ) | 25 | include ( $(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 | |||
41 | using namespace Opie; | ||
42 | |||
43 | struct 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 | */ | ||
57 | OColorButton::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 | */ | ||
77 | OColorButton::~OColorButton ( ) | ||
78 | { | ||
79 | delete d; | ||
80 | } | ||
81 | |||
82 | /** | ||
83 | * @return Returns the current color of the button | ||
84 | */ | ||
85 | QColor 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 | */ | ||
94 | void OColorButton::setColor ( const QColor &c ) | ||
95 | { | ||
96 | updateColor ( c ); | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * @internal | ||
101 | */ | ||
102 | void 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 | |||
36 | class OColorButtonPrivate; | ||
37 | class QColor; | ||
38 | |||
39 | namespace 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 | */ | ||
49 | class OColorButton : public QPushButton | ||
50 | { | ||
51 | Q_OBJECT | ||
52 | public: | ||
53 | OColorButton ( QWidget *parent = 0, const QColor & = black, const char *name = 0 ); | ||
54 | virtual ~OColorButton ( ); | ||
55 | |||
56 | QColor color ( ) const; | ||
57 | |||
58 | signals: | ||
59 | /** | ||
60 | * emitted when a color gets selected | ||
61 | */ | ||
62 | void colorSelected ( const QColor & ); | ||
63 | |||
64 | public slots: | ||
65 | virtual void setColor ( const QColor & ); | ||
66 | |||
67 | protected slots: | ||
68 | /** | ||
69 | * @internal | ||
70 | */ | ||
71 | virtual void updateColor ( const QColor & ); | ||
72 | |||
73 | private: | ||
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,103 +1,106 @@ | |||
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 | ||
41 | using namespace Opie; | ||
42 | |||
40 | OColorPanelButton::OColorPanelButton( const QColor& color, QWidget* parent, const char* name ) | 43 | OColorPanelButton::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 | ||
49 | OColorPanelButton::~OColorPanelButton() | 52 | OColorPanelButton::~OColorPanelButton() |
50 | { | 53 | { |
51 | } | 54 | } |
52 | 55 | ||
53 | void OColorPanelButton::setActive( bool active ) | 56 | void 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 | ||
64 | void OColorPanelButton::enterEvent( QEvent* ) | 67 | void 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 | ||
71 | void OColorPanelButton::leaveEvent( QEvent* ) | 74 | void 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 | ||
78 | void OColorPanelButton::paintEvent( QPaintEvent* e ) | 81 | void 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 | ||
90 | void OColorPanelButton::mouseReleaseEvent( QMouseEvent* ) | 93 | void OColorPanelButton::mouseReleaseEvent( QMouseEvent* ) |
91 | { | 94 | { |
92 | emit selected( m_color ); | 95 | emit selected( m_color ); |
93 | } | 96 | } |
94 | 97 | ||
95 | OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name ) | 98 | OColorPopupMenu::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 | ||
diff --git a/libqtaux/ocolorpopupmenu.h b/libqtaux/ocolorpopupmenu.h index 90cfbed..7ab3ca6 100644 --- a/libqtaux/ocolorpopupmenu.h +++ b/libqtaux/ocolorpopupmenu.h | |||
@@ -1,105 +1,110 @@ | |||
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 | ||
39 | class QWidget; | 41 | class QWidget; |
40 | class QGridLayout; | 42 | class QGridLayout; |
41 | 43 | ||
44 | namespace 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 | */ |
52 | class OColorPanelButton : public QFrame | 57 | class OColorPanelButton : public QFrame |
53 | { | 58 | { |
54 | Q_OBJECT | 59 | Q_OBJECT |
55 | 60 | ||
56 | public: | 61 | public: |
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. |
@@ -191,65 +196,67 @@ private: | |||
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 | ||
210 | signals: | 215 | signals: |
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 | ||
223 | protected slots: | 228 | protected 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 |