📄 helloworld.cc
字号:
#include "helloworld.hh"#include <gfc/gtk/button.hh>#include <iostream>HelloWorld::HelloWorld(): Gtk::WidgetSignals(this){ // Sets the border width of the window. set_border_width(10); // Creates a new button with the label "Hello World". Gtk::Button *button = new Gtk::Button("Hello World"); // When the button receives the "clicked" signal, it calls the on_hello() slot. button->sig_clicked().connect(sigc::mem_fun(this, &HelloWorld::on_hello)); // This will cause the window to be destroyed by calling HelloWindow's inherited dispose method. button->sig_clicked().connect(sigc::mem_fun(static_cast<Gtk::Object*>(this), &HelloWorld::dispose)); // This packs the button into the window (a Gtk::Container). add(*button); // The final step is to display this newly created widget. button->show();}HelloWorld::~HelloWorld(){}boolHelloWorld::on_delete_event(const Gdk::EventAny& event){ // When the window is given the "delete_event" signal (this is given by the window manager, // usually by the "close" option, or on the titlebar), the on_delete_event() slot is called. // If you return false a "destroy" signal is emitted. Returning true means you don't want // the window to be destroyed. This is useful for popping up 'are you sure you want to quit?' // type dialogs. std::cout << "delete event occurred" << '\n'; return true;}voidHelloWorld::on_hello(){ std::cout << "Hello World" << std::endl;}int main (int argc, char *argv[]){ using namespace Main; init(&argc, &argv); HelloWorld window; window.sig_destroy().connect(sigc::ptr_fun(&GFC::Main::quit)); window.show(); run(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -