removed OldAutoSize

git-svn-id: trunk@25190 -
This commit is contained in:
mattias 2010-05-04 19:16:18 +00:00
parent 1cc38bd305
commit cf55952b42
23 changed files with 20 additions and 1074 deletions

View File

@ -1001,6 +1001,7 @@ function ParseFPCVerbose(List: TStrings; out UnitPaths: TStrings;
SymbolName, SymbolValue, UpLine, NewPath: string; SymbolName, SymbolValue, UpLine, NewPath: string;
i, len, curpos: integer; i, len, curpos: integer;
begin begin
DebugLn(['ProcessOutputLine ',Line]);
len := length(Line); len := length(Line);
if len <= 6 then Exit; // shortest match if len <= 6 then Exit; // shortest match

View File

@ -302,7 +302,7 @@ begin
if not FormEditingHook.GetDefaultComponentPosition(TypeClass,ParentCI,X,Y) if not FormEditingHook.GetDefaultComponentPosition(TypeClass,ParentCI,X,Y)
then exit; then exit;
DisableAutoSize:={$IFDEF OldAutoSize}false{$ELSE}true{$ENDIF}; DisableAutoSize:=true;
CompIntf:=FormEditingHook.CreateComponent(ParentCI,TypeClass,'',X,Y,0,0, CompIntf:=FormEditingHook.CreateComponent(ParentCI,TypeClass,'',X,Y,0,0,
DisableAutoSize); DisableAutoSize);
if Assigned(CompIntf) then begin if Assigned(CompIntf) then begin

View File

@ -282,7 +282,7 @@ begin
if not FormEditingHook.GetDefaultComponentPosition(TypeClass,ParentCI,X,Y) if not FormEditingHook.GetDefaultComponentPosition(TypeClass,ParentCI,X,Y)
then exit; then exit;
//debugln('TComponentPalette.ComponentBtnDblClick ',dbgsName(Sender),' ',dbgs(X),',',dbgs(Y)); //debugln('TComponentPalette.ComponentBtnDblClick ',dbgsName(Sender),' ',dbgs(X),',',dbgs(Y));
DisableAutoSize:={$IFDEF OldAutoSize}false{$ELSE}true{$ENDIF}; DisableAutoSize:=true;
CompIntf:=FormEditingHook.CreateComponent(ParentCI,TypeClass,'',X,Y,0,0, CompIntf:=FormEditingHook.CreateComponent(ParentCI,TypeClass,'',X,Y,0,0,
DisableAutoSize); DisableAutoSize);
if CompIntf<>nil then begin if CompIntf<>nil then begin

View File

@ -1309,20 +1309,16 @@ begin
HiddenWindowsOnRun:=TList.Create; HiddenWindowsOnRun:=TList.Create;
// menu // menu
{$IFNDEF OldAutoSize}
MainIDEBar.DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TMainIDE.Create'){$ENDIF}; MainIDEBar.DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TMainIDE.Create'){$ENDIF};
try try
{$ENDIF}
SetupStandardIDEMenuItems; SetupStandardIDEMenuItems;
SetupMainMenu; SetupMainMenu;
SetupSpeedButtons; SetupSpeedButtons;
SetupComponentNoteBook; SetupComponentNoteBook;
ConnectMainBarEvents; ConnectMainBarEvents;
{$IFNDEF OldAutoSize}
finally finally
MainIDEBar.EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TMainIDE.Create'){$ENDIF}; MainIDEBar.EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TMainIDE.Create'){$ENDIF};
end; end;
{$ENDIF}
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.Create MENU');{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.Create MENU');{$ENDIF}
// create main IDE register items // create main IDE register items
@ -1791,9 +1787,7 @@ procedure TMainIDE.SetupSpeedButtons;
Result.Name := AName; Result.Name := AName;
Result.Parent := MainIDEBar.pnlSpeedButtons; Result.Parent := MainIDEBar.pnlSpeedButtons;
Result.Images := IDEImages.Images_16; Result.Images := IDEImages.Images_16;
{$IFNDEF OldAutoSize}
Result.AutoSize := true; Result.AutoSize := true;
{$ENDIF}
end; end;
begin begin
@ -1805,9 +1799,7 @@ begin
Align := alLeft; Align := alLeft;
Caption := ''; Caption := '';
BevelOuter := bvNone; BevelOuter := bvNone;
{$IFNDEF OldAutoSize}
AutoSize := true; AutoSize := true;
{$ENDIF}
Visible := EnvironmentOptions.IDESpeedButtonsVisible; Visible := EnvironmentOptions.IDESpeedButtonsVisible;
end; end;
@ -6121,7 +6113,7 @@ begin
if NewUnitName='' then if NewUnitName='' then
NewUnitName:=ExtractFileNameOnly(AnUnitInfo.Filename); NewUnitName:=ExtractFileNameOnly(AnUnitInfo.Filename);
// ToDo: create AncestorBinStream(s) via hook, not via parameters // ToDo: create AncestorBinStream(s) via hook, not via parameters
DisableAutoSize:={$IFDEF OldAutoSize}false{$ELSE}true{$ENDIF}; DisableAutoSize:=true;
NewComponent:=FormEditor1.CreateRawComponentFromStream(BinStream, NewComponent:=FormEditor1.CreateRawComponentFromStream(BinStream,
AncestorType,copy(NewUnitName,1,255),true,true,DisableAutoSize,AnUnitInfo); AncestorType,copy(NewUnitName,1,255),true,true,DisableAutoSize,AnUnitInfo);
if (NewComponent is TControl) then begin if (NewComponent is TControl) then begin
@ -7907,7 +7899,7 @@ begin
end else begin end else begin
// create a designer form for a form/datamodule/frame // create a designer form for a form/datamodule/frame
//DebugLn(['TMainIDE.DoNewFile Name=',NewFileDescriptor.Name,' Class=',NewFileDescriptor.ClassName]); //DebugLn(['TMainIDE.DoNewFile Name=',NewFileDescriptor.Name,' Class=',NewFileDescriptor.ClassName]);
DisableAutoSize:={$IFDEF OldAutoSize}false{$ELSE}true{$ENDIF}; DisableAutoSize:=true;
Result := CreateNewForm(NewUnitInfo, AncestorType, nil, Result := CreateNewForm(NewUnitInfo, AncestorType, nil,
NewFileDescriptor.UseCreateFormStatements, NewFileDescriptor.UseCreateFormStatements,
DisableAutoSize); DisableAutoSize);

View File

@ -6021,9 +6021,7 @@ begin
ReleaseEditor(Edit); ReleaseEditor(Edit);
Edit.UpdateNoteBook(DestWin, DestWin.NoteBookPage[NewPageIndex]); Edit.UpdateNoteBook(DestWin, DestWin.NoteBookPage[NewPageIndex]);
DestWin.AcceptEditor(Edit); DestWin.AcceptEditor(Edit);
{$IfNDef OldAutoSize}
DestWin.NotebookPage[NewPageIndex].ReAlign; DestWin.NotebookPage[NewPageIndex].ReAlign;
{$EndIf}
NoteBookDeletePage(OldPageIndex); NoteBookDeletePage(OldPageIndex);
UpdatePageNames; UpdatePageNames;
@ -6448,10 +6446,8 @@ Begin
{$IFDEF IDE_DEBUG} {$IFDEF IDE_DEBUG}
writeln('[TSourceNotebook.NewFile] A '); writeln('[TSourceNotebook.NewFile] A ');
{$ENDIF} {$ENDIF}
{$IFNDEF OldAutoSize}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TSourceNotebook.NewFile'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TSourceNotebook.NewFile'){$ENDIF};
try try
{$ENDIF}
Visible:=true; Visible:=true;
Result := NewSE(-1, -1, AShareEditor); Result := NewSE(-1, -1, AShareEditor);
{$IFDEF IDE_DEBUG} {$IFDEF IDE_DEBUG}
@ -6464,11 +6460,9 @@ Begin
Result.PageName:= Manager.FindUniquePageName(NewShortName, Result); Result.PageName:= Manager.FindUniquePageName(NewShortName, Result);
UpdatePageNames; UpdatePageNames;
UpdateProjectFiles; UpdateProjectFiles;
{$IFNDEF OldAutoSize}
finally finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TSourceNotebook.NewFile'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TSourceNotebook.NewFile'){$ENDIF};
end; end;
{$ENDIF}
if FocusIt then FocusEditor; if FocusIt then FocusEditor;
{$IFDEF IDE_DEBUG} {$IFDEF IDE_DEBUG}
writeln('[TSourceNotebook.NewFile] end'); writeln('[TSourceNotebook.NewFile] end');
@ -6486,10 +6480,8 @@ begin
TempEditor:=FindSourceEditorWithPageIndex(APageIndex); TempEditor:=FindSourceEditorWithPageIndex(APageIndex);
if TempEditor=nil then exit; if TempEditor=nil then exit;
//debugln(['TSourceNotebook.CloseFile ',TempEditor.FileName,' ',TempEditor.APageIndex]); //debugln(['TSourceNotebook.CloseFile ',TempEditor.FileName,' ',TempEditor.APageIndex]);
{$IFNDEF OldAutoSize}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TSourceNotebook.CloseFile'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TSourceNotebook.CloseFile'){$ENDIF};
try try
{$ENDIF}
Visible:=true; Visible:=true;
EndIncrementalFind; EndIncrementalFind;
TempEditor.Close; TempEditor.Close;
@ -6512,11 +6504,9 @@ begin
if not FIsClosing then if not FIsClosing then
Close; Close;
end; end;
{$IFNDEF OldAutoSize}
finally finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TSourceNotebook.CloseFile'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TSourceNotebook.CloseFile'){$ENDIF};
end; end;
{$ENDIF}
if (TempEditor <> nil) then if (TempEditor <> nil) then
TempEditor.EditorComponent.SetFocus; TempEditor.EditorComponent.SetFocus;
{$IFDEF IDE_DEBUG} {$IFDEF IDE_DEBUG}

View File

@ -84,7 +84,6 @@ type
procedure CustomAlignPosition(AControl: TControl; var ANewLeft, ANewTop, ANewWidth, procedure CustomAlignPosition(AControl: TControl; var ANewLeft, ANewTop, ANewWidth,
ANewHeight: Integer; var AlignRect: TRect; ANewHeight: Integer; var AlignRect: TRect;
AlignInfo: TAlignInfo); override; AlignInfo: TAlignInfo); override;
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure SetAlign(Value: TAlign); override; procedure SetAlign(Value: TAlign); override;
procedure CMAppShowBtnGlyphChanged(var Message: TLMessage); message CM_APPSHOWBTNGLYPHCHANGED; procedure CMAppShowBtnGlyphChanged(var Message: TLMessage); message CM_APPSHOWBTNGLYPHCHANGED;
@ -284,10 +283,8 @@ end;
procedure TCustomButtonPanel.CalculatePreferredSize(var PreferredWidth, procedure TCustomButtonPanel.CalculatePreferredSize(var PreferredWidth,
PreferredHeight: integer; WithThemeSpace: Boolean); PreferredHeight: integer; WithThemeSpace: Boolean);
begin begin
{$IFNDEF OldAutoSize}
if HandleAllocated then if HandleAllocated then
begin begin
{$ENDIF}
UpdateSizes; UpdateSizes;
if Align in [alTop, alBottom] then if Align in [alTop, alBottom] then
begin begin
@ -302,10 +299,7 @@ begin
if ShowBevel then if ShowBevel then
inc(PreferredWidth, Spacing + FBevel.Width); inc(PreferredWidth, Spacing + FBevel.Width);
end; end;
{$IFNDEF OldAutoSize}
ReAlign;
end; end;
{$ENDIF}
end; end;
procedure TCustomButtonPanel.UpdateButtonOrder; procedure TCustomButtonPanel.UpdateButtonOrder;
@ -333,20 +327,14 @@ end;
procedure TCustomButtonPanel.SetAlign(Value: TAlign); procedure TCustomButtonPanel.SetAlign(Value: TAlign);
begin begin
{$IFNDEF OldAutoSize}
DisableAutoSizing; DisableAutoSizing;
{$ENDIF}
try try
inherited SetAlign(Value); inherited SetAlign(Value);
UpdateBevel; UpdateBevel;
{$IFNDEF OldAutoSize}
UpdateSizes; UpdateSizes;
Realign; Realign;
{$ENDIF}
finally finally
{$IFNDEF OldAutoSize}
EnableAutoSizing; EnableAutoSizing;
{$ENDIF}
end; end;
end; end;
@ -394,9 +382,7 @@ begin
Exit; Exit;
end; end;
{$IFNDEF OldAutoSize}
DisableAutoSizing; DisableAutoSizing;
{$ENDIF}
try try
FBevel := TBevel.Create(Self); FBevel := TBevel.Create(Self);
FBevel.Parent := Self; FBevel.Parent := Self;
@ -405,20 +391,10 @@ begin
UpdateBevel; UpdateBevel;
finally finally
{$IFNDEF OldAutoSize}
EnableAutoSizing; EnableAutoSizing;
{$ENDIF}
end; end;
end; end;
procedure TCustomButtonPanel.Loaded;
begin
inherited Loaded;
{$IFDEF OldAutoSize}
Realign;
{$ENDIF}
end;
procedure TCustomButtonPanel.Notification(AComponent: TComponent; procedure TCustomButtonPanel.Notification(AComponent: TComponent;
Operation: TOperation); Operation: TOperation);
var var

View File

@ -1579,9 +1579,6 @@ type
function DialogChar(var Message: TLMKey): boolean; override; function DialogChar(var Message: TLMKey): boolean; override;
procedure SetAutoSize(Value: Boolean); override; procedure SetAutoSize(Value: Boolean); override;
procedure RealSetText(const AValue: TCaption); override; procedure RealSetText(const AValue: TCaption); override;
{$IFDEF OldAutoSize}
procedure DoAutoSize; override;
{$ENDIF}
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
function CheckMenuDropdown: Boolean; virtual; function CheckMenuDropdown: Boolean; virtual;

View File

