Re: [php-gtk-cvs] cvs: php-gtk /demos scribble.php

From: Date: Thu, 20 Oct 2005 16:29:51 +0000
Subject: Re: [php-gtk-cvs] cvs: php-gtk /demos scribble.php
References: 1  Groups: php.gtk.cvs 
Request: Send a blank email to php-gtk-cvs+get-1931@lists.php.net to get a copy of this message
That's what I was trying to avoid... Any idea why it crashes on exit? ----- Original Message ----- From: "Christian Weiske" <cweiske@php.net> To: <php-gtk-cvs@lists.php.net> Sent: Thursday, October 20, 2005 5:27 PM Subject: [php-gtk-cvs] cvs: php-gtk /demos scribble.php > cweiske Thu Oct 20 12:27:58 2005 EDT > > Added files: > /php-gtk/demos scribble.php > Log: > Steph's scribble adaption for the framework > Beware: Crashes on exit > > > > > http://cvs.php.net/co.php/php-gtk/demos/scribble.php?r=1.1&p=1 > Index: php-gtk/demos/scribble.php > +++ php-gtk/demos/scribble.php > <?php > /** > * Scribble demo - simple painting with your mouse > */ > > class Scribble extends GtkWindow > { > protected $size_group = null; > protected $pixmap = null; > > > function __construct($parent = null) > { > parent::__construct(); > > if (@$GLOBALS['framework']) { > return; > } > > if ($parent) > $this->set_screen($parent->get_screen()); > else > $this->connect_simple('destroy', array('gtk', > 'main_quit')); > > $this->set_title(__CLASS__); > $this->set_position(Gtk::WIN_POS_CENTER); > $this->set_default_size(-1, -1); > $this->set_border_width(8); > > $this->add($this->__create_box()); > $this->show_all(); > }//function __construct($parent = null) > > > > function __create_box() > { > $vbox = new GtkVBox(); > $vbox->show(); > > $drawing_area = new GtkDrawingArea(); > $drawing_area->set_size_request(300, 300); > $vbox->pack_start($drawing_area); > // $drawing_area->realize(); > > $drawing_area->connect('expose_event' , array($this, 'expose_event')); > $drawing_area->connect('configure_event' , array($this, 'configure_event')); > > $drawing_area->connect('motion_notify_event', array($this, 'motion_notify_event')); > $drawing_area->connect('button_press_event' , array($this, 'button_press_event')); > > $drawing_area->set_events(Gdk::EXPOSURE_MASK > | Gdk::LEAVE_NOTIFY_MASK > | Gdk::BUTTON_PRESS_MASK > | Gdk::POINTER_MOTION_MASK > | Gdk::POINTER_MOTION_HINT_MASK); > > return $vbox; > }//function __create_box() > > > > function configure_event($widget, $event) > { > $this->pixmap = new GdkPixmap($widget->window, > $widget->allocation->width, > $widget->allocation->height, > -1); > $this->pixmap->draw_rectangle($widget->style->white_gc, > true, 0, 0, > $widget->allocation->width, > $widget->allocation->height); > return true; > } > > > function expose_event($widget, $event) > { > $widget->window->draw_drawable($widget->style->fg_gc[$widget->state], > $this->pixmap, > $event->area->x, $event->area->y, > $event->area->x, $event->area->y, > $event->area->width, $event->area->height); > > return false; > } > > > > function button_press_event($widget, $event) > { > if ($event->button == 1 && $this->pixmap) { > $this->draw_brush($widget, (int)$event->x, (int)$event->y); > } > > return true; > } > > > > function motion_notify_event($widget, $event) > { > $window = $event->window; > $pointer = $window->get_pointer(); > $x = $pointer[0]; > $y = $pointer[1]; > $state = $pointer[2]; > > if (($state & Gdk::BUTTON1_MASK) && $this->pixmap) { > $this->draw_brush($widget, $x, $y); > } > > return true; > } > > > > function draw_brush($widget, $x, $y) > { > $this->pixmap->draw_arc($widget->style->black_gc, true, $x - 4, $y - 4, 8, 8, 0, 64 * 360); > $widget->queue_draw_area($x - 4, $y - 4, 8, 8); > } > }//class Scribble extends GtkWindow > > > $GLOBALS['class'] = 'Scribble'; > $GLOBALS['description'] = "Scribble lets you draw paintings with your mouse"; > > if (!@$GLOBALS['framework']) { > new Scribble(); > Gtk::main(); > } > ?> > > -- > PHP-GTK CVS Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.gtk.cvs (#1931) next »