diff options
Diffstat (limited to 'src/fltk-dialogs.adb')
-rw-r--r-- | src/fltk-dialogs.adb | 84 |
1 files changed, 59 insertions, 25 deletions
diff --git a/src/fltk-dialogs.adb b/src/fltk-dialogs.adb index 46c14ad..7f0629c 100644 --- a/src/fltk-dialogs.adb +++ b/src/fltk-dialogs.adb @@ -17,34 +17,41 @@ package body FLTK.Dialogs is procedure dialog_fl_alert (M : in Interfaces.C.char_array); pragma Import (C, dialog_fl_alert, "dialog_fl_alert"); + pragma Inline (dialog_fl_alert); -- function dialog_fl_ask -- (M : in Interfaces.C.char_array) -- return Interfaces.C.int; -- pragma Import (C, dialog_fl_ask, "dialog_fl_ask"); + -- pragma Inline (dialog_fl_ask); procedure dialog_fl_beep (B : in Interfaces.C.int); pragma Import (C, dialog_fl_beep, "dialog_fl_beep"); + pragma Inline (dialog_fl_beep); function dialog_fl_choice (M, A, B, C : in Interfaces.C.char_array) return Interfaces.C.int; pragma Import (C, dialog_fl_choice, "dialog_fl_choice"); + pragma Inline (dialog_fl_choice); function dialog_fl_input (M, D : in Interfaces.C.char_array) return Interfaces.C.Strings.chars_ptr; pragma Import (C, dialog_fl_input, "dialog_fl_input"); + pragma Inline (dialog_fl_input); procedure dialog_fl_message (M : in Interfaces.C.char_array); pragma Import (C, dialog_fl_message, "dialog_fl_message"); + pragma Inline (dialog_fl_message); function dialog_fl_password (M, D : in Interfaces.C.char_array) return Interfaces.C.Strings.chars_ptr; pragma Import (C, dialog_fl_password, "dialog_fl_password"); + pragma Inline (dialog_fl_password); @@ -55,18 +62,29 @@ package body FLTK.Dialogs is M : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, dialog_fl_color_chooser, "dialog_fl_color_chooser"); + pragma Inline (dialog_fl_color_chooser); + + function dialog_fl_color_chooser2 + (N : in Interfaces.C.char_array; + R, G, B : in out Interfaces.C.unsigned_char; + M : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, dialog_fl_color_chooser2, "dialog_fl_color_chooser2"); + pragma Inline (dialog_fl_color_chooser2); function dialog_fl_dir_chooser (M, D : in Interfaces.C.char_array; R : in Interfaces.C.int) return Interfaces.C.Strings.chars_ptr; pragma Import (C, dialog_fl_dir_chooser, "dialog_fl_dir_chooser"); + pragma Inline (dialog_fl_dir_chooser); function dialog_fl_file_chooser (M, P, D : in Interfaces.C.char_array; R : in Interfaces.C.int) return Interfaces.C.Strings.chars_ptr; pragma Import (C, dialog_fl_file_chooser, "dialog_fl_file_chooser"); + pragma Inline (dialog_fl_file_chooser); @@ -74,26 +92,32 @@ package body FLTK.Dialogs is function dialog_fl_get_message_hotspot return Interfaces.C.int; pragma Import (C, dialog_fl_get_message_hotspot, "dialog_fl_get_message_hotspot"); + pragma Inline (dialog_fl_get_message_hotspot); procedure dialog_fl_set_message_hotspot (V : in Interfaces.C.int); pragma Import (C, dialog_fl_set_message_hotspot, "dialog_fl_set_message_hotspot"); + pragma Inline (dialog_fl_set_message_hotspot); procedure dialog_fl_message_font (F, S : in Interfaces.C.int); pragma Import (C, dialog_fl_message_font, "dialog_fl_message_font"); + pragma Inline (dialog_fl_message_font); function dialog_fl_message_icon return System.Address; pragma Import (C, dialog_fl_message_icon, "dialog_fl_message_icon"); + pragma Inline (dialog_fl_message_icon); procedure dialog_fl_message_title (T : in Interfaces.C.char_array); pragma Import (C, dialog_fl_message_title, "dialog_fl_message_title"); + pragma Inline (dialog_fl_message_title); procedure dialog_fl_message_title_default (T : in Interfaces.C.char_array); pragma Import (C, dialog_fl_message_title_default, "dialog_fl_message_title_default"); + pragma Inline (dialog_fl_message_title_default); @@ -143,11 +167,8 @@ package body FLTK.Dialogs is (Interfaces.C.To_C (Message), Interfaces.C.To_C (Default)); begin - if Result = Interfaces.C.Strings.Null_Ptr then - return ""; - else - return Interfaces.C.Strings.Value (Result); - end if; + -- string does not need dealloc + return Interfaces.C.Strings.Value (Result); end Text_Input; @@ -167,11 +188,8 @@ package body FLTK.Dialogs is (Interfaces.C.To_C (Message), Interfaces.C.To_C (Default)); begin - if Result = Interfaces.C.Strings.Null_Ptr then - return ""; - else - return Interfaces.C.Strings.Value (Result); - end if; + -- string does not need dealloc + return Interfaces.C.Strings.Value (Result); end Password; @@ -179,8 +197,9 @@ package body FLTK.Dialogs is function Color_Chooser (Title : in String; - R, G, B : in out Long_Float; - Mode : in FLTK.Widgets.Groups.Color_Choosers.Color_Mode) + R, G, B : in out RGB_Float; + Mode : in FLTK.Widgets.Groups.Color_Choosers.Color_Mode := + FLTK.Widgets.Groups.Color_Choosers.RGB) return Boolean is C_R : Interfaces.C.double := Interfaces.C.double (R); @@ -190,9 +209,30 @@ package body FLTK.Dialogs is Result : Boolean := dialog_fl_color_chooser (Interfaces.C.To_C (Title), C_R, C_G, C_B, M) /= 0; begin - R := Long_Float (C_R); - G := Long_Float (C_G); - B := Long_Float (C_B); + R := RGB_Float (C_R); + G := RGB_Float (C_G); + B := RGB_Float (C_B); + return Result; + end Color_Chooser; + + + function Color_Chooser + (Title : in String; + R, G, B : in out RGB_Int; + Mode : in FLTK.Widgets.Groups.Color_Choosers.Color_Mode := + FLTK.Widgets.Groups.Color_Choosers.RGB) + return Boolean + is + C_R : Interfaces.C.unsigned_char := Interfaces.C.unsigned_char (R); + C_G : Interfaces.C.unsigned_char := Interfaces.C.unsigned_char (G); + C_B : Interfaces.C.unsigned_char := Interfaces.C.unsigned_char (B); + M : Interfaces.C.int := FLTK.Widgets.Groups.Color_Choosers.Color_Mode'Pos (Mode); + Result : Boolean := dialog_fl_color_chooser2 + (Interfaces.C.To_C (Title), C_R, C_G, C_B, M) /= 0; + begin + R := RGB_Int (C_R); + G := RGB_Int (C_G); + B := RGB_Int (C_B); return Result; end Color_Chooser; @@ -207,11 +247,8 @@ package body FLTK.Dialogs is Interfaces.C.To_C (Default), Boolean'Pos (Relative)); begin - if Result = Interfaces.C.Strings.Null_Ptr then - return ""; - else - return Interfaces.C.Strings.Value (Result); - end if; + -- I'm... fairly sure the string does not need dealloc? + return Interfaces.C.Strings.Value (Result); end Dir_Chooser; @@ -226,11 +263,8 @@ package body FLTK.Dialogs is Interfaces.C.To_C (Default), Boolean'Pos (Relative)); begin - if Result = Interfaces.C.Strings.Null_Ptr then - return ""; - else - return Interfaces.C.Strings.Value (Result); - end if; + -- I'm... fairly sure the string does not need dealloc? + return Interfaces.C.Strings.Value (Result); end File_Chooser; |