summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2017-05-09 18:09:47 +1000
committerJed Barber <jjbarber@y7mail.com>2017-05-09 18:09:47 +1000
commit17eee7d8d33a3e3d3fdeda6dcb5548973cddeacb (patch)
treef8e143ffa09b2905a8502d964656d41b17d0a888
parentca10c01bea1e7a64b347ef058796a45f3b155e8e (diff)
Secret_Input widgets added
-rw-r--r--src/c_fl_secret_input.cpp57
-rw-r--r--src/c_fl_secret_input.h18
-rw-r--r--src/fltk-widgets-inputs-secret.adb94
-rw-r--r--src/fltk-widgets-inputs-secret.ads30
4 files changed, 199 insertions, 0 deletions
diff --git a/src/c_fl_secret_input.cpp b/src/c_fl_secret_input.cpp
new file mode 100644
index 0000000..0c6c7b3
--- /dev/null
+++ b/src/c_fl_secret_input.cpp
@@ -0,0 +1,57 @@
+
+
+#include <FL/Fl_Secret_Input.H>
+#include "c_fl_secret_input.h"
+
+
+typedef void (hook)(void*);
+typedef hook* hook_p;
+
+
+
+
+class My_Secret_Input : public Fl_Secret_Input {
+ public:
+ using Fl_Secret_Input::Fl_Secret_Input;
+ friend void secret_input_set_draw_hook(SECRET_INPUT n, void * d);
+ friend void fl_secret_input_draw(SECRET_INPUT n);
+ protected:
+ void draw();
+ void real_draw();
+ hook_p draw_hook;
+};
+
+
+void My_Secret_Input::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+
+void My_Secret_Input::real_draw() {
+ Fl_Secret_Input::draw();
+}
+
+
+void secret_input_set_draw_hook(SECRET_INPUT n, void * d) {
+ reinterpret_cast<My_Secret_Input*>(n)->draw_hook = reinterpret_cast<hook_p>(d);
+}
+
+
+void fl_secret_input_draw(SECRET_INPUT n) {
+ reinterpret_cast<My_Secret_Input*>(n)->real_draw();
+}
+
+
+
+
+SECRET_INPUT new_fl_secret_input(int x, int y, int w, int h, char* label) {
+ My_Secret_Input *i = new My_Secret_Input(x, y, w, h, label);
+ return i;
+}
+
+
+void free_fl_secret_input(SECRET_INPUT i) {
+ delete reinterpret_cast<My_Secret_Input*>(i);
+}
+
+
diff --git a/src/c_fl_secret_input.h b/src/c_fl_secret_input.h
new file mode 100644
index 0000000..58b60a1
--- /dev/null
+++ b/src/c_fl_secret_input.h
@@ -0,0 +1,18 @@
+
+
+#ifndef FL_SECRET_INPUT_GUARD
+#define FL_SECRET_INPUT_GUARD
+
+
+typedef void* SECRET_INPUT;
+
+
+extern "C" void secret_input_set_draw_hook(SECRET_INPUT n, void * d);
+extern "C" void fl_secret_input_draw(SECRET_INPUT n);
+
+extern "C" SECRET_INPUT new_fl_secret_input(int x, int y, int w, int h, char* label);
+extern "C" void free_fl_secret_input(SECRET_INPUT i);
+
+
+#endif
+
diff --git a/src/fltk-widgets-inputs-secret.adb b/src/fltk-widgets-inputs-secret.adb
new file mode 100644
index 0000000..46d0b0b
--- /dev/null
+++ b/src/fltk-widgets-inputs-secret.adb
@@ -0,0 +1,94 @@
+
+
+with Interfaces.C.Strings;
+with System;
+use type System.Address;
+
+
+package body FLTK.Widgets.Inputs.Secret is
+
+
+ procedure secret_input_set_draw_hook
+ (W, D : in System.Address);
+ pragma Import (C, secret_input_set_draw_hook, "secret_input_set_draw_hook");
+
+ procedure fl_secret_input_draw
+ (W : in System.Address);
+ pragma Import (C, fl_secret_input_draw, "fl_secret_input_draw");
+
+ function new_fl_secret_input
+ (X, Y, W, H : in Interfaces.C.int;
+ Text : in Interfaces.C.char_array)
+ return System.Address;
+ pragma Import (C, new_fl_secret_input, "new_fl_secret_input");
+
+ procedure free_fl_secret_input
+ (F : in System.Address);
+ pragma Import (C, free_fl_secret_input, "free_fl_secret_input");
+
+
+
+
+ procedure Draw_Hook (U : in System.Address);
+ pragma Convention (C, Draw_Hook);
+
+ procedure Draw_Hook
+ (U : in System.Address)
+ is
+ package Secret_Input_Convert is new
+ System.Address_To_Access_Conversions (Secret_Input'Class);
+
+ Ada_Input : access Secret_Input'Class :=
+ Secret_Input_Convert.To_Pointer (U);
+ begin
+ Ada_Input.Draw;
+ end Draw_Hook;
+
+
+
+
+ procedure Draw
+ (This : in out Secret_Input) is
+ begin
+ fl_secret_input_draw (This.Void_Ptr);
+ end Draw;
+
+
+
+
+ procedure Finalize
+ (This : in out Secret_Input) is
+ begin
+ if This in Secret_Input and then
+ This.Void_Ptr /= System.Null_Address
+ then
+ free_fl_secret_input (This.Void_Ptr);
+ end if;
+ Finalize (Input (This));
+ end Finalize;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Secret_Input is
+ begin
+ return This : Secret_Input do
+ This.Void_Ptr := new_fl_secret_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));
+ secret_input_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
+ end return;
+ end Create;
+
+
+end FLTK.Widgets.Inputs.Secret;
+
diff --git a/src/fltk-widgets-inputs-secret.ads b/src/fltk-widgets-inputs-secret.ads
new file mode 100644
index 0000000..f45250b
--- /dev/null
+++ b/src/fltk-widgets-inputs-secret.ads
@@ -0,0 +1,30 @@
+
+
+package FLTK.Widgets.Inputs.Secret is
+
+
+ type Secret_Input is new Input with private;
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Secret_Input;
+
+
+ procedure Draw
+ (This : in out Secret_Input);
+
+
+private
+
+
+ type Secret_Input is new Input with null record;
+
+
+ overriding procedure Finalize
+ (This : in out Secret_Input);
+
+
+end FLTK.Widgets.Inputs.Secret;
+