[Gambas-user] Release of gambas 1.9.42
Benoit Minisini
gambas at ...1...
Sat Sep 23 11:01:34 CEST 2006
On Friday 15 September 2006 10:20, Timothy Marshal-Nichols wrote:
> Hello,
>
> A little bug a appears to have crept in with the setting of the
> Form.BackColor property. Possibly also the Form.ForeColor. (Using the gb.qt
> controls.)
>
> I have a couple of projects that use this properties to ensure the
> background color is the same as the form when drawing.
>
> Take the following code:
>
> PUBLIC SUB Timer1_Timer()
> Draw.Begin(ME)
> Draw.FillStyle = Fill.Solid
> Draw.ForeColor = ME.ForeColor
> Draw.FillColor = ME.ForeColor
> Draw.BackColor = ME.ForeColor
> Draw.Rect(10, 10, 210, 210)
> Draw.ForeColor = ME.BackColor
> Draw.FillColor = ME.BackColor
> Draw.BackColor = ME.BackColor
> Draw.Rect(110, 110, 310, 310)
> Draw.End
> END
>
> Using the default values (empty) in the properties toolbox. It now draws
> two squares both are white with a black border.
>
> If you set the Form.BackColor or Form.ForeColor property at design time
> this appears to be set these values correctly. It is just if you use the
> Form.BackColor at its default value.
>
> Thanks
>
> 8-{)} Timothy Marshal-Nichols
> <mailto: timothy.marshal-nichols at ...247...>
>
Actually the previous behaviour was unspecified.
Now if you don't specify any color for Form.Background or Form.Foreground,
they take the special Color.Default value.
But settings Color.Default to Draw.Foreground or Draw.Background sets Black &
White, unless you draw directly on a widget. Then the default colors should
be the colors of the widget.
So if you set Draw.ForeColor = Me.BackColor, and if Me.BackColor =
Color.Default, then you just set Draw.ForeColor to the default color, not to
the real color of Me.BackColor!
When you need the real color, you must use the static properties
Color.Background to get the real color of the default background, and
Color.Foreground for the default foreground.
So to set the form background to the draw foreground, you need to do something
like:
IF ME.Background = Color.Default THEN
Draw.Foreground = Color.Background
ELSE
Draw.Foreground = ME.Background
ENDIF
Regards,
--
Benoit Minisini
More information about the User
mailing list