19 #include "karrowbutton.h"
22 #include <tqpainter.h>
24 class KArrowButtonPrivate
32 : TQPushButton(parent, name)
34 d =
new KArrowButtonPrivate();
45 return TQSize( 12, 12 );
62 const unsigned int arrowSize = 8;
63 const unsigned int margin = 2;
65 p->fillRect( rect(), colorGroup().brush( TQColorGroup::Background ) );
66 style().drawPrimitive( TQStyle::PE_Panel, p, TQRect( 0, 0, width(), height() ),
68 isDown() ? TQStyle::Style_Sunken : TQStyle::Style_Default,
69 TQStyleOption( 2, 0 ) );
71 if (
static_cast<unsigned int>(width()) < arrowSize + margin ||
72 static_cast<unsigned int>(height()) < arrowSize + margin)
75 unsigned int x = 0, y = 0;
76 if (d->arrow == DownArrow) {
77 x = (width() - arrowSize) / 2;
78 y = height() - (arrowSize + margin);
79 }
else if (d->arrow == UpArrow) {
80 x = (width() - arrowSize) / 2;
82 }
else if (d->arrow == RightArrow) {
83 x = width() - (arrowSize + margin);
84 y = (height() - arrowSize) / 2;
87 y = (height() - arrowSize) / 2;
95 TQStyle::PrimitiveElement e = TQStyle::PE_ArrowLeft;
98 case TQt::LeftArrow: e = TQStyle::PE_ArrowLeft;
break;
99 case TQt::RightArrow: e = TQStyle::PE_ArrowRight;
break;
100 case TQt::UpArrow: e = TQStyle::PE_ArrowUp;
break;
101 case TQt::DownArrow: e = TQStyle::PE_ArrowDown;
break;
103 int flags = TQStyle::Style_Enabled;
105 flags |= TQStyle::Style_Down;
106 style().drawPrimitive( e, p, TQRect( TQPoint( x, y ), TQSize( arrowSize, arrowSize ) ),
107 colorGroup(), flags );
110 void KArrowButton::virtual_hook(
int,
void* )
113 #include "karrowbutton.moc"