22#include <tqpushbutton.h>
23#include <tqapplication.h>
24#include <tqclipboard.h>
26#include <tqdrawutil.h>
37#include <kcolordialog.h>
40#include <koFrameButton.h>
42#include <kis_canvas_subject.h>
44#include <kis_color_cup.h>
46KisColorPopup::KisColorPopup(TQColor c, TQWidget * parent, const char * name)
47 : TQFrame(parent, name, WType_Popup | WStyle_Customize | WStyle_NoBorder)
51 setFocusPolicy(TQWidget::StrongFocus);
52 TQHBoxLayout * l = new TQHBoxLayout( this);
53 l->add(m_khsSelector = new KHSSelector( this));
54 m_khsSelector->setMinimumSize(140, 7);
55 l->add(m_valueSelector = new KValueSelector( this));
56 m_valueSelector->setMinimumSize(26, 70);
57 m_khsSelector->show();
58 m_valueSelector->show();
62KisColorCup::KisColorCup(TQWidget * parent, const char * name)
63 : TQPushButton(parent, name)
66 m_popup = new KisColorPopup(m_color, this, "colorpopup");
67 connect( this, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotClicked()));
68 connect(m_popup, TQ_SIGNAL(changed( const TQColor &)), this, TQ_SLOT(setColor( const TQColor &)));
71void KisColorCup::setColor( const TQColor & c)
77void KisColorCup::slotClicked()
81 emit changed(m_color);
84TQSize KisColorCup::sizeHint() const
86 return style().sizeFromContents(TQStyle::CT_PushButton, this, TQSize(24, 24)).
87 expandedTo(TQApplication::globalStrut());
90void KisColorCup::drawButtonLabel( TQPainter *painter )
93 TQRect r = style().subRect( TQStyle::SR_PushButtonContents, this );
94 r.rect(&x, &y, &w, &h);
102 if (isOn() || isDown()) {
103 x += style().pixelMetric( TQStyle::PM_ButtonShiftHorizontal, this );
104 y += style().pixelMetric( TQStyle::PM_ButtonShiftVertical, this );
107 qDrawShadePanel( painter, x, y, w, h, colorGroup(), true, 1, NULL);
108 if ( m_color.isValid() )
109 painter->fillRect( x+1, y+1, w-2, h-2, m_color );
112 TQRect focusRect = style().subRect( TQStyle::SR_PushButtonFocusRect, this );
113 style().drawPrimitive( TQStyle::PE_FocusRect, painter, focusRect, colorGroup() );
118#include "kis_color_cup.moc"
|