sábado, 26 de maio de 2007

Extending classes to develop faster with PHP-GTK

Sometimes we need to have some control on the code, in way to implement some new features.
Extending classes is a nice trick to build personalized and complex applications.
Programming oriented to objects (OOP), ebables a lot of possibilities .
Extend an class is a technic that allows to get all properties of main class and add some new ones.
On PHP you do it using the reserved word extends.
On this article i will teack you how to create some objects by extending the class GtkFixed, to create a kind of Tform like those ones we work on Java.
I will just implement one or two methods , but you can create any as you need.

The technic on my script is to pass and object type by parameter, as the example above shows.
public function setObject(GtkWidget $object,$name,...

Everitime you call this method all you need to do is to pass an object instance , as GtkButton, GtkEntry ,....
The code below shows how to build class.
Follows a short example showinf how to this class works


Sem comentários: