LCL: made NewAutoSize default, added -dOldAutoSize

git-svn-id: trunk@23943 -
This commit is contained in:
mattias 2010-03-11 15:49:01 +00:00
parent 44d0f22378
commit 874b22249a
9 changed files with 205 additions and 212 deletions

View File

@ -6646,7 +6646,7 @@ Begin
{$IFDEF IDE_DEBUG}
writeln('[TSourceNotebook.NewFile] A ');
{$ENDIF}
{$IFDEF NewAutoSize}
{$IFNDEF OldwAutoSize}
DisableAutoSizing;
try
{$ENDIF}
@ -6661,7 +6661,7 @@ Begin
{$ENDIF}
Result.PageName:=FindUniquePageName(NewShortName, FindPageWithEditor(Result));
UpdatePageNames;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
finally
EnableAutoSizing;
end;
@ -6683,7 +6683,7 @@ begin
TempEditor:=FindSourceEditorWithPageIndex(APageIndex);
if TempEditor=nil then exit;
//debugln(['TSourceNotebook.CloseFile ',TempEditor.FileName,' ',TempEditor.APageIndex]);
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
DisableAutoSizing;
try
{$ENDIF}
@ -6720,7 +6720,7 @@ begin
Notebook:=nil;
Hide;
end;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
finally
EnableAutoSizing;
end;

View File

