mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-10 08:18:34 +02:00
fixed mouse events return wrong coordinates in scrolling components (win32, issue #1983), enabled ajustments for customforms in gtk
git-svn-id: trunk@9316 -
This commit is contained in:
parent
b31c5c3b3e
commit
aa20edd467
@ -151,6 +151,7 @@ type
|
|||||||
protected
|
protected
|
||||||
procedure AlignControls(AControl: TControl; var ARect: TRect); override;
|
procedure AlignControls(AControl: TControl; var ARect: TRect); override;
|
||||||
procedure CreateWnd; override;
|
procedure CreateWnd; override;
|
||||||
|
function GetClientScrollOffset: TPoint; override;
|
||||||
Procedure WMEraseBkgnd(var Message: TLMEraseBkgnd); message LM_ERASEBKGND;
|
Procedure WMEraseBkgnd(var Message: TLMEraseBkgnd); message LM_ERASEBKGND;
|
||||||
procedure WMPaint(var message: TLMPaint); message LM_PAINT;
|
procedure WMPaint(var message: TLMPaint); message LM_PAINT;
|
||||||
procedure DoOnResize; override;
|
procedure DoOnResize; override;
|
||||||
@ -179,8 +180,6 @@ type
|
|||||||
{ TScrollBox }
|
{ TScrollBox }
|
||||||
|
|
||||||
TScrollBox = class(TScrollingWinControl)
|
TScrollBox = class(TScrollingWinControl)
|
||||||
protected
|
|
||||||
function GetClientScrollOffset: TPoint; override;
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
published
|
published
|
||||||
|
@ -15,12 +15,6 @@
|
|||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
}
|
}
|
||||||
|
|
||||||
function TScrollBox.GetClientScrollOffset: TPoint;
|
|
||||||
begin
|
|
||||||
Result.X:=HorzScrollBar.Position;
|
|
||||||
Result.Y:=VertScrollBar.Position;
|
|
||||||
end;
|
|
||||||
|
|
||||||
constructor TScrollBox.Create(AOwner: TComponent);
|
constructor TScrollBox.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
Inherited Create(AOwner);
|
Inherited Create(AOwner);
|
||||||
|
@ -34,6 +34,12 @@ begin
|
|||||||
UpdateScrollBars;
|
UpdateScrollBars;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TScrollingWinControl.GetClientScrollOffset: TPoint;
|
||||||
|
begin
|
||||||
|
Result.X:=HorzScrollBar.Position;
|
||||||
|
Result.Y:=VertScrollBar.Position;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TScrollingWinControl.AlignControls(AControl: TControl; var ARect: TRect);
|
procedure TScrollingWinControl.AlignControls(AControl: TControl; var ARect: TRect);
|
||||||
begin
|
begin
|
||||||
HorzScrollBar.AutoCalcRange;
|
HorzScrollBar.AutoCalcRange;
|
||||||
|
@ -3549,9 +3549,39 @@ procedure TGtkWidgetSet.SetCallback(const AMsg: LongInt;
|
|||||||
ConnectSenderSignalAfter(AnObject,
|
ConnectSenderSignalAfter(AnObject,
|
||||||
'key-release-event', @GTKKeyUpDownAfter, GDK_KEY_RELEASE_MASK);
|
'key-release-event', @GTKKeyUpDownAfter, GDK_KEY_RELEASE_MASK);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetAdjustment(const gObject: PGTKObject; vertical: boolean):PGtkObject;
|
||||||
|
var
|
||||||
|
Scroll: PGtkObject;
|
||||||
|
begin
|
||||||
|
if Vertical then begin
|
||||||
|
if ALCLObject is TScrollBar then
|
||||||
|
result := PGtkObject(PgtkhScrollBar(gObject)^.Scrollbar.Range.Adjustment)
|
||||||
|
else if (ALCLObject is TScrollBox) or (ALCLObject is TCustomForm) then begin
|
||||||
|
Scroll := gtk_object_get_data(gObject, odnScrollArea);
|
||||||
|
Result := PGtkObject(gtk_scrolled_window_get_vadjustment(
|
||||||
|
PGTKScrolledWindow(Scroll)));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Result := PGtkObject(gtk_scrolled_window_get_vadjustment(
|
||||||
|
PGTKScrolledWindow(gObject)));
|
||||||
|
|
||||||
|
end else begin
|
||||||
|
if ALCLObject is TScrollBar then
|
||||||
|
Result := PgtkObject(PgtkhScrollBar(gObject)^.Scrollbar.Range.Adjustment)
|
||||||
|
else if (ALCLObject is TScrollBox) or (ALCLObject is TCustomForm) then begin
|
||||||
|
Scroll := gtk_object_get_data(gObject, odnScrollArea);
|
||||||
|
Result := PgtkObject(gtk_scrolled_window_get_hadjustment(
|
||||||
|
PGTKScrolledWindow(Scroll)));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Result := PgtkObject(gtk_scrolled_window_get_hadjustment(
|
||||||
|
PGTKScrolledWindow(gObject)));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
gObject, gFixed, gCore, Scroll, Adjustment: PGTKObject;
|
gObject, gFixed, gCore, Adjustment: PGTKObject;
|
||||||
begin
|
begin
|
||||||
//debugln('TGtkWidgetSet.SetCallback A ALCLObject=',DbgSName(ALCLObject),' AMsg=',dbgs(AMsg));
|
//debugln('TGtkWidgetSet.SetCallback A ALCLObject=',DbgSName(ALCLObject),' AMsg=',dbgs(AMsg));
|
||||||
if AGTKObject = nil
|
if AGTKObject = nil
|
||||||
@ -3912,31 +3942,13 @@ begin
|
|||||||
|
|
||||||
LM_HSCROLL:
|
LM_HSCROLL:
|
||||||
begin
|
begin
|
||||||
if ALCLObject is TScrollBar then
|
Adjustment := GetAdjustment(gObject, False);
|
||||||
Adjustment := PgtkObject(PgtkhScrollBar(gObject)^.Scrollbar.Range.Adjustment)
|
|
||||||
else if ALCLObject is TScrollBox then begin
|
|
||||||
Scroll := gtk_object_get_data(gObject, odnScrollArea);
|
|
||||||
Adjustment := PgtkObject(gtk_scrolled_window_get_hadjustment(
|
|
||||||
PGTKScrolledWindow(Scroll)));
|
|
||||||
end
|
|
||||||
else
|
|
||||||
Adjustment := PgtkObject(gtk_scrolled_window_get_hadjustment(
|
|
||||||
PGTKScrolledWindow(gObject)));
|
|
||||||
ConnectSenderSignal(Adjustment, 'value-changed', @GTKHScrollCB);
|
ConnectSenderSignal(Adjustment, 'value-changed', @GTKHScrollCB);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
LM_VSCROLL:
|
LM_VSCROLL:
|
||||||
begin
|
begin
|
||||||
if ALCLObject is TScrollBar then
|
Adjustment := GetAdjustment(gObject, True);
|
||||||
Adjustment := PGtkObject(PgtkhScrollBar(gObject)^.Scrollbar.Range.Adjustment)
|
|
||||||
else if ALCLObject is TScrollBox then begin
|
|
||||||
Scroll := gtk_object_get_data(gObject, odnScrollArea);
|
|
||||||
Adjustment := PGtkObject(gtk_scrolled_window_get_vadjustment(
|
|
||||||
PGTKScrolledWindow(Scroll)));
|
|
||||||
end
|
|
||||||
else
|
|
||||||
Adjustment := PGtkObject(gtk_scrolled_window_get_vadjustment(
|
|
||||||
PGTKScrolledWindow(gObject)));
|
|
||||||
ConnectSenderSignal(Adjustment, 'value-changed', @GTKVScrollCB);
|
ConnectSenderSignal(Adjustment, 'value-changed', @GTKVScrollCB);
|
||||||
ConnectSenderSignal(Adjustment, 'value-changed', @GTKVScrollCB);
|
ConnectSenderSignal(Adjustment, 'value-changed', @GTKVScrollCB);
|
||||||
end;
|
end;
|
||||||
@ -4285,6 +4297,8 @@ begin
|
|||||||
SetCallback(LM_CONFIGUREEVENT, AGTKObject, ALCLObject);
|
SetCallback(LM_CONFIGUREEVENT, AGTKObject, ALCLObject);
|
||||||
SetCallback(LM_CLOSEQUERY, AGTKObject, ALCLObject);
|
SetCallback(LM_CLOSEQUERY, AGTKObject, ALCLObject);
|
||||||
SetCallBack(LM_Activate, AGTKObject, ALCLObject);
|
SetCallBack(LM_Activate, AGTKObject, ALCLObject);
|
||||||
|
SetCallback(LM_HSCROLL, AGTKObject, ALCLObject);
|
||||||
|
SetCallback(LM_VSCROLL, AGTKObject, ALCLObject);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -6613,6 +6613,7 @@ Function CreateFormContents(AForm: TCustomForm;
|
|||||||
var
|
var
|
||||||
ScrolledWidget, ClientAreaWidget: PGtkWidget;
|
ScrolledWidget, ClientAreaWidget: PGtkWidget;
|
||||||
WindowStyle: PGtkStyle;
|
WindowStyle: PGtkStyle;
|
||||||
|
Adjustment: PGtkAdjustment;
|
||||||
begin
|
begin
|
||||||
// Create the VBox. We need that to place controls outside
|
// Create the VBox. We need that to place controls outside
|
||||||
// the client area (like menu)
|
// the client area (like menu)
|
||||||
@ -6644,6 +6645,17 @@ begin
|
|||||||
GTK_CAN_FOCUS);
|
GTK_CAN_FOCUS);
|
||||||
gtk_scrolled_window_set_policy(PGtkScrolledWindow(ScrolledWidget),
|
gtk_scrolled_window_set_policy(PGtkScrolledWindow(ScrolledWidget),
|
||||||
GTK_POLICY_NEVER,GTK_POLICY_NEVER);
|
GTK_POLICY_NEVER,GTK_POLICY_NEVER);
|
||||||
|
|
||||||
|
Adjustment := gtk_scrolled_window_get_vadjustment(PGTKScrolledWindow(ScrolledWidget));
|
||||||
|
if Adjustment <> nil
|
||||||
|
then gtk_object_set_data(PGTKObject(Adjustment), odnScrollBar,
|
||||||
|
PGTKScrolledWindow(ScrolledWidget)^.vscrollbar);
|
||||||
|
|
||||||
|
Adjustment := gtk_scrolled_window_get_hadjustment(PGTKScrolledWindow(ScrolledWidget));
|
||||||
|
if Adjustment <> nil
|
||||||
|
then gtk_object_set_data(PGTKObject(Adjustment), odnScrollBar,
|
||||||
|
PGTKScrolledWindow(ScrolledWidget)^.hscrollbar);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1785,8 +1785,13 @@ Begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// convert from win32 client to lcl client pos
|
// convert from win32 client to lcl client pos.
|
||||||
if PLMsg = @LMMouseMove then
|
//
|
||||||
|
// hack to prevent GetLCLClientBoundsOffset from changing mouse client
|
||||||
|
// coordinates for TScrollingWinControls, this is required in
|
||||||
|
// IsControlMouseMsg and ControlAtPos where unscrolled client coordinates
|
||||||
|
// are expected.
|
||||||
|
if (PLMsg = @LMMouseMove) and not (lWinControl is TScrollingWinControl) then
|
||||||
begin
|
begin
|
||||||
if GetLCLClientBoundsOffset(Window, R) then
|
if GetLCLClientBoundsOffset(Window, R) then
|
||||||
begin
|
begin
|
||||||
@ -1794,7 +1799,7 @@ Begin
|
|||||||
Dec(LMMouseMove.YPos, R.Top);
|
Dec(LMMouseMove.YPos, R.Top);
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
if PLMsg = @LMMouse then
|
if (PLMsg = @LMMouse) and not (lWinControl is TScrollingWinControl) then
|
||||||
begin
|
begin
|
||||||
if GetLCLClientBoundsOffset(Window, R) then
|
if GetLCLClientBoundsOffset(Window, R) then
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user