summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/colordialog.h12
-rw-r--r--libopie/colorpopupmenu.cpp51
-rw-r--r--libopie/colorpopupmenu.h213
3 files changed, 236 insertions, 40 deletions
diff --git a/libopie/colordialog.h b/libopie/colordialog.h
index 474bc61..926f8f2 100644
--- a/libopie/colordialog.h
+++ b/libopie/colordialog.h
@@ -1,77 +1,89 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of OColorDialog class 4** Definition of OColorDialog class
5** 5**
6** Created : 990222 6** Created : 990222
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the dialogs module of the Qt GUI Toolkit. 10** This file is part of the dialogs module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef OColorDialog_H 38#ifndef OColorDialog_H
39#define OColorDialog_H 39#define OColorDialog_H
40 40
41#ifndef QT_H 41#ifndef QT_H
42#include <qdialog.h> 42#include <qdialog.h>
43#endif // QT_H 43#endif // QT_H
44 44
45class OColorDialogPrivate; 45class OColorDialogPrivate;
46 46
47/**
48 * @class OColorDialog
49 * @brief The OColorDialog class is a copy of QColorDialog for use in Opie.
50 *
51 * OColorDialog is a copy of TrollTech's QColorDialog for use in Opie. The default
52 * build of QT/Embedded used by Opie does not include QColorDialog, so it is provided
53 * here. It is renamed to prevent conflicts in the event the QColorDialog is included
54 * at a later date in QP/E.
55 *
56 * See http://doc.trolltech.com/2.3/qcolordialog.html for complete documentation of
57 * QColorDialog.
58 */
47class Q_EXPORT OColorDialog : public QDialog 59class Q_EXPORT OColorDialog : public QDialog
48{ 60{
49 Q_OBJECT 61 Q_OBJECT
50 62
51public: 63public:
52 static QColor getColor( QColor, QWidget *parent=0, const char* name=0 ); // ### 3.0: make const QColor& 64 static QColor getColor( QColor, QWidget *parent=0, const char* name=0 ); // ### 3.0: make const QColor&
53 static QRgb getRgba( QRgb, bool* ok = 0, 65 static QRgb getRgba( QRgb, bool* ok = 0,
54 QWidget *parent=0, const char* name=0 ); 66 QWidget *parent=0, const char* name=0 );
55 67
56private: 68private:
57 ~OColorDialog(); 69 ~OColorDialog();
58 70
59 OColorDialog( QWidget* parent=0, const char* name=0, bool modal=FALSE ); 71 OColorDialog( QWidget* parent=0, const char* name=0, bool modal=FALSE );
60 void setColor( QColor ); // ### 3.0: make const QColor& 72 void setColor( QColor ); // ### 3.0: make const QColor&
61 QColor color() const; 73 QColor color() const;
62 74
63private: 75private:
64 void setSelectedAlpha( int ); 76 void setSelectedAlpha( int );
65 int selectedAlpha() const; 77 int selectedAlpha() const;
66private: 78private:
67 OColorDialogPrivate *d; 79 OColorDialogPrivate *d;
68 friend class OColorDialogPrivate; 80 friend class OColorDialogPrivate;
69 81
70 private:// Disabled copy constructor and operator= 82 private:// Disabled copy constructor and operator=
71#if defined(Q_DISABLE_COPY) 83#if defined(Q_DISABLE_COPY)
72 OColorDialog( const OColorDialog & ); 84 OColorDialog( const OColorDialog & );
73 OColorDialog& operator=( const OColorDialog & ); 85 OColorDialog& operator=( const OColorDialog & );
74#endif 86#endif
75}; 87};
76 88
77#endif 89#endif
diff --git a/libopie/colorpopupmenu.cpp b/libopie/colorpopupmenu.cpp
index 17e2c0a..510a2ad 100644
--- a/libopie/colorpopupmenu.cpp
+++ b/libopie/colorpopupmenu.cpp
@@ -1,68 +1,79 @@
1/********************************************************************** 1/*
2** ColorPopupMenu 2                This file is part of the Opie Project
3** 3
4** Popup menu for selecting colors 4              Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net>
5** 5              Dan Williams <williamsdr@acm.org>
6** Based on colorpanel by S. Prud'homme <prudhomme@laposte.net> 6 =.
7** 7 .=l.
8** Copyright (C) 2002, Dan Williams 8           .>+-=
9** williamsdr@acm.org 9 _;:,     .>    :=|. This program is free software; you can
10** http://draknor.net 10.> <`_,   >  .   <= redistribute it and/or modify it under
11** 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12** This file may be distributed and/or modified under the terms of the 12.="- .-=="i,     .._ License as published by the Free Software
13** GNU General Public License version 2 as published by the Free Software 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14** Foundation and appearing in the file LICENSE.GPL included in the 14     ._= =}       : or (at your option) any later version.
15** packaging of this file. 15    .%`+i>       _;_.
16** 16    .i_,=:_.      -<s. This program is distributed in the hope that
17** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 18    : ..    .:,     . . . without even the implied warranty of
19** 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20**********************************************************************/ 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details.
23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA.
30
31*/
21 32
22#include "colorpopupmenu.h" 33#include "colorpopupmenu.h"
23#include "colordialog.h" 34#include "colordialog.h"
24 35
25#include <qaction.h> 36#include <qaction.h>
26#include <qlayout.h> 37#include <qlayout.h>
27#include <qpainter.h> 38#include <qpainter.h>
28 39
29ColorPanelButton::ColorPanelButton( const QColor& color, QWidget* parent, const char* name ) 40ColorPanelButton::ColorPanelButton( const QColor& color, QWidget* parent, const char* name )
30 : QFrame( parent, name ) 41 : QFrame( parent, name )
31{ 42{
32 m_color = color; 43 m_color = color;
33 44
34 setFixedSize( 16, 16 ); 45 setFixedSize( 16, 16 );
35 setActive( FALSE ); 46 setActive( FALSE );
36} 47}
37 48
38ColorPanelButton::~ColorPanelButton() 49ColorPanelButton::~ColorPanelButton()
39{ 50{
40} 51}
41 52
42void ColorPanelButton::setActive( bool active ) 53void ColorPanelButton::setActive( bool active )
43{ 54{
44 m_active = active; 55 m_active = active;
45 56
46 if ( m_active ) { 57 if ( m_active ) {
47 setFrameStyle( Panel | Sunken ); 58 setFrameStyle( Panel | Sunken );
48 } else { 59 } else {
49 setFrameStyle( NoFrame ); 60 setFrameStyle( NoFrame );
50 } 61 }
51} 62}
52 63
53void ColorPanelButton::enterEvent( QEvent* e ) 64void ColorPanelButton::enterEvent( QEvent* e )
54{ 65{
55 Q_UNUSED( e ) 66 Q_UNUSED( e )
56 67
57 if ( !m_active ) { 68 if ( !m_active ) {
58 setFrameStyle( Panel | Sunken ); 69 setFrameStyle( Panel | Sunken );
59 } 70 }
60} 71}
61 72
62void ColorPanelButton::leaveEvent( QEvent* e ) 73void ColorPanelButton::leaveEvent( QEvent* e )
63{ 74{
64 Q_UNUSED( e ) 75 Q_UNUSED( e )
65 76
66 if ( !m_active ) { 77 if ( !m_active ) {
67 setFrameStyle( NoFrame ); 78 setFrameStyle( NoFrame );
68 } 79 }
diff --git a/libopie/colorpopupmenu.h b/libopie/colorpopupmenu.h
index 1a6ab08..b0453b2 100644
--- a/libopie/colorpopupmenu.h
+++ b/libopie/colorpopupmenu.h
@@ -1,81 +1,254 @@
1/********************************************************************** 1/*
2** ColorPopupMenu 2                This file is part of the Opie Project
3** 3
4** Popup menu for selecting colors 4              Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net>
5** 5              Dan Williams <williamsdr@acm.org>
6** Based on colorpanel by S. Prud'homme <prudhomme@laposte.net> 6 =.
7** 7 .=l.
8** Copyright (C) 2002, Dan Williams 8           .>+-=
9** williamsdr@acm.org 9 _;:,     .>    :=|. This program is free software; you can
10** http://draknor.net 10.> <`_,   >  .   <= redistribute it and/or modify it under
11** 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12** This file may be distributed and/or modified under the terms of the 12.="- .-=="i,     .._ License as published by the Free Software
13** GNU General Public License version 2 as published by the Free Software 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14** Foundation and appearing in the file LICENSE.GPL included in the 14     ._= =}       : or (at your option) any later version.
15** packaging of this file. 15    .%`+i>       _;_.
16** 16    .i_,=:_.      -<s. This program is distributed in the hope that
17** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 18    : ..    .:,     . . . without even the implied warranty of
19** 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20**********************************************************************/ 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details.
23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA.
30
31*/
21 32
22#ifndef COLORPOPUPMENU_H 33#ifndef COLORPOPUPMENU_H
23#define COLORPOPUPMENU_H 34#define COLORPOPUPMENU_H
24 35
25#include <qframe.h> 36#include <qframe.h>
26#include <qpopupmenu.h> 37#include <qpopupmenu.h>
27 38
28class QWidget; 39class QWidget;
29class QGridLayout; 40class QGridLayout;
30 41
42/**
43 * @class ColorPanelButton
44 * @brief The ColorPanelButton class provides a button for color selection.
45 *
46 * @see ColorPopupMenu
47 *
48 * The ColorPanelButton class provides a button for color selection. The button
49 * is drawn with the desired color and no border. This class is used internally
50 * by the ColorPopupMenu class to displaying colors in its menu.
51 */
31class ColorPanelButton : public QFrame 52class ColorPanelButton : public QFrame
32{ 53{
33 Q_OBJECT 54 Q_OBJECT
34 55
35public: 56public:
57
58/**
59 * @fn ColorPanelButton( const QColor& color, QWidget* parent = 0, const char* name = 0 )
60 * @brief Object constructor.
61 *
62 * @param color Desired color.
63 * @param parent Pointer to parent of this control.
64 * @param name Name of control.
65 *
66 * Constructs a new ColorPanelButton control with parent, name and desired color.
67 */
36 ColorPanelButton(const QColor& color, QWidget* parent = 0, const char* name = 0); 68 ColorPanelButton(const QColor& color, QWidget* parent = 0, const char* name = 0);
69
70/**
71 * @fn ~ColorPanelButton()
72 * @brief Object destructor.
73 */
37 ~ColorPanelButton(); 74 ~ColorPanelButton();
38 75
76/**
77 * @fn setActive( bool active )
78 * @brief Sets button selection state.
79 *
80 * @param active Boolean indicator of new button state.
81 *
82 * Changes button selection state. If button is selected, a highlighted border
83 * is drawn.
84 */
39 void setActive(bool active); 85 void setActive(bool active);
40 86
87/**
88 * @fn enterEvent( QEvent* e )
89 * @brief Reimplemented for internal reasons.
90 *
91 * @param e Event currently being processed.
92 *
93 * Reimplemented to ensure correct display of button based on whether it is
94 * active or not.
95 */
41 void enterEvent(QEvent* e); 96 void enterEvent(QEvent* e);
97
98/**
99 * @fn leaveEvent( QEvent* e )
100 * @brief Reimplemented for internal reasons.
101 *
102 * @param e Event currently being processed.
103 *
104 * Reimplemented to ensure correct display of button based on whether it is
105 * active or not.
106 */
42 void leaveEvent(QEvent* e); 107 void leaveEvent(QEvent* e);
108
109/**
110 * @fn paintEvent( QEvent* e )
111 * @brief Reimplemented for internal reasons.
112 *
113 * @param e Event currently being processed.
114 *
115 * Reimplemented to ensure correct display of button.
116 */
43 void paintEvent(QPaintEvent* e); 117 void paintEvent(QPaintEvent* e);
118
119/**
120 * @fn mouseReleaseEvent( QMouseEvent* e )
121 * @brief Slot executed when button is pressed.
122 *
123 * @param e Mouse event currently being processed.
124 *
125 * @see selected()
126 *
127 * This slot executes when the button has been pressed. It emits the selected
128 * signal as notification that it has been pressed.
129 */
44 void mouseReleaseEvent(QMouseEvent* e); 130 void mouseReleaseEvent(QMouseEvent* e);
45 131
46signals: 132signals:
133
134/**
135 * @fn selected( const QColor& color )
136 * @brief Signal to indicate button has been pressed.
137 *
138 * @param color Button color.
139 *
140 * This signal is emitted when the button is pressed. It provides the color
141 * associated to this button.
142 */
47 void selected(const QColor&); 143 void selected(const QColor&);
48 144
49private: 145private:
50 QColor m_color; 146 QColor m_color;
51 bool m_active : 1; 147 bool m_active : 1;
52 class ColorPanelButtonPrivate; 148 class ColorPanelButtonPrivate;
53 ColorPanelButtonPrivate *d; 149 ColorPanelButtonPrivate *d;
54}; 150};
55 151
152/**
153 * @class ColorPopupMenu
154 * @brief The ColorPopupMenu class provides a small color selection
155 * popup menu.
156 *
157 * ColorPopupMenu is a derivation of TrollTech's QPopupMenu and provides
158 * a small color selection popup menu which can be attached to another control
159 * such as a toolbar button of menu item.
160 *
161 * 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
163 * finer color control.
164 */
56class ColorPopupMenu : public QPopupMenu 165class ColorPopupMenu : public QPopupMenu
57{ 166{
58 Q_OBJECT 167 Q_OBJECT
59 168
60public: 169public:
170
171/**
172 * @fn ColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 )
173 * @brief Object constructor.
174 *
175 * @param color Initial color selected in menu.
176 * @param parent Pointer to parent of this control.
177 * @param name Name of control.
178 *
179 * Constructs a new ColorPopupMenu control with parent, name and initial color selected.
180 */
61 ColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 ); 181 ColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 );
182
183/**
184 * @fn ~ColorPopupMenu()
185 * @brief Object destructor.
186 */
62 ~ColorPopupMenu(); 187 ~ColorPopupMenu();
63 188
64private: 189private:
65 class ColorPopupMenuPrivate; 190 class ColorPopupMenuPrivate;
66 ColorPopupMenuPrivate *d; 191 ColorPopupMenuPrivate *d;
67 QColor m_color; 192 QColor m_color;
68 QWidget* colorPanel; 193 QWidget* colorPanel;
69 QGridLayout* colorLayout; 194 QGridLayout* colorLayout;
70 195
196/**
197 * @fn addColor( const QColor& color, int row, int col )
198 * @brief Adds color selection option to popup menu.
199 *
200 * @param color Color to be displayed in menu.
201 * @param row Row where color is to appear in menu.
202 * @param col Column where color is to appear in menu.
203 *
204 * Adds a color selection option to popup menu. Used internally when
205 * initially constructing the menu control.
206 */
71 void addColor( const QColor& color, int row, int col ); 207 void addColor( const QColor& color, int row, int col );
72 208
73signals: 209signals:
210
211/**
212 * @fn colorSelected( const QColor& color )
213 * @brief Signal to indicate color chosen from the menu.
214 *
215 * @param color Color selected from the menu.
216 *
217 * This signal is emitted when a color has been selected either directly from
218 * the menu, or chosen from the color selection dialog.
219 */
74 void colorSelected( const QColor& color ); 220 void colorSelected( const QColor& color );
75 221
76protected slots: 222protected slots:
223
224/**
225 * @fn buttonSelected( const QColor& color )
226 * @brief Slot to process selected color.
227 *
228 * @param color Color selected from the menu.
229 *
230 * @see colorSelected()
231 *
232 * This slot executes when a color has been selected from the menu. It performs
233 * two functions:
234 * - Emit the colorSelected signal with the color selected.
235 * - Hide the menu.
236 */
77 void buttonSelected( const QColor& color ); 237 void buttonSelected( const QColor& color );
238
239/**
240 * @fn moreColorClicked()
241 * @brief Slot to process display color selection dialog.
242 *
243 * @see colorSelected()
244 *
245 * This slot executes when the 'More...' option is selected at the bottom of the menu.
246 * It performs the following functions:
247 * - Constructs and executes a OColorDialog to allow finer color selection.
248 * - Emit the colorSelected signal with the color selected.
249 * - Hide the menu.
250 */
78 void moreColorClicked(); 251 void moreColorClicked();
79}; 252};
80 253
81#endif // COLORPOPUPMENUANEL_H 254#endif // COLORPOPUPMENUANEL_H