[Gambas-user] GB3 Custom controls

Bruce Bruen bbruen at ...2308...
Sun Nov 13 09:48:22 CET 2011


Hi Fabien,

Thanks for your input, responses inline

regards
Bruce

On Sun, 2011-11-13 at 08:07 +0100, Fabien Bodard wrote:

> 2011/11/13 Bruce Bruen <bbruen at ...2308...>:
> > On Sun, 2011-11-13 at 03:01 +0100, Benoît Minisini wrote:
> >
> >> Hi Bruce,
> >>
> >> I took at a look at your code. You made a big mistake by making your
> >> controls inherit UserContainer, whereas they are not containers. Which
> >> makes the IDE mad when you want to use _DrawWith or some other properties.
> >
> >
> > Yes, that makes sense.
> >
> >
> >> They must inherit UserControl.
> >
> >
> > I used UserContainer in gb2 for some reason lost in the mists of time, I
> > think it was to do with a "handy" property in the UserContainer that was
> > not in UserControl.
> >
> > I thought that maybe the reason has "gone away" now so I retried the
> > LabelTextBox inheriting UserControl.  However, I have struck a problem -
> > I can't seem to restrict the Height value if my control is used inside a
> > container that enforces it's own height.  For example, if the
> > LabelTextBox is inside a HBox it's height will expand to the HBox
> > height.  I realise that this is what is "supposed to happen" but it's
> > not what I "want to happen".
> >
> > I have attached two screen shots showing my problem.
> well it's not a problem from gambas :)
> 
> you must add more containers to achieve what you want to do :
> 
> HBox
> |__ VBox(expanded)
> |   |__ hBox
> |   |   |__ Label
> |   |   |__ SpecialTexBox(expanded)
> |   |__ Panel(expanded)
> |__ Picture
> 
> 
> this is how gambas containers works

:-) Yes, I know! and this is what I am trying to subvert.  I see what
you are saying about the expandable panel.  In fact the custom control
includes the hBox, Label and TextBox.  So the (failing) model is:
HBox
|___LabelTextBox
|___Picture

The desire is to constrain the height of the LabelTextBox so no matter
what the custom control parent's Arrangement is, the LabelTextBox.Height
is immutable.  That is the requirement, pure and simple.  

> >
> > I don't know why my intentions work when inheriting UserContainer and
> > not when inheriting UserControl.  I'll look into this further this week
> > to see if I can characterise it properly.
> your widget are usercontrol ... not containers ... that have no need
> to work like a panel or anything on this ype
> 

Funny thing is, the requirement is met when LabelTextBox inherits from
UserContainer, but not when it inherits from UserControl.  This is what
I am trying to understand.

> 
> >
> >> Or maybe I didn't understand what you
> >> want to achieve at all!
> >
> >
> > The intent is to give my two volunteer designers/coders with
> > "simplified" controls that:
> > - behave in terms of "navigation" the same way in both QT4 and GTK+
> that is the work of benoit and gambas

Not in this case! :-) I want it to work "my way" not the gambas way!  In
other discussions with Benoît, we have come to an understanding that
some of the ways that GTK+ and QT4 work are mutually exclusive as far as
Gambas is concerned,  this is not a problem for me.  I am working with a
captive set of users on a thoroughbred training management system and
the "way" that form navigation will work for this is around 90% my
problem and not Benoît's.

> > - provide some extra properties (e.g. the label) that can be set in the
> > IDE and thus reduce both design and coding time
> you have just to export it and setup the _properties constant

Yep, that's what I'm doing.

> 
> > - subsume the various native events (Activate, Click, Change etc) into a
> > single "Changed" event that is only raised when the user has finished
> > altering the value content of the controls
> ok
> > - ( and at stage two), to build some "data aware" controls - like
> > gb.db.form - but which will work with some standardised "business
> > object" classes.
> ??? don't understand( that is already what gb.db.form do ... no ?)

Yes, it does for the native database objects (basically Result) but what
I am talking about are my own classes that provide much more extended
functionality than the simple table oriented native classes.  For
example, a horse may be entered into one or several events in a trials
meeting for some reason such as to check its' "barrier manners", I have
a business class for its' behaviour over the whole day.  The database
tables involved are horse, meeting, event, performance.  These are all
combined into a single object that will have the horse detail, the
meeting detail and a collection of event+performance details.  These are
not simple table/row relationships but the "whole view" of the horse's
attitude on a particular day.

So the form using these objects will have say a bunch of textboxes and
say a gridview.  These controls will take their values from an object of
that class expressed in the same way that gb.db.form does, i.e instead
of a DataSource container there will be a DataObject container that uses
the class object instead of a native db object.  Is that clearer?

I have done this in gb2 and it works well.  But the code is extremely
messy and I would not care to share it with anyone :-) .   I am taking
advantage of the move to gb3 to clean up (and extend) the whole thing.



More information about the User mailing list