mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 01:29:08 +02:00
lcl: use GetSysColorBrush if solid brush needs to be created with system color
win32: call Windows.GetSysColorBrush for lclintf.GetSysColorBrush git-svn-id: trunk@25128 -
This commit is contained in:
parent
dec729b223
commit
9e2134c1a2
@ -1787,6 +1787,7 @@ function StringToColor(const S: shortstring): TColor;
|
||||
procedure GetColorValues(Proc: TGetColorStringProc);
|
||||
function InvertColor(AColor: TColor): TColor;
|
||||
function DecColor(AColor: TColor; AQuantity: Byte): TColor;
|
||||
function IsSysColor(AColor: TColor): Boolean;
|
||||
|
||||
function Blue(rgb: TColor): BYTE; // does not work on system color
|
||||
function Green(rgb: TColor): BYTE; // does not work on system color
|
||||
@ -2464,6 +2465,11 @@ begin
|
||||
Result := RGBToColor(R, G, B);
|
||||
end;
|
||||
|
||||
function IsSysColor(AColor: TColor): Boolean;
|
||||
begin
|
||||
Result := (Cardinal(AColor) and Cardinal(SYS_COLOR_BASE)) <> 0;
|
||||
end;
|
||||
|
||||
|
||||
{$I graphicsobject.inc}
|
||||
{$I graphic.inc}
|
||||
|
@ -234,7 +234,10 @@ begin
|
||||
end else
|
||||
begin
|
||||
if LogBrush.lbStyle <> BS_PATTERN then
|
||||
FReference._lclHandle := TLCLHandle(CreateBrushIndirect(LogBrush))
|
||||
if (LogBrush.lbStyle = BS_SOLID) and IsSysColor(LogBrush.lbColor) then
|
||||
FReference._lclHandle := GetSysColorBrush(SysColorToSysColorIndex(LogBrush.lbColor))
|
||||
else
|
||||
FReference._lclHandle := TLCLHandle(CreateBrushIndirect(LogBrush))
|
||||
else
|
||||
FReference._lclHandle := TLCLHandle(CreatePatternBrush(LogBrush.lbHatch));
|
||||
BrushResourceCache.AddResource(FReference.Handle, @LogBrush);
|
||||
|
@ -184,10 +184,7 @@ const
|
||||
var
|
||||
OldHandle: HBRUSH;
|
||||
begin
|
||||
//DebugLn('[TCanvas.CreateBrush] ',Classname,' Self=',DbgS(Self)
|
||||
// ,' Brush=',DbgS(Brush));
|
||||
OldHandle := SelectObject(FHandle, HGDIOBJ(Brush.Reference.Handle));
|
||||
//debugln('TCanvas.CreateBrush ',ClassName,' Self=',DbgS(Self),' OldHandle=',DbgS(OldHandle),8),' NewHandle=',DbgS(Brush.Handle),' FSavedBrushHandle=',DbgS(Cardinal(FSavedBrushHandle));
|
||||
if (OldHandle <> HBRUSH(Brush.Reference.Handle)) and (FSavedBrushHandle=0) then
|
||||
FSavedBrushHandle := OldHandle;
|
||||
Include(FState, csBrushValid);
|
||||
|
@ -1048,6 +1048,16 @@ begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TWidgetSet.GetSysColorBrush(nIndex: Integer): HBrush;
|
||||
var
|
||||
LogBrush: TLogBrush;
|
||||
begin
|
||||
LogBrush.lbColor := GetSysColor(nIndex);
|
||||
LogBrush.lbStyle := 0; // BS_CLEAR
|
||||
LogBrush.lbHatch := 0;
|
||||
Result := CreateBrushIndirect(LogBrush);
|
||||
end;
|
||||
|
||||
function TWidgetSet.GetSystemMetrics(nIndex: Integer): Integer;
|
||||
begin
|
||||
Result := 0;
|
||||
|
@ -466,6 +466,11 @@ begin
|
||||
Result := WidgetSet.GetSysColor(nIndex);
|
||||
end;
|
||||
|
||||
function GetSysColorBrush(nIndex: Integer): HBrush;
|
||||
begin
|
||||
Result := WidgetSet.GetSysColorBrush(nIndex);
|
||||
end;
|
||||
|
||||
function GetSystemMetrics(nIndex: Integer): Integer;
|
||||
begin
|
||||
Result := WidgetSet.GetSystemMetrics(nIndex);
|
||||
|
@ -144,6 +144,7 @@ function GetScrollInfo(Handle: HWND; SBStyle: Integer; var ScrollInfo: TScrollIn
|
||||
//function GetScrollRange --> independent
|
||||
function GetStockObject(Value: Integer): THandle; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function GetSysColor(nIndex: Integer): DWORD; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function GetSysColorBrush(nIndex: Integer): HBrush; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function GetSystemPaletteEntries(DC: HDC; StartIndex, NumEntries: UINT;
|
||||
var PaletteEntries): UINT; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function GetSystemMetrics(nIndex: Integer): Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
|
@ -1981,6 +1981,13 @@ begin
|
||||
Result := Windows.GetSysColor(nIndex);
|
||||
end;
|
||||
|
||||
function TWin32WidgetSet.GetSysColorBrush(nIndex: Integer): HBrush;
|
||||
begin
|
||||
if NIndex = COLOR_FORM then
|
||||
NIndex := COLOR_BTNFACE;
|
||||
Result := Windows.GetSysColorBrush(nIndex);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: GetSystemMetrics
|
||||
Params: NIndex - system metric to retrieve
|
||||
|
@ -119,6 +119,7 @@ function GetRGNBox(Rgn: HRGN; lpRect : PRect) : Longint; override;
|
||||
function GetScrollInfo(Handle: HWND; BarFlag: Integer; Var ScrollInfo: TScrollInfo): Boolean; override;
|
||||
function GetStockObject(Value: Integer): THandle; override;
|
||||
function GetSysColor(NIndex: Integer): DWORD; override;
|
||||
function GetSysColorBrush(nIndex: Integer): HBrush; override;
|
||||
function GetSystemMetrics(NIndex: Integer): Integer; override;
|
||||
function GetTextColor(DC: HDC): TColorRef; override;
|
||||
function GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; Var Size: TSize): Boolean; override;
|
||||
|
Loading…
Reference in New Issue
Block a user