summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/c_fl_multiline_input.cpp57
-rw-r--r--src/c_fl_multiline_input.h18
-rw-r--r--src/fltk-widgets-inputs-multiline.adb94
-rw-r--r--src/fltk-widgets-inputs-multiline.ads30
4 files changed, 199 insertions, 0 deletions
diff --git a/src/c_fl_multiline_input.cpp b/src/c_fl_multiline_input.cpp
new file mode 100644
index 0000000..c9bdfaa
--- /dev/null
+++ b/src/c_fl_multiline_input.cpp
@@ -0,0 +1,57 @@
+
+
+#include <FL/Fl_Multiline_Input.H>
+#include "c_fl_multiline_input.h"
+
+
+typedef void (hook)(void*);
+typedef hook* hook_p;
+
+
+
+
+class My_Multiline_Input : public Fl_Multiline_Input {
+ public:
+ using Fl_Multiline_Input::Fl_Multiline_Input;
+ friend void multiline_input_set_draw_hook(MULTILINE_INPUT n, void * d);
+ friend void fl_multiline_input_draw(MULTILINE_INPUT n);
+ protected:
+ void draw();
+ void real_draw();
+ hook_p draw_hook;
+};
+
+
+void My_Multiline_Input::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+
+void My_Multiline_Input::real_draw() {
+ Fl_Multiline_Input::draw();
+}
+
+
+void multiline_input_set_draw_hook(MULTILINE_INPUT n, void * d) {
+ reinterpret_cast<My_Multiline_Input*>(n)->draw_hook = reinterpret_cast<hook_p>(d);
+}
+
+
+void fl_multiline_input_draw(MULTILINE_INPUT n) {
+ reinterpret_cast<My_Multiline_Input*>(n)->real_draw();
+}
+
+
+
+
+MULTILINE_INPUT new_fl_multiline_input(int x, int y, int w, int h, char* label) {
+ My_Multiline_Input *i = new My_Multiline_Input(x, y, w, h, label);
+ return i;
+}
+
+
+void free_fl_multiline_input(MULTILINE_INPUT i) {
+ delete reinterpret_cast<My_Multiline_Input*>(i);
+}
+
+
diff --git a/src/c_fl_multiline_input.h b/src/c_fl_multiline_input.h
new file mode 100644
index 0000000..f0b6ea1
--- /dev/null
+++ b/src/c_fl_multiline_input.h
@@ -0,0 +1,18 @@
+
+
+#ifndef FL_MULTILINE_INPUT_GUARD
+#define FL_MULTILINE_INPUT_GUARD
+
+
+typedef void* MULTILINE_INPUT;
+
+
+extern "C" void multiline_input_set_draw_hook(MULTILINE_INPUT n, void * d);
+extern "C" void fl_multiline_input_draw(MULTILINE_INPUT n);
+
+extern "C" MULTILINE_INPUT new_fl_multiline_input(int x, int y, int w, int h, char* label);
+extern "C" void free_fl_multiline_input(MULTILINE_INPUT i);
+
+
+#endif
+
diff --git a/src/fltk-widgets-inputs-multiline.adb b/src/fltk-widgets-inputs-multiline.adb
new file mode 100644
index 0000000..5b76868
--- /dev/null
+++ b/src/fltk-widgets-inputs-multiline.adb
@@ -0,0 +1,94 @@
+
+
+with Interfaces.C.Strings;
+with System;
+use type System.Address;
+
+
+package body FLTK.Widgets.Inputs.Multiline is
+
+
+ procedure multiline_input_set_draw_hook
+ (W, D : in System.Address);
+ pragma Import (C, multiline_input_set_draw_hook, "multiline_input_set_draw_hook");
+
+ procedure fl_multiline_input_draw
+ (W : in System.Address);
+ pragma Import (C, fl_multiline_input_draw, "fl_multiline_input_draw");
+
+ function new_fl_multiline_input
+ (X, Y, W, H : in Interfaces.C.int;
+ Text : in Interfaces.C.char_array)
+ return System.Address;
+ pragma Import (C, new_fl_multiline_input, "new_fl_multiline_input");
+
+ procedure free_fl_multiline_input
+ (F : in System.Address);
+ pragma Import (C, free_fl_multiline_input, "free_fl_multiline_input");
+
+
+
+
+ procedure Draw_Hook (U : in System.Address);
+ pragma Convention (C, Draw_Hook);
+
+ procedure Draw_Hook
+ (U : in System.Address)
+ is
+ package Multi_Input_Convert is new
+ System.Address_To_Access_Conversions (Multiline_Input'Class);
+
+ Ada_Input : access Multiline_Input'Class :=
+ Multi_Input_Convert.To_Pointer (U);
+ begin
+ Ada_Input.Draw;
+ end Draw_Hook;
+
+
+
+
+ procedure Draw
+ (This : in out Multiline_Input) is
+ begin
+ fl_multiline_input_draw (This.Void_Ptr);
+ end Draw;
+
+
+
+
+ procedure Finalize
+ (This : in out Multiline_Input) is
+ begin
+ if This in Multiline_Input and then
+ This.Void_Ptr /= System.Null_Address
+ then
+ free_fl_multiline_input (This.Void_Ptr);
+ end if;
+ Finalize (Input (This));
+ end Finalize;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Multiline_Input is
+ begin
+ return This : Multiline_Input do
+ This.Void_Ptr := new_fl_multiline_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));
+ multiline_input_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
+ end return;
+ end Create;
+
+
+end FLTK.Widgets.Inputs.Multiline;
+
diff --git a/src/fltk-widgets-inputs-multiline.ads b/src/fltk-widgets-inputs-multiline.ads
new file mode 100644
index 0000000..2d7b7d7
--- /dev/null
+++ b/src/fltk-widgets-inputs-multiline.ads
@@ -0,0 +1,30 @@
+
+
+package FLTK.Widgets.Inputs.Multiline is
+
+
+ type Multiline_Input is new Input with private;
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Multiline_Input;
+
+
+ procedure Draw
+ (This : in out Multiline_Input);
+
+
+private
+
+
+ type Multiline_Input is new Input with null record;
+
+
+ overriding procedure Finalize
+ (This : in out Multiline_Input);
+
+
+end FLTK.Widgets.Inputs.Multiline;
+