/* stuff for the verbose canvas cursor */
- string fontname = get_font_for_style (N_("VerboseCanvasCursor"));
+ Pango::FontDescription font = get_font_for_style (N_("VerboseCanvasCursor"));
verbose_canvas_cursor = gnome_canvas_item_new (gnome_canvas_root(GNOME_CANVAS(track_gnome_canvas)),
- gnome_canvas_text_get_type(),
- "font", fontname.c_str(),
- "anchor", GTK_ANCHOR_NW,
- "fill_color_rgba", color_map[cVerboseCanvasCursor],
- NULL);
+ gnome_canvas_text_get_type(),
+ "font-desc", fontname,
+ "anchor", GTK_ANCHOR_NW,
+ "fill_color_rgba", color_map[cVerboseCanvasCursor],
+ NULL);
verbose_cursor_visible = false;
/* a group to hold time (measure) lines */
if (session == 0 && !ARDOUR_UI::instance()->will_create_new_session_automatically()) {
- string fontname = get_font_for_style (N_("FirstActionMessage"));
+ Pango::FontDescription font = get_font_for_style (N_("FirstActionMessage"));
const char *txt1 = _("Start a new session\n");
const char *txt2 = _("via Session menu");
compute width, and multiply the height by 2.
*/
- gint width;
- gint lbearing;
- gint rbearing;
- gint ascent;
- gint descent;
+ int pixel_height;
+ int pixel_width;
/* this is a dummy widget that exists so that we can get the
style from the RC file.
*/
Label foo (_(txt2));
+ Glib::RefPtr<Pango::Layout> layout;
foo.set_name ("NoSessionMessage");
foo.ensure_style ();
- gdk_string_extents (foo.get_style()->get_font(),
- _(txt2),
- &lbearing,
- &rbearing,
- &width,
- &ascent,
- &descent);
+ layout = foo.create_pango_layout (_(txt2));
+ layout->set_font_description (font);
+ layout->get_pixel_size (pixel_width, pixel_height);
if (first_action_message == 0) {
strcat (txt, _(txt2));
first_action_message = gnome_canvas_item_new (gnome_canvas_root(GNOME_CANVAS(track_gnome_canvas)),
- gnome_canvas_text_get_type(),
- "font", fontname.c_str(),
- "fill_color_rgba", color_map[cFirstActionMessage],
- "x", (gdouble) (canvas_width - width) / 2.0,
- "y", (gdouble) (canvas_height/2.0) - (2.0 * (ascent+descent)),
- "anchor", GTK_ANCHOR_NORTH_WEST,
- "text", txt,
- NULL);
+ gnome_canvas_text_get_type(),
+ "fontdesc", font,
+ "fill_color_rgba", color_map[cFirstActionMessage],
+ "x", (gdouble) (canvas_width - pixel_width) / 2.0,
+ "y", (gdouble) (canvas_height/2.0) - (2.0 * (pixel_height)),
+ "anchor", GTK_ANCHOR_NORTH_WEST,
+ "text", txt,
+ NULL);
} else {
/* center it */
gnome_canvas_item_set (first_action_message,
- "x", (gdouble) (canvas_width - width) / 2.0,
- "y", (gdouble) (canvas_height/2.0) - (2.0 * (ascent+descent)),
+ "x", (gdouble) (canvas_width - pixel_width) / 2.0,
+ "y", (gdouble) (canvas_height/2.0) - (2.0 * (pixel_height)),
NULL);
}
}
"outline_color", "black",
NULL);
- string fontname = get_font_for_style (N_("MarkerText"));
+ Pango::FontDescription font = get_font_for_style (N_("MarkerText"));
text = gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
- gnome_canvas_text_get_type (),
- "text", annotation.c_str(),
- "x", label_offset,
- "y", 0.0,
- "font", fontname.c_str(),
- "anchor", GTK_ANCHOR_NW,
- "fill_color", "black",
- NULL);
+ gnome_canvas_text_get_type (),
+ "text", annotation.c_str(),
+ "x", label_offset,
+ "y", 0.0,
+ "fontdesc", font,
+ "anchor", GTK_ANCHOR_NW,
+ "fill_color", "black",
+ NULL);
gtk_object_set_data (GTK_OBJECT(group), "marker", this);
gtk_signal_connect (GTK_OBJECT(group), "event", (GtkSignalFunc) callback, &editor);
//------------------------------------------------------------------------------
/** Initialize static memeber data */
-std::string TimeAxisViewItem::NAME_FONT;
+Pango::FontDescription TimeAxisViewItem::NAME_FONT;
+bool TimeAxisViewItem::have_name_font = false;
const double TimeAxisViewItem::NAME_X_OFFSET = 15.0;
const double TimeAxisViewItem::NAME_Y_OFFSET = 15.0 ; /* XXX depends a lot on the font size, sigh. */
const double TimeAxisViewItem::NAME_HIGHLIGHT_SIZE = 15.0 ; /* ditto */
Visibility visibility)
: trackview (tv)
{
- if (NAME_FONT.empty()) {
+ if (!have_name_font) {
NAME_FONT = get_font_for_style (N_("TimeAxisViewItemName"));
+ have_name_font = true;
}
item_name = it_name ;
bool name_active() const { return name_connected; }
// Default sizes, font and spacing
- static std::string NAME_FONT ;
+ static Pango::FontDescription NAME_FONT ;
+ static bool have_name_font;
static const double NAME_X_OFFSET ;
static const double NAME_Y_OFFSET ;
static const double NAME_HIGHLIGHT_SIZE ;
#include <gtkmm/combo.h>
#include <gtkmm/label.h>
#include <gtkmm/paned.h>
+#include <gtkmm/action.h>
+#include <gtkmm/actiongroup.h>
+#include <gtkmm/accelgroup.h>
+#include <gtkmm/accelmap.h>
#include <gtk/gtkpaned.h>
#include <gtkmm2ext/utils.h>
using namespace std;
using namespace Gtk;
+using namespace sigc;
string
short_version (string orig, string::size_type target_length)
}
string
-fit_to_pixels (string str, int32_t pixel_width, Gdk_Font& font)
+fit_to_pixels (string str, int pixel_width, string font)
{
- gint width;
- gint lbearing;
- gint rbearing;
- gint ascent;
- gint descent;
-
+ Label foo;
+ int width;
+ int height;
+ Pango::FontDescription fontdesc (font);
+
int namelen = str.length();
char cstr[namelen+1];
strcpy (cstr, str.c_str());
while (namelen) {
-
- gdk_string_extents (font,
- cstr,
- &lbearing,
- &rbearing,
- &width,
- &ascent,
- &descent);
+ Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout (cstr);
+
+ layout->set_font_description (fontdesc);
+ layout->get_pixel_size (width, height);
if (width < (pixel_width)) {
break;
}
}
-string
+Pango::FontDescription
get_font_for_style (string widgetname)
{
Gtk::Label foobar;
+ Glib::RefPtr<Style> style;
foobar.set_name (widgetname);
foobar.ensure_style();
- if (foobar.get_style() == 0 || foobar.get_style()->gobj()->rc_style == 0 || foobar.get_style()->gobj()->rc_style->font_name == 0) {
- return "fixed";
- }
-
- string str = foobar.get_style()->gobj()->rc_style->font_name;
-
- if (str.empty()) {
- return "fixed"; // standard X Window fallback font
- } else {
- return str;
- }
+ style = foobar.get_style ();
+ return style->get_font();
}
+
gint
pane_handler (GdkEventButton* ev, Gtk::Paned* pane)
{
gint pos;
gint cmp;
-
- pos = Gtkmm2ext::gtk_paned_get_position (pane->gobj());
+
+ pos = pane->get_position ();
if (dynamic_cast<VPaned*>(pane)) {
cmp = pane->get_height();
void
decorate (Gtk::Window& w, Gdk::WMDecoration d)
{
- w.get_window().set_decorations (d);
+ w.get_window()->set_decorations (d);
+}
+
+Glib::RefPtr<Action>
+register_action (Glib::RefPtr<ActionGroup> group, string name, string label, slot<void> sl, guint key, Gdk::ModifierType mods)
+{
+ Glib::RefPtr<Action> act;
+
+ act = Action::create (name, label);
+ group->add (act, sl);
+ AccelMap::add_entry (act->get_accel_path(), key, mods);
+
+ return act;
+}
+
+Glib::RefPtr<Action>
+register_action (Glib::RefPtr<ActionGroup> group, string name, string label, slot<void> sl)
+{
+ Glib::RefPtr<Action> act;
+
+ act = Action::create (name, label);
+ group->add (act, sl);
+
+ return act;
+}
+
+Glib::RefPtr<Action>
+register_action (Glib::RefPtr<ActionGroup> group, string name, string label)
+{
+ Glib::RefPtr<Action> act;
+
+ act = Action::create (name, label);
+ group->add (act);
+
+ return act;
}
}
std::string short_version (std::string, std::string::size_type target_length);
-std::string fit_to_pixels (std::string, int32_t pixel_width, Gdk::Font&);
+std::string fit_to_pixels (std::string, int pixel_width, std::string font);
int atoi (const std::string&);
double atof (const std::string&);
GnomeCanvasPoints* get_canvas_points (std::string who, uint32_t npoints);
int channel_combo_get_channel_count (Gtk::ComboBoxText& combo);
-std::string get_font_for_style (std::string widgetname);
+Pango::FontDescription get_font_for_style (std::string widgetname);
gint pane_handler (GdkEventButton*, Gtk::Paned*);
uint32_t rgba_from_style (std::string style, uint32_t, uint32_t, uint32_t, uint32_t);
+Glib::RefPtr<Gtk::Action> register_action (Glib::RefPtr<Gtk::ActionGroup> group, string name, string label, sigc::slot<void> sl, guint key, Gdk::ModifierType mods);
+Glib::RefPtr<Gtk::Action> register_action (Glib::RefPtr<Gtk::ActionGroup> group, string name, string label, sigc::slot<void> sl);
+Glib::RefPtr<Gtk::Action> register_action (Glib::RefPtr<Gtk::ActionGroup> group, string name, string label);
+
+
#endif /* __ardour_gtk_utils_h__ */
#include <vector>
#include <string>
#include <gtkmm/widget.h>
+#include <gtkmm/paned.h>
#include <gtkmm/comboboxtext.h>
namespace Gtkmm2ext {
template<class T> void deferred_delete (void *ptr) {
delete static_cast<T *> (ptr);
}
-};
-gint do_not_propagate (GdkEventButton*);
+ GdkWindow* get_paned_handle (Gtk::Paned& paned);
+};
#endif /* __gtkmm2ext_utils_h__ */
$Id$
*/
+#include <gtk/gtkpaned.h>
#include <gtkmm2ext/utils.h>
#include <gtkmm2ext/gtkutils.h>
#include <gtkmm/comboboxtext.h>
set_size_request_to_display_given_text(w, text, hpadding, vpadding);
}
-gint
-do_not_propagate (GdkEventButton *ev)
-{
- return TRUE;
-}
-
void
Gtkmm2ext::init ()
{
cr.append_text (*i);
}
}
+
+GdkWindow*
+Gtkmm2ext::get_paned_handle (Gtk::Paned& paned)
+{
+ return GTK_PANED(paned.gobj())->handle;
+}