/** * Define the icon of the button * @param $image image path */ public function setImage($image) { if (file_exists('lib/adianti/images/' . $image)) { $imagem = GtkImage::new_from_file('lib/adianti/images/' . $image); } else { $imagem = GtkImage::new_from_file('app/images/' . $image); } parent::set_image($imagem); }
/** * Class Constructor * @param $name Name of the widget */ public function __construct($name) { parent::__construct($name); $this->widget = new GtkHBox(); parent::add($this->widget); $this->mask = 'yyyy-mm-dd'; // creates the entry field $this->entry = new TEntry($name); $this->entry->setSize(200); $this->setMask($this->mask); $this->widget->add($this->entry); // creates a button with a calendar image $button = new GtkButton(); $button->set_relief(GTK::RELIEF_NONE); $imagem = GtkImage::new_from_file('lib/adianti/images/tdate-gtk.png'); $button->set_image($imagem); $this->actionButton = $button; // define the button's callback $button->connect_simple('clicked', array($this, 'onCalendar')); $this->widget->add($button); // creates the calendar window $this->popWindow = new GtkWindow(Gtk::WINDOW_POPUP); // creates the calendar $this->calendar = new GtkCalendar(); // define the action when the user selects a date $this->calendar->connect_simple('day-selected-double-click', array($this, 'onSelectDate')); $this->month = new TCombo('tdate-month'); $this->month->addItems(array(TAdiantiCoreTranslator::translate('January'), TAdiantiCoreTranslator::translate('February'), TAdiantiCoreTranslator::translate('March'), TAdiantiCoreTranslator::translate('April'), TAdiantiCoreTranslator::translate('May'), TAdiantiCoreTranslator::translate('June'), TAdiantiCoreTranslator::translate('July'), TAdiantiCoreTranslator::translate('August'), TAdiantiCoreTranslator::translate('September'), TAdiantiCoreTranslator::translate('October'), TAdiantiCoreTranslator::translate('November'), TAdiantiCoreTranslator::translate('December'))); $this->month->setCallback(array($this, 'onChangeMonth')); $this->month->setSize(70); for ($n = date('Y') - 10; $n <= date('Y') + 10; $n++) { $years[$n] = $n; } $this->year = new TCombo('tdate-year'); $this->year->addItems($years); $this->year->setCallback(array($this, 'onChangeMonth')); $this->year->setSize(70); $hbox = new GtkHBox(); $hbox->pack_start($this->month); $hbox->pack_start($this->year); $bt_today = new GtkButton(TAdiantiCoreTranslator::translate('Today')); $bt_close = new GtkButton(TAdiantiCoreTranslator::translate('Close')); $bt_today->connect_simple('clicked', array($this, 'selectToday')); $inst = $this->popWindow; $bt_close->connect_simple('clicked', array($inst, 'hide')); $hbox2 = new GtkHBox(); $hbox2->pack_start($bt_today); $hbox2->pack_start($bt_close); $vbox = new GtkVBox(); $vbox->pack_start($hbox, FALSE, FALSE); $vbox->pack_start($this->calendar); $vbox->pack_start($hbox2, FALSE, FALSE); // shows the window $this->popWindow->add($vbox); }
function append($page) { $this->remove_background(); $page->Parent = $this; $page->Owner = $this->Owner; // Icone + Rotulo $guide = new GtkHBox(); if ($page->Icon) { $guide->pack_start(GtkImage::new_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . $page->Icon), false); } $guide->pack_start(new GtkLabel(' ' . $page->Title . ' ')); // Fechar $guide->pack_start($close = new GtkButton()); $close->set_image(GtkImage::new_from_stock(Gtk::STOCK_CLOSE, Gtk::ICON_SIZE_BUTTON)); $guide->show_all(); // Guia $menu_item = new GtkHBox(); if ($page->Icon) { $menu_item->pack_start(GtkImage::new_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . $page->Icon), false); } $menu_item->pack_start(new GtkLabel(' ' . $page->Title . ' ')); $menu_item->show_all(); $scroll = new GtkScrolledWindow(); $scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); $scroll->add_with_viewport($page); $scroll->show_all(); $current = $this->append_page_menu($scroll, $guide, $menu_item); $this->set_current_page($current); // Close signal if ($this->background) { $close->connect('clicked', array($this, 'xmoney_close_clicked'), $current); } else { $close->connect('clicked', array($this, 'close_button'), $current); } return $current; }
<?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();
/** * Add an Action to the DataGrid * @param $object A TDataGridAction object */ public function addAction(TDataGridAction $action) { $this->actions[] = $action; $button = new GtkButton($action->getLabel()); if (file_exists('lib/adianti/images/' . $action->getImage())) { $button->set_image(GtkImage::new_from_file('lib/adianti/images/' . $action->getImage())); } else { $button->set_image(GtkImage::new_from_file('app/images/' . $action->getImage())); } $button->connect_simple('clicked', array($this, 'onExecute'), $action); $this->action_area->pack_start($button); }
/** * Add an Action to the DataGrid * @param $object A TDataGridAction object */ public function addAction(TDataGridAction $action) { if ($this->modelCreated) { throw new Exception(TAdiantiCoreTranslator::translate('You must call ^1 before ^2', __METHOD__, 'createModel')); } else { $this->actions[] = $action; $button = new GtkButton($action->getLabel()); if (file_exists('lib/adianti/images/' . $action->getImage())) { $button->set_image(GtkImage::new_from_file('lib/adianti/images/' . $action->getImage())); } else { $button->set_image(GtkImage::new_from_file('app/images/' . $action->getImage())); } $button->connect_simple('clicked', array($this, 'onExecute'), $action); $this->action_area->pack_start($button); } }