@ -231,10 +231,6 @@ type
csClicked, csClicked,
csPalette, csPalette,
csReadingState, csReadingState,
{$IFDEF OldAutoSize}
// deprecated
csAlignmentNeeded,
{$ENDIF}
csFocusing, csFocusing,
csCreating, // not used, exists for Delphi compatibility csCreating, // not used, exists for Delphi compatibility
csPaintCopy, csPaintCopy,
@ -794,7 +790,6 @@ type
{ TControl } { TControl }
{$IFNDEF OldAutoSize}
TControlAutoSizePhase = ( TControlAutoSizePhase = (
caspNone, caspNone,
caspChangingProperties, caspChangingProperties,
@ -804,7 +799,6 @@ type
caspShowing // make handles visible caspShowing // make handles visible
); );
TControlAutoSizePhases = set of TControlAutoSizePhase; TControlAutoSizePhases = set of TControlAutoSizePhase;
{$ENDIF}
TTabOrder = -1..32767; TTabOrder = -1..32767;
@ -813,12 +807,7 @@ type
var Handled: Boolean) of object; var Handled: Boolean) of object;
TControlFlag = ( TControlFlag = (
{$IFDEF OldAutoSize}
// obsolete
cfRequestAlignNeeded,
{$ELSE}
cfLoading, // set by TControl.ReadState, unset by TControl.Loaded when all on form finished loading cfLoading, // set by TControl.ReadState, unset by TControl.Loaded when all on form finished loading
{$ENDIF}
cfAutoSizeNeeded, cfAutoSizeNeeded,
cfLeftLoaded, // cfLeftLoaded is set, when 'Left' is set during loading. cfLeftLoaded, // cfLeftLoaded is set, when 'Left' is set during loading.
cfTopLoaded, cfTopLoaded,
@ -830,9 +819,6 @@ type
cfBaseBoundsValid, cfBaseBoundsValid,
cfPreferredSizeValid, cfPreferredSizeValid,
cfPreferredMinSizeValid, cfPreferredMinSizeValid,
{$IFDEF OldAutoSize}
cfOnResizeNeeded,
{$ENDIF}
cfOnChangeBoundsNeeded cfOnChangeBoundsNeeded
); );
TControlFlags = set of TControlFlag; TControlFlags = set of TControlFlag;
@ -896,10 +882,6 @@ type
FHelpType: THelpType; FHelpType: THelpType;
FHint: TTranslateString; FHint: TTranslateString;
FHostDockSite: TWinControl; FHostDockSite: TWinControl;
{$IFDEF OldAutoSize}
fLastAlignedBounds: TRect;
fLastAlignedBoundsTried: integer;
{$ENDIF}
FLastChangebounds: TRect; FLastChangebounds: TRect;
FLastDoChangeBounds: TRect; FLastDoChangeBounds: TRect;
FLastDoChangeClientSize: TPoint; FLastDoChangeClientSize: TPoint;
@ -957,18 +939,14 @@ type
FParentFont: Boolean; FParentFont: Boolean;
FParentShowHint: Boolean; FParentShowHint: Boolean;
FAutoSize: Boolean; FAutoSize: Boolean;
{$IFNDEF OldAutoSize}
FAutoSizingAll: boolean; FAutoSizingAll: boolean;
{$ENDIF}
FAutoSizingSelf: Boolean; FAutoSizingSelf: Boolean;
FEnabled: Boolean; FEnabled: Boolean;
FMouseEntered: boolean; FMouseEntered: boolean;
FVisible: Boolean; FVisible: Boolean;
function CaptureMouseButtonsIsStored: boolean; function CaptureMouseButtonsIsStored: boolean;
procedure DoActionChange(Sender: TObject); procedure DoActionChange(Sender: TObject);
{$IFNDEF OldAutoSize}
function GetAutoSizingAll: Boolean; function GetAutoSizingAll: Boolean;
{$ENDIF}
function GetAnchorSide(Kind: TAnchorKind): TAnchorSide; function GetAnchorSide(Kind: TAnchorKind): TAnchorSide;
function GetAnchorSideIndex(Index: integer): TAnchorSide; function GetAnchorSideIndex(Index: integer): TAnchorSide;
function GetAnchoredControls(Index: integer): TControl; function GetAnchoredControls(Index: integer): TControl;
@ -1032,14 +1010,9 @@ type
protected protected
// sizing/aligning // sizing/aligning
procedure DoAutoSize; virtual; procedure DoAutoSize; virtual;
{$IFNDEF OldAutoSize}
procedure DoAllAutoSize; virtual; // while autosize needed call DoAutoSize, used by AdjustSize and EnableAutoSizing 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 procedure BeginAutoSizing; // set AutoSizing=true, can be used to prevent circles
procedure EndAutoSizing; // set AutoSizing=false procedure EndAutoSizing; // set AutoSizing=false
{$IFDEF OldAutoSize}
function AutoSizeCanStart: boolean; virtual;
{$ENDIF}
procedure AnchorSideChanged(TheAnchorSide: TAnchorSide); virtual; procedure AnchorSideChanged(TheAnchorSide: TAnchorSide); virtual;
procedure ForeignAnchorSideChanged(TheAnchorSide: TAnchorSide; procedure ForeignAnchorSideChanged(TheAnchorSide: TAnchorSide;
Operation: TAnchorSideChangeOperation); virtual; Operation: TAnchorSideChangeOperation); virtual;
@ -1064,16 +1037,11 @@ type
procedure Resize; virtual;// checks for changes and calls DoOnResize procedure Resize; virtual;// checks for changes and calls DoOnResize
procedure RequestAlign; virtual;// smart calling Parent.AlignControls procedure RequestAlign; virtual;// smart calling Parent.AlignControls
procedure UpdateAnchorRules; procedure UpdateAnchorRules;
procedure ChangeBounds(ALeft, ATop, AWidth, AHeight: integer procedure ChangeBounds(ALeft, ATop, AWidth, AHeight: integer; KeepBase: boolean); virtual;
{$IFNDEF OldAutoSize}; KeepBase: boolean{$ENDIF}); virtual;
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); virtual; procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); virtual;
procedure ChangeScale(Multiplier, Divider: Integer); virtual; procedure ChangeScale(Multiplier, Divider: Integer); virtual;
function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; virtual; function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; virtual;
{$IFDEF OldAutoSize}
procedure SetAlignedBounds(aLeft, aTop, aWidth, aHeight: integer); virtual;
{$ELSE}
procedure UpdateAlignIndex; procedure UpdateAlignIndex;
{$ENDIF}
procedure SetBiDiMode(AValue: TBiDiMode); virtual; procedure SetBiDiMode(AValue: TBiDiMode); virtual;
procedure SetParentBiDiMode(AValue: Boolean); virtual; procedure SetParentBiDiMode(AValue: Boolean); virtual;
function IsAParentAligning: boolean; function IsAParentAligning: boolean;
@ -1089,9 +1057,7 @@ type
function HeightIsAnchored: boolean; function HeightIsAnchored: boolean;
property AutoSizing: Boolean read FAutoSizingSelf;// see Begin/EndAutoSizing property AutoSizing: Boolean read FAutoSizingSelf;// see Begin/EndAutoSizing
{$IFNDEF OldAutoSize}
property AutoSizingAll: Boolean read GetAutoSizingAll;// set in DoAllAutoSize property AutoSizingAll: Boolean read GetAutoSizingAll;// set in DoAllAutoSize
{$ENDIF}
property AutoSizingLockCount: Integer read FAutoSizingLockCount; property AutoSizingLockCount: Integer read FAutoSizingLockCount;
protected protected
// protected messages // protected messages
@ -1280,9 +1246,7 @@ type
public public
// size // size
procedure AdjustSize; virtual;// smart calling DoAutoSize procedure AdjustSize; virtual;// smart calling DoAutoSize
{$IFNDEF OldAutoSize}
function AutoSizePhases: TControlAutoSizePhases; virtual; function AutoSizePhases: TControlAutoSizePhases; virtual;
{$ENDIF}
function AutoSizeDelayed: boolean; virtual; function AutoSizeDelayed: boolean; virtual;
function AutoSizeCheckParent: Boolean; virtual; function AutoSizeCheckParent: Boolean; virtual;
procedure AnchorToNeighbour(Side: TAnchorKind; Space: integer; procedure AnchorToNeighbour(Side: TAnchorKind; Space: integer;
@ -1302,7 +1266,7 @@ type
procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); virtual; procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); virtual;
procedure SetInitialBounds(aLeft, aTop, aWidth, aHeight: integer); virtual; procedure SetInitialBounds(aLeft, aTop, aWidth, aHeight: integer); virtual;
procedure SetBoundsKeepBase(aLeft, aTop, aWidth, aHeight: integer procedure SetBoundsKeepBase(aLeft, aTop, aWidth, aHeight: integer
{$IFDEF OldAutoSize}; Lock: boolean = true{$ENDIF}); virtual; // if you use this, disable the LCL autosizing for this control ); virtual; // if you use this, disable the LCL autosizing for this control
procedure GetPreferredSize(var PreferredWidth, PreferredHeight: integer; procedure GetPreferredSize(var PreferredWidth, PreferredHeight: integer;
Raw: boolean = false; Raw: boolean = false;
WithThemeSpace: boolean = true); virtual; WithThemeSpace: boolean = true); virtual;
@ -1319,10 +1283,6 @@ type
{$ENDIF} {$ENDIF}
procedure UpdateBaseBounds(StoreBounds, StoreParentClientSize, procedure UpdateBaseBounds(StoreBounds, StoreParentClientSize,
UseLoadedValues: boolean); virtual; UseLoadedValues: boolean); virtual;
{$IFDEF OldAutoSize}
procedure LockBaseBounds;
procedure UnlockBaseBounds;
{$ENDIF}
property BaseBounds: TRect read FBaseBounds; property BaseBounds: TRect read FBaseBounds;
property ReadBounds: TRect read FReadBounds; property ReadBounds: TRect read FReadBounds;
procedure WriteLayoutDebugReport(const Prefix: string); virtual; procedure WriteLayoutDebugReport(const Prefix: string); virtual;
@ -1617,11 +1577,7 @@ type
wcfClientRectNeedsUpdate, wcfClientRectNeedsUpdate,
wcfColorChanged, wcfColorChanged,
wcfFontChanged, // Set if font was changed before handle creation wcfFontChanged, // Set if font was changed before handle creation
{$IFDEF OldAutoSize}
wcfReAlignNeeded,
{$ELSE}
wcfAllAutoSizing, wcfAllAutoSizing,
{$ENDIF}
wcfAligningControls, wcfAligningControls,
wcfEraseBackground, wcfEraseBackground,
wcfCreatingHandle, // Set while constructing the handle of this control wcfCreatingHandle, // Set while constructing the handle of this control
@ -1693,9 +1649,6 @@ type
FTabOrder: integer; FTabOrder: integer;
FTabList: TFPList; FTabList: TFPList;
// keep small variables together to save some bytes // keep small variables together to save some bytes
{$IFDEF OldAutoSize}
FAlignLevel: Word;
{$ENDIF}
FTabStop: Boolean; FTabStop: Boolean;
FShowing: Boolean; FShowing: Boolean;
FDoubleBuffered: Boolean; FDoubleBuffered: Boolean;
@ -1741,9 +1694,6 @@ type
function DoAlignChildControls(TheAlign: TAlign; AControl: TControl; function DoAlignChildControls(TheAlign: TAlign; AControl: TControl;
AControlList: TFPList; var ARect: TRect): Boolean; virtual; AControlList: TFPList; var ARect: TRect): Boolean; virtual;
procedure DoChildSizingChange(Sender: TObject); virtual; procedure DoChildSizingChange(Sender: TObject); virtual;
{$IFDEF OldAutoSize}
procedure ResizeDelayedAutoSizeChildren; virtual;
{$ENDIF}
procedure InvalidatePreferredChildSizes; procedure InvalidatePreferredChildSizes;
function CanTab: Boolean; override; function CanTab: Boolean; override;
function IsClientHeightStored: boolean; override; function IsClientHeightStored: boolean; override;
@ -1757,10 +1707,8 @@ type
procedure DoConstraintsChange(Sender: TObject); override; procedure DoConstraintsChange(Sender: TObject); override;
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); override; procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
procedure DoAutoSize; override; procedure DoAutoSize; override;
{$IFNDEF OldAutoSize}
procedure DoAllAutoSize; override; procedure DoAllAutoSize; override;
procedure AllAutoSized; virtual; // called by DoAllAutoSize after all bounds are computed, see TCustomForm.AllAutoSized procedure AllAutoSized; virtual; // called by DoAllAutoSize after all bounds are computed, see TCustomForm.AllAutoSized
{$ENDIF}
procedure CalculatePreferredSize(var PreferredWidth, procedure CalculatePreferredSize(var PreferredWidth,
PreferredHeight: integer; PreferredHeight: integer;
WithThemeSpace: Boolean); override; WithThemeSpace: Boolean); override;
@ -1928,9 +1876,7 @@ type
property VisibleDockClientCount: Integer read GetVisibleDockClientCount; property VisibleDockClientCount: Integer read GetVisibleDockClientCount;
public public
// size, position, bounds // size, position, bounds
{$IFNDEF OldAutoSize}
function AutoSizePhases: TControlAutoSizePhases; override; function AutoSizePhases: TControlAutoSizePhases; override;
{$ENDIF}
function AutoSizeDelayed: boolean; override; function AutoSizeDelayed: boolean; override;
function AutoSizeCheckParent: Boolean; override; function AutoSizeCheckParent: Boolean; override;
procedure BeginUpdateBounds; // disable SetBounds procedure BeginUpdateBounds; // disable SetBounds
@ -2351,7 +2297,6 @@ const
'alNone', 'alTop', 'alBottom', 'alLeft', 'alRight', 'alClient', 'alCustom'); 'alNone', 'alTop', 'alBottom', 'alLeft', 'alRight', 'alClient', 'alCustom');
AnchorNames: array[TAnchorKind] of string = ( AnchorNames: array[TAnchorKind] of string = (
'akTop', 'akLeft', 'akRight', 'akBottom'); 'akTop', 'akLeft', 'akRight', 'akBottom');
{$IFNDEF OldAutoSize}
AutoSizePhaseNames: array[TControlAutoSizePhase] of string = ( AutoSizePhaseNames: array[TControlAutoSizePhase] of string = (
'caspNone', 'caspNone',
'caspChangingProperties', 'caspChangingProperties',
@ -2360,7 +2305,6 @@ const
'caspRealizingBounds', 'caspRealizingBounds',
'caspShowing' 'caspShowing'
); );
{$ENDIF}
function FindDragTarget(const Position: TPoint; AllowDisabled: Boolean): TControl; function FindDragTarget(const Position: TPoint; AllowDisabled: Boolean): TControl;
function FindControlAtPosition(const Position: TPoint; AllowDisabled: Boolean): TControl; function FindControlAtPosition(const Position: TPoint; AllowDisabled: Boolean): TControl;
@ -2415,10 +2359,8 @@ function DbgS(a: TAnchorKind): string; overload;
function DbgS(Anchors: TAnchors): string; overload; function DbgS(Anchors: TAnchors): string; overload;
function DbgS(a: TAlign): string; overload; function DbgS(a: TAlign): string; overload;
function DbgS(a: TAnchorKind; Side: TAnchorSideReference): string; overload; function DbgS(a: TAnchorKind; Side: TAnchorSideReference): string; overload;
{$IFNDEF OldAutoSize}
function DbgS(p: TControlAutoSizePhase): string; overload; function DbgS(p: TControlAutoSizePhase): string; overload;
function DbgS(Phases: TControlAutoSizePhases): string; overload; function DbgS(Phases: TControlAutoSizePhases): string; overload;
{$ENDIF}
operator := (AVariant: Variant): TCaption; operator := (AVariant: Variant): TCaption;
@ -2605,7 +2547,6 @@ begin
end; end;
end; end;
{$IFNDEF OldAutoSize}
function DbgS(p: TControlAutoSizePhase): string; overload; function DbgS(p: TControlAutoSizePhase): string; overload;
begin begin
Result:=AutoSizePhaseNames[p]; Result:=AutoSizePhaseNames[p];
@ -2624,7 +2565,6 @@ begin
end; end;
Result:='['+Result+']'; Result:='['+Result+']';
end; end;
{$ENDIF}
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
RecreateWnd RecreateWnd

View File

@ -530,9 +530,7 @@ type
procedure MoveToDefaultPosition; virtual; procedure MoveToDefaultPosition; virtual;
procedure UpdateShowing; override; procedure UpdateShowing; override;
procedure SetVisible(Value: boolean); override; procedure SetVisible(Value: boolean); override;
{$ifndef OldAutoSize}
procedure AllAutoSized; override; procedure AllAutoSized; override;
{$endif}
procedure DoFirstShow; virtual; procedure DoFirstShow; virtual;
procedure UpdateWindowState; procedure UpdateWindowState;
procedure VisibleChanging; override; procedure VisibleChanging; override;

View File

