A GtkMenuBar should normally be packed into a GtkVBox, and the parent window size and position set as appropriate. As with all containers, the menu bar itself takes up no screen area until its child widgets are in place.
Ejemplo 24. Creating a Menu Bar
<?php dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); $window = &new GtkWindow(); $window->set_uposition(10, 10); $window->set_usize((gdk::screen_width()-20), (gdk::screen_height()-30)); $window->connect_object('destroy', array('gtk', 'main_quit')); $box = &new GtkVBox(); $window->add($box); $menubar = &new GtkMenuBar(); $box->pack_start($menubar, false, false, 0); $header1 = &new GtkMenuItem("File"); $menubar->append($header1); $header2 = &new GtkMenuItem("Edit"); $menubar->append($header2); $filemenu = &new GtkMenu(); $open = &new GtkMenuItem("Open"); $filemenu->append($open); $save = &new GtkMenuItem("Save"); $filemenu->append($save); $separator = &new GtkMenuItem(); $separator->set_sensitive(false); $filemenu->append($separator); $exit = &new GtkMenuItem("Exit"); $exit->connect_object("activate", array("gtk", "main_quit")); $filemenu->append($exit); $header1->set_submenu($filemenu); $window->show_all(); gtk::main(); ?> |