/** * Constructor Method */ function __construct() { parent::__construct(); parent::set_size_request(840, 640); parent::set_position(GTK::WIN_POS_CENTER); parent::connect_simple('delete-event', array($this, 'onClose')); parent::connect_simple('destroy', array('Gtk', 'main_quit')); parent::set_title(self::APP_TITLE); parent::set_icon(GdkPixbuf::new_from_file('favicon.png')); $gtk = GtkSettings::get_default(); $gtk->set_long_property("gtk-button-images", TRUE, 0); $gtk->set_long_property("gtk-menu-images", TRUE, 0); self::$inst = $this; $ini = parse_ini_file('application.ini'); $lang = $ini['language']; TAdiantiCoreTranslator::setLanguage($lang); TApplicationTranslator::setLanguage($lang); date_default_timezone_set($ini['timezone']); $this->content = new GtkFixed(); $vbox = new GtkVBox(); parent::add($vbox); $vbox->pack_start(GtkImage::new_from_file('app/images/pageheader-gtk.png'), false, false); $MenuBar = TMenuBar::newFromXML('menu.xml'); $vbox->pack_start($MenuBar, false, false); $vbox->pack_start($this->content, true, true); parent::show_all(); }
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(); }
protected function setUpMore() { $wnd = new GtkWindow(); $wnd->add($this->tv); $this->tv->realize(); $this->mod = new GtkListStore(Gtk::TYPE_STRING); $this->tv->set_model($this->mod); $this->col = new GtkTreeViewColumn('Title', new GtkCellRendererText(), 'text', 0); $this->tv->append_column($this->col); $this->mod->append(array('One')); $this->mod->append(array('Two')); }
/** * Cria a janela no modo splash * * @name set_splash_image($image) * @param string $image Caminho para a imagem do splash * @return GtkFixed */ public function set_splash_image($image) { // Carrega a imagem $pixbuf = GdkPixbuf::new_from_file($image); // Modifica as propriedades da janela parent::set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN); parent::set_size_request($pixbuf->get_width(), $pixbuf->get_height()); parent::set_position(GTK::WIN_POS_CENTER); parent::realize(); // Adiciona a imagem no fundo do GtkWindow list($pixmap, $mask) = $pixbuf->render_pixmap_and_mask(255); $style = parent::get_style(); $style = $style->copy(); $style->bg_pixmap[Gtk::STATE_NORMAL] = $pixmap; parent::set_style($style); // Adiciona um fixed para futuros widgets $fixed = new GtkFixed(); parent::add($fixed); // Mostra o splash parent::show_all(); // Retorna o fixed para adição de widgets return $fixed; }
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); /* * Show the window and all its child widgets. */ $window->show_all(); /* Run the main loop. */ Gtk::main();
<?php $window = new GtkWindow(); $window->set_default_size(120, 120); $vbox = new GtkVBox(); // new Button $button = new GtkButton(); $button->set_label('Icon Test'); $p = GdkPixbuf::new_from_file('images/publica.png'); $a = new GtkImage(); $a->set_from_pixbuf($p); $button->set_image($a); $vbox->pack_start($button, false, false); $window->add($vbox); $window->show_all(); Gtk::main();
<?php $w = new GtkWindow(); $t = new GtkTextBuffer(); $v = new GtkTextView($t); $s = new GtkSpell($v); $s->set_language('en'); $w->set_title('Spell Check'); $w->set_size_request(200, 200); $w->add($v); $w->show_all(); $w->connect_simple('destroy', array('Gtk', 'main_quit')); Gtk::main(); ?>
$cell_renderer = new GtkCellRendererText(); $column->pack_start($cell_renderer, true); $column->set_attributes($cell_renderer, 'text', 0); // Create columns for each type of data. $column = new GtkTreeViewColumn(); $column->set_title('Inventory'); $view->insert_column($column, 1); // Create a renderer for the column. $cell_renderer = new GtkCellRendererText(); $column->pack_start($cell_renderer, true); $column->set_attributes($cell_renderer, 'text', 1); // Create columns for each type of data. $column = new GtkTreeViewColumn(); $column->set_title('Price'); $view->insert_column($column, 2); // Create a renderer for the column. $cell_renderer = new GtkCellRendererText(); $column->pack_start($cell_renderer, true); $column->set_attributes($cell_renderer, 'text', 2); // Create a window and show everything. $window = new GtkWindow(); $window->add($view); $window->show_all(); $window->connect_simple('destroy', array('gtk', 'main_quit')); gtk::main(); /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: */
return false; } function starttips($tipsquery, $tooltips) { if ($tooltips->enabled) { $tipsquery->start_query(); $tooltips->disable(); } else { // $tipsquery->stop_query(); - this is automatic when the caller button is clicked $tooltips->enable(); } } $window = new GtkWindow(); $window->set_title('Tooltip'); $window->connect_simple('destroy', array('gtk', 'main_quit')); $window->add($vbox = new GtkVBox()); $vbox->pack_start($button = new GtkButton('Button1')); $tooltips->set_tip($button, 'This is button 1', 'Here is some help for button 1'); $vbox->pack_start($button = new GtkButton('Button2')); $tooltips->set_tip($button, 'This is button 2. This is also a really long tooltip which probably won\'t fit on a single line and will therefore need to be wrapped. Hopefully the wrapping will work correctly.', 'Here is some Help for button 2'); $vbox->pack_start($button = new GtkButton('Override TipsQuery Label')); $tooltips->set_tip($button, 'Toggle TipsQuery view.', 'Help for Help?'); $popup = new GtkWindow(Gtk::WINDOW_POPUP); $popup->add($tipsquery = new GtkTipsQuery()); $tipsquery->set_labels('Click to get help', 'No help found'); $button->connect_simple('clicked', 'starttips', $tipsquery, $tooltips); $tipsquery->set_caller($button); $tipsquery->connect('widget-entered', 'showtips'); $window->show_all(); $popup->show_all(); Gtk::main();
#!/usr/bin/php -c/etc/php/php-gtk.ini #GTK Hello world! by Harvie 2oo9 <?php if (!class_exists('gtk')) { die("Please load the php-gtk2 module in your php.ini\r\n"); } $wnd = new GtkWindow(); $wnd->set_title('Hello world'); $wnd->connect_simple('destroy', array('gtk', 'main_quit')); $lblHello = new GtkLabel("Just wanted to say\r\n'Hello world!'"); $wnd->add($lblHello); $wnd->show_all(); Gtk::main();
/* * Create a list widget and populate it with month names. */ $list = new GtkList(); $list->set_selection_mode(GTK_SELECTION_BROWSE); foreach (range(1, 12) as $month_num) { $items[] = new GtkListItem(strftime('%B', mktime(0, 0, 0, $month_num))); } $list->append_items($items); /* * Create a scrolled window and add the list widget to it - this provides * automatic scrollbars. */ $scrolled_window = new GtkScrolledWindow(); $scrolled_window->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); $scrolled_window->add_with_viewport($list); /* * Add scrolled window and button to the vertical layout box. */ $box->pack_start($scrolled_window); $box->pack_start($button, false); /* * Add layout box to the window, set window attributes and show everything. */ $window->add($box); $window->set_title('PHP Rules!'); $window->set_name('MainWindow'); $window->set_usize(150, 200); $window->show_all(); /* Run the main loop. */ Gtk::main();
$context->moveTo($x, $y); $context->lineTo($x + $radius * 0.75 * sin(pi() / 30 * $minutes), $y + $radius * 0.75 * -cos(pi() / 30 * $minutes)); $context->stroke(); // seconds hand $context->save(); $context->setSourceRgb(1, 0, 0); // red $context->moveTo($x, $y); $context->lineTo($x + $radius * 0.7 * sin(pi() / 30 * $seconds), $y + $radius * 0.7 * -cos(pi() / 30 * $seconds)); $context->stroke(); $context->restore(); } } Gobject::register_type('Clock'); function time_changed_cb($widget, $hours, $minutes) { echo "time-changed - {$hours}:{$minutes}\n"; } $window = new GtkWindow(); $clock = new Clock(); $window->add($clock); $window->connect_simple('destroy', array('Gtk', 'main_quit')); $clock->connect('time_changed', 'time_changed_cb'); $window->show_all(); Gtk::main(); ?>
<?php $someHtml = ' <h1>Hello World!</h1> <p><font color="red" size="20">This is GtkHTML</font></p> <h2>Bye Bye World!</h2>'; $x = new GtkWindow(); $y = new GtkHTML(); $y->set_title("HTML Test!"); $y->load_from_string($someHtml); $x->add($y); $x->show_all(); $x->connect_simple('destroy', array('Gtk', 'main_quit')); Gtk::main();
<?php $x = new GtkSheet(10, 10, 'test'); $y = new GtkWindow(); $y->add($x); $y->connect_simple('destroy', array('Gtk', 'main_quit')); $y->set_title('Testing GtkSheet'); $y->show_all(); Gtk::main();
$r = $radius + $radius / 3.0 * sin($f * 2.0 * pi()); $xpos = floor($xmid + $r * cos($ang) - $iw / 2.0 + 0.5); $ypos = floor($ymid + $r * sin($ang) - $ih / 2.0 + 0.5); $k = $i & 1 ? sin($f * 2.0 * pi()) : cos($f * 2.0 * pi()); $k = 2.0 * $k * $k; $k = max(0.25, $k); $r1 = new GdkRectangle($xpos, $ypos, $iw * $k, $ih * $k); $r2 = new GdkRectangle(0, 0, $back_width, $back_height); $dest = $r1->intersect($r2); $images[$i]->composite($frame, $dest->x, $dest->y, $dest->width, $dest->height, $xpos, $ypos, $k, $k, Gdk::INTERP_NEAREST, $i & 1 ? max(127, abs(255 * sin($f * 2.0 * pi()))) : max(127, abs(255 * cos($f * 2.0 * pi())))); } $da->queue_draw(); $frame_num++; return true; } $timeout_id = 0; //pixbuf_init (); if (!load_pixbufs()) { die("main(): Could not load all the pixbufs!"); } $frame = new GdkPixbuf(Gdk::COLORSPACE_RGB, false, 8, $back_width, $back_height); $window = new GtkWindow(Gtk::WINDOW_TOPLEVEL); $window->set_size_request($back_width, $back_height); $window->set_resizable(false); $window->connect_simple('destroy', array('gtk', 'main_quit')); $da = new GtkDrawingArea(); $da->connect('expose_event', 'expose_cb'); $window->add($da); Gtk::timeout_add(FRAME_DELAY, 'timeout'); $window->show_all(); Gtk::main();
<?php //Create our widgets $wnd = new GtkWindow(); $box = new GtkVBox(); $frame = new GtkFrame('Frame'); $btn = new GtkButton('Button'); //Pack them into each other $wnd->add($box); $box->add($frame); $frame->add($btn); //Give some a custom name $wnd->set_name('My window'); $btn->set_name('demo button'); //And now echo the class path of the button, // and the normal path echo 'class_path: "' . $btn->class_path() . "\"\n"; echo 'path: "' . $btn->path() . "\"\n"; /* Returns: class_path: "GtkWindow.GtkVBox.GtkFrame.GtkButton" path: "My window.GtkVBox.GtkFrame.demo 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(); } }
$chnapis3->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#800000")); $v2box->pack_start($h2box = new GtkHBox(), 1, 1); $h2box->pack_start($G["displejchyby"] = new GtkLabel("0"), 1); $G["displejchyby"]->modify_font(new PangoFontDescription($font . " 85")); $G["displejchyby"]->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#800000")); $h2box->pack_start($G["displejodm"] = new GtkLabel('0'), 1); $G["displejodm"]->modify_font(new PangoFontDescription($font . " 85")); $G["displejodm"]->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#800000")); $h2box->pack_start($G["displejtb"] = new GtkLabel('0.00'), 1); $G["displejtb"]->modify_font(new PangoFontDescription($font . " 85")); $G["displejtb"]->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#800000")); $window = new GtkWindow(); $window->set_title($argv[0]); $window->set_size_request(750, 550); $window->connect_simple('destroy', array('Gtk', 'main_quit')); $window->add($vbox = new GtkVBox()); $window->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse("#ffffff")); $window->connect_after('key-press-event', 'onKeyPress'); function onKeyPress($widget, $event) { global $righthand, $lefthand; if (get_class($widget) == "GtkWindow") { echo "Pressed: " . $event->keyval; } return true; } $G["rezimdisplej"] = new GtkLabel('A->A'); $G["sensorstatus1"] = new GtkLabel('[ ]'); $G["sensorstatus2"] = new GtkLabel('[ ]'); setup_menu($vbox, $menu_definition); $vbox->pack_start($hbox = new GtkHBox(), 0, 0);
/** * Show a popup with information about the application. * * The popup should show information about the version, * the author, the license, where to get the latest * version and a short description. * * @access public * @param none * @return void */ function about() { // Create the new window. $about = new GtkWindow(); $about->set_title('About PHPUnit GUI Gtk'); $about->set_usize(250, -1); // Put two vboxes in the hbox. $vBox = new GtkVBox(); $about->add($vBox); // Create the labels. $version = new GtkLabel(" Version: 1.0"); $license = new GtkLabel(" License: PHP License v3.0"); $where = new GtkLabel(" Download from: http://pear.php.net/PHPUnit/"); $unitAuth = new GtkLabel(" PHPUnit Author: Sebastian Bergman"); $gtkAuth = new GtkLabel(" Gtk GUI Author: Scott Mattocks"); // Align everything to the left $where->set_alignment(0, 0.5); $version->set_alignment(0, 0.5); $license->set_alignment(0, 0.5); $gtkAuth->set_alignment(0, 0.5); $unitAuth->set_alignment(0, 0.5); // Pack everything into the vBox; $vBox->pack_start($version); $vBox->pack_start($license); $vBox->pack_start($where); $vBox->pack_start($unitAuth); $vBox->pack_start($gtkAuth); // Connect the destroy signal. $about->connect('destroy', array('gtk', 'true')); // Show the goods. $about->show_all(); }