Chinaunix首页 | 论坛 | 博客
  • 博客访问: 34758
  • 博文数量: 23
  • 博客积分: 1415
  • 博客等级: 上尉
  • 技术积分: 235
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-20 09:41
文章分类
文章存档

2011年(1)

2010年(2)

2009年(20)

我的朋友

分类:

2009-09-28 01:42:29

普通的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();
        


阅读(455) | 评论(0) | 转发(0) |
0

上一篇:Gtk::Progressor

下一篇:Gtk::Toolbar

给主人留下些什么吧!~~