lcl: formatting

git-svn-id: trunk@30287 -
This commit is contained in:
paul 2011-04-14 01:03:20 +00:00
parent 26ede9d979
commit c20cf07caf
2 changed files with 63 additions and 57 deletions

View File

@ -678,7 +678,7 @@ begin
inherited WMSize(Message); inherited WMSize(Message);
if (Message.SizeType and Size_Restored)>0 then if (Message.SizeType and Size_Restored) > 0 then
begin begin
FRestoredLeft := Left; FRestoredLeft := Left;
FRestoredTop := Top; FRestoredTop := Top;
@ -1381,11 +1381,12 @@ end;
procedure TCustomForm.DoSendBoundsToInterface; procedure TCustomForm.DoSendBoundsToInterface;
begin begin
inherited DoSendBoundsToInterface; inherited DoSendBoundsToInterface;
if WindowState=wsNormal then begin if WindowState = wsNormal then
FRestoredLeft:=Left; begin
FRestoredTop:=Top; FRestoredLeft := Left;
FRestoredWidth:=Width; FRestoredTop := Top;
FRestoredHeight:=Height; FRestoredWidth := Width;
FRestoredHeight := Height;
end; end;
end; end;

View File

@ -6738,7 +6738,7 @@ begin
{$IFDEF CHECK_POSITION} {$IFDEF CHECK_POSITION}
if CheckPosition(Self) then if CheckPosition(Self) then
{$ENDIF} {$ENDIF}
if (Message.SizeType and Size_SourceIsInterface)>0 then if (Message.SizeType and Size_SourceIsInterface) > 0 then
DebugLn(['TWinControl.WMSize A ',Name,':',ClassName,' Message=',Message.Width,',',Message.Height, DebugLn(['TWinControl.WMSize A ',Name,':',ClassName,' Message=',Message.Width,',',Message.Height,
' BoundsRealized=',dbgs(FBoundsRealized), ' BoundsRealized=',dbgs(FBoundsRealized),
' WChg=',FBoundsRealized.Right-FBoundsRealized.Left<>Message.Width, ' WChg=',FBoundsRealized.Right-FBoundsRealized.Left<>Message.Width,
@ -6746,8 +6746,8 @@ begin
' FromIntf=',(Message.SizeType and Size_SourceIsInterface)>0,' ClientRectInvalid=',ClientRectNeedsInterfaceUpdate]); ' FromIntf=',(Message.SizeType and Size_SourceIsInterface)>0,' ClientRectInvalid=',ClientRectNeedsInterfaceUpdate]);
{$ENDIF} {$ENDIF}
NewLeft:=Left; NewLeft := Left;
NewTop:=Top; NewTop := Top;
if ((Message.SizeType and Size_SourceIsInterface) > 0) then if ((Message.SizeType and Size_SourceIsInterface) > 0) then
begin begin
// interface widget has resized // interface widget has resized
@ -6771,14 +6771,17 @@ begin
GetWindowRelativePosition(Handle, NewLeft, NewTop); GetWindowRelativePosition(Handle, NewLeft, NewTop);
//DebugLn('TWinControl.WMSize B ',Name,':',ClassName,' ',NewLeft,',',NewTop); //DebugLn('TWinControl.WMSize B ',Name,':',ClassName,' ',NewLeft,',',NewTop);
NewBoundsRealized := Bounds(NewLeft, NewTop, Message.Width, Message.Height); NewBoundsRealized := Bounds(NewLeft, NewTop, Message.Width, Message.Height);
OldClientSize:=Size(0,0); OldClientSize := Size(0, 0);
NewClientSize:=Size(0,0); NewClientSize := Size(0, 0);
if CompareRect(@NewBoundsRealized,@FBoundsRealized) then begin if CompareRect(@NewBoundsRealized, @FBoundsRealized) then
if not (wcfClientRectNeedsUpdate in FWinControlFlags) then begin begin
OldClientSize:=Size(FClientWidth,FClientHeight); if not (wcfClientRectNeedsUpdate in FWinControlFlags) then
NewClientSize:=Size(ClientWidth,ClientHeight); begin
if (OldClientSize.cx=NewClientSize.cx) OldClientSize := Size(FClientWidth, FClientHeight);
and (OldClientSize.cy=NewClientSize.cy) then exit; NewClientSize := Size(ClientWidth, ClientHeight);
if (OldClientSize.cx = NewClientSize.cx) and
(OldClientSize.cy = NewClientSize.cy) then
Exit;
end; end;
end; end;
{$IFDEF VerboseAllAutoSize} {$IFDEF VerboseAllAutoSize}
@ -6787,16 +6790,14 @@ begin
' wcfClientRectNeedsUpdate=',wcfClientRectNeedsUpdate in FWinControlFlags]); ' wcfClientRectNeedsUpdate=',wcfClientRectNeedsUpdate in FWinControlFlags]);
{$ENDIF} {$ENDIF}
TopParent:=GetTopParent; TopParent := GetTopParent;
if (TopParent is TWinControl) if (TopParent is TWinControl) and (wcfKillIntfSetBounds in TWinControl(TopParent).FWinControlFlags) then
and (wcfKillIntfSetBounds in TWinControl(TopParent).FWinControlFlags)
then
RaiseLoop; RaiseLoop;
FBoundsRealized := NewBoundsRealized; FBoundsRealized := NewBoundsRealized;
//DebugLn(['TWinControl.WMSize ',DbgSName(Self),' phases=',dbgs(AutoSizePhases)]); //DebugLn(['TWinControl.WMSize ',DbgSName(Self),' phases=',dbgs(AutoSizePhases)]);
if ([caspCreatingHandles,caspComputingBounds]*AutoSizePhases<>[]) if ([caspCreatingHandles, caspComputingBounds] * AutoSizePhases <> []) then
then begin begin
// while the LCL is creating handles the widgetset may send default bounds // while the LCL is creating handles the widgetset may send default bounds
// we have not yet told the widgetset the final bounds // we have not yet told the widgetset the final bounds
// => the InvalidatePreferredSize and the InvalidateClientRectCache // => the InvalidatePreferredSize and the InvalidateClientRectCache
@ -6805,19 +6806,18 @@ begin
// => do not call SetBounds, as this will set the Bounds to the widgetset // => do not call SetBounds, as this will set the Bounds to the widgetset
// default values. // default values.
//DebugLn(['TWinControl.WMSize from intf ignored, because phases=',dbgs(AutoSizePhases),' boundsrealized=',wcfBoundsRealized in FWinControlFlags]); //DebugLn(['TWinControl.WMSize from intf ignored, because phases=',dbgs(AutoSizePhases),' boundsrealized=',wcfBoundsRealized in FWinControlFlags]);
exit; Exit;
end; end;
if Parent<>nil then if Assigned(Parent) then
InvalidatePreferredSize; InvalidatePreferredSize;
end; end;
if Parent<>nil then if Assigned(Parent) then
SetBoundsKeepBase(NewLeft, NewTop, Message.Width, Message.Height) SetBoundsKeepBase(NewLeft, NewTop, Message.Width, Message.Height)
else else
SetBounds(NewLeft, NewTop, Message.Width, Message.Height); SetBounds(NewLeft, NewTop, Message.Width, Message.Height);
if ((Message.SizeType and Size_SourceIsInterface) > 0) if ((Message.SizeType and Size_SourceIsInterface) > 0) and ClientRectNeedsInterfaceUpdate then
and ClientRectNeedsInterfaceUpdate then
DoAdjustClientRectChange; DoAdjustClientRectChange;
{$IFDEF VerboseClientRectBugFix} {$IFDEF VerboseClientRectBugFix}
//if Name=CheckClientRectName then //if Name=CheckClientRectName then
@ -7207,46 +7207,47 @@ var
begin begin
//DebugLn('[TWinControl.CreateWnd] START ',DbgSName(Self)); //DebugLn('[TWinControl.CreateWnd] START ',DbgSName(Self));
if (csDestroying in ComponentState) if (csDestroying in ComponentState) or Assigned(Parent) and (csDestroying in Parent.ComponentState) then
or (Parent<>nil) and (csDestroying in Parent.ComponentState) then begin begin
DebugLn('[TWinControl.CreateWnd] NOTE: csDestroying ',DbgSName(Self)); DebugLn('[TWinControl.CreateWnd] NOTE: csDestroying ',DbgSName(Self));
RaiseGDBException(''); RaiseGDBException('');
exit; exit;
end; end;
if wcfInitializing in FWinControlFlags if wcfInitializing in FWinControlFlags then
then begin begin
DebugLn('[WARNING] Recursive call to CreateWnd for ',DbgSName(Self), ' while initializing'); DebugLn('[WARNING] Recursive call to CreateWnd for ',DbgSName(Self), ' while initializing');
RaiseGDBException(''); RaiseGDBException('');
Exit; Exit;
end; end;
if wcfCreatingHandle in FWinControlFlags if wcfCreatingHandle in FWinControlFlags then
then begin begin
DebugLn('[WARNING] Recursive call to CreateWnd for ',DbgSName(Self), ' while creating handle'); DebugLn('[WARNING] Recursive call to CreateWnd for ',DbgSName(Self), ' while creating handle');
RaiseGDBException(''); RaiseGDBException('');
Exit; Exit;
end; end;
if wcfCreatingChildHandles in FWinControlFlags if wcfCreatingChildHandles in FWinControlFlags then
then begin begin
DebugLn('[WARNING] Recursive call to CreateWnd for ',DbgSName(Self), ' while creating children'); DebugLn('[WARNING] Recursive call to CreateWnd for ',DbgSName(Self), ' while creating children');
RaiseGDBException(''); RaiseGDBException('');
Exit; Exit;
end; end;
if [csLoading,csDesigning]*ComponentState=[csLoading] then begin if [csLoading,csDesigning]*ComponentState=[csLoading] then
begin
DebugLn('[HINT] TWinControl.CreateWnd creating Handle during loading ',DbgSName(Self),' csDesigning=',dbgs(csDesigning in ComponentState)); DebugLn('[HINT] TWinControl.CreateWnd creating Handle during loading ',DbgSName(Self),' csDesigning=',dbgs(csDesigning in ComponentState));
//DumpStack; //DumpStack;
//RaiseGDBException(''); //RaiseGDBException('');
end; end;
FBoundsRealized:=Rect(0,0,0,0); FBoundsRealized := Rect(0,0,0,0);
Exclude(FWinControlFlags,wcfBoundsRealized); Exclude(FWinControlFlags, wcfBoundsRealized);
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.CreateWnd'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.CreateWnd'){$ENDIF};
try try
if (Parent<>nil) and (not Parent.HandleAllocated) then if Assigned(Parent) and not Parent.HandleAllocated then
begin begin
// first create the parent handle // first create the parent handle
Parent.HandleNeeded; Parent.HandleNeeded;
@ -7257,7 +7258,7 @@ begin
FShowing := False; FShowing := False;
Exclude(FWinControlFlags, wcfHandleVisible); Exclude(FWinControlFlags, wcfHandleVisible);
Include(FWinControlFlags,wcfCreatingHandle); Include(FWinControlFlags, wcfCreatingHandle);
try try
CreateParams(Params); CreateParams(Params);
with Params do with Params do
@ -7271,7 +7272,8 @@ begin
//DebugLn(['TWinControl.CreateWnd Creating handle ... ',DbgSName(WidgetSetClass),' ',DbgSName(Self)]); //DebugLn(['TWinControl.CreateWnd Creating handle ... ',DbgSName(WidgetSetClass),' ',DbgSName(Self)]);
FHandle := TWSWinControlClass(WidgetSetClass).CreateHandle(Self, Params); FHandle := TWSWinControlClass(WidgetSetClass).CreateHandle(Self, Params);
if not HandleAllocated then begin if not HandleAllocated then
begin
if WidgetSet.LCLPlatform=lpNoGUI then if WidgetSet.LCLPlatform=lpNoGUI then
RaiseGDBException('TWinControl.CreateWnd: The nogui widgetset does not support visual controls.') RaiseGDBException('TWinControl.CreateWnd: The nogui widgetset does not support visual controls.')
else else
@ -7286,7 +7288,7 @@ begin
TWSWinControlClass(WidgetSetClass).ConstraintsChange(Self); TWSWinControlClass(WidgetSetClass).ConstraintsChange(Self);
//WriteClientRect('A'); //WriteClientRect('A');
if Parent <> nil then if Assigned(Parent) then
AddControl AddControl
else else
if ParentWindow <> 0 then if ParentWindow <> 0 then
@ -7376,13 +7378,13 @@ begin
begin begin
// replace by update style call // replace by update style call
TWSWinControlClass(WidgetSetClass).SetColor(Self); TWSWinControlClass(WidgetSetClass).SetColor(Self);
FWinControlFlags:=FWinControlFlags-[wcfColorChanged]; Exclude(FWinControlFlags, wcfColorChanged);
end; end;
if wcfFontChanged in FWinControlFlags then if wcfFontChanged in FWinControlFlags then
begin begin
// replace by update style call // replace by update style call
TWSWinControlClass(WidgetSetClass).SetFont(Self,Font); TWSWinControlClass(WidgetSetClass).SetFont(Self,Font);
FWinControlFlags:=FWinControlFlags-[wcfFontChanged]; Exclude(FWinControlFlags, wcfFontChanged);
end; end;
if not (csDesigning in ComponentState) then if not (csDesigning in ComponentState) then
@ -7396,9 +7398,10 @@ begin
InvalidatePreferredSize; InvalidatePreferredSize;
end; end;
if csDesigning in ComponentState if csDesigning in ComponentState then
then TWSWinControlClass(WidgetSetClass).SetCursor(Self, Screen.Cursors[crDefault]) TWSWinControlClass(WidgetSetClass).SetCursor(Self, Screen.Cursors[crDefault])
else TWSWinControlClass(WidgetSetClass).SetCursor(Self, Screen.Cursors[Cursor]); else
TWSWinControlClass(WidgetSetClass).SetCursor(Self, Screen.Cursors[Cursor]);
finally finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.InitializeWnd'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.InitializeWnd'){$ENDIF};
end; end;
@ -7624,7 +7627,7 @@ end;
function TWinControl.BrushCreated: Boolean; function TWinControl.BrushCreated: Boolean;
begin begin
Result := FBrush <> nil; Result := Assigned(FBrush);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -8118,7 +8121,8 @@ var
OldBounds: TRect; OldBounds: TRect;
{$ENDIF} {$ENDIF}
begin begin
if (Parent=nil) and (not HandleObjectShouldBeVisible) then begin if (Parent = nil) and (not HandleObjectShouldBeVisible) then
begin
{ do not move invisible forms { do not move invisible forms
Reason: It is common to do this: Reason: It is common to do this:
Form1:=TForm1.Create(nil); Form1:=TForm1.Create(nil);
@ -8127,9 +8131,9 @@ begin
Form1.Show; Form1.Show;
This moves the form around and confuses some windowmanagers. This moves the form around and confuses some windowmanagers.
Only send the last bounds. } Only send the last bounds. }
exit; Exit;
end; end;
NewBounds:=Bounds(Left, Top, Width, Height); NewBounds := Bounds(Left, Top, Width, Height);
{$IF defined(VerboseResizeFlicker) or defined(VerboseSizeMsg)} {$IF defined(VerboseResizeFlicker) or defined(VerboseSizeMsg)}
if HandleAllocated then begin if HandleAllocated then begin
GetWindowRelativePosition(Handle,OldBounds.Left,OldBounds.Top); GetWindowRelativePosition(Handle,OldBounds.Left,OldBounds.Top);
@ -8172,14 +8176,15 @@ begin
' -> NewBounds=',dbgs(NewBounds)); ' -> NewBounds=',dbgs(NewBounds));
end; end;
{$ENDIF} {$ENDIF}
FBoundsRealized:=NewBounds; FBoundsRealized := NewBounds;
OldClientRect:=ClientRect; OldClientRect := ClientRect;
Include(FWinControlFlags,wcfBoundsRealized); // Note: set before calling widgetset, because used in WMSize Include(FWinControlFlags, wcfBoundsRealized); // Note: set before calling widgetset, because used in WMSize
//if Parent=nil then DebugLn(['TWinControl.DoSendBoundsToInterface ',DbgSName(Self),' ',dbgs(BoundsRect)]); //if Parent=nil then DebugLn(['TWinControl.DoSendBoundsToInterface ',DbgSName(Self),' ',dbgs(BoundsRect)]);
// this can trigger WMSize messages // this can trigger WMSize messages
TWSWinControlClass(WidgetSetClass).SetBounds(Self, Left, Top, Width, Height); TWSWinControlClass(WidgetSetClass).SetBounds(Self, Left, Top, Width, Height);
NewClientRect:=ClientRect; NewClientRect := ClientRect;
if not CompareRect(@OldClientRect,@NewClientRect) then begin if not CompareRect(@OldClientRect,@NewClientRect) then
begin
// the widgetset has changed the clientrect // the widgetset has changed the clientrect
//DebugLn(['TWinControl.DoSendBoundsToInterface ',DbgSName(Self),' Bounds=',dbgs(BoundsRect),' OldClientRect=',dbgs(OldClientRect),' NewClientRect=',dbgs(NewClientRect)]); //DebugLn(['TWinControl.DoSendBoundsToInterface ',DbgSName(Self),' Bounds=',dbgs(BoundsRect),' OldClientRect=',dbgs(OldClientRect),' NewClientRect=',dbgs(NewClientRect)]);
AdjustSize; AdjustSize;