IDE: improved layout of compiler options, LCL: calling AdjustSize when client rect changed

git-svn-id: trunk@9890 -
This commit is contained in:
mattias 2006-09-13 20:57:35 +00:00
parent 2ca7b335bb
commit f68e5b904f
7 changed files with 792 additions and 1063 deletions

File diff suppressed because it is too large Load Diff

View File

@ -98,6 +98,7 @@ resourcestring
lisLazarusLanguageID = 'Lazarus language ID (e.g. en, de, br, fi)'; lisLazarusLanguageID = 'Lazarus language ID (e.g. en, de, br, fi)';
lisLazarusLanguageName = 'Lazarus language name (e.g. english, deutsch)'; lisLazarusLanguageName = 'Lazarus language name (e.g. english, deutsch)';
lisLCLWidgetType = 'LCL Widget Type'; lisLCLWidgetType = 'LCL Widget Type';
lisCOVarious = '%s (various)';
lisTargetCPU = 'Target CPU'; lisTargetCPU = 'Target CPU';
lisTargetOS = 'Target OS'; lisTargetOS = 'Target OS';
lisCommandLineParamsOfProgram = 'Command line parameters of program'; lisCommandLineParamsOfProgram = 'Command line parameters of program';

View File

@ -1124,6 +1124,7 @@ type
Sibling: TControl; Sibling: TControl;
FreeCompositeSide: boolean = true); FreeCompositeSide: boolean = true);
procedure AnchorSame(Side: TAnchorKind; Sibling: TControl); procedure AnchorSame(Side: TAnchorKind; Sibling: TControl);
procedure AnchorAsAlign(TheAlign: TAlign; Space: Integer);
procedure AnchorClient(Space: Integer); procedure AnchorClient(Space: Integer);
function AnchoredControlCount: integer; function AnchoredControlCount: integer;
property AnchoredControls[Index: integer]: TControl read GetAnchoredControls; property AnchoredControls[Index: integer]: TControl read GetAnchoredControls;

View File