@ -40,18 +40,6 @@
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.Adjustsize; procedure TControl.Adjustsize;
begin begin
{$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));
Include(FControlFlags,cfAutoSizeNeeded);
exit;
end;
//debugln(['TControl.AdjustSize DoAutoSize ',DbgSName(Self)]);
DoAutoSize;
Exclude(FControlFlags,cfAutoSizeNeeded);
{$ELSE}
{$IFDEF VerboseAdjustSize} {$IFDEF VerboseAdjustSize}
if (Parent=nil) and (not (cfAutoSizeNeeded in FControlFlags)) if (Parent=nil) and (not (cfAutoSizeNeeded in FControlFlags))
and (Self is TCustomForm) then begin and (Self is TCustomForm) then begin
@ -71,7 +59,6 @@ begin
if not AutoSizeDelayed then if not AutoSizeDelayed then
DoAllAutoSize; DoAllAutoSize;
end; end;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -336,8 +323,8 @@ end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TControl.ChangeBounds TControl.ChangeBounds
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.ChangeBounds(ALeft, ATop, AWidth, AHeight: integer procedure TControl.ChangeBounds(ALeft, ATop, AWidth, AHeight: integer;
{$IFNDEF OldAutoSize}; KeepBase: boolean{$ENDIF}); KeepBase: boolean);
var var
SizeChanged, PosChanged : boolean; SizeChanged, PosChanged : boolean;
OldLeft: Integer; OldLeft: Integer;
@ -390,50 +377,9 @@ begin
// change base bounds // change base bounds
// (base bounds are the base for the automatic resizing) // (base bounds are the base for the automatic resizing)
{$IFNDEF OldAutoSize}
if not KeepBase then if not KeepBase then
{$ENDIF}
UpdateAnchorRules; UpdateAnchorRules;
{$IFDEF OldAutoSize}
// lock the base bounds while automatic resizing
LockBaseBounds;
// lock size messages
inc(FSizeLock);
try
// lock the autosizing of the child controls
if Self is TWinControl then
TWinControl(Self).DisableAlign;
try
// resize parents client area
if Parent <> nil then
Parent.AdjustSize;
if PosSizeKept then exit;
// notify before autosizing
BoundsChanged;
if PosSizeKept then exit;
//if csDesigning in ComponentState then
// DebugLn('TControl.ChangeBounds ',Name,':',ClassName,' ',Left,',',Top,',',Width,',',Height);
// autosize this control and its brothers
RequestAlign;
if PosSizeKept then exit;
// autosize childs
if SizeChanged and (Self is TWinControl) then
TWinControl(Self).ReAlign;
finally
// unlock the autosizing of the child controls
// (this will autosize the childs)
if Self is TWinControl then
TWinControl(Self).EnableAlign;
// autosize self
AdjustSize;
end;
finally
dec(FSizeLock);
UnlockBaseBounds;
end;
{$ELSE}
// lock size messages // lock size messages
inc(FSizeLock); inc(FSizeLock);
try try
@ -445,7 +391,6 @@ begin
finally finally
dec(FSizeLock); dec(FSizeLock);
end; end;
{$ENDIF}
if PosSizeKept then exit; if PosSizeKept then exit;
// send messages, if this is the top level call // send messages, if this is the top level call
@ -560,9 +505,7 @@ begin
if (FloatingClass<>nil) and (FloatingClass<>TWinControlClass(ClassType)) then if (FloatingClass<>nil) and (FloatingClass<>TWinControlClass(ClassType)) then
begin begin
Result := TWinControl(FloatingClass.NewInstance); Result := TWinControl(FloatingClass.NewInstance);
{$IFNDEF OldAutoSize}
Result.DisableAutoSizing; Result.DisableAutoSizing;
{$ENDIF}
Result.Create(Self); Result.Create(Self);
// resize with minimal resizes // resize with minimal resizes
NewClientWidth:=Bounds.Right-Bounds.Left; NewClientWidth:=Bounds.Right-Bounds.Left;
@ -572,9 +515,7 @@ begin
Result.SetBounds(Bounds.Left,Bounds.Top,NewWidth,NewHeight); Result.SetBounds(Bounds.Left,Bounds.Top,NewWidth,NewHeight);
Result.SetClientSize(Point(NewClientWidth,NewClientHeight)); Result.SetClientSize(Point(NewClientWidth,NewClientHeight));
debugln('TControl.CreateFloatingDockSite A ',DbgSName(Self),' ',DbgSName(Result),' ',dbgs(Result.BoundsRect)); debugln('TControl.CreateFloatingDockSite A ',DbgSName(Self),' ',DbgSName(Result),' ',dbgs(Result.BoundsRect));
{$IFNDEF OldAutoSize}
Result.EnableAutoSizing; Result.EnableAutoSizing;
{$ENDIF}
end; end;
end; end;
@ -885,9 +826,6 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.DoOnResize; procedure TControl.DoOnResize;
begin begin
{$IFDEF OldAutoSize}
Exclude(FControlFlags,cfOnResizeNeeded);
{$ENDIF}
if Assigned(FOnResize) then FOnResize(Self); if Assigned(FOnResize) then FOnResize(Self);
DoCallNotifyHandler(chtOnResize); DoCallNotifyHandler(chtOnResize);
end; end;
@ -1368,47 +1306,13 @@ begin
OnShowHint(Self,HintInfo); OnShowHint(Self,HintInfo);
end; end;
{$IFDEF OldAutoSize}
procedure TControl.SetAlignedBounds(aLeft, aTop, aWidth, aHeight: integer);
{ try to set the automatic changed bounds
If the interface does not like our bounds, it sends a message with the real
bounds, which invokes the automatic realigning of the control, .. a circle.
To break the circle, only bounds that are different from the last try will
be sent.
}
var
NewBounds: TRect;
begin
NewBounds:=Bounds(aLeft, aTop, aWidth, aHeight);
if (fLastAlignedBoundsTried>0)
and CompareRect(@NewBounds,@fLastAlignedBounds) then begin
inc(fLastAlignedBoundsTried);
if fLastAlignedBoundsTried>4 then begin
DebugLn(['TControl.SetAlignedBounds ',DbgSName(Self),' last try ',dbgs(NewBounds),' try=',fLastAlignedBoundsTried]);
exit;
end;
end;
fLastAlignedBounds:=NewBounds;
fLastAlignedBoundsTried:=1;
//if AnsiCompareText(ClassName,'TSCROLLBAR')=0 then
// DebugLn('TControl.SetAlignedBounds A ',Name,':',ClassName,' ',aLeft,',',aTop,',',aWidth,',',aHeight);
SetBoundsKeepBase(aLeft, aTop, aWidth, aHeight{$IFDEF OldAutoSize}, true{$ENDIF});
end;
{$ENDIF}
function TControl.IsAParentAligning: boolean; function TControl.IsAParentAligning: boolean;
var var
p: TWinControl; p: TWinControl;
begin begin
p:=Parent; p:=Parent;
while (p<>nil) do begin while (p<>nil) do begin
if (wcfAligningControls in p.FWinControlFlags) if (wcfAligningControls in p.FWinControlFlags) then
{$IFDEF OldAutoSize}
or (p.FAlignLevel>0)
{$ENDIF}
then
exit(true); exit(true);
p:=p.Parent; p:=p.Parent;
end; end;
@ -1516,7 +1420,6 @@ begin
Result := TControl(FAnchoredControls[Index]); Result := TControl(FAnchoredControls[Index]);
end; end;
{$IFNDEF OldAutoSize}
function TControl.GetAutoSizingAll: Boolean; function TControl.GetAutoSizingAll: Boolean;
begin begin
if Parent <> nil then if Parent <> nil then
@ -1524,7 +1427,6 @@ begin
else else
Result := FAutoSizingAll; Result := FAutoSizingAll;
end; end;
{$ENDIF}
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TControl GetClientRect TControl GetClientRect
@ -2441,16 +2343,13 @@ end;
That's why you should always call AdjustSize instead of DoAutoSize. That's why you should always call AdjustSize instead of DoAutoSize.
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.DoAutoSize; procedure TControl.DoAutoSize;
{$IFNDEF OldAutoSize}
var var
PreferredWidth: integer; PreferredWidth: integer;
PreferredHeight: integer; PreferredHeight: integer;
ResizeWidth: Boolean; ResizeWidth: Boolean;
ResizeHeight: Boolean; ResizeHeight: Boolean;
{$ENDIF}
begin begin
// handled by TWinControl, or other descendants // handled by TWinControl, or other descendants
{$IFNDEF OldAutoSize}
ResizeWidth:=not WidthIsAnchored; ResizeWidth:=not WidthIsAnchored;
ResizeHeight:=not HeightIsAnchored; ResizeHeight:=not HeightIsAnchored;
if ResizeWidth or ResizeHeight then begin if ResizeWidth or ResizeHeight then begin
@ -2461,7 +2360,6 @@ begin
if (not ResizeHeight) or (PreferredHeight<=0) then PreferredHeight:=Height; if (not ResizeHeight) or (PreferredHeight<=0) then PreferredHeight:=Height;
SetBoundsKeepBase(Left,Top,PreferredWidth,PreferredHeight); SetBoundsKeepBase(Left,Top,PreferredWidth,PreferredHeight);
end; end;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -2469,7 +2367,6 @@ end;
Run DoAutoSize until done. Run DoAutoSize until done.
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
{$IFNDEF OldAutoSize}
procedure TControl.DoAllAutoSize; procedure TControl.DoAllAutoSize;
procedure AutoSizeControl(AControl: TControl); procedure AutoSizeControl(AControl: TControl);
@ -2547,7 +2444,6 @@ begin
DebugLn(['TControl.DoAllAutoSize END ',DbgSName(Self),' ',dbgs(BoundsRect)]); DebugLn(['TControl.DoAllAutoSize END ',DbgSName(Self),' ',dbgs(BoundsRect)]);
{$ENDIF} {$ENDIF}
end; end;
{$ENDIF}
procedure TControl.AnchorSideChanged(TheAnchorSide: TAnchorSide); procedure TControl.AnchorSideChanged(TheAnchorSide: TAnchorSide);
begin begin
@ -2582,43 +2478,6 @@ begin
end; end;
end; end;
{$IFDEF OldAutoSize}
{------------------------------------------------------------------------------
function TControl.AutoSizeCanStart: boolean;
Returns true if DoAutoSize can start. That means, it tests the minimum
requirements to start. Some controls need even more.
It returns false if
- AutoSize=false
- or the control is currently autosizing
- or the control is not visible
- or the control is destroying
------------------------------------------------------------------------------}
function TControl.AutoSizeCanStart: boolean;
begin
Result:=AutoSize
and (not AutoSizing)
and (not (csDestroying in ComponentState))
and ((not (csDesigning in ComponentState)) or (Parent<>nil)) // do not autosize forms in the designer
and IsControlVisible;
{$IFDEF VerboseCanAutoSize}
if (not Result) and AutoSize then begin
DbgOut('TControl.AutoSizeCanStart Self='+DbgSName(Self)+' ');
if not AutoSize then DebugLn('not AutoSize')
else if AutoSizing then DebugLn('AutoSizing')
else if csDestroying in ComponentState then DebugLn('csDestroying in ComponentState')
else if not IsControlVisible then
DebugLn('Visible=',dbgs(Visible),
' csDesigning=',dbgs(csDesigning in ComponentState),
' csNoDesignVisible=',dbgs(csNoDesignVisible in ControlStyle))
else DebugLn('?');
end;
{$ENDIF}
end;
{$ENDIF}
{$IFNDEF OldAutoSize}
function TControl.AutoSizePhases: TControlAutoSizePhases; function TControl.AutoSizePhases: TControlAutoSizePhases;
begin begin
if Parent<>nil then if Parent<>nil then
@ -2626,7 +2485,6 @@ begin
else else
Result:=[]; Result:=[];
end; end;
{$ENDIF}
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
function TControl.AutoSizeDelayed: boolean; function TControl.AutoSizeDelayed: boolean;
@ -2639,9 +2497,7 @@ begin
Result:=(FAutoSizingLockCount>0) Result:=(FAutoSizingLockCount>0)
// no autosize during loading or destruction // no autosize during loading or destruction
or ([csLoading,csDestroying]*ComponentState<>[]) or ([csLoading,csDestroying]*ComponentState<>[])
{$IFNDEF OldAutoSize}
or (cfLoading in FControlFlags) or (cfLoading in FControlFlags)
{$ENDIF}
// no autosize for invisible controls // no autosize for invisible controls
or (not IsControlVisible) or (not IsControlVisible)
// if there is no parent, then this control is not visible // if there is no parent, then this control is not visible
@ -3123,19 +2979,11 @@ end;
procedure TControl.Resize; procedure TControl.Resize;
begin begin
if ([csLoading,csDestroying]*ComponentState<>[]) then exit; if ([csLoading,csDestroying]*ComponentState<>[]) then exit;
{$IFNDEF OldAutoSize}
if AutoSizeDelayed then exit; if AutoSizeDelayed then exit;
{$ENDIF}
if (FLastResizeWidth<>Width) or (FLastResizeHeight<>Height) if (FLastResizeWidth<>Width) or (FLastResizeHeight<>Height)
or (FLastResizeClientWidth<>ClientWidth) or (FLastResizeClientWidth<>ClientWidth)
or (FLastResizeClientHeight<>ClientHeight) then begin or (FLastResizeClientHeight<>ClientHeight) then begin
{$IFDEF OldAutoSize}
if FormIsUpdating then begin
Include(FControlFlags,cfOnResizeNeeded);
exit;
end;
{$ENDIF}
//if AnsiCompareText('NOTEBOOK',Name)=0 then //if AnsiCompareText('NOTEBOOK',Name)=0 then
{DebugLn(['[TControl.Resize] ',Name,':',ClassName, {DebugLn(['[TControl.Resize] ',Name,':',ClassName,
' Last=',FLastResizeWidth,',',FLastResizeHeight, ' Last=',FLastResizeWidth,',',FLastResizeHeight,
@ -3152,7 +3000,6 @@ end;
procedure TControl.Loaded; procedure TControl.Loaded;
{$IFNDEF OldAutoSize}
function FindLoadingControl(AControl: TControl): TControl; function FindLoadingControl(AControl: TControl): TControl;
var var
i: Integer; i: Integer;
@ -3202,7 +3049,6 @@ procedure TControl.Loaded;
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.Loaded.CheckLoading'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.Loaded.CheckLoading'){$ENDIF};
end; end;
end; end;
{$ENDIF}
var var
UseClientWidthForWidth: boolean; UseClientWidthForWidth: boolean;
@ -3261,27 +3107,12 @@ begin
UpdateBaseBounds(true,true,true); UpdateBaseBounds(true,true,true);
{$IFDEF OldAutoSize}
// obsolete
// align this control and the brothers
if cfRequestAlignNeeded in FControlFlags then
RequestAlign;
// autosize this control
if cfAutoSizeNeeded in FControlFlags then
AdjustSize;
{$ENDIF}
// store designed width and height for undocking // store designed width and height for undocking
FUndockHeight := Height; FUndockHeight := Height;
FUndockWidth := Width; FUndockWidth := Width;
if Action <> nil then ActionChange(Action, True); if Action <> nil then ActionChange(Action, True);
{$IFDEF OldAutoSize}
CheckOnChangeBounds;
{$ELSE}
CheckLoading(Self); CheckLoading(Self);
{$ENDIF}
end; end;
procedure TControl.LoadedAll; procedure TControl.LoadedAll;
@ -3323,29 +3154,20 @@ end;
procedure TControl.ReadState(Reader: TReader); procedure TControl.ReadState(Reader: TReader);
begin begin
{$IFNDEF OldAutoSize}
Include(FControlFlags,cfLoading); Include(FControlFlags,cfLoading);
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.ReadState'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.ReadState'){$ENDIF};
try try
{$ENDIF}
inherited ReadState(Reader); inherited ReadState(Reader);
{$IFNDEF OldAutoSize}
finally finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.ReadState'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.ReadState'){$ENDIF};
end; end;
{$ENDIF}
end; end;
procedure TControl.FormEndUpdated; procedure TControl.FormEndUpdated;
// called when control is on a form and EndFormUpdate reached 0 // called when control is on a form and EndFormUpdate reached 0
// it is called recursively // it is called recursively
begin begin
{$IFDEF OldAutoSize}
if cfOnResizeNeeded in FControlFlags then
Resize;
if cfOnChangeBoundsNeeded in FControlFlags then
CheckOnChangeBounds;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -3353,7 +3175,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.SetBounds(ALeft, ATop, AWidth, AHeight: integer); procedure TControl.SetBounds(ALeft, ATop, AWidth, AHeight: integer);
begin begin
ChangeBounds(ALeft, ATop, AWidth, AHeight{$IFNDEF OldAutoSize},false{$ENDIF}); ChangeBounds(ALeft, ATop, AWidth, AHeight, false);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -3375,9 +3197,6 @@ begin
//DebugLn(['TControl.SetAlign ',DbgSName(Self),' Old=',AlignNames[FAlign],' New=',AlignNames[Value],' ',Anchors<>AnchorAlign[FAlign]]); //DebugLn(['TControl.SetAlign ',DbgSName(Self),' Old=',AlignNames[FAlign],' New=',AlignNames[Value],' ',Anchors<>AnchorAlign[FAlign]]);
OldAlign := FAlign; OldAlign := FAlign;
FAlign := Value; FAlign := Value;
{$IFDEF OldAutoSize}
fLastAlignedBoundsTried:=0;
{$ENDIF}
// if anchors were on default then change them to new default // if anchors were on default then change them to new default
// This is done for Delphi compatibility. // This is done for Delphi compatibility.
if (Anchors = AnchorAlign[OldAlign]) and (Anchors <> AnchorAlign[FAlign]) then if (Anchors = AnchorAlign[OldAlign]) and (Anchors <> AnchorAlign[FAlign]) then
@ -3393,12 +3212,7 @@ procedure TControl.SetAnchors(const AValue: TAnchors);
begin begin
if Anchors = AValue then Exit; if Anchors = AValue then Exit;
FAnchors := AValue; FAnchors := AValue;
{$IFDEF OldAutoSize}
fLastAlignedBoundsTried:=0;
RequestAlign;
{$ELSE}
AdjustSize; AdjustSize;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -3408,19 +3222,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.RequestAlign; procedure TControl.RequestAlign;
begin begin
{$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));
Include(FControlFlags,cfRequestAlignNeeded);
exit;
end;
//debugln('TControl.RequestAlign AlignControl ',DbgSName(Self));
Parent.AlignControl(Self);
Exclude(FControlFlags,cfRequestAlignNeeded);
{$ELSE}
AdjustSize; AdjustSize;
{$ENDIF}
end; end;
procedure TControl.UpdateBaseBounds(StoreBounds, procedure TControl.UpdateBaseBounds(StoreBounds,
@ -3464,24 +3266,8 @@ begin
FBaseBounds:=NewBaseBounds; FBaseBounds:=NewBaseBounds;
Include(FControlFlags,cfBaseBoundsValid); Include(FControlFlags,cfBaseBoundsValid);
FBaseParentClientSize:=NewBaseParentClientSize; FBaseParentClientSize:=NewBaseParentClientSize;
{$IFDEF OldAutoSize}
fLastAlignedBounds:=Rect(0,0,0,0);
{$ENDIF}
end; end;
{$IFDEF OldAutoSize}
procedure TControl.LockBaseBounds;
begin
inc(fBaseBoundsLock);
end;
procedure TControl.UnlockBaseBounds;
begin
dec(fBaseBoundsLock);
if fBaseBoundsLock<0 then RaiseGDBException('TControl.UnlockBaseBounds');
end;
{$ENDIF}
procedure TControl.WriteLayoutDebugReport(const Prefix: string); procedure TControl.WriteLayoutDebugReport(const Prefix: string);
var var
a: TAnchorKind; a: TAnchorKind;
@ -3683,10 +3469,8 @@ end;
procedure TControl.SetParent(NewParent: TWinControl); procedure TControl.SetParent(NewParent: TWinControl);
begin begin
if FParent = NewParent then exit; if FParent = NewParent then exit;
{$IFNDEF OldAutoSize}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.SetParent'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.SetParent'){$ENDIF};
try try
{$ENDIF}
CheckNewParent(NewParent); CheckNewParent(NewParent);
if FParent <> nil then FParent.RemoveControl(Self); if FParent <> nil then FParent.RemoveControl(Self);
if cfBoundsRectForNewParentValid in FControlFlags then if cfBoundsRectForNewParentValid in FControlFlags then
@ -3695,11 +3479,9 @@ begin
BoundsRect := BoundsRectForNewParent; BoundsRect := BoundsRectForNewParent;
end; end;
if NewParent <> nil then NewParent.InsertControl(Self); if NewParent <> nil then NewParent.InsertControl(Self);
{$IFNDEF OldAutoSize}
finally finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.SetParent'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.SetParent'){$ENDIF};
end; end;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -3869,10 +3651,8 @@ begin
if FVisible <> Value then if FVisible <> Value then
begin begin
//DebugLn(['TControl.SetVisible ',DbgSName(Self),' NewVisible=',Value]); //DebugLn(['TControl.SetVisible ',DbgSName(Self),' NewVisible=',Value]);
{$IFNDEF OldAutoSize}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.SetVisible'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.SetVisible'){$ENDIF};
try try
{$ENDIF}
VisibleChanging; VisibleChanging;
FVisible := Value; FVisible := Value;
try try
@ -3883,7 +3663,6 @@ begin
AsWincontrol := TWinControl(Self) AsWincontrol := TWinControl(Self)
else else
AsWincontrol := nil; AsWincontrol := nil;
{$IFNDEF OldAutoSize}
InvalidatePreferredSize; InvalidatePreferredSize;
if AsWincontrol <> nil then if AsWincontrol <> nil then
AsWincontrol.InvalidatePreferredChildSizes; AsWincontrol.InvalidatePreferredChildSizes;
@ -3895,39 +3674,12 @@ begin
Parent.InvalidatePreferredSize; Parent.InvalidatePreferredSize;
Parent.AdjustSize; Parent.AdjustSize;
end; end;
{$ELSE}
Include(FControlFlags, cfRequestAlignNeeded);
// resize parent if it has autosize
if (Parent <> nil) and Parent.AutoSize then
begin
Parent.InvalidatePreferredSize;
Parent.AdjustSize;
end;
if FVisible then
begin
// control became visible
if AsWincontrol <> nil then begin
AsWincontrol.InvalidatePreferredChildSizes;
Include(AsWincontrol.FWinControlFlags, wcfReAlignNeeded);
end;
AdjustSize;
if (AsWincontrol <> nil) and (wcfReAlignNeeded in AsWincontrol.FWinControlFlags) then
AsWincontrol.ReAlign;
end;
if cfRequestAlignNeeded in FControlFlags then
RequestAlign;
//DebugLn(['TControl.SetVisible ',dbgsName(AsWincontrol)]);
if FVisible and (AsWincontrol <> nil) then
AsWincontrol.ResizeDelayedAutoSizeChildren;
{$ENDIF}
finally finally
VisibleChanged; VisibleChanged;
end; end;
{$IFNDEF OldAutoSize}
finally finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.SetVisible'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.SetVisible'){$ENDIF};
end; end;
{$ENDIF}
end; end;
if (csLoading in ComponentState) then if (csLoading in ComponentState) then
ControlState := ControlState + [csVisibleSetInLoading]; ControlState := ControlState + [csVisibleSetInLoading];
@ -3956,13 +3708,9 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TControl.HandleObjectShouldBeVisible: boolean; function TControl.HandleObjectShouldBeVisible: boolean;
begin begin
{$IFDEF OldAutoSize}
Result:=IsControlVisible;
{$ELSE}
Result := (not (csDestroying in ComponentState)) and IsControlVisible; Result := (not (csDestroying in ComponentState)) and IsControlVisible;
if Result and Assigned(Parent) then if Result and Assigned(Parent) then
Result := Parent.HandleObjectShouldBeVisible; Result := Parent.HandleObjectShouldBeVisible;
{$ENDIF}
//DebugLn(['TControl.HandleObjectShouldBeVisible ',DbgSName(Self),' ',Result]); //DebugLn(['TControl.HandleObjectShouldBeVisible ',DbgSName(Self),' ',Result]);
end; end;
@ -4052,9 +3800,7 @@ begin
RaiseAlreadyDocking; RaiseAlreadyDocking;
// dock // dock
{$IFNDEF OldAutoSize}
DisableAutoSizing; DisableAutoSizing;
{$ENDIF}
Include(FControlState, csDocking); Include(FControlState, csDocking);
try try
OldHostDockSite:=HostDockSite; OldHostDockSite:=HostDockSite;
@ -4084,9 +3830,7 @@ begin
NewDockSite.FDockClients.Remove(Self); NewDockSite.FDockClients.Remove(Self);
Exclude(FControlState, csDocking); Exclude(FControlState, csDocking);
end; end;
{$IFNDEF OldAutoSize}
EnableAutoSizing; EnableAutoSizing;
{$ENDIF}
//DebugLn(['TControl.Dock END ',DbgSName(Self),' ',DbgSName(HostDockSite)]); //DebugLn(['TControl.Dock END ',DbgSName(Self),' ',DbgSName(HostDockSite)]);
end; end;
@ -4231,9 +3975,7 @@ var
begin begin
Result := False; Result := False;
{$IFNDEF OldAutoSize}
DisableAutoSizing; DisableAutoSizing;
{$ENDIF}
OldDockSite := Control.HostDockSite; OldDockSite := Control.HostDockSite;
if (OldDockSite<>nil) and (not HostDockSiteManagerAvailable(OldDockSite)) then if (OldDockSite<>nil) and (not HostDockSiteManagerAvailable(OldDockSite)) then
exit; exit;
@ -4247,9 +3989,7 @@ begin
OldDockSite.DockManager.SetReplacingControl(nil); OldDockSite.DockManager.SetReplacingControl(nil);
end; end;
Result:=Control.ManualDock(NewDockSite,DropControl,ControlSide); Result:=Control.ManualDock(NewDockSite,DropControl,ControlSide);
{$IFNDEF OldAutoSize}
EnableAutoSizing; EnableAutoSizing;
{$ENDIF}
end; end;
procedure TControl.AddHandlerOnResize(const OnResizeEvent: TNotifyEvent; procedure TControl.AddHandlerOnResize(const OnResizeEvent: TNotifyEvent;
@ -4475,10 +4215,8 @@ constructor TControl.Create(TheOwner: TComponent);
var var
Side: TAnchorKind; Side: TAnchorKind;
begin begin
{$IFNDEF OldAutoSize}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.Create'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.Create'){$ENDIF};
try try
{$ENDIF}
//if AnsiCompareText(ClassName,'TSpeedButton')=0 then //if AnsiCompareText(ClassName,'TSpeedButton')=0 then
// DebugLn('TControl.Create START ',Name,':',ClassName); // DebugLn('TControl.Create START ',Name,':',ClassName);
inherited Create(TheOwner); inherited Create(TheOwner);
@ -4512,11 +4250,9 @@ begin
FDragCursor := crDrag; FDragCursor := crDrag;
FFloatingDockSiteClass := TCustomDockForm; FFloatingDockSiteClass := TCustomDockForm;
//DebugLn('TControl.Create END ',Name,':',ClassName); //DebugLn('TControl.Create END ',Name,':',ClassName);
{$IFNDEF OldAutoSize}
finally finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.Create'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.Create'){$ENDIF};
end; end;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -4792,19 +4528,9 @@ begin
SetBounds(aLeft,aTop,aWidth,aHeight); SetBounds(aLeft,aTop,aWidth,aHeight);
end; end;
procedure TControl.SetBoundsKeepBase(aLeft, aTop, aWidth, aHeight: integer procedure TControl.SetBoundsKeepBase(aLeft, aTop, aWidth, aHeight: integer);
{$IFDEF OldAutoSize}; Lock: boolean{$ENDIF});
begin begin
{$IFDEF OldAutoSize}
if Lock then LockBaseBounds;
try
SetBounds(aLeft, aTop, aWidth, aHeight);
finally
if Lock then UnlockBaseBounds;
end;
{$ELSE}
ChangeBounds(aLeft, aTop, aWidth, aHeight, true); ChangeBounds(aLeft, aTop, aWidth, aHeight, true);
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -4864,22 +4590,6 @@ begin
PreferredHeight:=Height; PreferredHeight:=Height;
end; end;
{$IFDEF OldAutoSize}
// if this control is aligned adjust PreferredWidth and/or PreferredHeight
if WidthIsAnchored then begin
// the control will be expanded to maximum width
// -> use the current width, which is or will be eventually set by the
// aligning code
PreferredWidth:=Width;
end;
if HeightIsAnchored then begin
// the control will be expanded to maximum height
// -> use the current height, which is or will be eventually set by the
// aligning code
PreferredHeight:=Height;
end;
{$ENDIF}
// apply constraints // apply constraints
PreferredWidth:=Constraints.MinMaxWidth(PreferredWidth); PreferredWidth:=Constraints.MinMaxWidth(PreferredWidth);
PreferredHeight:=Constraints.MinMaxHeight(PreferredHeight); PreferredHeight:=Constraints.MinMaxHeight(PreferredHeight);
@ -4969,9 +4679,7 @@ begin
while AControl<>nil do begin while AControl<>nil do begin
Exclude(AControl.FControlFlags,cfPreferredSizeValid); Exclude(AControl.FControlFlags,cfPreferredSizeValid);
Exclude(AControl.FControlFlags,cfPreferredMinSizeValid); Exclude(AControl.FControlFlags,cfPreferredMinSizeValid);
{$IFNDEF OldAutoSize}
if not AControl.IsControlVisible then break; if not AControl.IsControlVisible then break;
{$ENDIF}
AControl:=AControl.Parent; AControl:=AControl.Parent;
end; end;
end; end;
@ -5008,9 +4716,6 @@ end;
procedure TControl.DisableAutoSizing procedure TControl.DisableAutoSizing
{$IFDEF DebugDisableAutoSizing}(const Reason: string){$ENDIF}; {$IFDEF DebugDisableAutoSizing}(const Reason: string){$ENDIF};
begin begin
{$IFDEF OldAutoSize}
inc(FAutoSizingLockCount);
{$ELSE}
inc(FAutoSizingLockCount); inc(FAutoSizingLockCount);
{$IFDEF DebugDisableAutoSizing} {$IFDEF DebugDisableAutoSizing}
if FAutoSizingLockReasons=nil then FAutoSizingLockReasons:=TStringList.Create; if FAutoSizingLockReasons=nil then FAutoSizingLockReasons:=TStringList.Create;
@ -5025,29 +4730,11 @@ begin
Parent.DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.DisableAutoSizing'){$ENDIF}; Parent.DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.DisableAutoSizing'){$ENDIF};
end; end;
end; end;
{$ENDIF}
end; end;
procedure TControl.EnableAutoSizing procedure TControl.EnableAutoSizing
{$IFDEF DebugDisableAutoSizing}(const Reason: string){$ENDIF}; {$IFDEF DebugDisableAutoSizing}(const Reason: string){$ENDIF};
{$IFDEF OldAutoSize}
procedure AdjustSizeRecursive(AControl: TControl);
var
AWinControl: TWinControl;
i: Integer;
begin
if cfAutoSizeNeeded in AControl.FControlFlags then
AControl.AdjustSize;
if AControl is TWinControl then begin
AWinControl:=TWinControl(AControl);
if AWincontrol.FControls<>nil then
for i:=0 to AWincontrol.FControls.Count-1 do
AdjustSizeRecursive(TControl(AWincontrol.FControls[i]));
end;
end;
{$ENDIF}
{$IFDEF DebugDisableAutoSizing} {$IFDEF DebugDisableAutoSizing}
procedure CheckReason; procedure CheckReason;
var var
@ -5071,11 +4758,6 @@ begin
{$ENDIF} {$ENDIF}
if FAutoSizingLockCount<=0 then RaiseGDBException('TControl.EnableAutoSizing'); if FAutoSizingLockCount<=0 then RaiseGDBException('TControl.EnableAutoSizing');
{$IFDEF OldAutoSize}
dec(FAutoSizingLockCount);
if FAutoSizingLockCount=0 then
AdjustSizeRecursive(Self);
{$ELSE}
dec(FAutoSizingLockCount); dec(FAutoSizingLockCount);
//DebugLn([Space(FAutoSizingLockCount*2),'TControl.EnableAutoSizing ',DbgSName(Self),' ',FAutoSizingLockCount]); //DebugLn([Space(FAutoSizingLockCount*2),'TControl.EnableAutoSizing ',DbgSName(Self),' ',FAutoSizingLockCount]);
@ -5088,7 +4770,6 @@ begin
end else end else
DoAllAutoSize; DoAllAutoSize;
end; end;
{$ENDIF}
end; end;
{$IFDEF DebugDisableAutoSizing} {$IFDEF DebugDisableAutoSizing}
@ -5140,14 +4821,10 @@ begin
{$ENDIF} {$ENDIF}
//Assert(False, Format('Trace:[TWinControl.WMSize] %s', [ClassName])); //Assert(False, Format('Trace:[TWinControl.WMSize] %s', [ClassName]));
{$IFDEF OldAutoSize}
SetBoundsKeepBase(Left,Top,Message.Width,Message.Height,Parent<>nil);
{$ELSE}
if Parent<>nil then if Parent<>nil then
SetBoundsKeepBase(Left,Top,Message.Width,Message.Height) SetBoundsKeepBase(Left,Top,Message.Width,Message.Height)
else else
SetBounds(Left,Top,Message.Width,Message.Height); SetBounds(Left,Top,Message.Width,Message.Height);
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -5165,16 +4842,11 @@ begin
if CheckPosition(Self) then if CheckPosition(Self) then
DebugLn('[TControl.WMMove] Name=',Name,':',ClassName,' Message.XPos=',DbgS(Message.XPos),' Message.YPos=',DbgS(Message.YPos),' OldLeft=',DbgS(Left),' OldTop=',DbgS(Top)); DebugLn('[TControl.WMMove] Name=',Name,':',ClassName,' Message.XPos=',DbgS(Message.XPos),' Message.YPos=',DbgS(Message.YPos),' OldLeft=',DbgS(Left),' OldTop=',DbgS(Top));
{$ENDIF} {$ENDIF}
{$IFDEF OldAutoSize}
{ Just sync the coordinates }
SetBoundsKeepBase(Message.XPos, Message.YPos, Width, Height,Parent<>nil);
{$ELSE}
// Just sync the coordinates // Just sync the coordinates
if Parent<>nil then if Parent<>nil then
SetBoundsKeepBase(Message.XPos, Message.YPos, Width, Height) SetBoundsKeepBase(Message.XPos, Message.YPos, Width, Height)
else else
SetBounds(Message.XPos, Message.YPos, Width, Height); SetBounds(Message.XPos, Message.YPos, Width, Height);
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------