@ -228,9 +228,8 @@ type
csClicked,
csPalette,
csReadingState,
{$IFDEF NewAutoSize}
{$IFDEF OldAutoSize}
// deprecated
{$ELSE}
csAlignmentNeeded,
{$ENDIF}
csFocusing,
@ -792,7 +791,7 @@ type
{ TControl }
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
TControlAutoSizePhase = (
caspNone,
caspChangingProperties,
@ -810,11 +809,11 @@ type
var Handled: Boolean) of object;
TControlFlag = (
{$IFDEF NewAutoSize}
cfLoading, // set by TControl.ReadState, unset by TControl.Loaded when all on form finished loading
{$ELSE}
{$IFDEF OldAutoSize}
// obsolete
cfRequestAlignNeeded,
{$ELSE}
cfLoading, // set by TControl.ReadState, unset by TControl.Loaded when all on form finished loading
{$ENDIF}
cfAutoSizeNeeded,
cfLeftLoaded, // cfLeftLoaded is set, when 'Left' is set during loading.
@ -947,7 +946,7 @@ type
FParentFont: Boolean;
FParentShowHint: Boolean;
FAutoSize: Boolean;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
fAutoSizingAll: boolean;
{$ENDIF}
FAutoSizingSelf: Boolean;
@ -956,7 +955,7 @@ type
FVisible: Boolean;
function CaptureMouseButtonsIsStored: boolean;
procedure DoActionChange(Sender: TObject);
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
function GetAutoSizingAll: Boolean;
{$ENDIF}
function GetAnchorSide(Kind: TAnchorKind): TAnchorSide;
@ -1022,7 +1021,7 @@ type
protected
// sizing/aligning
procedure DoAutoSize; virtual;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
procedure DoAllAutoSize; virtual; // while autosize needed call DoAutoSize, used by AdjustSize and EnableAutoSizing
{$ENDIF}
procedure BeginAutoSizing; // set AutoSizing=true, can be used to prevent circles
@ -1070,7 +1069,7 @@ type
function IsClientWidthStored: boolean; virtual;
property AutoSizing: Boolean read FAutoSizingSelf;// see Begin/EndAutoSizing
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
property AutoSizingAll: Boolean read GetAutoSizingAll;// set in DoAllAutoSize
{$ENDIF}
property AutoSizingLockCount: Integer read FAutoSizingLockCount;
@ -1261,7 +1260,7 @@ type
public
// size
procedure AdjustSize; virtual;// smart calling DoAutoSize
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
function AutoSizePhase: TControlAutoSizePhase; virtual;
{$ENDIF}
function AutoSizeDelayed: boolean; virtual;
@ -1593,10 +1592,10 @@ type
wcfClientRectNeedsUpdate,
wcfColorChanged,
wcfFontChanged, // Set if font was changed before handle creation
{$IFDEF NewAutoSize}
wcfAllAutoSizing,
{$ELSE}
{$IFDEF OldAutoSize}
wcfReAlignNeeded,
{$ELSE}
wcfAllAutoSizing,
{$ENDIF}
wcfAligningControls,
wcfEraseBackground,
@ -1667,7 +1666,7 @@ type
FTabOrder: integer;
FTabList: TFPList;
// keep small variables together to save some bytes
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
FAlignLevel: Word;
{$ENDIF}
FTabStop: Boolean;
@ -1715,7 +1714,7 @@ type
function DoAlignChildControls(TheAlign: TAlign; AControl: TControl;
AControlList: TFPList; var ARect: TRect): Boolean; virtual;
procedure DoChildSizingChange(Sender: TObject); virtual;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
procedure ResizeDelayedAutoSizeChildren; virtual;
{$ENDIF}
procedure InvalidatePreferredChildSizes;
@ -1731,7 +1730,7 @@ type
procedure DoConstraintsChange(Sender: TObject); override;
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
procedure DoAutoSize; override;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
procedure DoAllAutoSize; override;
{$ENDIF}
procedure CalculatePreferredSize(var PreferredWidth,
@ -1900,7 +1899,7 @@ type
property VisibleDockClientCount: Integer read GetVisibleDockClientCount;
public
// size, position, bounds
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
function AutoSizePhase: TControlAutoSizePhase; override;
{$ENDIF}
function AutoSizeDelayed: boolean; override;
@ -2322,7 +2321,7 @@ const
'alNone', 'alTop', 'alBottom', 'alLeft', 'alRight', 'alClient', 'alCustom');
AnchorNames: array[TAnchorKind] of string = (
'akTop', 'akLeft', 'akRight', 'akBottom');
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
AutoSizePhaseNames: array[TControlAutoSizePhase] of string = (
'caspNone',
'caspChangingProperties',

View File

@ -40,16 +40,7 @@
------------------------------------------------------------------------------}
procedure TControl.Adjustsize;
begin
{$IFDEF NewAutoSize}
Include(FControlFlags,cfAutoSizeNeeded);
if IsControlVisible then
begin
if Parent<>nil then
Parent.AdjustSize
else if not AutoSizeDelayed then
DoAllAutoSize;
end;
{$ELSE}
{$IFDEF OldAutoSize}
//debugln(['TControl.AdjustSize START ',DbgSName(Self),' AutoSizeCanStart=',AutoSizeCanStart,' AutoSizeDelayed=',AutoSizeDelayed]);
if (not AutoSizeCanStart) or AutoSizeDelayed then begin
//debugln('TControl.AdjustSize AutoSizeDelayed ',DbgSName(Self));
@ -59,6 +50,15 @@ begin
//debugln(['TControl.AdjustSize DoAutoSize ',DbgSName(Self)]);
DoAutoSize;
Exclude(FControlFlags,cfAutoSizeNeeded);
{$ELSE}
Include(FControlFlags,cfAutoSizeNeeded);
if IsControlVisible then
begin
if Parent<>nil then
Parent.AdjustSize
else if not AutoSizeDelayed then
DoAllAutoSize;
end;
{$ENDIF}
end;
@ -365,18 +365,7 @@ begin
// change base bounds
// (base bounds are the base for the automatic resizing)
UpdateAnchorRules;
{$IFDEF NewAutoSize}
// lock size messages
inc(FSizeLock);
try
// notify before autosizing
BoundsChanged;
if PosSizeKept then exit;
AdjustSize;
finally
dec(FSizeLock);
end;
{$ELSE}
{$IFDEF OldAutoSize}
// lock the base bounds while automatic resizing
LockBaseBounds;
// lock size messages
@ -414,6 +403,17 @@ begin
dec(FSizeLock);
UnlockBaseBounds;
end;
{$ELSE}
// lock size messages
inc(FSizeLock);
try
// notify before autosizing
BoundsChanged;
if PosSizeKept then exit;
AdjustSize;
finally
dec(FSizeLock);
end;
{$ENDIF}
if PosSizeKept then exit;
@ -1344,7 +1344,7 @@ begin
p:=Parent;
while (p<>nil) do begin
if (wcfAligningControls in p.FWinControlFlags)
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
or (p.FAlignLevel>0)
{$ENDIF}
then
@ -1455,7 +1455,7 @@ begin
Result := TControl(FAnchoredControls[Index]);
end;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
function TControl.GetAutoSizingAll: Boolean;
begin
if Parent<>nil then
@ -2373,7 +2373,7 @@ end;
Run DoAutoSize until done.
------------------------------------------------------------------------------}
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
procedure TControl.DoAllAutoSize;
procedure AutoSizeControl(AControl: TControl);
@ -2489,7 +2489,7 @@ begin
{$ENDIF}
end;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
function TControl.AutoSizePhase: TControlAutoSizePhase;
begin
if Parent<>nil then
@ -2510,7 +2510,7 @@ begin
Result:=(FAutoSizingLockCount>0)
// no autosize during loading or destruction
or ([csLoading,csDestroying]*ComponentState<>[])
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
or (cfLoading in FControlFlags)
{$ENDIF}
// no autosize for invisible controls
@ -2989,7 +2989,7 @@ end;
procedure TControl.Loaded;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
function FindLoadingControl(AControl: TControl): TControl;
var
i: Integer;
@ -3098,7 +3098,7 @@ begin
UpdateBaseBounds(true,true,true);
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
// obsolete
// align this control and the brothers
@ -3114,10 +3114,10 @@ begin
FUndockWidth := Width;
if Action <> nil then ActionChange(Action, True);
{$IFDEF NewAutoSize}
CheckLoading(Self);
{$ELSE}
{$IFDEF OldAutoSize}
CheckOnChangeBounds;
{$ELSE}
CheckLoading(Self);
{$ENDIF}
end;
@ -3160,13 +3160,13 @@ end;
procedure TControl.ReadState(Reader: TReader);
begin
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
Include(FControlFlags,cfLoading);
DisableAutoSizing;
try
{$ENDIF}
inherited ReadState(Reader);
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
finally
EnableAutoSizing;
end;
@ -3177,9 +3177,7 @@ procedure TControl.FormEndUpdated;
// called when control is on a form and EndFormUpdate reached 0
// it is called recursively
begin
{$IFDEF NewAutoSize}
{$ELSE}
{$IFDEF OldAutoSize}
if cfOnResizeNeeded in FControlFlags then
Resize;
if cfOnChangeBoundsNeeded in FControlFlags then
@ -3241,9 +3239,7 @@ end;
------------------------------------------------------------------------------}
procedure TControl.RequestAlign;
begin
{$IFDEF NewAutoSize}
AdjustSize;
{$ELSE}
{$IFDEF OldAutoSize}
if (Parent = nil) or (csDestroying in ComponentState) then exit;
if (csLoading in ComponentState) or (not Parent.HandleAllocated) then begin
//debugln('TControl.RequestAlign csLoading or not HandleAllocated ',DbgSName(Self));
@ -3253,6 +3249,8 @@ begin
//debugln('TControl.RequestAlign AlignControl ',DbgSName(Self));
Parent.AlignControl(Self);
Exclude(FControlFlags,cfRequestAlignNeeded);
{$ELSE}
AdjustSize;
{$ENDIF}
end;
@ -3510,7 +3508,7 @@ end;
procedure TControl.SetParent(NewParent: TWinControl);
begin
if FParent = NewParent then exit;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
DisableAutoSizing;
try
{$ENDIF}
@ -3522,7 +3520,7 @@ begin
BoundsRect := BoundsRectForNewParent;
end;
if NewParent <> nil then NewParent.InsertControl(Self);
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
finally
EnableAutoSizing;
end;
@ -3696,7 +3694,7 @@ begin
if FVisible <> Value then
begin
//DebugLn(['TControl.SetVisible ',DbgSName(Self),' NewVisible=',Value]);
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
DisableAutoSizing;
try
{$ENDIF}
@ -3710,7 +3708,7 @@ begin
AsWincontrol := TWinControl(Self)
else
AsWincontrol := nil;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
InvalidatePreferredSize;
if AsWincontrol <> nil then
AsWincontrol.InvalidatePreferredChildSizes;
@ -3750,7 +3748,7 @@ begin
finally
VisibleChanged;
end;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
finally
EnableAutoSizing;
end;
@ -4744,7 +4742,7 @@ begin
while AControl<>nil do begin
Exclude(AControl.FControlFlags,cfPreferredSizeValid);
Exclude(AControl.FControlFlags,cfPreferredMinSizeValid);
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
if not AControl.IsControlVisible then break;
{$ENDIF}
AControl:=AControl.Parent;
@ -4782,7 +4780,9 @@ end;
procedure TControl.DisableAutoSizing;
begin
{$IFDEF NewAutoSize}
{$IFDEF OldAutoSize}
inc(FAutoSizingLockCount);
{$ELSE}
inc(FAutoSizingLockCount);
//DebugLn([Space(FAutoSizingLockCount*2),'TControl.DisableAutoSizing ',DbgSName(Self),' ',FAutoSizingLockCount]);
if FAutoSizingLockCount=1 then
@ -4793,14 +4793,12 @@ begin
Parent.DisableAutoSizing;
end;
end;
{$ELSE}
inc(FAutoSizingLockCount);
{$ENDIF}
end;
procedure TControl.EnableAutoSizing;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
procedure AdjustSizeRecursive(AControl: TControl);
var
AWinControl: TWinControl;
@ -4819,7 +4817,11 @@ procedure TControl.EnableAutoSizing;
begin
if FAutoSizingLockCount<=0 then RaiseGDBException('TControl.EnableAutoSizing');
{$IFDEF NewAutoSize}
{$IFDEF OldAutoSize}
dec(FAutoSizingLockCount);
if FAutoSizingLockCount=0 then
AdjustSizeRecursive(Self);
{$ELSE}
dec(FAutoSizingLockCount);
//DebugLn([Space(FAutoSizingLockCount*2),'TControl.EnableAutoSizing ',DbgSName(Self),' ',FAutoSizingLockCount]);
if (FAutoSizingLockCount=0) then
@ -4831,10 +4833,6 @@ begin
end else
DoAllAutoSize;
end;
{$ELSE}
dec(FAutoSizingLockCount);
if FAutoSizingLockCount=0 then
AdjustSizeRecursive(Self);
{$ENDIF}
end;

