#include <gtk/gtk.h> int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *label; gtk_init(&argc, &argv); /* Create the main, top level window */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); /* Give it the title */ gtk_window_set_title(GTK_WINDOW(window), "Hello, world!"); /* Center the window */ gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); /* Set the window's default size */ gtk_window_set_default_size(GTK_WINDOW(window), 200, 100); /* ** Map the destroy signal of the window to gtk_main_quit; ** When the window is about to be destroyed, we get a notification and ** stop the main GTK+ loop by returning 0 */ g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); /* ** Assign the variable "label" to a new GTK label, ** with the text "Hello, world!" */ label = gtk_label_new("Hello, world!"); /* Plot the label onto the main window */ gtk_container_add(GTK_CONTAINER(window), label); /* Make sure that everything, window and label, are visible */ gtk_widget_show_all(window); /* ** Start the main loop, and do nothing (block) until ** the application is closed */ gtk_main(); return 0; }
//HelloWorldWindow.h #ifndef HELLOWORLDWINDOW_H #define HELLOWORLDWINDOW_H #include <gtkmm/window.h> #include <gtkmm/button.h> // Derive a new window widget from an existing one. // This window will only contain a button labelled "Hello World" class HelloWorldWindow : public Gtk::Window { public: HelloWorldWindow(); protected: void on_button_clicked(); //event handler Gtk::Button hello_world; }; #endif //HelloWorldWindow.cc #include <iostream> #include "HelloWorldWindow.h" HelloWorldWindow::HelloWorldWindow() : hello_world("Hello World") { // Set the title of the window. set_title("Hello World"); // Add the member button to the window, add(hello_world); // Handle the 'click' event. hello_world.signal_clicked().connect( sigc::mem_fun(*this, &HelloWorldWindow::on_button_clicked)); // Display all the child widgets of the window. show_all_children(); } void HelloWorldWindow::on_button_clicked() { std::cout << "Hello world" << std::endl; } //main.cc #include <gtkmm/main.h> #include "HelloWorldWindow.h" int main(int argc, char *argv[]) { // Initialization Gtk::Main kit(argc, argv); // Create a hello world window object HelloWorldWindow example; // gtkmm main loop Gtk::Main::run(example); return 0; }
PORTD = 0xff;
class led { public: led: port {*s}{/*..*/} ledOn(number) {/*...*/}; //... };
Source: https://habr.com/ru/post/253274/
All Articles