Qt: fixed preffered size of autosized groupboxes. issue #23351

git-svn-id: trunk@39892 -
This commit is contained in:
zeljko 2013-01-19 16:29:30 +00:00
parent 3e31ff5eeb
commit 60db6ec323

View File

@ -712,6 +712,8 @@ type
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override; function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
function getClientBounds: TRect; override; function getClientBounds: TRect; override;
function getText: WideString; override; function getText: WideString; override;
procedure preferredSize(var PreferredWidth, PreferredHeight: integer;
WithThemeSpace: Boolean); override;
procedure setText(const W: WideString); override; procedure setText(const W: WideString); override;
procedure setFocusPolicy(const APolicy: QtFocusPolicy); override; procedure setFocusPolicy(const APolicy: QtFocusPolicy); override;
property GroupBoxType: TQtGroupBoxType read FGroupBoxType write FGroupBoxType; property GroupBoxType: TQtGroupBoxType read FGroupBoxType write FGroupBoxType;
@ -6821,7 +6823,6 @@ var
begin begin
if ALayout = nil then if ALayout = nil then
exit; exit;
QWidget_getContentsMargins(AWidget,@LeftMargin, @TopMargin, @RightMargin, @BottomMargin); QWidget_getContentsMargins(AWidget,@LeftMargin, @TopMargin, @RightMargin, @BottomMargin);
{if contentsMargins TopMargin is huge then we must rethink about TopMargin {if contentsMargins TopMargin is huge then we must rethink about TopMargin
@ -6892,8 +6893,8 @@ begin
inherited AttachEvents; inherited AttachEvents;
if FCentralWidget <> nil then if FCentralWidget <> nil then
begin begin
FCWEventHook := QObject_hook_create(FCentralWidget); // FCWEventHook := QObject_hook_create(FCentralWidget);
QObject_hook_hook_events(FCWEventHook, @EventFilter); // QObject_hook_hook_events(FCWEventHook, @EventFilter);
end; end;
end; end;
@ -6901,8 +6902,8 @@ procedure TQtGroupBox.DetachEvents;
begin begin
if FCWEventHook <> nil then if FCWEventHook <> nil then
begin begin
QObject_hook_destroy(FCWEventHook); // QObject_hook_destroy(FCWEventHook);
FCWEventHook := nil; // FCWEventHook := nil;
end; end;
inherited DetachEvents; inherited DetachEvents;
end; end;
@ -6927,9 +6928,6 @@ begin
if (Sender = FCentralWidget) then if (Sender = FCentralWidget) then
begin begin
if (QEvent_type(Event) = QEventResize) and
LCLObject.ClientRectNeedsInterfaceUpdate then
LCLObject.InvalidateClientRectCache(False);
exit; exit;
end; end;
@ -6973,6 +6971,36 @@ begin
QGroupBox_title(QGroupBoxH(Widget), @Result); QGroupBox_title(QGroupBoxH(Widget), @Result);
end; end;
procedure TQtGroupBox.preferredSize(var PreferredWidth,
PreferredHeight: integer; WithThemeSpace: Boolean);
var
L: Integer;
T: Integer;
R: Integer;
B: Integer;
PH: Integer;
ASize: TSize;
R1: TRect;
begin
QWidget_getContentsMargins(Widget,@L, @T, @R, @B);
QWidget_sizeHint(Widget, @ASize);
PreferredWidth := ASize.cx + L + R;
PreferredHeight := ASize.cy + B + T;
if LCLObject.AutoSize and Assigned(FCentralWidget) and Assigned(LCLObject) then
begin
L := 0;
PH := 0;
for L := 0 to LCLObject.ControlCount - 1 do
begin
R1 := LCLObject.Controls[L].BoundsRect;
if PH < (R1.Top + (R1.Bottom - R1.Top) + T + B) then
PH := R1.Top + (R1.Bottom - R1.Top) + T + B;
end;
if PH > 0 then
PreferredHeight := PH;
end;
end;
procedure TQtGroupBox.setText(const W: WideString); procedure TQtGroupBox.setText(const W: WideString);
begin begin
QGroupBox_setTitle(QGroupBoxH(Widget), @W); QGroupBox_setTitle(QGroupBoxH(Widget), @W);
@ -7194,8 +7222,9 @@ begin
{$ifdef VerboseQt} {$ifdef VerboseQt}
writeln('TQtAbstractSlider.rangeChanged() to min=',minimum,' max=',maximum); writeln('TQtAbstractSlider.rangeChanged() to min=',minimum,' max=',maximum);
{$endif} {$endif}
if (FOwner <> nil) and if (FOwner <> nil) and Assigned(FOwner.LCLObject) and
(FOwner.FChildOfComplexWidget = ccwScrollingWinControl) then (FOwner.FChildOfComplexWidget = ccwScrollingWinControl) and
not (caspComputingBounds in FOwner.LCLObject.AutoSizePhases) then
LCLObject.InvalidateClientRectCache(True); LCLObject.InvalidateClientRectCache(True);
end; end;