[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TestStyleColor


On Fri, 9 Jan 2026 at 15:31, CD <dessere.claude@xxxxxx> wrote:

>
>
> On Wed, 7 Jan 2026 at 16:18, Benoît Minisini <
> benoit.minisini@xxxxxxxxxxxxxxxx> wrote:
>
> Le 07/01/2026 à 17:04, Bruce Steers a écrit :
> >
> > I think a better description of what Style.color does is needed. the
> > wiki just says "Return or set the highlight color of the styled borders.
> > "  and it sets much more than borders in my programs, many controls
> > Backgrounds are adjusting to it and it's a bit ugly.
> >
>
> Actually "styled borders" draws inside the borders when 'Style.Flat' is
> true. So the term is not very good in that case!
>
> But the wiki description of 'Style.Color' is exact: that property is
> used when you want to globally higlight the styled borders (and
> backgrounds) with a specific color.
>
> It is used by the IDE for highlighting the interface according to the
> current git branch.
>
> Yes, it is a bit ugly, but it's very useful when you work on tons of
> branchs and projects.
>
> Regards,
>
> --
> Benoît Minisini.
>
>
> Le mercredi 07 janvier 2026 à 18:05 +0000, Bruce Steers a écrit :
>
> Cheers Benoit, yes i figured it out when i read the difference is it
> either uses Paint.Stroke or Paint.Fill , then it all made sense.
>
> I just added a little info to the wiki Style.Color page.
>
> Respects
> BruceS
>
>
>
> Hello,
>
> first thanks for Gambas 3.21.2
>
> I have read the replies you exchanged, Bruces and Benoît.
>
> I added a checkbox for Style.Flat = True or False:
>
> The attached application, in my opinion, does not correspond to what you
> added to the wiki in:
>
> https://gambaswiki.org/wiki/comp/gb.qt4/style/flat
> and
> https://gambaswiki.org/wiki/comp/gb.qt4/style/color
>
> However, now that Style.Flat is True or False, the issue no longer occurs
> with the gb.gtk3 and gb.qt5 components!
>
> It only occurs with gb.qt6.
>
> How is it that with gb.qt6, when the control has focus, the color is not
> applied?
>
> Modified project attached.
>

If you put a Panel in that test program and set it's Border to
Border.Styled you will see what I wrote in the wiki is very true.
When Flat = False only a border is drawn, when Flat = True the whole area
is coloured.

A Panel with Border = Border.Styled automatically uses the Style.class
properly.

Your code on the other hand does not. ;)
You said "based on SwitchButton.class but it's nothing like
SwitchButton.class Draw event @
https://gitlab.com/gambas/gambas/-/blob/master/comp/src/gb.form/.src/Button/SwitchButton.class?ref_type=heads#L68
(for starters you are "setting" properties in a _Draw event (never do
that!) that could cause a Refresh and get you in a loop)

I would suggest that in order to make your own custom SwitchButton just
copy the SwitchButton.class source from
https://gitlab.com/gambas/gambas/-/blob/master/comp/src/gb.form/.src/Button/SwitchButton.class

Call it MySwitchButton.class or something and modify it from there.
Modifying existing sources may help you understand the workings of
Style.class better than trying to make your own.
Benoit's SwitchButton.class knows exactly what it's doing (unlike you and
me lol :D )

Respects
BruceS

References:
Re: TestStyleColorCD <dessere.claude@xxxxxx>