Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_text_label.cpp


Ignore:
Timestamp:
May 10, 2017, 3:20:54 PM (7 years ago)
Author:
stoecker
Message:

update qwt and qwtpolar, many QT5 fixes (unfinished)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_text_label.cpp

    r4271 r8127  
    6464
    6565/*!
     66   Interface for the designer plugin - does the same as setText()
     67   \sa plainText()
     68 */
     69void QwtTextLabel::setPlainText( const QString &text )
     70{
     71    setText( QwtText( text ) );
     72}
     73
     74/*!
     75   Interface for the designer plugin
     76
     77   \return Text as plain text
     78   \sa setPlainText(), text()
     79 */
     80QString QwtTextLabel::plainText() const
     81{
     82    return d_data->text.text();
     83}
     84
     85/*!
    6686   Change the label's text, keeping all other QwtText attributes
    6787   \param text New text
     
    7090  \sa QwtText
    7191*/
    72 void QwtTextLabel::setText( const QString &text, QwtText::TextFormat textFormat )
     92void QwtTextLabel::setText( const QString &text,
     93    QwtText::TextFormat textFormat )
    7394{
    7495    d_data->text.setText( text, textFormat );
     
    126147}
    127148
    128 //! Return label's text indent in pixels
     149//! Return label's text margin in pixels
    129150int QwtTextLabel::margin() const
    130151{
     
    144165}
    145166
    146 //! Return label's margin in pixels
     167//! Return a size hint
    147168QSize QwtTextLabel::sizeHint() const
    148169{
     
    177198
    178199/*!
    179    Returns the preferred height for this widget, given the width.
    180200   \param width Width
     201   \return Preferred height for this widget, given the width.
    181202*/
    182203int QwtTextLabel::heightForWidth( int width ) const
     
    192213        width -= indent;
    193214
    194     int height = d_data->text.heightForWidth( width, font() );
    195     if ( renderFlags & Qt::AlignTop || renderFlags & Qt::AlignBottom )
     215    int height = qCeil( d_data->text.heightForWidth( width, font() ) );
     216    if ( ( renderFlags & Qt::AlignTop ) || ( renderFlags & Qt::AlignBottom ) )
    196217        height += indent;
    197218
     
    232253    painter->setPen( palette().color( QPalette::Active, QPalette::Text ) );
    233254
    234     drawText( painter, r );
     255    drawText( painter, QRectF( r ) );
    235256
    236257    if ( hasFocus() )
    237258    {
    238         const int margin = 2;
    239 
    240         QRect focusRect = contentsRect();
    241         focusRect.setRect( focusRect.x() + margin, focusRect.y() + margin,
    242             focusRect.width() - 2 * margin - 2,
    243             focusRect.height() - 2 * margin - 2 );
     259        const int m = 2;
     260
     261        QRect focusRect = contentsRect().adjusted( m, m, -m + 1, -m + 1);
    244262
    245263        QwtPainter::drawFocusRect( painter, this, focusRect );
     
    248266
    249267//! Redraw the text
    250 void QwtTextLabel::drawText( QPainter *painter, const QRect &textRect )
     268void QwtTextLabel::drawText( QPainter *painter, const QRectF &textRect )
    251269{
    252270    d_data->text.draw( painter, textRect );
     
    254272
    255273/*!
    256   Calculate the rect for the text in widget coordinates
    257   \return Text rect
     274  Calculate geometry for the text in widget coordinates
     275  \return Geometry for the text
    258276*/
    259277QRect QwtTextLabel::textRect() const
Note: See TracChangeset for help on using the changeset viewer.