View File

@ -114,9 +114,7 @@ begin
//DebugLn('[TCustomForm.Destroy] A ',Name,':',ClassName); //DebugLn('[TCustomForm.Destroy] A ',Name,':',ClassName);
if not (csDestroying in ComponentState) then GlobalNameSpace.BeginWrite; if not (csDestroying in ComponentState) then GlobalNameSpace.BeginWrite;
try try
{$IFNDEF OldAutoSize}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomForm.Destroy'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomForm.Destroy'){$ENDIF};
{$ENDIF}
FreeThenNil(FIcon); FreeThenNil(FIcon);
FreeIconHandles; FreeIconHandles;
Screen.RemoveForm(Self); Screen.RemoveForm(Self);
@ -127,9 +125,7 @@ begin
inherited Destroy; inherited Destroy;
//DebugLn('[TCustomForm.Destroy] END ',Name,':',ClassName); //DebugLn('[TCustomForm.Destroy] END ',Name,':',ClassName);
finally finally
{$IFNDEF OldAutoSize}
if not (csDestroying in ComponentState) then if not (csDestroying in ComponentState) then
{$ENDIF}
GlobalNameSpace.EndWrite; GlobalNameSpace.EndWrite;
end; end;
end; end;
@ -403,7 +399,6 @@ begin
//DebugLn(['[TCustomForm.SetVisible] END ',Name,':',ClassName,' ',Value,' ',(fsCreating in FFormState),' ',Visible]); //DebugLn(['[TCustomForm.SetVisible] END ',Name,':',ClassName,' ',Value,' ',(fsCreating in FFormState),' ',Visible]);
end; end;
{$ifndef OldAutoSize}
procedure TCustomForm.AllAutoSized; procedure TCustomForm.AllAutoSized;
begin begin
inherited AllAutoSized; inherited AllAutoSized;
@ -413,7 +408,6 @@ begin
MoveToDefaultPosition; MoveToDefaultPosition;
end; end;
end; end;
{$endif}
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
procedure TCustomForm.SetWindowFocus; procedure TCustomForm.SetWindowFocus;
@ -696,12 +690,7 @@ begin
lMessage.Result := 0; lMessage.Result := 0;
DisableAlign; DisableAlign;
try try
{$IFDEF OldAutoSize} AdjustSize;
if Parent<>nil then
Parent.ReAlign
else
{$ENDIF}
AdjustSize;
for i := 0 to ComponentCount - 1 do for i := 0 to ComponentCount - 1 do
begin begin
// all TControl descendants have this notification in TWinControl.CMBidiModeChanged // all TControl descendants have this notification in TWinControl.CMBidiModeChanged
@ -930,9 +919,7 @@ begin
if FFormUpdateCount=0 then begin if FFormUpdateCount=0 then begin
FormEndUpdated; FormEndUpdated;
Visible:=(fsVisible in FFormState); Visible:=(fsVisible in FFormState);
{$IFNDEF OldAutoSize}
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomForm.BeginFormUpdate'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomForm.BeginFormUpdate'){$ENDIF};
{$ENDIF}
end; end;
end; end;
@ -1080,18 +1067,14 @@ end;
procedure TCustomForm.SetParent(NewParent: TWinControl); procedure TCustomForm.SetParent(NewParent: TWinControl);
begin begin
if Parent=NewParent then exit; if Parent=NewParent then exit;
{$IFNDEF OldAutoSize}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomForm.SetParent'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomForm.SetParent'){$ENDIF};
{$ENDIF}
try try
if HandleAllocated then DestroyHandle; if HandleAllocated then DestroyHandle;
inherited SetParent(NewParent); inherited SetParent(NewParent);
if (Parent=nil) and Visible then if (Parent=nil) and Visible then
HandleNeeded; HandleNeeded;
finally finally
{$IFNDEF OldAutoSize}
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomForm.SetParent'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomForm.SetParent'){$ENDIF};
{$ENDIF}
end; end;
end; end;
@ -2352,29 +2335,6 @@ begin
Assert(False, 'Trace:[TCustomForm.CreateWnd] FMenu.HandleNeeded'); Assert(False, 'Trace:[TCustomForm.CreateWnd] FMenu.HandleNeeded');
UpdateMenu; UpdateMenu;
{$IFDEF OldAutoSize}
// activate focus if visible
if Visible then begin
if (ActiveControl = nil) and (not (csDesigning in ComponentState))
and (Parent=nil) then begin
// automatically choose a control to focus
{$IFDEF VerboseFocus}
DebugLn('TCustomForm.CreateWnd ',DbgSName(Self),' Set ActiveControl := ',DbgSName(FindDefaultForActiveControl));
{$ENDIF}
ActiveControl := FindDefaultForActiveControl;
end;
if (Parent=nil)
and (FActiveControl<>nil) and FActiveControl.HandleAllocated
and FActiveControl.CanFocus
and ([csLoading,csDestroying,csDesigning]*ComponentState=[]) then begin
{$IFDEF VerboseFocus}
DebugLn('TCustomForm.CreateWnd A ',DbgSName(Self),' FActiveControl=',DbgSName(FActiveControl));
{$ENDIF}
LCLIntf.SetFocus(FActiveControl.Handle);
end;
end;
{$ENDIF}
// update icon // update icon
Perform(CM_ICONCHANGED, 0, 0); Perform(CM_ICONCHANGED, 0, 0);
//DebugLn('TCustomForm.CreateWnd END ',ClassName); //DebugLn('TCustomForm.CreateWnd END ',ClassName);
@ -2431,10 +2391,8 @@ end;
procedure TCustomForm.BeginFormUpdate; procedure TCustomForm.BeginFormUpdate;
begin begin
inc(FFormUpdateCount); inc(FFormUpdateCount);
{$IFNDEF OldAutoSize}
if FFormUpdateCount=1 then if FFormUpdateCount=1 then
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomForm.BeginFormUpdate'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomForm.BeginFormUpdate'){$ENDIF};
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -2467,7 +2425,6 @@ begin
{$IFDEF CHECK_POSITION} {$IFDEF CHECK_POSITION}
DebugLn('[TCustomForm.UpdateShowing] END ',Name,':',Classname,' Pos=',DbgS(Left),',',DbgS(Top)); DebugLn('[TCustomForm.UpdateShowing] END ',Name,':',Classname,' Pos=',DbgS(Left),',',DbgS(Top));
{$ENDIF} {$ENDIF}
{$IFNDEF OldAutoSize}
// activate focus if visible // activate focus if visible
if Showing and (not (csDestroying in ComponentState)) then begin if Showing and (not (csDestroying in ComponentState)) then begin
if (ActiveControl = nil) and (not (csDesigning in ComponentState)) if (ActiveControl = nil) and (not (csDesigning in ComponentState))
@ -2489,7 +2446,6 @@ begin
end; end;
UpdateShowInTaskBar; UpdateShowInTaskBar;
end; end;
{$ENDIF}
end; end;
procedure TCustomForm.DoFirstShow; procedure TCustomForm.DoFirstShow;

