Exemplo n.º 1
0
function create_pixmap()
{
    global $windows;
    if (!isset($windows['pixmap'])) {
        $window =& new GtkWindow();
        $windows['pixmap'] = $window;
        $window->connect('delete-event', 'delete_event');
        $window->set_title('GtkPixmap');
        $window->set_border_width(0);
        $window->realize();
        $box1 =& new GtkVBox();
        $window->add($box1);
        $box1->show();
        $box2 =& new GtkVBox(false, 10);
        $box2->set_border_width(10);
        $box1->pack_start($box2);
        $box2->show();
        $button =& new GtkButton();
        $box2->pack_start($button, false, false);
        $button->show();
        list($pixmap, $mask) = Gdk::pixmap_create_from_xpm($window->window, null, "window.xpm");
        $pixmapwid =& new GtkPixmap($pixmap, $mask);
        $label =& new GtkLabel("Pixmap\ntest");
        $box3 =& new GtkHBox();
        $box3->set_border_width(2);
        $box3->pack_start($pixmapwid);
        $box3->pack_start($label);
        $pixmapwid->show();
        $label->show();
        $button->add($box3);
        $box3->show();
        $separator =& new GtkHSeparator();
        $box1->pack_start($separator, false);
        $separator->show();
        $box2 =& new GtkVBox(false, 10);
        $box2->set_border_width(10);
        $box1->pack_start($box2, false);
        $box2->show();
        $button =& new GtkButton('close');
        $button->connect('clicked', 'close_window');
        $box2->pack_start($button);
        $button->set_flags(GTK_CAN_DEFAULT);
        $button->grab_default();
        $button->show();
    }
    if ($windows['pixmap']->flags() & GTK_VISIBLE) {
        $windows['pixmap']->hide();
    } else {
        $windows['pixmap']->show();
    }
}