mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-05 13:18:08 +02:00
Gtk3: implemented TGtk3Widget.Repaint, use it in TGtk3WSWinControl.Repaint and TGtk3WidgetSet.UpdateWindow.
This commit is contained in:
parent
890c652c25
commit
fa50636812
@ -199,6 +199,7 @@ type
|
|||||||
procedure Move(ALeft, ATop: Integer);
|
procedure Move(ALeft, ATop: Integer);
|
||||||
procedure Activate; virtual;
|
procedure Activate; virtual;
|
||||||
procedure preferredSize(var PreferredWidth, PreferredHeight: integer; {%H-}WithThemeSpace: Boolean); virtual;
|
procedure preferredSize(var PreferredWidth, PreferredHeight: integer; {%H-}WithThemeSpace: Boolean); virtual;
|
||||||
|
procedure Repaint(const ARect: PRect = nil); virtual;
|
||||||
procedure SetCursor(ACursor: HCURSOR);
|
procedure SetCursor(ACursor: HCURSOR);
|
||||||
procedure SetFocus; virtual;
|
procedure SetFocus; virtual;
|
||||||
procedure SetParent(AParent: TGtk3Widget; const ALeft, ATop: Integer); virtual;
|
procedure SetParent(AParent: TGtk3Widget; const ALeft, ATop: Integer); virtual;
|
||||||
@ -3298,6 +3299,43 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TGtk3Widget.Repaint(const ARect: PRect);
|
||||||
|
var
|
||||||
|
aLayout: PGtkLayout;
|
||||||
|
aWindow: PGdkWindow;
|
||||||
|
cr, tmpCtx: Pcairo_t;
|
||||||
|
aRegion: Pcairo_region_t;
|
||||||
|
tmpSurf: Pcairo_surface_t;
|
||||||
|
ACairoRect: Tcairo_rectangle_int_t;
|
||||||
|
begin
|
||||||
|
if [wtLayout] * WidgetType <> [] then
|
||||||
|
begin
|
||||||
|
aLayout := PGtkLayout(GetContainerWidget);
|
||||||
|
if Gtk3IsGdkWindow(aLayout^.get_bin_window) then
|
||||||
|
begin
|
||||||
|
//TODO: implement ARect
|
||||||
|
aWindow := aLayout^.get_bin_window;
|
||||||
|
cr := gdk_cairo_create(aWindow);
|
||||||
|
aRegion := gdk_window_get_visible_region(aWindow);
|
||||||
|
cairo_region_get_extents(aRegion, @ACairoRect);
|
||||||
|
tmpSurf := cairo_surface_create_similar(cairo_get_target(cr), CAIRO_CONTENT_COLOR_ALPHA, ACairoRect.Width, ACairoRect.Height);
|
||||||
|
tmpCtx := cairo_create(tmpSurf);
|
||||||
|
cairo_translate(tmpCtx, ACairoRect.X, ACairoRect.Y);
|
||||||
|
gtk_widget_draw(aLayout, tmpCtx);
|
||||||
|
cairo_set_source_surface(cr, tmpSurf, 0, 0);
|
||||||
|
cairo_paint(cr);
|
||||||
|
cairo_destroy(tmpCtx);
|
||||||
|
cairo_surface_destroy(tmpSurf);
|
||||||
|
cairo_destroy(cr);
|
||||||
|
cairo_region_destroy(aRegion);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
GetContainerWidget^.queue_draw;
|
||||||
|
if GetContainerWidget^.get_has_window and Gtk3IsGdkWindow(GetContainerWidget^.window) then
|
||||||
|
GetContainerWidget^.window^.process_updates(True);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TGtk3Widget.SetCursor(ACursor: HCURSOR);
|
procedure TGtk3Widget.SetCursor(ACursor: HCURSOR);
|
||||||
begin
|
begin
|
||||||
if IsWidgetOk then
|
if IsWidgetOk then
|
||||||
|
@ -4675,17 +4675,7 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
if IsValidHandle(Handle) then
|
if IsValidHandle(Handle) then
|
||||||
begin
|
begin
|
||||||
TGtk3Widget(Handle).Update(nil);
|
TGtk3Widget(Handle).Repaint(nil);
|
||||||
if TGtk3Widget(Handle).GetContainerWidget^.get_has_window then
|
|
||||||
begin
|
|
||||||
if Gtk3IsGdkWindow(TGtk3Widget(Handle).GetContainerWidget^.window) then
|
|
||||||
TGtk3Widget(Handle).GetContainerWidget^.window^.process_updates(True);
|
|
||||||
end else
|
|
||||||
if TGtk3Widget(Handle).Widget^.get_has_window then
|
|
||||||
begin
|
|
||||||
if Gtk3IsGdkWindow(TGtk3Widget(Handle).Widget^.window) then
|
|
||||||
TGtk3Widget(Handle).Widget^.window^.process_updates(True);
|
|
||||||
end;
|
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -352,35 +352,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TGtk3WSWinControl.Repaint(const AWinControl: TWinControl);
|
class procedure TGtk3WSWinControl.Repaint(const AWinControl: TWinControl);
|
||||||
var
|
|
||||||
cr, tmpCtx: Pcairo_t;
|
|
||||||
aWindow: PGdkWindow;
|
|
||||||
aRegion: Pcairo_region_t;
|
|
||||||
ARect: Tcairo_rectangle_int_t;
|
|
||||||
tmpSurf: Pcairo_surface_t;
|
|
||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(AWinControl, 'Repaint') then
|
if not WSCheckHandleAllocated(AWinControl, 'Repaint') then
|
||||||
Exit;
|
Exit;
|
||||||
|
TGtk3Widget(AWinControl.Handle).Repaint(nil);
|
||||||
if Gtk3IsLayout(TGtk3Widget(AWinControl.Handle).GetContainerWidget) and
|
|
||||||
Gtk3IsGdkWindow(PGtkLayout(TGtk3Widget(AWinControl.Handle).GetContainerWidget)^.get_bin_window) then
|
|
||||||
begin
|
|
||||||
aWindow := PGtkLayout(TGtk3Widget(AWinControl.Handle).GetContainerWidget)^.get_bin_window;
|
|
||||||
cr := gdk_cairo_create(aWindow);
|
|
||||||
aRegion := gdk_window_get_visible_region(aWIndow);
|
|
||||||
cairo_region_get_extents(aRegion, @ARect);
|
|
||||||
tmpSurf := cairo_surface_create_similar(cairo_get_target(cr), CAIRO_CONTENT_COLOR_ALPHA, ARect.Width, ARect.Height);
|
|
||||||
tmpCtx := cairo_create(tmpSurf);
|
|
||||||
cairo_translate(tmpCtx, ARect.X, ARect.Y);
|
|
||||||
gtk_widget_draw(TGtk3Widget(AWinControl.Handle).GetContainerWidget, tmpCtx);
|
|
||||||
cairo_set_source_surface(cr, tmpSurf, 0, 0);
|
|
||||||
cairo_paint(cr);
|
|
||||||
cairo_destroy(tmpCtx);
|
|
||||||
cairo_surface_destroy(tmpSurf);
|
|
||||||
cairo_destroy(cr);
|
|
||||||
cairo_region_destroy(aRegion);
|
|
||||||
end else
|
|
||||||
TGtk3Widget(AWinControl.Handle).Update(nil);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TGtk3WSWinControl.SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer);
|
class procedure TGtk3WSWinControl.SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer);
|
||||||
|
Loading…
Reference in New Issue
Block a user