View File

@ -102,44 +102,9 @@ begin
end; end;
procedure TCustomLabel.DoAutoSize; procedure TCustomLabel.DoAutoSize;
{$IFDEF OldAutoSize}
var
NewWidth, NewHeight: integer;
CurAnchors: TAnchors;
{$ENDIF}
begin begin
inherited DoAutoSize; inherited DoAutoSize;
//debugln('TCustomLabel.DoAutoSize ',DbgSName(Self),' AutoSizing=',dbgs(AutoSizing),' AutoSize=',dbgs(AutoSize),' Parent=',DbgSName(Parent),' csLoading=',dbgs(csLoading in ComponentState),' Parnet.HandleAllocated=',dbgs((Parent<>nil) and (Parent.HandleAllocated))); //debugln('TCustomLabel.DoAutoSize ',DbgSName(Self),' AutoSizing=',dbgs(AutoSizing),' AutoSize=',dbgs(AutoSize),' Parent=',DbgSName(Parent),' csLoading=',dbgs(csLoading in ComponentState),' Parnet.HandleAllocated=',dbgs((Parent<>nil) and (Parent.HandleAllocated)));
{$IFDEF OldAutoSize}
if OptimalFill and (not AutoSize) then
begin
AdjustFontForOptimalFill;
Exit;
end;
if AutoSizeDelayed then
Exit;
GetPreferredSize(NewWidth, NewHeight);
//debugln('TCustomLabel.DoAutoSize ',dbgsName(Self),' Nice ',dbgs(Left),',',dbgs(Top),',w=',dbgs(NewWidth),',h=',dbgs(NewHeight),' Caption="',dbgstr(Caption),'"');
CurAnchors := [];
if Align in [alLeft, alRight, alBottom, alTop, alClient] then
CurAnchors := AnchorAlign[Align];
CurAnchors := Anchors + CurAnchors;
if (CurAnchors * [akLeft, akRight] = [akLeft, akRight]) or
(WordWrap and (NewWidth < Width)) then
NewWidth := Width;
if CurAnchors * [akTop, akBottom] = [akTop, akBottom] then
NewHeight := Height;
//debugln('TCustomLabel.DoAutoSize ',dbgsName(Self),' Anchored ',dbgs(Left),',',dbgs(Top),',w=',dbgs(NewWidth),',h=',dbgs(NewHeight));
FInternalSetBounds := True;
try
SetBoundsKeepBase(Left, Top, NewWidth, NewHeight);
finally
FInternalSetBounds := False;
end;
{$ENDIF}
end; end;
procedure TCustomLabel.SetAlignment(Value : TAlignment); procedure TCustomLabel.SetAlignment(Value : TAlignment);
@ -323,9 +288,7 @@ end;
procedure TCustomLabel.Loaded; procedure TCustomLabel.Loaded;
begin begin
inherited Loaded; inherited Loaded;
{$IFNDEF OldAutoSize}
AdjustSize; AdjustSize;
{$ENDIF}
end; end;
procedure TCustomLabel.UpdateSize; procedure TCustomLabel.UpdateSize;
@ -333,10 +296,6 @@ begin
InvalidatePreferredSize; InvalidatePreferredSize;
if OptimalFill and (not AutoSize) then if OptimalFill and (not AutoSize) then
AdjustFontForOptimalFill; AdjustFontForOptimalFill;
{$IFDEF OldAutoSize}
if (Parent <> nil) and Parent.AutoSize then
Parent.AdjustSize;
{$ENDIF}
AdjustSize; AdjustSize;
end; end;

View File

@ -590,10 +590,8 @@ end;
procedure TCustomNoteBook.AddRemovePageHandle(APage: TCustomPage); procedure TCustomNoteBook.AddRemovePageHandle(APage: TCustomPage);
begin begin
{$IFNDEF OldAutoSize}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomNoteBook.AddRemovePageHandle'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomNoteBook.AddRemovePageHandle'){$ENDIF};
try try
{$ENDIF}
if (not (csDestroying in APage.ComponentState)) if (not (csDestroying in APage.ComponentState))
and (APage.TabVisible or (csDesigning in ComponentState)) then begin and (APage.TabVisible or (csDesigning in ComponentState)) then begin
{$IFDEF NOTEBOOK_DEBUG} {$IFDEF NOTEBOOK_DEBUG}
@ -603,11 +601,7 @@ begin
Include(APage.FFlags,pfAdding); Include(APage.FFlags,pfAdding);
TWSCustomNotebookClass(WidgetSetClass).AddPage(Self, APage, APage.VisibleIndex); TWSCustomNotebookClass(WidgetSetClass).AddPage(Self, APage, APage.VisibleIndex);
APage.FFlags:=APage.FFlags+[pfAdded]-[pfAdding]; APage.FFlags:=APage.FFlags+[pfAdded]-[pfAdding];
{$IFDEF OldAutoSize}
APage.ResizeDelayedAutoSizeChildren
{$ELSE}
APage.AdjustSize; APage.AdjustSize;
{$ENDIF}
end else begin end else begin
{$IFDEF NOTEBOOK_DEBUG} {$IFDEF NOTEBOOK_DEBUG}
DebugLn(['TCustomNoteBook.AddRemovePageHandle REMOVE ',DbgSName(APage),' pfAdded=',pfAdded in APage.FFlags]); DebugLn(['TCustomNoteBook.AddRemovePageHandle REMOVE ',DbgSName(APage),' pfAdded=',pfAdded in APage.FFlags]);
@ -620,11 +614,9 @@ begin
APage.DestroyHandle; APage.DestroyHandle;
Exclude(APage.FFlags, pfRemoving); Exclude(APage.FFlags, pfRemoving);
end; end;
{$IFNDEF OldAutoSize}
finally finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomNoteBook.AddRemovePageHandle'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomNoteBook.AddRemovePageHandle'){$ENDIF};
end; end;
{$ENDIF}
end; end;
procedure TCustomNotebook.RemovePage(Index: Integer); procedure TCustomNotebook.RemovePage(Index: Integer);

View File

@ -29,17 +29,13 @@ end;
procedure TScrollingWinControl.CreateWnd; procedure TScrollingWinControl.CreateWnd;
begin begin
{$IFNDEF OldAutoSize}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TScrollingWinControl.CreateWnd'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TScrollingWinControl.CreateWnd'){$ENDIF};
try try
{$ENDIF}
inherited CreateWnd; inherited CreateWnd;
UpdateScrollBars; UpdateScrollBars;
{$IFNDEF OldAutoSize}
finally finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TScrollingWinControl.CreateWnd'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TScrollingWinControl.CreateWnd'){$ENDIF};
end; end;
{$ENDIF}
end; end;
function TScrollingWinControl.GetClientScrollOffset: TPoint; function TScrollingWinControl.GetClientScrollOffset: TPoint;

View File

@ -45,9 +45,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TSizeConstraints.UpdateInterfaceConstraints; procedure TSizeConstraints.UpdateInterfaceConstraints;
begin begin
{$IFNDEF OldAutoSize}
if (Control is TWinControl) and TWinControl(Control).HandleAllocated then if (Control is TWinControl) and TWinControl(Control).HandleAllocated then
{$ENDIF}
TWSControlClass(Control.WidgetSetClass).GetConstraints(Control, Self); TWSControlClass(Control.WidgetSetClass).GetConstraints(Control, Self);
end; end;

View File

@ -327,11 +327,7 @@ begin
TControl(FButtons[i]).InvalidatePreferredSize; TControl(FButtons[i]).InvalidatePreferredSize;
TControl(FButtons[i]).AdjustSize; TControl(FButtons[i]).AdjustSize;
end; end;
{$IFDEF OldAutoSize}
ReAlign;
{$ELSE}
AdjustSize; AdjustSize;
{$ENDIF}
Invalidate; Invalidate;
Exclude(FToolBarFlags,tbfUpdateVisibleBarNeeded); Exclude(FToolBarFlags,tbfUpdateVisibleBarNeeded);
end; end;
@ -453,73 +449,21 @@ begin
end; end;
procedure TToolBar.DoAutoSize; procedure TToolBar.DoAutoSize;
{$IFDEF OldAutoSize}
var
NewWidth: Integer;
NewHeight: Integer;
ModifyWidth, ModifyHeight : Boolean;
{$ENDIF}
begin begin
{$IFDEF OldAutoSize}
if AutoSizing then Exit; // we shouldn't come here in the first place
BeginAutoSizing;
try
NewWidth:=Width;
NewHeight:=Height;
GetPreferredSize(NewWidth,NewHeight);
ModifyWidth := [akLeft, akRight] * (Anchors+AnchorAlign[Align]) <> [akLeft, akRight];
ModifyHeight := [akTop, akBottom] * (Anchors+AnchorAlign[Align]) <> [akTop, akBottom];
if not ModifyWidth then NewWidth := Width;
if not ModifyHeight then NewHeight := Height;
//DebugLn(['TToolBar.DoAutoSize ',DbgSName(Self),' ',Width,',',Height,' ',NewWidth,',',NewHeight]);
if (NewWidth <> Width) or (NewHeight <> Height) then
SetBounds(Left, Top, NewWidth, NewHeight);
finally
EndAutoSizing;
end;
{$ELSE}
// childs are moved in ControlsAligned independent of AutoSize=true // childs are moved in ControlsAligned independent of AutoSize=true
{$ENDIF}
end; end;
procedure TToolBar.CalculatePreferredSize(var PreferredWidth, procedure TToolBar.CalculatePreferredSize(var PreferredWidth,
PreferredHeight: integer; WithThemeSpace: Boolean); PreferredHeight: integer; WithThemeSpace: Boolean);
var var
{$IFDEF OldAutoSize}
ARect, Adjusted: TRect;
ACount: Integer;
{$ENDIF}
NewWidth: Integer; NewWidth: Integer;
NewHeight: Integer; NewHeight: Integer;
FixedWidth: Boolean; FixedWidth: Boolean;
begin begin
NewWidth:=0; NewWidth:=0;
NewHeight:=0; NewHeight:=0;
{$IFDEF OldAutoSize}
ARect := ClientRect;
Adjusted := ARect;
AdjustClientRect(Adjusted);
ACount := ButtonCount;
if IsVertical then
PreferredWidth := ButtonWidth
else
PreferredWidth := ButtonWidth * ACount;
inc(PreferredWidth, (Adjusted.Left - ARect.Left) + (ARect.Right - Adjusted.Right));
if IsVertical then
PreferredWidth := ButtonHeight * ACount
else
PreferredHeight := ButtonHeight;
inc(PreferredHeight, (Adjusted.Top - ARect.Top) + (ARect.Bottom - Adjusted.Bottom));
{$ENDIF}
{$IFNDEF OldAutoSize}
FixedWidth:=false; FixedWidth:=false;
{$ENDIF}
if [akLeft,akRight]*Anchors=[akLeft,akRight] then begin if [akLeft,akRight]*Anchors=[akLeft,akRight] then begin
// the width depends on the parent or siblings // the width depends on the parent or siblings
// use a simpe heuristic to find out if the width is fixed // use a simpe heuristic to find out if the width is fixed
@ -528,22 +472,18 @@ begin
and (Parent.AutoSize=false) and (Parent.AutoSize=false)
then begin then begin
// the width is fixed // the width is fixed
{$IFNDEF OldAutoSize}
FixedWidth:=true; FixedWidth:=true;
{$ENDIF}
WrapButtons(Width, NewWidth, NewHeight, True); WrapButtons(Width, NewWidth, NewHeight, True);
PreferredWidth := NewWidth; PreferredWidth := NewWidth;
PreferredHeight := NewHeight; PreferredHeight := NewHeight;
//DebugLn(['TToolBar.CalculatePreferredSize fixed width: ',PreferredWidth,'x',PreferredHeight]); //DebugLn(['TToolBar.CalculatePreferredSize fixed width: ',PreferredWidth,'x',PreferredHeight]);
end; end;
end; end;
{$IFNDEF OldAutoSize}
if not FixedWidth then begin if not FixedWidth then begin
WrapButtons(Screen.Width,NewWidth,NewHeight,true); WrapButtons(Screen.Width,NewWidth,NewHeight,true);
PreferredWidth := NewWidth; PreferredWidth := NewWidth;
PreferredHeight := NewHeight; PreferredHeight := NewHeight;
end; end;
{$ENDIF}
//DebugLn(['TToolBar.CalculatePreferredSize ',DbgSName(Self),' ',PreferredWidth,'x',PreferredHeight,' Count=',ControlCount]); //DebugLn(['TToolBar.CalculatePreferredSize ',DbgSName(Self),' ',PreferredWidth,'x',PreferredHeight,' Count=',ControlCount]);
end; end;

View File

@ -404,17 +404,6 @@ begin
else inherited RealSetText(AValue); else inherited RealSetText(AValue);
end; end;
{$IFDEF OldAutoSize}
procedure TToolButton.DoAutoSize;
var
PreferredWidth: integer;
PreferredHeight: integer;
begin
GetPreferredSize(PreferredWidth,PreferredHeight);
SetBounds(Left,Top,PreferredWidth,PreferredHeight);
end;
{$ENDIF}
procedure TToolButton.SetToolBar(NewToolBar: TToolBar); procedure TToolButton.SetToolBar(NewToolBar: TToolBar);
begin begin
if FToolBar = NewToolBar then exit; if FToolBar = NewToolBar then exit;
@ -863,7 +852,7 @@ begin
else else
NewWidth := Width; NewWidth := Width;
NewHeight := TToolBar(AParent).ButtonHeight; NewHeight := TToolBar(AParent).ButtonHeight;
SetBoundsKeepBase(Left, Top, NewWidth, NewHeight{$IFDEF OldAutoSize}, True{$ENDIF}); SetBoundsKeepBase(Left, Top, NewWidth, NewHeight);
end; end;
// inherited // inherited

View File

