<?php
if( !extension_loaded('gtk')) {
dl( 'php_gtk.' . PHP_SHLIB_SUFFIX) || die("Can't load php_gtk module!\n");
}
function show_event_type($button, $event, $text)
{
$event_type = $event->type;
$insert = $text->get_length();
$text->freeze();
switch($event_type) {
case 2:
$text->insert_text("GDK_EXPOSE\n", $insert);
break;
case 3:
$text->insert_text("GDK_MOTION_NOTIFY\n", $insert);
break;
case 4:
$text->insert_text("GDK_BUTTON_PRESS\n", $insert);
break;
case 5:
$text->insert_text("GDK_2BUTTON_PRESS\n", $insert);
$button->hide();
break;
case 7:
$text->insert_text("GDK_BUTTON_RELEASE\n", $insert);
break;
case 8:
$text->insert_text("GDK_KEY_PRESS\n", $insert);
break;
case 9:
$text->insert_text("GDK_KEY_RELEASE\n", $insert);
break;
case 10:
$text->insert_text("GDK_ENTER_NOTIFY\n", $insert);
break;
case 11:
$text->insert_text("GDK_LEAVE_NOTIFY\n", $insert);
break;
case 12:
$text->insert_text("GDK_FOCUS_CHANGE\n", $insert);
break;
case 14:
$text->insert_text("GDK_MAP\n", $insert);
break;
case 15:
$text->insert_text("GDK_UNMAP\n", $insert);
$button->destroy();
$text->insert_text(
"\n* GDK EVENTS AND GTK SIGNALS - background stream vs foreground
messaging *
\n
* Most GdkEventTypes have counterpart GTK signals, known as 'event'
signals, implemented in GtkWidget. The types on your screen are there
because the GtkButton was programmed to emit the generic 'event' signal
each time it captured one of the stream of GDK events that makes up the
GTK main loop. In each case, the captured GdkEvent was passed as a
callback parameter so that its enumerated type value could be determined
within the signal handler function. Scroll down to see the series of event
values captured during your recent interaction with the GtkButton widget. *
\n
* Please note that the majority of GTK signals do NOT correspond to GDK
events in this or any other way! For example, the signal connection
\$button->connect('pressed', 'whatever');
has no relationship to the GDK_BUTTON_PRESS event it generates, which
refers to mouse-button activity and not to the GtkButton 'pressed' signal. *
\n", 0);
break;
}
$text->thaw();
return false;
}
$window = &new GtkWindow();
$window->set_position(GTK_WIN_POS_CENTER);
$window->set_default_size((gdk::screen_width()/1.5),
(gdk::screen_height()-20));
$window->connect_object("destroy", array("gtk",
"main_quit"));
$window->realize();
$box = &new GtkVBox(false, 5);
$window->add($box);
$scrlwin = &new GtkScrolledWindow();
$box->pack_start($scrlwin, true, true, 0);
$text = &new GtkText();
$scrlwin->add($text);
$button = &new GtkButton("Double-click here for information..");
$button->add_events(GDK_ALL_EVENTS_MASK);
$button->connect("event", "show_event_type", $text);
$box->pack_end($button, false, false, 5);
$window->show_all();
gtk::main();
?>
|