PHP-GTK
Sunday, December 21, 2014 
download | documentation | applications | faq | changelog | resources 


search for in the  


previousGtkEventBox
GtkEventBox::get_above_childnext

Last updated: Sun, 12 May 2013
view this page in English

GtkEventBox Constructor

Use this constructor to create a new GtkEventBox.

Example 61. A Demonstration of usage of the event box.

<?php
//Initialising the event box and adding an image to it
$imageEvent = new GtkEventBox();
$imageWidget = GtkImage::new_from_stock(
    Gtk::STOCK_DIALOG_WARNING,
    Gtk::ICON_SIZE_DIALOG
);
$imageEvent->add($imageWidget);
 
//Initialising another event box and adding a label to it
$labelEvent = new GtkEventBox();
$labelWidget = new GtkLabel('Click something!');
$labelEvent->add($labelWidget);
 
//Connecting the signals to the callback
$imageEvent->connect('button_press_event', 'doSomething');
$labelEvent->connect('button_press_event', 'doSomething');
 
//The callback function
function doSomething($widget, $event)
{
    //Determine which widget triggered the signal
    $widget = $widget->get_child()->get_name();
    if ($widget == 'GtkImage') {
        $type = 'image';
    } else {
        $type = 'label';
    }
 
    //Show a dialog that displays a message
    $dialog = new GtkMessageDialog(
        null,
        0,
        Gtk::MESSAGE_INFO,
        Gtk::BUTTONS_OK,
        'You clicked the ' . $type . '!'
    );
    $dialog->run();
    $dialog->destroy();
}
 
//Creating a VBox to add the event boxes to
$vbox = new GtkVBox();
$seperator = new GtkHSeparator();
$vbox->pack_start($imageEvent);
$vbox->pack_start($seperator);
$vbox->pack_start($labelEvent);
 
//Creating a window and adding the VBox to it
$window = new GtkWindow();
$window->add($vbox);
$window->set_position(Gtk::WIN_POS_CENTER);
$window->set_default_size(200,150);
$window->show_all();
$window->set_title("Event Boxes!");
$window->connect_simple(
    'destroy',
    array('Gtk', 'main_quit')
);
 
//Starting main loop
Gtk::main();
?>

User Contributed Notes
gtk.gtkeventbox.constructor.php
add a note about notes
There are no user contributed notes for this page.


previousGtkEventBox
GtkEventBox::get_above_childnext

Last updated: Sun, 12 May 2013
view this page in English


credits 

PHP  Copyright © 2001-2014 The PHP Group
 All rights reserved.
Last updated: Sun May 12 20:50:57 2013 CEST