14#include "richtextlabel.h"
16RichTextLabel::RichTextLabel(karamba* k) :
17 Meter(k, 0, 0, 100, 100),
20 colorGrp(k->colorGroup()),
23 originalSize = TQSize(0, 0);
26RichTextLabel::RichTextLabel(karamba* k,
int x,
int y,
int w,
int h) :
30 colorGrp(k->colorGroup()),
33 kdDebug() << k_funcinfo << x <<
", " << y <<
", " << w <<
", " << h << endl;
34 originalSize = TQSize(w, h);
37RichTextLabel::~RichTextLabel()
46void RichTextLabel::setText(TQString t,
bool linkUnderline)
58 underlineLinks = linkUnderline;
61 text =
new TQSimpleRichText(t, font, m_karamba->theme().path(),
70 if(originalSize.width() < 1)
71 setWidth(text->width());
73 text->setWidth(getWidth());
74 if(originalSize.height() < 1)
75 setHeight(text->height());
78void RichTextLabel::setValue(TQString text)
83void RichTextLabel::setValue(
long v)
85 setText(TQString::number(v));
88void RichTextLabel::setFont(TQString f)
92 text->setDefaultFont(font);
95TQString RichTextLabel::getFont()
const
100void RichTextLabel::setFontSize(
int size)
102 font.setPixelSize(size);
104 text->setDefaultFont(font);
107int RichTextLabel::getFontSize()
const
109 return font.pixelSize();
112void RichTextLabel::setFixedPitch(
bool fp)
114 font.setFixedPitch(fp);
116 text->setDefaultFont(font);
119bool RichTextLabel::getFixedPitch()
const
121 return font.fixedPitch();
124void RichTextLabel::setTextProps(
TextField* t)
128 setFontSize(t->getFontSize());
129 setFont(t->getFont());
130 colorGrp.setColor(TQColorGroup::Text, t->getColor());
134void RichTextLabel::setWidth(
int width)
136 Meter::setWidth(width);
138 text->setWidth(getWidth());
139 if(originalSize.height() < 1)
140 setHeight(text->height());
143void RichTextLabel::mUpdate(TQPainter* p)
145 if (hidden || text == 0)
154 TQRect clipRect(x, y, w, h);
155 text->draw(p, x, y, clipRect, colorGrp, 0 );
158bool RichTextLabel::click(TQMouseEvent* e)
164 TQPoint point(e->x() - getX(), e->y() - getY());
165 TQString anchor = text->anchorAt(point);
166 if (anchor[0] !=
'#')
168 if (e->button() == TQt::LeftButton)
170 KRun :: runCommand(anchor);
181TQString RichTextLabel::anchorAt(
int x,
int y)
183 TQPoint point(x - getX(), y - getY());
184 TQString anchor = text->anchorAt(point);
185 if (anchor[0] ==
'#')
187 return anchor.remove(0, 1);
196bool RichTextLabel::insideActiveArea(
int x,
int y)
198 TQPoint point(x - getX(), y - getY());
199 return text->anchorAt(point) !=
"";
202void RichTextLabel::setColorGroup(
const TQColorGroup &colorg)
207const TQColorGroup & RichTextLabel::getColorGroup()
const
212#include "richtextlabel.moc"