21 #include "krsqueezedtextlabel.h"
22 #include "kstringhandler.h"
23 #include <tqtooltip.h>
26 : TQLabel ( parent, name ) {
27 setSizePolicy(TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
33 : TQLabel ( parent, name ) {
34 setSizePolicy(TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
41 TQSize KRSqueezedTextLabel::minimumSizeHint()
const
43 TQSize sh = TQLabel::minimumSizeHint();
48 TQSize KRSqueezedTextLabel::sizeHint()
const
50 return TQSize(contentsRect().width(), TQLabel::sizeHint().height());
53 void KRSqueezedTextLabel::setText(
const TQString &text ) {
59 TQFontMetrics fm(fontMetrics());
60 int labelWidth = size().width();
61 int textWidth = fm.width(fullText);
62 if (textWidth > labelWidth) {
63 TQString squeezedText = KStringHandler::rPixelSqueeze(fullText, fm, labelWidth);
64 TQLabel::setText(squeezedText);
66 TQToolTip::remove(
this );
67 TQToolTip::add(
this, fullText );
70 TQLabel::setText(fullText);
72 TQToolTip::remove(
this );
81 TQString tmpFull(fullText);
82 TQLabel::setAlignment(alignment);
86 #include "krsqueezedtextlabel.moc"
void squeezeTextToLabel()
does the dirty work
KRSqueezedTextLabel(TQWidget *parent, const char *name=0)
Default constructor.
virtual void setAlignment(int)
Overridden for internal reasons; the API remains unaffected.
void resizeEvent(TQResizeEvent *)
used when widget is resized