a3a06d39d33b85c2159d1be4af686df1a5e8bb2f
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / motionfeedback.h
1 /*
2     Copyright (C) 1998-99 Paul Barton-Davis 
3     This program is free software; you can redistribute it and/or modify
4     it under the terms of the GNU General Public License as published by
5     the Free Software Foundation; either version 2 of the License, or
6     (at your option) any later version.
7
8     This program is distributed in the hope that it will be useful,
9     but WITHOUT ANY WARRANTY; without even the implied warranty of
10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11     GNU General Public License for more details.
12
13     You should have received a copy of the GNU General Public License
14     along with this program; if not, write to the Free Software
15     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
17     $Id: motionfeedback.h,v 1.1.1.1 2001/11/24 00:44:46 pbd Exp $
18 */
19
20 #ifndef __gtkmm2ext_motion_feedback_h__
21 #define __gtkmm2ext_motion_feedback_h__
22
23 #include <gdkmm/pixbuf.h>
24 #include <gtkmm/box.h>
25 #include <gtkmm/eventbox.h>
26
27 namespace Gtk {
28         class Adjustment;
29         class SpinButton;
30 }
31
32 namespace Gtkmm2ext {
33
34 class MotionFeedback : public Gtk::VBox
35 {
36  public:
37         enum Type {
38                 Rotary,
39                 CenterSpring,
40                 Endless
41         };
42
43         MotionFeedback (Glib::RefPtr<Gdk::Pixbuf>, 
44                         Type type,
45                         const char *widget_name = NULL,
46                         Gtk::Adjustment *adj = NULL, 
47                         bool with_numeric_display = true,
48                         int sub_image_width = 40,
49                         int sub_image_height = 40);
50         virtual ~MotionFeedback ();
51
52         void set_adjustment (Gtk::Adjustment *adj);
53         Gtk::Adjustment *get_adjustment () { return adjustment; }
54
55         Gtk::Widget&     eventwin () { return pixwin; }
56         Gtk::SpinButton& spinner() const { return *value; }
57
58         gfloat lower () { return _lower; }
59         gfloat upper () { return _upper; }
60         gfloat range () { return _range; }
61
62  protected:
63         gfloat _range;
64         gfloat _lower;
65         gfloat _upper;
66
67         void pixwin_size_request (GtkRequisition *);
68
69         bool pixwin_button_press_event (GdkEventButton *);
70         bool pixwin_button_release_event (GdkEventButton *);
71         bool pixwin_motion_notify_event (GdkEventMotion *);
72         bool pixwin_key_press_event (GdkEventKey *);
73         bool pixwin_enter_notify_event (GdkEventCrossing *);
74         bool pixwin_leave_notify_event (GdkEventCrossing *);
75         bool pixwin_focus_in_event (GdkEventFocus*);
76         bool pixwin_focus_out_event (GdkEventFocus *);
77         bool pixwin_expose_event (GdkEventExpose*);
78         bool pixwin_scroll_event (GdkEventScroll*);
79
80   private:
81         Type type;
82         Gtk::EventBox      pixwin;
83         Gtk::HBox*         value_packer;
84         Gtk::SpinButton*   value;
85         Gtk::Adjustment*   adjustment;
86         Glib::RefPtr<Gdk::Pixbuf> pixbuf;
87
88         double default_value;
89         double  step_inc;
90         double page_inc;
91         bool   grab_is_fine;
92         double grabbed_y;
93         double grabbed_x;
94         bool i_own_my_adjustment;
95         int subwidth;
96         int subheight;
97         void adjustment_changed ();
98 };
99
100 } /* namespace */
101         
102 #endif // __gtkmm2ext_motion_feedback_h__