From 17473af7e8ed13e0a9399a69442f9839e5d83aef Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Thu, 9 Jan 2025 14:58:19 +1300 Subject: Used C FFI to make Extra_Init and Extra_Final calls more consistent --- src/fltk-widgets-valuators-sliders-scrollbars.adb | 56 +++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'src/fltk-widgets-valuators-sliders-scrollbars.adb') diff --git a/src/fltk-widgets-valuators-sliders-scrollbars.adb b/src/fltk-widgets-valuators-sliders-scrollbars.adb index 2afca08..84a0cc6 100644 --- a/src/fltk-widgets-valuators-sliders-scrollbars.adb +++ b/src/fltk-widgets-valuators-sliders-scrollbars.adb @@ -12,6 +12,10 @@ with package body FLTK.Widgets.Valuators.Sliders.Scrollbars is + ------------------------ + -- Functions From C -- + ------------------------ + procedure scrollbar_set_draw_hook (W, D : in Storage.Integer_Address); pragma Import (C, scrollbar_set_draw_hook, "scrollbar_set_draw_hook"); @@ -88,6 +92,26 @@ package body FLTK.Widgets.Valuators.Sliders.Scrollbars is + ------------------- + -- Destructors -- + ------------------- + + -- End of the line + procedure scrollbar_extra_final_hook + (Ada_Obj : in Storage.Integer_Address); + pragma Export (C, scrollbar_extra_final_hook, "scrollbar_extra_final_hook"); + + procedure scrollbar_extra_final_hook + (Ada_Obj : in Storage.Integer_Address) + is + My_Scrollbar : Scrollbar; + for My_Scrollbar'Address use Storage.To_Address (Ada_Obj); + pragma Import (Ada, My_Scrollbar); + begin + Extra_Final (My_Scrollbar); + end scrollbar_extra_final_hook; + + procedure Extra_Final (This : in out Scrollbar) is begin @@ -108,6 +132,34 @@ package body FLTK.Widgets.Valuators.Sliders.Scrollbars is + -------------------- + -- Constructors -- + -------------------- + + -- Radio signal successfully intercepted + procedure scrollbar_extra_init_hook + (Ada_Obj : in Storage.Integer_Address; + X, Y, W, H : in Interfaces.C.int; + C_Str : in Interfaces.C.Strings.chars_ptr); + pragma Export (C, scrollbar_extra_init_hook, "scrollbar_extra_init_hook"); + + procedure scrollbar_extra_init_hook + (Ada_Obj : in Storage.Integer_Address; + X, Y, W, H : in Interfaces.C.int; + C_Str : in Interfaces.C.Strings.chars_ptr) + is + My_Scrollbar : Scrollbar; + for My_Scrollbar'Address use Storage.To_Address (Ada_Obj); + pragma Import (Ada, My_Scrollbar); + begin + Extra_Init + (My_Scrollbar, + Integer (X), Integer (Y), + Integer (W), Integer (H), + Interfaces.C.Strings.Value (C_Str)); + end scrollbar_extra_init_hook; + + procedure Extra_Init (This : in out Scrollbar; X, Y, W, H : in Integer; @@ -142,6 +194,10 @@ package body FLTK.Widgets.Valuators.Sliders.Scrollbars is + ----------------------- + -- API Subprograms -- + ----------------------- + function Get_Line_Size (This : in Scrollbar) return Natural is -- cgit