Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

AndOr - Construindo um GtkToolbar

blogandor Nov 15th, 2018 84 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. <?php
  2. /**
  3.  * Construindo um GtkToolbar
  4.  * PHP-GTK
  5.  * http://andor.com.br
  6.  */
  7.  
  8. /**
  9.  * Seta a codificação do programa
  10.  */
  11. ini_set("php-gtk.codepage", "UTF-8");
  12.    
  13. /**
  14.  * @Demo
  15.  */
  16. class Demo {
  17.     /**
  18.      * Armazena os widgets necessarios
  19.      *
  20.      * @access private
  21.      * @property array $widgets
  22.      */
  23.     public $widgets = array();
  24.    
  25.     /**
  26.      * @name __construct()
  27.      * @return Demo
  28.      */
  29.     public function __construct() {
  30.         // Cria a janela
  31.         $this->widgets['frmDemo'] = new GtkWindow();
  32.         $this->widgets['frmDemo']->set_size_request(250, 250);
  33.         $this->widgets['frmDemo']->set_position(Gtk::WIN_POS_CENTER_ALWAYS);
  34.         $this->widgets['frmDemo']->set_title("Demo");
  35.         $this->widgets['frmDemo']->connect("destroy", array($this, "frmDemo_unload"));
  36.         $vbox = new GtkVBox();
  37.  
  38.         // Toolbar
  39.         $this->widgets['tlbDemo'] = Fabula::GtkToolbar();
  40.         $vbox->pack_start($this->widgets['tlbDemo'], FALSE, FALSE);
  41.        
  42.         // Botão do stock
  43.         $btnAbrir = $this->widgets['tlbDemo']->append_button_from_stock(Gtk::STOCK_OPEN, NULL, "Abrir");
  44.         $btnConectar = $this->widgets['tlbDemo']->append_button_from_stock(Gtk::STOCK_CONNECT, NULL, "Conectar");
  45.         $btnSair = $this->widgets['tlbDemo']->append_button_from_stock(Gtk::STOCK_CLOSE, NULL, "Sair");
  46.        
  47.         // Conecta
  48.         $btnAbrir->connect_simple("clicked", array($this, "btnToolbar_clicked"), 1);
  49.         $btnConectar->connect_simple("clicked", array($this, "btnToolbar_clicked"), 2);
  50.         $btnSair->connect_simple("clicked", array($this, "btnToolbar_clicked"), 3);
  51.        
  52.         // Inicia a aplicação
  53.         $vbox->pack_start(new GtkFixed());
  54.         $this->widgets['frmDemo']->add($vbox);
  55.         $this->frmDemo_onload();
  56.     }
  57.    
  58.     /**
  59.      * Método do carregamento do formulario
  60.      *
  61.      * @name frmDemo_onload()
  62.      */
  63.     public function frmDemo_onload() {
  64.         // Inicia a aplicação
  65.         $this->widgets['frmDemo']->show_all();
  66.         Gtk::main();
  67.     }
  68.    
  69.     /**
  70.      * Método do descarregamento do formulario
  71.      *
  72.      * @name frmDemo_unload()
  73.      */
  74.     public function frmDemo_unload() {
  75.         // Encerra a aplicação
  76.         Gtk::main_quit();
  77.     }
  78.    
  79.     /**
  80.      * Método do click dos botões do menu
  81.      *
  82.      * @name btnToolbar_clicked()
  83.      * @param integer $btn Index do botão pressionado
  84.      */
  85.     public function btnToolbar_clicked($btn) {
  86.         echo $btn . "\n";
  87.     }
  88. }
  89.    
  90. /**
  91.  * Inicia o demo
  92.  */
  93. new Demo();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top