summaryrefslogtreecommitdiff
path: root/src/fltk-devices-surfaces.adb
blob: 7b95bec2677d89057d50f164d88a0d74aae4d076 (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96


with

    System;

use type

    System.Address;


package body FLTK.Devices.Surfaces is


    function new_fl_surface
           (G : in System.Address)
        return System.Address;
    pragma Import (C, new_fl_surface, "new_fl_surface");

    procedure free_fl_surface
           (S : in System.Address);
    pragma Import (C, free_fl_surface, "free_fl_surface");




    procedure fl_surface_set_current
           (S : in System.Address);
    pragma Import (C, fl_surface_set_current, "fl_surface_set_current");

    function fl_surface_get_surface
        return System.Address;
    pragma Import (C, fl_surface_get_surface, "fl_surface_get_surface");




    procedure Finalize
           (This : in out Surface_Device) is
    begin
        if  This.Void_Ptr /= System.Null_Address and then
            This in Surface_Device'Class
        then
            if This.Needs_Dealloc then
                free_fl_surface (This.Void_Ptr);
            end if;
            This.Void_Ptr := System.Null_Address;
        end if;
        Finalize (Device (This));
    end Finalize;




    package body Forge is

        function Create
               (Graphics : in out FLTK.Devices.Graphics.Graphics_Driver)
            return Surface_Device is
        begin
            return This : Surface_Device do
                This.Void_Ptr := new_fl_surface (Wrapper (Graphics).Void_Ptr);
            end return;
        end Create;

    end Forge;




    function Get_Current
        return access Surface_Device'Class is
    begin
        return Current_Ptr;
    end Get_Current;


    procedure Set_Current
           (This : in out Surface_Device) is
    begin
        fl_surface_set_current (This.Void_Ptr);
        Current_Ptr := This'Unchecked_Access;
    end Set_Current;




begin


    Original_Surface.Void_Ptr := fl_surface_get_surface;
    Original_Surface.Needs_Dealloc := False;


end FLTK.Devices.Surfaces;