diff options
Diffstat (limited to 'body/fltk-widgets-inputs.adb')
-rw-r--r-- | body/fltk-widgets-inputs.adb | 96 |
1 files changed, 67 insertions, 29 deletions
diff --git a/body/fltk-widgets-inputs.adb b/body/fltk-widgets-inputs.adb index 0d3a3fe..2057f96 100644 --- a/body/fltk-widgets-inputs.adb +++ b/body/fltk-widgets-inputs.adb @@ -28,6 +28,8 @@ package body FLTK.Widgets.Inputs is -- Functions From C -- ------------------------ + -- Allocation -- + function new_fl_input (X, Y, W, H : in Interfaces.C.int; Text : in Interfaces.C.char_array) @@ -43,6 +45,8 @@ package body FLTK.Widgets.Inputs is + -- Clipboard -- + function fl_input_copy (I : in Storage.Integer_Address; C : in Interfaces.C.int) @@ -85,6 +89,8 @@ package body FLTK.Widgets.Inputs is + -- Readonly, Tabs, Wrap -- + function fl_input_get_readonly (I : in Storage.Integer_Address) return Interfaces.C.int; @@ -124,6 +130,8 @@ package body FLTK.Widgets.Inputs is + -- Shortcut, Input Position -- + function fl_input_get_input_type (I : in Storage.Integer_Address) return Interfaces.C.int; @@ -184,6 +192,8 @@ package body FLTK.Widgets.Inputs is + -- Text Field -- + function fl_input_index (I : in Storage.Integer_Address; P : in Interfaces.C.int) @@ -219,6 +229,8 @@ package body FLTK.Widgets.Inputs is + -- Input Size -- + function fl_input_get_maximum_size (I : in Storage.Integer_Address) return Interfaces.C.int; @@ -240,6 +252,8 @@ package body FLTK.Widgets.Inputs is + -- Cursors, Text Settings -- + function fl_input_get_cursor_color (I : in Storage.Integer_Address) return Interfaces.C.unsigned; @@ -291,6 +305,8 @@ package body FLTK.Widgets.Inputs is + -- Dimensions -- + procedure fl_input_set_size (I : in Storage.Integer_Address; W, H : in Interfaces.C.int); @@ -306,6 +322,8 @@ package body FLTK.Widgets.Inputs is + -- Drawing, Events -- + procedure fl_input_draw (W : in Storage.Integer_Address); pragma Import (C, fl_input_draw, "fl_input_draw"); @@ -375,11 +393,11 @@ package body FLTK.Widgets.Inputs is begin return This : Input do This.Void_Ptr := new_fl_input - (Interfaces.C.int (X), - Interfaces.C.int (Y), - Interfaces.C.int (W), - Interfaces.C.int (H), - Interfaces.C.To_C (Text)); + (Interfaces.C.int (X), + Interfaces.C.int (Y), + Interfaces.C.int (W), + Interfaces.C.int (H), + Interfaces.C.To_C (Text)); Extra_Init (This, X, Y, W, H, Text); end return; end Create; @@ -405,16 +423,20 @@ package body FLTK.Widgets.Inputs is -- API Subprograms -- ----------------------- + -- Clipboard -- + procedure Copy (This : in out Input; Destination : in Clipboard_Kind := Cut_Paste_Board) is - Result : Interfaces.C.int := fl_input_copy + Result : constant Interfaces.C.int := fl_input_copy (This.Void_Ptr, Clipboard_Kind'Pos (Destination)); begin pragma Assert (Result in 0 .. 1); exception - when Chk.Assertion_Error => raise Internal_FLTK_Error; + when Chk.Assertion_Error => raise Internal_FLTK_Error with + "Fl_Input_::copy returned unexpected int value of " & + Interfaces.C.int'Image (Result); end Copy; @@ -423,20 +445,22 @@ package body FLTK.Widgets.Inputs is Destination : in Clipboard_Kind := Cut_Paste_Board) return Boolean is - Result : Interfaces.C.int := fl_input_copy + Result : constant Interfaces.C.int := fl_input_copy (This.Void_Ptr, Clipboard_Kind'Pos (Destination)); begin pragma Assert (Result in 0 .. 1); return Boolean'Val (Result); exception - when Chk.Assertion_Error => raise Internal_FLTK_Error; + when Chk.Assertion_Error => raise Internal_FLTK_Error with + "Fl_Input_::copy returned unexpected int value of " & + Interfaces.C.int'Image (Result); end Copy; procedure Cut (This : in out Input) is - Result : Interfaces.C.int := fl_input_cut (This.Void_Ptr); + Ignore : constant Interfaces.C.int := fl_input_cut (This.Void_Ptr); begin null; end Cut; @@ -454,7 +478,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; Num_Bytes : in Integer) is - Result : Interfaces.C.int := fl_input_cut2 + Ignore : constant Interfaces.C.int := fl_input_cut2 (This.Void_Ptr, Interfaces.C.int (Num_Bytes)); begin @@ -477,7 +501,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; Start, Finish : in Integer) is - Result : Interfaces.C.int := fl_input_cut3 + Ignore : constant Interfaces.C.int := fl_input_cut3 (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish)); @@ -501,7 +525,7 @@ package body FLTK.Widgets.Inputs is procedure Copy_Cuts (This : in out Input) is - Result : Interfaces.C.int := fl_input_copy_cuts (This.Void_Ptr); + Ignore : constant Interfaces.C.int := fl_input_copy_cuts (This.Void_Ptr); begin null; end Copy_Cuts; @@ -511,7 +535,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input) return Boolean is - Result : Interfaces.C.int := fl_input_copy_cuts (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_input_copy_cuts (This.Void_Ptr); begin return Result /= 0; end Copy_Cuts; @@ -520,7 +544,7 @@ package body FLTK.Widgets.Inputs is procedure Undo (This : in out Input) is - Result : Interfaces.C.int := fl_input_undo (This.Void_Ptr); + Ignore : constant Interfaces.C.int := fl_input_undo (This.Void_Ptr); begin null; end Undo; @@ -536,6 +560,8 @@ package body FLTK.Widgets.Inputs is + -- Readonly, Tabs, Wrap -- + function Is_Readonly (This : in Input) return Boolean is @@ -586,11 +612,13 @@ package body FLTK.Widgets.Inputs is + -- Shortcut, Input Position -- + function Get_Kind (This : in Input) return Input_Kind is - C_Val : Interfaces.C.int := fl_input_get_input_type (This.Void_Ptr); + C_Val : constant Interfaces.C.int := fl_input_get_input_type (This.Void_Ptr); begin for V in Input_Kind loop if Input_Kind_Values (V) = C_Val then @@ -601,20 +629,20 @@ package body FLTK.Widgets.Inputs is end Get_Kind; - function Get_Shortcut_Key + function Get_Shortcut (This : in Input) return Key_Combo is begin - return To_Ada (fl_input_get_shortcut (This.Void_Ptr)); - end Get_Shortcut_Key; + return To_Ada (Interfaces.C.unsigned (fl_input_get_shortcut (This.Void_Ptr))); + end Get_Shortcut; - procedure Set_Shortcut_Key + procedure Set_Shortcut (This : in out Input; To : in Key_Combo) is begin - fl_input_set_shortcut (This.Void_Ptr, To_C (To)); - end Set_Shortcut_Key; + fl_input_set_shortcut (This.Void_Ptr, Interfaces.C.int (To_C (To))); + end Set_Shortcut; function Get_Mark @@ -629,7 +657,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; To : in Natural) is - Result : Interfaces.C.int := fl_input_set_mark + Ignore : constant Interfaces.C.int := fl_input_set_mark (This.Void_Ptr, Interfaces.C.int (To)); begin @@ -660,7 +688,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; To : in Natural) is - Result : Interfaces.C.int := fl_input_set_position + Ignore : constant Interfaces.C.int := fl_input_set_position (This.Void_Ptr, Interfaces.C.int (To)); begin @@ -684,7 +712,7 @@ package body FLTK.Widgets.Inputs is Place : in Natural; Mark : in Natural) is - Result : Interfaces.C.int := fl_input_set_position2 + Ignore : constant Interfaces.C.int := fl_input_set_position2 (This.Void_Ptr, Interfaces.C.int (Place), Interfaces.C.int (Mark)); @@ -708,6 +736,8 @@ package body FLTK.Widgets.Inputs is + -- Text Field -- + function Index (This : in Input; Place : in Integer) @@ -721,7 +751,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; Str : in String) is - Result : Interfaces.C.int := fl_input_insert + Ignore : constant Interfaces.C.int := fl_input_insert (This.Void_Ptr, Interfaces.C.To_C (Str, False), Str'Length); @@ -747,7 +777,7 @@ package body FLTK.Widgets.Inputs is From, To : in Natural; New_Text : in String) is - Result : Interfaces.C.int := fl_input_replace + Ignore : constant Interfaces.C.int := fl_input_replace (This.Void_Ptr, Interfaces.C.int (From), Interfaces.C.int (To), @@ -777,7 +807,7 @@ package body FLTK.Widgets.Inputs is (This : in Input) return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_input_get_value (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_input_get_value (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; @@ -792,7 +822,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; To : in String) is - Result : Interfaces.C.int := fl_input_set_value + Ignore : constant Interfaces.C.int := fl_input_set_value (This.Void_Ptr, Interfaces.C.To_C (To), To'Length); begin null; @@ -813,6 +843,8 @@ package body FLTK.Widgets.Inputs is + -- Input Size -- + function Get_Maximum_Size (This : in Input) return Natural is @@ -839,6 +871,8 @@ package body FLTK.Widgets.Inputs is + -- Cursors, Text Settings -- + function Get_Cursor_Color (This : in Input) return Color is @@ -905,6 +939,8 @@ package body FLTK.Widgets.Inputs is + -- Dimensions -- + procedure Resize (This : in out Input; W, H : in Integer) is @@ -928,6 +964,8 @@ package body FLTK.Widgets.Inputs is + -- Changing Input Type -- + package body Extra is procedure Set_Kind |