@ -2207,17 +2207,10 @@ begin
OldBounds:=CurControl.BoundsRect; OldBounds:=CurControl.BoundsRect;
if not CompareRect(@NewBounds,@OldBounds) then begin if not CompareRect(@NewBounds,@OldBounds) then begin
Result:=true; Result:=true;
{$IFDEF OldAutoSize}
CurControl.SetAlignedBounds(NewBounds.Left,
NewBounds.Top,
NewBounds.Right-NewBounds.Left,
NewBounds.Bottom-NewBounds.Top);
{$ELSE}
CurControl.SetBoundsKeepBase(NewBounds.Left, CurControl.SetBoundsKeepBase(NewBounds.Left,
NewBounds.Top, NewBounds.Top,
NewBounds.Right-NewBounds.Left, NewBounds.Right-NewBounds.Left,
NewBounds.Bottom-NewBounds.Top); NewBounds.Bottom-NewBounds.Top);
{$ENDIF}
end; end;
end; end;
end; end;
@ -2310,7 +2303,6 @@ begin
ReallocMem(Childs[o],0); ReallocMem(Childs[o],0);
end; end;
{$IFNDEF OldAutoSize}
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
function TWinControl.AutoSizePhases: TControlAutoSizePhases; function TWinControl.AutoSizePhases: TControlAutoSizePhases;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
@ -2332,23 +2324,13 @@ begin
Include(Result,caspChangingProperties); Include(Result,caspChangingProperties);
end; end;
end; end;
{$ENDIF}
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
function TWinControl.AutoSizeDelayed: boolean; function TWinControl.AutoSizeDelayed: boolean;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TWinControl.AutoSizeDelayed: boolean; function TWinControl.AutoSizeDelayed: boolean;
begin begin
Result:={$IFDEF OldAutoSize} Result:=(csDestroyingHandle in ControlState)
// no handle means not visible
(not HandleAllocated)
// obsolete
or ((not FShowing) and (not (csDesigning in ComponentState)))
// during handle creation no autosize
or (wcfCreatingChildHandles in FWinControlFlags)
{$ELSE}
(csDestroyingHandle in ControlState)
{$ENDIF}
or (inherited AutoSizeDelayed); or (inherited AutoSizeDelayed);
//if Result then debugln('TWinControl.AutoSizeDelayed A ',DbgSName(Self),' wcfCreatingChildHandles=',dbgs(wcfCreatingChildHandles in FWinControlFlags),' csLoading=',dbgs(csLoading in ComponentState)); //if Result then debugln('TWinControl.AutoSizeDelayed A ',DbgSName(Self),' wcfCreatingChildHandles=',dbgs(wcfCreatingChildHandles in FWinControlFlags),' csLoading=',dbgs(csLoading in ComponentState));
{$IFDEF VerboseCanAutoSize} {$IFDEF VerboseCanAutoSize}
@ -2946,11 +2928,7 @@ var
// lock the base bounds, so that the new automatic bounds do not override // lock the base bounds, so that the new automatic bounds do not override
// the user settings // the user settings
OldBounds:=Control.BoundsRect; OldBounds:=Control.BoundsRect;
{$IFDEF OldAutoSize}
Control.SetAlignedBounds(NewLeft, NewTop, NewWidth, NewHeight);
{$ELSE}
Control.SetBoundsKeepBase(NewLeft, NewTop, NewWidth, NewHeight); Control.SetBoundsKeepBase(NewLeft, NewTop, NewWidth, NewHeight);
{$ENDIF}
//DebugLn(['DoPosition ',DbgSName(Control),' ',cfAutoSizeNeeded in Control.FControlFlags]); //DebugLn(['DoPosition ',DbgSName(Control),' ',cfAutoSizeNeeded in Control.FControlFlags]);
NewBounds:=Control.BoundsRect; NewBounds:=Control.BoundsRect;
BoundsMutated:=not CompareRect(@OldBounds,@NewBounds); BoundsMutated:=not CompareRect(@OldBounds,@NewBounds);
@ -3093,9 +3071,6 @@ var
var var
i: Integer; i: Integer;
{$IFDEF OldAutoSize}
ChildControl: TControl;
{$ENDIF}
OldRemainingClientRect: TRect; OldRemainingClientRect: TRect;
OldRemainingBorderSpace: TRect; OldRemainingBorderSpace: TRect;
MaxTries: LongInt; MaxTries: LongInt;
@ -3104,30 +3079,6 @@ begin
if wcfAligningControls in FWinControlFlags then exit; if wcfAligningControls in FWinControlFlags then exit;
Include(FWinControlFlags,wcfAligningControls); Include(FWinControlFlags,wcfAligningControls);
try try
{$IFDEF OldAutoSize}
// obsolete
// call delayed autosize
for i:=ControlCount-1 downto 0 do begin
ChildControl:=Controls[i];
if cfAutoSizeNeeded in ChildControl.FControlFlags then begin
//DebugLn(['TWinControl.AlignControls ',DbgSName(Self),' autosize needed for child ',DbgSName(ChildControl)]);
ChildControl.AdjustSize;
end;
end;
{$ENDIF}
{$IFDEF OldAutoSize}
// obsolete
// unset all align needed flags
Exclude(FWinControlFlags,wcfReAlignNeeded);
for i:=ControlCount-1 downto 0 do begin
ChildControl:=Controls[i];
Exclude(ChildControl.FControlFlags,cfRequestAlignNeeded);
end;
{$ENDIF}
//if csDesigning in ComponentState then begin //if csDesigning in ComponentState then begin
//DebugLn('[TWinControl.AlignControls] ',Name,':',Classname,' ',Left,',',Top,',',Width,',',Height,' AlignWork=',NeedAlignWork,' ControlCount=',ControlCount); //DebugLn('[TWinControl.AlignControls] ',Name,':',Classname,' ',Left,',',Top,',',Width,',',Height,' AlignWork=',NeedAlignWork,' ControlCount=',ControlCount);
//if AControl<>nil then DebugLn(' AControl=',AControl.Name,':',AControl.ClassName); //if AControl<>nil then DebugLn(' AControl=',AControl.Name,':',AControl.ClassName);
@ -3187,18 +3138,6 @@ begin
finally finally
Exclude(FWinControlFlags,wcfAligningControls); Exclude(FWinControlFlags,wcfAligningControls);
end; end;
{$IFDEF OldAutoSize}
// obsolete
// let childs autosize themselves
for i:=0 to ControlCount-1 do begin
ChildControl:=Controls[i];
if cfAutoSizeNeeded in ChildControl.FControlFlags then begin
//DebugLn(['TWinControl.AlignControls AdjustSize: ',DbgSName(ChildControl),' ',(not ChildControl.AutoSizeCanStart),' ',ChildControl.AutoSizeDelayed]);
ChildControl.AdjustSize;
end;
end;
{$ENDIF}
end; end;
function TWinControl.CustomAlignInsertBefore(AControl1, AControl2: TControl): Boolean; function TWinControl.CustomAlignInsertBefore(AControl1, AControl2: TControl): Boolean;
@ -3214,8 +3153,6 @@ begin
then FOnAlignPosition(Self, AControl, ANewLeft, ANewTop, ANewWidth, ANewHeight, AlignRect, AlignInfo); then FOnAlignPosition(Self, AControl, ANewLeft, ANewTop, ANewWidth, ANewHeight, AlignRect, AlignInfo);
end; end;
function TWinControl.DoAlignChildControls(TheAlign: TAlign; AControl: TControl; function TWinControl.DoAlignChildControls(TheAlign: TAlign; AControl: TControl;
AControlList: TFPList; var ARect: TRect): Boolean; AControlList: TFPList; var ARect: TRect): Boolean;
begin begin
@ -3230,46 +3167,6 @@ begin
ReAlign; ReAlign;
end; end;
{$IFDEF OldAutoSize}
procedure TWinControl.ResizeDelayedAutoSizeChildren;
var
i: Integer;
Child: TControl;
AWinControl: TWinControl;
begin
if ControlCount=0 then exit;
//DebugLn(['TWinControl.ResizeDelayedAutoSizeChildren START ',DbgSName(Self),' Visible=',Visible]);
if AutoSizeDelayed then exit;
//DebugLn(['TWinControl.ResizeDelayedAutoSizeChildren RUN ',DbgSName(Self)]);
DisableAlign;
try
for i:=0 to ControlCount-1 do begin
Child:=Controls[i];
if Child.AutoSizeDelayed then begin
//DebugLn(['TWinControl.ResizeDelayedAutoSizeChildren Child.AutoSizeDelayed Child=',dbgsName(Child)]);
continue;
end;
//DebugLn(['TWinControl.ResizeDelayedAutoSizeChildren ',dbgsName(Child),' AutoSize=',Child.AutoSize,' cfAutoSizeNeeded=',cfAutoSizeNeeded in Child.FControlFlags]);
if cfRequestAlignNeeded in Child.FControlFlags then
Child.RequestAlign;
if (cfAutoSizeNeeded in Child.FControlFlags)
or (Child.AutoSize and (not (cfPreferredSizeValid in Child.FControlFlags))) then
Child.AdjustSize;
if Child is TWinControl then begin
AWinControl:=TWinControl(Child);
AWinControl.ResizeDelayedAutoSizeChildren;
if wcfReAlignNeeded in AWinControl.FWinControlFlags then
AWinControl.ReAlign;
end;
end;
finally
EnableAlign;
end;
end;
{$ENDIF}
procedure TWinControl.InvalidatePreferredChildSizes; procedure TWinControl.InvalidatePreferredChildSizes;
var var
AControl: TControl; AControl: TControl;
@ -3339,18 +3236,6 @@ var
NewChildBounds: TRect; NewChildBounds: TRect;
OldChildBounds: TRect; OldChildBounds: TRect;
begin begin
{$IFDEF OldAutoSize}
{$IFDEF VerboseAutoSize}
debugln('TWinControl.DoAutoSize ',DbgSName(Self));
{$ENDIF}
if (not AutoSizeCanStart) or AutoSizeDelayed then begin
{$IFDEF VerboseAutoSize}
DebugLn(['TWinControl.DoAutoSize DELAYED AutoSizeCanStart=',AutoSizeCanStart,' AutoSizeDelayed=',AutoSizeDelayed]);
{$ENDIF}
Include(FControlFlags,cfAutoSizeNeeded);
exit;
end;
{$ELSE}
{$IFDEF VerboseAllAutoSize} {$IFDEF VerboseAllAutoSize}
debugln('TWinControl.DoAutoSize ',DbgSName(Self)); debugln('TWinControl.DoAutoSize ',DbgSName(Self));
{$ENDIF} {$ENDIF}
@ -3361,13 +3246,8 @@ begin
Include(FControlFlags,cfAutoSizeNeeded); Include(FControlFlags,cfAutoSizeNeeded);
exit; exit;
end; end;
{$ENDIF}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.DoAutoSize'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.DoAutoSize'){$ENDIF};
{$IFDEF OldAutoSize}
// obsolete
DisableAlign;
{$ENDIF}
try try
// test if resizing is possible // test if resizing is possible
HasVisibleChilds:=false; HasVisibleChilds:=false;
@ -3454,23 +3334,14 @@ begin
inc(NewTop,Height-PreferredHeight); inc(NewTop,Height-PreferredHeight);
//if CompareText(Name,'NewUnitOkButton')=0 then //if CompareText(Name,'NewUnitOkButton')=0 then
//debugln(['DoAutoSize Resize ',DbgSName(Self),' Old=',dbgs(BoundsRect),' New=',dbgs(Bounds(NewLeft,NewTop,PreferredWidth,PreferredHeight)),' WidthIsFixed=',WidthIsFixed,' HeightIsFixed=',HeightIsFixed,' Align=',dbgs(Align),' Anchors=',dbgs(Anchors)]); //debugln(['DoAutoSize Resize ',DbgSName(Self),' Old=',dbgs(BoundsRect),' New=',dbgs(Bounds(NewLeft,NewTop,PreferredWidth,PreferredHeight)),' WidthIsFixed=',WidthIsFixed,' HeightIsFixed=',HeightIsFixed,' Align=',dbgs(Align),' Anchors=',dbgs(Anchors)]);
{$IFDEF OldAutoSize}
SetAlignedBounds(NewLeft,NewTop,PreferredWidth,PreferredHeight);
{$ELSE}
SetBoundsKeepBase(NewLeft,NewTop,PreferredWidth,PreferredHeight); SetBoundsKeepBase(NewLeft,NewTop,PreferredWidth,PreferredHeight);
{$ENDIF}
end; end;
finally finally
Exclude(FControlFlags,cfAutoSizeNeeded); Exclude(FControlFlags,cfAutoSizeNeeded);
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.DoAutoSize'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.DoAutoSize'){$ENDIF};
{$IFDEF OldAutoSize}
// obsolete
EnableAlign;
{$ENDIF}
end; end;
end; end;
{$IFNDEF OldAutoSize}
procedure TWinControl.DoAllAutoSize; procedure TWinControl.DoAllAutoSize;
function CheckHandleAllocated(AWinControl: TWinControl): boolean; function CheckHandleAllocated(AWinControl: TWinControl): boolean;
@ -3595,7 +3466,6 @@ procedure TWinControl.AllAutoSized;
begin begin
// see TCustomForm.AllAutoSized // see TCustomForm.AllAutoSized
end; end;
{$ENDIF}
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TWinControl BroadCast TWinControl BroadCast
@ -3668,12 +3538,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TWinControl.DisableAlign; procedure TWinControl.DisableAlign;
begin begin
{$IFDEF OldAutoSize}
Inc(FAlignLevel);
//DebugLn(['TWinControl.DisableAlign ',dbgsName(Self),' ',FAlignLevel]);
{$ELSE}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.DisableAlign'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.DisableAlign'){$ENDIF};
{$ENDIF}
end; end;
{------------------------------------------------------------------------------- {-------------------------------------------------------------------------------
@ -3687,7 +3552,7 @@ var
R: TRect; R: TRect;
begin begin
if InvalidateRect then if InvalidateRect then
InvalidateClientRectCache({$IFDEF OldAutoSize}True{$ELSE}False{$ENDIF}); InvalidateClientRectCache(False);
R := GetClientRect; R := GetClientRect;
AdjustClientRect(R); AdjustClientRect(R);
//DebugLn(['TWinControl.DoAdjustClientRectChange ',DbgSName(Self),' ',r.Right,',',r.Bottom,' ',CompareRect(@r,@FAdjustClientRectRealized)]); //DebugLn(['TWinControl.DoAdjustClientRectChange ',DbgSName(Self),' ',r.Right,',',r.Bottom,' ',CompareRect(@r,@FAdjustClientRectRealized)]);
@ -3700,9 +3565,6 @@ begin
' New=',DbgS(r.Right),'x',DbgS(r.Bottom)); ' New=',DbgS(r.Right),'x',DbgS(r.Bottom));
{$ENDIF} {$ENDIF}
FAdjustClientRectRealized := R; FAdjustClientRectRealized := R;
{$IFDEF OldAutoSize}
ReAlign;
{$ENDIF}
AdjustSize; AdjustSize;
Resize; Resize;
end; end;
@ -3802,10 +3664,6 @@ var
OldHeight: LongInt; OldHeight: LongInt;
begin begin
//DbgOut('[TWinControl.DoSetBounds] ',Name,':',ClassName,' OldHeight=',DbgS(FHeight),' NewHeight=',DbgS(AHeight)); //DbgOut('[TWinControl.DoSetBounds] ',Name,':',ClassName,' OldHeight=',DbgS(FHeight),' NewHeight=',DbgS(AHeight));
{$IFDEF OldAutoSize}
InvalidateClientRectCache(False);
inherited DoSetBounds(ALeft, ATop, AWidth, AHeight);
{$ELSE}
OldWidth:=Width; OldWidth:=Width;
OldHeight:=Height; OldHeight:=Height;
inherited DoSetBounds(ALeft, ATop, AWidth, AHeight); inherited DoSetBounds(ALeft, ATop, AWidth, AHeight);
@ -3814,7 +3672,6 @@ begin
if FClientWidth<0 then FClientWidth:=0; if FClientWidth<0 then FClientWidth:=0;
inc(FClientHeight,Height-OldHeight); inc(FClientHeight,Height-OldHeight);
if FClientHeight<0 then FClientHeight:=0; if FClientHeight<0 then FClientHeight:=0;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -3822,17 +3679,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TWinControl.EnableAlign; procedure TWinControl.EnableAlign;
begin begin
{$IFDEF OldAutoSize}
Dec(FAlignLevel);
//DebugLn(['TWinControl.EnableAlign ',dbgsName(Self),' ',FAlignLevel]);
if FAlignLevel = 0 then begin
if (csAlignmentNeeded in ControlState)
or (wcfReAlignNeeded in FWinControlFlags) then
ReAlign;
end;
{$ELSE}
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.DisableAlign'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.DisableAlign'){$ENDIF};
{$ENDIF}
end; end;
procedure TWinControl.WriteLayoutDebugReport(const Prefix: string); procedure TWinControl.WriteLayoutDebugReport(const Prefix: string);
@ -3957,9 +3804,6 @@ function TWinControl.GetClientRect: TRect;
procedure StoreClientRect(NewClientRect: TRect); procedure StoreClientRect(NewClientRect: TRect);
var var
ClientSizeChanged: boolean; ClientSizeChanged: boolean;
{$IFDEF OldAutoSize}
i: Integer;
{$ENDIF}
begin begin
if wcfClientRectNeedsUpdate in FWinControlFlags then begin if wcfClientRectNeedsUpdate in FWinControlFlags then begin
ClientSizeChanged:=(FClientWidth<>NewClientRect.Right) ClientSizeChanged:=(FClientWidth<>NewClientRect.Right)
@ -3976,12 +3820,7 @@ function TWinControl.GetClientRect: TRect;
{$IFDEF VerboseClientRectBugFix} {$IFDEF VerboseClientRectBugFix}
DebugLn(['StoreClientRect ',DbgSName(Self),' ',FClientWidth,',',FClientHeight,' HandleAllocated=',HandleAllocated,' wcfBoundsRealized=',wcfBoundsRealized in FWinControlFlags]); DebugLn(['StoreClientRect ',DbgSName(Self),' ',FClientWidth,',',FClientHeight,' HandleAllocated=',HandleAllocated,' wcfBoundsRealized=',wcfBoundsRealized in FWinControlFlags]);
{$ENDIF} {$ENDIF}
{$IFDEF OldAutoSize}
for i:=0 to ControlCount-1 do
Controls[i].fLastAlignedBoundsTried:=0;
{$ELSE}
FAdjustClientRectRealized:=Rect(0,0,0,0); FAdjustClientRectRealized:=Rect(0,0,0,0);
{$ENDIF}
end; end;
Exclude(FWinControlFlags,wcfClientRectNeedsUpdate); Exclude(FWinControlFlags,wcfClientRectNeedsUpdate);
end; end;
@ -4340,35 +4179,6 @@ var
begin begin
bShow := HandleObjectShouldBeVisible; bShow := HandleObjectShouldBeVisible;
{$IFDEF OldAutoSize}
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;
ChangeShowing(bShow);
//DebugLn(['TWinControl.UpdateShowing ',DbgSName(Self),' FShowing=',FShowing,' AutoSizeDelayed=',AutoSizeDelayed]);
if FShowing then
begin
DisableAlign;
try
ResizeDelayedAutoSizeChildren;
AdjustSize;
finally
EnableAlign;
end;
end;
{$ELSE}
if bShow then begin if bShow then begin
if not HandleAllocated then CreateHandle; if not HandleAllocated then CreateHandle;
if FControls <> nil if FControls <> nil
@ -4394,7 +4204,6 @@ begin
end; end;
end; end;
ChangeShowing(bShow); ChangeShowing(bShow);
{$ENDIF}
end; end;
procedure TWinControl.Update; procedure TWinControl.Update;
@ -5998,14 +5807,12 @@ begin
end; end;
AControl.FParent := Self; AControl.FParent := Self;
{$IFNDEF OldAutoSize}
if AControl.FAutoSizingLockCount>0 then if AControl.FAutoSizingLockCount>0 then
begin begin
// the AControl has disabled autosizing => disable it for the parent=self too // the AControl has disabled autosizing => disable it for the parent=self too
//DebugLn([Space(FAutoSizingLockCount*2+2),'TWinControl.Insert ',DbgSName(Self),' Control=',DbgSName(AControl),' disable Parent']); //DebugLn([Space(FAutoSizingLockCount*2+2),'TWinControl.Insert ',DbgSName(Self),' Control=',DbgSName(AControl),' disable Parent']);
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.DisableAutoSizing'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.DisableAutoSizing'){$ENDIF};
end; end;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -6015,24 +5822,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TWinControl.ReAlign; procedure TWinControl.ReAlign;
begin begin
{$IFDEF OldAutoSize}
if (csDestroying in ComponentState) then exit;
if (csLoading in ComponentState) or (not HandleAllocated) then begin
Include(FWinControlFlags,wcfReAlignNeeded);
exit;
end;
Exclude(FWinControlFlags,wcfReAlignNeeded);// avoid calling after rekursive EnableAlign
{$IFDEF VerboseAutoSize}
DebugLn('TWinControl.ReAlign A',Name,':',ClassName,' ', Dbgs(BoundsRect));
{$ENDIF}
AlignControl(nil);
{$IFDEF VerboseAutoSize}
DebugLn('TWinControl.ReAlign B',Name,':',ClassName,' ', Dbgs(BoundsRect));
{$ENDIF}
Exclude(FWinControlFlags,wcfReAlignNeeded);// done
{$ELSE}
AdjustSize; AdjustSize;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -6048,7 +5838,6 @@ begin
ListRemove(FControls, AControl); ListRemove(FControls, AControl);
ListRemove(FAlignOrder, AControl); ListRemove(FAlignOrder, AControl);
AControl.FParent := nil; AControl.FParent := nil;
{$IFNDEF OldAutoSize}
if AControl.FAutoSizingLockCount>0 then if AControl.FAutoSizingLockCount>0 then
begin begin
// AControl has disabled autosizing and thus for its parent=Self too // AControl has disabled autosizing and thus for its parent=Self too
@ -6056,7 +5845,6 @@ begin
//DebugLn([Space(FAutoSizingLockCount*2),'TWinControl.Remove ',DbgSName(Self),' Control=',DbgSName(AControl),' enable Parent']); //DebugLn([Space(FAutoSizingLockCount*2),'TWinControl.Remove ',DbgSName(Self),' Control=',DbgSName(AControl),' enable Parent']);
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.DisableAutoSizing'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.DisableAutoSizing'){$ENDIF};
end; end;
{$ENDIF}
end; end;
end; end;
@ -6136,31 +5924,11 @@ end;
TWinControl.CMVisibleChanged TWinControl.CMVisibleChanged
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TWinControl.UpdateControlState; procedure TWinControl.UpdateControlState;
{$IFDEF OldAutoSize}
var
AWinControl: TWinControl;
{$ENDIF}
begin begin
{$IFDEF OldAutoSize}
AWinControl:= Self;
{ If any of the parent is not visible, exit }
while AWinControl.Parent <> nil do
begin
AWinControl:= AWinControl.Parent;
if (not AWinControl.Showing) or (not AWinControl.HandleAllocated) then Exit;
end;
if ((AWinControl is TCustomForm) and (AWinControl.Parent=nil))
or (AWinControl.FParentWindow <> 0) then
begin
UpdateShowing;
end;
{$ELSE}
if HandleObjectShouldBeVisible then if HandleObjectShouldBeVisible then
AdjustSize // this will trigger DoAllAutoSize, which calls UpdateShowing AdjustSize // this will trigger DoAllAutoSize, which calls UpdateShowing
else else
UpdateShowing; // hide immediately UpdateShowing; // hide immediately
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -6173,10 +5941,8 @@ end;
procedure TWinControl.InsertControl(AControl: TControl; Index: integer); procedure TWinControl.InsertControl(AControl: TControl; Index: integer);
begin begin
{$IFNDEF OldAutoSize}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.InsertControl'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.InsertControl'){$ENDIF};
try try
{$ENDIF}
AControl.ValidateContainer(Self); AControl.ValidateContainer(Self);
Perform(CM_CONTROLLISTCHANGE, WParam(AControl), LParam(True)); Perform(CM_CONTROLLISTCHANGE, WParam(AControl), LParam(True));
Insert(AControl,Index); Insert(AControl,Index);
@ -6194,22 +5960,11 @@ begin
AControl.Invalidate; AControl.Invalidate;
//DebugLn('TWinControl.InsertControl ',Name,':',ClassName); //DebugLn('TWinControl.InsertControl ',Name,':',ClassName);
end; end;
{$IFDEF OldAutoSize}
if not (csDestroying in ComponentState) then
begin
if not (csLoading in ComponentState) then
AControl.UpdateAnchorRules;
AControl.RequestAlign;
end;
{$ELSE}
AdjustSize; AdjustSize;
{$ENDIF}
Perform(CM_CONTROLCHANGE, WParam(AControl), LParam(True)); Perform(CM_CONTROLCHANGE, WParam(AControl), LParam(True));
{$IFNDEF OldAutoSize}
finally finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.InsertControl'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.InsertControl'){$ENDIF};
end; end;
{$ENDIF}
//debugln(['TWinControl.InsertControl ',DbgSName(Self),' ',csDesigning in ComponentState,' ',DbgSName(AControl),' ',csDesigning in AControl.ComponentState]); //debugln(['TWinControl.InsertControl ',DbgSName(Self),' ',csDesigning in ComponentState,' ',DbgSName(AControl),' ',csDesigning in AControl.ComponentState]);
end; end;
@ -6220,10 +5975,8 @@ procedure TWinControl.RemoveControl(AControl: TControl);
var var
AWinControl: TWinControl; AWinControl: TWinControl;
begin begin
{$IFNDEF OldAutoSize}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.RemoveControl'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.RemoveControl'){$ENDIF};
try try
{$ENDIF}
Perform(CM_CONTROLCHANGE, WParam(AControl), LParam(False)); Perform(CM_CONTROLCHANGE, WParam(AControl), LParam(False));
if AControl is TWinControl then if AControl is TWinControl then
begin begin
@ -6239,23 +5992,12 @@ begin
Perform(CM_CONTROLLISTCHANGE, WParam(AControl), LParam(False)); Perform(CM_CONTROLLISTCHANGE, WParam(AControl), LParam(False));
if not (csDestroying in ComponentState) then if not (csDestroying in ComponentState) then
begin begin
{$IFDEF OldAutoSize}
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Realign;
{$ELSE}
InvalidatePreferredSize; InvalidatePreferredSize;
AdjustSize; AdjustSize;
{$ENDIF}
end; end;
{$IFNDEF OldAutoSize}
finally finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.RemoveControl'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.RemoveControl'){$ENDIF};
end; end;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -6265,10 +6007,6 @@ procedure TWinControl.AlignControl(AControl: TControl);
var var
ARect: TRect; ARect: TRect;
NewRect: TRect; NewRect: TRect;
{$IFDEF OldAutoSize}
i: Integer;
ChildControl: TControl;
{$ENDIF}
begin begin
//if csDesigning in ComponentState then begin //if csDesigning in ComponentState then begin
// DbgOut('TWinControl.AlignControl ',Name,':',ClassName); // DbgOut('TWinControl.AlignControl ',Name,':',ClassName);
@ -6276,47 +6014,8 @@ begin
//end; //end;
if csDestroying in ComponentState then exit; if csDestroying in ComponentState then exit;
{$IFDEF OldAutoSize}
if FAlignLevel <> 0 then begin
Include(FControlState, csAlignmentNeeded);
exit;
end;
// check if all childs have finished loading
for i:=0 to ControlCount-1 do begin
ChildControl:=Controls[i];
if csLoading in ChildControl.ComponentState then begin
// child is loading
// -> mark the child, that itself and its brothers needs realigning
// (it will do this, when it has finished loading)
Include(ChildControl.FControlFlags,cfRequestAlignNeeded);
exit;
end;
end;
{$ELSE}
// only called by DoAllAutoSize, so no check needed // only called by DoAllAutoSize, so no check needed
{$ENDIF}
{$IFDEF OldAutoSize}
DisableAlign;
try
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);
finally
Exclude(FControlState, csAlignmentNeeded);
EnableAlign;
if (FAlignLevel=0) and (not IsAParentAligning) and (FControls<>nil) then
for i:=0 to FControls.Count-1 do
if TObject(FControls[i]) is TWinControl then
TWinControl(FControls[i]).RealizeBoundsRecursive;
end;
{$ELSE}
DisableAlign; DisableAlign;
try try
ARect:= GetLogicalClientRect; ARect:= GetLogicalClientRect;
@ -6329,7 +6028,6 @@ begin
finally finally
EnableAlign; EnableAlign;
end; end;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -6804,7 +6502,6 @@ begin
if HandleAllocated and (not IsIconic(Handle)) then if HandleAllocated and (not IsIconic(Handle)) then
GetWindowSize(Handle, NewWidth, NewHeight); GetWindowSize(Handle, NewWidth, NewHeight);
FBoundsRealized := Bounds(Message.XPos, Message.YPos, NewWidth, NewHeight); FBoundsRealized := Bounds(Message.XPos, Message.YPos, NewWidth, NewHeight);
{$IFNDEF OldAutoSize}
if ([caspCreatingHandles,caspComputingBounds]*AutoSizePhases<>[]) if ([caspCreatingHandles,caspComputingBounds]*AutoSizePhases<>[])
then begin then 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
@ -6817,16 +6514,11 @@ begin
//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;
{$ENDIF}
end; end;
{$IFDEF OldAutoSize}
SetBoundsKeepBase(Message.XPos, Message.YPos, NewWidth, NewHeight, Parent <> nil);
{$ELSE}
if Parent<>nil then if Parent<>nil then
SetBoundsKeepBase(Message.XPos, Message.YPos, NewWidth, NewHeight) SetBoundsKeepBase(Message.XPos, Message.YPos, NewWidth, NewHeight)
else else
SetBounds(Message.XPos, Message.YPos, NewWidth, NewHeight); SetBounds(Message.XPos, Message.YPos, NewWidth, NewHeight);
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -6887,7 +6579,6 @@ begin
{$ENDIF} {$ENDIF}
FBoundsRealized := NewBoundsRealized; FBoundsRealized := NewBoundsRealized;
{$IFNDEF OldAutoSize}
//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 begin then begin
@ -6901,22 +6592,11 @@ begin
//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;
{$ENDIF}
{$IFNDEF OldAutoSize}
if Parent<>nil then if Parent<>nil then
{$ENDIF}
InvalidatePreferredSize; InvalidatePreferredSize;
end; end;
{$IFDEF OldAutoSize}
SetBoundsKeepBase(NewLeft, NewTop, Message.Width, Message.Height, Parent <> nil);
if ClientRectNeedsInterfaceUpdate then
DoAdjustClientRectChange;
if ((Message.SizeType and Size_SourceIsInterface) > 0) and
(Parent <> nil) and Parent.AutoSize then
Parent.AdjustSize;
{$ELSE}
if Parent<>nil then if Parent<>nil then
SetBoundsKeepBase(NewLeft, NewTop, Message.Width, Message.Height) SetBoundsKeepBase(NewLeft, NewTop, Message.Width, Message.Height)
else else
@ -6924,7 +6604,6 @@ begin
if ((Message.SizeType and Size_SourceIsInterface) > 0) if ((Message.SizeType and Size_SourceIsInterface) > 0)
and ClientRectNeedsInterfaceUpdate then and ClientRectNeedsInterfaceUpdate then
DoAdjustClientRectChange; DoAdjustClientRectChange;
{$ENDIF}
{$IFDEF VerboseClientRectBugFix} {$IFDEF VerboseClientRectBugFix}
//if Name=CheckClientRectName then //if Name=CheckClientRectName then
if ((Message.SizeType and Size_SourceIsInterface) > 0) then if ((Message.SizeType and Size_SourceIsInterface) > 0) then
@ -6993,7 +6672,6 @@ begin
' wcfClientRectNeedsUpdate=',wcfClientRectNeedsUpdate in FWinControlFlags]); ' wcfClientRectNeedsUpdate=',wcfClientRectNeedsUpdate in FWinControlFlags]);
{ $ENDIF} { $ENDIF}
FBoundsRealized := NewBoundsRealized; FBoundsRealized := NewBoundsRealized;
{$IFNDEF OldAutoSize}
//DebugLn(['TWinControl.WMSize ',DbgSName(Self),' phases=',dbgs(AutoSizePhases)]); //DebugLn(['TWinControl.WMSize ',DbgSName(Self),' phases=',dbgs(AutoSizePhases)]);
if ([caspCreatingHandles,caspComputingBounds]*AutoSizePhases<>[]) if ([caspCreatingHandles,caspComputingBounds]*AutoSizePhases<>[])
or (not (wcfBoundsRealized in FWinControlFlags)) or (not (wcfBoundsRealized in FWinControlFlags))
@ -7011,9 +6689,7 @@ begin
if Parent<>nil then if Parent<>nil then
InvalidatePreferredSize; InvalidatePreferredSize;
{$ENDIF}
{$IFNDEF OldAutoSize}
if Parent<>nil then if Parent<>nil then
SetBoundsKeepBase(NewLeft, NewTop, NewWidth, NewHeight) SetBoundsKeepBase(NewLeft, NewTop, NewWidth, NewHeight)
else else
@ -7021,7 +6697,6 @@ begin
if ((Message.WindowPos^.flags and SWP_SourceIsInterface) > 0) if ((Message.WindowPos^.flags and SWP_SourceIsInterface) > 0)
and ClientRectNeedsInterfaceUpdate then and ClientRectNeedsInterfaceUpdate then
DoAdjustClientRectChange; DoAdjustClientRectChange;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -7306,36 +6981,28 @@ begin
if (csDestroying in ComponentState) if (csDestroying in ComponentState)
or (Parent<>nil) and (csDestroying in Parent.ComponentState) then begin or (Parent<>nil) and (csDestroying in Parent.ComponentState) then begin
DebugLn('[TWinControl.CreateWnd] NOTE: csDestroying ',DbgSName(Self)); DebugLn('[TWinControl.CreateWnd] NOTE: csDestroying ',DbgSName(Self));
{$IFNDEF OldAutoSize}
RaiseGDBException(''); RaiseGDBException('');
{$ENDIF}
exit; exit;
end; end;
if wcfInitializing in FWinControlFlags if wcfInitializing in FWinControlFlags
then begin then begin
DebugLn('[WARNING] Recursive call to CreateWnd for ',DbgSName(Self), ' while initializing'); DebugLn('[WARNING] Recursive call to CreateWnd for ',DbgSName(Self), ' while initializing');
{$IFNDEF OldAutoSize}
RaiseGDBException(''); RaiseGDBException('');
{$ENDIF}
Exit; Exit;
end; end;
if wcfCreatingHandle in FWinControlFlags if wcfCreatingHandle in FWinControlFlags
then begin then 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');
{$IFNDEF OldAutoSize}
RaiseGDBException(''); RaiseGDBException('');
{$ENDIF}
Exit; Exit;
end; end;
if wcfCreatingChildHandles in FWinControlFlags if wcfCreatingChildHandles in FWinControlFlags
then begin then 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');
{$IFNDEF OldAutoSize}
RaiseGDBException(''); RaiseGDBException('');
{$ENDIF}
Exit; Exit;
end; end;
@ -7348,13 +7015,8 @@ begin
FBoundsRealized:=Rect(0,0,0,0); FBoundsRealized:=Rect(0,0,0,0);
Exclude(FWinControlFlags,wcfBoundsRealized); Exclude(FWinControlFlags,wcfBoundsRealized);
{$IFDEF OldAutoSize}
// obsolete
DisableAlign;
{$ENDIF}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.CreateWnd'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.CreateWnd'){$ENDIF};
try try
{$IFNDEF OldAutoSize}
if (Parent<>nil) and (not Parent.HandleAllocated) then if (Parent<>nil) and (not Parent.HandleAllocated) then
begin begin
// first create the parent handle // first create the parent handle
@ -7362,7 +7024,6 @@ begin
if HandleAllocated then exit; if HandleAllocated then exit;
DebugLn(['WARNING: TWinControl.CreateWnd: parent created handles, but not ours']); DebugLn(['WARNING: TWinControl.CreateWnd: parent created handles, but not ours']);
end; end;
{$ENDIF}
// Control is not visible at this moment. It will be shown in UpdateShowing // Control is not visible at this moment. It will be shown in UpdateShowing
FShowing := False; FShowing := False;
Exclude(FWinControlFlags, wcfHandleVisible); Exclude(FWinControlFlags, wcfHandleVisible);
@ -7426,22 +7087,11 @@ begin
Exclude(FWinControlFlags, wcfCreatingChildHandles); Exclude(FWinControlFlags, wcfCreatingChildHandles);
end; end;
{$IFDEF OldAutoSize}
// size this control
UpdateShowing;
AdjustSize;
if FControls<>nil then
for i:=0 to FControls.Count-1 do
TControl(FControls[i]).AdjustSize;
// realign childs
ReAlign;
{$ELSE}
if FControls<>nil then if FControls<>nil then
for i:=0 to FControls.Count-1 do for i:=0 to FControls.Count-1 do
TControl(FControls[i]).InvalidatePreferredSize; TControl(FControls[i]).InvalidatePreferredSize;
// size this control // size this control
AdjustSize; AdjustSize;
{$ENDIF}
finally finally
//DebugLn(['TWinControl.CreateWnd created ',DbgSName(Self),' enable autosizing ...']); //DebugLn(['TWinControl.CreateWnd created ',DbgSName(Self),' enable autosizing ...']);
(* If an error occured and FHandle was not created, (* If an error occured and FHandle was not created,
@ -7451,10 +7101,6 @@ begin
As a side effect the current control will be left in autosize-disabled *) As a side effect the current control will be left in autosize-disabled *)
if FHandle <> 0 then if FHandle <> 0 then
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.CreateWnd'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.CreateWnd'){$ENDIF};
{$IFDEF OldAutoSize}
// obsolete
EnableAlign;
{$ENDIF}
end; end;
//DebugLn('[TWinControl.CreateWnd] END ',Name,':',Classname); //DebugLn('[TWinControl.CreateWnd] END ',Name,':',Classname);
@ -7480,9 +7126,6 @@ begin
// First set the WinControl property some interfaces depends on it // First set the WinControl property some interfaces depends on it
SetProp(Handle,'WinControl',TWinControl(Self)); SetProp(Handle,'WinControl',TWinControl(Self));
{$IFDEF OldAutoSize}
DisableAlign;
{$ENDIF}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.InitializeWnd'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.InitializeWnd'){$ENDIF};
try try
{$IFDEF CHECK_POSITION} {$IFDEF CHECK_POSITION}
@ -7491,11 +7134,6 @@ begin
' OldRelBounds=',dbgs(FBoundsRealized), ' OldRelBounds=',dbgs(FBoundsRealized),
' -> NewBounds=',dbgs(BoundsRect)); ' -> NewBounds=',dbgs(BoundsRect));
{$ENDIF} {$ENDIF}
{$IFDEF OldAutoSize}
// obsolete
if (Width>0) and (Height>0) then
DoSendBoundsToInterface;
{$ENDIF}
if wcfColorChanged in FWinControlFlags then if wcfColorChanged in FWinControlFlags then
begin begin
@ -7526,9 +7164,6 @@ begin
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};
{$IFDEF OldAutoSize}
EnableAlign;
{$ENDIF}
end; end;
// send pending OnResize // send pending OnResize
Resize; Resize;
@ -7611,12 +7246,7 @@ var
LoadedClientSize: TPoint; LoadedClientSize: TPoint;
CurControl: TWinControl; CurControl: TWinControl;
begin begin
{$IFDEF OldAutoSize}
// obsolete
DisableAlign;
{$ELSE}
//DebugLn(['TWinControl.Loaded START ',DbgSName(Self),' cfWidthLoaded=',cfWidthLoaded in FControlFlags,' cfHeightLoaded=',cfHeightLoaded in FControlFlags,' ']); //DebugLn(['TWinControl.Loaded START ',DbgSName(Self),' cfWidthLoaded=',cfWidthLoaded in FControlFlags,' cfHeightLoaded=',cfHeightLoaded in FControlFlags,' ']);
{$ENDIF}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.Loaded'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.Loaded'){$ENDIF};
try try
//DebugLn(['TWinControl.Loaded ',DbgSName(Self),' cfWidthLoaded=',cfWidthLoaded in FControlFlags,' cfHeightLoaded=',cfHeightLoaded in FControlFlags,' ']); //DebugLn(['TWinControl.Loaded ',DbgSName(Self),' cfWidthLoaded=',cfWidthLoaded in FControlFlags,' cfHeightLoaded=',cfHeightLoaded in FControlFlags,' ']);
@ -7675,23 +7305,10 @@ begin
FixupTabList; FixupTabList;
{$IFDEF OldAutoSize}
// obsolete
RealizeBounds;
if HandleAllocated and ([csDestroying]*ComponentState=[]) then
DoSendShowHideToInterface;
{$ENDIF}
finally finally
{$IFNDEF OldAutoSize}
//DebugLn(['TWinControl.Loaded enableautosizing ',DbgSName(Self),' ',dbgs(BoundsRect)]); //DebugLn(['TWinControl.Loaded enableautosizing ',DbgSName(Self),' ',dbgs(BoundsRect)]);
{$ENDIF}
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.Loaded'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.Loaded'){$ENDIF};
{$IFDEF OldAutoSize}
// obsolete
EnableAlign;
{$ELSE}
//DebugLn(['TWinControl.Loaded END ',DbgSName(Self),' ',dbgs(BoundsRect)]); //DebugLn(['TWinControl.Loaded END ',DbgSName(Self),' ',dbgs(BoundsRect)]);
{$ENDIF}
end; end;
end; end;
@ -7718,10 +7335,8 @@ begin
if HandleAllocated then if HandleAllocated then
begin begin
//DebugLn(['TWinControl.DestroyWnd ',DbgSName(Self)]); //DebugLn(['TWinControl.DestroyWnd ',DbgSName(Self)]);
{$IFNDEF OldAutoSize}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.DestroyWnd'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.DestroyWnd'){$ENDIF};
try try
{$ENDIF}
FinalizeWnd; FinalizeWnd;
if FControls <> nil then if FControls <> nil then
@ -7735,11 +7350,9 @@ begin
// again. To propely initialize control after we need to restore color // again. To propely initialize control after we need to restore color
// and font. Request update. // and font. Request update.
FWinControlFlags := FWinControlFlags + [wcfColorChanged, wcfFontChanged]; FWinControlFlags := FWinControlFlags + [wcfColorChanged, wcfFontChanged];
{$IFNDEF OldAutoSize}
finally finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.DestroyWnd'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.DestroyWnd'){$ENDIF};
end; end;
{$ENDIF}
end; end;
end; end;
@ -7824,9 +7437,7 @@ begin
RaiseGDBException('UnlockRealizeBounds'); RaiseGDBException('UnlockRealizeBounds');
dec(FRealizeBoundsLockCount); dec(FRealizeBoundsLockCount);
if (FRealizeBoundsLockCount=0) if (FRealizeBoundsLockCount=0)
{$IFNDEF OldAutoSize}
and (not AutoSizeDelayed) and (caspRealizingBounds in AutoSizePhases) and (not AutoSizeDelayed) and (caspRealizingBounds in AutoSizePhases)
{$ENDIF}
then then
RealizeBounds; RealizeBounds;
end; end;
@ -7989,11 +7600,7 @@ begin
if [csDesigning,csDestroying,csLoading]*ComponentState=[csDesigning] then if [csDesigning,csDestroying,csLoading]*ComponentState=[csDesigning] then
CheckDesignBounds; CheckDesignBounds;
// LCL bounds are not up2date -> process new bounds // LCL bounds are not up2date -> process new bounds
{$IFDEF OldAutoSize}
LockRealizeBounds;
{$ELSE}
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.SetBounds'){$ENDIF}; DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.SetBounds'){$ENDIF};
{$ENDIF}
try try
{$IFDEF CHECK_POSITION} {$IFDEF CHECK_POSITION}
//if csDesigning in ComponentState then //if csDesigning in ComponentState then
@ -8005,11 +7612,7 @@ begin
inherited SetBounds(ALeft, ATop, AWidth, AHeight); inherited SetBounds(ALeft, ATop, AWidth, AHeight);
//DebugLn(['TWinControl.SetBounds ',DbgSName(Self),' FUseDockManager=',FUseDockManager,' ',DbgSName(DockManager)]); //DebugLn(['TWinControl.SetBounds ',DbgSName(Self),' FUseDockManager=',FUseDockManager,' ',DbgSName(DockManager)]);
finally finally
{$IFDEF OldAutoSize}
UnlockRealizeBounds;
{$ELSE}
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.SetBounds'){$ENDIF}; EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.SetBounds'){$ENDIF};
{$ENDIF}
end; end;
end; end;
end; end;
@ -8250,7 +7853,6 @@ var
OldBounds: TRect; OldBounds: TRect;
{$ENDIF} {$ENDIF}
begin begin
{$IFNDEF OldAutoSize}
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:
@ -8262,7 +7864,6 @@ begin
Only send the last bounds. } Only send the last bounds. }
exit; exit;
end; end;
{$ENDIF}
NewBounds:=Bounds(Left, Top, Width, Height); NewBounds:=Bounds(Left, Top, Width, Height);
{$IF defined(VerboseResizeFlicker)} {$IF defined(VerboseResizeFlicker)}
if HandleAllocated then begin if HandleAllocated then begin
@ -8307,26 +7908,21 @@ begin
end; end;
{$ENDIF} {$ENDIF}
FBoundsRealized:=NewBounds; FBoundsRealized:=NewBounds;
{$IFNDEF OldAutoSize}
OldClientRect:=ClientRect; OldClientRect:=ClientRect;
{$ENDIF}
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);
{$IFNDEF OldAutoSize}
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;
end; end;
{$ENDIF}
end; end;
procedure TWinControl.RealizeBounds; procedure TWinControl.RealizeBounds;
{$IFNDEF OldAutoSize}
procedure Check; procedure Check;
var var
c: TWinControl; c: TWinControl;
@ -8342,7 +7938,6 @@ procedure TWinControl.RealizeBounds;
end; end;
RaiseGDBException(''); RaiseGDBException('');
end; end;
{$ENDIF}
var var
NewBounds: TRect; NewBounds: TRect;
@ -8352,9 +7947,6 @@ begin
and ([csLoading,csDestroying]*ComponentState=[]) and ([csLoading,csDestroying]*ComponentState=[])
and (not (csDestroyingHandle in ControlState)) and (not (csDestroyingHandle in ControlState))
and (not CompareRect(@NewBounds,@FBoundsRealized)) and (not CompareRect(@NewBounds,@FBoundsRealized))
{$IFDEF OldAutoSize}
and (not IsAParentAligning)
{$ENDIF}
then begin then begin
// the new bounds were not yet sent to the InterfaceObject -> send them // the new bounds were not yet sent to the InterfaceObject -> send them
{$IFDEF CHECK_POSITION} {$IFDEF CHECK_POSITION}
@ -8383,9 +7975,7 @@ begin
if (CompareRect(@NewBounds,@FBoundsRealized)) then debugln('bounds not changed'); if (CompareRect(@NewBounds,@FBoundsRealized)) then debugln('bounds not changed');
end; end;
{$ENDIF} {$ENDIF}
{$IFNDEF OldAutoSize}
if not HandleAllocated then Check; if not HandleAllocated then Check;
{$ENDIF}
end; end;
end; end;

