How to create a button with a icon inside ?

From: Date: Mon, 09 Jul 2001 03:07:21 +0000
Subject: How to create a button with a icon inside ?
Groups: php.gtk 
Request: Send a blank email to php-gtk+get-2098@lists.php.net to get a copy of this message
Thanks to Rich & Steph ! This board really have a good people ! Those are the few first i made for imediate use: <? if(strtoupper(substr(PHP_OS,0,3))=='WIN') dl('php_gtk.dll'); else dl('php_gtk.so'); function closeWindow($widget){$window=$widget->get_toplevel();$window->destroy();} function shutdown(){Gtk::main_quit();} $frstArray=array( "13 13 2 1", " c None s None", "X c black", " ", " ", " X X ", " X XX ", " X XXX ", " X XXXX ", " X XXXXX ", " X XXXX ", " X XXX ", " X XX ", " X X ", " ", " ", ); $prevArray=array( "13 13 2 1", " c None s None", "X c black", " ", " ", " X ", " XX ", " XXX ", " XXXX ", " XXXXX ", " XXXX ", " XXX ", " XX ", " X ", " ", " ", ); $nextArray=array( "13 13 2 1", " c none s none", "X c black", " ", " ", " X ", " XX ", " XXX ", " XXXX ", " XXXXX ", " XXXX ", " XXX ", " XX ", " X ", " ", " ", ); $lastArray=array( "13 13 2 1", " c none s none", "X c black", " ", " ", " X X ", " XX X ", " XXX X ", " XXXX X ", " XXXXX X ", " XXXX X ", " XXX X ", " XX X ", " X X ", " ", ); $newArray=array( "13 13 3 1", " c none s none", "O c white", "X c #404040", " ", " ", " XXXXX ", " XXOOOX ", " XXXOOOX ", " XOOOOOX ", " XOOOOOX ", " XOOOOOX ", " XOOOOOX ", " XOOOOOX ", " XXXXXXX ", " ", " ", ); $disArray=array( "13 13 2 1", " c none s none", "X c brown", " ", " ", " XXX ", " XXX XXX ", " XX XX ", " XX XX ", " XX XX ", " XX XX XX ", " XXXX ", " XXX ", " XXXXX ", " ", " ", ); $wrtArray=array( "13 13 4 1", " c none s none", "O c white", "@ c #008000", "X c black", " ", " @ ", " @ ", " @@ ", " @@ ", " @@ ", " @ @@ ", " @@ @@ ", " @@@@ ", " @@ ", " @ ", " ", " ", ); $delArray=array( "13 13 4 1", " c none s none", "@ c #800000", "O c white", "X c black", " ", " @ ", " @@ ", " @ @@ ", " @@@ @@ ", " @@@@@ ", " @@@ ", " @@@@ ", " @@ @@ ", " @@ @@ ", " @ ", " ", " ", ); $fltArray=array( "13 13 4 1", " c none s none", "C c black", "O c #8080FF", "X c black", " ", " ", " XXX ", " XOOOX ", " XOOOOOX ", " XOOOOOX ", " XOOOX ", " XXXXX ", " XXX ", " XXX ", " XX ", " ", " ", ); $endArray=array( "13 13 3 1", " c none s none", "O c #C00000", "X c black", " ", " ", " XXXXXXX ", " XOOOOOX ", " XOOOOOX ", " XOOOOOX ", " XOOOXOX ", " XOOOOOX ", " XOOOOOX ", " XOOOOOX ", " XXXXXXXXX ", " ", " ", ); $window = &new GtkWindow(); $window->set_title((string)utf8_encode('Graphical Buttons')); $window->realize(); $gdkWindow = $window->window; $transparent=&new GdkColor(0,0,0); list($frstXpm,$frstMask)=Gdk::pixmap_create_from_xpm_d($gdkWindow,$transparent,$frstArray); list($prevXpm,$prevMask)=Gdk::pixmap_create_from_xpm_d($gdkWindow,$transparent,$prevArray); list($nextXpm,$nextMask)=Gdk::pixmap_create_from_xpm_d($gdkWindow,$transparent,$nextArray); list($lastXpm,$lastMask)=Gdk::pixmap_create_from_xpm_d($gdkWindow,$transparent,$lastArray); list($newXpm,$newMask) =Gdk::pixmap_create_from_xpm_d($gdkWindow,$transparent,$newArray); list($disXpm,$disMask) =Gdk::pixmap_create_from_xpm_d($gdkWindow,$transparent,$disArray); list($wrtXpm,$wrtMask) =Gdk::pixmap_create_from_xpm_d($gdkWindow,$transparent,$wrtArray); list($delXpm,$delMask) =Gdk::pixmap_create_from_xpm_d($gdkWindow,$transparent,$delArray); list($fltXpm,$fltMask) =Gdk::pixmap_create_from_xpm_d($gdkWindow,$transparent,$fltArray); list($endXpm,$endMask) =Gdk::pixmap_create_from_xpm_d($gdkWindow,$transparent,$endArray); $frstIcon = &new GtkPixmap($frstXpm,$frstMask); $prevIcon = &new GtkPixmap($prevXpm,$prevMask); $nextIcon = &new GtkPixmap($nextXpm,$nextMask); $lastIcon = &new GtkPixmap($lastXpm,$lastMask); $newIcon = &new GtkPixmap($newXpm,$newMask); $disIcon = &new GtkPixmap($disXpm,$disMask); $wrtIcon = &new GtkPixmap($wrtXpm,$wrtMask); $delIcon = &new GtkPixmap($delXpm,$delMask); $fltIcon = &new GtkPixmap($fltXpm,$fltMask); $endIcon = &new GtkPixmap($endXpm,$endMask); $hBox = &new GtkHBox(); $window->add($hBox); $hBox->show(); $frstButton = &new GtkButton(); $frstButton->add($frstIcon); $hBox->pack_start($frstButton); $frstButton->show(); $prevButton = &new GtkButton(); $prevButton->add($prevIcon); $hBox->pack_start($prevButton); $prevButton->show(); $nextButton = &new GtkButton(); $nextButton->add($nextIcon); $hBox->pack_start($nextButton); $nextButton->show(); $lastButton = &new GtkButton(); $lastButton->add($lastIcon); $hBox->pack_start($lastButton); $lastButton->show(); $newButton = &new GtkButton(); $newButton->add($newIcon); $hBox->pack_start($newButton); $newButton->show(); $disButton = &new GtkButton(); $disButton->add($disIcon); $hBox->pack_start($disButton); $disButton->show(); $wrtButton = &new GtkButton(); $wrtButton->add($wrtIcon); $hBox->pack_start($wrtButton); $wrtButton->show(); $delButton = &new GtkButton(); $delButton->add($delIcon); $hBox->pack_start($delButton); $delButton->show(); $fltButton = &new GtkButton(); $fltButton->add($fltIcon); $hBox->pack_start($fltButton); $fltButton->show(); $endButton = &new GtkButton(); $endButton->add($endIcon); $hBox->pack_start($endButton); $endButton->show(); $window->show_all(); Gtk::main(); ?>

« previous php.gtk (#2098) next »