#include <LegendItemWidget.h>
Public Member Functions | |
| LegendItemDisplay () | |
| LegendItemDisplay (const LegendItem &o) | |
| void | paint (QPainter &p, double dotpercm, int x, int y, int w, int h) const |
| void | setDisplayText (bool b) |
| QSize | sizeHint (const QFont &font) const |
| ~LegendItemDisplay () | |
Protected Attributes | |
| bool | _displayText |
References _displayText, and TRACE.
{
TRACE;
_displayText=true;
}
| SciFigs::LegendItemDisplay::LegendItemDisplay | ( | const LegendItem & | o | ) |
References _displayText, and TRACE.
: LegendItem(o) { TRACE; _displayText=true; }
| SciFigs::LegendItemDisplay::~LegendItemDisplay | ( | ) | [inline] |
{}
| void SciFigs::LegendItemDisplay::paint | ( | QPainter & | p, |
| double | dotpercm, | ||
| int | x, | ||
| int | y, | ||
| int | w, | ||
| int | h | ||
| ) | const |
References _displayText, SciFigs::LegendItem::_pen, SciFigs::LegendItem::_symbol, SciFigs::LegendItem::_text, SciFigs::LegendItem::_textColor, MAX_INT, SciFigs::Symbol::paint(), SciFigs::Pen::qpen(), and TRACE.
Referenced by ProcessStatusDelegate::paint().
{
TRACE;
p.fillRect(x, y, w, h, Qt::white);
int lim=w;
if(_displayText) {
QRect r=p.boundingRect(0,0,MAX_INT,h,Qt::AlignLeft | Qt::AlignVCenter,_text);
lim-=r.width();
if(lim<1.4*dotpercm) lim=(int)floor(1.4*dotpercm+0.5);
r.translate(lim,0);
p.setBrush(_textColor);
p.drawText(r, Qt::AlignLeft | Qt::AlignVCenter, _text);
}
p.setPen(_pen.qpen(dotpercm));
int yc=y+(h >> 1);
p.drawLine(x, yc, x+lim, yc);
_symbol.paint(p, QPointF(x+(lim >> 1), yc));
}
| void SciFigs::LegendItemDisplay::setDisplayText | ( | bool | b | ) | [inline] |
Referenced by ProcessStatusDelegate::paint(), and ProcessStatusDelegate::sizeHint().
{_displayText=b;}
| QSize SciFigs::LegendItemDisplay::sizeHint | ( | const QFont & | font | ) | const |
References _displayText, SciFigs::LegendItem::_pen, SciFigs::LegendItem::_text, MAX_INT, SciFigs::SciFigsGlobal::screenResolution(), SciFigs::Pen::screenWidth(), and TRACE.
Referenced by SciFigs::LegendItemWidget::sizeHint(), and ProcessStatusDelegate::sizeHint().
{
TRACE;
int spw=_pen.screenWidth(SciFigsGlobal::screenResolution())+8;
if(_displayText) {
QFontMetrics f(font);
QRect r=f.boundingRect(0,0,MAX_INT,MAX_INT, Qt::AlignLeft | Qt::AlignTop,_text);
QSize s;
if(spw>r.height())
s.setHeight(spw);
else
s.setHeight(r.height());
s.setWidth(r.width()+25);
return s;
}
else return QSize(25,spw);
}
bool SciFigs::LegendItemDisplay::_displayText [protected] |
Referenced by LegendItemDisplay(), paint(), and sizeHint().