summaryrefslogtreecommitdiff
path: root/libqtaux/ocolorpopupmenu.h
Unidiff
Diffstat (limited to 'libqtaux/ocolorpopupmenu.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libqtaux/ocolorpopupmenu.h255
1 files changed, 255 insertions, 0 deletions
diff --git a/libqtaux/ocolorpopupmenu.h b/libqtaux/ocolorpopupmenu.h
new file mode 100644
index 0000000..90cfbed
--- a/dev/null
+++ b/libqtaux/ocolorpopupmenu.h
@@ -0,0 +1,255 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net>
5              Dan Williams <williamsdr@acm.org>
6 =.
7 .=l.
8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
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*/
32
33#ifndef COLORPOPUPMENU_H
34#define COLORPOPUPMENU_H
35
36#include <qframe.h>
37#include <qpopupmenu.h>
38
39class QWidget;
40class QGridLayout;
41
42/**
43 * @class OColorPanelButton
44 * @brief The OColorPanelButton class provides a button for color selection.
45 *
46 * @see OColorPopupMenu
47 *
48 * 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
50 * by the OColorPopupMenu class to displaying colors in its menu.
51 */
52class OColorPanelButton : public QFrame
53{
54 Q_OBJECT
55
56public:
57
58/**
59 * @fn OColorPanelButton( 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 */
68 OColorPanelButton(const QColor& color, QWidget* parent = 0, const char* name = 0);
69
70/**
71 * @fn ~OColorPanelButton()
72 * @brief Object destructor.
73 */
74 ~OColorPanelButton();
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 */
85 void setActive(bool active);
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 */
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 */
107 void leaveEvent(QEvent* e);
108
109/**
110 * @fn paintEvent( QPaintEvent* e )
111 * @brief Reimplemented for internal reasons.
112 *
113 * @param e Event currently being processed.
114 * @reimp
115 * Reimplemented to ensure correct display of button.
116 */
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 */
130 void mouseReleaseEvent(QMouseEvent* e);
131
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 */
143 void selected(const QColor&);
144
145private:
146 QColor m_color;
147 bool m_active : 1;
148 class ColorPanelButtonPrivate;
149 ColorPanelButtonPrivate *d;
150};
151
152/**
153 * @class OColorPopupMenu
154 * @brief The OColorPopupMenu class provides a small color selection
155 * popup menu.
156 *
157 * OColorPopupMenu 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 */
165class OColorPopupMenu : public QPopupMenu
166{
167 Q_OBJECT
168
169public:
170
171/**
172 * @fn OColorPopupMenu( 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 OColorPopupMenu control with parent, name and initial color selected.
180 */
181 // FIXME add Wflags? -zecke
182 OColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 );
183
184/**
185 * @fn ~OColorPopupMenu()
186 * @brief Object destructor.
187 */
188 ~OColorPopupMenu();
189
190private:
191 class ColorPopupMenuPrivate;
192 ColorPopupMenuPrivate *d;
193 QColor m_color;
194 QWidget* colorPanel;
195 QGridLayout* colorLayout;
196
197/**
198 * @fn addColor( const QColor& color, int row, int col )
199 * @brief Adds color selection option to popup menu.
200 *
201 * @param color Color to be displayed in menu.
202 * @param row Row where color is to appear in menu.
203 * @param col Column where color is to appear in menu.
204 *
205 * Adds a color selection option to popup menu. Used internally when
206 * initially constructing the menu control.
207 */
208 void addColor( const QColor& color, int row, int col );
209
210signals:
211
212/**
213 * @fn colorSelected( const QColor& color )
214 * @brief Signal to indicate color chosen from the menu.
215 *
216 * @param color Color selected from the menu.
217 *
218 * This signal is emitted when a color has been selected either directly from
219 * the menu, or chosen from the color selection dialog.
220 */
221 void colorSelected( const QColor& color );
222
223protected slots:
224
225/**
226 * @fn buttonSelected( const QColor& color )
227 * @brief Slot to process selected color.
228 *
229 * @param color Color selected from the menu.
230 *
231 * @see colorSelected()
232 *
233 * This slot executes when a color has been selected from the menu. It performs
234 * two functions:
235 * - Emit the colorSelected signal with the color selected.
236 * - Hide the menu.
237 */
238 void buttonSelected( const QColor& color );
239
240/**
241 * @fn moreColorClicked()
242 * @brief Slot to process display color selection dialog.
243 *
244 * @see colorSelected()
245 *
246 * This slot executes when the 'More...' option is selected at the bottom of the menu.
247 * It performs the following functions:
248 * - Constructs and executes a QColorDialog to allow finer color selection.
249 * - Emit the colorSelected signal with the color selected.
250 * - Hide the menu.
251 */
252 void moreColorClicked();
253};
254
255#endif // COLORPOPUPMENUANEL_H