[Gambas-user] Important design changes
gambas at ...1...
Sat Aug 31 11:39:32 CEST 2002
Hello world !
I'm going to begin the cleaning of the Qt component interface, and I want to
get your opinion.
As you may have noticed :-), many controls contain sub-elements : a Treeview
has nodes, a GridView has cells, etc.
In Visual Basic, controls are ActiveX objects, and they choosed to implement
these sub-elements as ActiveX objects too. But I think following the same
kind of implementation in Gambas is a bad idea.
Creating objects for sub-elements is a significant memory and speed overhead,
(and a significant amount of work for me :-) ).
The life of these objects are very short, because they are mainly used for
accessing sub-elements properties. So, why not generalizing the principle of
"virtual" objects. Maybe have you already dealt with such objects, but
Let's take an example. To access an element of the ListBox, you must do the
following thing in Gambas :
PRINT MyListBox.Current.Text;" is ";
IF NOT MyListBox.Current.Selected THEN PRINT "not ";
But you cannot assign the current item to a variable :
MyObject = MyListBox.Current
-> Bad use of virtual class
MyListBox.Current returns a "virtual object", i.e. an hidden object whose
class is "virtual", i.e. that cannot be instanciated nor assigned.
In fact, this "virtual object" is even not an object : it is just an internal
counter of the ListBox that indicates which element we are going to use.
I want to generalize this principle to every control. For example, at the
moment, you can do the following :
MyNode = MyTreeView["#Key"]
After the change, you won't. Nodes objects will not be created any longer. You
will have to do :
You can imagine the same thing in the GridView :
PRINT MyGridView[X, Y].Text
IMHO, I'm sure that the overhead of accessing nodes by keys, cells by
coordinates, etc. is better than the overhead of creating and managing
In Visual Basic, I have always found that filling a TreeView is very slow. I
thnik that creating a lot of ActiveX objects needs a lot of memory and a lot
of CPU cycles ! So I hope that it will be better in Gambas :-)
At the moment, the Qt component interface is a "bastard" mix of the two
approaches. For example, do not try to remove a Node on a TreeView, having a
reference on the deleted Node ! But accessing the columns and rows properties
of a GridView is made with virtual classes. etc.
Tell me if you have remarks.
mailto:gambas at ...1...
More information about the User