Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_arrow_button.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_arrow_button.cpp (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_arrow_button.cpp
r8127 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 9 9 10 10 #include "qwt_arrow_button.h" 11 #include "qwt_math.h" 11 #include "qwt.h" 12 12 13 #include <qpainter.h> 13 14 #include <qstyle.h> 14 15 #include <qstyleoption.h> 15 16 #include <qevent.h> 16 #include <qapplication.h>17 17 18 18 static const int MaxNum = 3; … … 22 22 class QwtArrowButton::PrivateData 23 23 { 24 public: 24 public: 25 25 int num; 26 26 Qt::ArrowType arrowType; … … 30 30 { 31 31 QStyleOptionButton option; 32 option.init( btn ); 32 option.initFrom( btn ); 33 33 option.features = QStyleOptionButton::None; 34 34 if ( btn->isFlat() ) … … 49 49 50 50 /*! 51 \param num Number of arrows 52 \param arrowType see Qt::ArrowType in the Qt docs. 53 \param parent Parent widget 54 */ 55 QwtArrowButton::QwtArrowButton( int num, 56 Qt::ArrowType arrowType, QWidget *parent ): 57 QPushButton( parent ) 58 { 59 d_data = new PrivateData; 60 d_data->num = qBound( 1, num, MaxNum ); 61 d_data->arrowType = arrowType; 51 \param num Number of arrows 52 \param arrowType see Qt::ArrowType in the Qt docs. 53 \param parent Parent widget 54 */ 55 QwtArrowButton::QwtArrowButton( int num, Qt::ArrowType arrowType, QWidget* parent ) 56 : QPushButton( parent ) 57 { 58 m_data = new PrivateData; 59 m_data->num = qBound( 1, num, MaxNum ); 60 m_data->arrowType = arrowType; 62 61 63 62 setAutoRepeat( true ); 64 63 setAutoDefault( false ); 65 64 66 switch ( d_data->arrowType )65 switch ( m_data->arrowType ) 67 66 { 68 67 case Qt::LeftArrow: … … 80 79 QwtArrowButton::~QwtArrowButton() 81 80 { 82 delete d_data;83 d_data = NULL;84 } 85 86 /*! 87 \brief The direction of the arrows 88 */ 81 delete m_data; 82 m_data = NULL; 83 } 84 85 /*! 86 \brief The direction of the arrows 87 */ 89 88 Qt::ArrowType QwtArrowButton::arrowType() const 90 89 { 91 return d_data->arrowType;92 } 93 94 /*! 95 \brief The number of arrows 96 */ 90 return m_data->arrowType; 91 } 92 93 /*! 94 \brief The number of arrows 95 */ 97 96 int QwtArrowButton::num() const 98 97 { 99 return d_data->num;100 } 101 102 /*! 103 \return the bounding rectangle for the label 104 */ 98 return m_data->num; 99 } 100 101 /*! 102 \return the bounding rectangle for the label 103 */ 105 104 QRect QwtArrowButton::labelRect() const 106 105 { … … 128 127 Paint event handler 129 128 \param event Paint event 130 */ 131 void QwtArrowButton::paintEvent( QPaintEvent *event )129 */ 130 void QwtArrowButton::paintEvent( QPaintEvent* event ) 132 131 { 133 132 QPushButton::paintEvent( event ); … … 137 136 138 137 /*! 139 \brief Draw the button label 140 141 \param painter Painter 142 \sa The Qt Manual for QPushButton 143 */ 144 void QwtArrowButton::drawButtonLabel( QPainter *painter )145 { 146 const bool isVertical = d_data->arrowType == Qt::UpArrow ||147 d_data->arrowType == Qt::DownArrow;138 \brief Draw the button label 139 140 \param painter Painter 141 \sa The Qt Manual for QPushButton 142 */ 143 void QwtArrowButton::drawButtonLabel( QPainter* painter ) 144 { 145 const bool isVertical = m_data->arrowType == Qt::UpArrow || 146 m_data->arrowType == Qt::DownArrow; 148 147 149 148 const QRect r = labelRect(); … … 162 161 163 162 QRect contentsSize; // aligned rect where to paint all arrows 164 if ( d_data->arrowType == Qt::LeftArrow ||d_data->arrowType == Qt::RightArrow )165 { 166 contentsSize.setWidth( d_data->num * arrow.width()167 + ( d_data->num - 1 ) * Spacing );163 if ( m_data->arrowType == Qt::LeftArrow || m_data->arrowType == Qt::RightArrow ) 164 { 165 contentsSize.setWidth( m_data->num * arrow.width() 166 + ( m_data->num - 1 ) * Spacing ); 168 167 contentsSize.setHeight( arrow.height() ); 169 168 } … … 171 170 { 172 171 contentsSize.setWidth( arrow.width() ); 173 contentsSize.setHeight( d_data->num * arrow.height()174 + ( d_data->num - 1 ) * Spacing );172 contentsSize.setHeight( m_data->num * arrow.height() 173 + ( m_data->num - 1 ) * Spacing ); 175 174 } 176 175 … … 180 179 181 180 painter->save(); 182 for ( int i = 0; i < d_data->num; i++ )183 { 184 drawArrow( painter, arrowRect, d_data->arrowType );181 for ( int i = 0; i < m_data->num; i++ ) 182 { 183 drawArrow( painter, arrowRect, m_data->arrowType ); 185 184 186 185 int dx = 0; … … 199 198 { 200 199 QStyleOptionFocusRect option; 201 option.init( this ); 200 option.initFrom( this ); 202 201 option.backgroundColor = palette().color( QPalette::Window ); 203 202 … … 213 212 \param r Rectangle where to paint the arrow 214 213 \param arrowType Arrow type 215 */ 216 void QwtArrowButton::drawArrow( QPainter *painter,217 const QRect &r, Qt::ArrowType arrowType ) const214 */ 215 void QwtArrowButton::drawArrow( QPainter* painter, 216 const QRect& r, Qt::ArrowType arrowType ) const 218 217 { 219 218 QPolygon pa( 3 ); … … 256 255 257 256 /*! 258 \return a size hint 259 */ 257 \return a size hint 258 */ 260 259 QSize QwtArrowButton::sizeHint() const 261 260 { 262 261 const QSize hint = minimumSizeHint(); 263 return hint.expandedTo( QApplication::globalStrut());264 } 265 266 /*! 267 \brief Return a minimum size hint 268 */ 262 return qwtExpandedToGlobalStrut( hint ); 263 } 264 265 /*! 266 \brief Return a minimum size hint 267 */ 269 268 QSize QwtArrowButton::minimumSizeHint() const 270 269 { … … 274 273 2 * Margin + ( MaxNum - 1 ) * Spacing + MaxNum * asz.width(), 275 274 2 * Margin + asz.height() 276 ); 277 278 if ( d_data->arrowType == Qt::UpArrow ||d_data->arrowType == Qt::DownArrow )275 ); 276 277 if ( m_data->arrowType == Qt::UpArrow || m_data->arrowType == Qt::DownArrow ) 279 278 sz.transpose(); 280 279 281 280 QStyleOption styleOption; 282 styleOption.init( this ); 281 styleOption.initFrom( this ); 283 282 284 283 sz = style()->sizeFromContents( QStyle::CT_PushButton, … … 294 293 \param boundingSize Bounding size 295 294 \return Size of the arrow 296 */ 295 */ 297 296 QSize QwtArrowButton::arrowSize( Qt::ArrowType arrowType, 298 const QSize &boundingSize ) const297 const QSize& boundingSize ) const 299 298 { 300 299 QSize bs = boundingSize; … … 323 322 324 323 /*! 325 \brief autoRepeat for the space keys 326 */ 327 void QwtArrowButton::keyPressEvent( QKeyEvent *event )324 \brief autoRepeat for the space keys 325 */ 326 void QwtArrowButton::keyPressEvent( QKeyEvent* event ) 328 327 { 329 328 if ( event->isAutoRepeat() && event->key() == Qt::Key_Space )
Note:
See TracChangeset
for help on using the changeset viewer.
