summaryrefslogtreecommitdiffstats
path: root/lib/kofficeui/tkcoloractions.h
blob: 2c4f68b69859f09aa44ca108902581a9a6fe04a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
 * Kivio - Visual Modelling and Flowcharting
 * Copyright (C) 2000 theKompany.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef TKCOLORACTION_H
#define TKCOLORACTION_H

#include "ttdeaction.h"
#include <koffice_export.h>
#include <tdepopupmenu.h>
#include <tqdict.h>

class TQGridLayout;
class TKColorPanel;
class TTDESelectColorActionPrivate;

class TKColorPopupMenu : public TDEPopupMenu
{ TQ_OBJECT
  
public:
  TKColorPopupMenu( TQWidget* parent = 0, const char* name = 0 );
  ~TKColorPopupMenu();

public slots:
  void updateItemSize();
};
/****************************************************************************************/
class KOFFICEUI_EXPORT TTDESelectColorAction : public TTDEAction
{ TQ_OBJECT
  
public:
  enum Type {
    TextColor,
    LineColor,
    FillColor,
    Color
  };

  TTDESelectColorAction( const TQString& text, Type type, TQObject* parent, const char* name, bool menuDefaultColor=false);
  TTDESelectColorAction( const TQString& text, Type type,
                       TQObject* receiver, const char* slot,
                       TQObject* parent, const char* name,bool menuDefaultColor=false );

  virtual ~TTDESelectColorAction();

  TQColor color() const { return m_pCurrentColor; }

  TDEPopupMenu* popupMenu() const { return m_pMenu; }
  void setDefaultColor(const TQColor &_col);


public slots:
  void setCurrentColor( const TQColor& );
  void setActiveColor( const TQColor& );
  virtual void activate();

signals:
  void colorSelected( const TQColor& );

protected slots:
  void selectColorDialog();
  void panelColorSelected( const TQColor& );
  void panelReject();
  virtual void slotActivated();
  void defaultColor();

protected:
  void init();
  virtual void initToolBarButton(TTDEToolBarButton*);
  void updatePixmap();
  void updatePixmap(TTDEToolBarButton*);

protected:
  TKColorPopupMenu* m_pMenu;
  TKColorPanel* m_pStandardColor;
  TKColorPanel* m_pRecentColor;
  int m_type;

  TQColor m_pCurrentColor;

private:
  TTDESelectColorActionPrivate *d;
};
/****************************************************************************************/
class TKColorPanelButton : public TQFrame
{ TQ_OBJECT
  
public:
  TKColorPanelButton( const TQColor&, TQWidget* parent, const char* name = 0 );
  ~TKColorPanelButton();

  void setActive( bool );

  TQColor panelColor() const { return m_Color; }

signals:
  void selected( const TQColor& );

protected:
  virtual void paintEvent( TQPaintEvent* );
  virtual void enterEvent( TQEvent* );
  virtual void leaveEvent( TQEvent* );
  virtual void mouseReleaseEvent( TQMouseEvent* );

  TQColor m_Color;
  bool m_bActive;

private:
  class TKColorPanelButtonPrivate;
  TKColorPanelButtonPrivate *d;
};
/****************************************************************************************/
class TKColorPanel : public TQWidget
{ TQ_OBJECT
  

public:
  TKColorPanel( TQWidget* parent = 0L, const char* name = 0 );
  ~TKColorPanel();

  void setActiveColor( const TQColor& );
  void setNumCols( int col );
  void clear();

public slots:
  void insertColor( const TQColor& );
  void insertColor( const TQColor&, const TQString& );
  void selected( const TQColor& );

signals:
  void colorSelected( const TQColor& );
  void reject();
  void sizeChanged();

protected:
  void addToGrid( TKColorPanelButton* );
  void resetGrid();

  virtual void mouseReleaseEvent( TQMouseEvent* );
  virtual void showEvent( TQShowEvent *e );

  TQGridLayout* m_pLayout;
  int m_iWidth;
  int m_iX;
  int m_iY;

  TQColor m_activeColor;
  TQDict<TKColorPanelButton> m_pColorDict;

private:
  void fillPanel();

  class TKColorPanelPrivate;
  TKColorPanelPrivate *d;
};

#endif