summaryrefslogtreecommitdiffstats
path: root/libkscan/kscanslider.h
blob: 0ecf73af9f64a03b1596e78355f06cc376e90d4d (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/* This file is part of the KDE Project
   Copyright (C) 2000 Klaas Freitag <[email protected]>

   This library 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 library 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 library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef KSCANSLIDER_H
#define KSCANSLIDER_H

#include <tqframe.h>
#include <tqstrlist.h>
#include <tqhbox.h>
#include <tqcombobox.h>
#include <tqslider.h>
#include <tqlineedit.h>
/**
  *@author Klaas Freitag
  */

class TQPushButton;
class TQSpinBox;
class TQLabel;

/**
 * a kind of extended slider which has a spinbox beside the slider offering
 * the possibility to enter an exact numeric value to the slider. If
 * desired, the slider has a neutral button by the side. A descriptional
 * text is handled automatically.
 *
 * @author Klaas Freitag <[email protected]>
 */
class KScanSlider : public TQFrame
{
   Q_OBJECT
  
   TQ_PROPERTY( int slider_val READ value WRITE slSetSlider )

public:
   /**
    * Create the slider.
    *
    * @param parent parent widget
    * @param text is the text describing the the slider value. If the text
    *        contains a '&', a buddy for the slider will be created.
    * @param min minimum slider value
    * @param max maximum slider value
    * @param haveStdButt make a 'set to standard'-button visible. The button
    *        appears on the left of the slider.
    * @param stdValue the value to which the standard button resets the slider.
    */
   KScanSlider( TQWidget *parent, const TQString& text,
		double min, double max, bool haveStdButt=false,
		int stdValue=0);
   /**
    * Destructor
    */
   ~KScanSlider();

   /**
    * @return the current slider value
    */
   int value( ) const
      { return( slider->value()); }

public slots:
  /**
   * sets the slider value
   */
   void		slSetSlider( int );

   /**
    * enables the complete slider.
    */
   void		setEnabled( bool b );

protected slots:
    /**
     * reverts the slider back to the standard value given in the constructor
     */
     void         slRevertValue();

   signals:
    /**
     * emitted if the slider value changes
     */
     void	  valueChanged( int );

private slots:
   void		slSliderChange( int );

private:
   TQSlider	*slider;
   TQLabel	*l1, *numdisp;
   TQSpinBox     *m_spin;
   int          m_stdValue;
   TQPushButton  *m_stdButt;
   class KScanSliderPrivate;
   KScanSliderPrivate *d;

};

/**
 * a entry field with a prefix text for description.
 */
class KScanEntry : public TQFrame
{
   Q_OBJECT
  
   TQ_PROPERTY( TQString text READ text WRITE slSetEntry )

public:
   /**
    * create a new entry field prepended by text.
    * @param parent the parent widget
    * @text the prefix text
    */
   KScanEntry( TQWidget *parent, const TQString& text );
   // ~KScanEntry();

   /**
    * @return the current entry field contents.
    */
   TQString text( ) const;

public slots:
   /**
    * set the current text
    * @param t the new string
    */
   void		slSetEntry( const TQString& t );
   /**
    * enable or disable the text entry.
    * @param b set enabled if true, else disabled.
    */
   void		setEnabled( bool b ){ if( entry) entry->setEnabled( b ); }

protected slots:
   void         slReturnPressed( void );

signals:
   void		valueChanged( const TQCString& );
   void         returnPressed( const TQCString& );

private slots:
   void		slEntryChange( const TQString& );

private:
   TQLineEdit 	*entry;

   class KScanEntryPrivate;
   KScanEntryPrivate *d;

};


/**
 * a combobox filled with a decriptional text.
 */
class KScanCombo : public TQHBox
{
   Q_OBJECT
  
   TQ_PROPERTY( TQString cbEntry READ currentText WRITE slSetEntry )

public:
   /**
    * create a combobox with prepended text.
    *
    * @param parent parent widget
    * @param text the text the combobox is prepended by
    * @param list a stringlist with values the list should contain.
    */
   KScanCombo( TQWidget *parent, const TQString& text, const TQStrList& list );
   KScanCombo( TQWidget *parent, const TQString& text, const TQStringList& list );
   // ~KScanCombo();

   /**
    * @return the current selected text
    */
   TQString      currentText( ) const;

   /**
    * @return the text a position i
    */
   TQString      text( int i ) const;

   /**
    * @return the amount of list entries.
    */
   int  	count( ) const;

public slots:
   /**
    * set the current entry to the given string if it is member of the list.
    * if not, the entry is not changed.
    */
   void		slSetEntry( const TQString &);

   /**
    * enable or disable the combobox.
    * @param b enables the combobox if true.
    */
   void		setEnabled( bool b){ if(combo) combo->setEnabled( b ); };

   /**
    * set an icon for a string in the combobox
    * @param pix the pixmap to set.
    * @param str the string for which the pixmap should be set.
    */
   void         slSetIcon( const TQPixmap& pix, const TQString& str);

   /**
    * set the current item of the combobox.
    */
   void         setCurrentItem( int i );

private slots:
   void         slFireActivated( int);
   void		slComboChange( const TQString & );

signals:
   void		valueChanged( const TQCString& );
   void         activated(int);

private:
    void createCombo( const TQString& text );
   TQComboBox	*combo;
   TQStrList	combolist;

   class KScanComboPrivate;
   KScanComboPrivate *d;
};

#endif