Beispiel #1
0
Gtk::Widget *
LPESimplify::newWidget()
{
    // use manage here, because after deletion of Effect object, others might still be pointing to this widget.
    Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) );
    
    vbox->set_border_width(5);
    vbox->set_homogeneous(false);
    vbox->set_spacing(2);
    std::vector<Parameter *>::iterator it = param_vector.begin();
    Gtk::HBox * buttons = Gtk::manage(new Gtk::HBox(true,0));
    while (it != param_vector.end()) {
        if ((*it)->widget_is_visible) {
            Parameter * param = *it;
            Gtk::Widget * widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget());
            if (param->param_key == "simplify_individual_paths" ||
                    param->param_key == "simplify_just_coalesce") {
                Glib::ustring * tip = param->param_getTooltip();
                if (widg) {
                    buttons->pack_start(*widg, true, true, 2);
                    if (tip) {
                        widg->set_tooltip_text(*tip);
                    } else {
                        widg->set_tooltip_text("");
                        widg->set_has_tooltip(false);
                    }
                }
            } else {
                Glib::ustring * tip = param->param_getTooltip();
                if (widg) {
                    Gtk::HBox * horizontal_box = dynamic_cast<Gtk::HBox *>(widg);
                    std::vector< Gtk::Widget* > child_list = horizontal_box->get_children();
                    Gtk::Entry* entry_widg = dynamic_cast<Gtk::Entry *>(child_list[1]);
                    entry_widg->set_width_chars(8);
                    vbox->pack_start(*widg, true, true, 2);
                    if (tip) {
                        widg->set_tooltip_text(*tip);
                    } else {
                        widg->set_tooltip_text("");
                        widg->set_has_tooltip(false);
                    }
                }
            }
        }

        ++it;
    }
    vbox->pack_start(*buttons,true, true, 2);
    return dynamic_cast<Gtk::Widget *>(vbox);
}
// A wrapper around set_tooltip_*() for portability across different gtkmm versions.
void app_gtkmm_set_widget_tooltip(Gtk::Widget& widget,
		const Glib::ustring& tooltip_text, bool use_markup)
{
	// set_tooltip_* is available since 2.12
#ifndef APP_GTKMM_OLD_TOOLTIPS
	if (use_markup) {
		widget.set_tooltip_markup(tooltip_text);
	} else {
		widget.set_tooltip_text(tooltip_text);
	}

#else  // use the old tooltips api
	Gtk::Widget* toplevel = widget.get_toplevel();
	if (toplevel && toplevel->is_toplevel()) {  // orphan widgets return themselves, so check toplevelness.
		GtkTooltips* tooltips = static_cast<GtkTooltips*>(toplevel->get_data("window_tooltips"));
		if (tooltips) {
			if (use_markup) {
				// strip markup
				Glib::ustring stripped;
				if (app_pango_strip_markup(tooltip_text, stripped)) {
					gtk_tooltips_set_tip(tooltips, widget.gobj(), stripped.c_str(), "");
				}

			} else {
				gtk_tooltips_set_tip(tooltips, widget.gobj(), tooltip_text.c_str(), "");
			}
		}
	}
#endif
}
//------------------------------------------------------------------------------
void mforms::gtk::ToolBarImpl::set_item_tooltip(mforms::ToolBarItem *item, const std::string &text) {
  Gtk::Widget *w = cast<Gtk::Widget *>(item->get_data_ptr());
  if (w) {
#if GTK_VERSION_GT(2, 10)
    w->set_tooltip_text(text);
#endif
  }
}