set_title("Interface Prototype"); $window->connect_simple('destroy', array('gtk', 'main_quit')); $bottomlabele = new GtkLabel("show/hide bottom pane"); $bottomlabel = new gtkeventbox(); $bottomlabel->add($bottomlabele); $notebook = new GtkFrame(); $notebook->set_shadow_type(Gtk::SHADOW_IN); $vbox = new GtkVbox(); $vbox->pack_end($bottomlabel,false,false); $hbox = new GtkHbox(); $leftlabele = new gtklabel("show/hide left pane"); $rightlabele = new gtklabel("show/hide right pane"); $leftlabele->set_angle(270); $rightlabele->set_angle(90); $leftlabel = new gtkeventbox(); $leftlabel->add($leftlabele); $rightlabel = new gtkeventbox(); $rightlabel->add($rightlabele); $bottompane = new GtkVPaned(); $leftpane = new GtkHPaned(); $rightpane = new GtkHPaned(); $vbox->pack_start($leftpane); $leftpane->add2($rightpane); $rightpane->add1($hbox); $hbox->pack_start($leftlabel,false,false); $hbox->pack_start($notebook); $hbox->pack_start($rightlabel,false,false); $bottompane->add1($vbox); // add items to bottom right and left frames $bottom = new GtkFrame(); $bottom->set_shadow_type(Gtk::SHADOW_IN); $left = new GtkFrame(); $left->set_shadow_type(Gtk::SHADOW_IN); $right = new GtkFrame(); $right->set_shadow_type(Gtk::SHADOW_IN); $bottompane->add2($bottom); $leftpane->add1($left); $rightpane->add2($right); $basebox = new gtkvbox(); // --start-- // define menu definition $menu_definition = array( // note 1 '_File' => array('_New', '_Open', '_Close', '_Quit'), '_Test' => array('Test1', 'Test2', 'Test3', '
', array('Selection 1', 'Selection 2', 'Selection 3'), // note 2 '
', 'Test4') ); // define menu definition $toolbar_definition = array('New', 'Open', 'Save', '
', // note 1 'Cut', 'Copy', 'Paste', '
', 'Undo','Redo'); setup_menu($basebox, $menu_definition); // note 1 setup_toolbar($basebox, $toolbar_definition); // setup menu function setup_menu($vbox, $menus) { // note 1 $menubar = new GtkMenuBar(); $vbox->pack_start($menubar, 0, 0); foreach($menus as $toplevel => $sublevels) { $menubar->append($top_menu = new GtkMenuItem($toplevel)); $menu = new GtkMenu(); $top_menu->set_submenu($menu); foreach($sublevels as $submenu) { if (is_array($submenu)) { // set up radio menus $i=0; $radio[0] = null; foreach($submenu as $radio_item) {// note 3 $radio[$i] = new GtkRadioMenuItem($radio[0], $radio_item); $menu->append($radio[$i]); ++$i; } $radio[0]->set_active(1); // select the first item } else { if ($submenu=='
') { $menu->append(new GtkSeparatorMenuItem()); } else { $menu->append($menu_item = new GtkMenuItem($submenu)); } } } } } // setup toolbar function setup_toolbar($vbox, $toolbar_definition) { // note 1 $toolbar = new GtkToolBar(); // note 2 $vbox->pack_start($toolbar, 0, 0); foreach($toolbar_definition as $item) { if ($item=='
') { $toolbar->insert(new GtkSeparatorToolItem(), -1); } else { $stock_image_name = 'Gtk::STOCK_'.strtoupper($item); // note 3 if (defined($stock_image_name)) { $toolbar_item = GtkToolButton::new_from_stock(constant ($stock_image_name)); // note 4 $toolbar->insert($toolbar_item, -1); // note 5 } } } } // -- end -- $basebox->pack_end(new gtkstatusbar(),false,false); $basebox->pack_start($bottompane); $window->add($basebox); $window->set_size_request(400,350); $window->show_all(); $bottom->hide(); $left->hide(); $right->hide(); $leftlabel->connect_simple('button-press-event','hide_show',$left); $rightlabel->connect_simple('button-press-event','hide_show',$right); $bottomlabel->connect_simple('button-press-event','hide_show',$bottom); Gtk::main(); function hide_show($pane){ switch($pane->is_visible()){ case true: $pane->hide_all(); break; case false: $pane->show_all(); break; } } ?>