Home  |  Linux  | Mysql  | PHP  | XML
From:Elizabeth M Smith Date:Fri Jun 20 06:35:03 2008
Subject:Re: Re[PHP-GTK] defining base class functions?
kksou wrote:
> 
> Benjamin Smith wrote:
>> Is there a way (PHP-GTK1) to redefine a base class method? Specifically, I 
>> need to change set_usize() so that the values for X and Y can be 
>> recalculated.
>>
> 
> Hi Ben,
> 
> Don't think PHP-GTK1 or PHP-GTK2 allows you to redefine a base class or
> override an existing class method.
> 
That's not exactly true - in PHP-GTK2 you can extend a class and then
override a call in that class with your own version.

For example, you could extend GtkWindow and create a method

class MyWindow extends GtkWindow {
public method size($x, $y) {
// do something to $x
$x = $x + 5;
// do something to $y
if ($y > 10) {
$y = 5;
}
// then call the "real" method
return parent::move($x, $y);
}
}

To use this you'd create a window using
$window = new MyWindow();
not
$window = new GtkWindow();

I have no idea if this works in GTK1... I'd have to wonder why you're
using it at all.

Thanks,
Elizabeth
Navigate in group php.gtk.general at sever news.php.net
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by Zareef Ahmed
Powered By PHP Consultants