Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_knob.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_knob.cpp (modified) (46 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_knob.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 10 10 #include "qwt_knob.h" 11 11 #include "qwt_round_scale_draw.h" 12 #include "qwt_math.h"13 12 #include "qwt_painter.h" 14 13 #include "qwt_scale_map.h" 14 #include "qwt_math.h" 15 #include "qwt.h" 16 15 17 #include <qpainter.h> 16 18 #include <qpalette.h> … … 18 20 #include <qstyleoption.h> 19 21 #include <qevent.h> 22 #include <qmargins.h> 20 23 #include <qmath.h> 21 #include <qapplication.h> 22 23 #if QT_VERSION < 0x040601 24 #define qAtan2(y, x) ::atan2(y, x) 25 #define qFabs(x) ::fabs(x) 26 #define qFastCos(x) qCos(x) 27 #define qFastSin(x) qSin(x) 28 #endif 29 30 static QSize qwtKnobSizeHint( const QwtKnob *knob, int min ) 24 25 static QSize qwtKnobSizeHint( const QwtKnob* knob, int min ) 31 26 { 32 27 int knobWidth = knob->knobWidth(); … … 35 30 36 31 // Add the scale radial thickness to the knobWidth 37 const int extent = qCeil( knob->scaleDraw()->extent( knob->font() ) ); 32 const int extent = qwtCeil( knob->scaleDraw()->extent( knob->font() ) ); 38 33 const int d = 2 * ( extent + 4 ) + knobWidth; 39 34 40 int left, right, top, bottom; 41 knob->getContentsMargins( &left, &top, &right, &bottom ); 42 43 return QSize( d + left + right, d + top + bottom ); 35 const QMargins m = knob->contentsMargins(); 36 return QSize( d + m.left() + m.right(), d + m.top() + m.bottom() ); 44 37 } 45 38 … … 65 58 class QwtKnob::PrivateData 66 59 { 67 public: 68 PrivateData() :69 knobStyle( QwtKnob::Raised ) ,70 markerStyle( QwtKnob::Notch ) ,71 borderWidth( 2 ) ,72 borderDist( 4 ) ,73 scaleDist( 4 ) ,74 maxScaleTicks( 11 ) ,75 knobWidth( 0 ) ,76 alignment( Qt::AlignCenter ) ,77 markerSize( 8 ) ,78 totalAngle( 270.0 ) ,79 mouseOffset( 0.0 ) 60 public: 61 PrivateData() 62 : knobStyle( QwtKnob::Raised ) 63 , markerStyle( QwtKnob::Notch ) 64 , borderWidth( 2 ) 65 , borderDist( 4 ) 66 , scaleDist( 4 ) 67 , maxScaleTicks( 11 ) 68 , knobWidth( 0 ) 69 , alignment( Qt::AlignCenter ) 70 , markerSize( 8 ) 71 , totalAngle( 270.0 ) 72 , mouseOffset( 0.0 ) 80 73 { 81 74 } … … 98 91 99 92 /*! 100 \brief Constructor 101 102 Construct a knob with an angle of 270°. The style is 103 QwtKnob::Raised and the marker style is QwtKnob::Notch. 104 The width of the knob is set to 50 pixels. 105 106 \param parent Parent widget 107 108 \sa setTotalAngle() 109 */ 110 QwtKnob::QwtKnob( QWidget* parent ) :111 QwtAbstractSlider( parent ) 112 { 113 d_data = new PrivateData;93 \brief Constructor 94 95 Construct a knob with an angle of 270°. The style is 96 QwtKnob::Raised and the marker style is QwtKnob::Notch. 97 The width of the knob is set to 50 pixels. 98 99 \param parent Parent widget 100 101 \sa setTotalAngle() 102 */ 103 QwtKnob::QwtKnob( QWidget* parent ) 104 : QwtAbstractSlider( parent ) 105 { 106 m_data = new PrivateData; 114 107 115 108 setScaleDraw( new QwtRoundScaleDraw() ); … … 127 120 QwtKnob::~QwtKnob() 128 121 { 129 delete d_data;130 } 131 132 /*! 133 \brief Set the knob type 134 135 \param knobStyle Knob type 136 \sa knobStyle(), setBorderWidth() 137 */ 122 delete m_data; 123 } 124 125 /*! 126 \brief Set the knob type 127 128 \param knobStyle Knob type 129 \sa knobStyle(), setBorderWidth() 130 */ 138 131 void QwtKnob::setKnobStyle( KnobStyle knobStyle ) 139 132 { 140 if ( d_data->knobStyle != knobStyle )141 { 142 d_data->knobStyle = knobStyle;133 if ( m_data->knobStyle != knobStyle ) 134 { 135 m_data->knobStyle = knobStyle; 143 136 update(); 144 137 } … … 148 141 \return Marker type of the knob 149 142 \sa setKnobStyle(), setBorderWidth() 150 */ 143 */ 151 144 QwtKnob::KnobStyle QwtKnob::knobStyle() const 152 145 { 153 return d_data->knobStyle;154 } 155 156 /*! 157 \brief Set the marker type of the knob 158 159 \param markerStyle Marker type 160 \sa markerStyle(), setMarkerSize() 161 */ 146 return m_data->knobStyle; 147 } 148 149 /*! 150 \brief Set the marker type of the knob 151 152 \param markerStyle Marker type 153 \sa markerStyle(), setMarkerSize() 154 */ 162 155 void QwtKnob::setMarkerStyle( MarkerStyle markerStyle ) 163 156 { 164 if ( d_data->markerStyle != markerStyle )165 { 166 d_data->markerStyle = markerStyle;157 if ( m_data->markerStyle != markerStyle ) 158 { 159 m_data->markerStyle = markerStyle; 167 160 update(); 168 161 } … … 170 163 171 164 /*! 172 \return Marker type of the knob 173 \sa setMarkerStyle(), setMarkerSize() 174 */ 165 \return Marker type of the knob 166 \sa setMarkerStyle(), setMarkerSize() 167 */ 175 168 QwtKnob::MarkerStyle QwtKnob::markerStyle() const 176 169 { 177 return d_data->markerStyle;178 } 179 180 /*! 181 \brief Set the total angle by which the knob can be turned 182 \param angle Angle in degrees. 183 184 The angle has to be between [10, 360] degrees. Angles above 185 360 ( so that the knob can be turned several times around its axis ) 186 have to be set using setNumTurns(). 187 188 The default angle is 270 degrees. 189 190 \sa totalAngle(), setNumTurns() 191 */ 170 return m_data->markerStyle; 171 } 172 173 /*! 174 \brief Set the total angle by which the knob can be turned 175 \param angle Angle in degrees. 176 177 The angle has to be between [10, 360] degrees. Angles above 178 360 ( so that the knob can be turned several times around its axis ) 179 have to be set using setNumTurns(). 180 181 The default angle is 270 degrees. 182 183 \sa totalAngle(), setNumTurns() 184 */ 192 185 void QwtKnob::setTotalAngle ( double angle ) 193 186 { 194 187 angle = qBound( 10.0, angle, 360.0 ); 195 188 196 if ( angle != d_data->totalAngle )197 { 198 d_data->totalAngle = angle;199 200 scaleDraw()->setAngleRange( -0.5 * d_data->totalAngle,201 0.5 * d_data->totalAngle );189 if ( angle != m_data->totalAngle ) 190 { 191 m_data->totalAngle = angle; 192 193 scaleDraw()->setAngleRange( -0.5 * m_data->totalAngle, 194 0.5 * m_data->totalAngle ); 202 195 203 196 updateGeometry(); … … 207 200 208 201 /*! 209 \return the total angle 210 \sa setTotalAngle(), setNumTurns(), numTurns() 202 \return the total angle 203 \sa setTotalAngle(), setNumTurns(), numTurns() 211 204 */ 212 205 double QwtKnob::totalAngle() const 213 206 { 214 return d_data->totalAngle;215 } 216 217 /*! 218 \brief Set the number of turns 219 220 When numTurns > 1 the knob can be turned several times around its axis 221 - otherwise the total angle is floored to 360°. 222 223 \sa numTurns(), totalAngle(), setTotalAngle() 224 */ 207 return m_data->totalAngle; 208 } 209 210 /*! 211 \brief Set the number of turns 212 213 When numTurns > 1 the knob can be turned several times around its axis 214 - otherwise the total angle is floored to 360°. 215 216 \sa numTurns(), totalAngle(), setTotalAngle() 217 */ 225 218 226 219 void QwtKnob::setNumTurns( int numTurns ) … … 228 221 numTurns = qMax( numTurns, 1 ); 229 222 230 if ( numTurns == 1 && d_data->totalAngle <= 360.0 )223 if ( numTurns == 1 && m_data->totalAngle <= 360.0 ) 231 224 return; 232 225 233 226 const double angle = numTurns * 360.0; 234 if ( angle != d_data->totalAngle )235 { 236 d_data->totalAngle = angle;237 238 scaleDraw()->setAngleRange( -0.5 * d_data->totalAngle,239 0.5 * d_data->totalAngle );227 if ( angle != m_data->totalAngle ) 228 { 229 m_data->totalAngle = angle; 230 231 scaleDraw()->setAngleRange( -0.5 * m_data->totalAngle, 232 0.5 * m_data->totalAngle ); 240 233 241 234 updateGeometry(); … … 245 238 246 239 /*! 247 \return Number of turns. 248 249 When the total angle is below 360° numTurns() is ceiled to 1. 250 \sa setNumTurns(), setTotalAngle(), totalAngle() 240 \return Number of turns. 241 242 When the total angle is below 360° numTurns() is ceiled to 1. 243 \sa setNumTurns(), setTotalAngle(), totalAngle() 251 244 */ 252 245 int QwtKnob::numTurns() const 253 246 { 254 return q Ceil( d_data->totalAngle / 360.0 );247 return qwtCeil( m_data->totalAngle / 360.0 ); 255 248 } 256 249 … … 263 256 264 257 \sa scaleDraw() 265 */ 266 void QwtKnob::setScaleDraw( QwtRoundScaleDraw *scaleDraw )258 */ 259 void QwtKnob::setScaleDraw( QwtRoundScaleDraw* scaleDraw ) 267 260 { 268 261 setAbstractScaleDraw( scaleDraw ); 269 setTotalAngle( d_data->totalAngle );262 setTotalAngle( m_data->totalAngle ); 270 263 271 264 updateGeometry(); … … 276 269 \return the scale draw of the knob 277 270 \sa setScaleDraw() 278 */ 279 const QwtRoundScaleDraw *QwtKnob::scaleDraw() const280 { 281 return static_cast<const QwtRoundScaleDraw *>( abstractScaleDraw() );271 */ 272 const QwtRoundScaleDraw* QwtKnob::scaleDraw() const 273 { 274 return static_cast< const QwtRoundScaleDraw* >( abstractScaleDraw() ); 282 275 } 283 276 … … 285 278 \return the scale draw of the knob 286 279 \sa setScaleDraw() 287 */ 288 QwtRoundScaleDraw *QwtKnob::scaleDraw()289 { 290 return static_cast<QwtRoundScaleDraw *>( abstractScaleDraw() );291 } 292 293 /*! 294 Calculate the bounding rectangle of the knob without the scale 295 296 \return Bounding rectangle of the knob 297 \sa knobWidth(), alignment(), QWidget::contentsRect() 280 */ 281 QwtRoundScaleDraw* QwtKnob::scaleDraw() 282 { 283 return static_cast< QwtRoundScaleDraw* >( abstractScaleDraw() ); 284 } 285 286 /*! 287 Calculate the bounding rectangle of the knob without the scale 288 289 \return Bounding rectangle of the knob 290 \sa knobWidth(), alignment(), QWidget::contentsRect() 298 291 */ 299 292 QRect QwtKnob::knobRect() const … … 301 294 const QRect cr = contentsRect(); 302 295 303 const int extent = qCeil( scaleDraw()->extent( font() ) ); 304 const int d = extent + d_data->scaleDist;305 306 int w = d_data->knobWidth;296 const int extent = qwtCeil( scaleDraw()->extent( font() ) ); 297 const int d = extent + m_data->scaleDist; 298 299 int w = m_data->knobWidth; 307 300 if ( w <= 0 ) 308 301 { … … 315 308 QRect r( 0, 0, w, w ); 316 309 317 if ( d_data->alignment & Qt::AlignLeft )310 if ( m_data->alignment & Qt::AlignLeft ) 318 311 { 319 312 r.moveLeft( cr.left() + d ); 320 313 } 321 else if ( d_data->alignment & Qt::AlignRight )314 else if ( m_data->alignment & Qt::AlignRight ) 322 315 { 323 316 r.moveRight( cr.right() - d ); … … 328 321 } 329 322 330 if ( d_data->alignment & Qt::AlignTop )323 if ( m_data->alignment & Qt::AlignTop ) 331 324 { 332 325 r.moveTop( cr.top() + d ); 333 326 } 334 else if ( d_data->alignment & Qt::AlignBottom )327 else if ( m_data->alignment & Qt::AlignBottom ) 335 328 { 336 329 r.moveBottom( cr.bottom() - d ); … … 345 338 346 339 /*! 347 \brief Determine what to do when the user presses a mouse button. 348 349 \param pos Mouse position 350 351 \retval True, when pos is inside the circle of the knob. 352 \sa scrolledTo() 353 */ 354 bool QwtKnob::isScrollPosition( const QPoint &pos ) const340 \brief Determine what to do when the user presses a mouse button. 341 342 \param pos Mouse position 343 344 \retval True, when pos is inside the circle of the knob. 345 \sa scrolledTo() 346 */ 347 bool QwtKnob::isScrollPosition( const QPoint& pos ) const 355 348 { 356 349 const QRect kr = knobRect(); … … 362 355 const double valueAngle = qwtToDegrees( scaleMap().transform( value() ) ); 363 356 364 d_data->mouseOffset = qwtNormalizeDegrees( angle - valueAngle );357 m_data->mouseOffset = qwtNormalizeDegrees( angle - valueAngle ); 365 358 366 359 return true; … … 371 364 372 365 /*! 373 \brief Determine the value for a new position of the mouse 374 375 \param pos Mouse position 376 377 \return Value for the mouse position 378 \sa isScrollPosition() 379 */ 380 double QwtKnob::scrolledTo( const QPoint &pos ) const366 \brief Determine the value for a new position of the mouse 367 368 \param pos Mouse position 369 370 \return Value for the mouse position 371 \sa isScrollPosition() 372 */ 373 double QwtKnob::scrolledTo( const QPoint& pos ) const 381 374 { 382 375 double angle = QLineF( rect().center(), pos ).angle(); 383 angle = qwtNormalizeDegrees( angle - d_data->mouseOffset );376 angle = qwtNormalizeDegrees( angle - m_data->mouseOffset ); 384 377 385 378 if ( scaleMap().pDist() > 360.0 ) … … 389 382 const double v = scaleMap().transform( value() ); 390 383 391 int numTurns = qFloor( ( v - scaleMap().p1() ) / 360.0 ); 384 int numTurns = qwtFloor( ( v - scaleMap().p1() ) / 360.0 ); 392 385 393 386 double valueAngle = qwtNormalizeDegrees( v ); … … 404 397 qBound( scaleMap().p1(), angle, scaleMap().p2() ); 405 398 406 d_data->mouseOffset += ( boundedAngle - angle );399 m_data->mouseOffset += ( boundedAngle - angle ); 407 400 angle = boundedAngle; 408 401 } … … 423 416 boundedAngle = scaleMap().p1(); 424 417 425 d_data->mouseOffset += ( boundedAngle - angle );418 m_data->mouseOffset += ( boundedAngle - angle ); 426 419 } 427 420 … … 433 426 434 427 /*! 435 Handle QEvent::StyleChange and QEvent::FontChange; 436 \param event Change event 437 */ 438 void QwtKnob::changeEvent( QEvent *event )428 Handle QEvent::StyleChange and QEvent::FontChange; 429 \param event Change event 430 */ 431 void QwtKnob::changeEvent( QEvent* event ) 439 432 { 440 433 switch( event->type() ) … … 453 446 454 447 /*! 455 Repaint the knob 456 \param event Paint event 457 */ 458 void QwtKnob::paintEvent( QPaintEvent *event )448 Repaint the knob 449 \param event Paint event 450 */ 451 void QwtKnob::paintEvent( QPaintEvent* event ) 459 452 { 460 453 const QRectF knobRect = this->knobRect(); … … 464 457 465 458 QStyleOption opt; 466 opt.init(this); 459 opt.initFrom(this); 467 460 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); 468 461 … … 471 464 if ( !knobRect.contains( event->region().boundingRect() ) ) 472 465 { 473 scaleDraw()->setRadius( 0.5 * knobRect.width() + d_data->scaleDist );466 scaleDraw()->setRadius( 0.5 * knobRect.width() + m_data->scaleDist ); 474 467 scaleDraw()->moveCenter( knobRect.center() ); 475 468 … … 489 482 490 483 /*! 491 \brief Draw the knob 492 493 \param painter painter 494 \param knobRect Bounding rectangle of the knob (without scale) 495 */ 496 void QwtKnob::drawKnob( QPainter *painter, const QRectF&knobRect ) const484 \brief Draw the knob 485 486 \param painter painter 487 \param knobRect Bounding rectangle of the knob (without scale) 488 */ 489 void QwtKnob::drawKnob( QPainter* painter, const QRectF& knobRect ) const 497 490 { 498 491 double dim = qMin( knobRect.width(), knobRect.height() ); 499 dim -= d_data->borderWidth * 0.5;492 dim -= m_data->borderWidth * 0.5; 500 493 501 494 QRectF aRect( 0, 0, dim, dim ); … … 503 496 504 497 QPen pen( Qt::NoPen ); 505 if ( d_data->borderWidth > 0 )498 if ( m_data->borderWidth > 0 ) 506 499 { 507 500 QColor c1 = palette().color( QPalette::Light ); … … 514 507 gradient.setColorAt( 1.0, c2 ); 515 508 516 pen = QPen( gradient, d_data->borderWidth );509 pen = QPen( gradient, m_data->borderWidth ); 517 510 } 518 511 519 512 QBrush brush; 520 switch( d_data->knobStyle )513 switch( m_data->knobStyle ) 521 514 { 522 515 case QwtKnob::Raised: … … 542 535 543 536 const QColor c = palette().color( QPalette::Button ); 544 gradient.setColorAt(0, c.lighter(110)); 545 gradient.setColorAt( qreal(0.5), c);546 gradient.setColorAt( qreal(0.501), c.darker(102));547 gradient.setColorAt(1, c.darker(115)); 537 gradient.setColorAt(0, c.lighter(110) ); 538 gradient.setColorAt( 0.5, c); 539 gradient.setColorAt( 0.501, c.darker(102) ); 540 gradient.setColorAt(1, c.darker(115) ); 548 541 549 542 brush = QBrush( gradient ); … … 574 567 575 568 /*! 576 \brief Draw the marker at the knob's front 577 578 \param painter Painter 579 \param rect Bounding rectangle of the knob without scale 580 \param angle Angle of the marker in degrees 569 \brief Draw the marker at the knob's front 570 571 \param painter Painter 572 \param rect Bounding rectangle of the knob without scale 573 \param angle Angle of the marker in degrees 581 574 ( clockwise, 0 at the 12 o'clock position ) 582 */ 583 void QwtKnob::drawMarker( QPainter *painter,584 const QRectF &rect, double angle ) const585 { 586 if ( d_data->markerStyle == NoMarker || !isValid() )575 */ 576 void QwtKnob::drawMarker( QPainter* painter, 577 const QRectF& rect, double angle ) const 578 { 579 if ( m_data->markerStyle == NoMarker || !isValid() ) 587 580 return; 588 581 … … 595 588 const double margin = 4.0; 596 589 597 double radius = 0.5 * ( rect.width() - d_data->borderWidth ) - margin;590 double radius = 0.5 * ( rect.width() - m_data->borderWidth ) - margin; 598 591 if ( radius < 1.0 ) 599 592 radius = 1.0; 600 593 601 intmarkerSize =d_data->markerSize;594 double markerSize = m_data->markerSize; 602 595 if ( markerSize <= 0 ) 603 596 markerSize = qRound( 0.4 * radius ); 604 597 605 switch ( d_data->markerStyle )598 switch ( m_data->markerStyle ) 606 599 { 607 600 case Notch: 608 601 case Nub: 609 602 { 610 const double dotWidth = 611 qMin( double( markerSize ), radius); 603 const double dotWidth = qwtMinF( markerSize, radius ); 612 604 613 605 const double dotCenterDist = radius - 0.5 * dotWidth; … … 623 615 QColor c2 = palette().color( QPalette::Mid ); 624 616 625 if ( d_data->markerStyle == Notch )617 if ( m_data->markerStyle == Notch ) 626 618 qSwap( c1, c2 ); 627 619 … … 640 632 case Dot: 641 633 { 642 const double dotWidth = 643 qMin( double( markerSize ), radius); 634 const double dotWidth = qwtMinF( markerSize, radius); 644 635 645 636 const double dotCenterDist = radius - 0.5 * dotWidth; … … 661 652 case Tick: 662 653 { 663 const double rb = q Max( radius - markerSize, 1.0 );654 const double rb = qwtMaxF( radius - markerSize, 1.0 ); 664 655 const double re = radius; 665 656 … … 676 667 case Triangle: 677 668 { 678 const double rb = q Max( radius - markerSize, 1.0 );669 const double rb = qwtMaxF( radius - markerSize, 1.0 ); 679 670 const double re = radius; 680 671 … … 701 692 702 693 /*! 703 Draw the focus indicator 704 \param painter Painter 705 */ 706 void QwtKnob::drawFocusIndicator( QPainter *painter ) const694 Draw the focus indicator 695 \param painter Painter 696 */ 697 void QwtKnob::drawFocusIndicator( QPainter* painter ) const 707 698 { 708 699 const QRect cr = contentsRect(); 709 700 710 int w = d_data->knobWidth;701 int w = m_data->knobWidth; 711 702 if ( w <= 0 ) 712 703 { … … 716 707 { 717 708 const int extent = qCeil( scaleDraw()->extent( font() ) ); 718 w += 2 * ( extent + d_data->scaleDist );709 w += 2 * ( extent + m_data->scaleDist ); 719 710 } 720 711 … … 726 717 727 718 /*! 728 \brief Set the alignment of the knob 729 730 Similar to a QLabel::alignment() the flags decide how 731 to align the knob inside of contentsRect(). 732 733 The default setting is Qt::AlignCenter 734 735 \param alignment Or'd alignment flags 736 737 \sa alignment(), setKnobWidth(), knobRect() 719 \brief Set the alignment of the knob 720 721 Similar to a QLabel::alignment() the flags decide how 722 to align the knob inside of contentsRect(). 723 724 The default setting is Qt::AlignCenter 725 726 \param alignment Or'd alignment flags 727 728 \sa alignment(), setKnobWidth(), knobRect() 738 729 */ 739 730 void QwtKnob::setAlignment( Qt::Alignment alignment ) 740 731 { 741 if ( d_data->alignment != alignment )742 { 743 d_data->alignment = alignment;732 if ( m_data->alignment != alignment ) 733 { 734 m_data->alignment = alignment; 744 735 update(); 745 736 } … … 747 738 748 739 /*! 749 \return Alignment of the knob inside of contentsRect() 750 \sa setAlignment(), knobWidth(), knobRect() 740 \return Alignment of the knob inside of contentsRect() 741 \sa setAlignment(), knobWidth(), knobRect() 751 742 */ 752 743 Qt::Alignment QwtKnob::alignment() const 753 744 { 754 return d_data->alignment;755 } 756 757 /*! 758 \brief Change the knob's width. 759 760 Setting a fixed value for the diameter of the knob 761 is helpful for aligning several knobs in a row. 762 763 \param width New width 764 765 \sa knobWidth(), setAlignment() 766 \note Modifies the sizePolicy() 767 */ 745 return m_data->alignment; 746 } 747 748 /*! 749 \brief Change the knob's width. 750 751 Setting a fixed value for the diameter of the knob 752 is helpful for aligning several knobs in a row. 753 754 \param width New width 755 756 \sa knobWidth(), setAlignment() 757 \note Modifies the sizePolicy() 758 */ 768 759 void QwtKnob::setKnobWidth( int width ) 769 760 { 770 761 width = qMax( width, 0 ); 771 762 772 if ( width != d_data->knobWidth )763 if ( width != m_data->knobWidth ) 773 764 { 774 765 QSizePolicy::Policy policy; … … 780 771 setSizePolicy( policy, policy ); 781 772 782 d_data->knobWidth = width;773 m_data->knobWidth = width; 783 774 784 775 updateGeometry(); … … 790 781 int QwtKnob::knobWidth() const 791 782 { 792 return d_data->knobWidth;793 } 794 795 /*! 796 \brief Set the knob's border width 797 \param borderWidth new border width 798 */ 783 return m_data->knobWidth; 784 } 785 786 /*! 787 \brief Set the knob's border width 788 \param borderWidth new border width 789 */ 799 790 void QwtKnob::setBorderWidth( int borderWidth ) 800 791 { 801 d_data->borderWidth = qMax( borderWidth, 0 );792 m_data->borderWidth = qMax( borderWidth, 0 ); 802 793 803 794 updateGeometry(); … … 808 799 int QwtKnob::borderWidth() const 809 800 { 810 return d_data->borderWidth;811 } 812 813 /*! 814 \brief Set the size of the marker 815 816 When setting a size <= 0 the marker will 817 automatically scaled to 40% of the radius of the knob. 818 819 \sa markerSize(), markerStyle() 820 */ 801 return m_data->borderWidth; 802 } 803 804 /*! 805 \brief Set the size of the marker 806 807 When setting a size <= 0 the marker will 808 automatically scaled to 40% of the radius of the knob. 809 810 \sa markerSize(), markerStyle() 811 */ 821 812 void QwtKnob::setMarkerSize( int size ) 822 813 { 823 if ( d_data->markerSize != size )824 { 825 d_data->markerSize = size;814 if ( m_data->markerSize != size ) 815 { 816 m_data->markerSize = size; 826 817 update(); 827 818 } … … 829 820 830 821 /*! 831 \return Marker size 832 \sa setMarkerSize() 822 \return Marker size 823 \sa setMarkerSize() 833 824 */ 834 825 int QwtKnob::markerSize() const 835 826 { 836 return d_data->markerSize;837 } 838 839 /*! 840 \return sizeHint() 841 */ 827 return m_data->markerSize; 828 } 829 830 /*! 831 \return sizeHint() 832 */ 842 833 QSize QwtKnob::sizeHint() const 843 834 { 844 835 const QSize hint = qwtKnobSizeHint( this, 50 ); 845 return hint.expandedTo( QApplication::globalStrut());846 } 847 848 /*! 849 \return Minimum size hint 850 \sa sizeHint() 851 */ 836 return qwtExpandedToGlobalStrut( hint ); 837 } 838 839 /*! 840 \return Minimum size hint 841 \sa sizeHint() 842 */ 852 843 QSize QwtKnob::minimumSizeHint() const 853 844 { 854 845 return qwtKnobSizeHint( this, 20 ); 855 846 } 847 848 #include "moc_qwt_knob.cpp"
Note:
See TracChangeset
for help on using the changeset viewer.