View File

@ -99,7 +99,7 @@ begin
//DebugLn('[TCustomForm.Destroy] A ',Name,':',ClassName);
if not (csDestroying in ComponentState) then GlobalNameSpace.BeginWrite;
try
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
DisableAutoSizing;
{$ENDIF}
FreeThenNil(FIcon);
@ -112,7 +112,7 @@ begin
inherited Destroy;
//DebugLn('[TCustomForm.Destroy] END ',Name,':',ClassName);
finally
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
if not (csDestroying in ComponentState) then
{$ENDIF}
GlobalNameSpace.EndWrite;
@ -847,7 +847,7 @@ begin
if FFormUpdateCount=0 then begin
FormEndUpdated;
Visible:=(fsVisible in FFormState);
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
EnableAutoSizing;
{$ENDIF}
end;
@ -1647,7 +1647,7 @@ constructor TCustomForm.CreateNew(AOwner: TComponent; Num: Integer = 0);
begin
Include(FFormState,fsFirstShow);
//DebugLn('[TCustomForm.CreateNew] Class=',Classname);
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
BeginFormUpdate;
{$ENDIF}
FBorderIcons := [biSystemMenu, biMinimize, biMaximize];
@ -1681,7 +1681,7 @@ begin
Color := clBtnFace;
FloatingDockSiteClass := TWinControlClass(ClassType);
Screen.AddForm(Self);
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
EndFormUpdate;
{$ENDIF}
FAllowDropFiles := False;
@ -2215,7 +2215,7 @@ end;
procedure TCustomForm.BeginFormUpdate;
begin
inc(FFormUpdateCount);
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
if FFormUpdateCount=1 then
DisableAutoSizing;
{$ENDIF}

