entry.cc

来自「gfc编程示例 gfc sample of Linux GFC」· CC 代码 · 共 88 行

CC
88
字号
#include "entry.hh"#include <gfc/gtk/stockid.hh>#include <iostream>EntryWindow::EntryWindow(){	set_title("GFC Entry");	set_size_request(200, 100);	Gtk::VBox *vbox = new Gtk::VBox;	add(*vbox);	vbox->show();	entry = new Gtk::Entry;	entry->set_max_length(50);	entry->sig_activate().connect(sigc::mem_fun(this, &EntryWindow::on_enter));	entry->set_text("hello");	int tmp_pos = entry->gtk_entry()->text_length;	entry->insert_text(" world", tmp_pos);	entry->select_region(0, entry->gtk_entry()->text_length);	vbox->pack_start(*entry);	entry->show();	Gtk::HBox *hbox = new Gtk::HBox;	vbox->add(*hbox);	hbox->show();	Gtk::CheckButton *check = new Gtk::CheckButton("Editable");	hbox->pack_start(*check);	check->sig_toggled().connect(sigc::bind(sigc::mem_fun(this, &EntryWindow::on_entry_toggle_editable), check));	check->set_active(true);	check->show();	check = new Gtk::CheckButton("Visible");	hbox->pack_start(*check);	check->sig_toggled().connect(sigc::bind(sigc::mem_fun(this, &EntryWindow::on_entry_toggle_visible), check));	check->set_active(true);	check->show();	Gtk::Button *button = new Gtk::Button(Gtk::StockId::CLOSE);	button->sig_clicked().connect(sigc::mem_fun(this, &EntryWindow::dispose));	vbox->pack_start(*button);	button->set_flags(Gtk::CAN_DEFAULT);	button->grab_default();	button->show();}EntryWindow::~EntryWindow(){}voidEntryWindow::on_enter(){	using namespace std;	String text = entry->get_text();	cout << "Entry contents: " << text.c_str() << endl;}voidEntryWindow::on_entry_toggle_editable(Gtk::CheckButton *button){	entry->set_editable(button->get_active());}voidEntryWindow::on_entry_toggle_visible(Gtk::CheckButton *button){	entry->set_visibility(button->get_active());}int main(int argc, char *argv[]){	using namespace Main;	init(&argc, &argv);	EntryWindow window;	window.sig_destroy().connect(sigc::ptr_fun(&GFC::Main::quit));	window.show();	run();	return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?