From 79dcb7831b63d0ebd66c720643eeee51d7a23d4b Mon Sep 17 00:00:00 2001 From: juha Date: Thu, 19 Nov 2015 13:55:33 +0000 Subject: [PATCH] LCL: Bug fix for QT painting non-visual components for TFakeNonControl design form (TDataModule and TFrame). From Maciej. git-svn-id: trunk@50418 - --- components/ideintf/formeditingintf.pas | 15 +++++++++------ lcl/forms.pp | 13 +++++++++++++ lcl/interfaces/qt/qtwsforms.pp | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/components/ideintf/formeditingintf.pas b/components/ideintf/formeditingintf.pas index 87a432a716..ba5118cdf0 100644 --- a/components/ideintf/formeditingintf.pas +++ b/components/ideintf/formeditingintf.pas @@ -292,7 +292,6 @@ procedure SetDesignInfoLeft(AComponent: TComponent; const aLeft: SmallInt); inli procedure SetDesignInfoTop(AComponent: TComponent; const aTop: SmallInt); inline; function LeftTopToDesignInfo(const ALeft, ATop: SmallInt): LongInt; inline; procedure DesignInfoToLeftTop(ADesignInfo: LongInt; out ALeft, ATop: SmallInt); inline; -function IsFormDesign(AForm: TCustomForm): boolean; function LookupRoot(AForm: TCustomForm): TComponent; implementation @@ -386,13 +385,15 @@ begin ATop := LazLongRec(ADesignInfo).Hi; end; -function IsFormDesign(AForm: TCustomForm): boolean; +function IsFormDesignFunction(AForm: TWinControl): boolean; +var + LForm: TCustomForm absolute AForm; begin - if AForm = nil then + if (AForm = nil) or not (AForm is TCustomForm) then Exit(False); - Result := (csDesignInstance in AForm.ComponentState) - or ((csDesigning in AForm.ComponentState) and (AForm.Designer <> nil)) - or (AForm is TNonFormProxyDesignerForm); + Result := (csDesignInstance in LForm.ComponentState) + or ((csDesigning in LForm.ComponentState) and (LForm.Designer <> nil)) + or (LForm is TNonFormProxyDesignerForm); end; function LookupRoot(AForm: TCustomForm): TComponent; @@ -807,5 +808,7 @@ begin end; +initialization + IsFormDesign := @IsFormDesignFunction; end. diff --git a/lcl/forms.pp b/lcl/forms.pp index 5db3208ea6..abd578a9cd 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -1738,9 +1738,11 @@ procedure RestoreFocusState(FocusState: TFocusState); type TGetDesignerFormEvent = function(APersistent: TPersistent): TCustomForm of object; + TIsFormDesignFunction = function(AForm: TWinControl): boolean; var OnGetDesignerForm: TGetDesignerFormEvent = nil; + IsFormDesign: TIsFormDesignFunction = nil; function GetParentForm(Control: TControl; TopForm: Boolean = True): TCustomForm; function GetFirstParentForm(Control:TControl): TCustomForm; @@ -2114,6 +2116,16 @@ begin ImageList.Draw(Canvas,AX,AY,AIndex,ADrawEffect); end; +function IsFormDesignFunction(AForm: TWinControl): boolean; +var + LForm: TCustomForm absolute AForm; +begin + if (AForm = nil) or not (AForm is TCustomForm) then + Exit(False); + Result := (csDesignInstance in LForm.ComponentState) + or ((csDesigning in LForm.ComponentState) and (LForm.Designer <> nil)); +end; + initialization RegisterPropertyToSkip(TForm, 'OldCreateOrder', 'VCL compatibility property', ''); RegisterPropertyToSkip(TForm, 'TextHeight', 'VCL compatibility property', ''); @@ -2121,6 +2133,7 @@ initialization RegisterPropertyToSkip(TForm, 'TransparentColorValue', 'VCL compatibility property', ''); LCLProc.OwnerFormDesignerModifiedProc:=@IfOwnerIsFormThenDesignerModified; ThemesImageDrawEvent:=@ImageDrawEvent; + IsFormDesign := @IsFormDesignFunction; Screen:=TScreen.Create(nil); Application:=TApplication.Create(nil); diff --git a/lcl/interfaces/qt/qtwsforms.pp b/lcl/interfaces/qt/qtwsforms.pp index 6036e8c1e1..9902e49906 100644 --- a/lcl/interfaces/qt/qtwsforms.pp +++ b/lcl/interfaces/qt/qtwsforms.pp @@ -174,7 +174,7 @@ begin if (QtVersionMajor = 4) and (QtVersionMinor >= 6) then QCoreApplication_setAttribute(QtAA_ImmediateWidgetCreation, True); {$ENDIF} - if csDesigning in AWinControl.ComponentState then + if IsFormDesign(AWinControl) or (csDesigning in AWinControl.ComponentState) then QtMainWindow := TQtDesignWidget.Create(AWinControl, AParams) else QtMainWindow := TQtMainWindow.Create(AWinControl, AParams);