diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2008-06-02 21:41:35 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2008-06-02 21:41:35 +0000 |
commit | 449aab3c465bbbf66d221fac3d7ea559f1720357 (patch) | |
tree | 6843cc40c88250a132acac701271f1504cd2df04 /libs/gtkmm2ext/gtkmm2ext | |
parent | 9c0d7d72d70082a54f823cd44c0ccda5da64bb6f (diff) |
rollback to 3428, before the mysterious removal of libs/* at 3431/3432
git-svn-id: svn://localhost/ardour2/branches/3.0@3435 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/gtkmm2ext/gtkmm2ext')
31 files changed, 2141 insertions, 0 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/.cvsignore b/libs/gtkmm2ext/gtkmm2ext/.cvsignore new file mode 100644 index 0000000000..67020331ba --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/.cvsignore @@ -0,0 +1 @@ +version.h diff --git a/libs/gtkmm2ext/gtkmm2ext/auto_spin.h b/libs/gtkmm2ext/gtkmm2ext/auto_spin.h new file mode 100644 index 0000000000..b692a7ccdc --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/auto_spin.h @@ -0,0 +1,71 @@ +/* + Copyright (C) 2000 Paul Barton-Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_auto_spin_h__ +#define __gtkmm2ext_auto_spin_h__ + +#include <gtkmm.h> + +namespace Gtkmm2ext { + +class AutoSpin + +{ + public: + AutoSpin (Gtk::Adjustment &adj, gfloat cr = 0, bool round_to_steps_yn = false); + + Gtk::Adjustment &get_adjustment() { return adjustment; } + + void use_left_as_decrement (bool yn) { left_is_decrement = yn; } + void set_wrap (bool yn) { wrap = yn; } + void set_climb_rate (gfloat cr) { climb_rate = cr; } + void set_bounds (gfloat initial, gfloat low, gfloat high, + bool with_reset = true); + + gint button_press (GdkEventButton *); + gint stop_spinning (GdkEventButton *ignored_but_here_for_clicked); + void start_spinning (bool decrementing, bool use_page); + + private: + Gtk::Adjustment &adjustment; + gfloat climb_rate; + gfloat timer_increment; + gfloat initial; + unsigned int timer_calls; + bool have_timer; + bool need_timer; + bool wrap; + gint timeout_tag; + bool left_is_decrement; + bool round_to_steps; + + static const unsigned int initial_timer_interval; + static const unsigned int timer_interval; + static const unsigned int climb_timer_calls; + + void stop_timer (); + static gint _timer (void *arg); + gint timer (); + bool adjust_value (gfloat increment); + void set_value (gfloat value); +}; + +} /* namespace */ + +#endif /* __gtkmm2ext_auto_spin_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/barcontroller.h b/libs/gtkmm2ext/gtkmm2ext/barcontroller.h new file mode 100644 index 0000000000..fe67e9ecec --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/barcontroller.h @@ -0,0 +1,104 @@ +/* + Copyright (C) 2004 Paul Davis + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_bar_controller_h__ +#define __gtkmm2ext_bar_controller_h__ + +#include <gtkmm/frame.h> +#include <gtkmm/drawingarea.h> +#include <gtkmm2ext/binding_proxy.h> + +namespace ARDOUR { + class Controllable; +} + +namespace Gtkmm2ext { + +class BarController : public Gtk::Frame +{ + public: + typedef sigc::slot<void,char*,unsigned int> LabelCallback; + + BarController (Gtk::Adjustment& adj, PBD::Controllable&, LabelCallback lc = LabelCallback()); + + virtual ~BarController () {} + + enum Style { + LeftToRight, + RightToLeft, + Line, + CenterOut, + + TopToBottom, + BottomToTop + }; + + Style style() const { return _style; } + void set_style (Style); + void set_with_text (bool yn); + void set_use_parent (bool yn); + + void set_sensitive (bool yn); + + Gtk::SpinButton& get_spin_button() { return spinner; } + + sigc::signal<void> StartGesture; + sigc::signal<void> StopGesture; + + /* export this to allow direct connection to button events */ + + Gtk::Widget& event_widget() { return darea; } + PBD::Controllable* get_controllable() { return binding_proxy.get_controllable(); } + + protected: + Gtk::Adjustment& adjustment; + BindingProxy binding_proxy; + Gtk::DrawingArea darea; + LabelCallback label_callback; + Glib::RefPtr<Pango::Layout> layout; + Style _style; + bool grabbed; + bool switching; + bool switch_on_release; + bool with_text; + double initial_value; + double grab_x; + GdkWindow* grab_window; + Gtk::SpinButton spinner; + bool use_parent; + + virtual bool button_press (GdkEventButton *); + virtual bool button_release (GdkEventButton *); + virtual bool motion (GdkEventMotion *); + virtual bool expose (GdkEventExpose *); + virtual bool scroll (GdkEventScroll *); + virtual bool entry_focus_out (GdkEventFocus*); + + gint mouse_control (double x, GdkWindow* w, double scaling); + + gint switch_to_bar (); + gint switch_to_spinner (); + + void entry_activated (); + void drop_grab (); +}; + + +}; /* namespace */ + +#endif // __gtkmm2ext_bar_controller_h__ diff --git a/libs/gtkmm2ext/gtkmm2ext/bindable_button.h b/libs/gtkmm2ext/gtkmm2ext/bindable_button.h new file mode 100644 index 0000000000..1cde32c5ba --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/bindable_button.h @@ -0,0 +1,81 @@ +/* + Copyright (C) 2004 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __bindable_button_h__ +#define __bindable_button_h__ + +#include <string> + +#include <gtkmm2ext/stateful_button.h> +#include "binding_proxy.h" + +namespace PBD { + class Controllable; +} + +class BindableToggleButton : public Gtkmm2ext::StatefulToggleButton +{ + public: + BindableToggleButton (PBD::Controllable& c) : binding_proxy (c) {} + + explicit BindableToggleButton (PBD::Controllable& c, const std::string &label) + : Gtkmm2ext::StatefulToggleButton (label), binding_proxy (c) {} + + virtual ~BindableToggleButton() {} + + bool on_button_press_event (GdkEventButton *ev) { + if (!binding_proxy.button_press_handler (ev)) { + StatefulToggleButton::on_button_press_event (ev); + return false; + } else { + return true; + } + } + + PBD::Controllable* get_controllable() { return binding_proxy.get_controllable(); } + private: + BindingProxy binding_proxy; +}; + +class BindableButton : public Gtkmm2ext::StatefulButton +{ + public: + BindableButton (PBD::Controllable& c) : binding_proxy (c) {} + + explicit BindableButton (PBD::Controllable& c, const std::string &label) + : Gtkmm2ext::StatefulButton (label), binding_proxy (c) {} + + ~BindableButton() {} + + bool on_button_press_event (GdkEventButton *ev) { + if (!binding_proxy.button_press_handler (ev)) { + StatefulButton::on_button_press_event (ev); + return false; + } else { + return true; + } + } + + PBD::Controllable* get_controllable() { return binding_proxy.get_controllable(); } + + private: + BindingProxy binding_proxy; +}; + +#endif diff --git a/libs/gtkmm2ext/gtkmm2ext/binding_proxy.h b/libs/gtkmm2ext/gtkmm2ext/binding_proxy.h new file mode 100644 index 0000000000..dd9b94319d --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/binding_proxy.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2006 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id$ +*/ + +#ifndef __binding_proxy__ +#define __binding_proxy__ + +#include <string> + +#include <gtkmm2ext/popup.h> + +namespace PBD { + class Controllable; +} + +class BindingProxy : public sigc::trackable +{ + public: + BindingProxy (PBD::Controllable&); + virtual ~BindingProxy(); + + void set_bind_button_state (guint button, guint statemask); + void get_bind_button_state (guint &button, guint &statemask); + + bool button_press_handler (GdkEventButton *); + + PBD::Controllable* get_controllable() { return &controllable; } + protected: + + Gtkmm2ext::PopUp* prompter; + PBD::Controllable& controllable; + guint bind_button; + guint bind_statemask; + sigc::connection learning_connection; + void learning_finished (); + bool prompter_hiding (GdkEventAny *); +}; + +#endif diff --git a/libs/gtkmm2ext/gtkmm2ext/choice.h b/libs/gtkmm2ext/gtkmm2ext/choice.h new file mode 100644 index 0000000000..b6dcdc05c1 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/choice.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2000-2007 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __pbd_gtkmm_choice_h__ +#define __pbd_gtkmm_choice_h__ + +#include <gtkmm/dialog.h> +#include <gtkmm/image.h> +#include <gtkmm/stock.h> +#include <gtkmm/box.h> +#include <string> +#include <vector> + +namespace Gtkmm2ext { + +class Choice : public Gtk::Dialog +{ + public: + Choice (std::string prompt, std::vector<std::string> choices, bool center = true); + virtual ~Choice (); + + protected: + void on_realize (); +}; + +} /* namespace */ + +#endif // __pbd_gtkmm_choice_h__ diff --git a/libs/gtkmm2ext/gtkmm2ext/click_box.h b/libs/gtkmm2ext/gtkmm2ext/click_box.h new file mode 100644 index 0000000000..8f9fb55717 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/click_box.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 1999 Paul Barton-Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_click_box_h__ +#define __gtkmm2ext_click_box_h__ + +#include <string> +#include <gtkmm.h> + +#include <gtkmm2ext/auto_spin.h> + +namespace Gtkmm2ext { + +class ClickBox : public Gtk::DrawingArea, public AutoSpin +{ + public: + ClickBox (Gtk::Adjustment *adj, const std::string &name, bool round_to_steps = false); + ~ClickBox (); + + void set_print_func(void (*pf)(char buf[32], Gtk::Adjustment &, void *), + void *arg) { + print_func = pf; + print_arg = arg; + set_label (); + } + + + protected: + bool on_expose_event (GdkEventExpose*); + + private: + void (*print_func) (char buf[32], Gtk::Adjustment &, void *); + void *print_arg; + + Glib::RefPtr<Pango::Layout> layout; + int twidth; + int theight; + + void set_label (); + void style_changed (const Glib::RefPtr<Gtk::Style> &); + bool button_press_handler (GdkEventButton *); + bool button_release_handler (GdkEventButton *); + + static void default_printer (char buf[32], Gtk::Adjustment &, void *); +}; + +} /* namespace */ + +#endif /* __gtkmm2ext_click_box_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/dndtreeview.h b/libs/gtkmm2ext/gtkmm2ext/dndtreeview.h new file mode 100644 index 0000000000..fbc5ea90ef --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/dndtreeview.h @@ -0,0 +1,165 @@ +/* + Copyright (C) 2000-2007 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_dndtreeview_h__ +#define __gtkmm2ext_dndtreeview_h__ + +#include <stdint.h> +#include <string> +#include <gtkmm/treeview.h> +#include <gtkmm/treeselection.h> +#include <gtkmm/selectiondata.h> + +namespace Gtkmm2ext { + +template<class DataType> +struct SerializedObjectPointers { + uint32_t size; + uint32_t cnt; + char type[32]; + DataType data[0]; +}; + +class DnDTreeViewBase : public Gtk::TreeView +{ + private: + public: + DnDTreeViewBase (); + ~DnDTreeViewBase() {} + + void add_drop_targets (std::list<Gtk::TargetEntry>&); + void add_object_drag (int column, std::string type_name); + + void on_drag_leave(const Glib::RefPtr<Gdk::DragContext>& context, guint time) { + suggested_action = context->get_suggested_action(); + TreeView::on_drag_leave (context, time); + } + + bool on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time) { + suggested_action = context->get_suggested_action(); + return TreeView::on_drag_motion (context, x, y, time); + } + + bool on_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time); + + protected: + std::list<Gtk::TargetEntry> draggable; + Gdk::DragAction suggested_action; + int data_column; +}; + +template<class DataType> +class DnDTreeView : public DnDTreeViewBase +{ + public: + DnDTreeView() {} + ~DnDTreeView() {} + + sigc::signal<void,std::string,uint32_t,const DataType*> signal_object_drop; + + void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time) { + if (selection_data.get_target() == "GTK_TREE_MODEL_ROW") { + + TreeView::on_drag_data_get (context, selection_data, info, time); + + } else if (data_column >= 0) { + + Gtk::TreeSelection::ListHandle_Path selection = get_selection()->get_selected_rows (); + SerializedObjectPointers<DataType>* sr = serialize_pointers (get_model(), &selection, selection_data.get_target()); + selection_data.set (8, (guchar*)sr, sr->size); + } + } + + void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time) { + if (suggested_action) { + /* this is a drag motion callback. just update the status to + say that we are still dragging, and that's it. + */ + suggested_action = Gdk::DragAction (0); + TreeView::on_drag_data_received (context, x, y, selection_data, info, time); + return; + } + + if (selection_data.get_target() == "GTK_TREE_MODEL_ROW") { + + TreeView::on_drag_data_received (context, x, y, selection_data, info, time); + + } else if (data_column >= 0) { + + /* object D-n-D */ + + const void* data = selection_data.get_data(); + const SerializedObjectPointers<DataType>* sr = reinterpret_cast<const SerializedObjectPointers<DataType> *>(data); + + if (sr) { + signal_object_drop (sr->type, sr->cnt, sr->data); + } + + } else { + /* some kind of target type added by the app, which will be handled by a signal handler */ + } + } + + private: + + SerializedObjectPointers<DataType>* serialize_pointers (Glib::RefPtr<Gtk::TreeModel> model, + Gtk::TreeSelection::ListHandle_Path* selection, + Glib::ustring type) { + + /* this nasty chunk of code is here because X's DnD protocol (probably other graphics UI's too) + requires that we package up the entire data collection for DnD in a single contiguous region + (so that it can be trivially copied between address spaces). We don't know the type of DataType so + we have to mix-and-match C and C++ programming techniques here to get the right result. + + The C trick is to use the "someType foo[0];" declaration trick to create a zero-sized array at the + end of a SerializedObjectPointers<DataType object. Then we allocate a raw memory buffer that extends + past that array and thus provides space for however many DataType items we actually want to pass + around. + + The C++ trick is to use the placement operator new() syntax to initialize that extra + memory properly. + */ + + uint32_t cnt = selection->size(); + uint32_t sz = (sizeof (DataType) * cnt) + sizeof (SerializedObjectPointers<DataType>); + + char* buf = new char[sz]; + SerializedObjectPointers<DataType>* sr = (SerializedObjectPointers<DataType>*) buf; + + for (uint32_t i = 0; i < cnt; ++i) { + new ((void *) &sr->data[i]) DataType (); + } + + sr->cnt = cnt; + sr->size = sz; + snprintf (sr->type, sizeof (sr->type), "%s", type.c_str()); + + cnt = 0; + + for (Gtk::TreeSelection::ListHandle_Path::iterator x = selection->begin(); x != selection->end(); ++x, ++cnt) { + model->get_iter (*x)->get_value (data_column, sr->data[cnt]); + } + + return sr; + } +}; + +} // namespace + +#endif /* __gtkmm2ext_dndtreeview_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/doi.h b/libs/gtkmm2ext/gtkmm2ext/doi.h new file mode 100644 index 0000000000..6ad1f7dd94 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/doi.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __ardour_gtk_doi_h__ +#define __ardour_gtk_doi_h__ + +#include <gtkmm.h> + +/* XXX g++ 2.95 can't compile this as pair of member function templates */ + +template<typename T> gint idle_delete (T *obj) { delete obj; return FALSE; } +template<typename T> void delete_when_idle (T *obj) { + Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (idle_delete<T>), obj)); +} +template<typename T> gint delete_on_unmap (GdkEventAny *ignored, T *obj) { + Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (idle_delete<T>), obj)); + return FALSE; +} + +#endif /* __ardour_gtk_doi_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h new file mode 100644 index 0000000000..2bf4539d87 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h @@ -0,0 +1,92 @@ +/* + Copyright (C) 2003 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_fastmeter_h__ +#define __gtkmm2ext_fastmeter_h__ + +#include <gtkmm/drawingarea.h> +#include <gdkmm/pixbuf.h> + +namespace Gtkmm2ext { + +class FastMeter : public Gtk::DrawingArea { + public: + enum Orientation { + Horizontal, + Vertical + }; + + FastMeter (long hold_cnt, unsigned long width, Orientation, int len=0, int clrb0=0x00ff00, int clr1=0xffff00, int clr2=0xffaa00, int clr3=0xff0000); + virtual ~FastMeter (); + + void set (float level); + void clear (); + + float get_level() { return current_level; } + float get_user_level() { return current_user_level; } + float get_peak() { return current_peak; } + + long hold_count() { return hold_cnt; } + void set_hold_count (long); + + protected: + bool on_expose_event (GdkEventExpose*); + void on_size_request (GtkRequisition*); + void on_size_allocate (Gtk::Allocation&); + + private: + + Glib::RefPtr<Gdk::Pixbuf> pixbuf; + gint pixheight; + gint pixwidth; + static int _clr0, _clr1, _clr2, _clr3; + + Orientation orientation; + GdkRectangle pixrect; + GdkRectangle last_peak_rect; + gint request_width; + gint request_height; + unsigned long hold_cnt; + unsigned long hold_state; + float current_level; + float current_peak; + float current_user_level; + + bool vertical_expose (GdkEventExpose*); + bool horizontal_expose (GdkEventExpose*); + void queue_vertical_redraw (const Glib::RefPtr<Gdk::Window>&, float); + void queue_horizontal_redraw (const Glib::RefPtr<Gdk::Window>&, float); + + static Glib::RefPtr<Gdk::Pixbuf> request_vertical_meter(int w, int h); + + static Glib::RefPtr<Gdk::Pixbuf> *v_pixbuf_cache; + static int min_v_pixbuf_size; + static int max_v_pixbuf_size; + + static Glib::RefPtr<Gdk::Pixbuf> request_horizontal_meter(int w, int h); + + static Glib::RefPtr<Gdk::Pixbuf> *h_pixbuf_cache; + static int min_h_pixbuf_size; + static int max_h_pixbuf_size; +}; + + +} /* namespace */ + + #endif /* __gtkmm2ext_fastmeter_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/focus_entry.h b/libs/gtkmm2ext/gtkmm2ext/focus_entry.h new file mode 100644 index 0000000000..3fb57b433d --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/focus_entry.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2000-2007 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_focus_entry_h__ +#define __gtkmm2ext_focus_entry_h__ + +#include <gtkmm/entry.h> + +namespace Gtkmm2ext { + +class FocusEntry : public Gtk::Entry +{ + public: + FocusEntry (); + + protected: + bool on_button_press_event (GdkEventButton*); + bool on_button_release_event (GdkEventButton*); + private: + bool next_release_selects; +}; + +} + +#endif /* __gtkmm2ext_focus_entry_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/grouped_buttons.h b/libs/gtkmm2ext/gtkmm2ext/grouped_buttons.h new file mode 100644 index 0000000000..99d9f8ffc4 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/grouped_buttons.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2001 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_grouped_buttons_h__ +#define __gtkmm2ext_grouped_buttons_h__ + +#include <stdint.h> + +#include <vector> +#include <sigc++/signal.h> + +namespace Gtk { + class ToggleButton; +}; + +class GroupedButtons : public sigc::trackable +{ + public: + GroupedButtons (uint32_t nbuttons, uint32_t first_active); + GroupedButtons (std::vector<Gtk::ToggleButton *>&); + + Gtk::ToggleButton& button (uint32_t which) { + return *buttons[which]; + } + + private: + std::vector<Gtk::ToggleButton *> buttons; + uint32_t current_active; + void one_clicked (uint32_t which); +}; + +#endif /* __gtkmm2ext_grouped_buttons_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h b/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h new file mode 100644 index 0000000000..0c2ff0d798 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h @@ -0,0 +1,177 @@ +/* + Copyright (C) 1999 Paul Barton-Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __pbd_gtk_ui_h__ +#define __pbd_gtk_ui_h__ + +#include <string> +#include <queue> +#include <map> + +#include <stdint.h> +#include <setjmp.h> +#include <pthread.h> +#include <gtkmm/widget.h> +#include <gtkmm/style.h> +#include <gtkmm/textbuffer.h> +#include <gtkmm/main.h> +#include <gtkmm/tooltips.h> +#include <gdkmm/color.h> +#include <pbd/abstract_ui.h> +#include <pbd/ringbufferNPT.h> + +#include <pbd/pool.h> +#include <pbd/error.h> +#include <pbd/receiver.h> + +using std::string; +using std::queue; + +class Touchable; + +namespace Gtkmm2ext { + +class TextViewer; + +extern BaseUI::RequestType ErrorMessage; +extern BaseUI::RequestType Quit; +extern BaseUI::RequestType CallSlot; +extern BaseUI::RequestType TouchDisplay; +extern BaseUI::RequestType StateChange; +extern BaseUI::RequestType SetTip; +extern BaseUI::RequestType AddIdle; +extern BaseUI::RequestType AddTimeout; + +struct UIRequest : public BaseUI::BaseRequestObject { + + /* this once used anonymous unions to merge elements + that are never part of the same request. that makes + the creation of a legal copy constructor difficult + because of the semantics of the slot member. + */ + + Touchable *display; + const char *msg; + Gtk::StateType new_state; + int (*function)(void *); + Gtk::Widget *widget; + Transmitter::Channel chn; + void *arg; + const char *msg2; + sigc::slot<void> slot; + + ~UIRequest () { + if (type == ErrorMessage && msg) { + /* msg was strdup()'ed */ + free ((char *)msg); + } + } + }; + +class UI : public Receiver, public AbstractUI<UIRequest> +{ + public: + UI (string name, int *argc, char **argv[]); + virtual ~UI (); + + static UI *instance() { return theGtkUI; } + + /* receiver interface */ + + void receive (Transmitter::Channel, const char *); + + /* Abstract UI interfaces */ + + bool caller_is_ui_thread (); + + static pthread_t thread_id() { return gui_thread; } + + /* Gtk-UI specific interfaces */ + + bool running (); + void quit (); + void kill (); + int load_rcfile (string, bool themechange = false); + void run (Receiver &old_receiver); + + void set_state (Gtk::Widget *w, Gtk::StateType state); + void popup_error (const char *text); + void flush_pending (); + void toggle_errors (); + void touch_display (Touchable *); + void set_tip (Gtk::Widget *w, const gchar *tip, const gchar *hlp); + void idle_add (int (*func)(void *), void *arg); + + template<class T> static bool idle_delete (T *obj) { delete obj; return false; } + template<class T> static void delete_when_idle (T *obj) { + Glib::signal_idle().connect (bind (slot (&UI::idle_delete<T>), obj)); + } + + Gdk::Color get_color (const string& prompt, bool& picked, const Gdk::Color *initial = 0); + + /* starting is sent just before we enter the main loop, + stopping just after we return from it (at the top level) + */ + + sigc::signal<void> starting; + sigc::signal<void> stopping; + + sigc::signal<void> theme_changed; + + static bool just_hide_it (GdkEventAny *, Gtk::Window *); + + static pthread_t the_gui_thread() { return gui_thread; } + + protected: + virtual void handle_fatal (const char *); + virtual void display_message (const char *prefix, gint prefix_len, + Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, + Glib::RefPtr<Gtk::TextBuffer::Tag> mtag, + const char *msg); + + private: + static UI *theGtkUI; + static pthread_t gui_thread; + bool _active; + Gtk::Main *theMain; + Gtk::Tooltips *tips; + TextViewer *errors; + Glib::RefPtr<Gtk::TextBuffer::Tag> error_ptag; + Glib::RefPtr<Gtk::TextBuffer::Tag> error_mtag; + Glib::RefPtr<Gtk::TextBuffer::Tag> fatal_ptag; + Glib::RefPtr<Gtk::TextBuffer::Tag> fatal_mtag; + Glib::RefPtr<Gtk::TextBuffer::Tag> info_ptag; + Glib::RefPtr<Gtk::TextBuffer::Tag> info_mtag; + Glib::RefPtr<Gtk::TextBuffer::Tag> warning_ptag; + Glib::RefPtr<Gtk::TextBuffer::Tag> warning_mtag; + + static void signal_pipe_callback (void *, gint, GdkInputCondition); + void process_error_message (Transmitter::Channel, const char *); + void do_quit (); + + void color_selection_done (bool status); + bool color_selection_deleted (GdkEventAny *); + bool color_picked; + + void do_request (UIRequest*); +}; + +} /* namespace */ + +#endif /* __pbd_gtk_ui_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/gtkutils.h b/libs/gtkmm2ext/gtkmm2ext/gtkutils.h new file mode 100644 index 0000000000..832423f31d --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/gtkutils.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 1998-99 Paul Barton-Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkutils_h__ +#define __gtkutils_h__ + +#include <string> + +namespace Gtk { + class Widget; +} + +void gtk_set_size_request_to_display_given_text (Gtk::Widget& w, + const std::string& text, + gint hpadding = 0, + gint vpadding = 0); +#endif /* __gtkutils_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/hexentry.h b/libs/gtkmm2ext/gtkmm2ext/hexentry.h new file mode 100644 index 0000000000..410f54274e --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/hexentry.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 1999 Paul Barton-Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_hexentry_h__ +#define __gtkmm2ext_hexentry_h__ + +#include <gtkmm.h> + +namespace Gtkmm2ext { + +class HexEntry : public Gtk::Entry + +{ + public: + /* Take a byte-level representation of a series of hexadecimal + values and use them to set the displayed text of the entry. + Eg. if hexbuf[0] = 0xff and hexbuf[1] = 0xa1 and buflen = 2, + then the text will be set to "ff a1". + */ + + void set_hex (unsigned char *hexbuf, unsigned int buflen); + + /* puts byte-level representation of current entry text + into hexbuf, and returns number of bytes written there. + + NOTE: this will release the existing memory pointed to + by hexbuf if buflen indicates that it is not long enough + to hold the new representation, and hexbuf is not zero. + + If the returned length is zero, the contents of hexbuf + are undefined. + */ + + unsigned int get_hex (unsigned char *hexbuf, size_t buflen); + + private: + bool on_key_press_event (GdkEventKey *); +}; + +} /* namespace */ + +#endif /* __gtkmm2ext_hexentry_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/idle_adjustment.h b/libs/gtkmm2ext/gtkmm2ext/idle_adjustment.h new file mode 100644 index 0000000000..d8bda35cb5 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/idle_adjustment.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2000-2007 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_idle_adjustment_h__ +#define __gtkmm2ext_idle_adjustment_h__ + +#include <sys/time.h> +#include <gtkmm/adjustment.h> + +namespace Gtkmm2ext { + +class IdleAdjustment : public sigc::trackable +{ + public: + IdleAdjustment (Gtk::Adjustment& adj); + ~IdleAdjustment (); + + sigc::signal<void> value_changed; + + private: + void underlying_adjustment_value_changed(); + struct timeval last_vc; + gint timeout_handler(); + bool timeout_queued; +}; + +} + +#endif /* __gtkmm2ext_idle_adjustment_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/pathlist.h b/libs/gtkmm2ext/gtkmm2ext/pathlist.h new file mode 100644 index 0000000000..f4a5973d5a --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/pathlist.h @@ -0,0 +1,63 @@ +/* + Copyright (C) 2006 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_pathlist_h__ +#define __gtkmm2ext_pathlist_h__ + +#include <vector> +#include <string> + +#include <gtkmm.h> + +namespace Gtkmm2ext { + +class PathList : public Gtk::VBox +{ + public: + PathList (); + ~PathList () {}; + + std::vector<std::string> get_paths (); + void set_paths (std::vector<std::string> paths); + + sigc::signal<void> PathsUpdated; + + protected: + Gtk::Button add_btn; + Gtk::Button subtract_btn; + + void add_btn_clicked (); + void subtract_btn_clicked (); + + private: + struct PathColumns : public Gtk::TreeModel::ColumnRecord { + PathColumns() { add (paths); } + Gtk::TreeModelColumn<std::string> paths; + }; + PathColumns path_columns; + + Glib::RefPtr<Gtk::ListStore> _store; + Gtk::TreeView _view; + + void selection_changed (); +}; + +} // namespace Gtkmm2ext + +#endif // __gtkmm2ext_pathlist_h__ diff --git a/libs/gtkmm2ext/gtkmm2ext/pixfader.h b/libs/gtkmm2ext/gtkmm2ext/pixfader.h new file mode 100644 index 0000000000..519e1c9e1e --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/pixfader.h @@ -0,0 +1,78 @@ +/* + Copyright (C) 2006 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_pixfader_h__ +#define __gtkmm2ext_pixfader_h__ + +#include <cmath> + +#include <gtkmm/drawingarea.h> +#include <gtkmm/adjustment.h> +#include <gdkmm/pixbuf.h> + +namespace Gtkmm2ext { + +class PixFader : public Gtk::DrawingArea { + public: + PixFader (Glib::RefPtr<Gdk::Pixbuf> belt_image, Gtk::Adjustment& adjustment, int orientation); + virtual ~PixFader (); + + protected: + Gtk::Adjustment& adjustment; + + void on_size_request (GtkRequisition*); + + bool on_expose_event (GdkEventExpose*); + bool on_button_press_event (GdkEventButton*); + bool on_button_release_event (GdkEventButton*); + bool on_motion_notify_event (GdkEventMotion*); + bool on_scroll_event (GdkEventScroll* ev); + + enum Orientation { + VERT=1, + HORIZ=2, + }; + + private: + Glib::RefPtr<Gdk::Pixbuf> pixbuf; + int span, girth; + int _orien; + + GdkRectangle view; + + GdkWindow* grab_window; + double grab_loc; + double grab_start; + int last_drawn; + bool dragging; + float default_value; + int unity_loc; + + void adjustment_changed (); + + int display_span (); + + static int fine_scale_modifier; + static int extra_fine_scale_modifier; +}; + + +} /* namespace */ + + #endif /* __gtkmm2ext_pixfader_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/pixscroller.h b/libs/gtkmm2ext/gtkmm2ext/pixscroller.h new file mode 100644 index 0000000000..ea33359a25 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/pixscroller.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2000-2007 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_pixscroller_h__ +#define __gtkmm2ext_pixscroller_h__ + +#include <gtkmm/drawingarea.h> +#include <gtkmm/adjustment.h> +#include <gdkmm.h> + +namespace Gtkmm2ext { + +class PixScroller : public Gtk::DrawingArea +{ + public: + PixScroller(Gtk::Adjustment& adjustment, + Glib::RefPtr<Gdk::Pixbuf> slider, + Glib::RefPtr<Gdk::Pixbuf> rail); + + bool on_expose_event (GdkEventExpose*); + bool on_motion_notify_event (GdkEventMotion*); + bool on_button_press_event (GdkEventButton*); + bool on_button_release_event (GdkEventButton*); + bool on_scroll_event (GdkEventScroll*); + void on_size_request (GtkRequisition*); + + protected: + Gtk::Adjustment& adj; + + private: + Glib::RefPtr<Gdk::Pixbuf> rail; + Glib::RefPtr<Gdk::Pixbuf> slider; + Gdk::Rectangle sliderrect; + Gdk::Rectangle railrect; + GdkWindow* grab_window; + double grab_y; + double grab_start; + int overall_height; + bool dragging; + + float default_value; + + void adjustment_changed (); +}; + +} // namespace + +#endif /* __gtkmm2ext_pixscroller_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/popup.h b/libs/gtkmm2ext/gtkmm2ext/popup.h new file mode 100644 index 0000000000..1db357341d --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/popup.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 1998-99 Paul Barton-Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __qui_popup_h__ +#define __qui_popup_h__ + +#include <string> +#include <gtkmm.h> + +#include <pbd/touchable.h> + +namespace Gtkmm2ext { + +class PopUp : public Gtk::Window, public Touchable +{ + public: + PopUp (Gtk::WindowPosition pos, unsigned int show_for_msecs = 0, + bool delete_on_hide = false); + virtual ~PopUp (); + void touch (); + void remove (); + void set_text (std::string); + void set_name (std::string); + gint button_click (GdkEventButton *); + + bool on_delete_event (GdkEventAny* ); + + protected: + void on_realize (); + + private: + Gtk::Label label; + std::string my_text; + gint timeout; + static gint remove_prompt_timeout (void *); + bool delete_on_hide; + unsigned int popdown_time; + +}; + +} /* namespace */ + +#endif // __qui_popup_h__ diff --git a/libs/gtkmm2ext/gtkmm2ext/prompter.h b/libs/gtkmm2ext/gtkmm2ext/prompter.h new file mode 100644 index 0000000000..5f71463288 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/prompter.h @@ -0,0 +1,72 @@ +/* + Copyright (C) 1999 Paul Barton-Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_prompter_h__ +#define __gtkmm2ext_prompter_h__ + +#include <string> +#include <gtkmm/box.h> +#include <gtkmm/entry.h> +#include <gtkmm/label.h> +#include <gtkmm/dialog.h> +#include <sigc++/sigc++.h> + +namespace Gtk { + class Window; +} + +namespace Gtkmm2ext { + +class Prompter : public Gtk::Dialog + +{ + public: + Prompter (bool modal = false); + Prompter (Gtk::Window& parent, bool modal = false); + ~Prompter () {}; + + void set_prompt (std::string prompt) { + entryLabel.set_label (prompt); + } + + void set_initial_text (std::string txt) { + entry.set_text (txt); + entry.select_region (0, entry.get_text_length()); + } + + void change_labels (std::string ok, std::string cancel); + + void get_result (std::string &str, bool strip=true); + + protected: + Gtk::Entry& the_entry() { return entry; } + + void on_entry_changed (); + + private: + Gtk::Entry entry; + Gtk::HBox entryBox; + Gtk::Label entryLabel; + + void init (); +}; + +} /* namespace */ + +#endif /* __gtkmm2ext_prompter_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/scroomer.h b/libs/gtkmm2ext/gtkmm2ext/scroomer.h new file mode 100644 index 0000000000..d4f2ce6aa3 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/scroomer.h @@ -0,0 +1,88 @@ +/* + Copyright (C) 2008 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_scroomer_h__ +#define __gtkmm2ext_scroomer_h__ + +#include <gtkmm/drawingarea.h> +#include <gtkmm/adjustment.h> +#include <gdkmm.h> + +namespace Gtkmm2ext { + +class Scroomer : public Gtk::DrawingArea +{ +public: + enum Component { + TopBase = 0, + Handle1 = 1, + Slider = 2, + Handle2 = 3, + BottomBase = 4, + Total = 5, + None = 6 + }; + + Scroomer(Gtk::Adjustment& adjustment); + ~Scroomer(); + + bool on_motion_notify_event (GdkEventMotion*); + bool on_button_press_event (GdkEventButton*); + bool on_button_release_event (GdkEventButton*); + bool on_scroll_event (GdkEventScroll*); + virtual void on_size_allocate (Gtk::Allocation&); + + void set_comp_rect(GdkRectangle&, Component) const; + + Component point_in(double point) const; + + void set_min_page_size(double page_size); + int get_handle_size() { return handle_size; } + + inline int position_of(Component comp) { return position[comp]; } + + // debug + std::string get_comp_name(Component); + +protected: + Gtk::Adjustment& adj; + +private: + struct UpdateRect { + GdkRectangle rect; + Component first_comp; + }; + + void update(); + void adjustment_changed (); + + int position[6]; + int old_pos[6]; + int handle_size; + double min_page_size; + GdkWindow* grab_window; + Component grab_comp; + double grab_y; + double unzoomed_val; + double unzoomed_page; +}; + +} // namespace + +#endif /* __gtkmm2ext_scroomer_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/selector.h b/libs/gtkmm2ext/gtkmm2ext/selector.h new file mode 100644 index 0000000000..841742db03 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/selector.h @@ -0,0 +1,110 @@ +/* + Copyright (C) 1999 Paul Barton-Davis + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkselector_h__ +#define __gtkselector_h__ + +#include <string> +#include <vector> + +#include <gtkmm.h> + +namespace Gtkmm2ext { + +class TreeView_Selector : public Gtk::TreeView +{ +public: + TreeView_Selector() {} + virtual ~TreeView_Selector() {} + +protected: + virtual bool on_button_press_event(GdkEventButton *ev); +}; + +typedef void (SelectorRefillFunction)(Glib::RefPtr<Gtk::ListStore>, void *); + +class Selector : public Gtk::VBox +{ + friend class Gtkmm2ext::TreeView_Selector; + +public: + Selector (SelectorRefillFunction, void *arg, + std::vector<std::string> titles); + + virtual ~Selector (); + Glib::RefPtr<Gtk::ListStore> liststore () { return lstore; } + void reset (void (*refiller)(Glib::RefPtr<Gtk::ListStore>, void *), void *arg); + void set_size (unsigned int w, unsigned int h) { + scroll.set_size_request (w, h); + tview.columns_autosize (); + } + + struct Result { + Gtk::TreeView& view; + Glib::RefPtr<Gtk::TreeSelection> selection; + + Result (Gtk::TreeView& v, Glib::RefPtr<Gtk::TreeSelection> sel) + : view (v), selection (sel) {} + }; + + /* selection is activated via a double click, choice via + a single click. + */ + sigc::signal<void,Result*> selection_made; + sigc::signal<void,Result*> choice_made; + sigc::signal<void,Result*> shift_made; + sigc::signal<void,Result*> control_made; + + sigc::signal<void> update_contents; + + void accept(); + void cancel(); + void rescan(); + + + protected: + virtual void on_map (); + virtual void on_show (); + + private: + Gtk::ScrolledWindow scroll; + Gtk::TreeModel::ColumnRecord column_records; + Glib::RefPtr<Gtk::ListStore> lstore; + Gtkmm2ext::TreeView_Selector tview; + void (*refiller)(Glib::RefPtr<Gtk::ListStore>, void *); + void *refill_arg; + gint selected_row; + gint selected_column; + gint chosen_row; + gint chosen_column; + + void refill (); + void chosen (); + void shift_clicked (); + void control_clicked (); + + static gint _accept (gpointer); + static gint _chosen (gpointer); + static gint _shift_clicked (gpointer); + static gint _control_clicked (gpointer); + +}; + +} /* namespace */ + +#endif // __gtkselector_h__ diff --git a/libs/gtkmm2ext/gtkmm2ext/slider_controller.h b/libs/gtkmm2ext/gtkmm2ext/slider_controller.h new file mode 100644 index 0000000000..60c8eef660 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/slider_controller.h @@ -0,0 +1,83 @@ +/* + Copyright (C) 1998-2006 Paul Davis + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_slider_controller_h__ +#define __gtkmm2ext_slider_controller_h__ + +#include <gtkmm.h> +#include <gtkmm2ext/popup.h> +#include <gtkmm2ext/pixfader.h> +#include <gtkmm2ext/binding_proxy.h> + +namespace Gtkmm2ext { + class Pix; +} + +namespace PBD { + class Controllable; +} + +namespace Gtkmm2ext { + +class SliderController : public Gtkmm2ext::PixFader +{ + public: + SliderController (Glib::RefPtr<Gdk::Pixbuf> image, + Gtk::Adjustment* adj, int orientation, + PBD::Controllable&, + bool with_numeric = true); + + virtual ~SliderController () {} + + void set_value (float); + + Gtk::SpinButton& get_spin_button () { return spin; } + + bool on_button_press_event (GdkEventButton *ev); + + protected: + BindingProxy binding_proxy; + Glib::RefPtr<Gdk::Pixbuf> slider; + Glib::RefPtr<Gdk::Pixbuf> rail; + Gtk::SpinButton spin; + Gtk::Frame spin_frame; + Gtk::HBox spin_hbox; +}; + +class VSliderController : public SliderController +{ + public: + VSliderController (Glib::RefPtr<Gdk::Pixbuf> image, + Gtk::Adjustment *adj, + PBD::Controllable&, + bool with_numeric = true); +}; + +class HSliderController : public SliderController +{ + public: + HSliderController (Glib::RefPtr<Gdk::Pixbuf> image, + Gtk::Adjustment *adj, + PBD::Controllable&, + bool with_numeric = true); +}; + + +}; /* namespace */ + +#endif // __gtkmm2ext_slider_controller_h__ diff --git a/libs/gtkmm2ext/gtkmm2ext/stateful_button.h b/libs/gtkmm2ext/gtkmm2ext/stateful_button.h new file mode 100644 index 0000000000..c86402e54e --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/stateful_button.h @@ -0,0 +1,83 @@ +/* + Copyright (C) 2005 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __pbd_gtkmm_abutton_h__ +#define __pbd_gtkmm_abutton_h__ + +#include <vector> + +#include <gtkmm/togglebutton.h> + +namespace Gtkmm2ext { + +class StateButton +{ + public: + StateButton(); + virtual ~StateButton() {} + + void set_visual_state (int); + int get_visual_state () { return visual_state; } + void set_self_managed (bool yn) { _self_managed = yn; } + + protected: + int visual_state; + bool _self_managed; + bool _is_realized; + + virtual std::string get_widget_name() const = 0; + virtual void set_widget_name (std::string) = 0; + virtual int get_widget_state() = 0; +}; + + +class StatefulToggleButton : public StateButton, public Gtk::ToggleButton +{ + public: + StatefulToggleButton() {} + explicit StatefulToggleButton(const std::string &label) : Gtk::ToggleButton (label) {} + ~StatefulToggleButton() {} + + protected: + void on_realize (); + void on_toggled (); + + std::string get_widget_name() const { return get_name(); } + void set_widget_name (std::string name) { set_name (name); get_child()->set_name (name); } + int get_widget_state() { return get_state(); } +}; + +class StatefulButton : public StateButton, public Gtk::Button +{ + public: + StatefulButton() {} + explicit StatefulButton(const std::string &label) : Gtk::Button (label) {} + virtual ~StatefulButton() {} + + protected: + void on_realize (); + + std::string get_widget_name() const { return get_name(); } + void set_widget_name (std::string name) { set_name (name); get_child()->set_name (name); } + int get_widget_state() { return get_state(); } +}; + +}; + +#endif diff --git a/libs/gtkmm2ext/gtkmm2ext/stop_signal.h b/libs/gtkmm2ext/gtkmm2ext/stop_signal.h new file mode 100644 index 0000000000..cb8dedca12 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/stop_signal.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2000-2007 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __ardour_gtk_stop_signal_h__ +#define __ardour_gtk_stop_signal_h__ + +#include <gtkmm.h> +#include <gtk/gtksignal.h> + +static inline gint +stop_signal (Gtk::Widget& widget, const char *signal_name) +{ + gtk_signal_emit_stop_by_name (GTK_OBJECT(widget.gobj()), signal_name); + return TRUE; +} + +#endif /* __ardour_gtk_stop_signal_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/sync-menu.h b/libs/gtkmm2ext/gtkmm2ext/sync-menu.h new file mode 100644 index 0000000000..2be5e71d02 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/sync-menu.h @@ -0,0 +1,44 @@ +/* GTK+ Integration for the Mac OS X Menubar. + * + * Copyright (C) 2007 Pioneer Research Center USA, Inc. + * Copyright (C) 2007 Imendio AB + * + * For further information, see: + * http://developer.imendio.com/projects/gtk-macosx/menubar + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __IGE_MAC_MENU_H__ +#define __IGE_MAC_MENU_H__ + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +typedef struct _IgeMacMenuGroup IgeMacMenuGroup; + +void ige_mac_menu_set_menu_bar (GtkMenuShell *menu_shell); +void ige_mac_menu_set_quit_menu_item (GtkMenuItem *menu_item); + +IgeMacMenuGroup * ige_mac_menu_add_app_menu_group (void); +void ige_mac_menu_add_app_menu_item (IgeMacMenuGroup *group, + GtkMenuItem *menu_item, + const gchar *label); + +G_END_DECLS + +#endif /* __IGE_MAC_MENU_H__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/tearoff.h b/libs/gtkmm2ext/gtkmm2ext/tearoff.h new file mode 100644 index 0000000000..5e80892b98 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/tearoff.h @@ -0,0 +1,70 @@ +/* + Copyright (C) 2003 Paul Barton-Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_tearoff_h__ +#define __gtkmm2ext_tearoff_h__ + +#include <gtkmm/window.h> +#include <gtkmm/arrow.h> +#include <gtkmm/box.h> +#include <gtkmm/eventbox.h> + +namespace Gtkmm2ext { + +class TearOff : public Gtk::HBox +{ + public: + TearOff (Gtk::Widget& contents, bool allow_resize = false); + virtual ~TearOff (); + + void set_visible (bool yn); + + sigc::signal<void> Detach; + sigc::signal<void> Attach; + sigc::signal<void> Visible; + sigc::signal<void> Hidden; + + Gtk::Window& tearoff_window() { return own_window; } + bool torn_off() const; + + private: + Gtk::Widget& contents; + Gtk::Window own_window; + Gtk::Arrow tearoff_arrow; + Gtk::Arrow close_arrow; + Gtk::HBox window_box; + Gtk::EventBox tearoff_event_box; + Gtk::EventBox close_event_box; + double drag_x; + double drag_y; + bool dragging; + bool _visible; + + gint tearoff_click (GdkEventButton*); + gint close_click (GdkEventButton*); + + gint window_motion (GdkEventMotion*); + gint window_button_press (GdkEventButton*); + gint window_button_release (GdkEventButton*); + gint window_delete_event (GdkEventAny*); +}; + +} /* namespace */ + +#endif // __gtkmm2ext_tearoff_h__ diff --git a/libs/gtkmm2ext/gtkmm2ext/textviewer.h b/libs/gtkmm2ext/gtkmm2ext/textviewer.h new file mode 100644 index 0000000000..9cc639cd75 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/textviewer.h @@ -0,0 +1,57 @@ +/* + Copyright (C) 1999 Paul Barton-Davis + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __pbd_gtkmm_textviewer_h__ +#define __pbd_gtkmm_textviewer_h__ + +#include <string> +#include <gtkmm.h> + +#include <pbd/transmitter.h> + +using std::string; + +namespace Gtkmm2ext { + +class TextViewer : public Gtk::Window, public Transmitter +{ + Gtk::TextView etext; + Gtk::VBox vbox1; + Gtk::VBox vbox2; + Gtk::ScrolledWindow scrollwin; + Gtk::Button dismiss; + bool _editable; + + void toggle_edit (); + void toggle_word_wrap (); + void signal_released_handler (); + + public: + TextViewer (size_t width, size_t height); + Gtk::TextView& text() { return etext; } + Gtk::Button& dismiss_button() { return dismiss; } + + void insert_file (const string &); + void scroll_to_bottom (); + + void deliver (); +}; + +} /* namespace */ + +#endif // __pbd_gtkmm_textviewer_h__ diff --git a/libs/gtkmm2ext/gtkmm2ext/utils.h b/libs/gtkmm2ext/gtkmm2ext/utils.h new file mode 100644 index 0000000000..ca1b88abba --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/utils.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 1999 Paul Barton-Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_utils_h__ +#define __gtkmm2ext_utils_h__ + +#include <vector> +#include <string> + +#include <gtkmm/treeview.h> +#include <gdkmm/window.h> /* for WMDecoration */ + +namespace Gtk { + class ComboBoxText; + class Widget; + class Window; + class Paned; +} + +namespace Gtkmm2ext { + void init (); + + void get_ink_pixel_size (Glib::RefPtr<Pango::Layout>, int& width, int& height); + + void set_size_request_to_display_given_text (Gtk::Widget &w, + const gchar *text, + gint hpadding, + gint vpadding); + + void set_popdown_strings (Gtk::ComboBoxText&, const std::vector<std::string>&); + + template<class T> void deferred_delete (void *ptr) { + delete static_cast<T *> (ptr); + } + + GdkWindow* get_paned_handle (Gtk::Paned& paned); + void set_decoration (Gtk::Window* win, Gdk::WMDecoration decor); + void set_treeview_header_as_default_label(Gtk::TreeViewColumn *c); + Glib::RefPtr<Gdk::Drawable> get_bogus_drawable(); +}; + +#endif /* __gtkmm2ext_utils_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/window_title.h b/libs/gtkmm2ext/gtkmm2ext/window_title.h new file mode 100644 index 0000000000..93b47d9d45 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/window_title.h @@ -0,0 +1,63 @@ +/* + Copyright (C) 2000-2007 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef WINDOW_TITLE_INCLUDED +#define WINDOW_TITLE_INCLUDED + +#include <string> + +namespace Gtkmm2ext { + +using std::string; + +/** + * \class The WindowTitle class can be used to maintain the + * consistancy of window titles between windows and dialogs. + * + * Each string element that is added to the window title will + * be separated by a hyphen. + */ +class WindowTitle +{ +public: + + /** + * \param title The first string/element of the window title + * which will may be the application name or the document + * name in a document based application. + */ + WindowTitle(const string& title); + + /** + * Add an string element to the window title. + */ + void operator+= (const string&); + + /// @return The window title string. + const string& get_string () { return m_title;} + +private: + + string m_title; + +}; + +} // Gtkmm2ext + +#endif // WINDOW_TITLE_INCLUDED |