diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/c_fl_multiline_output.cpp | 57 | ||||
-rw-r--r-- | src/c_fl_multiline_output.h | 18 | ||||
-rw-r--r-- | src/fltk-widgets-inputs-outputs-multiline.adb | 95 | ||||
-rw-r--r-- | src/fltk-widgets-inputs-outputs-multiline.ads | 30 |
4 files changed, 200 insertions, 0 deletions
diff --git a/src/c_fl_multiline_output.cpp b/src/c_fl_multiline_output.cpp new file mode 100644 index 0000000..eaf4274 --- /dev/null +++ b/src/c_fl_multiline_output.cpp @@ -0,0 +1,57 @@ + + +#include <FL/Fl_Multiline_Output.H> +#include "c_fl_multiline_output.h" + + +typedef void (hook)(void*); +typedef hook* hook_p; + + + + +class My_Multiline_Output : public Fl_Multiline_Output { + public: + using Fl_Multiline_Output::Fl_Multiline_Output; + friend void multiline_output_set_draw_hook(MULTILINE_OUTPUT n, void * d); + friend void fl_multiline_output_draw(MULTILINE_OUTPUT n); + protected: + void draw(); + void real_draw(); + hook_p draw_hook; +}; + + +void My_Multiline_Output::draw() { + (*draw_hook)(this->user_data()); +} + + +void My_Multiline_Output::real_draw() { + Fl_Multiline_Output::draw(); +} + + +void multiline_output_set_draw_hook(MULTILINE_OUTPUT n, void * d) { + reinterpret_cast<My_Multiline_Output*>(n)->draw_hook = reinterpret_cast<hook_p>(d); +} + + +void fl_multiline_output_draw(MULTILINE_OUTPUT n) { + reinterpret_cast<My_Multiline_Output*>(n)->real_draw(); +} + + + + +MULTILINE_OUTPUT new_fl_multiline_output(int x, int y, int w, int h, char* label) { + My_Multiline_Output *i = new My_Multiline_Output(x, y, w, h, label); + return i; +} + + +void free_fl_multiline_output(MULTILINE_OUTPUT i) { + delete reinterpret_cast<My_Multiline_Output*>(i); +} + + diff --git a/src/c_fl_multiline_output.h b/src/c_fl_multiline_output.h new file mode 100644 index 0000000..cc8eabd --- /dev/null +++ b/src/c_fl_multiline_output.h @@ -0,0 +1,18 @@ + + +#ifndef FL_MULTILINE_OUTPUT_GUARD +#define FL_MULTILINE_OUTPUT_GUARD + + +typedef void* MULTILINE_OUTPUT; + + +extern "C" void multiline_output_set_draw_hook(MULTILINE_OUTPUT n, void * d); +extern "C" void fl_multiline_output_draw(MULTILINE_OUTPUT n); + +extern "C" MULTILINE_OUTPUT new_fl_multiline_output(int x, int y, int w, int h, char* label); +extern "C" void free_fl_multiline_output(MULTILINE_OUTPUT i); + + +#endif + diff --git a/src/fltk-widgets-inputs-outputs-multiline.adb b/src/fltk-widgets-inputs-outputs-multiline.adb new file mode 100644 index 0000000..5edd67f --- /dev/null +++ b/src/fltk-widgets-inputs-outputs-multiline.adb @@ -0,0 +1,95 @@ + + +with Interfaces.C.Strings; +with System; +use type System.Address; + + +package body FLTK.Widgets.Inputs.Outputs.Multiline is + + + procedure multiline_output_set_draw_hook + (W, D : in System.Address); + pragma Import (C, multiline_output_set_draw_hook, "multiline_output_set_draw_hook"); + + procedure fl_multiline_output_draw + (W : in System.Address); + pragma Import (C, fl_multiline_output_draw, "fl_multiline_output_draw"); + + function new_fl_multiline_output + (X, Y, W, H : in Interfaces.C.int; + Text : in Interfaces.C.char_array) + return System.Address; + pragma Import (C, new_fl_multiline_output, "new_fl_multiline_output"); + + procedure free_fl_multiline_output + (F : in System.Address); + pragma Import (C, free_fl_multiline_output, "free_fl_multiline_output"); + + + + + procedure Draw_Hook (U : in System.Address); + pragma Convention (C, Draw_Hook); + + procedure Draw_Hook + (U : in System.Address) + is + package Output_Convert is new + System.Address_To_Access_Conversions (Multiline_Output'Class); + + Ada_Output : access Multiline_Output'Class := + Output_Convert.To_Pointer (U); + begin + Ada_Output.Draw; + end Draw_Hook; + + + + + procedure Draw + (This : in out Multiline_Output) is + begin + fl_multiline_output_draw (This.Void_Ptr); + end Draw; + + + + + procedure Finalize + (This : in out Multiline_Output) is + begin + if This.Void_Ptr /= System.Null_Address and then + This in Multiline_Output'Class + then + free_fl_multiline_output (This.Void_Ptr); + This.Void_Ptr := System.Null_Address; + end if; + Finalize (Output (This)); + end Finalize; + + + + + function Create + (X, Y, W, H : in Integer; + Text : in String) + return Multiline_Output is + begin + return This : Multiline_Output do + This.Void_Ptr := new_fl_multiline_output + (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_output_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); + end return; + end Create; + + +end FLTK.Widgets.Inputs.Outputs.Multiline; + diff --git a/src/fltk-widgets-inputs-outputs-multiline.ads b/src/fltk-widgets-inputs-outputs-multiline.ads new file mode 100644 index 0000000..5f9f193 --- /dev/null +++ b/src/fltk-widgets-inputs-outputs-multiline.ads @@ -0,0 +1,30 @@ + + +package FLTK.Widgets.Inputs.Outputs.Multiline is + + + type Multiline_Output is new Output with private; + + + function Create + (X, Y, W, H : in Integer; + Text : in String) + return Multiline_Output; + + + procedure Draw + (This : in out Multiline_Output); + + +private + + + type Multiline_Output is new Output with null record; + + + overriding procedure Finalize + (This : in out Multiline_Output); + + +end FLTK.Widgets.Inputs.Outputs.Multiline; + |