Re: GtkDrawingArea in OOP HOWTO?

From: Date: Thu, 19 Feb 2004 18:09:38 +0000
Subject: Re: GtkDrawingArea in OOP HOWTO?
References: 1 2 3  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-4409@lists.php.net to get a copy of this message
> you can't pass the gdkwindow like this, > you must do something like that: > > $gdkwindow = $area->window ; > i think it's the same for the style $style = $area->style (not sure for > this one ck=heck in manual if doesn't work) > and then pass those variable to gdk::draw_pixmap. > > Does it work now? No, this does not work better. See the error message : $ ./test-oop-draw_pixmap.1.php Warning: draw_pixmap() expects the drawable to be GdkWindow, GdkPixmap, or GdkBitmap in /home/blue_prawn/test-oop-draw_pixmap.1.php on line 52 =============================== #! /usr/bin/php -q <?php dl('php_gtk.'. PHP_SHLIB_SUFFIX); $cl = new cl(); class cl { var $width; var $height; var $area; var $bg_pixmap; function cl() { $this->width = 600; $this->height = 450; $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect('delete_event', array($this, 'delete_event')); $window->connect('destroy', array($this, 'destroy')); $this->area = &new GtkDrawingArea(); $this->area->size($this->width, $this->height); $this->area->connect('configure_event', array($this, 'configure_event')); $this->area->connect('expose_event', array($this, 'expose_event')); $this->area->show(); $window->add($this->area); $window->show(); gtk::main(); } function delete_event() { return false; } function destroy() { Gtk::main_quit(); } function expose_event($area) { //function expose_event() { //var_dump($area); //var_dump($this->area); $gdkwindow = $this->area->window; //$this->area = $area; $style = $this->area->style; gdk::draw_pixmap($gdkwindow, $style->fg_gc[$area->state], $this->bg_pixmap, 0, 0, 0, 0, $this->width, $this->height); /* gdk::draw_pixmap($this->area->window, $this->area->style->fg_gc[$area->state], $this->bg_pixmap, 0, 0, 0, 0, $this->width, $this->height); */ return false; } function configure_event() { $filename = './image.xpm'; $transparent = &new GdkColor(1, 0, 0); list($this->bg_pixmap, $mask) = Gdk::pixmap_create_from_xpm($this->area->window, $transparent, $filename); get_class_methods($this->bg_pixmap); return true; } } ?> =============================== Original without OOP : #! /usr/bin/php -q <?php dl('php_gtk.'. PHP_SHLIB_SUFFIX); function delete_event() { return false; } function destroy() { Gtk::main_quit(); } $width = 600; $height = 450; $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect('delete_event', 'delete_event'); $window->connect('destroy', 'destroy'); $area = &new GtkDrawingArea(); $area->size($width, $height); $area->connect('configure_event', 'configure_event'); $area->connect('expose_event', 'expose_event'); $area->show(); $window->add($area); $window->show(); gtk::main(); function expose_event($area) { global $bg_pixmap, $width, $height; global $x, $y; gdk::draw_pixmap($area->window, $area->style->fg_gc[$area->state], $bg_pixmap, 0, 0, 0, 0, $width, $height); return false; } function configure_event() { global $bg_pixmap, $area; $filename = './image.xpm'; $transparent = &new GdkColor(1, 0, 0); list($bg_pixmap, $mask) = Gdk::pixmap_create_from_xpm($area->window, $transparent, $filename); get_class_methods($bg_pixmap); return true; } ?> ===============================

« previous php.gtk.general (#4409) next »