agpl_1.0.0_b5da3320/src/agpl-gdk/agpl-gdk-controlled_gc.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--  A controlled GC to avoid resource leaks.
--  On creation it is allocated, on finalization it is unref'ed.

with Gdk.Drawable; use Gdk.Drawable;
with Gdk.GC;       use Gdk.GC;

with Ada.Finalization;

package Agpl.Gdk.Controlled_Gc is

   pragma Elaborate_Body;

   type Object (Draw : Gdk_Drawable) is tagged limited private;

   function Get_Gc (This : in Object) return Gdk_GC;
   function "+" (This : in Object) return Gdk_GC renames Get_Gc;

private

   type Object (Draw : Gdk_Drawable) is new Ada.Finalization.Limited_Controlled with
      record
         Gc : Gdk_GC;
      end record;

   procedure Initialize (This : in out Object);
   procedure Finalize   (This : in out Object);

end Agpl.Gdk.Controlled_Gc;