summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2016-11-14 20:36:33 +1100
committerJed Barber <jjbarber@y7mail.com>2016-11-14 20:36:33 +1100
commite3b35b33f519945036ecbe101b46cf701fca37fd (patch)
tree6024d3e783b3daebf5cbfeff6beffc3c0ebce004
parentb787152c2603f8d51b1626f163d234b343dbeb6f (diff)
Added FLTK integer inputs
-rw-r--r--src/fltk_binding/c_fl_int_input.cpp21
-rw-r--r--src/fltk_binding/c_fl_int_input.h18
-rw-r--r--src/fltk_binding/fltk-widgets-inputs-int.adb75
-rw-r--r--src/fltk_binding/fltk-widgets-inputs-int.ads31
4 files changed, 145 insertions, 0 deletions
diff --git a/src/fltk_binding/c_fl_int_input.cpp b/src/fltk_binding/c_fl_int_input.cpp
new file mode 100644
index 0000000..2224857
--- /dev/null
+++ b/src/fltk_binding/c_fl_int_input.cpp
@@ -0,0 +1,21 @@
+
+
+#include <FL/Fl_Int_Input.H>
+#include "c_fl_int_input.h"
+
+
+INT_INPUT new_fl_int_input(int x, int y, int w, int h, char* label) {
+ Fl_Int_Input *i = new Fl_Int_Input(x, y, w, h, label);
+ return i;
+}
+
+
+void free_fl_int_input(INT_INPUT i) {
+ delete reinterpret_cast<Fl_Int_Input*>(i);
+}
+
+
+const char * fl_int_input_get_value(INT_INPUT i) {
+ return reinterpret_cast<Fl_Int_Input*>(i)->value();
+}
+
diff --git a/src/fltk_binding/c_fl_int_input.h b/src/fltk_binding/c_fl_int_input.h
new file mode 100644
index 0000000..5d99c3f
--- /dev/null
+++ b/src/fltk_binding/c_fl_int_input.h
@@ -0,0 +1,18 @@
+
+
+#ifndef FL_INT_INPUT_GUARD
+#define FL_INT_INPUT_GUARD
+
+
+typedef void* INT_INPUT;
+
+
+extern "C" INT_INPUT new_fl_int_input(int x, int y, int w, int h, char* label);
+extern "C" void free_fl_int_input(INT_INPUT i);
+
+
+extern "C" const char * fl_int_input_get_value(INT_INPUT i);
+
+
+#endif
+
diff --git a/src/fltk_binding/fltk-widgets-inputs-int.adb b/src/fltk_binding/fltk-widgets-inputs-int.adb
new file mode 100644
index 0000000..30f3d01
--- /dev/null
+++ b/src/fltk_binding/fltk-widgets-inputs-int.adb
@@ -0,0 +1,75 @@
+
+
+with Interfaces.C.Strings;
+with System;
+use type System.Address;
+
+
+package body FLTK.Widgets.Inputs.Int is
+
+
+ function new_fl_int_input
+ (X, Y, W, H : in Interfaces.C.int;
+ Text : in Interfaces.C.char_array)
+ return System.Address;
+ pragma Import (C, new_fl_int_input, "new_fl_int_input");
+
+ procedure free_fl_int_input
+ (F : in System.Address);
+ pragma Import (C, free_fl_int_input, "free_fl_int_input");
+
+ function fl_int_input_get_value
+ (F : in System.Address)
+ return Interfaces.C.Strings.chars_ptr;
+ pragma Import (C, fl_int_input_get_value, "fl_int_input_get_value");
+
+
+
+
+ procedure Finalize
+ (This : in out Integer_Input) is
+ begin
+ Finalize (Input (This));
+ if This.Void_Ptr /= System.Null_Address then
+ if This in Integer_Input then
+ free_fl_int_input (This.Void_Ptr);
+ end if;
+ end if;
+ end Finalize;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Integer_Input is
+ begin
+ return This : Integer_Input do
+ This.Void_Ptr := new_fl_int_input
+ (Interfaces.C.int (X),
+ Interfaces.C.int (Y),
+ Interfaces.C.int (W),
+ Interfaces.C.int (H),
+ Interfaces.C.To_C (Text));
+ fl_widget_set_user_data
+ (This.Void_Ptr,
+ Widget_Convert.To_Address (This'Unchecked_Access));
+ end return;
+ end Create;
+
+
+
+
+ function Get_Value
+ (This : in Integer_Input)
+ return Integer is
+ begin
+ return Integer'Value
+ (Interfaces.C.Strings.Value
+ (fl_int_input_get_value (This.Void_Ptr)));
+ end Get_Value;
+
+
+end FLTK.Widgets.Inputs.Int;
+
diff --git a/src/fltk_binding/fltk-widgets-inputs-int.ads b/src/fltk_binding/fltk-widgets-inputs-int.ads
new file mode 100644
index 0000000..2777f54
--- /dev/null
+++ b/src/fltk_binding/fltk-widgets-inputs-int.ads
@@ -0,0 +1,31 @@
+
+
+package FLTK.Widgets.Inputs.Int is
+
+
+ type Integer_Input is new Input with private;
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Integer_Input;
+
+
+ function Get_Value
+ (This : in Integer_Input)
+ return Integer;
+
+
+private
+
+
+ type Integer_Input is new Input with null record;
+
+
+ overriding procedure Finalize
+ (This : in out Integer_Input);
+
+
+end FLTK.Widgets.Inputs.Int;
+