void EDA_MSG_PANEL::AppendMessage( const wxString& aUpperText, const wxString& aLowerText, EDA_COLOR_T aColor, int aPad ) { wxString text; wxSize drawSize = GetClientSize(); text = ( aUpperText.Len() > aLowerText.Len() ) ? aUpperText : aLowerText; text.Append( ' ', aPad ); MSG_PANEL_ITEM item; /* Don't put the first message a window client position 0. Offset by * one 'W' character width. */ if( m_last_x == 0 ) m_last_x = m_fontSize.x; item.m_X = m_last_x; item.m_UpperY = ( drawSize.y / 2 ) - m_fontSize.y; item.m_LowerY = drawSize.y - m_fontSize.y; item.m_UpperText = aUpperText; item.m_LowerText = aLowerText; item.m_Color = aColor; m_Items.push_back( item ); m_last_x += computeTextSize( text ).x; // Add an extra space between texts for a better look: m_last_x += m_fontSize.x; Refresh(); }
void KstPlotLabel::load(const QDomElement& e) { bool upLS = false; QDomNode n = e.firstChild(); while (!n.isNull()) { QDomElement e = n.toElement(); // try to convert the node to an element. if (!e.isNull()) { // the node was really an element. if (e.tagName() == "text") { setText(e.text()); } else if (e.tagName() == "justify") { _justify = KstLJustifyType(e.text().toInt()); } else if (e.tagName() == "rotation") { _rotation = e.text().toFloat(); } else if (e.tagName() == "interpret") { _interpret = true; } else if (e.tagName() == "fontfamily") { _fontName = e.text(); upLS = true; } else if ((e.tagName() == "fontsize") || (e.tagName() == "size")) { _fontSize = e.text().toInt(); upLS = true; } else if (e.tagName() == "useusercolor") { // Unsupported } else if (e.tagName() == "color") { // Unsupported } } n = n.nextSibling(); } if (upLS) { computeTextSize(); } }
void KstPlotLabel::setFontName(const QString& fontName) { if (_fontName != fontName) { _fontName = fontName; computeTextSize(); //setDirty(true); } }
void KstPlotLabel::setText(const QString& text) { if (_txt != text) { _txt = text; _scalarsUsed.clear(); _stringsUsed.clear(); _vectorsUsed.clear(); reparse(); computeTextSize(); //setDirty(true); } }
QSize KstViewLegend::sizeForText(const QRect& w) { double x_s, y_s; x_s = y_s = _fontSize + (double)KstSettings::globalSettings()->plotFontSize; int x_pix = w.width(); int y_pix = w.height(); if (x_pix < y_pix) { x_s *= x_pix/540.0; y_s *= y_pix/748.0; } else { y_s *= y_pix/540.0; x_s *= x_pix/748.0; } _absFontSize = int((x_s + y_s)/2.0); if (_absFontSize < KstSettings::globalSettings()->plotFontMinSize) { _absFontSize = KstSettings::globalSettings()->plotFontMinSize; } computeTextSize(); int width, height; if (_vertical) { width = qMax(_textWidth + 9*_ascent/2, _titleWidth); height = _textHeight; if (_titleHeight > 0) { height += _titleHeight; } } else { height = qMax(_textHeight, _titleHeight); if (_titleWidth > 0) { width = _titleWidth + _textWidth + 9*_ascent*_curves.count()/2; } else { width = _textWidth + 9*_ascent*_curves.count()/2 - _ascent; } } QSize sz(width, height); sz += QSize(2 * _legendMargin * _ascent / 10, 2 * _legendMargin * _ascent / 10); if (_parent) { QRect r(position(), sz); sz = r.intersect(_parent->geometry()).size(); } return sz; }
void KstPlotLabel::commonConstructor(const QString& txt, const QString& font, int fontSize, KstLJustifyType justify, float rotation) { _txt = txt; _interpret = true; _replace = true; _rotation = rotation; _sinr = fabs(sin(_rotation * M_PI / 180.0)); _cosr = fabs(cos(_rotation * M_PI / 180.0)); _justify = justify; _fontName = font; _fontSize = fontSize; _absFontSize = fontSize;// + KstSettings::globalSettings()->plotFontSize; _parsed = 0L; reparse(); computeTextSize(); }
void KstPlotLabel::updateAbsFontSize(int x_pix, int y_pix) { double x_s, y_s; x_s = y_s = _fontSize + (double)KstSettings::globalSettings()->plotFontSize; if (x_pix < y_pix) { x_s *= x_pix/540.0; y_s *= y_pix/748.0; } else { y_s *= y_pix/540.0; x_s *= x_pix/748.0; } _absFontSize = int((x_s + y_s)/2); if (_absFontSize < KstSettings::globalSettings()->plotFontMinSize) { _absFontSize = KstSettings::globalSettings()->plotFontMinSize; } computeTextSize(); }
KstViewLabel::KstViewLabel(const QString& txt, KstLJustifyType justify, float rotation) : KstBorderedViewObject("Label") { _fallThroughTransparency = false; _container = false; _dataPrecision = 8; _txt = txt; _interpret = true; _replace = true; _rotation = rotation; _justify = justify; _fontName = KstApp::inst()->defaultFont(); _fontSize = -1; setFontSize(0); _standardActions |= Delete | Edit | Rename; _parsed = 0L; _labelMargin = 0; _isResizable = false; reparse(); computeTextSize(_parsed); }
KstViewLegend::KstViewLegend() : KstBorderedViewObject("Legend") { _fallThroughTransparency = false; _container = false; _rotation = 0; _vertical = true; _fontName = KstApp::inst()->defaultFont(); _isResizable = false; setForegroundColor(KstSettings::globalSettings()->foregroundColor); setBorderColor(KstSettings::globalSettings()->foregroundColor); setBackgroundColor(KstSettings::globalSettings()->backgroundColor); setBorderWidth(2); _legendMargin = 5; _fontSize = -1; setFontSize(0); _layoutActions &= ~(MoveTo | Copy | CopyTo); _standardActions |= Delete | Edit; _parsedTitle = 0L; _trackContents = true; reparseTitle(); computeTextSize(); setDirty(false); }
KstViewLegend::KstViewLegend(const KstViewLegend& legend) : KstBorderedViewObject(legend) { _type = "Legend"; _layoutActions &= ~(MoveTo | Copy | CopyTo); _standardActions |= Delete | Edit; _fallThroughTransparency = legend._fallThroughTransparency; _container = legend._container; _rotation = legend._rotation; _fontName = legend._fontName; _fontSize = legend._fontSize; _vertical = legend._vertical; _isResizable = legend._isResizable; _absFontSize = legend._absFontSize; _legendMargin = legend._legendMargin; _title = legend._title; _parsedTitle = 0L; _trackContents = legend._trackContents; _curves = Q3DeepCopy<KstBaseCurveList>(legend._curves); reparseTitle(); computeTextSize(); }
QSize KstViewLabel::sizeForText(const QRect& w) { double x_s, y_s; x_s = y_s = _fontSize + (double)KstSettings::globalSettings()->plotFontSize; int x_pix = w.width(); int y_pix = w.height(); if (x_pix < y_pix) { x_s *= x_pix/540.0; y_s *= y_pix/748.0; } else { y_s *= y_pix/540.0; x_s *= x_pix/748.0; } _absFontSize = int((x_s + y_s)/2.0); if (_absFontSize < KstSettings::globalSettings()->plotFontMinSize) { _absFontSize = KstSettings::globalSettings()->plotFontMinSize; } if (!_parsed) { reparse(); } if (_parsed) { computeTextSize(_parsed); } QSize sz(kMax(1, _textWidth), kMax(1, _textHeight)); if (int(_rotation) != 0 && int(_rotation) != 180) { QPointArray pts(4); pts[0] = QPoint(0, 0); pts[1] = QPoint(0, _textHeight); pts[2] = QPoint(_textWidth, _textHeight); pts[3] = QPoint(_textWidth, 0); double theta = M_PI * (int(_rotation) % 360) / 180; double sina = sin(theta); double cosa = cos(theta); QWMatrix m(cosa, sina, -sina, cosa, 0.0, 0.0); pts = m.map(pts); if (_parent) { QRect r(position(), pts.boundingRect().size()); r.setSize(r.size() + QSize(2 * _labelMargin * _ascent / 10, 2 * _labelMargin * _ascent / 10)); sz = r.intersect(_parent->geometry()).size(); } else { sz = pts.boundingRect().size(); sz += QSize(2 * _labelMargin * _ascent / 10, 2 * _labelMargin * _ascent / 10); } } else { if (_parent) { QRect r(position(), sz); r.setSize(r.size() + QSize(2 * _labelMargin * _ascent / 10, 2 * _labelMargin * _ascent / 10)); sz = r.intersect(_parent->geometry()).size(); } } return sz; }