/** * Class Constructor * @param $title Window's title */ public function __construct($title = '') { parent::__construct(); parent::set_position(Gtk::WIN_POS_CENTER); parent::set_border_width(4); parent::connect('key_press_event', array($this, 'onKeyTest')); parent::connect_simple('delete-event', array($this, 'onClose')); parent::set_title($title); }
public function __construct() { parent::__construct(); parent::set_title('Incluir'); parent::connect_simple('destroy', array('Gtk', 'main_quit')); parent::set_default_size(400, 240); parent::set_border_width(10); parent::set_position(GTK::WIN_POS_CENTER); $vbox = new GtkVBox(); $this->labels['id'] = new GtkLabel('Código:'); $this->campos['id'] = new GtkEntry(); $this->campos['id']->set_size_request(80, -1); $this->labels['nome'] = new GtkLabel('Nome: '); $this->campos['nome'] = new GtkEntry(); $this->campos['nome']->set_size_request(240, -1); $this->labels['endereco'] = new GtkLabel('Endereço: '); $this->campos['endereco'] = new GtkEntry(); $this->campos['endereco']->set_size_request(240, -1); $this->labels['telefone'] = new GtkLabel('Telefone: '); $this->campos['telefone'] = new GtkEntry(); $this->campos['telefone']->set_size_request(140, -1); $this->labels['id_cidade'] = new GtkLabel('Cidade: '); $this->campos['id_cidade'] = GtkComboBox::new_text(); $this->campos['id_cidade']->set_size_request(240, -1); $this->campos['id_cidade']->insert_text(0, 'Porto Alegre'); $this->campos['id_cidade']->insert_text(1, 'São Paulo'); $this->campos['id_cidade']->insert_text(2, 'Rio de Janeiro'); $this->campos['id_cidade']->insert_text(3, 'Belo Horizonte'); foreach ($this->campos as $chave => $objeto) { $hbox = new GtkHBox(); $hbox->pack_start($this->labels[$chave], false, false); $hbox->pack_start($this->campos[$chave], false, false); $this->labels[$chave]->set_size_request(100, -1); $this->labels[$chave]->set_alignment(1, 0.5); // xAlign, yalign (0.5, 1) $vbox->pack_start($hbox, false, false); } $vbox->pack_start(new GtkHSeparator(), true, true); // cria uma caixa de botões $buttonbox = new GtkHButtonBox(); $buttonbox->set_layout(Gtk::BUTTONBOX_START); // cria um botão de salvar $botao = GtkButton::new_from_stock(Gtk::STOCK_SAVE); // conecta o botão ao método onSaveClick() $botao->connect_simple('clicked', array($this, 'onSaveClick')); $buttonbox->pack_start($botao, false, false); // cria um botão de fechar a aplicação $botao = GtkButton::new_from_stock(Gtk::STOCK_CLOSE); $botao->connect_simple('clicked', array('Gtk', 'main_quit')); $buttonbox->pack_start($botao, false, false); $vbox->pack_start($buttonbox, false, false); parent::add($vbox); // exibe a janela parent::show_all(); }
* Called when button is clicked. Print the message and destroy the window. */ function hello() { global $window; print "Hello World!\n"; $window->destroy(); } /* * Create a new top-level window and connect the signals to the appropriate * functions. Note that all constructors must be assigned by reference. */ $window = new GtkWindow(); $window->connect('destroy', 'destroy'); $window->connect('delete-event', 'delete_event'); $window->set_border_width(10); /* * Create a button, connect its clicked signal to hello() function and add * the button to the window. */ $button = new GtkButton('Hello World!'); $button->connect('clicked', 'hello'); /* * Create a new tooltips object and use it to set a tooltip for the button. */ $tt = new GtkTooltips(); $tt->set_delay(200); $tt->set_tip($button, 'Prints "Hello World!"', ''); $tt->enable(); $window->add($button); /*
function create_notebook() { global $windows, $sample_notebook, $book_open, $book_open_mask, $book_closed, $book_closed_mask, $book_open_xpm, $book_closed_xpm; $items = array('Standard' => array('standard_notebook', &$sample_notebook), 'No tabs' => array('notabs_notebook', &$sample_notebook), 'Scrollable' => array('scrollable_notebook', &$sample_notebook)); if (!isset($windows['notebook'])) { $window = new GtkWindow(); $windows['notebook'] = $window; $window->connect('delete_event', 'delete_event'); $window->set_title('Notebook'); $window->set_border_width(0); $box1 =& new GtkVBox(false, 0); $box1->show(); $window->add($box1); $sample_notebook = new GtkNotebook(); $sample_notebook->show(); $sample_notebook->connect('switch_page', 'page_switch'); $sample_notebook->set_tab_pos(GTK_POS_TOP); $box1->pack_start($sample_notebook, true, true, 0); $sample_notebook->set_border_width(10); $sample_notebook->realize(); list($book_open, $book_open_mask) = Gdk::pixmap_create_from_xpm_d($sample_notebook->window, null, $book_open_xpm); list($book_closed, $book_closed_mask) = Gdk::pixmap_create_from_xpm_d($sample_notebook->window, null, $book_closed_xpm); create_pages(&$sample_notebook, 1, 5); $separator =& new GtkHSeparator(); $separator->show(); $box1->pack_start($separator, false, true, 10); $box2 =& new GtkHBox(false, 5); $box2->show(); $box2->set_border_width(10); $box1->pack_start($box2, false, true, 0); $button =& new GtkCheckButton('popup menu'); $button->show(); $box2->pack_start($button, true, false, 0); $button->connect('clicked', 'notebook_popup', &$sample_notebook); $button =& new GtkCheckButton('homogeneous tabs'); $button->show(); $box2->pack_start($button, true, false, 0); $button->connect('clicked', 'notebook_homogeneous', &$sample_notebook); $box2 =& new GtkHBox(false, 5); $box2->show(); $box2->set_border_width(10); $box1->pack_start($box2, false, true, 0); $label =& new GtkLabel('Notebook Style:'); $label->show(); $box2->pack_start($label, false, true, 0); $omenu = build_option_menu($items, 3, 0, &$sample_notebook); $omenu->show(); $box2->pack_start($omenu, false, true, 0); $button =& new GtkButton('Show all Pages'); $button->show(); $box2->pack_start($button, false, true, 0); $button->connect_object('clicked', 'show_all_pages', &$sample_notebook); $box2 =& new GtkHBox(true, 10); $box2->show(); $box2->set_border_width(10); $box1->pack_start($box2, false, true, 0); $button =& new GtkButton('prev'); $button->show(); $button->connect_object('clicked', array(&$sample_notebook, 'prev_page')); $box2->pack_start($button, true, true, 0); $button =& new GtkButton('next'); $button->show(); $button->connect_object('clicked', array(&$sample_notebook, 'next_page')); $box2->pack_start($button, true, true, 0); $button =& new GtkButton('rotate'); $button->show(); $button->connect_object('clicked', 'notebook_rotate', &$sample_notebook); $box2->pack_start($button, true, true, 0); $separator =& new GtkHSeparator(); $separator->show(); $box1->pack_start($separator, false, true, 5); $button =& new GtkButton('close'); $button->show(); $button->set_border_width(5); $button->connect('clicked', 'close_window'); $box1->pack_start($button, false, false, 0); $button->set_flags(GTK_CAN_DEFAULT); $button->grab_default(); } if ($windows['notebook']->flags() & GTK_VISIBLE) { $windows['notebook']->hide(); } else { $windows['notebook']->show(); } }