colorpopupmenu.h
00001 /* 00002 This file is part of the Opie Project 00003 00004 Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net> 00005 Dan Williams <williamsdr@acm.org> 00006 =. 00007 .=l. 00008 .>+-= 00009 _;:, .> :=|. This program is free software; you can 00010 .> <`_, > . <= redistribute it and/or modify it under 00011 :`=1 )Y*s>-.-- : the terms of the GNU Library General Public 00012 .="- .-=="i, .._ License as published by the Free Software 00013 - . .-<_> .<> Foundation; either version 2 of the License, 00014 ._= =} : or (at your option) any later version. 00015 .%`+i> _;_. 00016 .i_,=:_. -<s. This program is distributed in the hope that 00017 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 00018 : .. .:, . . . without even the implied warranty of 00019 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 00020 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 00021 ..}^=.= = ; Library General Public License for more 00022 ++= -. .` .: details. 00023 : = ...= . :.=- 00024 -. .:....=;==+<; You should have received a copy of the GNU 00025 -_. . . )=. = Library General Public License along with 00026 -- :-=` this library; see the file COPYING.LIB. 00027 If not, write to the Free Software Foundation, 00028 Inc., 59 Temple Place - Suite 330, 00029 Boston, MA 02111-1307, USA. 00030 00031 */ 00032 00033 #ifndef COLORPOPUPMENU_H 00034 #define COLORPOPUPMENU_H 00035 00036 #include <qframe.h> 00037 #include <qpopupmenu.h> 00038 00039 class QWidget; 00040 class QGridLayout; 00041 00052 class OColorPanelButton : public QFrame 00053 { 00054 Q_OBJECT 00055 00056 public: 00057 00068 OColorPanelButton(const QColor& color, QWidget* parent = 0, const char* name = 0); 00069 00074 ~OColorPanelButton(); 00075 00085 void setActive(bool active); 00086 00096 void enterEvent(QEvent* e); 00097 00107 void leaveEvent(QEvent* e); 00108 00117 void paintEvent(QPaintEvent* e); 00118 00130 void mouseReleaseEvent(QMouseEvent* e); 00131 00132 signals: 00133 00143 void selected(const QColor&); 00144 00145 private: 00146 QColor m_color; 00147 bool m_active : 1; 00148 class ColorPanelButtonPrivate; 00149 ColorPanelButtonPrivate *d; 00150 }; 00151 00165 class OColorPopupMenu : public QPopupMenu 00166 { 00167 Q_OBJECT 00168 00169 public: 00170 00181 // FIXME add Wflags? -zecke 00182 OColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 ); 00183 00188 ~OColorPopupMenu(); 00189 00190 private: 00191 class ColorPopupMenuPrivate; 00192 ColorPopupMenuPrivate *d; 00193 QColor m_color; 00194 QWidget* colorPanel; 00195 QGridLayout* colorLayout; 00196 00208 void addColor( const QColor& color, int row, int col ); 00209 00210 signals: 00211 00221 void colorSelected( const QColor& color ); 00222 00223 protected slots: 00224 00238 void buttonSelected( const QColor& color ); 00239 00252 void moreColorClicked(); 00253 }; 00254 00255 #endif // COLORPOPUPMENUANEL_H
