Re: GtkDrawingArea in POO HOWTO?

From: Date: Mon, 09 Feb 2004 08:02:56 +0000
Subject: Re: GtkDrawingArea in POO HOWTO?
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-4386@lists.php.net to get a copy of this message
function expose_event() { //var_dump($area); var_dump($this->area); $area = $this->area; //$this->area = $area; gdk::draw_pixmap($area->window, $area->style->fg_gc[$area->state], $this->bg_pixmap, 0, 0, 0, 0, $this->width, $this->height); return false; } ----- Original Message ----- From: "Decapode Azur" <blue_prawn@tuxfamily.org> To: <php-gtk-general@lists.php.net> Sent: Sunday, February 08, 2004 7:18 PM Subject: [PHP-GTK] GtkDrawingArea in POO HOWTO? > hi all, > > I'm trying to convert this simple script in POO. > You can find my try (that does not work) below at the end of the mail. > Could someone tell me what is wrong? > > =============================== > #! /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 = './images/background_B03.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; > } > ?> > =============================== > #! /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); > > //$area = $this->area; > //$this->area = $area; > > gdk::draw_pixmap($area->window, > $area->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 = './images/background_B03.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; > } > } > > // vim:cindent sw=4 > ?> > =============================== > > -- > Thanks in advance, > Cheers > > -- > PHP-GTK General Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

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