tkcoloractions.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
This file is part of the documentation for lib Library Version 1.4.2.