tkcoloractions.cpp
00001
#include "tkcoloractions.h"
00002
#include "tktoolbarbutton.h"
00003
00004
#include <qlayout.h>
00005
#include <kcolordialog.h>
00006
#include <ktoolbar.h>
00007
#include <qpainter.h>
00008
#include <qtooltip.h>
00009
#include <qwhatsthis.h>
00010
#include <klocale.h>
00011
#include <kdebug.h>
00012
00013 TKColorPopupMenu::TKColorPopupMenu(
QWidget* parent,
const char* name )
00014 : KPopupMenu(parent,name)
00015 {
00016 }
00017
00018 TKColorPopupMenu::~TKColorPopupMenu()
00019 {
00020 }
00021
00022
void TKColorPopupMenu::updateItemSize()
00023 {
00024 styleChange(style());
00025 }
00026
00027
class TKSelectColorActionPrivate
00028 {
00029
public:
00030 TKSelectColorActionPrivate()
00031 {
00032 }
00033
bool defaultColorMenu;
00034
QColor defaultColor;
00035 };
00036
00037
00038 TKSelectColorAction::TKSelectColorAction(
const QString& text, Type type,
QObject* parent,
const char* name,
bool menuDefaultColor )
00039 : TKAction(parent,name)
00040 {
00041 d=
new TKSelectColorActionPrivate();
00042 d->defaultColorMenu=menuDefaultColor;
00043 d->defaultColor=
QColor();
00044 setText(text);
00045 m_type = type;
00046 init();
00047 }
00048
00049 TKSelectColorAction::TKSelectColorAction(
const QString& text, Type type,
00050
QObject* receiver,
const char* slot,
00051
QObject* parent,
const char* name,
bool menuDefaultColor)
00052 : TKAction(parent,name)
00053 {
00054 d=
new TKSelectColorActionPrivate();
00055 d->defaultColorMenu=menuDefaultColor;
00056 d->defaultColor=
QColor();
00057 setText(text);
00058 m_type = type;
00059 connect(
this, SIGNAL( activated() ), receiver, slot );
00060 init();
00061 }
00062
00063
void TKSelectColorAction::init()
00064 {
00065 m_pStandardColor =
new TKColorPanel();
00066 m_pRecentColor =
new TKColorPanel();
00067
00068 connect(m_pStandardColor,SIGNAL(colorSelected(
const QColor&)),SLOT(panelColorSelected(
const QColor&)));
00069 connect(m_pStandardColor,SIGNAL(reject()),SLOT(panelReject()));
00070 connect(m_pRecentColor,SIGNAL(colorSelected(
const QColor&)),SLOT(panelColorSelected(
const QColor&)));
00071 connect(m_pRecentColor,SIGNAL(reject()),SLOT(panelReject()));
00072
00073 m_pRecentColor->clear();
00074
00075 m_pMenu =
new TKColorPopupMenu();
00076 m_pMenu->insertItem(m_pStandardColor);
00077 m_pMenu->insertSeparator();
00078 m_pMenu->insertItem(m_pRecentColor);
00079 m_pMenu->insertSeparator();
00080
00081
switch (m_type) {
00082
case TextColor:
00083 m_pMenu->insertItem(i18n(
"More Text Colors..."),
this,SLOT(selectColorDialog()));
00084 setCurrentColor(black);
00085 setIcon(
"textcolor");
00086
break;
00087
case LineColor:
00088 m_pMenu->insertItem(i18n(
"More Line Colors..."),
this,SLOT(selectColorDialog()));
00089 setCurrentColor(black);
00090 setIcon(
"color_line");
00091
break;
00092
case FillColor:
00093 m_pMenu->insertItem(i18n(
"More Fill Colors..."),
this,SLOT(selectColorDialog()));
00094 setCurrentColor(white);
00095 setIcon(
"color_fill");
00096
break;
00097
case Color:
00098
break;
00099 }
00100
if(d->defaultColorMenu)
00101 {
00102 m_pMenu->insertSeparator();
00103 m_pMenu->insertItem(i18n(
"Default Color"),
this,SLOT(defaultColor()));
00104 }
00105
00106 connect(m_pStandardColor,SIGNAL(sizeChanged()),m_pMenu,SLOT(updateItemSize()));
00107 connect(m_pRecentColor,SIGNAL(sizeChanged()),m_pMenu,SLOT(updateItemSize()));
00108 }
00109
00110 TKSelectColorAction::~TKSelectColorAction()
00111 {
00112
delete m_pMenu;
00113
delete d;
00114 }
00115
00116
void TKSelectColorAction::initToolBarButton(TKToolBarButton* b)
00117 {
00118 QWhatsThis::add( b, whatsThis() );
00119 TKAction::initToolBarButton(b);
00120 b->setDelayedPopup( popupMenu() );
00121 updatePixmap(b);
00122 updatePixmap();
00123 }
00124
00125
void TKSelectColorAction::defaultColor()
00126 {
00127 m_pCurrentColor = d->defaultColor;
00128 emit activated();
00129 }
00130
00131
void TKSelectColorAction::setDefaultColor(
const QColor &_col)
00132 {
00133 d->defaultColor=_col;
00134 }
00135
00136
void TKSelectColorAction::updatePixmap()
00137 {
00138
for(
int id = 0;
id < containerCount(); ++
id ) {
00139
QWidget* w = container(
id);
00140
if ( w->inherits(
"KToolBar") ) {
00141
QWidget* r = static_cast<KToolBar*>(w)->getWidget(itemId(
id));
00142
if ( r->inherits(
"TKToolBarButton") ) {
00143 updatePixmap(static_cast<TKToolBarButton*>(r));
00144 }
00145 }
00146
else if(w->inherits(
"QPopupMenu") ) {
00147
QPixmap pix =iconSet(KIcon::Small).pixmap(QIconSet::Automatic,QIconSet::Active);
00148
if ( pix.isNull() )
00149
return;
00150
QPainter p(&pix);
00151
switch (m_type) {
00152
case TextColor:
00153 p.fillRect(
QRect(0,12,16,5), m_pCurrentColor);
00154
break;
00155
case LineColor:
00156 p.fillRect(
QRect(0,13,16,5), m_pCurrentColor);
00157 p.fillRect(
QRect(3,12,1,1), m_pCurrentColor);
00158
break;
00159
case FillColor:
00160 p.fillRect(
QRect(0,13,16,5), m_pCurrentColor);
00161 p.fillRect(
QRect(1,10,5,3), m_pCurrentColor);
00162
break;
00163
case Color:
00164
break;
00165 }
00166 p.end();
00167 setIconSet( pix );
00168 }
00169 }
00170 }
00171
00172
void TKSelectColorAction::updatePixmap(TKToolBarButton* b)
00173 {
00174
if (!b)
00175
return;
00176
00177
if (!m_pCurrentColor.isValid())
00178
return;
00179
QPixmap pix =b->getActivePixmap();
00180
QPainter p(&pix);
00181
switch (m_type) {
00182
case TextColor:
00183 p.fillRect(
QRect(0,12,16,5), m_pCurrentColor);
00184
break;
00185
case LineColor:
00186 p.fillRect(
QRect(0,13,16,5), m_pCurrentColor);
00187 p.fillRect(
QRect(3,12,1,1), m_pCurrentColor);
00188
break;
00189
case FillColor:
00190 p.fillRect(
QRect(0,13,16,5), m_pCurrentColor);
00191 p.fillRect(
QRect(1,10,5,3), m_pCurrentColor);
00192
break;
00193
case Color:
00194
break;
00195 }
00196 p.end();
00197 b->setPixmap(pix);
00198 }
00199
00200
void TKSelectColorAction::setCurrentColor(
const QColor& color )
00201 {
00202
if ( color == m_pCurrentColor )
00203
return;
00204 m_pCurrentColor = color;
00205 setActiveColor( color );
00206 m_pRecentColor->setActiveColor(color );
00207 updatePixmap();
00208 }
00209
00210
void TKSelectColorAction::setActiveColor(
const QColor& color )
00211 {
00212 m_pStandardColor->setActiveColor(color);
00213 }
00214
00215
void TKSelectColorAction::selectColorDialog()
00216 {
00217
QColor color;
00218
if ( d->defaultColorMenu )
00219 {
00220
if ( KColorDialog::getColor(color,d->defaultColor) == QDialog::Accepted )
00221 {
00222 setCurrentColor(color);
00223 m_pRecentColor->insertColor(m_pCurrentColor);
00224 activate();
00225 }
00226
00227 }
00228
else
00229 {
00230
if ( KColorDialog::getColor(color) == QDialog::Accepted )
00231 {
00232 setCurrentColor(color);
00233 m_pRecentColor->insertColor(m_pCurrentColor);
00234 activate();
00235 }
00236 }
00237 }
00238
00239
00240
void TKSelectColorAction::slotActivated()
00241 {
00242
00243
00244 selectColorDialog();
00245 }
00246
00247
void TKSelectColorAction::activate()
00248 {
00249 emit colorSelected(m_pCurrentColor);
00250 emit activated();
00251 }
00252
00253
void TKSelectColorAction::panelColorSelected(
const QColor& color )
00254 {
00255 m_pMenu->hide();
00256 setCurrentColor(color);
00257
00258 activate();
00259 }
00260
00261
void TKSelectColorAction::panelReject()
00262 {
00263 m_pMenu->hide();
00264 }
00265
00266
class TKColorPanel::TKColorPanelPrivate
00267 {
00268
public:
00269 TKColorPanelPrivate()
00270 {
00271 panelCreated =
false;
00272 }
00273
00274
bool panelCreated;
00275 };
00276
00277
00278 TKColorPanel::TKColorPanel(
QWidget* parent,
const char* name )
00279 :
QWidget(parent,name)
00280 {
00281 d =
new TKColorPanel::TKColorPanelPrivate();
00282 m_activeColor = black;
00283
00284
00285
00286
00287 m_pLayout = 0L;
00288 setNumCols(15);
00289 }
00290
00291
void TKColorPanel::setNumCols(
int col )
00292 {
00293 m_iWidth = col;
00294 resetGrid();
00295
00296
QDictIterator<TKColorPanelButton> it(m_pColorDict);
00297
while ( it.current() ) {
00298 addToGrid(it.current());
00299 ++it;
00300 }
00301 }
00302
00303 TKColorPanel::~TKColorPanel()
00304 {
00305
delete d;
00306 }
00307
00308
void TKColorPanel::resetGrid()
00309 {
00310 m_iX = 0;
00311 m_iY = 0;
00312
00313
delete m_pLayout;
00314 m_pLayout =
new QGridLayout(
this,0,m_iWidth+1,0,0);
00315
00316 emit sizeChanged();
00317 }
00318
00319
void TKColorPanel::clear()
00320 {
00321 m_pColorDict.setAutoDelete(
true);
00322 m_pColorDict.clear();
00323 m_pColorDict.setAutoDelete(
false);
00324 d->panelCreated =
true;
00325
00326 resetGrid();
00327 }
00328
00329
void TKColorPanel::insertColor(
const QColor& color,
const QString& text )
00330 {
00331
if (m_pColorDict[color.name()])
00332
return;
00333
00334 insertColor(color);
00335 QToolTip::add(m_pColorDict[color.name()],text);
00336 }
00337
00338
void TKColorPanel::insertColor(
const QColor& color )
00339 {
00340
if (m_pColorDict[color.name()])
00341
return;
00342
00343 m_pLayout->setMargin(3);
00344 TKColorPanelButton* f =
new TKColorPanelButton(color,
this);
00345 m_pColorDict.insert(color.name(),f);
00346
if ( m_activeColor == color )
00347 f->setActive(
true);
00348
00349 connect(f,SIGNAL(selected(
const QColor&)),SLOT(selected(
const QColor&)));
00350
00351 addToGrid(f);
00352 }
00353
00354
void TKColorPanel::addToGrid( TKColorPanelButton* f )
00355 {
00356 m_pLayout->addWidget(f,m_iY,m_iX);
00357 f->show();
00358 m_iX++;
00359
if ( m_iX == m_iWidth ) {
00360 m_iX = 0;
00361 m_iY++;
00362 }
00363 emit sizeChanged();
00364 }
00365
00366
void TKColorPanel::setActiveColor(
const QColor& color )
00367 {
00368 TKColorPanelButton* b = m_pColorDict[m_activeColor.name()];
00369
if (b)
00370 b->setActive(
false);
00371
00372 m_activeColor = color;
00373
00374 b = m_pColorDict[m_activeColor.name()];
00375
if (b)
00376 b->setActive(
true);
00377 }
00378
00379
void TKColorPanel::mouseReleaseEvent(
QMouseEvent* )
00380 {
00381 reject();
00382 }
00383
00384
void TKColorPanel::showEvent(
QShowEvent *e )
00385 {
00386
if ( !d->panelCreated )
00387 fillPanel();
00388 QWidget::showEvent(e);
00389 }
00390
00391
void TKColorPanel::selected(
const QColor& color )
00392 {
00393 emit colorSelected(color);
00394 }
00395
00396
void TKColorPanel::fillPanel()
00397 {
00398 d->panelCreated =
true;
00399 blockSignals(
true);
00400
00401 insertColor(
QColor( 255, 0, 0 ), i18n(
"Red"));
00402 insertColor(
QColor( 255, 165, 0 ), i18n(
"Orange"));
00403 insertColor(
QColor( 255, 0, 255 ), i18n(
"Magenta"));
00404 insertColor(
QColor( 0, 0, 255 ), i18n(
"Blue"));
00405 insertColor(
QColor( 0, 255, 255 ), i18n(
"Cyan"));
00406 insertColor(
QColor( 0, 255, 0 ), i18n(
"Green"));
00407 insertColor(
QColor( 255, 255, 0 ), i18n(
"Yellow"));
00408 insertColor(
QColor( 165, 42, 42 ), i18n(
"Brown"));
00409 insertColor(
QColor( 139, 0, 0 ), i18n(
"Darkred"));
00410 insertColor(
QColor( 255, 140, 0 ), i18n(
"Dark Orange"));
00411 insertColor(
QColor( 139, 0, 139 ), i18n(
"Dark Magenta"));
00412 insertColor(
QColor( 0, 0, 139 ), i18n(
"Dark Blue"));
00413 insertColor(
QColor( 0, 139, 139 ), i18n(
"Dark Cyan"));
00414 insertColor(
QColor( 0, 100, 0 ), i18n(
"Dark Green"));
00415 insertColor(
QColor( 130, 127, 0 ), i18n(
"Dark Yellow"));
00416
00417 insertColor(
QColor( 255, 255, 255 ), i18n(
"White"));
00418 insertColor(
QColor( 229, 229, 229 ), i18n(
"Gray 90%"));
00419 insertColor(
QColor( 204, 204, 204 ), i18n(
"Gray 80%"));
00420 insertColor(
QColor( 178, 178, 178 ), i18n(
"Gray 70%"));
00421 insertColor(
QColor( 153, 153, 153 ), i18n(
"Gray 60%"));
00422 insertColor(
QColor( 127, 127, 127 ), i18n(
"Gray 50%"));
00423 insertColor(
QColor( 102, 102, 102 ), i18n(
"Gray 40%"));
00424 insertColor(
QColor( 76, 76, 76 ), i18n(
"Gray 30%"));
00425 insertColor(
QColor( 51, 51, 51 ), i18n(
"Gray 20%"));
00426 insertColor(
QColor( 25, 25, 25 ), i18n(
"Gray 10%"));
00427 insertColor(
QColor( 0, 0, 0 ), i18n(
"Black"));
00428
00429 insertColor(
QColor( 255, 255, 240 ), i18n(
"Ivory"));
00430 insertColor(
QColor( 255, 250, 250 ), i18n(
"Snow"));
00431 insertColor(
QColor( 245, 255, 250 ), i18n(
"Mint Cream"));
00432 insertColor(
QColor( 255, 250, 240 ), i18n(
"Floral White"));
00433 insertColor(
QColor( 255, 255, 224 ), i18n(
"Light Yellow"));
00434 insertColor(
QColor( 240, 255, 255 ), i18n(
"Azure"));
00435 insertColor(
QColor( 248, 248, 255 ), i18n(
"Ghost White"));
00436 insertColor(
QColor( 240, 255, 240 ), i18n(
"Honeydew"));
00437 insertColor(
QColor( 255, 245, 238 ), i18n(
"Seashell"));
00438 insertColor(
QColor( 240, 248, 255 ), i18n(
"Alice Blue"));
00439 insertColor(
QColor( 255, 248, 220 ), i18n(
"Cornsilk"));
00440 insertColor(
QColor( 255, 240, 245 ), i18n(
"Lavender Blush"));
00441 insertColor(
QColor( 253, 245, 230 ), i18n(
"Old Lace"));
00442 insertColor(
QColor( 245, 245, 245 ), i18n(
"White Smoke"));
00443 insertColor(
QColor( 255, 250, 205 ), i18n(
"Lemon Chiffon"));
00444 insertColor(
QColor( 224, 255, 255 ), i18n(
"Light Cyan"));
00445 insertColor(
QColor( 250, 250, 210 ), i18n(
"Light Goldenrod Yellow"));
00446 insertColor(
QColor( 250, 240, 230 ), i18n(
"Linen"));
00447 insertColor(
QColor( 245, 245, 220 ), i18n(
"Beige"));
00448 insertColor(
QColor( 255, 239, 213 ), i18n(
"Papaya Whip"));
00449 insertColor(
QColor( 255, 235, 205 ), i18n(
"Blanched Almond"));
00450 insertColor(
QColor( 250, 235, 215 ), i18n(
"Antique White"));
00451 insertColor(
QColor( 255, 228, 225 ), i18n(
"Misty Rose"));
00452 insertColor(
QColor( 230, 230, 250 ), i18n(
"Lavender"));
00453 insertColor(
QColor( 255, 228, 196 ), i18n(
"Bisque"));
00454 insertColor(
QColor( 255, 228, 181 ), i18n(
"Moccasin"));
00455 insertColor(
QColor( 255, 222, 173 ), i18n(
"Navajo White"));
00456 insertColor(
QColor( 255, 218, 185 ), i18n(
"Peach Puff"));
00457 insertColor(
QColor( 238, 232, 170 ), i18n(
"Pale Goldenrod"));
00458 insertColor(
QColor( 245, 222, 179 ), i18n(
"Wheat"));
00459 insertColor(
QColor( 220, 220, 220 ), i18n(
"Gainsboro"));
00460 insertColor(
QColor( 240, 230, 140 ), i18n(
"Khaki"));
00461 insertColor(
QColor( 175, 238, 238 ), i18n(
"Pale Turquoise"));
00462 insertColor(
QColor( 255, 192, 203 ), i18n(
"Pink"));
00463 insertColor(
QColor( 238, 221, 130 ), i18n(
"Light Goldenrod"));
00464 insertColor(
QColor( 211, 211, 211 ), i18n(
"Light Gray"));
00465 insertColor(
QColor( 255, 182, 193 ), i18n(
"Light Pink"));
00466 insertColor(
QColor( 176, 224, 230 ), i18n(
"Powder Blue"));
00467 insertColor(
QColor( 127, 255, 212 ), i18n(
"Aquamarine"));
00468 insertColor(
QColor( 216, 191, 216 ), i18n(
"Thistle"));
00469 insertColor(
QColor( 173, 216, 230 ), i18n(
"Light Blue"));
00470 insertColor(
QColor( 152, 251, 152 ), i18n(
"Pale Green"));
00471 insertColor(
QColor( 255, 215, 0 ), i18n(
"Gold"));
00472 insertColor(
QColor( 173, 255, 47 ), i18n(
"Green Yellow"));
00473 insertColor(
QColor( 176, 196, 222 ), i18n(
"Light Steel Blue"));
00474 insertColor(
QColor( 144, 238, 144 ), i18n(
"Light Green"));
00475 insertColor(
QColor( 221, 160, 221 ), i18n(
"Plum"));
00476 insertColor(
QColor( 190, 190, 190 ), i18n(
"Gray"));
00477 insertColor(
QColor( 222, 184, 135 ), i18n(
"Burly Wood"));
00478 insertColor(
QColor( 135, 206, 250 ), i18n(
"Light Skyblue"));
00479 insertColor(
QColor( 255, 160, 122 ), i18n(
"Light Salmon"));
00480 insertColor(
QColor( 135, 206, 235 ), i18n(
"Sky Blue"));
00481 insertColor(
QColor( 210, 180, 140 ), i18n(
"Tan"));
00482 insertColor(
QColor( 238, 130, 238 ), i18n(
"Violet"));
00483 insertColor(
QColor( 244, 164, 96 ), i18n(
"Sandy Brown"));
00484 insertColor(
QColor( 233, 150, 122 ), i18n(
"Dark Salmon"));
00485 insertColor(
QColor( 189, 183, 107 ), i18n(
"Dark khaki"));
00486 insertColor(
QColor( 127, 255, 0 ), i18n(
"Chartreuse"));
00487 insertColor(
QColor( 169, 169, 169 ), i18n(
"Dark Gray"));
00488 insertColor(
QColor( 124, 252, 0 ), i18n(
"Lawn Green"));
00489 insertColor(
QColor( 255, 105, 180 ), i18n(
"Hot Pink"));
00490 insertColor(
QColor( 250, 128, 114 ), i18n(
"Salmon"));
00491 insertColor(
QColor( 240, 128, 128 ), i18n(
"Light Coral"));
00492 insertColor(
QColor( 64, 224, 208 ), i18n(
"Turquoise"));
00493 insertColor(
QColor( 143, 188, 143 ), i18n(
"Dark Seagreen"));
00494 insertColor(
QColor( 218, 112, 214 ), i18n(
"Orchid"));
00495 insertColor(
QColor( 102, 205, 170 ), i18n(
"Medium Aquamarine"));
00496 insertColor(
QColor( 255, 127, 80 ), i18n(
"Coral"));
00497 insertColor(
QColor( 154, 205, 50 ), i18n(
"Yellow Green"));
00498 insertColor(
QColor( 218, 165, 32 ), i18n(
"Goldenrod"));
00499 insertColor(
QColor( 72, 209, 204 ), i18n(
"Medium Turquoise"));
00500 insertColor(
QColor( 188, 143, 143 ), i18n(
"Rosy Brown"));
00501 insertColor(
QColor( 219, 112, 147 ), i18n(
"Pale VioletRed"));
00502 insertColor(
QColor( 0, 250, 154 ), i18n(
"Medium Spring Green"));
00503 insertColor(
QColor( 255, 99, 71 ), i18n(
"Tomato"));
00504 insertColor(
QColor( 0, 255, 127 ), i18n(
"Spring Green"));
00505 insertColor(
QColor( 205, 133, 63 ), i18n(
"Peru"));
00506 insertColor(
QColor( 100, 149, 237 ), i18n(
"Cornflower Blue"));
00507 insertColor(
QColor( 132, 112, 255 ), i18n(
"Light Slate Blue"));
00508 insertColor(
QColor( 147, 112, 219 ), i18n(
"Medium Purple"));
00509 insertColor(
QColor( 186, 85, 211 ), i18n(
"Medium Orchid"));
00510 insertColor(
QColor( 95, 158, 160 ), i18n(
"Cadet Blue"));
00511 insertColor(
QColor( 0, 206, 209 ), i18n(
"Dark Turquoise"));
00512 insertColor(
QColor( 0, 191, 255 ), i18n(
"Deep Skyblue"));
00513 insertColor(
QColor( 119, 136, 153 ), i18n(
"Light Slate Gray"));
00514 insertColor(
QColor( 184, 134, 11 ), i18n(
"Dark Goldenrod"));
00515 insertColor(
QColor( 123, 104, 238 ), i18n(
"MediumSlate Blue"));
00516 insertColor(
QColor( 205, 92, 92 ), i18n(
"IndianRed"));
00517 insertColor(
QColor( 210, 105, 30 ), i18n(
"Chocolate"));
00518 insertColor(
QColor( 60, 179, 113 ), i18n(
"Medium Sea Green"));
00519 insertColor(
QColor( 50, 205, 50 ), i18n(
"Lime Green"));
00520 insertColor(
QColor( 32, 178, 170 ), i18n(
"Light Sea Green"));
00521 insertColor(
QColor( 112, 128, 144 ), i18n(
"Slate Gray"));
00522 insertColor(
QColor( 30, 144, 255 ), i18n(
"Dodger Blue"));
00523 insertColor(
QColor( 255, 69, 0 ), i18n(
"Orange Red"));
00524 insertColor(
QColor( 255, 20, 147 ), i18n(
"Deep Pink"));
00525 insertColor(
QColor( 70, 130, 180 ), i18n(
"Steel Blue"));
00526 insertColor(
QColor( 106, 90, 205 ), i18n(
"Slate Blue"));
00527 insertColor(
QColor( 107, 142, 35 ), i18n(
"Olive Drab"));
00528 insertColor(
QColor( 65, 105, 225 ), i18n(
"Royal Blue"));
00529 insertColor(
QColor( 208, 32, 144 ), i18n(
"Violet Red"));
00530 insertColor(
QColor( 153, 50, 204 ), i18n(
"Dark Orchid"));
00531 insertColor(
QColor( 160, 32, 240 ), i18n(
"Purple"));
00532 insertColor(
QColor( 105, 105, 105 ), i18n(
"Dim Gray"));
00533 insertColor(
QColor( 138, 43, 226 ), i18n(
"Blue Violet"));
00534 insertColor(
QColor( 160, 82, 45 ), i18n(
"Sienna"));
00535 insertColor(
QColor( 199, 21, 133 ), i18n(
"Medium Violet Red"));
00536 insertColor(
QColor( 176, 48, 96 ), i18n(
"Maroon"));
00537 insertColor(
QColor( 46, 139, 87 ), i18n(
"Sea Green"));
00538 insertColor(
QColor( 85, 107, 47 ), i18n(
"Dark Olive Green"));
00539 insertColor(
QColor( 34, 139, 34 ), i18n(
"Forest Green"));
00540 insertColor(
QColor( 139, 69, 19 ), i18n(
"Saddle Brown"));
00541 insertColor(
QColor( 148, 0, 211 ), i18n(
"Darkviolet"));
00542 insertColor(
QColor( 178, 34, 34 ), i18n(
"Fire Brick"));
00543 insertColor(
QColor( 72, 61, 139 ), i18n(
"Dark Slate Blue"));
00544 insertColor(
QColor( 47, 79, 79 ), i18n(
"Dark Slate Gray"));
00545 insertColor(
QColor( 25, 25, 112 ), i18n(
"Midnight Blue"));
00546 insertColor(
QColor( 0, 0, 205 ), i18n(
"Medium Blue"));
00547 insertColor(
QColor( 0, 0, 128 ), i18n(
"Navy"));
00548
00549 blockSignals(
false);
00550 emit sizeChanged();
00551 }
00552
00553
00554 TKColorPanelButton::TKColorPanelButton(
const QColor& color,
QWidget* parent,
const char* name )
00555 :
QFrame(parent,name), m_Color(color), m_bActive(false)
00556 {
00557 setFixedSize(16,16);
00558 setFrameStyle( NoFrame );
00559 }
00560
00561 TKColorPanelButton::~TKColorPanelButton()
00562 {
00563 }
00564
00565
void TKColorPanelButton::enterEvent(
QEvent* )
00566 {
00567
if (!m_bActive)
00568 setFrameStyle( Panel | Sunken );
00569 }
00570
00571
void TKColorPanelButton::leaveEvent(
QEvent* )
00572 {
00573
if (!m_bActive)
00574 setFrameStyle( NoFrame );
00575 }
00576
00577
void TKColorPanelButton::paintEvent(
QPaintEvent* ev )
00578 {
00579 QFrame::paintEvent(ev);
00580
00581
QPainter p(
this,
this);
00582 p.fillRect(2,2,12,12,m_Color);
00583 p.setPen(gray);
00584 p.drawRect(2,2,12,12);
00585 p.end();
00586 }
00587
00588
void TKColorPanelButton::setActive(
bool f )
00589 {
00590 m_bActive = f;
00591 setFrameStyle( m_bActive ? Panel | Sunken : NoFrame );
00592 }
00593
00594
void TKColorPanelButton::mouseReleaseEvent(
QMouseEvent* )
00595 {
00596 emit selected(m_Color);
00597 }
00598
#include "tkcoloractions.moc"
This file is part of the documentation for lib Library Version 1.3.5.