Tutorial |
||
|
||
|
Fixed(); Fixed(Widget& widget, int x, int y); |
void
put(Widget& widget, int x, int y); void move(Widget& widget, int x, int y); |
void
set_has_window(bool has_window); bool get_has_window() const; |
#include<inti/main.h> #include <inti/core.h> #include <inti/gtk/fixed.h> #include <inti/gtk/button.h> using namespace Inti; class FixedWindow : public Gtk::Window { int x; int y; Gtk::Fixed *fixed; protected: void on_move_button(Gtk::Button *button); public: FixedWindow(); virtual ~FixedWindow(); }; |
#include"fixed.h" #include <inti/gtk/button.h> #include <inti/bind.h> FixedWindow::FixedWindow() : x(30), y(50), fixed(0) { set_title("Fixed Container"); set_border_width(10); // Create a Fixed Container fixed = new Gtk::Fixed; add(*fixed); fixed->show(); for (int i = 1 ; i <= 3 ; i++) { // Creates a new button with the label "Press me" Gtk::Button *button = new Gtk::Button("Press me"); // When the button receives the "clicked" signal, it will call the move_button() slot // passing it the Fixed Container as its argument. button->sig_clicked().connect(bind(slot(this, &FixedWindow::on_move_button), button)); // This packs the button into the fixed containers window. fixed->put(*button, i * 50, i * 50); // The final step is to display this newly created widget. button->show(); } } FixedWindow::~FixedWindow() { } void FixedWindow::on_move_button(Gtk::Button *button) { x = (x + 30) % 300; y = (y + 50) % 300; fixed->move(*button, x, y); } INTI_MAIN(FixedWindow) |
#define
INTI_MAIN(MainWidget)\ int main (int argc, char *argv[])\ {\ Inti::Main::init(&argc, &argv);\ MainWidget main_widget;\ main_widget.sig_destroy().connect(slot(&Inti::Main::quit));\ main_widget.show();\ Inti::Main::run();\ return 0;\ } |
|
|||
|
|||