gtk2: fix PaintTo (bug #0014201)

git-svn-id: trunk@20984 -
This commit is contained in:
paul 2009-07-28 04:02:20 +00:00
parent 19fef0b2ee
commit e97576c1c7

View File

@ -30,7 +30,7 @@ interface
uses uses
{$IFDEF GTK2} {$IFDEF GTK2}
Gtk2, Glib2, Gdk2, Gtk2, Glib2, Gdk2, Gdk2Pixbuf,
{$ELSE} {$ELSE}
Gtk, Glib, Gdk, Gtk, Glib, Gdk,
{$ENDIF} {$ENDIF}
@ -683,10 +683,22 @@ var
procedure PaintWindow(AWindow: PGdkWindow; AOffset: TPoint); procedure PaintWindow(AWindow: PGdkWindow; AOffset: TPoint);
var var
W, H: gint; W, H: gint;
{$ifndef gtk1}
Pixbuf: PGdkPixbuf;
{$endif}
begin begin
gdk_window_get_size(AWindow, @W, @H); gdk_window_get_size(AWindow, @W, @H);
{$ifdef gtk1}
gdk_window_copy_area(DC.Drawable, DC.GC, X, Y, AWindow, gdk_window_copy_area(DC.Drawable, DC.GC, X, Y, AWindow,
AOffset.X, AOffset.Y, W, H); AOffset.X, AOffset.Y, W, H);
{$else}
// for some reason gdk_window_copy_area does not work
Pixbuf := gdk_pixbuf_get_from_drawable(nil, AWindow, nil,
AOffset.X, AOffset.Y, 0, 0, W, H);
gdk_pixbuf_render_to_drawable(Pixbuf, DC.Drawable, DC.GC, 0, 0, X, Y,
-1, -1, GDK_RGB_DITHER_NONE, 0, 0);
gdk_pixbuf_unref(Pixbuf);
{$endif}
end; end;
procedure PaintWidget(AWidget: PGtkWidget); procedure PaintWidget(AWidget: PGtkWidget);
@ -694,7 +706,7 @@ var
AOffset: TPoint; AOffset: TPoint;
AWindow: PGdkWindow; AWindow: PGdkWindow;
begin begin
AWindow := AWidget^.window; AWindow := GetControlWindow(AWidget);
AOffset := Point(AWidget^.allocation.x, AWidget^.allocation.y); AOffset := Point(AWidget^.allocation.x, AWidget^.allocation.y);
if AWindow <> nil then if AWindow <> nil then
@ -704,8 +716,7 @@ var
begin begin
if not WSCheckHandleAllocated(AWinControl, 'PaintTo') if not WSCheckHandleAllocated(AWinControl, 'PaintTo')
then Exit; then Exit;
PaintWidget(GetFixedWidget(PGtkWidget(AWinControl.Handle)));
PaintWidget(PGtkWidget(AWinControl.Handle));
end; end;
{ helper/common routines } { helper/common routines }