/* * Create a list widget and populate it with month names. */ $list = new GtkList(); $list->set_selection_mode(GTK_SELECTION_BROWSE); foreach (range(1, 12) as $month_num) { $items[] = new GtkListItem(strftime('%B', mktime(0, 0, 0, $month_num))); } $list->append_items($items); /* * Create a scrolled window and add the list widget to it - this provides * automatic scrollbars. */ $scrolled_window = new GtkScrolledWindow(); $scrolled_window->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); $scrolled_window->add_with_viewport($list); /* * Add scrolled window and button to the vertical layout box. */ $box->pack_start($scrolled_window); $box->pack_start($button, false); /* * Add layout box to the window, set window attributes and show everything. */ $window->add($box); $window->set_title('PHP Rules!'); $window->set_name('MainWindow'); $window->set_usize(150, 200); $window->show_all(); /* Run the main loop. */ Gtk::main();
<?php //Create our widgets $wnd = new GtkWindow(); $box = new GtkVBox(); $frame = new GtkFrame('Frame'); $btn = new GtkButton('Button'); //Pack them into each other $wnd->add($box); $box->add($frame); $frame->add($btn); //Give some a custom name $wnd->set_name('My window'); $btn->set_name('demo button'); //And now echo the class path of the button, // and the normal path echo 'class_path: "' . $btn->class_path() . "\"\n"; echo 'path: "' . $btn->path() . "\"\n"; /* Returns: class_path: "GtkWindow.GtkVBox.GtkFrame.GtkButton" path: "My window.GtkVBox.GtkFrame.demo button" */
$y = (int) $event->y; $state = $event->state; } if ($state & GDK_BUTTON1_MASK && $pixmap) { draw_brush($widget, $x, $y); } return true; } function draw_brush($widget, $x, $y) { global $pixmap; gdk::draw_arc($pixmap, $widget->style->black_gc, true, $x - 4, $y - 4, 8, 8, 0, 64 * 360); $widget->draw(new GdkRectangle($x - 4, $y - 4, 8, 8)); } $window = new GtkWindow(); $window->set_name('Test Input'); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object('destroy', array('gtk', 'main_quit')); $vbox = new GtkVBox(); $window->add($vbox); $vbox->show(); $drawing_area = new GtkDrawingArea(); $drawing_area->size(300, 300); $vbox->pack_start($drawing_area); $drawing_area->show(); $drawing_area->connect('expose_event', 'expose_event'); $drawing_area->connect('configure_event', 'configure_event'); $drawing_area->connect('motion_notify_event', 'motion_notify_event'); $drawing_area->connect('button_press_event', 'button_press_event'); $drawing_area->set_events(GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); $button = new GtkButton('Quit');