summaryrefslogtreecommitdiffstats
path: root/kmix/ksmallslider.h
blob: 398d7728f0b83b421b0a3c70bc0dce9187af0c7e (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//-*-C++-*-
/*
 * KMix -- KDE's full featured mini mixer
 *
 *
 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this program; if not, write to the Free
 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#ifndef KSMALLSLIDER_H
#define KSMALLSLIDER_H

#include <kpanelapplet.h>

#include <qwidget.h>
#include <qpixmap.h>
#include <qrangecontrol.h>

class KSmallSlider : public QWidget, public QRangeControl
{
      Q_OBJECT

   public:
      KSmallSlider( QWidget *parent, const char *name=0 );
      KSmallSlider( Qt::Orientation, QWidget *parent, const char *name=0 );
      KSmallSlider( int minValue, int maxValue, int pageStep, int value,
		    Qt::Orientation, QWidget *parent, const char *name=0 );

    //virtual void setTracking( bool enable );
    //bool tracking() const;
      QSize sizeHint() const;
      QSizePolicy sizePolicy() const;
      QSize minimumSizeHint() const;

      int minValue() const;
      int maxValue() const;
      void setMinValue( int ); //  Don't use these unless you make versions
      void setMaxValue( int ); //  that work. -esigra
      int lineStep() const;
      int pageStep() const;
      void setLineStep( int );
      void setPageStep( int );
      int  value() const;

    //void paletteChange ( const QPalette & oldPalette );
      bool gray() const;

public slots:
    virtual void setValue( int );
    void addStep();
    void subtractStep();

      void setGray( bool value );
      void setColors( QColor high, QColor low, QColor back );
      void setGrayColors( QColor high, QColor low, QColor back );

      signals:
      void valueChanged( int value );
      void sliderPressed();
      void sliderMoved( int value );
      void sliderReleased();

   protected:
      void resizeEvent( QResizeEvent * );
      void paintEvent( QPaintEvent * );

      void mousePressEvent( QMouseEvent * );
      void mouseReleaseEvent( QMouseEvent * );
      void mouseMoveEvent( QMouseEvent * );
      void wheelEvent( QWheelEvent * );

      void valueChange();
      void rangeChange();

   private:
    //enum State { Idle, Dragging };

      void init();
      int positionFromValue( int ) const;
      int valueFromPosition( int ) const;
      void moveSlider( int );
    //void resetState();

    //      int slideLength() const;
      int available() const;
      int goodPart( const QPoint& ) const;
    //void initTicks();

    //QCOORD sliderPos;
    //int sliderVal;
    //State state;
    //bool track;
      bool grayed;
      Qt::Orientation _orientation;
      QColor colHigh, colLow, colBack;
      QColor grayHigh, grayLow, grayBack;

};

/*
inline bool KSmallSlider::tracking() const
{
    return track;
}
*/
#endif