/** * 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(); }
/** * 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; set_error_handler(array('TCoreApplication', 'errorHandler')); }
/** * 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; }
$h3box->pack_start($chnapis3 = new GtkLabel("TB"), 1); $chnapis3->modify_font(new PangoFontDescription($font . " 25")); $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('[ ]');
<?php $window = new GtkWindow(); $window->set_size_request(148, 240); $window->connect_simple('destroy', array('Gtk', 'main_quit')); $window->add($vbox = new GtkVBox()); // display title $title = new GtkLabel("Set up Volume Control\n" . "Part 1 - using GtkVScale"); $title->modify_font(new PangoFontDescription("Arial Narrow 8")); $title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff")); $title->set_size_request(-1, 40); $title->set_justify(Gtk::JUSTIFY_CENTER); $alignment = new GtkAlignment(0.5, 0.5, 0, 0); $alignment->add($title); $vbox->pack_start($alignment, 0); $vol_adj = GtkVScale::new_with_range(-100, 80, 1); // note 1 $vbox->pack_start(new GtkLabel('Volume'), 0); $vbox->pack_start($vol_adj, 0); $vol_adj->set_size_request(10, 160); $vol_adj->set_inverted(1); // note 2 $vol_adj->connect('format-value', 'on_format_value'); // note 3 $window->show_all(); Gtk::main(); function on_format_value($scale, $value) { return $value . "dB"; // note 4 }
<?php $window = new GtkWindow(); $window->connect_simple('destroy', array('Gtk', 'main_quit')); $window->set_size_request(400, 150); $window->add($vbox = new GtkVBox()); // display title $title = new GtkLabel("Setup and process GtkComboBox"); $title->modify_font(new PangoFontDescription("Times New Roman Italic 10")); $title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff")); $title->set_size_request(-1, 60); $vbox->pack_start($title, 0, 0); // the selection $list = array('item 1', 'item 2', 'item 3', 'item 4'); $vbox->pack_start($hbox = new GtkHBox(), 0, 0); $hbox->pack_start(new GtkLabel('Select: '), 0, 0); // Create a combobox $combobox = new GtkComboBox(); // Create a model if (defined("GObject::TYPE_STRING")) { $model = new GtkListStore(GObject::TYPE_STRING); } else { $model = new GtkListStore(Gtk::TYPE_STRING); } // Set up the combobox $combobox->set_model($model); // note 1 $cellRenderer = new GtkCellRendererText(); // note 2 $combobox->pack_start($cellRenderer); $combobox->set_attributes($cellRenderer, 'text', 0);
<?php $window = new GtkWindow(); $window->set_size_request(400, 200); $window->connect_simple('destroy', array('Gtk', 'main_quit')); $window->add($vbox = new GtkVBox()); // display title $title = new GtkLabel("Display 2D Array in GtkTreeView - Part 1"); $title->modify_font(new PangoFontDescription("Times New Roman Italic 10")); $title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff")); $title->set_size_request(-1, 40); $vbox->pack_start($title, 0, 0); $vbox->pack_start(new GtkLabel(), 0, 0); // the 2D table $data = array(array('row0', 'item 1', 2, 3.1), array('row1', 'item 4', 5, 6.21), array('row2', 'item 7', 8, 9.359999999999999), array('row3', 'item 10', 11, 12.4), array('row4', 'item 21', 14, 15.5), array('row5', 'item 36', 17, 18.6), array('row6', 'item 42', 20, 21.73)); display_table($vbox, $data); // note 1 $window->show_all(); Gtk::main(); function display_table($vbox, $data) { // Set up a scroll window $scrolled_win = new GtkScrolledWindow(); $scrolled_win->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); $vbox->pack_start($scrolled_win); // Creates the list store if (defined("GObject::TYPE_STRING")) { $model = new GtkListStore(GObject::TYPE_STRING, GObject::TYPE_STRING, GObject::TYPE_LONG, GObject::TYPE_DOUBLE); // note 2 } else { $model = new GtkListStore(Gtk::TYPE_STRING, Gtk::TYPE_STRING, Gtk::TYPE_LONG, Gtk::TYPE_DOUBLE);
$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 $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(); ?>
/** * Define the window's size * @param $width Window's width * @param $height Window's height */ public function setSize($width, $height) { parent::set_size_request($width, $height); }