Gtk2: improving ScrollWindowEx (for SynEdit / issue #7717 )

git-svn-id: trunk@19999 -
This commit is contained in:
martin 2009-05-17 01:34:00 +00:00
parent 0c0556f015
commit 9a731134fb
4 changed files with 61 additions and 13 deletions

View File

@ -28,6 +28,10 @@
{$ENDIF}
function DoDeliverPaintMessage(const Target: TObject; var PaintMsg: TLMPaint): PtrInt;
{$ifdef gtk2}
var
WidgetInfo: PWidgetInfo;
{$endif}
begin
{
erase backgound of custom controls
@ -46,6 +50,14 @@ begin
end;
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;
function DeliverPaintMessage(const Target: Pointer; var TheMessage): GBoolean;

View File

@ -6842,6 +6842,10 @@ var
gdkRect : TGDKRectangle;
Widget, PaintWidget: PGtkWidget;
LCLObject: TObject;
{$IfDef GTK2}
WidgetInfo: PWidgetInfo;
{$ENDIF}
r: TRect;
begin
// DebugLn(format('Rect = %d,%d,%d,%d',[rect^.left,rect^.top,rect^.Right,rect^.Bottom]));
Widget:=PGtkWidget(aHandle);
@ -6870,18 +6874,16 @@ begin
if PaintWidget=nil then PaintWidget:=Widget;
if Rect = nil then begin
gdkRect.X := 0;//PaintWidget^.Allocation.X;
gdkRect.Y := 0;//PaintWidget^.Allocation.Y;
gdkRect.Width:=PaintWidget^.Allocation.Width;
gdkRect.Height:=PaintWidget^.Allocation.Height;
end else begin
gdkRect.X := Rect^.Left;
gdkRect.Y := Rect^.Top;
gdkRect.Width := (Rect^.Right - Rect^.Left);
gdkRect.Height := (Rect^.Bottom - Rect^.Top);
end;
Rect := @r;
Rect^.Left := 0;//PaintWidget^.Allocation.X;
Rect^.Top := 0;//PaintWidget^.Allocation.Y;
Rect^.Right := PaintWidget^.Allocation.Width;
Rect^.Bottom := PaintWidget^.Allocation.Height;
end;
gdkRect.X := Rect^.Left;
gdkRect.Y := Rect^.Top;
gdkRect.Width := (Rect^.Right - Rect^.Left);
gdkRect.Height := (Rect^.Bottom - Rect^.Top);
{$IfDef GTK2}
if (PaintWidget<>nil) and GTK_WIDGET_NO_WINDOW(PaintWidget)
@ -6891,6 +6893,10 @@ begin
Inc(gdkRect.X, PaintWidget^.Allocation.x);
Inc(gdkRect.Y, PaintWidget^.Allocation.y);
end;
WidgetInfo := GetWidgetInfo(Widget, False); // True ??
if WidgetInfo <> nil then
UnionRect(WidgetInfo^.UpdateRect, WidgetInfo^.UpdateRect, Rect^);
{$EndIf}
if bErase then

View File

@ -176,6 +176,7 @@ function gdk_pixbuf_flip(src: PGdkPixbuf; horizontal: gboolean): PGdkPixbuf; cde
// gdk 2.8
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;
procedure gdk_window_move_region(window: PGdkWindow ; region: PGdkRegion; dx, dy: gint);cdecl; external gdklib;
type
TGtkPackDirection = longint;

View File

@ -599,8 +599,12 @@ function TGtk2WidgetSet.ScrollWindowEx(hWnd: HWND; dx, dy: Integer; prcScroll, p
var
Widget: PGtkWidget;
Window: PGdkWindow;
{$ifdef GTK_2_8}
Region: PGdkRegion;
Rect: TGdkRectangle;
Rect1: TGdkRectangle;
Rect2: TRect;
WidgetInfo: PWidgetInfo;
{$ENDIF}
begin
Result := False;
{$IFDEF DisableGtk2ScrollWindow}
@ -608,10 +612,35 @@ begin
{$ENDIF}
// prcScroll, prcClip are not supported under gdk yet
if (hWnd = 0) or (prcScroll <> nil) or (prcClip <> nil) then Exit;
Widget := pgtkwidget(hWnd);
Widget := GetFixedWidget(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);
{$ENDIF}
Result := true;
end;