View File

@ -462,9 +462,7 @@ procedure TCarbonWidget.UpdateLCLClientRect;
var var
R: TRect; R: TRect;
begin begin
if not Resizing if not Resizing then begin
{$IFDEF OldAutoSize} and not (csAlignmentNeeded in LCLObject.ControlState){$ENDIF}
then begin
GetBounds(R); GetBounds(R);
LCLObject.InvalidateClientRectCache(False); LCLObject.InvalidateClientRectCache(False);
LCLSendSizeMsg(LCLObject, R.Right - R.Left, R.Bottom - R.Top, Size_SourceIsInterface); LCLSendSizeMsg(LCLObject, R.Right - R.Left, R.Bottom - R.Top, Size_SourceIsInterface);

View File

@ -2016,21 +2016,7 @@ begin
SaveSizeNotification(Widget); SaveSizeNotification(Widget);
end; end;
{$ELSE} {$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
after all its childs. So, the gtk resizes in top-bottom order, just like the
LCL. But it sends size messages in bottom-top order, which can result in
many resizes in the LCL.
}
// The resize messages of the inner widget of a Control is cached.
// This is the resize of an outer widget and sent to the LCL immediately.
SendSizeNotificationToLCL(Widget);
end;
{$ELSE}
SendSizeNotificationToLCL(Widget); SendSizeNotificationToLCL(Widget);
{$ENDIF}
{$ENDIF} {$ENDIF}
end; end;
@ -2588,11 +2574,7 @@ begin
if (AWidgetInfo^.LCLObject is TScrollingWinControl) then if (AWidgetInfo^.LCLObject is TScrollingWinControl) then
begin begin
{$ifdef OldAutoSize}
MaxValue := ARange^.adjustment^.upper - ARange^.adjustment^.page_size;
{$else}
MaxValue := ARange^.adjustment^.upper; MaxValue := ARange^.adjustment^.upper;
{$endif}
if (AValue > MaxValue) or (AValue < ARange^.adjustment^.lower) then if (AValue > MaxValue) or (AValue < ARange^.adjustment^.lower) then
begin begin
Result := not Result; Result := not Result;

