X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fgtkmm2ext%2Fgtkmm2ext%2Fcairo_widget.h;h=036160ab14407e71a39820cfdf08d25862febab2;hb=86f56de6564728d0715191756373f48d983f4328;hp=c8927b050b98fbce2fa88b3f6fe1965173d5828b;hpb=e4e6010cd4671f8b7f90edeee0d41ad89bdf1192;p=ardour.git diff --git a/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h index c8927b050b..036160ab14 100644 --- a/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h +++ b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h @@ -20,6 +20,7 @@ #ifndef __gtk2_ardour_cairo_widget_h__ #define __gtk2_ardour_cairo_widget_h__ +#include #include #include "gtkmm2ext/visibility.h" @@ -39,7 +40,7 @@ public: Gtkmm2ext::ActiveState active_state() const { return _active_state; } Gtkmm2ext::VisualState visual_state() const { return _visual_state; } - /* derived widgets can override these two to catch + /* derived widgets can override these two to catch changes in active & visual state */ @@ -67,12 +68,40 @@ public: static void provide_background_for_cairo_widget (Gtk::Widget& w, const Gdk::Color& bg); + virtual void render (cairo_t *, cairo_rectangle_t*) = 0; + + static void set_flat_buttons (bool yn); + static bool flat_buttons() { return _flat_buttons; } + + static void set_widget_prelight (bool yn); + static bool widget_prelight() { return _widget_prelight; } + + static void set_source_rgb_a( cairo_t* cr, Gdk::Color, float a=1.0 ); + + /* set_focus_handler() will cause all button-press events on any + CairoWidget to invoke this slot/functor/function/method/callback. + + We do this because in general, CairoWidgets do not grab + keyboard focus, but a button press on them should + clear focus from any active text entry. + + This is global to all CairoWidgets and derived types. + + However, derived types can override the behaviour by defining their + own on_button_press_event() handler which returns true under all + conditions (which will block this handler from being called). If + they wish to invoke any existing focus handler from their own + button press handler, they can just use: focus_handler(); + */ + static void set_focus_handler (sigc::slot); + protected: /** Render the widget to the given Cairo context */ - virtual void render (cairo_t *) = 0; virtual bool on_expose_event (GdkEventExpose *); void on_size_allocate (Gtk::Allocation &); void on_state_changed (Gtk::StateType); + void on_style_changed (const Glib::RefPtr&); + bool on_button_press_event (GdkEventButton*); Gdk::Color get_parent_bg (); /* this is an additional virtual "on_..." method. Glibmm does not @@ -85,8 +114,18 @@ protected: Gtkmm2ext::VisualState _visual_state; bool _need_bg; + static bool _flat_buttons; + static bool _widget_prelight; + bool _grabbed; + + static sigc::slot focus_handler; + private: + Cairo::RefPtr image_surface; Glib::SignalProxyProperty _name_proxy; + sigc::connection _parent_style_change; + Widget * _current_parent; + }; #endif