- add GetDefaultColor to TControl which asks Parent in case widgetset returns clDefault color for it;
  - return clDefault instead of clWindow for generic TControl
win32, wince: use TControl.GetDefaultColor in all the places where we used TWSControlClass

git-svn-id: trunk@28172 -
This commit is contained in:
paul 2010-11-10 04:15:43 +00:00
parent 61ed016376
commit 9bd782a63e
11 changed files with 21 additions and 10 deletions

View File

@ -1287,6 +1287,7 @@ type
WithThemeSpace: boolean = true); virtual;
function GetDefaultWidth: integer;
function GetDefaultHeight: integer;
function GetDefaultColor: TColor; virtual;
function GetSidePosition(Side: TAnchorKind): integer;
procedure CNPreferredSizeChanged;
procedure InvalidatePreferredSize; virtual;

View File

@ -905,6 +905,16 @@ begin
Result := not ParentColor;
end;
function TControl.GetDefaultColor: TColor;
begin
Result := TWSControlClass(WidgetSetClass).GetDefaultColor(Self);
if (Result = clDefault) then
if ParentColor and Assigned(Parent) then
Result := Parent.GetDefaultColor
else
Result := clWindow;
end;
{------------------------------------------------------------------------------
TControl.DoConstrainedResize
------------------------------------------------------------------------------}

View File

@ -45,7 +45,7 @@ end;
function TControlCanvas.GetDefaultColor: TColor;
begin
if Assigned(FControl) then
Result := TWSControlClass(FControl.WidgetSetClass).GetDefaultColor(FControl)
Result := FControl.GetDefaultColor
else
Result := inherited GetDefaultColor;
end;

View File

@ -4622,7 +4622,7 @@ begin
inherited SetColor(Value);
if BrushCreated then
if Color = clDefault then
FBrush.Color := TWSWinControlClass(WidgetSetClass).GetDefaultColor(Self)
FBrush.Color := GetDefaultColor
else
FBrush.Color := Color;
if HandleAllocated and ([csLoading,csDestroying]*ComponentState=[]) then
@ -4823,7 +4823,7 @@ begin
if BrushCreated then exit;
FBrush := TBrush.Create;
if Color = clDefault then
FBrush.Color := TWSWinControlClass(WidgetSetClass).GetDefaultColor(Self)
FBrush.Color := GetDefaultColor
else
FBrush.Color := Color;
end;

View File

@ -1360,7 +1360,7 @@ begin
Windows.SetTextColor(WindowDC, Windows.COLORREF(ColorToRGB(ChildWinControl.Font.Color)));
WindowColor := ChildWinControl.Brush.Color;
if WindowColor = clDefault then
WindowColor := TWSWinControlClass(ChildWinControl.WidgetSetClass).GetDefaultColor(ChildWinControl);
WindowColor := ChildWinControl.GetDefaultColor;
Windows.SetBkColor(WindowDC, Windows.COLORREF(ColorToRGB(WindowColor)));
LMessage.Result := LResult(ChildWinControl.Brush.Reference.Handle);
//DebugLn(['WindowProc ', ChildWinControl.Name, ' Brush: ', LMessage.Result]);

View File

@ -456,7 +456,7 @@ begin
if not WSCheckHandleAllocated(AWinControl, 'TWin32WSStatusBar.SetColor') then
Exit;
if AWinControl.Color = clDefault then
Windows.SendMessage(AWinControl.Handle, SB_SETBKCOLOR, 0, ColorToRGB(TWSWinControlClass(AWinControl.WidgetSetClass).GetDefaultColor(AWinControl)))
Windows.SendMessage(AWinControl.Handle, SB_SETBKCOLOR, 0, ColorToRGB(AWinControl.GetDefaultColor))
else
Windows.SendMessage(AWinControl.Handle, SB_SETBKCOLOR, 0, ColorToRGB(AWinControl.Color));
end;

View File

@ -991,7 +991,7 @@ begin
Exit;
Color := AWinControl.Color;
if Color = clDefault then
Color := TWSWinControlClass(AWinControl.WidgetSetClass).GetDefaultColor(AWinControl);
Color := AWinControl.GetDefaultColor;
Windows.SendMessage(AWinControl.Handle, LVM_SETBKCOLOR, 0, ColorToRGB(Color));
Windows.SendMessage(AWinControl.Handle, LVM_SETTEXTBKCOLOR, 0, ColorToRGB(Color));
end;

View File

@ -221,7 +221,7 @@ var
ncm: NONCLIENTMETRICS;
begin
ncm.cbSize := sizeof(ncm);
if SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), @ncm, 0) then
if SystemParametersInfo(SPI_GETNONCLIENTMETRICS, SizeOf(ncm), @ncm, 0) then
lf := ncm.lfMenuFont
else
GetObject(GetStockObject(DEFAULT_GUI_FONT), SizeOf(LOGFONT), @lf);

View File

@ -1302,7 +1302,7 @@ begin
Windows.SetTextColor(HDC(WParam), Windows.COLORREF(ColorToRGB(ChildWinControl.Font.Color)));
WindowColor := ChildWinControl.Brush.Color;
if WindowColor = clDefault then
WindowColor := TWSWinControlClass(ChildWinControl.WidgetSetClass).GetDefaultColor(ChildWinControl);
WindowColor := ChildWinControl.GetDefaultColor;
Windows.SetBkColor(WindowDC, Windows.COLORREF(ColorToRGB(WindowColor)));
LMessage.Result := LResult(ChildWinControl.Brush.Reference.Handle);
//DebugLn(['WindowProc ', ChildWinControl.Name, ' Brush: ', LMessage.Result]);

View File

@ -731,7 +731,7 @@ begin
Exit;
Color := AWinControl.Color;
if Color = clDefault then
Color := TWSWinControlClass(AWinControl.WidgetSetClass).GetDefaultColor(AWinControl);
Color := AWinControl.GetDefaultColor;
Windows.SendMessage(AWinControl.Handle, LVM_SETBKCOLOR, 0, ColorToRGB(Color));
Windows.SendMessage(AWinControl.Handle, LVM_SETTEXTBKCOLOR, 0, ColorToRGB(Color));
end;

View File

@ -165,7 +165,7 @@ end;
class function TWSControl.GetDefaultColor(const AControl: TControl): TColor;
begin
Result := clWindow;
Result := clDefault;
end;
class procedure TWSControl.ConstraintWidth(const AControl: TControl;