20#include "kexiarrowtip.h"
28#include <tqfontmetrics.h>
31#include <kexiutils/utils.h>
33KexiArrowTip::KexiArrowTip(
const TQString& text, TQWidget* parent)
37 TQPalette pal( palette() );
38 TQColorGroup cg(pal.active());
39 cg.setColor(TQColorGroup::Foreground, TQt::red);
43 TQFontMetrics fm(font());
44 TQSize sz(fm.boundingRect(m_value.toString()).size());
46 m_arrowHeight = sz.height()/2;
47 sz += TQSize(0, m_arrowHeight);
53 TQPixmap maskPm(size());
55 TQPainter maskPainter(&maskPm);
56 drawFrame(maskPainter);
57 TQImage maskImg( maskPm.convertToImage() );
59 bm = maskImg.createHeuristicMask();
63KexiArrowTip::~KexiArrowTip()
67void KexiArrowTip::show()
73 setWindowOpacity(0.0);
78void KexiArrowTip::hide()
86void KexiArrowTip::increaseOpacity()
89 setWindowOpacity(m_opacity);
91 TQTimer::singleShot(25,
this, TQ_SLOT(increaseOpacity()));
94void KexiArrowTip::decreaseOpacity()
102 setWindowOpacity(m_opacity);
103 TQTimer::singleShot(25,
this, TQ_SLOT(decreaseOpacity()));
106bool KexiArrowTip::close (
bool alsoDelete )
109 return KexiToolTip::close(alsoDelete);
114 return KexiToolTip::close(alsoDelete);
115 return m_opacity<=0.0;
118void KexiArrowTip::drawContents(TQPainter& p)
120 p.setPen( TQPen(palette().active().foreground(), 1) );
121 p.drawText(TQRect(0,m_arrowHeight,width(),height()-m_arrowHeight),
122 TQt::AlignCenter, m_value.toString());
125void KexiArrowTip::drawFrame(TQPainter& p)
127 TQPen pen(palette().active().foreground(), 1, TQt::SolidLine, TQt::SquareCap, TQt::MiterJoin);
136 const int arrowOffset = 5;
138 pa.setPoint(0, 0, m_arrowHeight-1);
139 pa.setPoint(1, 0, height()-1);
140 pa.setPoint(2, width()-1, height()-1);
141 pa.setPoint(3, width()-1, m_arrowHeight-1);
142 pa.setPoint(4, arrowOffset+m_arrowHeight+m_arrowHeight-2, m_arrowHeight-1);
143 pa.setPoint(5, arrowOffset+m_arrowHeight-1, 0);
144 pa.setPoint(6, arrowOffset, m_arrowHeight-1);
145 pa.setPoint(7, 0, m_arrowHeight-1);
149 pa.setPoint(0, 1, m_arrowHeight);
150 pa.setPoint(1, 1, height()-2);
151 pa.setPoint(2, width()-2, height()-2);
152 pa.setPoint(3, width()-2, m_arrowHeight);
153 pa.setPoint(4, arrowOffset+m_arrowHeight+m_arrowHeight-2, m_arrowHeight);
154 pa.setPoint(5, arrowOffset+m_arrowHeight-1, 1);
155 pa.setPoint(6, arrowOffset, m_arrowHeight);
156 pa.setPoint(7, 0, m_arrowHeight);
157 pa.setPoint(8, arrowOffset+1, m_arrowHeight);
158 pa.setPoint(9, arrowOffset+m_arrowHeight-1, 2);
159 pa.setPoint(10, arrowOffset+m_arrowHeight+m_arrowHeight-3, m_arrowHeight);
160 pa.setPoint(11, width()-2, m_arrowHeight);
164#include "kexiarrowtip.moc"