View File

@ -590,7 +590,7 @@ end;
procedure TCustomNoteBook.AddRemovePageHandle(APage: TCustomPage);
begin
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
DisableAutoSizing;
try
{$ENDIF}
@ -603,10 +603,10 @@ begin
Include(APage.FFlags,pfAdding);
TWSCustomNotebookClass(WidgetSetClass).AddPage(Self, APage, APage.VisibleIndex);
APage.FFlags:=APage.FFlags+[pfAdded]-[pfAdding];
{$IFDEF NewAutoSize}
APage.AdjustSize;
{$ELSE}
{$IFDEF OldAutoSize}
APage.ResizeDelayedAutoSizeChildren
{$ELSE}
APage.AdjustSize;
{$ENDIF}
end else begin
{$IFDEF NOTEBOOK_DEBUG}
@ -620,7 +620,7 @@ begin
APage.DestroyHandle;
Exclude(APage.FFlags, pfRemoving);
end;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
finally
EnableAutoSizing;
end;

View File

@ -2247,7 +2247,7 @@ begin
ReallocMem(Childs[o],0);
end;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
{------------------------------------------------------------------------------
function TWinControl.AutoSizePhase: TControlAutoSizePhase;
------------------------------------------------------------------------------}
@ -2279,7 +2279,7 @@ function TWinControl.AutoSizeDelayed: boolean;
begin
Result:=// no handle means not visible
(not HandleAllocated)
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
// obsolete
or ((not FShowing) and (not (csDesigning in ComponentState)))
// during handle creation no autosize
@ -3023,7 +3023,7 @@ var
var
i: Integer;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
ChildControl: TControl;
{$ENDIF}
OldRemainingClientRect: TRect;
@ -3033,7 +3033,7 @@ begin
if wcfAligningControls in FWinControlFlags then exit;
Include(FWinControlFlags,wcfAligningControls);
try
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
// obsolete
// call delayed autosize
@ -3046,7 +3046,7 @@ begin
end;
{$ENDIF}
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
// obsolete
// unset all align needed flags
@ -3111,7 +3111,7 @@ begin
finally
Exclude(FWinControlFlags,wcfAligningControls);
end;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
// obsolete
// let childs autosize themselves
@ -3154,9 +3154,7 @@ begin
ReAlign;
end;
{$IFDEF NewAutoSize}
// deprecated
{$ELSE}
{$IFDEF OldAutoSize}
procedure TWinControl.ResizeDelayedAutoSizeChildren;
var
i: Integer;
@ -3301,18 +3299,7 @@ var
NewChildBounds: TRect;
OldChildBounds: TRect;
begin
{$IFDEF NewAutoSize}
{$IFDEF VerboseAllAutoSize}
debugln('TWinControl.DoAutoSize ',DbgSName(Self));
{$ENDIF}
if (not AutoSizeCanStart) or (AutoSizePhase<>caspComputingBounds) then begin
{$IFDEF VerboseAllAutoSize}
DebugLn(['TWinControl.DoAutoSize DELAYED AutoSizeCanStart=',AutoSizeCanStart,' AutoSizeDelayed=',AutoSizeDelayed,' AutoSizePhase=',AutoSizePhaseNames[AutoSizePhase]]);
{$ENDIF}
Include(FControlFlags,cfAutoSizeNeeded);
exit;
end;
{$ELSE}
{$IFDEF OldAutoSize}
{$IFDEF VerboseAutoSize}
debugln('TWinControl.DoAutoSize ',DbgSName(Self));
{$ENDIF}
@ -3323,10 +3310,21 @@ begin
Include(FControlFlags,cfAutoSizeNeeded);
exit;
end;
{$ELSE}
{$IFDEF VerboseAllAutoSize}
debugln('TWinControl.DoAutoSize ',DbgSName(Self));
{$ENDIF}
if (not AutoSizeCanStart) or (AutoSizePhase<>caspComputingBounds) then begin
{$IFDEF VerboseAllAutoSize}
DebugLn(['TWinControl.DoAutoSize DELAYED AutoSizeCanStart=',AutoSizeCanStart,' AutoSizeDelayed=',AutoSizeDelayed,' AutoSizePhase=',AutoSizePhaseNames[AutoSizePhase]]);
{$ENDIF}
Include(FControlFlags,cfAutoSizeNeeded);
exit;
end;
{$ENDIF}
DisableAutoSizing;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
// obsolete
DisableAlign;
{$ENDIF}
@ -3423,14 +3421,14 @@ begin
finally
Exclude(FControlFlags,cfAutoSizeNeeded);
EnableAutoSizing;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
// obsolete
EnableAlign;
{$ENDIF}
end;
end;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
procedure TWinControl.DoAllAutoSize;
procedure UpdateShowingRecursive(AWinControl: TWinControl);
@ -3573,11 +3571,11 @@ end;
------------------------------------------------------------------------------}
procedure TWinControl.DisableAlign;
begin
{$IFDEF NewAutoSize}
DisableAutoSizing;
{$ELSE}
{$IFDEF OldAutoSize}
Inc(FAlignLevel);
//DebugLn(['TWinControl.DisableAlign ',dbgsName(Self),' ',FAlignLevel]);
{$ELSE}
DisableAutoSizing;
{$ENDIF}
end;
@ -3605,7 +3603,7 @@ begin
' New=',DbgS(r.Right),'x',DbgS(r.Bottom));
{$ENDIF}
FAdjustClientRectRealized := R;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
ReAlign;
Resize;
{$ENDIF}
@ -3701,9 +3699,7 @@ end;
------------------------------------------------------------------------------}
procedure TWinControl.EnableAlign;
begin
{$IFDEF NewAutoSize}
EnableAutoSizing;
{$ELSE}
{$IFDEF OldAutoSize}
Dec(FAlignLevel);
//DebugLn(['TWinControl.EnableAlign ',dbgsName(Self),' ',FAlignLevel]);
if FAlignLevel = 0 then begin
@ -3711,6 +3707,8 @@ begin
or (wcfReAlignNeeded in FWinControlFlags) then
ReAlign;
end;
{$ELSE}
EnableAutoSizing;
{$ENDIF}
end;
@ -4197,28 +4195,7 @@ var
begin
bShow := HandleObjectShouldBeVisible;
{$IFDEF NewAutoSize}
if bShow then begin
if not HandleAllocated then CreateHandle;
if FControls <> nil
then begin
for n := 0 to FControls.Count - 1 do
if TObject(FControls[n]) is TWinControl then
TWinControl(FControls[n]).UpdateShowing;
end;
end;
if not HandleAllocated then Exit;
if FShowing = bShow then Exit;
//DebugLn('TWinControl.UpdateShowing A ',dbgsName(Self),' FShowing=',dbgs(FShowing),' bShow=',dbgs(bShow));
if bShow then
begin
// the Handle should become visible
// delay this until all autosizing has been processed
if AutoSizeDelayed or AutoSizingAll then exit;
end;
ChangeShowing(bShow);
{$ELSE}
{$IFDEF OldAutoSize}
if bShow then begin
if not HandleAllocated then CreateHandle;
if FControls <> nil
@ -4246,6 +4223,27 @@ begin
EnableAlign;
end;
end;
{$ELSE}
if bShow then begin
if not HandleAllocated then CreateHandle;
if FControls <> nil
then begin
for n := 0 to FControls.Count - 1 do
if TObject(FControls[n]) is TWinControl then
TWinControl(FControls[n]).UpdateShowing;
end;
end;
if not HandleAllocated then Exit;
if FShowing = bShow then Exit;
//DebugLn('TWinControl.UpdateShowing A ',dbgsName(Self),' FShowing=',dbgs(FShowing),' bShow=',dbgs(bShow));
if bShow then
begin
// the Handle should become visible
// delay this until all autosizing has been processed
if AutoSizeDelayed or AutoSizingAll then exit;
end;
ChangeShowing(bShow);
{$ENDIF}
end;
@ -5838,7 +5836,7 @@ begin
end;
AControl.FParent := Self;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
if AControl.FAutoSizingLockCount>0 then
begin
// the AControl has disabled autosizing => disable it for the parent=self too
@ -5855,9 +5853,7 @@ end;
------------------------------------------------------------------------------}
procedure TWinControl.ReAlign;
begin
{$IFDEF NewAutoSize}
AdjustSize;
{$ELSE}
{$IFDEF OldAutoSize}
if (csDestroying in ComponentState) then exit;
if (csLoading in ComponentState) or (not HandleAllocated) then begin
Include(FWinControlFlags,wcfReAlignNeeded);
@ -5872,6 +5868,8 @@ begin
DebugLn('TWinControl.ReAlign B',Name,':',ClassName,' ', Dbgs(BoundsRect));
{$ENDIF}
Exclude(FWinControlFlags,wcfReAlignNeeded);// done
{$ELSE}
AdjustSize;
{$ENDIF}
end;
@ -5887,7 +5885,7 @@ begin
ListRemove(FTabList, AControl);
ListRemove(FControls, AControl);
AControl.FParent := nil;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
if AControl.FAutoSizingLockCount>0 then
begin
// AControl has disabled autosizing and thus for its parent=Self too
@ -5997,7 +5995,7 @@ end;
procedure TWinControl.InsertControl(AControl: TControl; Index: integer);
begin
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
DisableAutoSizing;
try
{$ENDIF}
@ -6024,7 +6022,7 @@ begin
AControl.RequestAlign;
end;
Perform(CM_CONTROLCHANGE, WParam(AControl), LParam(True));
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
finally
EnableAutoSizing;
end;
@ -6039,7 +6037,7 @@ procedure TWinControl.RemoveControl(AControl: TControl);
var
AWinControl: TWinControl;
begin
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
DisableAutoSizing;
try
{$ENDIF}
@ -6058,19 +6056,19 @@ begin
Perform(CM_CONTROLLISTCHANGE, WParam(AControl), LParam(False));
if not (csDestroying in ComponentState) then
begin
{$IFDEF NewAutoSize}
InvalidatePreferredSize;
AdjustSize;
{$ELSE}
{$IFDEF OldAutoSize}
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Realign;
{$ELSE}
InvalidatePreferredSize;
AdjustSize;
{$ENDIF}
end;
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
finally
EnableAutoSizing;
end;
@ -6084,7 +6082,7 @@ procedure TWinControl.AlignControl(AControl: TControl);
var
ARect: TRect;
NewRect: TRect;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
i: Integer;
ChildControl: TControl;
{$ENDIF}
@ -6095,12 +6093,7 @@ begin
//end;
if csDestroying in ComponentState then exit;
{$IFDEF NewAutoSize}
if AutoSizeDelayed then begin
AdjustSize;
exit;
end;
{$ELSE}
{$IFDEF OldAutoSize}
if FAlignLevel <> 0 then begin
Include(FControlState, csAlignmentNeeded);
exit;
@ -6117,18 +6110,15 @@ begin
exit;
end;
end;
{$ELSE}
if AutoSizeDelayed then begin
AdjustSize;
exit;
end;
{$ENDIF}
{$IFDEF NewAutoSize}
ARect:= GetLogicalClientRect;
AlignControls(AControl, ARect);
// some widgetsets updates their clientrect when the first child was moved
// do a second pass if ClientRect changed
NewRect:=GetLogicalClientRect;
if not CompareRect(@ARect,@NewRect) then
AlignControls(AControl, NewRect);
{$ELSE}
{$IFDEF OldAutoSize}
DisableAlign;
try
ARect:= GetLogicalClientRect;
@ -6146,6 +6136,15 @@ begin
if TObject(FControls[i]) is TWinControl then
TWinControl(FControls[i]).RealizeBoundsRecursive;
end;
{$ELSE}
ARect:= GetLogicalClientRect;
AlignControls(AControl, ARect);
// some widgetsets updates their clientrect when the first child was moved
// do a second pass if ClientRect changed
NewRect:=GetLogicalClientRect;
if not CompareRect(@ARect,@NewRect) then
AlignControls(AControl, NewRect);
{$ENDIF}
end;
@ -6666,16 +6665,16 @@ begin
end;
SetBoundsKeepBase(NewLeft, NewTop, Message.Width, Message.Height, Parent <> nil);
{$IFDEF NewAutoSize}
if ((Message.SizeType and Size_SourceIsInterface) > 0)
and ClientRectNeedsInterfaceUpdate then
DoAdjustClientRectChange;
{$ELSE}
{$IFDEF OldAutoSize}
if ClientRectNeedsInterfaceUpdate then
DoAdjustClientRectChange;
if ((Message.SizeType and Size_SourceIsInterface) > 0) and
(Parent <> nil) and Parent.AutoSize then
Parent.AdjustSize;
{$ELSE}
if ((Message.SizeType and Size_SourceIsInterface) > 0)
and ClientRectNeedsInterfaceUpdate then
DoAdjustClientRectChange;
{$ENDIF}
end;
@ -6961,7 +6960,7 @@ begin
if (csDestroying in ComponentState)
or (Parent<>nil) and (csDestroying in Parent.ComponentState) then begin
DebugLn('[TWinControl.CreateWnd] NOTE: csDestroying ',DbgSName(Self));
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
RaiseGDBException('');
{$ENDIF}
exit;
@ -6970,7 +6969,7 @@ begin
if wcfInitializing in FWinControlFlags
then begin
DebugLn('[WARNING] Recursive call to CreateWnd for ',DbgSName(Self), ' while initializing');
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
RaiseGDBException('');
{$ENDIF}
Exit;
@ -6979,7 +6978,7 @@ begin
if wcfCreatingHandle in FWinControlFlags
then begin
DebugLn('[WARNING] Recursive call to CreateWnd for ',DbgSName(Self), ' while creating handle');
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
RaiseGDBException('');
{$ENDIF}
Exit;
@ -6988,7 +6987,7 @@ begin
if wcfCreatingChildHandles in FWinControlFlags
then begin
DebugLn('[WARNING] Recursive call to CreateWnd for ',DbgSName(Self), ' while creating children');
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
RaiseGDBException('');
{$ENDIF}
Exit;
@ -6996,20 +6995,20 @@ begin
if [csLoading,csDesigning]*ComponentState=[csLoading] then begin
DebugLn('[HINT] TWinControl.CreateWnd creating Handle during loading ',DbgSName(Self),' csDesigning=',dbgs(csDesigning in ComponentState));
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
RaiseGDBException('');
{$ENDIF}
//DumpStack;
//RaiseGDBException('');
end;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
// obsolete
DisableAlign;
{$ENDIF}
DisableAutoSizing;
try
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
if (Parent<>nil) and (not Parent.HandleAllocated) then
begin
// first create the parent handle
@ -7086,7 +7085,7 @@ begin
for i:=0 to FControls.Count-1 do
TControl(FControls[i]).AdjustSize;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
// obsolete
// realign childs
@ -7094,7 +7093,7 @@ begin
{$ENDIF}
finally
EnableAutoSizing;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
// obsolete
EnableAlign;
{$ENDIF}
@ -7123,7 +7122,7 @@ begin
// First set the WinControl property some interfaces depends on it
SetProp(Handle,'WinControl',TWinControl(Self));
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
DisableAlign;
{$ENDIF}
DisableAutoSizing;
@ -7134,7 +7133,7 @@ begin
' OldRelBounds=',dbgs(FBoundsRealized),
' -> NewBounds=',dbgs(BoundsRect));
{$ENDIF}
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
// obsolete
if (Width>0) and (Height>0) then
DoSendBoundsToInterface;
@ -7169,7 +7168,7 @@ begin
else TWSWinControlClass(WidgetSetClass).SetCursor(Self, Screen.Cursors[Cursor]);
finally
EnableAutoSizing;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
EnableAlign;
{$ENDIF}
end;
@ -7254,11 +7253,11 @@ var
LoadedClientSize: TPoint;
CurControl: TWinControl;
begin
{$IFDEF NewAutoSize}
//DebugLn(['TWinControl.Loaded START ',DbgSName(Self),' cfWidthLoaded=',cfWidthLoaded in FControlFlags,' cfHeightLoaded=',cfHeightLoaded in FControlFlags,' ']);
{$ELSE}
{$IFDEF OldAutoSize}
// obsolete
DisableAlign;
{$ELSE}
//DebugLn(['TWinControl.Loaded START ',DbgSName(Self),' cfWidthLoaded=',cfWidthLoaded in FControlFlags,' cfHeightLoaded=',cfHeightLoaded in FControlFlags,' ']);
{$ENDIF}
DisableAutoSizing;
try
@ -7318,22 +7317,22 @@ begin
FixupTabList;
{$IFNDEF NewAutoSize}
{$IFDEF OldAutoSize}
// obsolete
RealizeBounds;
if HandleAllocated and ([csDestroying]*ComponentState=[]) then
DoSendShowHideToInterface;
{$ENDIF}
finally
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
//DebugLn(['TWinControl.Loaded enableautosizing ',DbgSName(Self),' ',dbgs(BoundsRect)]);
{$ENDIF}
EnableAutoSizing;
{$IFDEF NewAutoSize}
//DebugLn(['TWinControl.Loaded END ',DbgSName(Self),' ',dbgs(BoundsRect)]);
{$ELSE}
{$IFDEF OldAutoSize}
// obsolete
EnableAlign;
{$ELSE}
//DebugLn(['TWinControl.Loaded END ',DbgSName(Self),' ',dbgs(BoundsRect)]);
{$ENDIF}
end;
end;
@ -7360,7 +7359,7 @@ var
begin
if HandleAllocated then
begin
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
DisableAutoSizing;
try
{$ENDIF}
@ -7376,7 +7375,7 @@ begin
// again. To propely initialize control after we need to restore color
// and font. Request update.
FWinControlFlags := FWinControlFlags + [wcfColorChanged, wcfFontChanged];
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
finally
EnableAutoSizing;
end;
@ -7465,7 +7464,7 @@ begin
RaiseGDBException('UnlockRealizeBounds');
dec(FRealizeBoundsLockCount);
if (FRealizeBoundsLockCount=0)
{$IFDEF NewAutoSize}
{$IFNDEF OldAutoSize}
and (not AutoSizingAll) and (not AutoSizeDelayed)
{$ENDIF}
then
@ -7630,10 +7629,10 @@ begin
if [csDesigning,csDestroying,csLoading]*ComponentState=[csDesigning] then
CheckDesignBounds;
// LCL bounds are not up2date -> process new bounds
{$IFDEF NewAutoSize}
DisableAutoSizing;
{$ELSE}
{$IFDEF OldAutoSize}
LockRealizeBounds;
{$ELSE}
DisableAutoSizing;
{$ENDIF}
try
{$IFDEF CHECK_POSITION}
@ -7647,10 +7646,10 @@ begin
if FUseDockManager and (DockManager <> nil) then
DockManager.ResetBounds(False);
finally
{$IFDEF NewAutoSize}
EnableAutoSizing;
{$ELSE}
{$IFDEF OldAutoSize}
UnlockRealizeBounds;
{$ELSE}
EnableAutoSizing;
{$ENDIF}
end;
end;

