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)';
lisLazarusLanguageName = 'Lazarus language name (e.g. english, deutsch)';
lisLCLWidgetType = 'LCL Widget Type';
lisCOVarious = '%s (various)';
lisTargetCPU = 'Target CPU';
lisTargetOS = 'Target OS';
lisCommandLineParamsOfProgram = 'Command line parameters of program';

View File

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

View File

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

View File

@ -1832,7 +1832,7 @@ procedure TWinControl.DoAutoSize;
end;
var
I : Integer;
I: Integer;
AControl: TControl;
PreferredWidth: LongInt;
PreferredHeight: LongInt;
@ -1874,7 +1874,7 @@ begin
or HeightDependsOnParent;
// 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
GetChildBounds(ChildBounds,true);
CurClientRect:=ClientRect;
@ -1892,9 +1892,9 @@ begin
if (dx<>0) or (dy<>0) then begin
// 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]);
For I := 0 to ControlCount - 1 do begin
for I := 0 to ControlCount - 1 do begin
AControl:=Controls[I];
If AControl.IsControlVisible then begin
if AControl.IsControlVisible then begin
//DebugLn(['TWinControl.DoAutoSize BEFORE ',DbgSName(AControl),' ',dbgs(AControl.BoundsRect)]);
ChildAnchors:=FindChildFixatedSides(AControl);
NewChildBounds:=AControl.BoundsRect;
@ -1919,8 +1919,7 @@ begin
// autosize control to preferred size
if (not WidthIsFixed) or (not HeightIsFixed) then begin
GetPreferredSize(PreferredWidth,PreferredHeight,false,false);
//if ControlCount>0 then
// DebugLn('TWinControl.DoAutoSize ',DbgSName(Self),' PreferredWidth=',dbgs(PreferredWidth),' PreferredHeight=',dbgs(PreferredHeight));
//if ControlCount>0 then DebugLn(['TWinControl.DoAutoSize ',DbgSName(Self),' PreferredWidth=',PreferredWidth,' PreferredHeight=',PreferredHeight,' ControlCount=',ControlCount]);
end else begin
PreferredWidth:=0;
PreferredHeight:=0;
@ -2050,7 +2049,7 @@ var r: TRect;
begin
r:=GetClientRect;
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
// client rect changed since last AlignControl
{$IFDEF VerboseClientRectBugFix}
@ -2061,6 +2060,7 @@ begin
FAdjustClientRectRealized:=r;
ReAlign;
Resize;
AdjustSize;
end;
end;
@ -2089,7 +2089,7 @@ var
I: Integer;
begin
{$IFDEF VerboseClientRectBugFix}
DebugLn('[TWinControl.InvalidateClientRectCache] ',Name,':',ClassName);
DebugLn('[TWinControl.InvalidateClientRectCache] ',DbgSName(Self));
{$ENDIF}
Include(FWinControlFlags,wcfClientRectNeedsUpdate);

View File

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

View File

@ -6316,9 +6316,11 @@ begin
PreferredHeight:=Requisition.height;
if not WithThemeSpace then begin
//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));
{$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}
end;
{DebugLn(['GetGTKDefaultWidgetSize Allocation=',Widget^.allocation.x,',',Widget^.allocation.y,',',Widget^.allocation.width,',',Widget^.allocation.height,