Qt5: Added QLCLOpenGLWidget. part of issue #36342

git-svn-id: trunk@62762 -
This commit is contained in:
zeljko 2020-03-13 13:59:24 +00:00
parent e4ea3046e3
commit 7d4574e050
2 changed files with 109 additions and 0 deletions

1
.gitattributes vendored
View File

@ -3979,6 +3979,7 @@ components/opengl/lazopenglcontext.pas svneol=native#text/plain
components/opengl/makeicon.bat svneol=native#text/plain
components/opengl/openglcontext.pas svneol=native#text/plain
components/opengl/openglcontext.res -text
components/opengl/qlclopenglwidget.pas svneol=native#text/plain
components/opengl/topenglcontrol.png -text svneol=unset#image/png
components/opengl/topenglcontrol_150.png -text svneol=unset#image/png
components/opengl/topenglcontrol_200.png -text svneol=unset#image/png

View File

@ -0,0 +1,108 @@
{
*****************************************************************************
See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
*****************************************************************************
Author: Željan Rikalo
}
unit qlclopenglwidget;
// this unit can be used only with Qt5 widgetset.
interface
uses
qt5, qtobjects, qtwidgets,
Classes, SysUtils, Types, Controls, LCLType;
type
QLCLOpenGLWidget_gl_Override = procedure of object cdecl;
function QLCLOpenGLWidget_Create(parent: QWidgetH = nil; f: QtWindowFlags = 0): QWidgetH; cdecl; external Qt5PasLib name 'QLCLOpenGLWidget_Create';
procedure QLCLOpenGLWidget_Destroy(handle: QWidgetH); cdecl; external Qt5PasLib name 'QLCLOpenGLWidget_Destroy';
procedure QLCLOpenGLWidget_override_paintGL(handle: QLCLOpenGLWidgetH; hook: QLCLOpenGLWidget_gl_Override); cdecl; external Qt5PasLib name 'QLCLOpenGLWidget_override_paintGL';
procedure QLCLOpenGLWidget_InheritedPaintGL(handle: QLCLOpenGLWidgetH); cdecl; external Qt5PasLib name 'QLCLOpenGLWidget_InheritedPaintGL';
type
{ TQtOpenGLWidget }
TQtOpenGLWidget = class(TQtWidget)
protected
function CreateWidget(const Params: TCreateParams):QWidgetH; override;
procedure paintGL(); cdecl; virtual;
public
function GetContainerWidget: QWidgetH; override;
procedure AttachEvents; override;
procedure DetachEvents; override;
procedure InitializeWidget; override;
procedure SlotPaintBg(Sender: QObjectH; Event: QEventH); cdecl; override;
procedure SlotPaint(Sender: QObjectH; Event: QEventH); cdecl; override;
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
end;
implementation
{ TQtOpenGLWidget }
function TQtOpenGLWidget.CreateWidget(const Params: TCreateParams): QWidgetH;
var
Parent: QWidgetH;
begin
if Params.WndParent <> 0 then
Parent := TQtWidget(Params.WndParent).GetContainerWidget
else
Parent := nil;
Widget := QLCLOpenGLWidget_Create(Parent);
Result := Widget;
end;
procedure TQtOpenGLWidget.paintGL(); cdecl;
begin
//writeln('TLCLOpenGLWidget.paintGL() ');
QLCLOpenGLWidget_InheritedPaintGL(QLCLOpenGLWidgetH(Widget));
end;
function TQtOpenGLWidget.GetContainerWidget: QWidgetH;
begin
Result := Widget;
end;
procedure TQtOpenGLWidget.AttachEvents;
begin
QLCLOpenGLWidget_override_paintGL(QLCLOpenGLWidgetH(Widget),
@paintGL);
inherited AttachEvents;
end;
procedure TQtOpenGLWidget.DetachEvents;
begin
inherited DetachEvents;
QLCLOpenGLWidget_override_paintGL(QLCLOpenGLWidgetH(Widget),
QLCLOpenGLWidget_gl_Override(NilMethod));
end;
procedure TQtOpenGLWidget.InitializeWidget;
begin
inherited InitializeWidget;
end;
procedure TQtOpenGLWidget.SlotPaintBg(Sender: QObjectH; Event: QEventH); cdecl;
begin
//
end;
procedure TQtOpenGLWidget.SlotPaint(Sender: QObjectH; Event: QEventH); cdecl;
begin
//
end;
function TQtOpenGLWidget.EventFilter(Sender: QObjectH; Event: QEventH
): Boolean; cdecl;
begin
Result := inherited EventFilter(Sender, Event);
end;
end.