View File

@ -1941,9 +1941,7 @@ begin
SaveSizeNotification(Widget);
end;
{$ELSE}
{$IFDEF NewAutoSize}
SendSizeNotificationToLCL(Widget);
{$ELSE}
{$IFDEF OldAutoSize}
if GTK_WIDGET_REALIZED(Widget) then begin
{ The gtk sends the size messages after the resizing. Therefore the parent
widget is already resized, but the parent resize message will be emitted
@ -1955,6 +1953,8 @@ begin
// This is the resize of an outer widget and sent to the LCL immediately.
SendSizeNotificationToLCL(Widget);
end;
{$ELSE}
SendSizeNotificationToLCL(Widget);
{$ENDIF}
{$ENDIF}
end;

View File

@ -6573,7 +6573,7 @@ begin
FWidgetsResized.Remove(MainWidget);
FFixWidgetsResized.Remove(FixedWidget);
{$IF defined(Gtk1) or not defined(NewAutoSize)}
{$IF defined(Gtk1) or defined(OldAutoSize)}
if not GTK_WIDGET_REALIZED(aWidget) then begin
// the widget is not yet realized, so this GTK resize was not a user change.
// => ignore

View File

@ -170,8 +170,5 @@ begin
}
//debugln('style-set after ',DbgSName(TWinControl(Data)));
//LCLObject.InvalidateClientRectCache(False);
{$IFNDEF NewAutoSize}
{$ENDIF}
end;