summaryrefslogtreecommitdiffstats
path: root/src/widget/wslidercomposed.h
blob: 86ce224184a0d0c7a7cb23414e1237a4ede13851 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/***************************************************************************
                          wslidercomposed.h  -  description
                             -------------------
    begin                : Tue Jun 25 2002
    copyright            : (C) 2002 by Tue & Ken Haste Andersen
    email                : haste@diku.dk
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef WSLIDERCOMPOSED_H
#define WSLIDERCOMPOSED_H

#include <QString>
#include <QWidget>
#include <QDomNode>
#include <QWheelEvent>
#include <QPaintEvent>
#include <QMouseEvent>

#include "widget/wwidget.h"
#include "widget/wpixmapstore.h"
#include "skin/skincontext.h"

/**
  * A widget for a slider composed of a background pixmap and a handle.
  *
  *@author Tue & Ken Haste Andersen
  */

class WSliderComposed : public WWidget  {
    Q_OBJECT
  public:
    WSliderComposed(QWidget *parent=0);
    virtual ~WSliderComposed();

    void setup(QDomNode node, const SkinContext& context);
    void setSliderPixmap(const QString& filenameSlider);
    void setHandlePixmap(bool bHorizontal, const QString& filenameHandle);
    void mouseMoveEvent(QMouseEvent *e);
    void mouseReleaseEvent(QMouseEvent *e);
    void mousePressEvent(QMouseEvent *e);
    void paintEvent(QPaintEvent *);
    void wheelEvent(QWheelEvent *e);
    inline bool isHorizontal() const { return m_bHorizontal; };
public slots:
    void onConnectedControlValueChanged(double);
private:
    void unsetPixmaps();

    // True if right mouse button is pressed.
    bool m_bRightButtonPressed;
    /** Internal storage of slider position in pixels */
    int m_iPos, m_iStartHandlePos, m_iStartMousePos;
    /** Length of handle in pixels */
    int m_iHandleLength;
    /** True if it's a horizontal slider */
    bool m_bHorizontal;
    /** Is true if events is emitted while the slider is dragged */
    bool m_bEventWhileDrag;
    /** True if slider is dragged. Only used when m_bEventWhileDrag is false */
    bool m_bDrag;
    /** Pointer to pixmap of the slider */
    PaintablePointer m_pSlider;
    /** Pointer to pixmap of the handle */
    PaintablePointer m_pHandle;
};

#endif