@ -3606,34 +3606,44 @@ end;
procedure TControl.AnchorToNeighbour(Side: TAnchorKind; Space: integer; procedure TControl.AnchorToNeighbour(Side: TAnchorKind; Space: integer;
Sibling: TControl); Sibling: TControl);
begin begin
case Side of if Parent<>nil then Parent.DisableAlign;
akLeft: BorderSpacing.Left:=Space; try
akTop: BorderSpacing.Top:=Space; case Side of
akRight: BorderSpacing.Right:=Space; akLeft: BorderSpacing.Left:=Space;
akBottom: BorderSpacing.Bottom:=Space; akTop: BorderSpacing.Top:=Space;
akRight: BorderSpacing.Right:=Space;
akBottom: BorderSpacing.Bottom:=Space;
end;
AnchorSide[Side].Side:=DefaultSideForAnchorKind[Side];
AnchorSide[Side].Control:=Sibling;
Anchors:=Anchors+[Side];
finally
if Parent<>nil then Parent.EnableAlign;
end; end;
AnchorSide[Side].Side:=DefaultSideForAnchorKind[Side];
AnchorSide[Side].Control:=Sibling;
Anchors:=Anchors+[Side];
end; end;
procedure TControl.AnchorParallel(Side: TAnchorKind; Space: integer; procedure TControl.AnchorParallel(Side: TAnchorKind; Space: integer;
Sibling: TControl); Sibling: TControl);
begin begin
case Side of if Parent<>nil then Parent.DisableAlign;
akLeft: BorderSpacing.Left:=Space; try
akTop: BorderSpacing.Top:=Space; case Side of
akRight: BorderSpacing.Right:=Space; akLeft: BorderSpacing.Left:=Space;
akBottom: BorderSpacing.Bottom:=Space; akTop: BorderSpacing.Top:=Space;
akRight: BorderSpacing.Right:=Space;
akBottom: BorderSpacing.Bottom:=Space;
end;
case Side of
akLeft: AnchorSide[Side].Side:=asrLeft;
akTop: AnchorSide[Side].Side:=asrTop;
akRight: AnchorSide[Side].Side:=asrRight;
akBottom: AnchorSide[Side].Side:=asrBottom;
end;
AnchorSide[Side].Control:=Sibling;
Anchors:=Anchors+[Side];
finally
if Parent<>nil then Parent.EnableAlign;
end; end;
case Side of
akLeft: AnchorSide[Side].Side:=asrLeft;
akTop: AnchorSide[Side].Side:=asrTop;
akRight: AnchorSide[Side].Side:=asrRight;
akBottom: AnchorSide[Side].Side:=asrBottom;
end;
AnchorSide[Side].Control:=Sibling;
Anchors:=Anchors+[Side];
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -3643,9 +3653,14 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.AnchorHorizontalCenterTo(Sibling: TControl); procedure TControl.AnchorHorizontalCenterTo(Sibling: TControl);
begin begin
AnchorSide[akLeft].Side:=asrCenter; if Parent<>nil then Parent.DisableAlign;
AnchorSide[akLeft].Control:=Sibling; try
Anchors:=Anchors+[akLeft]-[akRight]; AnchorSide[akLeft].Side:=asrCenter;
AnchorSide[akLeft].Control:=Sibling;
Anchors:=Anchors+[akLeft]-[akRight];
finally
if Parent<>nil then Parent.EnableAlign;
end;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -3655,9 +3670,14 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.AnchorVerticalCenterTo(Sibling: TControl); procedure TControl.AnchorVerticalCenterTo(Sibling: TControl);
begin begin
AnchorSide[akTop].Side:=asrCenter; if Parent<>nil then Parent.DisableAlign;
AnchorSide[akTop].Control:=Sibling; try
Anchors:=Anchors+[akTop]-[akBottom]; AnchorSide[akTop].Side:=asrCenter;
AnchorSide[akTop].Control:=Sibling;
Anchors:=Anchors+[akTop]-[akBottom];
finally
if Parent<>nil then Parent.EnableAlign;
end;
end; end;
procedure TControl.AnchorToCompanion(Side: TAnchorKind; Space: integer; procedure TControl.AnchorToCompanion(Side: TAnchorKind; Space: integer;
@ -3672,60 +3692,82 @@ procedure TControl.AnchorToCompanion(Side: TAnchorKind; Space: integer;
begin begin
if not (OppositeAnchor[Side] in Anchors) then if not (OppositeAnchor[Side] in Anchors) then
AnchorSide[OppositeResizeSide].Control:=nil; AnchorSide[OppositeResizeSide].Control:=nil;
AnchorToNeighbour(ResizeSide,0,Sibling); AnchorToNeighbour(ResizeSide,Space,Sibling);
AnchorParallel(FixedSide1,0,Sibling); AnchorParallel(FixedSide1,0,Sibling);
AnchorParallel(FixedSide2,0,Sibling); AnchorParallel(FixedSide2,0,Sibling);
BorderSpacing.SetSpace(ResizeSide,Space);
end; end;
var var
NewAnchors: TAnchors; NewAnchors: TAnchors;
begin begin
// anchor all. Except for the opposite side. if Parent<>nil then Parent.DisableAlign;
NewAnchors:=[akLeft,akTop,akRight,akBottom]; try
if FreeCompositeSide or (not (OppositeAnchor[Side] in Anchors)) then // anchor all. Except for the opposite side.
Exclude(NewAnchors,OppositeAnchor[Side]); NewAnchors:=[akLeft,akTop,akRight,akBottom];
Anchors:=NewAnchors; if FreeCompositeSide or (not (OppositeAnchor[Side] in Anchors)) then
Exclude(NewAnchors,OppositeAnchor[Side]);
Anchors:=NewAnchors;
case Side of case Side of
akLeft: AnchorCompanionSides(akLeft,akRight,akTop,akBottom); akLeft: AnchorCompanionSides(akLeft,akRight,akTop,akBottom);
akRight: AnchorCompanionSides(akRight,akLeft,akTop,akBottom); akRight: AnchorCompanionSides(akRight,akLeft,akTop,akBottom);
akTop: AnchorCompanionSides(akTop,akBottom,akLeft,akRight); akTop: AnchorCompanionSides(akTop,akBottom,akLeft,akRight);
akBottom: AnchorCompanionSides(akBottom,akTop,akLeft,akRight); akBottom: AnchorCompanionSides(akBottom,akTop,akLeft,akRight);
end;
finally
if Parent<>nil then Parent.EnableAlign;
end; end;
end; end;
procedure TControl.AnchorSame(Side: TAnchorKind; Sibling: TControl); procedure TControl.AnchorSame(Side: TAnchorKind; Sibling: TControl);
begin begin
if Side in Sibling.Anchors then if Parent<>nil then Parent.DisableAlign;
Anchors:=Anchors+[Side] try
else if Side in Sibling.Anchors then
Anchors:=Anchors-[Side]; Anchors:=Anchors+[Side]
AnchorSide[Side].Assign(Sibling.AnchorSide[Side]); else
Anchors:=Anchors-[Side];
AnchorSide[Side].Assign(Sibling.AnchorSide[Side]);
finally
if Parent<>nil then Parent.EnableAlign;
end;
end; end;
procedure TControl.AnchorClient(Space: Integer); procedure TControl.AnchorAsAlign(TheAlign: TAlign; Space: Integer);
var
a: TAnchorKind;
begin begin
Parent.DisableAlign; Parent.DisableAlign;
try try
BorderSpacing.Left:=Space; if akLeft in AnchorAlign[TheAlign] then begin
BorderSpacing.Top:=Space; BorderSpacing.Left:=Space;
BorderSpacing.Right:=Space; AnchorSide[akLeft].Side:=asrLeft;
BorderSpacing.Bottom:=Space; AnchorSide[akLeft].Control:=Parent;
AnchorSide[akLeft].Side:=asrLeft; end;
AnchorSide[akTop].Side:=asrTop; if akTop in AnchorAlign[TheAlign] then begin
AnchorSide[akRight].Side:=asrRight; BorderSpacing.Top:=Space;
AnchorSide[akBottom].Side:=asrBottom; AnchorSide[akTop].Side:=asrTop;
for a:=Low(TAnchorKind) to High(TAnchorKind) do AnchorSide[akTop].Control:=Parent;
AnchorSide[a].Control:=Parent; end;
Anchors:=[akLeft,akTop,akRight,akBottom]; if akRight in AnchorAlign[TheAlign] then begin
BorderSpacing.Right:=Space;
AnchorSide[akRight].Side:=asrRight;
AnchorSide[akRight].Control:=Parent;
end;
if akBottom in AnchorAlign[TheAlign] then begin
BorderSpacing.Bottom:=Space;
AnchorSide[akBottom].Side:=asrBottom;
AnchorSide[akBottom].Control:=Parent;
end;
Anchors:=Anchors+AnchorAlign[TheAlign];
finally finally
Parent.EnableAlign; Parent.EnableAlign;
end; end;
end; end;
procedure TControl.AnchorClient(Space: Integer);
begin
AnchorAsAlign(alClient,Space);
end;
function TControl.AnchoredControlCount: integer; function TControl.AnchoredControlCount: integer;
begin begin
if fAnchoredControls=nil then if fAnchoredControls=nil then
@ -3791,7 +3833,7 @@ begin
if PreferredWidth<=0 then PreferredWidth:=Width; if PreferredWidth<=0 then PreferredWidth:=Width;
if PreferredHeight<=0 then PreferredHeight:=Height; if PreferredHeight<=0 then PreferredHeight:=Height;
// if this control is aligned adjust PreferredWidth and or PreferredHeight // if this control is aligned adjust PreferredWidth and/or PreferredHeight
if Parent<>nil then begin if Parent<>nil then begin
if AnchorAlign[Align]*[akLeft,akRight]=[akLeft,akRight] then begin if AnchorAlign[Align]*[akLeft,akRight]=[akLeft,akRight] then begin
// the control will be expanded to maximum width // the control will be expanded to maximum width

View File

@ -1832,7 +1832,7 @@ procedure TWinControl.DoAutoSize;
end; end;
var var
I : Integer; I: Integer;
AControl: TControl; AControl: TControl;
PreferredWidth: LongInt; PreferredWidth: LongInt;
PreferredHeight: LongInt; PreferredHeight: LongInt;
@ -1874,7 +1874,7 @@ begin
or HeightDependsOnParent; or HeightDependsOnParent;
// move childs tight to left and top (so no space left and above childs) // move childs tight to left and top (so no space left and above childs)
If (ControlCount > 0) then begin if (ControlCount > 0) then begin
// get current bounds of all childs // get current bounds of all childs
GetChildBounds(ChildBounds,true); GetChildBounds(ChildBounds,true);
CurClientRect:=ClientRect; CurClientRect:=ClientRect;
@ -1892,9 +1892,9 @@ begin
if (dx<>0) or (dy<>0) then begin if (dx<>0) or (dy<>0) then begin
// move all childs to left and top of client area // move all childs to left and top of client area
//DebugLn(['TWinControl.DoAutoSize ',DbgSName(Self),' ',dbgs(dx),' ',dbgs(dy),' ChildBounds=',dbgs(ChildBounds),' CurClientRect=',dbgs(CurClientRect),' ChildFixedSides=',dbgs(ChildsFixedSides),' CurAnchors=',dbgs(CurAnchors),' IsFixed: w=',WidthIsFixed,'h=',HeightIsFixed]); //DebugLn(['TWinControl.DoAutoSize ',DbgSName(Self),' ',dbgs(dx),' ',dbgs(dy),' ChildBounds=',dbgs(ChildBounds),' CurClientRect=',dbgs(CurClientRect),' ChildFixedSides=',dbgs(ChildsFixedSides),' CurAnchors=',dbgs(CurAnchors),' IsFixed: w=',WidthIsFixed,'h=',HeightIsFixed]);
For I := 0 to ControlCount - 1 do begin for I := 0 to ControlCount - 1 do begin
AControl:=Controls[I]; AControl:=Controls[I];
If AControl.IsControlVisible then begin if AControl.IsControlVisible then begin
//DebugLn(['TWinControl.DoAutoSize BEFORE ',DbgSName(AControl),' ',dbgs(AControl.BoundsRect)]); //DebugLn(['TWinControl.DoAutoSize BEFORE ',DbgSName(AControl),' ',dbgs(AControl.BoundsRect)]);
ChildAnchors:=FindChildFixatedSides(AControl); ChildAnchors:=FindChildFixatedSides(AControl);
NewChildBounds:=AControl.BoundsRect; NewChildBounds:=AControl.BoundsRect;
@ -1919,8 +1919,7 @@ begin
// autosize control to preferred size // autosize control to preferred size
if (not WidthIsFixed) or (not HeightIsFixed) then begin if (not WidthIsFixed) or (not HeightIsFixed) then begin
GetPreferredSize(PreferredWidth,PreferredHeight,false,false); GetPreferredSize(PreferredWidth,PreferredHeight,false,false);
//if ControlCount>0 then //if ControlCount>0 then DebugLn(['TWinControl.DoAutoSize ',DbgSName(Self),' PreferredWidth=',PreferredWidth,' PreferredHeight=',PreferredHeight,' ControlCount=',ControlCount]);
// DebugLn('TWinControl.DoAutoSize ',DbgSName(Self),' PreferredWidth=',dbgs(PreferredWidth),' PreferredHeight=',dbgs(PreferredHeight));
end else begin end else begin
PreferredWidth:=0; PreferredWidth:=0;
PreferredHeight:=0; PreferredHeight:=0;
@ -2050,7 +2049,7 @@ var r: TRect;
begin begin
r:=GetClientRect; r:=GetClientRect;
AdjustClientRect(r); AdjustClientRect(r);
//DebugLn(' TWinControl.DoAdjustClientRectChange ',Name,':',ClassName,' ',dbgs(r.Right),',',dbgs(r.Bottom)); //DebugLn(['TWinControl.DoAdjustClientRectChange ',DbgSName(Self),' ',r.Right,',',r.Bottom,' ',CompareRect(@r,@FAdjustClientRectRealized)]);
if not CompareRect(@r,@FAdjustClientRectRealized) then begin if not CompareRect(@r,@FAdjustClientRectRealized) then begin
// client rect changed since last AlignControl // client rect changed since last AlignControl
{$IFDEF VerboseClientRectBugFix} {$IFDEF VerboseClientRectBugFix}
@ -2061,6 +2060,7 @@ begin
FAdjustClientRectRealized:=r; FAdjustClientRectRealized:=r;
ReAlign; ReAlign;
Resize; Resize;
AdjustSize;
end; end;
end; end;
@ -2089,7 +2089,7 @@ var
I: Integer; I: Integer;
begin begin
{$IFDEF VerboseClientRectBugFix} {$IFDEF VerboseClientRectBugFix}
DebugLn('[TWinControl.InvalidateClientRectCache] ',Name,':',ClassName); DebugLn('[TWinControl.InvalidateClientRectCache] ',DbgSName(Self));
{$ENDIF} {$ENDIF}
Include(FWinControlFlags,wcfClientRectNeedsUpdate); Include(FWinControlFlags,wcfClientRectNeedsUpdate);

View File

@ -1131,7 +1131,7 @@ procedure TGtkWidgetSet.SendCachedGtkMessages;
UpdateLCLRect; UpdateLCLRect;
{$IFDEF VerboseSizeMsg} {$IFDEF VerboseSizeMsg}
DebugLn('JJJ2 ',LCLControl.Name, DebugLn('SendSizeNotificationToLCL ',DbgSName(LCLControl),
' GTK=',dbgs(GtkLeft)+','+dbgs(GtkTop)+','+dbgs(GtkWidth)+'x'+dbgs(GtkHeight), ' GTK=',dbgs(GtkLeft)+','+dbgs(GtkTop)+','+dbgs(GtkWidth)+'x'+dbgs(GtkHeight),
' LCL=',dbgs(LCLLeft)+','+dbgs(LCLTop)+','+dbgs(LCLWidth)+'x'+dbgs(LCLHeight) ' LCL=',dbgs(LCLLeft)+','+dbgs(LCLTop)+','+dbgs(LCLWidth)+'x'+dbgs(LCLHeight)
); );
@ -1162,7 +1162,7 @@ procedure TGtkWidgetSet.SendCachedGtkMessages;
// then send a LM_SIZE message // then send a LM_SIZE message
if WidthHeightChanged then begin if WidthHeightChanged then begin
{$IFDEF VerboseSizeMsg} {$IFDEF VerboseSizeMsg}
DebugLn('JJJ3 Send LM_SIZE To LCL ',LCLControl.Name,':',LCLControl.ClassName); DebugLn('Send LM_SIZE To LCL ',LCLControl.Name,':',LCLControl.ClassName);
{$ENDIF} {$ENDIF}
with SizeMsg do with SizeMsg do
begin begin
@ -1188,7 +1188,7 @@ procedure TGtkWidgetSet.SendCachedGtkMessages;
// then send a LM_MOVE message // then send a LM_MOVE message
if TopLeftChanged then begin if TopLeftChanged then begin
{$IFDEF VerboseSizeMsg} {$IFDEF VerboseSizeMsg}
DebugLn('JJJ4 Send LM_MOVE To LCL ',LCLControl.Name,':',LCLControl.ClassName); DebugLn('Send LM_MOVE To LCL ',LCLControl.Name,':',LCLControl.ClassName);
{$ENDIF} {$ENDIF}
with MoveMsg do with MoveMsg do
begin begin

View File

@ -6316,9 +6316,11 @@ begin
PreferredHeight:=Requisition.height; PreferredHeight:=Requisition.height;
if not WithThemeSpace then begin if not WithThemeSpace then begin
//DebugLn('GetGTKDefaultWidgetSize ',DbgSName(AWinControl),' ',dbgs(gtk_widget_get_xthickness(Widget)),' ythickness=',dbgs(gtk_widget_get_ythickness(Widget))); //DebugLn('GetGTKDefaultWidgetSize ',DbgSName(AWinControl),' ',dbgs(gtk_widget_get_xthickness(Widget)),' ythickness=',dbgs(gtk_widget_get_ythickness(Widget)));
//DebugLn(['GetGTKDefaultWidgetSize ',GetWidgetDebugReport(Widget)]);
//dec(PreferredWidth,gtk_widget_get_xthickness(Widget)); //dec(PreferredWidth,gtk_widget_get_xthickness(Widget));
{$IFDEF Gtk1} {$IFDEF Gtk1}
dec(PreferredHeight,2*gtk_widget_get_ythickness(Widget)); if not GtkWidgetIsA(Widget,GTK_ENTRY_TYPE) then
dec(PreferredHeight,2*gtk_widget_get_ythickness(Widget));
{$ENDIF} {$ENDIF}
end; end;
{DebugLn(['GetGTKDefaultWidgetSize Allocation=',Widget^.allocation.x,',',Widget^.allocation.y,',',Widget^.allocation.width,',',Widget^.allocation.height, {DebugLn(['GetGTKDefaultWidgetSize Allocation=',Widget^.allocation.x,',',Widget^.allocation.y,',',Widget^.allocation.width,',',Widget^.allocation.height,