19 #include "ksqueezedtextlabel.h"
20 #include "kstringhandler.h"
21 #include <tqtooltip.h>
24 : TQLabel ( parent,
name ) {
25 setSizePolicy(TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
31 : TQLabel ( parent, name ) {
32 setSizePolicy(TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
39 TQSize KSqueezedTextLabel::minimumSizeHint()
const
41 TQSize sh = TQLabel::minimumSizeHint();
46 TQSize KSqueezedTextLabel::sizeHint()
const
48 return TQSize(contentsRect().width(), TQLabel::sizeHint().height());
51 void KSqueezedTextLabel::setText(
const TQString &text ) {
57 TQFontMetrics fm(fontMetrics());
58 int labelWidth = size().width();
59 int textWidth = fm.width(fullText);
60 if (textWidth > labelWidth) {
62 TQLabel::setText(squeezedText);
64 TQToolTip::remove(
this );
65 TQToolTip::add(
this, fullText );
68 TQLabel::setText(fullText);
70 TQToolTip::remove(
this );
79 TQString tmpFull(fullText);
80 TQLabel::setAlignment(alignment);
84 void KSqueezedTextLabel::virtual_hook(
int,
void* )
87 #include "ksqueezedtextlabel.moc"
virtual void setAlignment(int)
Overridden for internal reasons; the API remains unaffected.
void resizeEvent(TQResizeEvent *)
used when widget is resized
void squeezeTextToLabel()
does the dirty work
KSqueezedTextLabel(TQWidget *parent, const char *name=0)
Default constructor.
static TQString cPixelSqueeze(const TQString &name, const TQFontMetrics &fontMetrics, uint maxPixels)
TQString name(StdAccel id)