20#include "kexidropdownbutton.h"
22#include <tdepopupmenu.h>
26#include <tqapplication.h>
29 : TQToolButton(parent, "KexiDBImageBox::Button")
31 setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Expanding);
36 if (tqstricmp(style().name(), "thinkeramik")==0)
39 fixedWidth = style().querySubControlMetrics( TQStyle::CC_ComboBox,
40 this, TQStyle::SC_ComboBoxArrow ).width();
41 setFixedWidth( fixedWidth );
45KexiDropDownButton::~KexiDropDownButton()
49void KexiDropDownButton::drawButton( TQPainter *p )
51 TQToolButton::drawButton(p);
52 TQStyle::SFlags arrowFlags = TQStyle::Style_Default;
53 if (isDown() || state()==On)
54 arrowFlags |= TQStyle::Style_Down;
56 arrowFlags |= TQStyle::Style_Enabled;
57 style().drawPrimitive(TQStyle::PE_ArrowDown, p,
58 TQRect((width()-7)/2, height()-9, 7, 7), colorGroup(),
59 arrowFlags, TQStyleOption() );
62TQSize KexiDropDownButton::sizeHint () const
64 return TQSize( fontMetrics().maxWidth() + 2*2, fontMetrics().height()*2 + 2*2 );
67void KexiDropDownButton::keyPressEvent( TQKeyEvent * e )
69 const int k = e->key();
70 const bool dropDown = (e->state() == TQt::NoButton && (k==TQt::Key_Space || k==TQt::Key_Enter || k==TQt::Key_Return || k==TQt::Key_F2 || k==TQt::Key_F4))
71 || (e->state() == TQt::AltButton && k==TQt::Key_Down);
75 TQMouseEvent me( TQEvent::MouseButtonPress, TQPoint(2,2), TQt::LeftButton, TQt::NoButton );
76 TQApplication::sendEvent( this, &me );
79 TQToolButton::keyPressEvent(e);
82#include "kexidropdownbutton.moc"
|