Public feed #598373

Marc Quinton

public php v1 · immutable
Raw Edit
·published 2007-07-01 08:44 UTC
rendered paste body
<?phperror_reporting(E_ALL);# author Marc Quinton ; licence LGPL.# # this code is inspired from kksoo site:  http://www.kksou.com/php-gtk2/articles/create-a-round-button---Part-1.php# this one is fully object oriented and easy to override#class RoundButton extends GtkEventBox{	protected $image;	protected $pixbuf;	protected $pixmap;	protected $mask;	public function __construct($image, $visible=false){		parent::__construct();		$this->image = $image;		$this->pixbuf = GdkPixbuf::new_from_file($image);		list($this->pixmap, $this->mask) = $this->pixbuf->render_pixmap_and_mask(255);		$style = $this->get_style();		$style = $style->copy();		$style->bg_pixmap[Gtk::STATE_NORMAL] = $this->pixmap;		$this->set_style($style);		$x = $y = 0;  # should take care of $this->allocation and $image size.		$this->shape_combine_mask($this->mask, $x, $y);		$this->connect('button-press-event', array($this, 'on_button_press'));		$this->set_visible_window($visible);		$this->show_all();	}	public function on_button_press(){		echo "button_press\n";	}}# you can use popup window and make button fully transparent ; but there is some trick to correct.# this will give you a fully rounded window without any decoration.# $window = new GtkWindow(Gtk::WINDOW_POPUP);$window = new GtkWindow();$window->set_size_request(90,90);$window->set_position(Gtk::WIN_POS_CENTER);$window->connect_simple('destroy', array('Gtk','main_quit'));$window->add( $b = new RoundButton('button_play1.png'));$window->show_all();Gtk::main();?>