tkcoloractions.cpp
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
22#include "tkcoloractions.h"
23#include "ttdetoolbarbutton.h"
24
25#include <tqlayout.h>
26#include <kcolordialog.h>
27#include <tdetoolbar.h>
28#include <tqpainter.h>
29#include <tqtooltip.h>
30#include <tqwhatsthis.h>
31#include <tdelocale.h>
32#include <kdebug.h>
33#include <tqapplication.h>
34
35TKColorPopupMenu::TKColorPopupMenu( TQWidget* parent, const char* name )
36: TDEPopupMenu(parent,name)
37{
38}
39
40TKColorPopupMenu::~TKColorPopupMenu()
41{
42}
43
44void TKColorPopupMenu::updateItemSize()
45{
46 styleChange(style());
47}
48/****************************************************************************************/
49class TTDESelectColorActionPrivate
50{
51public:
52 TTDESelectColorActionPrivate()
53 {
54 }
55 bool defaultColorMenu;
56 TQColor defaultColor;
57};
58
59
60TTDESelectColorAction::TTDESelectColorAction( const TQString& text, Type type, TQObject* parent, const char* name, bool menuDefaultColor )
61: TTDEAction(parent,name)
62{
63 d=new TTDESelectColorActionPrivate();
64 d->defaultColorMenu=menuDefaultColor;
65 d->defaultColor=TQColor();
66 setText(text);
67 m_type = type;
68 init();
69}
70
71TTDESelectColorAction::TTDESelectColorAction( const TQString& text, Type type,
72 TQObject* receiver, const char* slot,
73 TQObject* parent, const char* name, bool menuDefaultColor)
74: TTDEAction(parent,name)
75{
76 d=new TTDESelectColorActionPrivate();
77 d->defaultColorMenu=menuDefaultColor;
78 d->defaultColor=TQColor();
79 setText(text);
80 m_type = type;
81 connect( this, TQ_SIGNAL( activated() ), receiver, slot );
82 init();
83}
84
85void TTDESelectColorAction::init()
86{
87 m_pStandardColor = new TKColorPanel();
88 m_pRecentColor = new TKColorPanel();
89
90 connect(m_pStandardColor,TQ_SIGNAL(colorSelected(const TQColor&)),TQ_SLOT(panelColorSelected(const TQColor&)));
91 connect(m_pStandardColor,TQ_SIGNAL(reject()),TQ_SLOT(panelReject()));
92 connect(m_pRecentColor,TQ_SIGNAL(colorSelected(const TQColor&)),TQ_SLOT(panelColorSelected(const TQColor&)));
93 connect(m_pRecentColor,TQ_SIGNAL(reject()),TQ_SLOT(panelReject()));
94
95 m_pRecentColor->clear();
96
97 m_pMenu = new TKColorPopupMenu();
98 m_pMenu->insertItem(m_pStandardColor);
99 m_pMenu->insertSeparator();
100 m_pMenu->insertItem(m_pRecentColor);
101 m_pMenu->insertSeparator();
102
103 switch (m_type) {
104 case TextColor:
105 m_pMenu->insertItem(i18n("More Text Colors..."),this,TQ_SLOT(selectColorDialog()));
106 setCurrentColor(black);
107 setIcon("textcolor");
108 break;
109 case LineColor:
110 m_pMenu->insertItem(i18n("More Line Colors..."),this,TQ_SLOT(selectColorDialog()));
111 setCurrentColor(black);
112 setIcon("color_line");
113 break;
114 case FillColor:
115 m_pMenu->insertItem(i18n("More Fill Colors..."),this,TQ_SLOT(selectColorDialog()));
116 setCurrentColor(white);
117 setIcon("color_fill");
118 break;
119 case Color:
120 break;
121 }
122 if(d->defaultColorMenu)
123 {
124 m_pMenu->insertSeparator();
125 m_pMenu->insertItem(i18n("Default Color"),this,TQ_SLOT(defaultColor()));
126 }
127
128 connect(m_pStandardColor,TQ_SIGNAL(sizeChanged()),m_pMenu,TQ_SLOT(updateItemSize()));
129 connect(m_pRecentColor,TQ_SIGNAL(sizeChanged()),m_pMenu,TQ_SLOT(updateItemSize()));
130}
131
132TTDESelectColorAction::~TTDESelectColorAction()
133{
134 delete m_pMenu;
135 delete d;
136}
137
138void TTDESelectColorAction::initToolBarButton(TTDEToolBarButton* b)
139{
140 TQWhatsThis::add( b, whatsThis() );
141 TTDEAction::initToolBarButton(b);
142 b->setDelayedPopup( popupMenu() );
143 updatePixmap(b);
144 updatePixmap();
145}
146
147void TTDESelectColorAction::defaultColor()
148{
149 m_pCurrentColor = d->defaultColor;
150 emit activated();
151}
152
153void TTDESelectColorAction::setDefaultColor(const TQColor &_col)
154{
155 d->defaultColor=_col;
156}
157
158void TTDESelectColorAction::updatePixmap()
159{
160 for( int id = 0; id < containerCount(); ++id ) {
161 TQWidget* w = container(id);
162 if ( w->inherits("TDEToolBar") ) {
163 TQWidget* r = static_cast<TDEToolBar*>(w)->getWidget(itemId(id));
164 if ( r->inherits("TTDEToolBarButton") ) {
165 updatePixmap(static_cast<TTDEToolBarButton*>(r));
166 }
167 }
168 else if(w->inherits("TQPopupMenu") ) {
169 TQPixmap pix =iconSet(TDEIcon::Small).pixmap(TQIconSet::Automatic,TQIconSet::Active);
170 if ( pix.isNull() )
171 return;
172 TQPainter p(&pix);
173 switch (m_type) {
174 case TextColor:
175 p.fillRect(TQRect(0,12,16,5), m_pCurrentColor);
176 break;
177 case LineColor:
178 p.fillRect(TQRect(0,13,16,5), m_pCurrentColor);
179 p.fillRect(TQRect(3,12,1,1), m_pCurrentColor);
180 break;
181 case FillColor:
182 p.fillRect(TQRect(0,13,16,5), m_pCurrentColor);
183 p.fillRect(TQRect(1,10,5,3), m_pCurrentColor);
184 break;
185 case Color:
186 break;
187 }
188 p.end();
189 setIconSet( pix );
190 }
191 }
192}
193
194void TTDESelectColorAction::updatePixmap(TTDEToolBarButton* b)
195{
196 if (!b)
197 return;
198 // Not much point in painting with an invalid color
199 if (!m_pCurrentColor.isValid())
200 return;
201 TQPixmap pix =b->getActivePixmap();
202 TQPainter p(&pix);
203 switch (m_type) {
204 case TextColor:
205 p.fillRect(TQRect(0,12,16,5), m_pCurrentColor);
206 break;
207 case LineColor:
208 p.fillRect(TQRect(0,13,16,5), m_pCurrentColor);
209 p.fillRect(TQRect(3,12,1,1), m_pCurrentColor);
210 break;
211 case FillColor:
212 p.fillRect(TQRect(0,13,16,5), m_pCurrentColor);
213 p.fillRect(TQRect(1,10,5,3), m_pCurrentColor);
214 break;
215 case Color:
216 break;
217 }
218 p.end();
219 b->setPixmap(pix);
220}
221
222void TTDESelectColorAction::setCurrentColor( const TQColor& color )
223{
224 if ( color == m_pCurrentColor )
225 return;
226 m_pCurrentColor = color;
227 setActiveColor( color );
228 m_pRecentColor->setActiveColor(color );
229 updatePixmap();
230}
231
232void TTDESelectColorAction::setActiveColor( const TQColor& color )
233{
234 m_pStandardColor->setActiveColor(color);
235}
236
237void TTDESelectColorAction::selectColorDialog()
238{
239 TQColor c = color();
240
241 if ( d->defaultColorMenu )
242 {
243 if ( KColorDialog::getColor(c,d->defaultColor, tqApp->activeWindow()) == TQDialog::Accepted )
244 {
245 setCurrentColor(c);
246 m_pRecentColor->insertColor(m_pCurrentColor);
247 activate();
248 }
249
250 }
251 else
252 {
253 if ( KColorDialog::getColor(c, tqApp->activeWindow()) == TQDialog::Accepted )
254 {
255 setCurrentColor(c);
256 m_pRecentColor->insertColor(m_pCurrentColor);
257 activate();
258 }
259 }
260}
261
262// Called when activating the menu item
263void TTDESelectColorAction::slotActivated()
264{
265 //kdDebug() << "TTDESelectColorAction::slotActivated" << endl;
266 selectColorDialog();
267}
268
269void TTDESelectColorAction::activate()
270{
271 emit colorSelected(m_pCurrentColor);
272 emit activated();
273}
274
275void TTDESelectColorAction::panelColorSelected( const TQColor& color )
276{
277 m_pMenu->hide();
278 setCurrentColor(color);
279
280 activate();
281}
282
283void TTDESelectColorAction::panelReject()
284{
285 m_pMenu->hide();
286}
287
288class TKColorPanel::TKColorPanelPrivate
289{
290public:
291 TKColorPanelPrivate()
292 {
293 panelCreated = false;
294 }
295
296 bool panelCreated;
297};
298
299/****************************************************************************************/
300TKColorPanel::TKColorPanel( TQWidget* parent, const char* name )
301: TQWidget(parent,name)
302{
303 d = new TKColorPanel::TKColorPanelPrivate();
304 m_activeColor = black;
305
306 //m_iX = 0; // happens in setNumCols() -> resetGrid()
307 //m_iY = 0; // anyway, so...
308
309 m_pLayout = 0L;
310 setNumCols(15);
311}
312
313void TKColorPanel::setNumCols( int col )
314{
315 m_iWidth = col;
316 resetGrid();
317
318 TQDictIterator<TKColorPanelButton> it(m_pColorDict);
319 while ( it.current() ) {
320 addToGrid(it.current());
321 ++it;
322 }
323}
324
325TKColorPanel::~TKColorPanel()
326{
327 delete d;
328}
329
330void TKColorPanel::resetGrid()
331{
332 m_iX = 0;
333 m_iY = 0;
334
335 delete m_pLayout;
336 m_pLayout = new TQGridLayout(this,0,m_iWidth+1,0,0);
337
338 emit sizeChanged();
339}
340
341void TKColorPanel::clear()
342{
343 m_pColorDict.setAutoDelete(true);
344 m_pColorDict.clear();
345 m_pColorDict.setAutoDelete(false);
346 d->panelCreated = true; // we don't want to create the default
347 // panel anymore now (b/c of recent colors)
348 resetGrid();
349}
350
351void TKColorPanel::insertColor( const TQColor& color, const TQString& text )
352{
353 if (m_pColorDict[color.name()])
354 return;
355
356 insertColor(color);
357 TQToolTip::add(m_pColorDict[color.name()],text);
358}
359
360void TKColorPanel::insertColor( const TQColor& color )
361{
362 if (m_pColorDict[color.name()])
363 return;
364
365 m_pLayout->setMargin(3);
366 TKColorPanelButton* f = new TKColorPanelButton(color,this);
367 m_pColorDict.insert(color.name(),f);
368 if ( m_activeColor == color )
369 f->setActive(true);
370
371 connect(f,TQ_SIGNAL(selected(const TQColor&)),TQ_SLOT(selected(const TQColor&)));
372
373 addToGrid(f);
374}
375
376void TKColorPanel::addToGrid( TKColorPanelButton* f )
377{
378 m_pLayout->addWidget(f,m_iY,m_iX);
379 f->show(); // yeehaaaw! ugly hack (Werner)
380 m_iX++;
381 if ( m_iX == m_iWidth ) {
382 m_iX = 0;
383 m_iY++;
384 }
385 emit sizeChanged();
386}
387
388void TKColorPanel::setActiveColor( const TQColor& color )
389{
390 TKColorPanelButton* b = m_pColorDict[m_activeColor.name()];
391 if (b)
392 b->setActive(false);
393
394 m_activeColor = color;
395
396 b = m_pColorDict[m_activeColor.name()];
397 if (b)
398 b->setActive(true);
399}
400
401void TKColorPanel::mouseReleaseEvent( TQMouseEvent* )
402{
403 reject();
404}
405
406void TKColorPanel::showEvent( TQShowEvent *e )
407{
408 if ( !d->panelCreated )
409 fillPanel();
410 TQWidget::showEvent(e);
411}
412
413void TKColorPanel::selected( const TQColor& color )
414{
415 emit colorSelected(color);
416}
417
418void TKColorPanel::fillPanel()
419{
420 d->panelCreated = true;
421 blockSignals(true); // don't emit sizeChanged() all the time
422
423 // ### TODO: names without space (e.g. red) are lower case in rgb.txt
424 insertColor(TQColor( 255, 0, 0 ), i18n( "color", "Red"));
425 insertColor(TQColor( 255, 165, 0 ), i18n( "color", "Orange"));
426 insertColor(TQColor( 255, 0, 255 ), i18n( "color", "Magenta"));
427 insertColor(TQColor( 0, 0, 255 ), i18n( "color", "Blue"));
428 insertColor(TQColor( 0, 255, 255 ), i18n( "color", "Cyan"));
429 insertColor(TQColor( 0, 255, 0 ), i18n( "color", "Green"));
430 insertColor(TQColor( 255, 255, 0 ), i18n( "color", "Yellow"));
431 insertColor(TQColor( 165, 42, 42 ), i18n( "color", "Brown"));
432 insertColor(TQColor( 139, 0, 0 ), i18n( "color", "DarkRed"));
433 insertColor(TQColor( 255, 140, 0 ), i18n( "color", "DarkOrange"));
434 insertColor(TQColor( 139, 0, 139 ), i18n( "color", "DarkMagenta"));
435 insertColor(TQColor( 0, 0, 139 ), i18n( "color", "DarkBlue"));
436 insertColor(TQColor( 0, 139, 139 ), i18n( "color", "DarkCyan"));
437 insertColor(TQColor( 0, 100, 0 ), i18n( "color", "DarkGreen"));
438 insertColor(TQColor( 130, 127, 0 ), i18n( "color", "DarkYellow")); // ### not in rgb.txt
439
440 insertColor(TQColor( 255, 255, 255 ), i18n( "color", "White"));
441 insertColor(TQColor( 229, 229, 229 ), i18n( "color", "Gray 90%")); // ### not in rgb.txt
442 insertColor(TQColor( 204, 204, 204 ), i18n( "color", "Gray 80%")); // ### not in rgb.txt
443 insertColor(TQColor( 178, 178, 178 ), i18n( "color", "Gray 70%")); // ### not in rgb.txt
444 insertColor(TQColor( 153, 153, 153 ), i18n( "color", "Gray 60%")); // ### not in rgb.txt
445 insertColor(TQColor( 127, 127, 127 ), i18n( "color", "Gray 50%")); // ### not in rgb.txt
446 insertColor(TQColor( 102, 102, 102 ), i18n( "color", "Gray 40%")); // ### not in rgb.txt
447 insertColor(TQColor( 76, 76, 76 ), i18n( "color", "Gray 30%")); // ### not in rgb.txt
448 insertColor(TQColor( 51, 51, 51 ), i18n( "color", "Gray 20%")); // ### not in rgb.txt
449 insertColor(TQColor( 25, 25, 25 ), i18n( "color", "Gray 10%")); // ### not in rgb.txt
450 insertColor(TQColor( 0, 0, 0 ), i18n( "color", "Black"));
451
452 insertColor(TQColor( 255, 255, 240 ), i18n( "color", "Ivory"));
453 insertColor(TQColor( 255, 250, 250 ), i18n( "color", "Snow"));
454 insertColor(TQColor( 245, 255, 250 ), i18n( "color", "MintCream"));
455 insertColor(TQColor( 255, 250, 240 ), i18n( "color", "FloralWhite"));
456 insertColor(TQColor( 255, 255, 224 ), i18n( "color", "LightYellow"));
457 insertColor(TQColor( 240, 255, 255 ), i18n( "color", "Azure"));
458 insertColor(TQColor( 248, 248, 255 ), i18n( "color", "GhostWhite"));
459 insertColor(TQColor( 240, 255, 240 ), i18n( "color", "Honeydew"));
460 insertColor(TQColor( 255, 245, 238 ), i18n( "color", "Seashell"));
461 insertColor(TQColor( 240, 248, 255 ), i18n( "color", "AliceBlue"));
462 insertColor(TQColor( 255, 248, 220 ), i18n( "color", "Cornsilk"));
463 insertColor(TQColor( 255, 240, 245 ), i18n( "color", "LavenderBlush"));
464 insertColor(TQColor( 253, 245, 230 ), i18n( "color", "OldLace"));
465 insertColor(TQColor( 245, 245, 245 ), i18n( "color", "WhiteSmoke"));
466 insertColor(TQColor( 255, 250, 205 ), i18n( "color", "LemonChiffon"));
467 insertColor(TQColor( 224, 255, 255 ), i18n( "color", "LightCyan"));
468 insertColor(TQColor( 250, 250, 210 ), i18n( "color", "LightGoldenrodYellow"));
469 insertColor(TQColor( 250, 240, 230 ), i18n( "color", "Linen"));
470 insertColor(TQColor( 245, 245, 220 ), i18n( "color", "Beige"));
471 insertColor(TQColor( 255, 239, 213 ), i18n( "color", "PapayaWhip"));
472 insertColor(TQColor( 255, 235, 205 ), i18n( "color", "BlanchedAlmond"));
473 insertColor(TQColor( 250, 235, 215 ), i18n( "color", "AntiqueWhite"));
474 insertColor(TQColor( 255, 228, 225 ), i18n( "color", "MistyRose"));
475 insertColor(TQColor( 230, 230, 250 ), i18n( "color", "Lavender"));
476 insertColor(TQColor( 255, 228, 196 ), i18n( "color", "Bisque"));
477 insertColor(TQColor( 255, 228, 181 ), i18n( "color", "Moccasin"));
478 insertColor(TQColor( 255, 222, 173 ), i18n( "color", "NavajoWhite"));
479 insertColor(TQColor( 255, 218, 185 ), i18n( "color", "PeachPuff"));
480 insertColor(TQColor( 238, 232, 170 ), i18n( "color", "PaleGoldenrod"));
481 insertColor(TQColor( 245, 222, 179 ), i18n( "color", "Wheat"));
482 insertColor(TQColor( 220, 220, 220 ), i18n( "color", "Gainsboro"));
483 insertColor(TQColor( 240, 230, 140 ), i18n( "color", "Khaki"));
484 insertColor(TQColor( 175, 238, 238 ), i18n( "color", "PaleTurquoise"));
485 insertColor(TQColor( 255, 192, 203 ), i18n( "color", "Pink"));
486 insertColor(TQColor( 238, 221, 130 ), i18n( "color", "LightGoldenrod"));
487 insertColor(TQColor( 211, 211, 211 ), i18n( "color", "LightGray"));
488 insertColor(TQColor( 255, 182, 193 ), i18n( "color", "LightPink"));
489 insertColor(TQColor( 176, 224, 230 ), i18n( "color", "PowderBlue"));
490 insertColor(TQColor( 127, 255, 212 ), i18n( "color", "Aquamarine"));
491 insertColor(TQColor( 216, 191, 216 ), i18n( "color", "Thistle"));
492 insertColor(TQColor( 173, 216, 230 ), i18n( "color", "LightBlue"));
493 insertColor(TQColor( 152, 251, 152 ), i18n( "color", "PaleGreen"));
494 insertColor(TQColor( 255, 215, 0 ), i18n( "color", "Gold"));
495 insertColor(TQColor( 173, 255, 47 ), i18n( "color", "GreenYellow"));
496 insertColor(TQColor( 176, 196, 222 ), i18n( "color", "LightSteelBlue"));
497 insertColor(TQColor( 144, 238, 144 ), i18n( "color", "LightGreen"));
498 insertColor(TQColor( 221, 160, 221 ), i18n( "color", "Plum"));
499 insertColor(TQColor( 190, 190, 190 ), i18n( "color", "Gray"));
500 insertColor(TQColor( 222, 184, 135 ), i18n( "color", "BurlyWood"));
501 insertColor(TQColor( 135, 206, 250 ), i18n( "color", "LightSkyblue"));
502 insertColor(TQColor( 255, 160, 122 ), i18n( "color", "LightSalmon"));
503 insertColor(TQColor( 135, 206, 235 ), i18n( "color", "SkyBlue"));
504 insertColor(TQColor( 210, 180, 140 ), i18n( "color", "Tan"));
505 insertColor(TQColor( 238, 130, 238 ), i18n( "color", "Violet"));
506 insertColor(TQColor( 244, 164, 96 ), i18n( "color", "SandyBrown"));
507 insertColor(TQColor( 233, 150, 122 ), i18n( "color", "DarkSalmon"));
508 insertColor(TQColor( 189, 183, 107 ), i18n( "color", "DarkKhaki"));
509 insertColor(TQColor( 127, 255, 0 ), i18n( "color", "Chartreuse"));
510 insertColor(TQColor( 169, 169, 169 ), i18n( "color", "DarkGray"));
511 insertColor(TQColor( 124, 252, 0 ), i18n( "color", "LawnGreen"));
512 insertColor(TQColor( 255, 105, 180 ), i18n( "color", "HotPink"));
513 insertColor(TQColor( 250, 128, 114 ), i18n( "color", "Salmon"));
514 insertColor(TQColor( 240, 128, 128 ), i18n( "color", "LightCoral"));
515 insertColor(TQColor( 64, 224, 208 ), i18n( "color", "Turquoise"));
516 insertColor(TQColor( 143, 188, 143 ), i18n( "color", "DarkSeagreen"));
517 insertColor(TQColor( 218, 112, 214 ), i18n( "color", "Orchid"));
518 insertColor(TQColor( 102, 205, 170 ), i18n( "color", "MediumAquamarine"));
519 insertColor(TQColor( 255, 127, 80 ), i18n( "color", "Coral"));
520 insertColor(TQColor( 154, 205, 50 ), i18n( "color", "YellowGreen"));
521 insertColor(TQColor( 218, 165, 32 ), i18n( "color", "Goldenrod"));
522 insertColor(TQColor( 72, 209, 204 ), i18n( "color", "MediumTurquoise"));
523 insertColor(TQColor( 188, 143, 143 ), i18n( "color", "RosyBrown"));
524 insertColor(TQColor( 219, 112, 147 ), i18n( "color", "PaleVioletRed"));
525 insertColor(TQColor( 0, 250, 154 ), i18n( "color", "MediumSpringGreen"));
526 insertColor(TQColor( 255, 99, 71 ), i18n( "color", "Tomato"));
527 insertColor(TQColor( 0, 255, 127 ), i18n( "color", "SpringGreen"));
528 insertColor(TQColor( 205, 133, 63 ), i18n( "color", "Peru"));
529 insertColor(TQColor( 100, 149, 237 ), i18n( "color", "CornflowerBlue"));
530 insertColor(TQColor( 132, 112, 255 ), i18n( "color", "LightSlateBlue"));
531 insertColor(TQColor( 147, 112, 219 ), i18n( "color", "MediumPurple"));
532 insertColor(TQColor( 186, 85, 211 ), i18n( "color", "MediumOrchid"));
533 insertColor(TQColor( 95, 158, 160 ), i18n( "color", "CadetBlue"));
534 insertColor(TQColor( 0, 206, 209 ), i18n( "color", "DarkTurquoise"));
535 insertColor(TQColor( 0, 191, 255 ), i18n( "color", "DeepSkyblue"));
536 insertColor(TQColor( 119, 136, 153 ), i18n( "color", "LightSlateGray"));
537 insertColor(TQColor( 184, 134, 11 ), i18n( "color", "DarkGoldenrod"));
538 insertColor(TQColor( 123, 104, 238 ), i18n( "color", "MediumSlateBlue"));
539 insertColor(TQColor( 205, 92, 92 ), i18n( "color", "IndianRed"));
540 insertColor(TQColor( 210, 105, 30 ), i18n( "color", "Chocolate"));
541 insertColor(TQColor( 60, 179, 113 ), i18n( "color", "MediumSeaGreen"));
542 insertColor(TQColor( 50, 205, 50 ), i18n( "color", "LimeGreen"));
543 insertColor(TQColor( 32, 178, 170 ), i18n( "color", "LightSeaGreen"));
544 insertColor(TQColor( 112, 128, 144 ), i18n( "color", "SlateGray"));
545 insertColor(TQColor( 30, 144, 255 ), i18n( "color", "DodgerBlue"));
546 insertColor(TQColor( 255, 69, 0 ), i18n( "color", "OrangeRed"));
547 insertColor(TQColor( 255, 20, 147 ), i18n( "color", "DeepPink"));
548 insertColor(TQColor( 70, 130, 180 ), i18n( "color", "SteelBlue"));
549 insertColor(TQColor( 106, 90, 205 ), i18n( "color", "SlateBlue"));
550 insertColor(TQColor( 107, 142, 35 ), i18n( "color", "OliveDrab"));
551 insertColor(TQColor( 65, 105, 225 ), i18n( "color", "RoyalBlue"));
552 insertColor(TQColor( 208, 32, 144 ), i18n( "color", "VioletRed"));
553 insertColor(TQColor( 153, 50, 204 ), i18n( "color", "DarkOrchid"));
554 insertColor(TQColor( 160, 32, 240 ), i18n( "color", "Purple"));
555 insertColor(TQColor( 105, 105, 105 ), i18n( "color", "DimGray"));
556 insertColor(TQColor( 138, 43, 226 ), i18n( "color", "BlueViolet"));
557 insertColor(TQColor( 160, 82, 45 ), i18n( "color", "Sienna"));
558 insertColor(TQColor( 199, 21, 133 ), i18n( "color", "MediumVioletRed"));
559 insertColor(TQColor( 176, 48, 96 ), i18n( "color", "Maroon"));
560 insertColor(TQColor( 46, 139, 87 ), i18n( "color", "SeaGreen"));
561 insertColor(TQColor( 85, 107, 47 ), i18n( "color", "DarkOliveGreen"));
562 insertColor(TQColor( 34, 139, 34 ), i18n( "color", "ForestGreen"));
563 insertColor(TQColor( 139, 69, 19 ), i18n( "color", "SaddleBrown"));
564 insertColor(TQColor( 148, 0, 211 ), i18n( "color", "DarkViolet"));
565 insertColor(TQColor( 178, 34, 34 ), i18n( "color", "FireBrick"));
566 insertColor(TQColor( 72, 61, 139 ), i18n( "color", "DarkSlateBlue"));
567 insertColor(TQColor( 47, 79, 79 ), i18n( "color", "DarkSlateGray"));
568 insertColor(TQColor( 25, 25, 112 ), i18n( "color", "MidnightBlue"));
569 insertColor(TQColor( 0, 0, 205 ), i18n( "color", "MediumBlue"));
570 insertColor(TQColor( 0, 0, 128 ), i18n( "color", "Navy"));
571
572 blockSignals(false); // Signals allowed again
573 emit sizeChanged(); // one call should be enough ;)
574}
575
576/****************************************************************************************/
577TKColorPanelButton::TKColorPanelButton( const TQColor& color, TQWidget* parent, const char* name )
578: TQFrame(parent,name), m_Color(color), m_bActive(false)
579{
580 setFixedSize(16,16);
581 setFrameStyle( NoFrame );
582}
583
584TKColorPanelButton::~TKColorPanelButton()
585{
586}
587
588void TKColorPanelButton::enterEvent( TQEvent* )
589{
590 if (!m_bActive)
591 setFrameStyle( Panel | Sunken );
592}
593
594void TKColorPanelButton::leaveEvent( TQEvent* )
595{
596 if (!m_bActive)
597 setFrameStyle( NoFrame );
598}
599
600void TKColorPanelButton::paintEvent( TQPaintEvent* ev )
601{
602 TQFrame::paintEvent(ev);
603
604 TQPainter p(this,this);
605 p.fillRect(2,2,12,12,m_Color);
606 p.setPen(gray);
607 p.drawRect(2,2,12,12);
608 p.end();
609}
610
611void TKColorPanelButton::setActive( bool f )
612{
613 m_bActive = f;
614 setFrameStyle( m_bActive ? Panel | Sunken : NoFrame );
615}
616
617void TKColorPanelButton::mouseReleaseEvent( TQMouseEvent* )
618{
619 emit selected(m_Color);
620}
621#include "tkcoloractions.moc"
static int getColor(TQColor &theColor, TQWidget *parent=0L)
TDEAction * whatsThis(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
const char * name(StdAction id)
@ Color
color
Definition property.h:78