mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-03 05:38:15 +02:00
Fixes using system colors under Windows CE.
git-svn-id: trunk@14162 -
This commit is contained in:
parent
29340e990e
commit
db8581b37f
@ -69,6 +69,10 @@ const
|
||||
TCS_VERTICAL = $0080;
|
||||
TCS_MULTILINE = $0200;
|
||||
|
||||
{ From Windows.pas (adapted for win32) }
|
||||
const
|
||||
SYS_COLOR_INDEX_FLAG = 0;
|
||||
|
||||
implementation
|
||||
|
||||
initialization
|
||||
|
@ -381,7 +381,7 @@ Var
|
||||
ORect.Top := 0;
|
||||
ORect.Right := DoubleBufferBitmapWidth;
|
||||
ORect.Bottom := DoubleBufferBitmapHeight;
|
||||
Windows.FillRect(DoubleBufferDC, ORect, GetSysColorBrush(COLOR_DESKTOP));
|
||||
Windows.FillRect(DoubleBufferDC, ORect, GetSysColorBrush(COLOR_DESKTOP or SYS_COLOR_INDEX_FLAG));
|
||||
{$endif}
|
||||
PaintRegion := CreateRectRgn(0, 0, 1, 1);
|
||||
{ if GetRandomRgn(DC, PaintRegion, SYSRGN) = 1 then
|
||||
|
@ -33,7 +33,8 @@ unit WinCEExtra;
|
||||
interface
|
||||
|
||||
uses
|
||||
LCLType {keep before windows}, Windows, Classes, SysUtils, Maps, GraphType;
|
||||
LCLType, LCLIntf, {keep both before windows}
|
||||
Windows, Classes, SysUtils, Maps, GraphType;
|
||||
|
||||
type
|
||||
DrawStateProc = function(
|
||||
@ -348,10 +349,10 @@ begin
|
||||
|
||||
if (flags and DSS_DISABLED) <> 0
|
||||
then
|
||||
hbrtmp := CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT))
|
||||
hbrtmp := CreateSolidBrush(LCLIntf.GetSysColor(COLOR_3DHILIGHT))
|
||||
else if (flags and DSS_DEFAULT) <> 0
|
||||
then
|
||||
hbrtmp := CreateSolidBrush(GetSysColor(COLOR_3DSHADOW));
|
||||
hbrtmp := CreateSolidBrush(LCLIntf.GetSysColor(COLOR_3DSHADOW));
|
||||
|
||||
{ Draw light or dark shadow }
|
||||
if (flags and (DSS_DISABLED or DSS_DEFAULT)) <> 0 then
|
||||
@ -367,7 +368,7 @@ begin
|
||||
|
||||
if (flags and DSS_DISABLED) <> 0 then
|
||||
begin
|
||||
hbrtmp := CreateSolidBrush(GetSysColor(COLOR_3DSHADOW));
|
||||
hbrtmp := CreateSolidBrush(LCLIntf.GetSysColor(COLOR_3DSHADOW));
|
||||
hbr := hbrtmp;
|
||||
if hbrtmp = 0 then goto cleanup;
|
||||
end
|
||||
|
@ -423,7 +423,7 @@ var
|
||||
begin
|
||||
drawRect := TControl(Arrow).ClientRect;
|
||||
canvasHandle := TCanvas(Canvas).Handle;
|
||||
Windows.FillRect(canvasHandle, drawRect, GetSysColorBrush(COLOR_BTNFACE));
|
||||
Windows.FillRect(canvasHandle, drawRect, GetSysColorBrush(COLOR_BTNFACE or SYS_COLOR_INDEX_FLAG));
|
||||
dec(drawRect.Left, 2);
|
||||
dec(drawRect.Top, 2);
|
||||
inc(drawRect.Right, 2);
|
||||
|
@ -543,7 +543,7 @@ begin
|
||||
if hIcon = 0 then
|
||||
hIcon := Windows.LoadIcon(0, IDI_APPLICATION);
|
||||
hCursor := LoadCursor(0, IDC_ARROW);
|
||||
hbrBackground := GetSysColorBrush(Color_BtnFace);
|
||||
hbrBackground := GetSysColorBrush(Color_BtnFace or SYS_COLOR_INDEX_FLAG);
|
||||
LPSzMenuName := nil;
|
||||
LPSzClassName := @ClsName;
|
||||
end;
|
||||
|
@ -170,9 +170,9 @@ var
|
||||
color and creating a brush because it uses a buffered brush
|
||||
}
|
||||
if Enabled and Selected then
|
||||
Brush := Windows.GetSysColorBrush(COLOR_HIGHLIGHT)
|
||||
Brush := Windows.GetSysColorBrush(COLOR_HIGHLIGHT or SYS_COLOR_INDEX_FLAG)
|
||||
else
|
||||
Brush := Windows.GetSysColorBrush(COLOR_WINDOW);
|
||||
Brush := Windows.GetSysColorBrush(COLOR_WINDOW or SYS_COLOR_INDEX_FLAG);
|
||||
Windows.FillRect(Data^._HDC, Windows.Rect(Data^.rcItem), Brush);
|
||||
|
||||
Rect := Data^.rcItem;
|
||||
@ -191,23 +191,24 @@ var
|
||||
{ Don't suppose anything about the current background color
|
||||
or text color. Always set them.
|
||||
|
||||
GetSysColor doesn't seam to work on WindowsCE inside this event,
|
||||
so we are hardcoding the colors for now until a better fix is found.
|
||||
LCLIntf.GetSysColor must be called instead of Windows.GetSysColor
|
||||
because the LCLIntf version makes sure that SYS_COLOR_INDEX_FLAG
|
||||
is added to the constant.
|
||||
}
|
||||
if Selected then
|
||||
begin
|
||||
OldColor := Windows.SetTextColor(Data^._HDC, Windows.GetSysColor(COLOR_HIGHLIGHTTEXT));
|
||||
OldBackColor := Windows.SetBkColor(Data^._HDC, $00D39137); {Windows.GetSysColor(COLOR_HIGHLIGHT)}
|
||||
OldColor := Windows.SetTextColor(Data^._HDC, LCLIntf.GetSysColor(COLOR_HIGHLIGHTTEXT));
|
||||
OldBackColor := Windows.SetBkColor(Data^._HDC, LCLIntf.GetSysColor(COLOR_HIGHLIGHT)); // $00D39137
|
||||
end
|
||||
else if not Enabled then
|
||||
begin
|
||||
OldColor := Windows.SetTextColor(Data^._HDC, $00BFBFBF); {Windows.GetSysColor(COLOR_GRAYTEXT)}
|
||||
OldBackColor := Windows.SetBkColor(Data^._HDC, $00FFFFFF); {Windows.GetSysColor(COLOR_WINDOW)}
|
||||
OldColor := Windows.SetTextColor(Data^._HDC, LCLIntf.GetSysColor(COLOR_GRAYTEXT)); // $00BFBFBF
|
||||
OldBackColor := Windows.SetBkColor(Data^._HDC, LCLIntf.GetSysColor(COLOR_WINDOW)); // $00FFFFFF
|
||||
end
|
||||
else
|
||||
begin
|
||||
OldColor := Windows.SetTextColor(Data^._HDC, Windows.GetSysColor(COLOR_CAPTIONTEXT));
|
||||
OldBackColor := Windows.SetBkColor(Data^._HDC, $00FFFFFF); {Windows.GetSysColor(COLOR_WINDOW)}
|
||||
OldColor := Windows.SetTextColor(Data^._HDC, LCLIntf.GetSysColor(COLOR_WINDOWTEXT));
|
||||
OldBackColor := Windows.SetBkColor(Data^._HDC, LCLIntf.GetSysColor(COLOR_WINDOW)); // $00FFFFFF
|
||||
end;
|
||||
|
||||
WideBuffer := LCLStringToPWideChar(CheckListBox.Items[Data^.ItemID]);
|
||||
@ -1494,7 +1495,8 @@ function TWinCEWidgetSet.GetSysColor(NIndex: Integer): DWORD;
|
||||
begin
|
||||
if NIndex = COLOR_FORM then
|
||||
NIndex := COLOR_BTNFACE;
|
||||
Result := Windows.GetSysColor(nIndex or $40000000);
|
||||
{ SYS_COLOR_INDEX_FLAG is indispensable on Windows CE }
|
||||
Result := Windows.GetSysColor(nIndex or SYS_COLOR_INDEX_FLAG);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
@ -32,7 +32,7 @@ uses
|
||||
// To get as little as posible circles,
|
||||
// uncomment only when needed for registration
|
||||
////////////////////////////////////////////////////
|
||||
Menus, Forms,
|
||||
Menus, Forms, LCLIntf, {keep before Windows }
|
||||
////////////////////////////////////////////////////
|
||||
WSMenus, WSLCLClasses,
|
||||
Windows, Controls, Classes, SysUtils, WinceInt, WinceProc, InterfaceBase, LCLProc;
|
||||
@ -472,12 +472,12 @@ function BackgroundColorMenu(const aSelected: boolean; const aInMainMenu: boolea
|
||||
var IsFlatMenu: Windows.BOOL;
|
||||
begin
|
||||
if aSelected then
|
||||
Result := GetSysColor(COLOR_HIGHLIGHT)
|
||||
Result := LCLIntf.GetSysColor(COLOR_HIGHLIGHT)
|
||||
// SPI_GETFLATMENU = 0x1022, it is not yet defined in the FPC
|
||||
else if aInMainMenu and (SystemParametersInfo($1022, 0, @IsFlatMenu, 0)) and IsFlatMenu then // COLOR_MENUBAR is not supported on Windows version < XP
|
||||
Result := GetSysColor(COLOR_MENUBAR)
|
||||
Result := LCLIntf.GetSysColor(COLOR_MENUBAR)
|
||||
else
|
||||
Result := GetSysColor(COLOR_MENU);
|
||||
Result := LCLIntf.GetSysColor(COLOR_MENU);
|
||||
end;
|
||||
|
||||
function TextColorMenu(const aSelected: boolean; const anEnabled: boolean): COLORREF;
|
||||
@ -485,11 +485,11 @@ begin
|
||||
if anEnabled then
|
||||
begin
|
||||
if aSelected then
|
||||
Result := GetSysColor(COLOR_HIGHLIGHTTEXT)
|
||||
Result := LCLIntf.GetSysColor(COLOR_HIGHLIGHTTEXT)
|
||||
else
|
||||
Result := GetSysColor(COLOR_MENUTEXT);
|
||||
Result := LCLIntf.GetSysColor(COLOR_MENUTEXT);
|
||||
end else
|
||||
Result := GetSysColor(COLOR_GRAYTEXT);
|
||||
Result := LCLIntf.GetSysColor(COLOR_GRAYTEXT);
|
||||
end;
|
||||
|
||||
procedure DrawSeparator(const aHDC: HDC; const aRect: Windows.RECT);
|
||||
|
Loading…
Reference in New Issue
Block a user