Re: PHP-GTK 2 update
| From: | Ivan Rodriguez | Date: | Mon, 07 Mar 2005 07:17:42 +0000 |
| Subject: | Re: PHP-GTK 2 update | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-5594@lists.php.net to get a copy of this message | ||
Andrei!!! This is incredible, an excellent work, as soon as it leaves
the stable version Php-gtk will be the boom of the technology of
development of desktop applications.
Congratulations :-)
On Sat, 5 Mar 2005 14:29:58 -0800, Andrei Zmievski
<andrei@gravitonic.com> wrote:
> For those of you wondering, the current CVS version of PHP-GTK can run
> fairly complex scripts, such as this one.
>
> <?php
>
> error_reporting(E_ALL);
>
> if ($argc < 2)
> die("\nUsage: php -q gdk_pixbuf.php <imagefile>\n\n");
>
> $image_file = $argv[1];
>
> $window = new GtkWindow();
> $window->set_border_width(5);
> $window->set_title('GdkPixbuf example');
> $window->set_resizable(false);
> $window->connect_object('destroy', array('gtk', 'main_quit'));
>
> try {
> $pixbuf = GdkPixbuf::new_from_file($image_file);
> } catch (PhpGtkGErrorException $e) {
> die($e->message . "\n");
> }
>
> $font = new GdkFont("-*-helvetica-bold-r-*-*-*-120-*-*-*-*-*-*");
> $extents = $font->extents($image_file);
>
> $area = new GtkDrawingArea();
> $area->set_size_request($pixbuf->get_width(), $pixbuf->get_height());
> $frame = new GtkFrame();
> $frame->add($area);
> $frame->set_shadow_type(Gtk::SHADOW_IN);
> $window->add($frame);
>
> $layout = $window->create_pango_layout(basename($image_file) .
>
> "\n\xd0\x90\xd0\xbd\xd0\xb4\xd1\x80\xd0\xb5\xd0\xb9");
> $fontdesc = new PangoFontDescription('Arial,Helvetica 14');
> $layout->set_font_description($fontdesc);
> list(, $extents) = $layout->get_pixel_extents();
>
> $area->connect('expose_event', 'expose_event', $pixbuf, $layout,
> $extents);
>
> $window->show_all();
>
> gtk::main();
>
> function expose_event($area, $event, $pixbuf, $layout, $extents)
> {
> $area->window->draw_pixbuf($area->style->fg_gc[Gtk::STATE_NORMAL],
> $pixbuf,
> $event->area->x,
> $event->area->y,
> $event->area->x,
> $event->area->y);
>
> if ($event->area->x < $extents[0] + 3 &&
> $event->area->y < $extents[1] + 3) {
> $area->window->draw_layout($area->style->white_gc, 3, 3, $layout);
> $area->window->draw_layout($area->style->black_gc, 2, 2, $layout);
> }
> }
>
> ?>
>
> -Andrei
>
> --
> PHP-GTK General Mailing List (http://gtk.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>