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