示例#1
0
 /**
  * Class Constructor
  * @param $title Window's title
  */
 public function __construct($title = '')
 {
     parent::__construct();
     parent::set_position(Gtk::WIN_POS_CENTER);
     parent::connect('key_press_event', array($this, 'onKeyTest'));
     parent::connect_simple('destroy', array($this, 'onClose'));
     parent::set_title($title);
 }
示例#2
0
}
/*
 * 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();
示例#3
0
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();
    }
}
示例#4
0
}
/*
 * Called when delete-event happens. Returns false to indicate that the event
 * should proceed.
 */
function delete_event()
{
    return false;
}
/*
 * 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_object('destroy', array('gtk', 'main_quit'));
$window->connect('delete-event', 'delete_event');
/*
 * Create a button and connect its 'clicked' signal to destroy() function.
 */
$button = new GtkButton('Close');
$button->connect_object('clicked', array('gtk', 'main_quit'));
/*
 * Create a vertical layout box.
 */
$box = new GtkVBox(false, 10);
$box->set_border_width(10);
/*
 * Create a list widget and populate it with month names.
 */
$list = new GtkList();
$list->set_selection_mode(GTK_SELECTION_BROWSE);
示例#5
0
文件: Gtk.php 项目: Zunair/xataface
 /**
  * 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();
 }