~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to arts/gui/kde/kpoti.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          kpoti.h  -  Potentiometer Widget
 
3
                             -------------------
 
4
    begin                : Wed Apr 28 23:05:05 MEST 1999
 
5
 
 
6
    copyright            : (C) 1999 by Martin Lorenz
 
7
    email                : lorenz@ch.tum.de
 
8
 ***************************************************************************/
 
9
 
 
10
/***************************************************************************
 
11
 *                                                                         *
 
12
 *   This program is free software; you can redistribute it and/or modify  *
 
13
 *   it under the terms of the GNU General Public License as published by  *
 
14
 *   the Free Software Foundation; either version 2 of the License, or     *
 
15
 *   (at your option) any later version.                                   *
 
16
 *                                                                         *
 
17
 ***************************************************************************/
 
18
 
 
19
#ifndef _KPOTI_H
 
20
#define _KPOTI_H
 
21
 
 
22
#include "qwidget.h"
 
23
#include "qrangect.h"
 
24
 
 
25
 
 
26
class QTimer;
 
27
struct QPotiData;
 
28
 
 
29
 
 
30
class KPoti : public QWidget, public QRangeControl
 
31
{
 
32
    Q_OBJECT
 
33
public:
 
34
 
 
35
    KPoti( QWidget *parent=0, const char *name=0 );
 
36
    KPoti( int minValue, int maxValue, int step, int value,
 
37
             QWidget *parent=0, const char *name=0 );
 
38
 
 
39
    void        setTracking( bool enable );
 
40
    bool        tracking() const;
 
41
 
 
42
    void        setPalette( const QPalette & );
 
43
    void        setColor( const QColor & );
 
44
 
 
45
    virtual void setTickmarks( bool );
 
46
    virtual void setLabel( bool );
 
47
    bool        tickmarks() const { return ticks; }
 
48
 
 
49
    virtual void setTickInterval( int );
 
50
    int         tickInterval() const { return tickInt; }
 
51
 
 
52
public slots:
 
53
    void        setValue( int );
 
54
    void        addStep();
 
55
    void        subtractStep();
 
56
 
 
57
signals:
 
58
    void        valueChanged( int value );
 
59
    void        potiPressed();
 
60
    void        potiMoved( int value );
 
61
    void        potiReleased();
 
62
    void  mouseEntered(int value);
 
63
 
 
64
protected:
 
65
    void        resizeEvent( QResizeEvent * );
 
66
    void        paintEvent( QPaintEvent * );
 
67
 
 
68
    void        keyPressEvent( QKeyEvent * );
 
69
 
 
70
    void        mousePressEvent( QMouseEvent * );
 
71
    void        mouseReleaseEvent( QMouseEvent * );
 
72
    void        mouseMoveEvent( QMouseEvent * );
 
73
    void  enterEvent( QEvent *);
 
74
 
 
75
    void        focusInEvent( QFocusEvent *e );
 
76
 
 
77
    void        valueChange();
 
78
    void        rangeChange();
 
79
 
 
80
    virtual void paintPoti( QPainter * );
 
81
    void        drawButton( QPainter *);
 
82
    void        drawTicks( QPainter *, int, int, int=1 ) const;
 
83
 
 
84
    virtual void wheelEvent(QWheelEvent *e);
 
85
private slots:
 
86
    void        repeatTimeout();
 
87
 
 
88
private:
 
89
    enum State { Idle, Dragging, TimingUp, TimingDown };
 
90
 
 
91
    void        init(int value=0);
 
92
    float       positionFromValue( int ) const;
 
93
    int         valueFromPosition( float ) const;
 
94
    void        movePoti( float );
 
95
    void        reallyMovePoti( float );
 
96
    void        resetState();
 
97
    int         potiRadius() const;
 
98
    void        initTicks();
 
99
 
 
100
    QTimer      *timer;
 
101
    float       potiPos;
 
102
    int         potiVal;
 
103
    int         clickOffset;
 
104
    State       state;
 
105
    bool        track;
 
106
    QPoint      center;
 
107
    bool        ticks,label;
 
108
    int         tickInt, space, buttonRadius, fontHeight;
 
109
    QColor      color;
 
110
private:        // Disabled copy constructor and operator=
 
111
    //    KPoti( const KPoti & ) {}
 
112
    //KPoti &operator=( const KPoti & ) { return *this; }
 
113
};
 
114
 
 
115
inline bool KPoti::tracking() const
 
116
{
 
117
    return track;
 
118
}
 
119
 
 
120
 
 
121
#endif // _KPOTI_H
 
122
 
 
123
 
 
124