huwenhuo
全部博文(23)
2011年(1)
2010年(2)
2009年(20)
zhujiang
kshark
__gatsby
老山688
fender01
gavincha
karma303
zhujian1
dd_4435
分类: 嵌入式
2009-09-27 19:22:52
void ExampleWindow::on_button_copy() { //Build a string representation of the stuff to be copied: //Ideally you would use XML, with an XML parser here: Glib::ustring strData; strData += m_ButtonA1.get_active() ? "1" : "0"; strData += m_ButtonA2.get_active() ? "1" : "0"; strData += m_ButtonB1.get_active() ? "1" : "0"; strData += m_ButtonB2.get_active() ? "1" : "0"; Glib::RefPtr<Gtk::Clipboard> refClipboard = Gtk::Clipboard::get(); refClipboard->set_text(strData); } void ExampleWindow::on_button_paste() { //Tell the clipboard to call our method when it is ready: Glib::RefPtr<Gtk::Clipboard> refClipboard = Gtk::Clipboard::get(); refClipboard->request_text(sigc::mem_fun(*this, &ExampleWindow::on_clipboard_text_received) ); } void ExampleWindow::on_clipboard_text_received(const Glib::ustring& text) { //See comment in on_button_copy() about this silly clipboard format. if(text.size() >= 4) { m_ButtonA1.set_active( text[0] == '1' ); m_ButtonA2.set_active( text[1] == '1' ); m_ButtonB1.set_active( text[2] == '1' ); m_ButtonB2.set_active( text[3] == '1' ); } }
上一篇:Gtk:Entry
下一篇:Gtk::Spinbutton
登录 注册