lib

tkcoloractions.h
1/*
2 * Kivio - Visual Modelling and Flowcharting
3 * Copyright (C) 2000 theKompany.com
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifndef TKCOLORACTION_H
22#define TKCOLORACTION_H
23
24#include "ttdeaction.h"
25#include <koffice_export.h>
26#include <tdepopupmenu.h>
27#include <tqdict.h>
28
29class TQGridLayout;
30class TKColorPanel;
31class TTDESelectColorActionPrivate;
32
33class TKColorPopupMenu : public TDEPopupMenu
34{ TQ_OBJECT
35
36public:
37 TKColorPopupMenu( TQWidget* parent = 0, const char* name = 0 );
38 ~TKColorPopupMenu();
39
40public slots:
41 void updateItemSize();
42};
43/****************************************************************************************/
44class KOFFICEUI_EXPORT TTDESelectColorAction : public TTDEAction
45{ TQ_OBJECT
46
47public:
48 enum Type {
49 TextColor,
50 LineColor,
51 FillColor,
52 Color
53 };
54
55 TTDESelectColorAction( const TQString& text, Type type, TQObject* parent, const char* name, bool menuDefaultColor=false);
56 TTDESelectColorAction( const TQString& text, Type type,
57 TQObject* receiver, const char* slot,
58 TQObject* parent, const char* name,bool menuDefaultColor=false );
59
60 virtual ~TTDESelectColorAction();
61
62 TQColor color() const { return m_pCurrentColor; }
63
64 TDEPopupMenu* popupMenu() const { return m_pMenu; }
65 void setDefaultColor(const TQColor &_col);
66
67
68public slots:
69 void setCurrentColor( const TQColor& );
70 void setActiveColor( const TQColor& );
71 virtual void activate();
72
73signals:
74 void colorSelected( const TQColor& );
75
76protected slots:
77 void selectColorDialog();
78 void panelColorSelected( const TQColor& );
79 void panelReject();
80 virtual void slotActivated();
81 void defaultColor();
82
83protected:
84 void init();
85 virtual void initToolBarButton(TTDEToolBarButton*);
86 void updatePixmap();
87 void updatePixmap(TTDEToolBarButton*);
88
89protected:
90 TKColorPopupMenu* m_pMenu;
91 TKColorPanel* m_pStandardColor;
92 TKColorPanel* m_pRecentColor;
93 int m_type;
94
95 TQColor m_pCurrentColor;
96
97private:
98 TTDESelectColorActionPrivate *d;
99};
100/****************************************************************************************/
101class TKColorPanelButton : public TQFrame
102{ TQ_OBJECT
103
104public:
105 TKColorPanelButton( const TQColor&, TQWidget* parent, const char* name = 0 );
106 ~TKColorPanelButton();
107
108 void setActive( bool );
109
110 TQColor panelColor() const { return m_Color; }
111
112signals:
113 void selected( const TQColor& );
114
115protected:
116 virtual void paintEvent( TQPaintEvent* );
117 virtual void enterEvent( TQEvent* );
118 virtual void leaveEvent( TQEvent* );
119 virtual void mouseReleaseEvent( TQMouseEvent* );
120
121 TQColor m_Color;
122 bool m_bActive;
123
124private:
125 class TKColorPanelButtonPrivate;
126 TKColorPanelButtonPrivate *d;
127};
128/****************************************************************************************/
129class TKColorPanel : public TQWidget
130{ TQ_OBJECT
131
132
133public:
134 TKColorPanel( TQWidget* parent = 0L, const char* name = 0 );
135 ~TKColorPanel();
136
137 void setActiveColor( const TQColor& );
138 void setNumCols( int col );
139 void clear();
140
141public slots:
142 void insertColor( const TQColor& );
143 void insertColor( const TQColor&, const TQString& );
144 void selected( const TQColor& );
145
146signals:
147 void colorSelected( const TQColor& );
148 void reject();
149 void sizeChanged();
150
151protected:
152 void addToGrid( TKColorPanelButton* );
153 void resetGrid();
154
155 virtual void mouseReleaseEvent( TQMouseEvent* );
156 virtual void showEvent( TQShowEvent *e );
157
158 TQGridLayout* m_pLayout;
159 int m_iWidth;
160 int m_iX;
161 int m_iY;
162
163 TQColor m_activeColor;
164 TQDict<TKColorPanelButton> m_pColorDict;
165
166private:
167 void fillPanel();
168
169 class TKColorPanelPrivate;
170 TKColorPanelPrivate *d;
171};
172
173#endif
virtual void activate()
@ Color
color
Definition property.h:78