lib Library API Documentation

tkcoloractions.h

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2000 theKompany.com
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef TKCOLORACTION_H
00021 #define TKCOLORACTION_H
00022 
00023 #include "tkaction.h"
00024 #include <koffice_export.h>
00025 #include <kpopupmenu.h>
00026 #include <qdict.h>
00027 
00028 class QGridLayout;
00029 class TKColorPanel;
00030 class TKSelectColorActionPrivate;
00031 
00032 class TKColorPopupMenu : public KPopupMenu
00033 { Q_OBJECT
00034 public:
00035   TKColorPopupMenu( QWidget* parent = 0, const char* name = 0 );
00036   ~TKColorPopupMenu();
00037 
00038 public slots:
00039   void updateItemSize();
00040 };
00041 /****************************************************************************************/
00042 class KOFFICEUI_EXPORT TKSelectColorAction : public TKAction
00043 { Q_OBJECT
00044 public:
00045   enum Type {
00046     TextColor,
00047     LineColor,
00048     FillColor,
00049     Color
00050   };
00051 
00052   TKSelectColorAction( const QString& text, Type type, QObject* parent, const char* name, bool menuDefaultColor=false);
00053   TKSelectColorAction( const QString& text, Type type,
00054                        QObject* receiver, const char* slot,
00055                        QObject* parent, const char* name,bool menuDefaultColor=false );
00056 
00057   virtual ~TKSelectColorAction();
00058 
00059   QColor color() const { return m_pCurrentColor; }
00060 
00061   KPopupMenu* popupMenu() const { return m_pMenu; }
00062   void setDefaultColor(const QColor &_col);
00063 
00064 
00065 public slots:
00066   void setCurrentColor( const QColor& );
00067   void setActiveColor( const QColor& );
00068   virtual void activate();
00069 
00070 signals:
00071   void colorSelected( const QColor& );
00072 
00073 protected slots:
00074   void selectColorDialog();
00075   void panelColorSelected( const QColor& );
00076   void panelReject();
00077   virtual void slotActivated();
00078   void defaultColor();
00079 
00080 protected:
00081   void init();
00082   virtual void initToolBarButton(TKToolBarButton*);
00083   void updatePixmap();
00084   void updatePixmap(TKToolBarButton*);
00085 
00086 protected:
00087   TKColorPopupMenu* m_pMenu;
00088   TKColorPanel* m_pStandardColor;
00089   TKColorPanel* m_pRecentColor;
00090   int m_type;
00091 
00092   QColor m_pCurrentColor;
00093 
00094 private:
00095   TKSelectColorActionPrivate *d;
00096 };
00097 /****************************************************************************************/
00098 class TKColorPanelButton : public QFrame
00099 { Q_OBJECT
00100 public:
00101   TKColorPanelButton( const QColor&, QWidget* parent, const char* name = 0 );
00102   ~TKColorPanelButton();
00103 
00104   void setActive( bool );
00105 
00106   QColor panelColor() const { return m_Color; }
00107 
00108 signals:
00109   void selected( const QColor& );
00110 
00111 protected:
00112   virtual void paintEvent( QPaintEvent* );
00113   virtual void enterEvent( QEvent* );
00114   virtual void leaveEvent( QEvent* );
00115   virtual void mouseReleaseEvent( QMouseEvent* );
00116 
00117   QColor m_Color;
00118   bool m_bActive;
00119 
00120 private:
00121   class TKColorPanelButtonPrivate;
00122   TKColorPanelButtonPrivate *d;
00123 };
00124 /****************************************************************************************/
00125 class TKColorPanel : public QWidget
00126 { Q_OBJECT
00127 
00128 public:
00129   TKColorPanel( QWidget* parent = 0L, const char* name = 0 );
00130   ~TKColorPanel();
00131 
00132   void setActiveColor( const QColor& );
00133   void setNumCols( int col );
00134   void clear();
00135 
00136 public slots:
00137   void insertColor( const QColor& );
00138   void insertColor( const QColor&, const QString& );
00139   void selected( const QColor& );
00140 
00141 signals:
00142   void colorSelected( const QColor& );
00143   void reject();
00144   void sizeChanged();
00145 
00146 protected:
00147   void addToGrid( TKColorPanelButton* );
00148   void resetGrid();
00149 
00150   virtual void mouseReleaseEvent( QMouseEvent* );
00151   virtual void showEvent( QShowEvent *e );
00152 
00153   QGridLayout* m_pLayout;
00154   int m_iWidth;
00155   int m_iX;
00156   int m_iY;
00157 
00158   QColor m_activeColor;
00159   QDict<TKColorPanelButton> m_pColorDict;
00160 
00161 private:
00162   void fillPanel();
00163 
00164   class TKColorPanelPrivate;
00165   TKColorPanelPrivate *d;
00166 };
00167 
00168 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:16 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003