mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-27 10:09:14 +02:00
Gtk2: improving ScrollWindowEx (for SynEdit / issue #7717 )
git-svn-id: trunk@19999 -
This commit is contained in:
parent
0c0556f015
commit
9a731134fb
@ -28,6 +28,10 @@
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
function DoDeliverPaintMessage(const Target: TObject; var PaintMsg: TLMPaint): PtrInt;
|
function DoDeliverPaintMessage(const Target: TObject; var PaintMsg: TLMPaint): PtrInt;
|
||||||
|
{$ifdef gtk2}
|
||||||
|
var
|
||||||
|
WidgetInfo: PWidgetInfo;
|
||||||
|
{$endif}
|
||||||
begin
|
begin
|
||||||
{
|
{
|
||||||
erase backgound of custom controls
|
erase backgound of custom controls
|
||||||
@ -46,6 +50,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
Result := DeliverMessage(Target, PaintMsg);
|
Result := DeliverMessage(Target, PaintMsg);
|
||||||
|
|
||||||
|
{$ifdef gtk2}
|
||||||
|
if (TObject(Target) is TCustomControl) then begin
|
||||||
|
WidgetInfo := GetWidgetInfo(PGtkWidget(TCustomControl(Target).Handle), False);
|
||||||
|
if WidgetInfo <> nil then
|
||||||
|
WidgetInfo^.UpdateRect := Rect(0,0,0,0);
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function DeliverPaintMessage(const Target: Pointer; var TheMessage): GBoolean;
|
function DeliverPaintMessage(const Target: Pointer; var TheMessage): GBoolean;
|
||||||
|
@ -6842,6 +6842,10 @@ var
|
|||||||
gdkRect : TGDKRectangle;
|
gdkRect : TGDKRectangle;
|
||||||
Widget, PaintWidget: PGtkWidget;
|
Widget, PaintWidget: PGtkWidget;
|
||||||
LCLObject: TObject;
|
LCLObject: TObject;
|
||||||
|
{$IfDef GTK2}
|
||||||
|
WidgetInfo: PWidgetInfo;
|
||||||
|
{$ENDIF}
|
||||||
|
r: TRect;
|
||||||
begin
|
begin
|
||||||
// DebugLn(format('Rect = %d,%d,%d,%d',[rect^.left,rect^.top,rect^.Right,rect^.Bottom]));
|
// DebugLn(format('Rect = %d,%d,%d,%d',[rect^.left,rect^.top,rect^.Right,rect^.Bottom]));
|
||||||
Widget:=PGtkWidget(aHandle);
|
Widget:=PGtkWidget(aHandle);
|
||||||
@ -6870,18 +6874,16 @@ begin
|
|||||||
if PaintWidget=nil then PaintWidget:=Widget;
|
if PaintWidget=nil then PaintWidget:=Widget;
|
||||||
|
|
||||||
if Rect = nil then begin
|
if Rect = nil then begin
|
||||||
gdkRect.X := 0;//PaintWidget^.Allocation.X;
|
Rect := @r;
|
||||||
gdkRect.Y := 0;//PaintWidget^.Allocation.Y;
|
Rect^.Left := 0;//PaintWidget^.Allocation.X;
|
||||||
gdkRect.Width:=PaintWidget^.Allocation.Width;
|
Rect^.Top := 0;//PaintWidget^.Allocation.Y;
|
||||||
gdkRect.Height:=PaintWidget^.Allocation.Height;
|
Rect^.Right := PaintWidget^.Allocation.Width;
|
||||||
|
Rect^.Bottom := PaintWidget^.Allocation.Height;
|
||||||
end else begin
|
end;
|
||||||
gdkRect.X := Rect^.Left;
|
gdkRect.X := Rect^.Left;
|
||||||
gdkRect.Y := Rect^.Top;
|
gdkRect.Y := Rect^.Top;
|
||||||
gdkRect.Width := (Rect^.Right - Rect^.Left);
|
gdkRect.Width := (Rect^.Right - Rect^.Left);
|
||||||
gdkRect.Height := (Rect^.Bottom - Rect^.Top);
|
gdkRect.Height := (Rect^.Bottom - Rect^.Top);
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{$IfDef GTK2}
|
{$IfDef GTK2}
|
||||||
if (PaintWidget<>nil) and GTK_WIDGET_NO_WINDOW(PaintWidget)
|
if (PaintWidget<>nil) and GTK_WIDGET_NO_WINDOW(PaintWidget)
|
||||||
@ -6891,6 +6893,10 @@ begin
|
|||||||
Inc(gdkRect.X, PaintWidget^.Allocation.x);
|
Inc(gdkRect.X, PaintWidget^.Allocation.x);
|
||||||
Inc(gdkRect.Y, PaintWidget^.Allocation.y);
|
Inc(gdkRect.Y, PaintWidget^.Allocation.y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
WidgetInfo := GetWidgetInfo(Widget, False); // True ??
|
||||||
|
if WidgetInfo <> nil then
|
||||||
|
UnionRect(WidgetInfo^.UpdateRect, WidgetInfo^.UpdateRect, Rect^);
|
||||||
{$EndIf}
|
{$EndIf}
|
||||||
|
|
||||||
if bErase then
|
if bErase then
|
||||||
|
@ -176,6 +176,7 @@ function gdk_pixbuf_flip(src: PGdkPixbuf; horizontal: gboolean): PGdkPixbuf; cde
|
|||||||
// gdk 2.8
|
// gdk 2.8
|
||||||
procedure gdk_display_warp_pointer(display: PGdkDisplay; screen: PGdkScreen; x, y: gint); cdecl; external gdklib;
|
procedure gdk_display_warp_pointer(display: PGdkDisplay; screen: PGdkScreen; x, y: gint); cdecl; external gdklib;
|
||||||
function gdk_screen_get_rgba_colormap(screen: PGdkScreen): PGdkColormap; cdecl; external gdklib;
|
function gdk_screen_get_rgba_colormap(screen: PGdkScreen): PGdkColormap; cdecl; external gdklib;
|
||||||
|
procedure gdk_window_move_region(window: PGdkWindow ; region: PGdkRegion; dx, dy: gint);cdecl; external gdklib;
|
||||||
|
|
||||||
type
|
type
|
||||||
TGtkPackDirection = longint;
|
TGtkPackDirection = longint;
|
||||||
|
@ -599,8 +599,12 @@ function TGtk2WidgetSet.ScrollWindowEx(hWnd: HWND; dx, dy: Integer; prcScroll, p
|
|||||||
var
|
var
|
||||||
Widget: PGtkWidget;
|
Widget: PGtkWidget;
|
||||||
Window: PGdkWindow;
|
Window: PGdkWindow;
|
||||||
|
{$ifdef GTK_2_8}
|
||||||
Region: PGdkRegion;
|
Region: PGdkRegion;
|
||||||
Rect: TGdkRectangle;
|
Rect1: TGdkRectangle;
|
||||||
|
Rect2: TRect;
|
||||||
|
WidgetInfo: PWidgetInfo;
|
||||||
|
{$ENDIF}
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
{$IFDEF DisableGtk2ScrollWindow}
|
{$IFDEF DisableGtk2ScrollWindow}
|
||||||
@ -608,10 +612,35 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
// prcScroll, prcClip are not supported under gdk yet
|
// prcScroll, prcClip are not supported under gdk yet
|
||||||
if (hWnd = 0) or (prcScroll <> nil) or (prcClip <> nil) then Exit;
|
if (hWnd = 0) or (prcScroll <> nil) or (prcClip <> nil) then Exit;
|
||||||
|
|
||||||
Widget := pgtkwidget(hWnd);
|
Widget := pgtkwidget(hWnd);
|
||||||
Widget := GetFixedWidget(Widget);
|
Widget := GetFixedWidget(Widget);
|
||||||
Window:=GetControlWindow(Widget);
|
Window:=GetControlWindow(Widget);
|
||||||
|
{$ifdef GTK_2_8}
|
||||||
|
Rect1.X := 0;//Widget^.Allocation.X;
|
||||||
|
Rect1.Y := 0; //Widget^.Allocation.Y;
|
||||||
|
Rect1.width := Widget^.Allocation.Width;
|
||||||
|
Rect1.height := Widget^.Allocation.Height;
|
||||||
|
|
||||||
|
WidgetInfo := GetWidgetInfo(Widget, False);
|
||||||
|
if WidgetInfo <> nil then begin
|
||||||
|
if (dy < 0) and (WidgetInfo^.UpdateRect.Bottom > 0) then begin
|
||||||
|
Rect1.Height := Min(Rect1.height, WidgetInfo^.UpdateRect.Top);
|
||||||
|
Rect2 := Rect(0, Rect1.height, Rect1.width, Widget^.Allocation.Height);
|
||||||
|
InvalidateRect(hWnd, @Rect2, false);
|
||||||
|
end;
|
||||||
|
if dy > 0 then begin
|
||||||
|
Rect1.y := Max(Rect1.y, WidgetInfo^.UpdateRect.Bottom);
|
||||||
|
Rect2 := Rect(0, 0, Rect1.width, Rect1.y);
|
||||||
|
InvalidateRect(hWnd, @Rect2, false);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Region := gdk_region_rectangle(@Rect1);
|
||||||
|
gdk_window_move_region(Window, Region, dx, dy);
|
||||||
|
{$ELSE}
|
||||||
gdk_window_scroll(Window, dx, dy);
|
gdk_window_scroll(Window, dx, dy);
|
||||||
|
{$ENDIF}
|
||||||
Result := true;
|
Result := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user