diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/c_fl_value_output.cpp | 108 | ||||
-rw-r--r-- | src/c_fl_value_output.h | 41 | ||||
-rw-r--r-- | src/fltk-widgets-valuators-value_outputs.adb | 242 | ||||
-rw-r--r-- | src/fltk-widgets-valuators-value_outputs.ads | 101 |
4 files changed, 492 insertions, 0 deletions
diff --git a/src/c_fl_value_output.cpp b/src/c_fl_value_output.cpp new file mode 100644 index 0000000..5e874f9 --- /dev/null +++ b/src/c_fl_value_output.cpp @@ -0,0 +1,108 @@ + + +#include <FL/Fl_Value_Output.H> +#include "c_fl_value_output.h" +#include "c_fl_type.h" + + + + +class My_Value_Output : public Fl_Value_Output { + public: + using Fl_Value_Output::Fl_Value_Output; + friend void value_output_set_draw_hook(VALUE_OUTPUT a, void * d); + friend void fl_value_output_draw(VALUE_OUTPUT a); + friend void value_output_set_handle_hook(VALUE_OUTPUT a, void * h); + friend int fl_value_output_handle(VALUE_OUTPUT a, int e); + protected: + void draw(); + void real_draw(); + int handle(int e); + int real_handle(int e); + d_hook_p draw_hook; + h_hook_p handle_hook; +}; + +void My_Value_Output::draw() { + (*draw_hook)(this->user_data()); +} + +void My_Value_Output::real_draw() { + Fl_Value_Output::draw(); +} + +int My_Value_Output::handle(int e) { + return (*handle_hook)(this->user_data(), e); +} + +int My_Value_Output::real_handle(int e) { + return Fl_Value_Output::handle(e); +} + +void value_output_set_draw_hook(VALUE_OUTPUT a, void * d) { + reinterpret_cast<My_Value_Output*>(a)->draw_hook = reinterpret_cast<d_hook_p>(d); +} + +void fl_value_output_draw(VALUE_OUTPUT a) { + reinterpret_cast<My_Value_Output*>(a)->real_draw(); +} + +void value_output_set_handle_hook(VALUE_OUTPUT a, void * h) { + reinterpret_cast<My_Value_Output*>(a)->handle_hook = reinterpret_cast<h_hook_p>(h); +} + +int fl_value_output_handle(VALUE_OUTPUT a, int e) { + return reinterpret_cast<My_Value_Output*>(a)->real_handle(e); +} + + + + +VALUE_OUTPUT new_fl_value_output(int x, int y, int w, int h, char* label) { + My_Value_Output *a = new My_Value_Output(x, y, w, h, label); + return a; +} + +void free_fl_value_output(VALUE_OUTPUT a) { + delete reinterpret_cast<My_Value_Output*>(a); +} + + + + +int fl_value_output_is_soft(VALUE_OUTPUT a) { + return reinterpret_cast<Fl_Value_Output*>(a)->soft(); +} + +void fl_value_output_set_soft(VALUE_OUTPUT a, int t) { + reinterpret_cast<Fl_Value_Output*>(a)->soft(t); +} + + + + +unsigned int fl_value_output_get_text_color(VALUE_OUTPUT v) { + return reinterpret_cast<Fl_Value_Output*>(v)->textcolor(); +} + +void fl_value_output_set_text_color(VALUE_OUTPUT v, unsigned int c) { + reinterpret_cast<Fl_Value_Output*>(v)->textcolor(static_cast<Fl_Color>(c)); +} + +int fl_value_output_get_text_font(VALUE_OUTPUT v) { + return reinterpret_cast<Fl_Value_Output*>(v)->textfont(); +} + +void fl_value_output_set_text_font(VALUE_OUTPUT v, int f) { + reinterpret_cast<Fl_Value_Output*>(v)->textfont(static_cast<Fl_Font>(f)); +} + +int fl_value_output_get_text_size(VALUE_OUTPUT v) { + return reinterpret_cast<Fl_Value_Output*>(v)->textsize(); +} + +void fl_value_output_set_text_size(VALUE_OUTPUT v, int s) { + reinterpret_cast<Fl_Value_Output*>(v)->textsize(static_cast<Fl_Fontsize>(s)); +} + + diff --git a/src/c_fl_value_output.h b/src/c_fl_value_output.h new file mode 100644 index 0000000..62e8426 --- /dev/null +++ b/src/c_fl_value_output.h @@ -0,0 +1,41 @@ + + +#ifndef FL_VALUE_OUTPUT_GUARD +#define FL_VALUE_OUTPUT_GUARD + + + + +typedef void* VALUE_OUTPUT; + + + + +extern "C" void value_output_set_draw_hook(VALUE_OUTPUT a, void * d); +extern "C" void fl_value_output_draw(VALUE_OUTPUT a); +extern "C" void value_output_set_handle_hook(VALUE_OUTPUT a, void * h); +extern "C" int fl_value_output_handle(VALUE_OUTPUT a, int e); + + + + +extern "C" VALUE_OUTPUT new_fl_value_output(int x, int y, int w, int h, char* label); +extern "C" void free_fl_value_output(VALUE_OUTPUT a); + + + + +extern "C" int fl_value_output_is_soft(VALUE_OUTPUT a); +extern "C" void fl_value_output_set_soft(VALUE_OUTPUT a, int t); + + +extern "C" unsigned int fl_value_output_get_text_color(VALUE_OUTPUT v); +extern "C" void fl_value_output_set_text_color(VALUE_OUTPUT v, unsigned int c); +extern "C" int fl_value_output_get_text_font(VALUE_OUTPUT v); +extern "C" void fl_value_output_set_text_font(VALUE_OUTPUT v, int f); +extern "C" int fl_value_output_get_text_size(VALUE_OUTPUT v); +extern "C" void fl_value_output_set_text_size(VALUE_OUTPUT v, int s); + + +#endif + diff --git a/src/fltk-widgets-valuators-value_outputs.adb b/src/fltk-widgets-valuators-value_outputs.adb new file mode 100644 index 0000000..0330bc5 --- /dev/null +++ b/src/fltk-widgets-valuators-value_outputs.adb @@ -0,0 +1,242 @@ + + +with + + Interfaces.C.Strings, + System; + +use type + + Interfaces.C.int, + System.Address; + + +package body FLTK.Widgets.Valuators.Value_Outputs is + + + procedure value_output_set_draw_hook + (W, D : in System.Address); + pragma Import (C, value_output_set_draw_hook, "value_output_set_draw_hook"); + pragma Inline (value_output_set_draw_hook); + + procedure value_output_set_handle_hook + (W, H : in System.Address); + pragma Import (C, value_output_set_handle_hook, "value_output_set_handle_hook"); + pragma Inline (value_output_set_handle_hook); + + + + + function new_fl_value_output + (X, Y, W, H : in Interfaces.C.int; + Text : in Interfaces.C.char_array) + return System.Address; + pragma Import (C, new_fl_value_output, "new_fl_value_output"); + pragma Inline (new_fl_value_output); + + procedure free_fl_value_output + (A : in System.Address); + pragma Import (C, free_fl_value_output, "free_fl_value_output"); + pragma Inline (free_fl_value_output); + + + + + function fl_value_output_is_soft + (A : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_value_output_is_soft, "fl_value_output_is_soft"); + pragma Inline (fl_value_output_is_soft); + + procedure fl_value_output_set_soft + (A : in System.Address; + T : in Interfaces.C.int); + pragma Import (C, fl_value_output_set_soft, "fl_value_output_set_soft"); + pragma Inline (fl_value_output_set_soft); + + + + + function fl_value_output_get_text_color + (TD : in System.Address) + return Interfaces.C.unsigned; + pragma Import (C, fl_value_output_get_text_color, "fl_value_output_get_text_color"); + pragma Inline (fl_value_output_get_text_color); + + procedure fl_value_output_set_text_color + (TD : in System.Address; + C : in Interfaces.C.unsigned); + pragma Import (C, fl_value_output_set_text_color, "fl_value_output_set_text_color"); + pragma Inline (fl_value_output_set_text_color); + + function fl_value_output_get_text_font + (TD : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_value_output_get_text_font, "fl_value_output_get_text_font"); + pragma Inline (fl_value_output_get_text_font); + + procedure fl_value_output_set_text_font + (TD : in System.Address; + F : in Interfaces.C.int); + pragma Import (C, fl_value_output_set_text_font, "fl_value_output_set_text_font"); + pragma Inline (fl_value_output_set_text_font); + + function fl_value_output_get_text_size + (TD : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_value_output_get_text_size, "fl_value_output_get_text_size"); + pragma Inline (fl_value_output_get_text_size); + + procedure fl_value_output_set_text_size + (TD : in System.Address; + S : in Interfaces.C.int); + pragma Import (C, fl_value_output_set_text_size, "fl_value_output_set_text_size"); + pragma Inline (fl_value_output_set_text_size); + + + + + procedure fl_value_output_draw + (W : in System.Address); + pragma Import (C, fl_value_output_draw, "fl_value_output_draw"); + pragma Inline (fl_value_output_draw); + + function fl_value_output_handle + (W : in System.Address; + E : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_value_output_handle, "fl_value_output_handle"); + pragma Inline (fl_value_output_handle); + + + + + procedure Finalize + (This : in out Value_Output) is + begin + if This.Void_Ptr /= System.Null_Address and then + This in Value_Output'Class + then + free_fl_value_output (This.Void_Ptr); + This.Void_Ptr := System.Null_Address; + end if; + Finalize (Valuator (This)); + end Finalize; + + + + + package body Forge is + + function Create + (X, Y, W, H : in Integer; + Text : in String) + return Value_Output is + begin + return This : Value_Output do + This.Void_Ptr := new_fl_value_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)); + value_output_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); + value_output_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); + end return; + end Create; + + end Forge; + + + + + function Is_Soft + (This : in Value_Output) + return Boolean is + begin + return fl_value_output_is_soft (This.Void_Ptr) /= 0; + end Is_Soft; + + + procedure Set_Soft + (This : in out Value_Output; + To : in Boolean) is + begin + fl_value_output_set_soft (This.Void_Ptr, Boolean'Pos (To)); + end Set_Soft; + + + + + function Get_Text_Color + (This : in Value_Output) + return Color is + begin + return Color (fl_value_output_get_text_color (This.Void_Ptr)); + end Get_Text_Color; + + + procedure Set_Text_Color + (This : in out Value_Output; + Col : in Color) is + begin + fl_value_output_set_text_color (This.Void_Ptr, Interfaces.C.unsigned (Col)); + end Set_Text_Color; + + + function Get_Text_Font + (This : in Value_Output) + return Font_Kind is + begin + return Font_Kind'Val (fl_value_output_get_text_font (This.Void_Ptr)); + end Get_Text_Font; + + + procedure Set_Text_Font + (This : in out Value_Output; + Font : in Font_Kind) is + begin + fl_value_output_set_text_font (This.Void_Ptr, Font_Kind'Pos (Font)); + end Set_Text_Font; + + + function Get_Text_Size + (This : in Value_Output) + return Font_Size is + begin + return Font_Size (fl_value_output_get_text_size (This.Void_Ptr)); + end Get_Text_Size; + + + procedure Set_Text_Size + (This : in out Value_Output; + Size : in Font_Size) is + begin + fl_value_output_set_text_size (This.Void_Ptr, Interfaces.C.int (Size)); + end Set_Text_Size; + + + + + procedure Draw + (This : in out Value_Output) is + begin + fl_value_output_draw (This.Void_Ptr); + end Draw; + + + function Handle + (This : in out Value_Output; + Event : in Event_Kind) + return Event_Outcome is + begin + return Event_Outcome'Val + (fl_value_output_handle (This.Void_Ptr, Event_Kind'Pos (Event))); + end Handle; + + +end FLTK.Widgets.Valuators.Value_Outputs; + diff --git a/src/fltk-widgets-valuators-value_outputs.ads b/src/fltk-widgets-valuators-value_outputs.ads new file mode 100644 index 0000000..c935aa6 --- /dev/null +++ b/src/fltk-widgets-valuators-value_outputs.ads @@ -0,0 +1,101 @@ + + +package FLTK.Widgets.Valuators.Value_Outputs is + + + type Value_Output is new Valuator with private; + + type Value_Output_Reference (Data : not null access Value_Output'Class) is + limited null record with Implicit_Dereference => Data; + + + + + package Forge is + + function Create + (X, Y, W, H : in Integer; + Text : in String) + return Value_Output; + + end Forge; + + + + + function Is_Soft + (This : in Value_Output) + return Boolean; + + procedure Set_Soft + (This : in out Value_Output; + To : in Boolean); + + + + + function Get_Text_Color + (This : in Value_Output) + return Color; + + procedure Set_Text_Color + (This : in out Value_Output; + Col : in Color); + + function Get_Text_Font + (This : in Value_Output) + return Font_Kind; + + procedure Set_Text_Font + (This : in out Value_Output; + Font : in Font_Kind); + + function Get_Text_Size + (This : in Value_Output) + return Font_Size; + + procedure Set_Text_Size + (This : in out Value_Output; + Size : in Font_Size); + + + + + procedure Draw + (This : in out Value_Output); + + function Handle + (This : in out Value_Output; + Event : in Event_Kind) + return Event_Outcome; + + +private + + + type Value_Output is new Valuator with null record; + + overriding procedure Finalize + (This : in out Value_Output); + + + + + pragma Inline (Is_Soft); + pragma Inline (Set_Soft); + + + pragma Inline (Get_Text_Color); + pragma Inline (Set_Text_Color); + pragma Inline (Get_Text_Font); + pragma Inline (Set_Text_Font); + pragma Inline (Get_Text_Size); + pragma Inline (Set_Text_Size); + + + pragma Inline (Draw); + pragma Inline (Handle); + + +end FLTK.Widgets.Valuators.Value_Outputs; + |