View File

@ -6633,10 +6633,8 @@ var
GtkLeft, GtkTop, GtkWidth, GtkHeight: integer; GtkLeft, GtkTop, GtkWidth, GtkHeight: integer;
TopLeftChanged, WidthHeightChanged, IsTopLevelWidget: boolean; TopLeftChanged, WidthHeightChanged, IsTopLevelWidget: boolean;
MessageDelivered: boolean; MessageDelivered: boolean;
{ $IFDEF OldAutoSize}
SizeMsg: TLMSize; SizeMsg: TLMSize;
MoveMsg: TLMMove; MoveMsg: TLMMove;
{ $ENDIF}
PosMsg : TLMWindowPosChanged; PosMsg : TLMWindowPosChanged;
MainWidget: PGtkWidget; MainWidget: PGtkWidget;
FixedWidget: PGtkWidget; FixedWidget: PGtkWidget;
@ -6672,7 +6670,7 @@ begin
FWidgetsResized.Remove(MainWidget); FWidgetsResized.Remove(MainWidget);
FFixWidgetsResized.Remove(FixedWidget); FFixWidgetsResized.Remove(FixedWidget);
{$IF defined(Gtk1) or defined(OldAutoSize)} {$IF defined(Gtk1)}
if not GTK_WIDGET_REALIZED(aWidget) then begin if not GTK_WIDGET_REALIZED(aWidget) then begin
// the widget is not yet realized, so this GTK resize was not a user change. // the widget is not yet realized, so this GTK resize was not a user change.
// => ignore // => ignore
@ -6747,9 +6745,7 @@ begin
cx := GtkWidth; cx := GtkWidth;
cy := GtkHeight; cy := GtkHeight;
flags:=0; flags:=0;
{$IFNDEF OldAutoSize} // flags := SWP_SourceIsInterface;
// flags := SWP_SourceIsInterface;
{$ENDIF}
end; end;
MessageDelivered := DeliverMessage(LCLControl, PosMsg) = 0; MessageDelivered := DeliverMessage(LCLControl, PosMsg) = 0;
finally finally
@ -6761,7 +6757,6 @@ begin
UpdateLCLSize; UpdateLCLSize;
end; end;
{ $IFDEF OldAutoSize}
// then send a LM_SIZE message // then send a LM_SIZE message
if WidthHeightChanged then begin if WidthHeightChanged then begin
{$IFDEF VerboseSizeMsg} {$IFDEF VerboseSizeMsg}
@ -6815,7 +6810,6 @@ begin
MessageDelivered := (DeliverMessage(LCLControl, MoveMsg) = 0); MessageDelivered := (DeliverMessage(LCLControl, MoveMsg) = 0);
if not MessageDelivered then exit; if not MessageDelivered then exit;
end; end;
{ $ENDIF}
{$ifndef gtk1} {$ifndef gtk1}
if GtkWidgetIsA(aWidget, GTKAPIWidget_Type) and if GtkWidgetIsA(aWidget, GTKAPIWidget_Type) and

View File

@ -410,9 +410,6 @@ var
MenuWidget: PGtkWidget; // the popup menu (hbox containing a pixmap and MenuWidget: PGtkWidget; // the popup menu (hbox containing a pixmap and
// a label) // a label)
MenuLabelWidget: PGtkWidget; // the label in the popup menu item MenuLabelWidget: PGtkWidget; // the label in the popup menu item
{$IFDEF OldAutoSize}
allocation: TGtkAllocation;
{$ENDIF}
begin begin
{$IFDEF NOTEBOOK_DEBUG} {$IFDEF NOTEBOOK_DEBUG}
DebugLn(['TGtkWSCustomNotebook.AddPage ',dbgsName(ANoteBook),' ',ANotebook.HandleAllocated,' AChild=',dbgsName(AChild),' ',AChild.HandleAllocated,' Child.TabVisible=',AChild.TabVisible]); DebugLn(['TGtkWSCustomNotebook.AddPage ',dbgsName(ANoteBook),' ',ANotebook.HandleAllocated,' AChild=',dbgsName(AChild),' ',AChild.HandleAllocated,' Child.TabVisible=',AChild.TabVisible]);
@ -472,16 +469,9 @@ begin
// init the size of the page widget // init the size of the page widget
//DebugLn(['TGtkWSCustomNotebook.AddPage ',DbgSName(ANoteBook),' ',dbgs(ANoteBook.BoundsRect)]); //DebugLn(['TGtkWSCustomNotebook.AddPage ',DbgSName(ANoteBook),' ',dbgs(ANoteBook.BoundsRect)]);
{$IFDEF OldAutoSize}
allocation.x := ANoteBook.Left;
allocation.y := ANoteBook.Top;
allocation.width := ANoteBook.Width;
allocation.height := ANoteBook.Height;
gtk_widget_size_allocate(NotebookWidget, @allocation);// Beware: this triggers callbacks
{$IFDEF VerboseSizeMsg} {$IFDEF VerboseSizeMsg}
DebugLn(['TGtkWSCustomNotebook.AddPage PageWidget^.allocation=',dbgs(PageWidget^.allocation),' NotebookWidget=',dbgs(NotebookWidget^.allocation)]); DebugLn(['TGtkWSCustomNotebook.AddPage PageWidget^.allocation=',dbgs(PageWidget^.allocation),' NotebookWidget=',dbgs(NotebookWidget^.allocation)]);
{$ENDIF} {$ENDIF}
{$ENDIF}
end; end;
class procedure TGtkWSCustomNotebook.MovePage(const ANotebook: TCustomNotebook; class procedure TGtkWSCustomNotebook.MovePage(const ANotebook: TCustomNotebook;

View File

@ -1503,11 +1503,7 @@ begin
gtk_frame_set_shadow_type(PGtkFrame(Result), StaticBorderShadowMap[AStaticText.BorderStyle]); gtk_frame_set_shadow_type(PGtkFrame(Result), StaticBorderShadowMap[AStaticText.BorderStyle]);
EventBox := gtk_event_box_new; // our area EventBox := gtk_event_box_new; // our area
{$IFDEF OldAutoSize}
LblWidget := gtk_label_new(nil); // our text widget
{$ELSE}
LblWidget := gtk_label_new(PChar(TCustomStaticText(AWinControl).Caption)); // our text widget LblWidget := gtk_label_new(PChar(TCustomStaticText(AWinControl).Caption)); // our text widget
{$ENDIF}
gtk_container_add(PGtkContainer(EventBox), LblWidget); gtk_container_add(PGtkContainer(EventBox), LblWidget);
SetLabelAlignment(PGtkLabel(LblWidget), AStaticText.Alignment); SetLabelAlignment(PGtkLabel(LblWidget), AStaticText.Alignment);
gtk_widget_show(LblWidget); gtk_widget_show(LblWidget);