mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-31 08:12:39 +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
|
||||
procedure AlignControls(AControl: TControl; var ARect: TRect); override;
|
||||
procedure CreateWnd; override;
|
||||
function GetClientScrollOffset: TPoint; override;
|
||||
Procedure WMEraseBkgnd(var Message: TLMEraseBkgnd); message LM_ERASEBKGND;
|
||||
procedure WMPaint(var message: TLMPaint); message LM_PAINT;
|
||||
procedure DoOnResize; override;
|
||||
@ -179,8 +180,6 @@ type
|
||||
{ TScrollBox }
|
||||
|
||||
TScrollBox = class(TScrollingWinControl)
|
||||
protected
|
||||
function GetClientScrollOffset: TPoint; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
published
|
||||
|
@ -15,12 +15,6 @@
|
||||
*****************************************************************************
|
||||
}
|
||||
|
||||
function TScrollBox.GetClientScrollOffset: TPoint;
|
||||
begin
|
||||
Result.X:=HorzScrollBar.Position;
|
||||
Result.Y:=VertScrollBar.Position;
|
||||
end;
|
||||
|
||||
constructor TScrollBox.Create(AOwner: TComponent);
|
||||
begin
|
||||
Inherited Create(AOwner);
|
||||
|
@ -34,6 +34,12 @@ begin
|
||||
UpdateScrollBars;
|
||||
end;
|
||||
|
||||
function TScrollingWinControl.GetClientScrollOffset: TPoint;
|
||||
begin
|
||||
Result.X:=HorzScrollBar.Position;
|
||||
Result.Y:=VertScrollBar.Position;
|
||||
end;
|
||||
|
||||
procedure TScrollingWinControl.AlignControls(AControl: TControl; var ARect: TRect);
|
||||
begin
|
||||
HorzScrollBar.AutoCalcRange;
|
||||
|
@ -3549,9 +3549,39 @@ procedure TGtkWidgetSet.SetCallback(const AMsg: LongInt;
|
||||
ConnectSenderSignalAfter(AnObject,
|
||||
'key-release-event', @GTKKeyUpDownAfter, GDK_KEY_RELEASE_MASK);
|
||||
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
|
||||
gObject, gFixed, gCore, Scroll, Adjustment: PGTKObject;
|
||||
gObject, gFixed, gCore, Adjustment: PGTKObject;
|
||||
begin
|
||||
//debugln('TGtkWidgetSet.SetCallback A ALCLObject=',DbgSName(ALCLObject),' AMsg=',dbgs(AMsg));
|
||||
if AGTKObject = nil
|
||||
@ -3912,31 +3942,13 @@ begin
|
||||
|
||||
LM_HSCROLL:
|
||||
begin
|
||||
if ALCLObject is TScrollBar then
|
||||
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)));
|
||||
Adjustment := GetAdjustment(gObject, False);
|
||||
ConnectSenderSignal(Adjustment, 'value-changed', @GTKHScrollCB);
|
||||
end;
|
||||
|
||||
LM_VSCROLL:
|
||||
begin
|
||||
if ALCLObject is TScrollBar then
|
||||
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)));
|
||||
Adjustment := GetAdjustment(gObject, True);
|
||||
ConnectSenderSignal(Adjustment, 'value-changed', @GTKVScrollCB);
|
||||
ConnectSenderSignal(Adjustment, 'value-changed', @GTKVScrollCB);
|
||||
end;
|
||||
@ -4285,6 +4297,8 @@ begin
|
||||
SetCallback(LM_CONFIGUREEVENT, AGTKObject, ALCLObject);
|
||||
SetCallback(LM_CLOSEQUERY, AGTKObject, ALCLObject);
|
||||
SetCallBack(LM_Activate, AGTKObject, ALCLObject);
|
||||
SetCallback(LM_HSCROLL, AGTKObject, ALCLObject);
|
||||
SetCallback(LM_VSCROLL, AGTKObject, ALCLObject);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -6613,6 +6613,7 @@ Function CreateFormContents(AForm: TCustomForm;
|
||||
var
|
||||
ScrolledWidget, ClientAreaWidget: PGtkWidget;
|
||||
WindowStyle: PGtkStyle;
|
||||
Adjustment: PGtkAdjustment;
|
||||
begin
|
||||
// Create the VBox. We need that to place controls outside
|
||||
// the client area (like menu)
|
||||
@ -6644,6 +6645,17 @@ begin
|
||||
GTK_CAN_FOCUS);
|
||||
gtk_scrolled_window_set_policy(PGtkScrolledWindow(ScrolledWidget),
|
||||
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;
|
||||
|
||||
|
@ -1785,8 +1785,13 @@ Begin
|
||||
|
||||
end;
|
||||
|
||||
// convert from win32 client to lcl client pos
|
||||
if PLMsg = @LMMouseMove then
|
||||
// convert from win32 client to lcl client pos.
|
||||
//
|
||||
// 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
|
||||
if GetLCLClientBoundsOffset(Window, R) then
|
||||
begin
|
||||
@ -1794,7 +1799,7 @@ Begin
|
||||
Dec(LMMouseMove.YPos, R.Top);
|
||||
end;
|
||||
end else
|
||||
if PLMsg = @LMMouse then
|
||||
if (PLMsg = @LMMouse) and not (lWinControl is TScrollingWinControl) then
|
||||
begin
|
||||
if GetLCLClientBoundsOffset(Window, R) then
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user