Canola  0.8.D001
canola/slider.h
Go to the documentation of this file.
00001 //
00002 // canola - canon canola 1614p emulator
00003 // Copyright (C) 2012 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, version 3, as
00007 // published by the Free Software Foundation.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License along
00015 // with this program. If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #ifndef CANOLA_SLIDER_H
00019 #define CANOLA_SLIDER_H
00020 
00021 #include <lib/config.h>
00022 #include <gtkmm.h>
00023 #include <vector>
00024 
00029 class slider:
00030     public Gtk::EventBox
00031 {
00032 public:
00036     virtual ~slider();
00037 
00038     typedef sigc::signal<void> value_changed_signal_t;
00039 
00049     value_changed_signal_t &value_changed_signal(void);
00050 
00055     int get_value(void) const;
00056 
00064     void set_value(int n);
00065 
00066 protected:
00079     slider(const std::string &name, int npos, bool act_on_rel = false);
00080 
00081 private:
00088     int nvalues;
00089 
00097     int value;
00098 
00099     typedef Glib::RefPtr<Gdk::Pixbuf> pixbuf_pointer;
00100 
00105     std::vector<pixbuf_pointer> value_images;
00106 
00112     Gtk::Image appearance;
00113 
00118     bool down;
00119 
00125     bool inside;
00126 
00133     int old_value;
00134 
00140     int frac;
00141 
00146     bool on_button_press(GdkEventButton *ep);
00147 
00152     bool on_button_release(GdkEventButton *ep);
00153 
00158     bool on_motion_notify(GdkEventMotion *ep);
00159 
00166     void update_value(int x, int y);
00167 
00171     value_changed_signal_t value_changed_source;
00172 
00177     bool activate_on_release;
00178 
00183     slider();
00184 
00192     slider(const slider &rhs);
00193 
00201     slider &operator=(const slider &rhs);
00202 };
00203 
00204 #endif // CANOLA_SLIDER_H