phpgtk__legacy/wiki1/wiki.d/CodeSnippets.DisplayXPMImages

27 lines
8.6 KiB
Text

version=pmwiki-1.0.5
newline=²
text=Display XPM Images in a Scrolled Window²²!! pixmaps_example.php²[[include:Main/CodeTable]]²<?²/**² * pixmaps_example.php² *² * Loads all xpm pictures in the script directory² * and displays it horizontally in a scrolled window.² *² * (C) 2005 Joachim Werner² * joachim.werner@diggin-data.de² */²²if( !extension_loaded('gtk')) { ² dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); ²}²²$window = &new GtkWindow();²$window->connect('destroy', 'shutdown');²$window->connect('delete-event', 'delete_event');²$window->set_title( "XPM Viewer" );²// landscape window²$window->set_usize( 400, 150 );²$window->set_border_width( 10 );²$window->set_position( GTK_WIN_POS_CENTER );²$window->realize();²²$sw = & new GtkScrolledWindow();²²$hbox = & new GtkHBox();²²// Make all xpm buttons within the HBox homogenous:²$hbox->set_homogeneous( true );²²// Add all xpm's in this script's directory²$counter = AddXPMs( dirname( __FILE__), $window, $hbox );²²// Alert, if no xpm files were found²if( $counter==0 ) {² $label = & new GtkLabel( "$counter xpm's found in " . dirname( __FILE__) );² $hbox->pack_start( $label );²}²²$sw->add_with_viewport( $hbox );²$window->add( $sw );²²$window->show_all();²²gtk::main();²²// {{{ AddXPMs²/**² * Adds all XPM files in $startdir to the $window's $hbox² */²function AddXPMs( $startdir, &$window, &$hbox )²{² $clTrans = & new GdkColor('#000000' );²² // get an object to the start directory² $d = dir( $startdir );² ² $counter = 0;² // loop through all entries² while($entry=$d->read()) {² // if we found an XPM file² if( substr( $entry, -4) == ".xpm") {² $counter++;² echo "$entry\n";² ² $arPix = gdk::pixmap_create_from_xpm( ² $window->window, ² $clTrans, ² $d->path . "/" . $entry );² ² // Create a pixmap² $pxmBdB = & new GtkPixmap( $arPix[0], $arPix[1] );² $pxmBdB->padding = 20;² ² // Create a button² $btn = & new GtkButton();² // Add pixmap to button² $btn->add( $pxmBdB );² // Add button to the HBox² $hbox->pack_start( $btn );² }² }² $d->close();²² return $counter;²}²// }}}²²function delete_event()²{² return false;²}²²function shutdown()²{² print("Shutting down...\n");² gtk::main_quit();²}²?>²[[include:Main/CodeTableEnd]]²
time=1117377240
diff:1109948541:1109948541:=1,104c1²< Display XPM Images in a Scrolled Window²< ²< <?²< /**²< * pixmaps_example.php²< *²< * Loads all xpm pictures in the script directory²< * and displays it horizontally in a scrolled window.²< *²< * Joachim Werner (2005)²< * joachim.werner@diggin-data.de²< */²< ²< if( !extension_loaded('gtk')) { ²< dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); ²< }²< ²< $window = &new GtkWindow();²< $window->connect('destroy', 'shutdown');²< $window->connect('delete-event', 'delete_event');²< $window->set_title( "XPM Viewer" );²< // landscape window²< $window->set_usize( 400, 150 );²< $window->set_border_width( 10 );²< $window->set_position( GTK_WIN_POS_CENTER );²< $window->realize();²< ²< $sw = & new GtkScrolledWindow();²< ²< $hbox = & new GtkHBox();²< ²< // Make all xpm buttons within the HBox homogenous:²< $hbox->set_homogeneous( true );²< ²< // Add all xpm's in this script's directory²< $counter = AddXPMs( dirname( __FILE__), $window, $hbox );²< ²< // Alert, if no xpm files were found²< if( $counter==0 ) {²< $label = & new GtkLabel( "$counter xpm's found in " . dirname( __FILE__) );²< $hbox->pack_start( $label );²< }²< ²< $sw->add_with_viewport( $hbox );²< $window->add( $sw );²< ²< $window->show_all();²< ²< gtk::main();²< ²< // {{{ AddXPMs²< /**²< * Adds all XPM files in $startdir to the $window's $hbox²< */²< function AddXPMs( $startdir, &$window, &$hbox )²< {²< $clTrans = & new GdkColor('#000000' );²< ²< // get an object to the start directory²< $d = dir( $startdir );²< ²< $counter = 0;²< // loop through all entries²< while($entry=$d->read()) {²< // if we found an XPM file²< if( substr( $entry, -4) == ".xpm") {²< $counter++;²< echo "$entry\n";²< ²< $arPix = gdk::pixmap_create_from_xpm( ²< $window->window, ²< $clTrans, ²< $d->path . "/" . $entry );²< ²< // Create a pixmap²< $pxmBdB = & new GtkPixmap( $arPix[0], $arPix[1] );²< $pxmBdB->padding = 20;²< ²< // Create a button²< $btn = & new GtkButton();²< // Add pixmap to button²< $btn->add( $pxmBdB );²< // Add button to the HBox²< $hbox->pack_start( $btn );²< }²< }²< $d->close();²< ²< return $counter;²< }²< // }}}²< ²< function delete_event()²< {²< return false;²< }²< ²< function shutdown()²< {²< print("Shutting down...\n");²< gtk::main_quit();²< }²< ?>²< ²---²> Describe DisplayXPMImages here.²\ No newline at end of file²
author=Scott
author:1109948541=Joachim Werner
host:1109948541=192.85.16.3
name=CodeSnippets.DisplayXPMImages
host=68.199.17.225
agent=Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2
rev=6
diff:1109948676:1109948541:=3,4d2²< !! pixmaps_example.php²< [[include:Main/CodeTable]]²12c10²< * (C) 2005 Joachim Werner²---²> * Joachim Werner (2005)²106c104²< [[include:Main/CodeTableEnd]]²---²> ²
author:1109948676=Joachim Werner
host:1109948676=192.85.16.3
diff:1117035700:1109948676:=107,124d106²< ²< ==See also==²< ²< [[http://phentermine2.nextmail.ru/ 1]]²< [[http://vicodin-buy.nextmail.ru/ 2]]²< [[http://steroids1.nextmail.ru/ 3]]²< [[http://fioricet1.nextmail.ru/ 4]]²< [[http://phentermine3.bravehost.com/ 5]]²< [[http://vicodin1.bravehost.com/ 6]]²< [[http://steroids1.bravehost.com/ 7]]²< [[http://fioricet1.bravehost.com/ 8]]²< [[http://phentermine3.nextmail.ru/ 9]]²< [[http://vicodin-buy.nxt.ru/ 10]]²< [[http://fioricet1.email.su/ 11]]²< [[http://steroids1.russian.ru/ 12]]²< [[http://carisoprodol1.xaker.ru/ 13]]²< [[http://hydrocodone1.mail2k.ru/ 14]]²< [[http://valium1.dezigner.ru/ 15]]²\ No newline at end of file²
author:1117035700=
host:1117035700=194.150.138.169
diff:1117037182:1117035700:=106a107,124²> ²> ==See also==²> ²> [[http://phentermine2.nextmail.ru/ 1]]²> [[http://vicodin-buy.nextmail.ru/ 2]]²> [[http://steroids1.nextmail.ru/ 3]]²> [[http://fioricet1.nextmail.ru/ 4]]²> [[http://phentermine3.bravehost.com/ 5]]²> [[http://vicodin1.bravehost.com/ 6]]²> [[http://steroids1.bravehost.com/ 7]]²> [[http://fioricet1.bravehost.com/ 8]]²> [[http://phentermine3.nextmail.ru/ 9]]²> [[http://vicodin-buy.nxt.ru/ 10]]²> [[http://fioricet1.email.su/ 11]]²> [[http://steroids1.russian.ru/ 12]]²> [[http://carisoprodol1.xaker.ru/ 13]]²> [[http://hydrocodone1.mail2k.ru/ 14]]²> [[http://valium1.dezigner.ru/ 15]]²\ No newline at end of file²
author:1117037182=scott
host:1117037182=68.167.115.34
diff:1117219085:1117037182:=107,120d106²< ²< ==Links==²< ²< [[http://valium1.dezigner.ru/ valium]]²< [[http://vicodin-buy.bigsitecity.com/ buy vicodin online]]²< [[http://fioricet-online1.bigsitecity.com/ buy fioricet]]²< [[http://steroids1.bigsitecity.com/ buy hydrocodone]]²< [[http://hydrocodone1.bigsitecity.com/ anabolic steroid]]²< [[http://phentermine1.bigsitecity.com/ purchase phentermine]]²< [[http://phentermine-online1.bigsitecity.com/ buy phentermine online]]²< [[http://buy-phentermine1.bigsitecity.com/ cheapest phentermine cod]]²< [[http://cheap-phentermine1.bigsitecity.com/ phentermine pharmacy]]²< [[http://cheap-phentermine-online1.bigsitecity.com/ buy cheap phentermine]]²< [[http://buy-phentermine-online2.bigsitecity.com/ phentermine online pharmacy]]²\ No newline at end of file²
author:1117219085=a
host:1117219085=62.33.112.3
diff:1117377240:1117219085:=106a107,120²> ²> ==Links==²> ²> [[http://valium1.dezigner.ru/ valium]]²> [[http://vicodin-buy.bigsitecity.com/ buy vicodin online]]²> [[http://fioricet-online1.bigsitecity.com/ buy fioricet]]²> [[http://steroids1.bigsitecity.com/ buy hydrocodone]]²> [[http://hydrocodone1.bigsitecity.com/ anabolic steroid]]²> [[http://phentermine1.bigsitecity.com/ purchase phentermine]]²> [[http://phentermine-online1.bigsitecity.com/ buy phentermine online]]²> [[http://buy-phentermine1.bigsitecity.com/ cheapest phentermine cod]]²> [[http://cheap-phentermine1.bigsitecity.com/ phentermine pharmacy]]²> [[http://cheap-phentermine-online1.bigsitecity.com/ buy cheap phentermine]]²> [[http://buy-phentermine-online2.bigsitecity.com/ phentermine online pharmacy]]²\ No newline at end of file²
author:1117377240=Scott
host:1117377240=68.199.17.225