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
|
// $Id: Flu_Spinner.h 672 2007-09-02 15:47:45Z Larry $
/***************************************************************
* FLU - FLTK Utility Widgets
* Copyright (C) 2002 Ohio Supercomputer Center, Ohio State University
*
* This file and its content is protected by a software license.
* You should have received a copy of this license with this file.
* If not, please contact the Ohio Supercomputer Center immediately:
* Attn: Jason Bryan Re: FLU 1224 Kinnear Rd, Columbus, Ohio 43212
*
***************************************************************/
#ifndef _FLU_SPINNER_H
#define _FLU_SPINNER_H
#include <FL/Fl_Valuator.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Group.H>
#include "Flu_Enumerations.h"
//! This class provides a simple spinner widget similar to Fl_Counter, except the manipulator buttons are vertical and you can click, click and hold, or click and drag to change the value
class FLU_EXPORT Flu_Spinner : public Fl_Valuator
{
class NoTabInput : public Fl_Input
{
public:
NoTabInput( Flu_Spinner *s, int x, int y, int w, int h, const char *l = 0 );
int handle( int event );
void draw();
Flu_Spinner *spinner;
};
public:
//! Normal FLTK widget constructor
Flu_Spinner( int x, int y, int w, int h, const char *l = 0 );
//! Default destructor
~Flu_Spinner();
//! Get whether the spinner automatically changes when you hold the button down
inline bool enable_repeating() const
{ return _doRepeat; }
//! Set whether the spinner automatically changes when you hold the button down
inline void enable_repeating( bool b )
{ _doRepeat = b; }
//! Set the auto repeating parameters
/*! \param initialDelay is how long to wait before repeating starts. Default is 0.5 seconds
\param initialTime is how long to wait between value changes. Default is 0.1 seconds (i.e. 10x per second)
\param rapidDelay is how long to wait before repeating more quickly. Default is 2 seconds
\param rapidTime is how long to wait between rapid value changes. Default is 0.02 seconds (i.e. 50x per second)
*/
inline void repeat( float initialDelay, float initialTime, float rapidDelay, float rapidTime )
{ _initialDelay = initialDelay; _repeatTime[0] = initialTime; _rapidDelay = rapidDelay;_repeatTime[1] = rapidTime; }
//! Get when the input calls the callback
inline int input_when() const
{ return _input.when(); }
//! Set when the input calls the callback
inline void input_when( int w )
{ _input.when(w); }
//! Get whether the input field can be edited. Default is \c true
inline bool editable() const
{ return _editable; }
//! Set whether the input field can be edited.
inline void editable( bool b )
{ _editable = b; }
//! Override of Fl_Widget::handle()
int handle( int );
//! Override of Fl_Widget::resize()
void resize( int X, int Y, int W, int H );
//! Override of Fl_Valuator::precision()
inline void precision( int p )
{ Fl_Valuator::precision(p); value_damage(); }
//! Override of Fl_Valuator::value_damage()
void value_damage();
//! Override of Fl_Valuator::hide()
inline void hide()
{ Fl_Valuator::hide(); _input.hide(); }
//! Override of Fl_Valuator::show()
inline void show()
{ Fl_Valuator::show(); _input.show(); }
//! Get the font for the widget value
inline Fl_Font valuefont() const { return (Fl_Font)_input.textfont(); }
//! Set the font for the widget value
inline void valuefont( uchar s ) { _input.textfont(s); }
//! Get the size of the font for the widget value
inline uchar valuesize() const { return _input.textsize(); }
//! Set the size of the font for the widget value
inline void valuesize( uchar s ) { _input.textsize(s); }
//! Get the background color of the widget value
inline Fl_Color valuecolor() const { return (Fl_Color)_input.color(); }
//! Set the background color for the widget value
inline void valuecolor( unsigned s ) { _input.color(s); }
//! Set the background and selection color for the widget value
inline void valuecolor( unsigned s, unsigned s1 ) { _input.color(s,s1); }
//! Get the color of the font for the widget value
inline Fl_Color valuefontcolor() const { return (Fl_Color)_input.textcolor(); }
//! Set the color of the font for the widget value
inline void valuefontcolor( unsigned s ) { _input.textcolor(s); }
protected:
friend class NoTabInput;
NoTabInput _input;
uchar _valbox[2];
bool _up, _pushed, _editable, _dragging;
float _totalTime;
double _lastValue;
int _lastY;
float _initialDelay, _repeatTime[2], _rapidDelay;
bool _doRepeat;
static void input_cb( Fl_Widget*, void* v );
static void repeat_callback(void *);
void increment_cb();
protected:
void draw();
};
#endif
|