diff options
| author | Alexander Valavanis <valavanisalex@gmail.com> | 2018-12-29 15:41:42 +0000 |
|---|---|---|
| committer | Alexander Valavanis <valavanisalex@gmail.com> | 2018-12-29 15:41:42 +0000 |
| commit | efbcfe42b148e4b5cda9c0ba230e2de94e5079b2 (patch) | |
| tree | 8304f18b2dc0cf5a5ebc69e8981fdc4bdaaa37de /src/widgets/button.h | |
| parent | SPDesktopWidget: Migrate ruler events to sigc++ (diff) | |
| download | inkscape-efbcfe42b148e4b5cda9c0ba230e2de94e5079b2.tar.gz inkscape-efbcfe42b148e4b5cda9c0ba230e2de94e5079b2.zip | |
C++ify button widget
Diffstat (limited to 'src/widgets/button.h')
| -rw-r--r-- | src/widgets/button.h | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/src/widgets/button.h b/src/widgets/button.h index a8fc61bee..736eed273 100644 --- a/src/widgets/button.h +++ b/src/widgets/button.h @@ -12,12 +12,9 @@ #ifndef SEEN_SP_BUTTON_H #define SEEN_SP_BUTTON_H -#include <gtk/gtk.h> +#include <gtkmm/togglebutton.h> #include <sigc++/connection.h> -#define SP_TYPE_BUTTON (sp_button_get_type ()) -G_DECLARE_FINAL_TYPE(SPButton, sp_button, SP, BUTTON, GtkToggleButton); - struct SPAction; namespace Inkscape { @@ -37,30 +34,49 @@ struct SPBChoiceData { guchar *px; }; -struct _SPButton { - GtkToggleButton parent_instance; +class SPButton : public Gtk::ToggleButton{ +private: + SPButtonType _type; + GtkIconSize _lsize; + unsigned int _psize; + SPAction *_action; + SPAction *_doubleclick_action; - SPButtonType type; - GtkIconSize lsize; - unsigned int psize; - SPAction *action; - SPAction *doubleclick_action; + sigc::connection _c_set_active; + sigc::connection _c_set_sensitive; - sigc::connection c_set_active; - sigc::connection c_set_sensitive; -}; + void set_action(SPAction *action); + void set_doubleclick_action(SPAction *action); + void set_composed_tooltip(SPAction *action); + void action_set_active(bool active); + void perform_action(); + bool process_event(GdkEvent *event); -#define SP_BUTTON_IS_DOWN(b) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (b)) + sigc::connection _on_clicked; + +protected: + virtual void get_preferred_width_vfunc(int &minimum_width, int &natural_width) const override; + virtual void get_preferred_height_vfunc(int &minimum_height, int &natural_height) const override; + void on_clicked() override; -GtkWidget *sp_button_new (GtkIconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action); +public: + SPButton(GtkIconSize size, + SPButtonType type, + SPAction *action, + SPAction *doubleclick_action); + + SPButton(GtkIconSize size, + SPButtonType type, + Inkscape::UI::View::View *view, + const gchar *name, + const gchar *tip); -void sp_button_toggle_set_down (SPButton *button, gboolean down); + ~SPButton(); -GtkWidget *sp_button_new_from_data (GtkIconSize size, - SPButtonType type, - Inkscape::UI::View::View *view, - const gchar *name, - const gchar *tip); + void toggle_set_down(bool down); +}; + +#define SP_BUTTON_IS_DOWN(b) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (b)) #endif // !SEEN_SP_BUTTON_H |
