* Fix MDIChilds due to LayoutWidget & CentralWidget commits.

git-svn-id: trunk@11513 -
This commit is contained in:
zeljko 2007-07-15 12:27:25 +00:00
parent 2725083a1f
commit 91a249f4e0
2 changed files with 34 additions and 14 deletions

View File

@ -1004,9 +1004,9 @@ begin
QEventHide: SlotShow(False);
QEventClose:
begin
Result:=True;
QEvent_ignore(Event);
SlotClose;
Result := True;
QEvent_ignore(Event);
SlotClose;
end;
QEventDestroy: SlotDestroy;
QEventFocusIn: SlotFocus(True);
@ -2185,9 +2185,6 @@ end;
function TQtMainWindow.CreateWidget(const AParams: TCreateParams): QWidgetH;
var
w: QWidgetH;
{$ifdef USE_QT_4_3}
mdihandle: QMdiAreaH;
{$endif}
begin
// Creates the widget
{$ifdef VerboseQt}
@ -2241,11 +2238,18 @@ begin
{$ifdef USE_QT_4_3}
if (LCLObject is TCustomForm) and (TCustomForm(LCLObject).FormStyle = fsMDIChild) then
begin
Result := QMdiSubWindow_create(niL, QtWindow);
mdiHandle := TQtMainWindow(Application.MainForm.Handle).MDIAreaHandle;
if Assigned(mdiHandle) then
QMdiArea_addSubWindow(mdiHandle, QMdiSubWindowH(Result), QtWindow);
if TQtMainWindow(Application.MainForm.Handle).MDIAreaHandle = nil
then
raise Exception.Create('MDIChild can be added to MDIForm only !');
Result := QMdiSubWindow_create(nil, QtWindow);
// QMdiSubWindow already have an layout
LayoutWidget := QBoxLayoutH(QWidget_layout(Result));
if LayoutWidget <> nil
then
QBoxLayout_destroy(LayoutWidget);
end
else
Result := QWidget_create(nil, QtWindow);

View File

@ -35,7 +35,7 @@ uses
{$endif}
qtwidgets,
// LCL
SysUtils, Controls, LCLType, Forms,
SysUtils, Classes, Controls, LCLType, Forms,
// Widgetset
InterfaceBase, WSForms, WSLCLClasses;
@ -144,6 +144,7 @@ class function TQtWSCustomForm.CreateHandle(const AWinControl: TWinControl;
var
QtMainWindow: TQtMainWindow;
Str: WideString;
R: TRect;
begin
{$ifdef VerboseQt}
WriteLn('[TQtWSCustomForm.CreateHandle] Height: ', IntToStr(AWinControl.Height),
@ -154,7 +155,8 @@ begin
QtMainWindow := TQtMainWindow.Create(AWinControl, AParams);
if (TCustomForm(AWinControl).ShowInTaskBar in [stDefault, stNever]) and
if (TCustomForm(AWinControl).ShowInTaskBar in [stDefault, stNever]) and not
(TCustomForm(AWinControl).FormStyle in [fsMDIChild]) and
(Application <> nil) and
(Application.MainForm <> nil) and
(Application.MainForm.HandleAllocated) and
@ -173,6 +175,20 @@ begin
// Sets Various Events
QtMainWindow.AttachEvents;
{$ifdef USE_QT_4_3}
if (TCustomForm(AWinControl).FormStyle in [fsMDIChild])
and (Application.MainForm.FormStyle = fsMdiForm)
then
begin
QWidget_geometry(QtMainWindow.MenuBar.Widget, @R);
QMdiArea_addSubWindow(TQtMainWindow(Application.MainForm.Handle).MDIAreaHandle, QtMainWindow.Widget, QtWindow);
AWinControl.Height := AWinControl.Height + R.Bottom;
{TODO: Show MDIChild Left&Top +10 of last created mdi child}
AWinControl.Left := 0;
AWinControl.Top := 0;
end;
{$endif}
// Return the handle
Result := THandle(QtMainWindow);
@ -286,7 +302,7 @@ end;
------------------------------------------------------------------------------}
class procedure TQtWSCustomForm.ShowModal(const ACustomForm: TCustomForm);
begin
{TODO: fix cpu burning , we need an sleep(0) in LCL modal loop}
end;
{------------------------------------------------------------------------------