1 #ifndef oxygenscrollbardata_h
2 #define oxygenscrollbardata_h
3 /*
4 * this file is part of the oxygen gtk engine
5 * Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
6 *
7 * This  library is free  software; you can  redistribute it and/or
8 * modify it  under  the terms  of the  GNU Lesser  General  Public
9 * License  as published  by the Free  Software  Foundation; either
10 * version 2 of the License, or(at your option ) any later version.
11 *
12 * This library is distributed  in the hope that it will be useful,
13 * but  WITHOUT ANY WARRANTY; without even  the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License  along  with  this library;  if not,  write to  the Free
19 * Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
21 */
22 
23 #include "oxygensignal.h"
24 #include "oxygentimer.h"
25 
26 #include <gtk/gtk.h>
27 
28 namespace Oxygen
29 {
30     // track scrollbars
31     class ScrollBarData
32     {
33 
34         public:
35 
36         //! constructor
ScrollBarData(void)37         ScrollBarData( void ):
38             _target( 0L ),
39             _updatesDelayed( false ),
40             _delay( 10 ),
41             _locked( false )
42         {}
43 
44         //! destructor
~ScrollBarData(void)45         virtual ~ScrollBarData( void )
46         { disconnect( _target ); }
47 
48         //! setup connections
49         void connect( GtkWidget* );
50 
51         //! disconnect
52         void disconnect( GtkWidget* );
53 
54         //! toggle delayed updates
setUpdatesDelayed(bool value)55         void setUpdatesDelayed( bool value )
56         { _updatesDelayed = value; }
57 
58         //! set delay
setDelay(int value)59         void setDelay( int value )
60         { _delay = value; }
61 
62         protected:
63 
64         static void valueChanged( GtkRange*, gpointer );
65 
66         //! delayed update
67         static gboolean delayedUpdate( gpointer );
68 
69         private:
70 
71         //! pointer to associated widget
72         GtkWidget* _target;
73 
74         //! true if updates are delayed
75         bool _updatesDelayed;
76 
77         //! update delay
78         int _delay;
79 
80         //! timer
81         Timer _timer;
82 
83         //! true if next update must be delayed
84         bool _locked;
85 
86         //! signal
87         Signal _valueChangedId;
88 
89     };
90 
91 }
92 
93 #endif
94