Lazarus
Programming => LCL => Topic started by: dtamadeEx on September 23, 2018, 03:36:13 pm
-
Report a bug
It doesn't work.
-
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.
-
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
-
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)
-
OK, I see. Thank you.
-
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.
-
You are right, of course. I applied your patch and put it on the merge list for v2.0RC2.
-
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.
:)