along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id$
*/
#include <cstdlib>
using namespace Glib;
using namespace PBD;
+int
+pixel_width (const ustring& str, Pango::FontDescription& font)
+{
+ Label foo;
+ Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout ("");
+
+ layout->set_font_description (font);
+ layout->set_text (str);
+
+ int width, height;
+ Gtkmm2ext::get_ink_pixel_size (layout, width, height);
+ return width;
+}
+
ustring
-fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font, int& actual_width)
+fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses)
{
Label foo;
Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout ("");
-
+ ustring::size_type shorter_by = 0;
+ ustring txt;
+
layout->set_font_description (font);
actual_width = 0;
ustring::iterator last = ustr.end();
--last; /* now points at final entry */
+ txt = ustr;
+
while (!ustr.empty()) {
- layout->set_text (ustr);
+ layout->set_text (txt);
int width, height;
Gtkmm2ext::get_ink_pixel_size (layout, width, height);
}
ustr.erase (last--);
+ shorter_by++;
+
+ if (with_ellipses && shorter_by > 3) {
+ txt = ustr;
+ txt += "...";
+ } else {
+ txt = ustr;
+ }
}
- return ustr;
+ return txt;
}
gint
return 0;
}
- savergb = rgb = (unsigned char*)art_alloc (h * w * 3);
+ savergb = rgb = (unsigned char*) malloc (h * w * 3);
// LOAD XPM COLORMAP LONG ENOUGH TO DO CONVERSION
for (t = 0; t < colors; ++t) {
return 0;
}
- savergb = rgb = (unsigned char*)art_alloc (h * w * 4);
+ savergb = rgb = (unsigned char*) malloc (h * w * 4);
// LOAD XPM COLORMAP LONG ENOUGH TO DO CONVERSION
foobar.ensure_style();
style = foobar.get_style ();
- return style->get_font();
+
+ Glib::RefPtr<const Pango::Layout> layout = foobar.get_layout();
+
+ PangoFontDescription *pfd = (PangoFontDescription *)pango_layout_get_font_description((PangoLayout *)layout->gobj());
+
+ if (!pfd) {
+
+ /* layout inherited its font description from a PangoContext */
+
+ PangoContext* ctxt = (PangoContext*) pango_layout_get_context ((PangoLayout*) layout->gobj());
+ pfd = pango_context_get_font_description (ctxt);
+ return Pango::FontDescription (pfd, true); /* make a copy */
+ }
+
+ return Pango::FontDescription (pfd, true); /* make a copy */
}
uint32_t
r = waverc->fg[state].red / 257;
g = waverc->fg[state].green / 257;
b = waverc->fg[state].blue / 257;
+
/* what a hack ... "a" is for "active" */
if (state == Gtk::STATE_NORMAL && rgba) {
a = waverc->fg[GTK_STATE_ACTIVE].red / 257;
#endif
if (focus) {
- if (GTK_IS_ENTRY(focus)) {
+ if (GTK_IS_ENTRY(focus) || Keyboard::some_magic_widget_has_focus()) {
special_handling_of_unmodified_accelerators = true;
}
}
#ifdef DEBUG_ACCELERATOR_HANDLING
if (debug) {
- cerr << "Key event: code = " << ev->keyval << " state = " << hex << ev->state << dec << " focus is an entry ? "
+ cerr << "Win = " << win << " Key event: code = " << ev->keyval << " state = " << hex << ev->state << dec << " special handling ? "
<< special_handling_of_unmodified_accelerators
<< endl;
}
/* no modifiers, propagate first */
+#ifdef DEBUG_ACCELERATOR_HANDLING
+ if (debug) {
+ cerr << "\tpropagate, then activate\n";
+ }
+#endif
+ if (!gtk_window_propagate_key_event (win, ev)) {
#ifdef DEBUG_ACCELERATOR_HANDLING
if (debug) {
- cerr << "\tactivate, then propagate\n";
+ cerr << "\tpropagation didn't handle, so activate\n";
}
#endif
- if (!gtk_window_propagate_key_event (win, ev)) {
return gtk_window_activate_key (win, ev);
- }
-
+ } else {
+#ifdef DEBUG_ACCELERATOR_HANDLING
+ if (debug) {
+ cerr << "\thandled by propagate\n";
+ }
+#endif
+ return true;
+ }
#ifdef DEBUG_ACCELERATOR_HANDLING
if (debug) {
return false;
}
+
+