lcl: Color property storing (fixes bug #0012322)

- change default ColorIsStored method. It was written probably to override old fpc streaming bug. Now it only checks for ParentColor property. If control want to skip some color storing then simple Default value need to be filled.
- remove TButtonControl.ColorIsStored, TStatusBar.ColorIsStored. Default value for color property do this job
- introduce new function IsColorDefault(AControl: TControl): Boolean; which checks both ParentColor and default color value
- gtk: use IsColorDefault instead of IsColorStored

git-svn-id: trunk@18744 -
This commit is contained in:
paul 2009-02-18 08:40:13 +00:00
parent 7ddb879bc3
commit fbfc224459
8 changed files with 24 additions and 24 deletions

View File

@ -148,7 +148,6 @@ type
procedure CalculatePreferredSize(
var PreferredWidth, PreferredHeight: integer;
WithThemeSpace: Boolean); override;
function ColorIsStored: boolean; override;
//added.
function CreatePanel: TStatusPanel; virtual;

View File

@ -99,7 +99,7 @@ type
Control: TControl;
Inserting: Boolean;
Result: LRESULT;
End;
end;
TCMDialogChar = TLMKEY;
TCMDialogKey = TLMKEY;
@ -2253,6 +2253,8 @@ procedure AdjustBorderSpace(var RemainingClientRect, CurBorderSpace: TRect;
procedure AdjustBorderSpace(var RemainingClientRect, CurBorderSpace: TRect;
const Space: TRect);
function IsColorDefault(AControl: TControl): Boolean;
function DbgS(a: TAnchorKind): string; overload;
function DbgS(Anchors: TAnchors): string; overload;
function DbgS(a: TAlign): string; overload;
@ -2341,6 +2343,21 @@ begin
Space.Right,Space.Bottom);
end;
function IsColorDefault(AControl: TControl): Boolean;
const
NoDefaultValue = Longint($80000000);
var
Info: PPropInfo;
begin
Result := not AControl.ColorIsStored;
if not Result then
begin
Info := GetPropInfo(AControl, 'Color');
if Info <> nil then
Result := (Info^.Default <> NoDefaultValue) and (Info^.Default = AControl.Color);
end;
end;
function DbgS(a: TAnchorKind): string;
begin
Result:=AnchorNames[a];

View File

@ -63,13 +63,6 @@ begin
inherited Click;
end;
function TButtonControl.ColorIsStored: boolean;
begin
Result:=(Color<>clBtnFace);
if Result and ParentColor and (Parent<>nil) then
Result:=false;
end;
constructor TButtonControl.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);

View File

@ -856,9 +856,7 @@ end;
------------------------------------------------------------------------------}
function TControl.ColorIsStored: boolean;
begin
Result := (Color <> clWindow);
if Result and ParentColor and (Parent <> nil) then
Result := False;
Result := not ParentColor or (Parent = nil);
end;
{------------------------------------------------------------------------------

View File

@ -1005,7 +1005,7 @@ end;
function TCustomForm.ColorIsStored: boolean;
begin
Result:=(Color<>clBtnFace);
Result:=(Color <> clBtnFace);
end;
procedure TCustomForm.DoSendBoundsToInterface;

View File

@ -201,13 +201,6 @@ begin
PreferredHeight := 25;
end;
function TStatusBar.ColorIsStored: boolean;
begin
Result:=(Color<>clBtnFace);
if Result and ParentColor and (Parent<>nil) then
Result:=false;
end;
procedure TStatusBar.BeginUpdate;
begin
inc(FUpdateLock);

View File

@ -8922,7 +8922,8 @@ begin
FreeFontSetName:=false;
try
// set default background
if (AWinControl.Color=clNone) then begin
if (AWinControl.Color=clNone) then
begin
// clNone => remove default background
if (FixWidget<>nil) and (FixWidget^.Window<>nil) then
begin
@ -8930,8 +8931,8 @@ begin
end;
end
else
if TWinControlAccess(AWinControl).ColorIsStored
and ((AWinControl.Color and SYS_COLOR_BASE)=0) then begin
if not IsColorDefault(AWinControl) and ((AWinControl.Color and SYS_COLOR_BASE)=0) then
begin
// set background to user defined color
// don't set background for custom controls, which paint themselves

View File

@ -1014,7 +1014,6 @@ type
procedure SetChecked(Value: Boolean); virtual;
procedure DoOnChange; virtual;
procedure Click; override;
function ColorIsStored: boolean; override;
procedure Loaded; override;
procedure CMWantSpecialKey(var Message: TLMessage); message CM_WANTSPECIALKEY;
protected