File indexing completed on 2024-05-12 15:27:42
0001 #ifndef QXTSPANSLIDER_P_H 0002 /**************************************************************************** 0003 ** Copyright (c) 2006 - 2011, the LibQxt project. 0004 ** See the Qxt AUTHORS file for a list of authors and copyright holders. 0005 ** All rights reserved. 0006 ** 0007 ** Redistribution and use in source and binary forms, with or without 0008 ** modification, are permitted provided that the following conditions are met: 0009 ** * Redistributions of source code must retain the above copyright 0010 ** notice, this list of conditions and the following disclaimer. 0011 ** * Redistributions in binary form must reproduce the above copyright 0012 ** notice, this list of conditions and the following disclaimer in the 0013 ** documentation and/or other materials provided with the distribution. 0014 ** * Neither the name of the LibQxt project nor the 0015 ** names of its contributors may be used to endorse or promote products 0016 ** derived from this software without specific prior written permission. 0017 ** 0018 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 0019 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 0020 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 0021 ** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY 0022 ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 0023 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 0024 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 0025 ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0026 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 0027 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0028 ** 0029 ** <http://libqxt.org> <foundation@libqxt.org> 0030 *****************************************************************************/ 0031 0032 #define QXTSPANSLIDER_P_H 0033 0034 #include <QStyle> 0035 #include <QObject> 0036 #include "qxtspanslider.h" 0037 0038 QT_FORWARD_DECLARE_CLASS(QStylePainter) 0039 QT_FORWARD_DECLARE_CLASS(QStyleOptionSlider) 0040 0041 class QxtSpanSliderPrivate : public QObject, public QxtPrivate<QxtSpanSlider> { 0042 Q_OBJECT 0043 0044 public: 0045 QXT_DECLARE_PUBLIC(QxtSpanSlider) 0046 0047 QxtSpanSliderPrivate(); 0048 void initStyleOption(QStyleOptionSlider* option, QxtSpanSlider::SpanHandle handle = QxtSpanSlider::UpperHandle) const; 0049 int pick(QPoint pt) const { 0050 return qxt_p().orientation() == Qt::Horizontal ? pt.x() : pt.y(); 0051 } 0052 int pixelPosToRangeValue(int pos) const; 0053 void handleMousePress(QPoint pos, QStyle::SubControl& control, int value, QxtSpanSlider::SpanHandle handle); 0054 void drawHandle(QStylePainter* painter, QxtSpanSlider::SpanHandle handle) const; 0055 void setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2) const; 0056 void drawSpan(QStylePainter* painter, QRect rect) const; 0057 void triggerAction(QAbstractSlider::SliderAction action, bool main); 0058 void swapControls(); 0059 0060 int lower; 0061 int upper; 0062 int lowerPos; 0063 int upperPos; 0064 int offset; 0065 int position; 0066 QxtSpanSlider::SpanHandle lastPressed; 0067 QxtSpanSlider::SpanHandle mainControl; 0068 QStyle::SubControl lowerPressed; 0069 QStyle::SubControl upperPressed; 0070 QxtSpanSlider::HandleMovementMode movement; 0071 bool firstMovement; 0072 bool blockTracking; 0073 0074 public Q_SLOTS: 0075 void updateRange(int min, int max); 0076 void movePressedHandle(); 0077 }; 0078 0079 #endif // QXTSPANSLIDER_P_H