Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_text.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.cpp

    r4271 r8127  
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    4  * Copyright (C) 2003   Uwe Rathmann
     4 * Copyright (C) 2002   Uwe Rathmann
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    139139    PrivateData():
    140140        renderFlags( Qt::AlignCenter ),
    141         backgroundPen( Qt::NoPen ),
     141        borderRadius( 0 ),
     142        borderPen( Qt::NoPen ),
    142143        backgroundBrush( Qt::NoBrush ),
    143144        paintAttributes( 0 ),
     
    151152    QFont font;
    152153    QColor color;
    153     QPen backgroundPen;
     154    double borderRadius;
     155    QPen borderPen;
    154156    QBrush backgroundBrush;
    155157
     
    219221        d_data->font == other.d_data->font &&
    220222        d_data->color == other.d_data->color &&
    221         d_data->backgroundPen == other.d_data->backgroundPen &&
     223        d_data->borderRadius == other.d_data->borderRadius &&
     224        d_data->borderPen == other.d_data->borderPen &&
    222225        d_data->backgroundBrush == other.d_data->backgroundBrush &&
    223226        d_data->paintAttributes == other.d_data->paintAttributes &&
     
    248251
    249252/*!
    250    Return the text.
     253   \return Text as QString.
    251254   \sa setText()
    252255*/
     
    261264   The default setting is Qt::AlignCenter
    262265
    263    \param renderFlags Bitwise OR of the flags used like in QPainter::drawText
     266   \param renderFlags Bitwise OR of the flags used like in QPainter::drawText()
    264267
    265268   \sa renderFlags(), QwtTextEngine::draw()
     
    304307
    305308/*!
    306   Return the font of the text, if it has one.
    307   Otherwise return defaultFont.
    308 
    309   \param defaultFont Default font
    310   \sa setFont(), font(), PaintAttributes
     309   Return the font of the text, if it has one.
     310   Otherwise return defaultFont.
     311
     312   \param defaultFont Default font
     313   \return Font used for drawing the text
     314
     315   \sa setFont(), font(), PaintAttributes
    311316*/
    312317QFont QwtText::usedFont( const QFont &defaultFont ) const
     
    319324
    320325/*!
    321    Set the pen color used for painting the text.
     326   Set the pen color used for drawing the text.
    322327
    323328   \param color Color
     
    342347
    343348  \param defaultColor Default color
     349  \return Color used for drawing the text
     350
    344351  \sa setColor(), color(), PaintAttributes
    345352*/
     
    353360
    354361/*!
     362  Set the radius for the corners of the border frame
     363
     364  \param radius Radius of a rounded corner
     365  \sa borderRadius(), setBorderPen(), setBackgroundBrush()
     366*/
     367void QwtText::setBorderRadius( double radius )
     368{
     369    d_data->borderRadius = qMax( 0.0, radius );
     370}
     371
     372/*!
     373  \return Radius for the corners of the border frame
     374  \sa setBorderRadius(), borderPen(), backgroundBrush()
     375*/
     376double QwtText::borderRadius() const
     377{
     378    return d_data->borderRadius;
     379}
     380
     381/*!
    355382   Set the background pen
    356383
    357384   \param pen Background pen
    358    \sa backgroundPen(), setBackgroundBrush()
    359 */
    360 void QwtText::setBackgroundPen( const QPen &pen )
    361 {
    362     d_data->backgroundPen = pen;
     385   \sa borderPen(), setBackgroundBrush()
     386*/
     387void QwtText::setBorderPen( const QPen &pen )
     388{
     389    d_data->borderPen = pen;
    363390    setPaintAttribute( PaintBackground );
    364391}
     
    366393/*!
    367394   \return Background pen
    368    \sa setBackgroundPen(), backgroundBrush()
    369 */
    370 QPen QwtText::backgroundPen() const
    371 {
    372     return d_data->backgroundPen;
     395   \sa setBorderPen(), backgroundBrush()
     396*/
     397QPen QwtText::borderPen() const
     398{
     399    return d_data->borderPen;
    373400}
    374401
     
    377404
    378405   \param brush Background brush
    379    \sa backgroundBrush(), setBackgroundPen()
     406   \sa backgroundBrush(), setBorderPen()
    380407*/
    381408void QwtText::setBackgroundBrush( const QBrush &brush )
     
    387414/*!
    388415   \return Background brush
    389    \sa setBackgroundBrush(), backgroundPen()
     416   \sa setBackgroundBrush(), borderPen()
    390417*/
    391418QBrush QwtText::backgroundBrush() const
     
    401428
    402429   \note Used by setFont(), setColor(),
    403          setBackgroundPen() and setBackgroundBrush()
     430         setBorderPen() and setBackgroundBrush()
    404431   \sa testPaintAttribute()
    405432*/
     
    492519
    493520/*!
    494    Find the height for a given width
    495 
    496    \param defaultFont Font, used for the calculation if the text has no font
    497 
    498    \return Calculated height
    499 */
    500 
    501 /*!
    502521   Returns the size, that is needed to render text
    503522
    504523   \param defaultFont Font of the text
    505    \return Caluclated size
     524   \return Calculated size
    506525*/
    507526QSizeF QwtText::textSize( const QFont &defaultFont ) const
     
    543562    if ( d_data->paintAttributes & PaintBackground )
    544563    {
    545         if ( d_data->backgroundPen != Qt::NoPen ||
     564        if ( d_data->borderPen != Qt::NoPen ||
    546565            d_data->backgroundBrush != Qt::NoBrush )
    547566        {
    548567            painter->save();
    549             painter->setPen( d_data->backgroundPen );
     568
     569            painter->setPen( d_data->borderPen );
    550570            painter->setBrush( d_data->backgroundBrush );
    551             QwtPainter::drawRect( painter, rect );
     571
     572            if ( d_data->borderRadius == 0 )
     573            {
     574                QwtPainter::drawRect( painter, rect );
     575            }
     576            else
     577            {
     578                painter->setRenderHint( QPainter::Antialiasing, true );
     579                painter->drawRoundedRect( rect,
     580                    d_data->borderRadius, d_data->borderRadius );
     581            }
     582
    552583            painter->restore();
    553584        }
     
    596627   In case of QwtText::AutoText the first text engine
    597628   (beside QwtPlainTextEngine) is returned, where QwtTextEngine::mightRender
    598    returns true. If there is none QwtPlainTextEngine is returnd.
     629   returns true. If there is none QwtPlainTextEngine is returned.
    599630
    600631   If no text engine is registered for the format QwtPlainTextEngine
     
    603634   \param text Text, needed in case of AutoText
    604635   \param format Text format
     636
     637   \return Corresponding text engine
    605638*/
    606639const QwtTextEngine *QwtText::textEngine( const QString &text,
Note: See TracChangeset for help on using the changeset viewer.