Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_text_label.cpp
- Timestamp:
- May 10, 2017, 3:20:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_text_label.cpp
r4271 r8127 64 64 65 65 /*! 66 Interface for the designer plugin - does the same as setText() 67 \sa plainText() 68 */ 69 void 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 */ 80 QString QwtTextLabel::plainText() const 81 { 82 return d_data->text.text(); 83 } 84 85 /*! 66 86 Change the label's text, keeping all other QwtText attributes 67 87 \param text New text … … 70 90 \sa QwtText 71 91 */ 72 void QwtTextLabel::setText( const QString &text, QwtText::TextFormat textFormat ) 92 void QwtTextLabel::setText( const QString &text, 93 QwtText::TextFormat textFormat ) 73 94 { 74 95 d_data->text.setText( text, textFormat ); … … 126 147 } 127 148 128 //! Return label's text indentin pixels149 //! Return label's text margin in pixels 129 150 int QwtTextLabel::margin() const 130 151 { … … 144 165 } 145 166 146 //! Return label's margin in pixels167 //! Return a size hint 147 168 QSize QwtTextLabel::sizeHint() const 148 169 { … … 177 198 178 199 /*! 179 Returns the preferred height for this widget, given the width.180 200 \param width Width 201 \return Preferred height for this widget, given the width. 181 202 */ 182 203 int QwtTextLabel::heightForWidth( int width ) const … … 192 213 width -= indent; 193 214 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 ) ) 196 217 height += indent; 197 218 … … 232 253 painter->setPen( palette().color( QPalette::Active, QPalette::Text ) ); 233 254 234 drawText( painter, r);255 drawText( painter, QRectF( r ) ); 235 256 236 257 if ( hasFocus() ) 237 258 { 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); 244 262 245 263 QwtPainter::drawFocusRect( painter, this, focusRect ); … … 248 266 249 267 //! Redraw the text 250 void QwtTextLabel::drawText( QPainter *painter, const QRect &textRect )268 void QwtTextLabel::drawText( QPainter *painter, const QRectF &textRect ) 251 269 { 252 270 d_data->text.draw( painter, textRect ); … … 254 272 255 273 /*! 256 Calculate the rectfor the text in widget coordinates257 \return Text rect274 Calculate geometry for the text in widget coordinates 275 \return Geometry for the text 258 276 */ 259 277 QRect QwtTextLabel::textRect() const
Note:
See TracChangeset
for help on using the changeset viewer.