mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 14:20:02 +02:00
Qt: implemented scrollbars on forms (scrollable forms).Currently it works only if QTSCROLLABLEFORMS define is enabled in qtdefines.inc. issue #24715
git-svn-id: trunk@43218 -
This commit is contained in:
parent
b1dfaeda44
commit
50760cf759
@ -5,4 +5,5 @@
|
|||||||
{$IF DEFINED(LINUX) or DEFINED(FREEBSD) or DEFINED(NETBSD)}
|
{$IF DEFINED(LINUX) or DEFINED(FREEBSD) or DEFINED(NETBSD)}
|
||||||
{$DEFINE HASX11}
|
{$DEFINE HASX11}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
{. $DEFINE QTSCROLLABLEFORMS}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
@ -49,6 +49,7 @@ type
|
|||||||
ccwAbstractScrollArea,
|
ccwAbstractScrollArea,
|
||||||
ccwCustomControl,
|
ccwCustomControl,
|
||||||
ccwScrollingWinControl,
|
ccwScrollingWinControl,
|
||||||
|
ccwScrollingWindow,
|
||||||
ccwTabWidget,
|
ccwTabWidget,
|
||||||
ccwTTabControl);
|
ccwTTabControl);
|
||||||
|
|
||||||
@ -585,6 +586,26 @@ type
|
|||||||
procedure ActivateSubWindow(AMdiWindow: QMdiSubWindowH);
|
procedure ActivateSubWindow(AMdiWindow: QMdiSubWindowH);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
{ TQtWindowArea }
|
||||||
|
|
||||||
|
{Scrollbars on qt forms}
|
||||||
|
TQtWindowArea = class(TQtAbstractScrollArea)
|
||||||
|
private
|
||||||
|
FViewPortEventHook: QObject_hookH;
|
||||||
|
public
|
||||||
|
procedure AttachEvents; override;
|
||||||
|
function CanAdjustClientRectOnResize: Boolean; override;
|
||||||
|
procedure DetachEvents; override;
|
||||||
|
function MapToGlobal(APt: TPoint; const AWithScrollOffset: Boolean = False): TPoint; override;
|
||||||
|
procedure scroll(dx, dy: integer; ARect: PRect = nil); override;
|
||||||
|
{abstractscrollarea events}
|
||||||
|
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
|
||||||
|
{viewport events}
|
||||||
|
function ScrollViewEventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
TQtMainWindow = class(TQtWidget)
|
TQtMainWindow = class(TQtWidget)
|
||||||
private
|
private
|
||||||
FBlocked: Boolean;
|
FBlocked: Boolean;
|
||||||
@ -606,11 +627,23 @@ type
|
|||||||
MDIChildArea: TQtMDIArea; // valid only if we are fsMDIChild
|
MDIChildArea: TQtMDIArea; // valid only if we are fsMDIChild
|
||||||
MenuBar: TQtMenuBar;
|
MenuBar: TQtMenuBar;
|
||||||
ToolBar: TQtToolBar;
|
ToolBar: TQtToolBar;
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
ScrollArea: TQtWindowArea;
|
||||||
|
{$ENDIF}
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Activate; override;
|
procedure Activate; override;
|
||||||
|
function CanAdjustClientRectOnResize: Boolean; override;
|
||||||
function getAcceptDropFiles: Boolean; override;
|
function getAcceptDropFiles: Boolean; override;
|
||||||
|
function GetContainerWidget: QWidgetH; override;
|
||||||
|
procedure grabMouse; override;
|
||||||
|
function getClientOffset: TPoint; override;
|
||||||
|
function getClientBounds: TRect; override;
|
||||||
|
|
||||||
function getText: WideString; override;
|
function getText: WideString; override;
|
||||||
function getTextStatic: Boolean; override;
|
function getTextStatic: Boolean; override;
|
||||||
|
|
||||||
|
function MapToGlobal(APt: TPoint; const AWithScrollOffset: Boolean = False): TPoint; override;
|
||||||
|
|
||||||
procedure Resize(ANewWidth, ANewHeight: Integer); override;
|
procedure Resize(ANewWidth, ANewHeight: Integer); override;
|
||||||
procedure setText(const W: WideString); override;
|
procedure setText(const W: WideString); override;
|
||||||
procedure setMenuBar(AMenuBar: QMenuBarH);
|
procedure setMenuBar(AMenuBar: QMenuBarH);
|
||||||
@ -621,6 +654,7 @@ type
|
|||||||
function MdiChildCount: integer;
|
function MdiChildCount: integer;
|
||||||
procedure OffsetMousePos(APoint: PQtPoint); override;
|
procedure OffsetMousePos(APoint: PQtPoint); override;
|
||||||
procedure setAcceptDropFiles(AValue: Boolean);
|
procedure setAcceptDropFiles(AValue: Boolean);
|
||||||
|
procedure setFocusPolicy(const APolicy: QtFocusPolicy); override;
|
||||||
procedure SlotActivateWindow(vActivate: Boolean); cdecl;
|
procedure SlotActivateWindow(vActivate: Boolean); cdecl;
|
||||||
procedure slotWindowStateChange; cdecl;
|
procedure slotWindowStateChange; cdecl;
|
||||||
procedure setShowInTaskBar(AValue: Boolean);
|
procedure setShowInTaskBar(AValue: Boolean);
|
||||||
@ -5938,10 +5972,172 @@ begin
|
|||||||
QMdiArea_setActiveSubWindow(QMdiAreaH(Widget), AMdiWindow);
|
QMdiArea_setActiveSubWindow(QMdiAreaH(Widget), AMdiWindow);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
|
||||||
|
{ TQtWindowArea }
|
||||||
|
|
||||||
|
procedure TQtWindowArea.AttachEvents;
|
||||||
|
begin
|
||||||
|
inherited AttachEvents;
|
||||||
|
FViewPortEventHook := QObject_hook_create(viewportWidget);
|
||||||
|
QObject_hook_hook_events(FViewPortEventHook, @ScrollViewEventFilter);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtWindowArea.CanAdjustClientRectOnResize: Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtWindowArea.DetachEvents;
|
||||||
|
begin
|
||||||
|
if Assigned(FViewPortEventHook) then
|
||||||
|
begin
|
||||||
|
QObject_hook_destroy(FViewPortEventHook);
|
||||||
|
FViewPortEventHook := nil;
|
||||||
|
end;
|
||||||
|
inherited DetachEvents;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtWindowArea.MapToGlobal(APt: TPoint; const AWithScrollOffset: Boolean
|
||||||
|
): TPoint;
|
||||||
|
var
|
||||||
|
Pt: TPoint;
|
||||||
|
begin
|
||||||
|
Result := inherited MapToGlobal(APt);
|
||||||
|
if AWithScrollOffset then
|
||||||
|
begin
|
||||||
|
Pt := ScrolledOffset;
|
||||||
|
dec(Result.X, Pt.X);
|
||||||
|
dec(Result.Y, Pt.Y);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtWindowArea.scroll(dx, dy: integer; ARect: PRect);
|
||||||
|
begin
|
||||||
|
inherited scroll(dx, dy, ARect);
|
||||||
|
FScrollX := FScrollX + dx;
|
||||||
|
FScrollY := FScrollY + dy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtWindowArea.EventFilter(Sender: QObjectH; Event: QEventH): Boolean;
|
||||||
|
cdecl;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
if (LCLObject = nil) then
|
||||||
|
exit;
|
||||||
|
if (QEvent_Type(Event) in [QEventMouseButtonPress, QEventMouseButtonRelease, QEventMouseButtonDblClick,
|
||||||
|
QEventMouseMove, QEventWheel, QEventPaint, QEventHoverEnter, QEventHoverMove,
|
||||||
|
QEventHoverLeave, QEventResize]) then
|
||||||
|
exit;
|
||||||
|
Result := inherited EventFilter(Sender, Event);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtWindowArea.ScrollViewEventFilter(Sender: QObjectH; Event: QEventH
|
||||||
|
): Boolean; cdecl;
|
||||||
|
var
|
||||||
|
HaveVertBar, HaveHorzBar: Boolean;
|
||||||
|
ScrollBar: QScrollBarH;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
if LCLObject = nil then
|
||||||
|
exit;
|
||||||
|
BeginEventProcessing;
|
||||||
|
if (QEvent_Type(Event) in [QEventMouseButtonPress, QEventMouseButtonRelease, QEventMouseButtonDblClick,
|
||||||
|
QEventMouseMove, QEventWheel, QEventPaint, QEventHoverEnter, QEventHoverMove,
|
||||||
|
QEventHoverLeave]) then
|
||||||
|
begin
|
||||||
|
Result := inherited EventFilter(Sender, Event);
|
||||||
|
end else
|
||||||
|
case QEvent_type(Event) of
|
||||||
|
QEventResize:
|
||||||
|
begin
|
||||||
|
// immediate update clientRect !
|
||||||
|
if FOwner <> nil then
|
||||||
|
begin
|
||||||
|
HaveVertBar := Assigned(FVScrollbar);
|
||||||
|
HaveHorzBar := Assigned(FHScrollbar);
|
||||||
|
if (caspComputingBounds in LCLObject.AutoSizePhases) then
|
||||||
|
{$IF DEFINED(VerboseQt) OR DEFINED(VerboseQtCustomControlResizeDeadlock)}
|
||||||
|
writeln('*** INTERCEPTED RESIZE DEADLOCK *** ',LCLObject.ClassName,
|
||||||
|
':',LCLObject.Name)
|
||||||
|
{$ENDIF}
|
||||||
|
else
|
||||||
|
LCLObject.DoAdjustClientRectChange(HaveVertBar or HaveHorzBar);
|
||||||
|
end else
|
||||||
|
LCLObject.DoAdjustClientRectChange;
|
||||||
|
end;
|
||||||
|
QEventWheel:
|
||||||
|
if not getEnabled then
|
||||||
|
inherited EventFilter(Sender, Event)
|
||||||
|
else
|
||||||
|
if (QtVersionMajor = 4) and (QtVersionMinor < 7) then
|
||||||
|
begin
|
||||||
|
Result := SlotMouseWheel(Sender, Event);
|
||||||
|
if not Result then
|
||||||
|
case QWheelEvent_orientation(QWheelEventH(Event)) of
|
||||||
|
QtVertical:
|
||||||
|
begin
|
||||||
|
if verticalScrollBar.getVisible then
|
||||||
|
begin
|
||||||
|
ScrollBar := QScrollBarH(verticalScrollBar.Widget);
|
||||||
|
QScrollBar_event(ScrollBar, Event);
|
||||||
|
end else
|
||||||
|
Result := inherited EventFilter(Sender, Event);
|
||||||
|
end;
|
||||||
|
QtHorizontal:
|
||||||
|
begin
|
||||||
|
if horizontalScrollBar.getVisible then
|
||||||
|
begin
|
||||||
|
ScrollBar := QScrollBarH(horizontalScrollBar.Widget);
|
||||||
|
QScrollBar_event(ScrollBar, Event);
|
||||||
|
end else
|
||||||
|
Result := inherited EventFilter(Sender, Event);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Result := True;
|
||||||
|
QEvent_ignore(Event);
|
||||||
|
end;
|
||||||
|
|
||||||
|
QEventLayoutRequest:
|
||||||
|
begin
|
||||||
|
with TQtMainWindow(FOwner) do
|
||||||
|
begin
|
||||||
|
if Self.LCLObject.ClientRectNeedsInterfaceUpdate then
|
||||||
|
Self.LCLObject.DoAdjustClientRectChange(True);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
EndEventProcessing;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
|
||||||
{ TQtMainWindow }
|
{ TQtMainWindow }
|
||||||
|
|
||||||
function TQtMainWindow.CreateWidget(const AParams: TCreateParams): QWidgetH;
|
function TQtMainWindow.CreateWidget(const AParams: TCreateParams): QWidgetH;
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
procedure SetScrollAreaRules;
|
||||||
|
begin
|
||||||
|
FCentralWidget := ScrollArea.Widget;
|
||||||
|
ScrollArea.ChildOfComplexWidget := ccwAbstractScrollArea;
|
||||||
|
ScrollArea.LCLObject := LCLObject;
|
||||||
|
|
||||||
|
QFrame_setFrameShape(QAbstractScrollAreaH(ScrollArea.Widget), QFrameNoFrame);
|
||||||
|
QWidget_setBackgroundRole(ScrollArea.viewportWidget, QPaletteNoRole);
|
||||||
|
QWidget_setAutoFillBackground(ScrollArea.viewportWidget, False);
|
||||||
|
|
||||||
|
// we must set minimum heigth / width to 1 otherwise we'll have strange
|
||||||
|
// effect eg. with main ide bar window (small size and cannot resize).
|
||||||
|
QWidget_setMinimumHeight(FCentralWidget, 1);
|
||||||
|
QWidget_setMinimumWidth(FCentralWidget, 1);
|
||||||
|
|
||||||
|
ScrollArea.setScrollBarPolicy(True, QtScrollBarAlwaysOff);
|
||||||
|
ScrollArea.setScrollBarPolicy(False, QtScrollBarAlwaysOff);
|
||||||
|
ScrollArea.HasPaint := True;
|
||||||
|
ScrollArea.FOwner := Self;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
var
|
var
|
||||||
p: QPaletteH;
|
p: QPaletteH;
|
||||||
begin
|
begin
|
||||||
@ -5959,6 +6155,9 @@ begin
|
|||||||
MDIAreaHandle := nil;
|
MDIAreaHandle := nil;
|
||||||
MDIChildArea := nil;
|
MDIChildArea := nil;
|
||||||
FMDIStateHook := nil;
|
FMDIStateHook := nil;
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
ScrollArea := nil;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
IsMainForm := (LCLObject <> nil) and (LCLObject = Application.MainForm);
|
IsMainForm := (LCLObject <> nil) and (LCLObject = Application.MainForm);
|
||||||
|
|
||||||
@ -5993,7 +6192,12 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
ScrollArea := TQtWindowArea.CreateFrom(LCLObject, QAbstractScrollArea_create(Result));
|
||||||
|
SetScrollAreaRules;
|
||||||
|
{$ELSE}
|
||||||
FCentralWidget := QWidget_create(Result);
|
FCentralWidget := QWidget_create(Result);
|
||||||
|
{$ENDIF}
|
||||||
MDIAreaHandle := nil;
|
MDIAreaHandle := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -6043,7 +6247,17 @@ begin
|
|||||||
MenuBar.setProperty(MenuBar.Widget,'lcldesignmenubar',1);
|
MenuBar.setProperty(MenuBar.Widget,'lcldesignmenubar',1);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if QWidget_windowType(Result) = QtSplashScreen then
|
||||||
|
FCentralWidget := QWidget_create(Result)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
ScrollArea := TQtWindowArea.CreateFrom(LCLObject, QAbstractScrollArea_create(Result));
|
||||||
|
SetScrollAreaRules;
|
||||||
|
end;
|
||||||
|
{$ELSE}
|
||||||
FCentralWidget := QWidget_create(Result);
|
FCentralWidget := QWidget_create(Result);
|
||||||
|
{$ENDIF}
|
||||||
QWidget_setMouseTracking(FCentralWidget, True);
|
QWidget_setMouseTracking(FCentralWidget, True);
|
||||||
|
|
||||||
LayoutWidget := QBoxLayout_create(QBoxLayoutTopToBottom, Result);
|
LayoutWidget := QBoxLayout_create(QBoxLayoutTopToBottom, Result);
|
||||||
@ -6127,6 +6341,16 @@ begin
|
|||||||
MDIAreaHandle.Widget := nil;
|
MDIAreaHandle.Widget := nil;
|
||||||
FreeThenNil(MDIAreaHandle);
|
FreeThenNil(MDIAreaHandle);
|
||||||
end;
|
end;
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if QtWidgetSet.IsValidHandle(HWND(ScrollArea)) then
|
||||||
|
begin
|
||||||
|
ScrollArea.DetachEvents;
|
||||||
|
if FOwnWidget and (ScrollArea.Widget <> nil) then
|
||||||
|
QWidget_destroy(ScrollArea.Widget);
|
||||||
|
ScrollArea.Widget := nil;
|
||||||
|
FreeAndNil(ScrollArea);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
@ -6155,11 +6379,73 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TQtMainWindow.CanAdjustClientRectOnResize: Boolean;
|
||||||
|
begin
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
Result := not Assigned(ScrollArea);
|
||||||
|
{$ELSE}
|
||||||
|
Result:=inherited CanAdjustClientRectOnResize;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
function TQtMainWindow.getAcceptDropFiles: Boolean;
|
function TQtMainWindow.getAcceptDropFiles: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := QWidget_acceptDrops(Widget);
|
Result := QWidget_acceptDrops(Widget);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TQtMainWindow.GetContainerWidget: QWidgetH;
|
||||||
|
begin
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if not Assigned(ScrollArea) or (QWidget_windowType(Widget) = QtToolTip) or
|
||||||
|
(QWidget_windowType(Widget) = QtSplashScreen) or
|
||||||
|
(TCustomForm(LCLObject).FormStyle = fsMdiForm) then
|
||||||
|
Result := inherited GetContainerWidget
|
||||||
|
else
|
||||||
|
Result := ScrollArea.GetContainerWidget;
|
||||||
|
{$ELSE}
|
||||||
|
Result := inherited GetContainerWidget;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtMainWindow.grabMouse;
|
||||||
|
begin
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if not Assigned(ScrollArea) then
|
||||||
|
inherited grabMouse
|
||||||
|
else
|
||||||
|
ScrollArea.grabMouse;
|
||||||
|
{$ELSE}
|
||||||
|
inherited grabMouse;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtMainWindow.getClientOffset: TPoint;
|
||||||
|
begin
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if Assigned(ScrollArea) then
|
||||||
|
Result := ScrollArea.getClientOffset
|
||||||
|
else
|
||||||
|
Result := inherited getClientOffset;
|
||||||
|
if Assigned(ScrollArea) and Assigned(MenuBar) and
|
||||||
|
(MenuBar.getVisible) then
|
||||||
|
inc(Result.Y, MenuBar.getHeight);
|
||||||
|
{$ELSE}
|
||||||
|
Result:=inherited getClientOffset;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtMainWindow.getClientBounds: TRect;
|
||||||
|
begin
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if Assigned(ScrollArea) then
|
||||||
|
Result := ScrollArea.getClientBounds
|
||||||
|
else
|
||||||
|
Result := inherited getClientBounds;
|
||||||
|
{$ELSE}
|
||||||
|
Result:=inherited getClientBounds;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
function TQtMainWindow.getText: WideString;
|
function TQtMainWindow.getText: WideString;
|
||||||
begin
|
begin
|
||||||
WindowTitle(@Result);
|
WindowTitle(@Result);
|
||||||
@ -6170,6 +6456,19 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TQtMainWindow.MapToGlobal(APt: TPoint; const AWithScrollOffset: Boolean
|
||||||
|
): TPoint;
|
||||||
|
begin
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if Assigned(ScrollArea) then
|
||||||
|
Result := ScrollArea.MapToGlobal(APt, AWithScrollOffset)
|
||||||
|
else
|
||||||
|
Result := inherited MapToGlobal(APt, AWithScrollOffset);
|
||||||
|
{$ELSE}
|
||||||
|
Result := inherited MapToGlobal(APt, AWithScrollOffset);
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TQtMainWindow.Resize(ANewWidth, ANewHeight: Integer);
|
procedure TQtMainWindow.Resize(ANewWidth, ANewHeight: Integer);
|
||||||
begin
|
begin
|
||||||
if not IsMDIChild and
|
if not IsMDIChild and
|
||||||
@ -6229,6 +6528,16 @@ begin
|
|||||||
' Event=', EventTypeToStr(Event),' inUpdate=',inUpdate);
|
' Event=', EventTypeToStr(Event),' inUpdate=',inUpdate);
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if Assigned(ScrollArea) and not IsMDIChild then
|
||||||
|
begin
|
||||||
|
if QEvent_type(Event) in [QEventMouseButtonPress, QEventMouseButtonRelease,
|
||||||
|
QEventMouseButtonDblClick, QEventPaint,
|
||||||
|
QEventContextMenu] then
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
BeginEventProcessing;
|
BeginEventProcessing;
|
||||||
case QEvent_type(Event) of
|
case QEvent_type(Event) of
|
||||||
QEventMouseButtonPress,
|
QEventMouseButtonPress,
|
||||||
@ -6474,6 +6783,18 @@ begin
|
|||||||
QWidget_setAcceptDrops(Widget, AValue);
|
QWidget_setAcceptDrops(Widget, AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TQtMainWindow.setFocusPolicy(const APolicy: QtFocusPolicy);
|
||||||
|
begin
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if Assigned(ScrollArea) then
|
||||||
|
ScrollArea.setFocusPolicy(APolicy)
|
||||||
|
else
|
||||||
|
inherited setFocusPolicy(APolicy);
|
||||||
|
{$ELSE}
|
||||||
|
inherited setFocusPolicy(APolicy);
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TQtMainWindow.SlotActivateWindow(vActivate: Boolean); cdecl;
|
procedure TQtMainWindow.SlotActivateWindow(vActivate: Boolean); cdecl;
|
||||||
var
|
var
|
||||||
Msg: TLMActivate;
|
Msg: TLMActivate;
|
||||||
@ -6507,7 +6828,7 @@ end;
|
|||||||
Params: None
|
Params: None
|
||||||
Returns: Nothing
|
Returns: Nothing
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TQtMainWindow.SlotWindowStateChange; cdecl;
|
procedure TQtMainWindow.slotWindowStateChange; cdecl;
|
||||||
var
|
var
|
||||||
Msg: TLMSize;
|
Msg: TLMSize;
|
||||||
begin
|
begin
|
||||||
@ -6556,8 +6877,11 @@ end;
|
|||||||
procedure TQtMainWindow.AttachEvents;
|
procedure TQtMainWindow.AttachEvents;
|
||||||
begin
|
begin
|
||||||
inherited AttachEvents;
|
inherited AttachEvents;
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
if FCentralWidget <> nil then
|
FCWEventHook := nil;
|
||||||
|
{$ENDIF}
|
||||||
|
if (FCentralWidget <> nil)
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS} and not Assigned(ScrollArea){$ENDIF} then
|
||||||
begin
|
begin
|
||||||
FCWEventHook := QObject_hook_create(FCentralWidget);
|
FCWEventHook := QObject_hook_create(FCentralWidget);
|
||||||
QObject_hook_hook_events(FCWEventHook, @CWEventFilter);
|
QObject_hook_hook_events(FCWEventHook, @CWEventFilter);
|
||||||
@ -7277,6 +7601,13 @@ begin
|
|||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
writeln('TQtAbstractSlider.rangeChanged() to min=',minimum,' max=',maximum);
|
writeln('TQtAbstractSlider.rangeChanged() to min=',minimum,' max=',maximum);
|
||||||
{$endif}
|
{$endif}
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if (FOwner <> nil) and Assigned(FOwner.LCLObject) and
|
||||||
|
(FOwner is TQtWindowArea) and
|
||||||
|
not (caspComputingBounds in FOwner.LCLObject.AutoSizePhases) then
|
||||||
|
LCLObject.InvalidateClientRectCache(True)
|
||||||
|
else
|
||||||
|
{$ENDIF}
|
||||||
if (FOwner <> nil) and Assigned(FOwner.LCLObject) and
|
if (FOwner <> nil) and Assigned(FOwner.LCLObject) and
|
||||||
(FOwner.FChildOfComplexWidget = ccwScrollingWinControl) and
|
(FOwner.FChildOfComplexWidget = ccwScrollingWinControl) and
|
||||||
not (caspComputingBounds in FOwner.LCLObject.AutoSizePhases) then
|
not (caspComputingBounds in FOwner.LCLObject.AutoSizePhases) then
|
||||||
@ -7474,7 +7805,15 @@ begin
|
|||||||
|
|
||||||
LMScroll.Pos := p1;
|
LMScroll.Pos := p1;
|
||||||
LMScroll.ScrollCode := SIF_POS;
|
LMScroll.ScrollCode := SIF_POS;
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if Assigned(FOwner) and (FOwner is TQtWindowArea) then
|
||||||
|
begin
|
||||||
|
if LMScroll.Msg = LM_VSCROLL then
|
||||||
|
TQtWindowArea(FOwner).FScrollY := -p1
|
||||||
|
else
|
||||||
|
TQtWindowArea(FOwner).FScrollX := -p1;
|
||||||
|
end else
|
||||||
|
{$ENDIF}
|
||||||
if (FChildOfComplexWidget = ccwAbstractScrollArea) and Assigned(FOwner) and
|
if (FChildOfComplexWidget = ccwAbstractScrollArea) and Assigned(FOwner) and
|
||||||
(FOwner.ChildOfComplexWidget = ccwScrollingWinControl) then
|
(FOwner.ChildOfComplexWidget = ccwScrollingWinControl) then
|
||||||
begin
|
begin
|
||||||
@ -7655,8 +7994,13 @@ var
|
|||||||
LMScroll: TLMScroll;
|
LMScroll: TLMScroll;
|
||||||
begin
|
begin
|
||||||
inherited SlotSliderReleased;
|
inherited SlotSliderReleased;
|
||||||
if (ChildOfComplexWidget = ccwAbstractScrollArea) and (FOwner <> nil) and
|
if
|
||||||
(FOwner.ChildOfComplexWidget in [ccwCustomControl]) then
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
((ChildOfComplexWidget = ccwAbstractScrollArea) and (FOwner <> nil) and
|
||||||
|
(FOwner is TQtWindowArea)) or
|
||||||
|
{$ENDIF}
|
||||||
|
((ChildOfComplexWidget = ccwAbstractScrollArea) and (FOwner <> nil) and
|
||||||
|
(FOwner.ChildOfComplexWidget in [ccwCustomControl])) then
|
||||||
begin
|
begin
|
||||||
AValue := getValue;
|
AValue := getValue;
|
||||||
if AValue <= getMin then
|
if AValue <= getMin then
|
||||||
@ -7708,7 +8052,12 @@ begin
|
|||||||
Result := inherited EventFilter(Sender, Event)
|
Result := inherited EventFilter(Sender, Event)
|
||||||
else
|
else
|
||||||
if (QEvent_type(Event) = QEventWheel) and Assigned(FOwner) and
|
if (QEvent_type(Event) = QEventWheel) and Assigned(FOwner) and
|
||||||
(FOwner is TQtCustomControl) then
|
(
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
(FOwner is TQtWindowArea) or
|
||||||
|
{$ENDIF}
|
||||||
|
(FOwner is TQtCustomControl)
|
||||||
|
) then
|
||||||
begin
|
begin
|
||||||
Result := inherited EventFilter(Sender, Event);
|
Result := inherited EventFilter(Sender, Event);
|
||||||
// do not scroll when disabled
|
// do not scroll when disabled
|
||||||
@ -7729,6 +8078,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
QEventHide:
|
QEventHide:
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if Assigned(FOwner) and (FOwner is TQtWindowArea) then
|
||||||
|
begin
|
||||||
|
if Assigned(TQtWindowArea(FOwner).viewportWidget) then
|
||||||
|
case getOrientation of
|
||||||
|
QtVertical: TQtWindowArea(FOwner).FScrollY := 0;
|
||||||
|
QtHorizontal: TQtWindowArea(FOwner).FScrollX := 0;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
{$ENDIF}
|
||||||
if Assigned(FOwner) and (FOwner is TQtCustomControl) then
|
if Assigned(FOwner) and (FOwner is TQtCustomControl) then
|
||||||
begin
|
begin
|
||||||
if Assigned(TQtCustomControl(FOwner).FViewPortWidget) then
|
if Assigned(TQtCustomControl(FOwner).FViewPortWidget) then
|
||||||
@ -15938,6 +16297,9 @@ begin
|
|||||||
Result := QWidget_create(Parent, QtToolTip);
|
Result := QWidget_create(Parent, QtToolTip);
|
||||||
FDeleteLater := True;
|
FDeleteLater := True;
|
||||||
MenuBar := nil;
|
MenuBar := nil;
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
ScrollArea := nil;
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtHintWindow.InitializeWidget;
|
procedure TQtHintWindow.InitializeWidget;
|
||||||
|
@ -3440,6 +3440,10 @@ begin
|
|||||||
w := TQtWidget(Handle);
|
w := TQtWidget(Handle);
|
||||||
|
|
||||||
{TODO: find out what to do with TCustomForm descendants }
|
{TODO: find out what to do with TCustomForm descendants }
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if (w is TQtMainWindow) and Assigned(TQtMainWindow(w).ScrollArea) then
|
||||||
|
w := TQtMainWindow(w).ScrollArea;
|
||||||
|
{$ENDIF}
|
||||||
if w is TQtAbstractScrollArea then
|
if w is TQtAbstractScrollArea then
|
||||||
begin
|
begin
|
||||||
if BarKind in [SM_CXVSCROLL, SM_CYVSCROLL] then
|
if BarKind in [SM_CXVSCROLL, SM_CYVSCROLL] then
|
||||||
@ -3474,6 +3478,11 @@ begin
|
|||||||
w := TQtWidget(Handle);
|
w := TQtWidget(Handle);
|
||||||
|
|
||||||
{TODO: find out what to do with TCustomForm descendants }
|
{TODO: find out what to do with TCustomForm descendants }
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if (w is TQtMainWindow) and Assigned(TQtMainWindow(w).ScrollArea) then
|
||||||
|
w := TQtMainWindow(w).ScrollArea;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
if w is TQtAbstractScrollArea then
|
if w is TQtAbstractScrollArea then
|
||||||
begin
|
begin
|
||||||
if SBStyle = SB_VERT then
|
if SBStyle = SB_VERT then
|
||||||
@ -3522,6 +3531,15 @@ begin
|
|||||||
|
|
||||||
if not TQtWidget(Handle).LCLObject.InheritsFrom(TCustomScrollBar) then
|
if not TQtWidget(Handle).LCLObject.InheritsFrom(TCustomScrollBar) then
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if (TQtWidget(Handle) is TQtMainWindow) and Assigned(TQtMainWindow(Handle).ScrollArea) then
|
||||||
|
begin
|
||||||
|
case BarFlag of
|
||||||
|
SB_HORZ: QtScrollBar := TQtMainWindow(Handle).ScrollArea.horizontalScrollBar;
|
||||||
|
SB_VERT: QtScrollBar := TQtMainWindow(Handle).ScrollArea.verticalScrollBar;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
{$ENDIF}
|
||||||
if (TQtWidget(Handle) is TQtAbstractScrollArea) then
|
if (TQtWidget(Handle) is TQtAbstractScrollArea) then
|
||||||
begin
|
begin
|
||||||
case BarFlag of
|
case BarFlag of
|
||||||
@ -4810,6 +4828,13 @@ begin
|
|||||||
with TQtWidget(aHandle).getClientOffset do
|
with TQtWidget(aHandle).getClientOffset do
|
||||||
OffsetRect(Rect^, x, y);
|
OffsetRect(Rect^, x, y);
|
||||||
|
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if (TQtWidget(AHandle) is TQtMainWindow) and Assigned(TQtMainWindow(AHandle).ScrollArea) then
|
||||||
|
begin
|
||||||
|
Pt := TQtMainWindow(AHandle).ScrollArea.ScrolledOffset;
|
||||||
|
OffsetRect(Rect^, -Pt.X, -Pt.Y);
|
||||||
|
end else
|
||||||
|
{$ENDIF}
|
||||||
if TQtWidget(AHandle).ChildOfComplexWidget = ccwScrollingWinControl then
|
if TQtWidget(AHandle).ChildOfComplexWidget = ccwScrollingWinControl then
|
||||||
begin
|
begin
|
||||||
Pt := TQtCustomControl(AHandle).viewport.ScrolledOffset;
|
Pt := TQtCustomControl(AHandle).viewport.ScrolledOffset;
|
||||||
@ -6187,6 +6212,15 @@ begin
|
|||||||
(csDestroying in TQtWidget(Handle).LCLObject.ComponentState) then
|
(csDestroying in TQtWidget(Handle).LCLObject.ComponentState) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if (TQtWidget(Handle) is TQtMainWindow) then
|
||||||
|
begin
|
||||||
|
if Assigned(TQtMainWindow(Handle).ScrollArea) then
|
||||||
|
Scrollbar := TQtMainWindow(Handle).ScrollArea.horizontalScrollBar
|
||||||
|
else
|
||||||
|
Scrollbar := nil;
|
||||||
|
end else
|
||||||
|
{$ENDIF}
|
||||||
if TQtWidget(Handle) is TQtAbstractScrollArea then
|
if TQtWidget(Handle) is TQtAbstractScrollArea then
|
||||||
begin
|
begin
|
||||||
ScrollBar := TQtAbstractScrollArea(Handle).horizontalScrollBar;
|
ScrollBar := TQtAbstractScrollArea(Handle).horizontalScrollBar;
|
||||||
@ -6205,6 +6239,15 @@ begin
|
|||||||
(csDestroying in TQtWidget(Handle).LCLObject.ComponentState) then
|
(csDestroying in TQtWidget(Handle).LCLObject.ComponentState) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if (TQtWidget(Handle) is TQtMainWindow) then
|
||||||
|
begin
|
||||||
|
if Assigned(TQtMainWindow(Handle).ScrollArea) then
|
||||||
|
Scrollbar := TQtMainWindow(Handle).ScrollArea.verticalScrollBar
|
||||||
|
else
|
||||||
|
Scrollbar := nil;
|
||||||
|
end else
|
||||||
|
{$ENDIF}
|
||||||
if TQtWidget(Handle) is TQtAbstractScrollArea then
|
if TQtWidget(Handle) is TQtAbstractScrollArea then
|
||||||
begin
|
begin
|
||||||
ScrollBar := TQtAbstractScrollArea(Handle).verticalScrollBar;
|
ScrollBar := TQtAbstractScrollArea(Handle).verticalScrollBar;
|
||||||
@ -6264,6 +6307,10 @@ begin
|
|||||||
|
|
||||||
w := TQtWidget(Handle);
|
w := TQtWidget(Handle);
|
||||||
|
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if (w is TQtMainWindow) and Assigned(TQtMainWindow(w).ScrollArea) then
|
||||||
|
w := TQtMainWindow(Handle).ScrollArea;
|
||||||
|
{$ENDIF}
|
||||||
if w is TQtAbstractScrollArea then
|
if w is TQtAbstractScrollArea then
|
||||||
begin
|
begin
|
||||||
ScrollArea := TQtAbstractScrollArea(w);
|
ScrollArea := TQtAbstractScrollArea(w);
|
||||||
|
@ -28,6 +28,7 @@ uses
|
|||||||
qtobjects, qtwidgets, qtproc,
|
qtobjects, qtwidgets, qtproc,
|
||||||
// LCL
|
// LCL
|
||||||
SysUtils, Classes, Controls, LCLType, Forms,
|
SysUtils, Classes, Controls, LCLType, Forms,
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}StdCtrls,{$ENDIF}
|
||||||
// Widgetset
|
// Widgetset
|
||||||
InterfaceBase, WSForms, WSProc, WSLCLClasses;
|
InterfaceBase, WSForms, WSProc, WSLCLClasses;
|
||||||
|
|
||||||
@ -76,6 +77,10 @@ type
|
|||||||
|
|
||||||
class procedure CloseModal(const ACustomForm: TCustomForm); override;
|
class procedure CloseModal(const ACustomForm: TCustomForm); override;
|
||||||
class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
class procedure ScrollBy(const AWinControl: TScrollingWinControl;
|
||||||
|
const DeltaX, DeltaY: integer); override;
|
||||||
|
{$ENDIF}
|
||||||
class procedure SetAllowDropFiles(const AForm: TCustomForm; AValue: Boolean); override;
|
class procedure SetAllowDropFiles(const AForm: TCustomForm; AValue: Boolean); override;
|
||||||
class procedure SetFormBorderStyle(const AForm: TCustomForm; const AFormBorderStyle: TFormBorderStyle); override;
|
class procedure SetFormBorderStyle(const AForm: TCustomForm; const AFormBorderStyle: TFormBorderStyle); override;
|
||||||
class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle, AOldFormStyle: TFormStyle); override;
|
class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle, AOldFormStyle: TFormStyle); override;
|
||||||
@ -202,6 +207,10 @@ begin
|
|||||||
|
|
||||||
// Sets Various Events
|
// Sets Various Events
|
||||||
QtMainWindow.AttachEvents;
|
QtMainWindow.AttachEvents;
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
if Assigned(QtMainWindow.ScrollArea) then
|
||||||
|
QtMainWindow.ScrollArea.AttachEvents;
|
||||||
|
{$ENDIF}
|
||||||
QtMainWindow.MenuBar.AttachEvents;
|
QtMainWindow.MenuBar.AttachEvents;
|
||||||
|
|
||||||
if (AForm.FormStyle in [fsMDIChild]) and
|
if (AForm.FormStyle in [fsMDIChild]) and
|
||||||
@ -243,6 +252,20 @@ begin
|
|||||||
w.Release;
|
w.Release;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
class procedure TQtWSCustomForm.ScrollBy(
|
||||||
|
const AWinControl: TScrollingWinControl; const DeltaX, DeltaY: integer);
|
||||||
|
var
|
||||||
|
Widget: TQtMainWindow;
|
||||||
|
begin
|
||||||
|
if not WSCheckHandleAllocated(AWinControl, 'ScrollBy') then
|
||||||
|
Exit;
|
||||||
|
Widget := TQtMainWindow(AWinControl.Handle);
|
||||||
|
if Assigned(Widget.ScrollArea) then
|
||||||
|
Widget.ScrollArea.scroll(DeltaX, DeltaY);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TQtWSCustomForm.SetAllowDropFiles
|
Method: TQtWSCustomForm.SetAllowDropFiles
|
||||||
Params:
|
Params:
|
||||||
|
Loading…
Reference in New Issue
Block a user