Recent

Author Topic: the TSpeedButton.Font.Color It doesn't work.  (Read 4888 times)

dtamadeEx

  • New Member
  • *
  • Posts: 17
the TSpeedButton.Font.Color It doesn't work.
« on: September 23, 2018, 03:36:13 pm »
Report a bug

Code: Pascal  [Select][+][-]
  1. TSpeedButton.Font.Color
It doesn't work.



Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: the TSpeedButton.Font.Color It doesn't work.
« Reply #1 on: September 23, 2018, 03:51:57 pm »
Just tested it on Lazarus 1.8.4 Linux Gtk2, it works. Tested both on design-time, runtime and by using Object Inspector and code.

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: the TSpeedButton.Font.Color It doesn't work.
« Reply #2 on: September 23, 2018, 04:33:35 pm »
IIRC then on Windows at least the font color of a TSpeedButton is themed (so determined by the OS).
You can turn off themes in Project Options to test it.
(But your program will look ancient then.)

Bart

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: the TSpeedButton.Font.Color It doesn't work.
« Reply #3 on: September 23, 2018, 04:42:44 pm »
Many of the components on the usual Lazarus component palettes are painted by the widgetset. Usually this means that colors and fonts cannot be changed by the program, but are defined by the currently active theme services.

So, if you really must change the font color of the speedbutton you must use one of the third-party components out there.

If it does not matter when the button gets the focus you an use TBitBtn instead, here you can change the Font.Color  (at least on Windows, but maybe not on other widgetsets)

dtamadeEx

  • New Member
  • *
  • Posts: 17
Re: the TSpeedButton.Font.Color It doesn't work.
« Reply #4 on: September 23, 2018, 04:58:16 pm »
OK, I see. Thank you.

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 220
Re: the TSpeedButton.Font.Color It doesn't work.
« Reply #5 on: September 23, 2018, 05:34:36 pm »
IIRC then on Windows at least the font color of a TSpeedButton is themed (so determined by the OS).

Yes, this is true. But why is this limitation there? The font color of a TSpeedButton should be themed only if default font is used - the same that is done in THintWindow.


Many of the components on the usual Lazarus component palettes are painted by the widgetset.

Yes, but this is not true for TSpeedButton. TSpeedButton is painted by the LCL and it is a bug that the Font.Color isn't taken into account.

See: speedbutton.inc -> TCustomSpeedButton.MeasureDraw, line 739: ThemeServices.DrawText

Compare TSpeedButton with THintWindow. THintWindow is painted by the LCL with Themes and yet it supports custom font. ThemeServices.DrawText should be used only if the fon't isn't changed - see the THintWindow how it is done:

hintwindow.inc -> THintWindow.Paint, line 210:

    if ThemeFG then
      ThemeServices.DrawText(Canvas, Details, Caption, ARect, GetDrawTextFlags, 0)
    else
      DrawText(Canvas.GetUpdatedHandle([csFontValid]), PChar(Caption),
        Length(Caption), ARect, GetDrawTextFlags);

---

The attached patch adds support for custom font in TSpeedButton.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: the TSpeedButton.Font.Color It doesn't work.
« Reply #6 on: September 23, 2018, 06:03:02 pm »
You are right, of course. I applied your patch and put it on the merge list for v2.0RC2.

dtamadeEx

  • New Member
  • *
  • Posts: 17
Re: the TSpeedButton.Font.Color It doesn't work.
« Reply #7 on: September 23, 2018, 10:20:32 pm »
IIRC then on Windows at least the font color of a TSpeedButton is themed (so determined by the OS).

Yes, this is true. But why is this limitation there? The font color of a TSpeedButton should be themed only if default font is used - the same that is done in THintWindow.


Many of the components on the usual Lazarus component palettes are painted by the widgetset.

Yes, but this is not true for TSpeedButton. TSpeedButton is painted by the LCL and it is a bug that the Font.Color isn't taken into account.

See: speedbutton.inc -> TCustomSpeedButton.MeasureDraw, line 739: ThemeServices.DrawText

Compare TSpeedButton with THintWindow. THintWindow is painted by the LCL with Themes and yet it supports custom font. ThemeServices.DrawText should be used only if the fon't isn't changed - see the THintWindow how it is done:

hintwindow.inc -> THintWindow.Paint, line 210:

    if ThemeFG then
      ThemeServices.DrawText(Canvas, Details, Caption, ARect, GetDrawTextFlags, 0)
    else
      DrawText(Canvas.GetUpdatedHandle([csFontValid]), PChar(Caption),
        Length(Caption), ARect, GetDrawTextFlags);

---

The attached patch adds support for custom font in TSpeedButton.

 :)

 

TinyPortal © 2005-2018