普通的widget加入Tooltips
m_label.set_tooltip_text("Another tooltip");
m_button_tooltip_window(Gtk::WINDOW_POPUP)
m_button.set_tooltip_window(m_button_tooltip_window);
m_checkbutton.set_tooltip_markup(markedup_tip);
|
在Gtk::TextView中, 加入对某一部份文本的Tooltips, 以tags为基础。
Gtk::TextIter iter;
std::vector< Glib::RefPtr<Gtk::TextTag> > tags;
//Set up a scrolled window:
m_scrolled_window.add(m_text_view);
m_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
m_vbox.pack_start(m_scrolled_window);
//Create a text buffer with some text:
m_ref_text_buffer = Gtk::TextBuffer::create();
iter = m_ref_text_buffer->end();
m_ref_text_buffer->insert(iter, "Hover over the text ");
//Insert some text with a tag.
//In the tooltip signal handler below, we will show a tooltip
//when mouse pointer is above this tagged text.
m_ref_bold_tag = m_ref_text_buffer->create_tag("bold");
m_ref_bold_tag->set_property("weight", Pango::WEIGHT_BOLD);
tags.push_back(m_ref_bold_tag);
iter = m_ref_text_buffer->end();
m_ref_text_buffer->insert_with_tags(iter, "in bold", tags);
iter = m_ref_text_buffer->end();
m_ref_text_buffer->insert(iter, " to see its' tooltip");
m_text_view.set_buffer(m_ref_text_buffer);
m_text_view.set_size_request(320, 50);
//When only connecting to the query-tooltip signal, and not using any
//of set_tooltip_text(), set_tooltip_markup() or set_tooltip_window(),
//we need to explicitly tell GTK+ that the widget has a tooltip which
//we'll show.
m_text_view.set_has_tooltip();
|
阅读(476) | 评论(0) | 转发(0) |