From ee210f26aecaaa19e991773a7be58028223d1cb8 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Fri, 18 May 2018 01:29:47 +1000 Subject: Added FLTK.Widgets.Valuators.Value_Outputs --- doc/fl_value_output.html | 176 +++++++++++++++++++ doc/index.html | 3 +- progress.txt | 1 + src/c_fl_value_output.cpp | 108 ++++++++++++ src/c_fl_value_output.h | 41 +++++ src/fltk-widgets-valuators-value_outputs.adb | 242 +++++++++++++++++++++++++++ src/fltk-widgets-valuators-value_outputs.ads | 101 +++++++++++ 7 files changed, 671 insertions(+), 1 deletion(-) create mode 100644 doc/fl_value_output.html create mode 100644 src/c_fl_value_output.cpp create mode 100644 src/c_fl_value_output.h create mode 100644 src/fltk-widgets-valuators-value_outputs.adb create mode 100644 src/fltk-widgets-valuators-value_outputs.ads diff --git a/doc/fl_value_output.html b/doc/fl_value_output.html new file mode 100644 index 0000000..3924e14 --- /dev/null +++ b/doc/fl_value_output.html @@ -0,0 +1,176 @@ + + + + + + + Fl_Value_Output Binding Map + + + + + + +

Fl_Value_Output Binding Map

+ + + + + + + + + + +
Package name
Fl_Value_OutputFLTK.Widgets.Valuators.Value_Outputs
+ + + + + + + + + + + + + + + + +
Types
Fl_Value_OutputValue_Output
 Value_Output_Reference
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Functions and Procedures
+Fl_Value_Output(int x, int y, int w, int h, const char *l=0);
+
+function Create
+       (X, Y, W, H : in Integer;
+        Text       : in String)
+    return Value_Output;
+
+void draw();
+
+procedure Draw
+       (This : in out Value_Output);
+
+int handle(int);
+
+function Handle
+       (This  : in out Value_Output;
+        Event : in     Event_Kind)
+    return Event_Outcome;
+
+void soft(char s);
+
+procedure Set_Soft
+       (This : in out Value_Output;
+        To   : in     Boolean);
+
+char soft() const;
+
+function Is_Soft
+       (This : in Value_Output)
+    return Boolean;
+
+Fl_Color textcolor() const;
+
+function Get_Text_Color
+       (This : in Value_Output)
+    return Color;
+
+void textcolor(Fl_Color n);
+
+procedure Set_Text_Color
+       (This : in out Value_Output;
+        Col  : in     Color);
+
+Fl_Font textfont() const;
+
+function Get_Text_Font
+       (This : in Value_Output)
+    return Font_Kind;
+
+void textfont(Fl_Font s);
+
+procedure Set_Text_Font
+       (This : in out Value_Output;
+        Font : in     Font_Kind);
+
+Fl_Fontsize textsize() const;
+
+function Get_Text_Size
+       (This : in Value_Output)
+    return Font_Size;
+
+void textsize(Fl_Fontsize s);
+
+procedure Set_Text_Size
+       (This : in out Value_Output;
+        Size : in     Font_Size);
+
+ + + + + diff --git a/doc/index.html b/doc/index.html index e9e3a78..1993a9a 100644 --- a/doc/index.html +++ b/doc/index.html @@ -119,7 +119,7 @@
  • Fl_Tree
  • Fl_Valuator
  • Fl_Value_Input
  • -
  • Fl_Value_Output
  • +
  • Fl_Value_Output
  • Fl_Value_Slider
  • Fl_Widget
  • Fl_Window
  • @@ -218,6 +218,7 @@
  • FLTK.Widgets.Valuators.Sliders.Value
  • FLTK.Widgets.Valuators.Sliders.Value.Horizontal
  • FLTK.Widgets.Valuators.Value_Inputs
  • +
  • FLTK.Widgets.Valuators.Value_Outputs
  • diff --git a/progress.txt b/progress.txt index b3740bd..e487fdd 100644 --- a/progress.txt +++ b/progress.txt @@ -95,6 +95,7 @@ FLTK.Widgets.Valuators.Sliders.Scrollbars FLTK.Widgets.Valuators.Sliders.Value FLTK.Widgets.Valuators.Sliders.Value.Horizontal FLTK.Widgets.Valuators.Value_Inputs +FLTK.Widgets.Valuators.Value_Outputs 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 +#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(a)->draw_hook = reinterpret_cast(d); +} + +void fl_value_output_draw(VALUE_OUTPUT a) { + reinterpret_cast(a)->real_draw(); +} + +void value_output_set_handle_hook(VALUE_OUTPUT a, void * h) { + reinterpret_cast(a)->handle_hook = reinterpret_cast(h); +} + +int fl_value_output_handle(VALUE_OUTPUT a, int e) { + return reinterpret_cast(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(a); +} + + + + +int fl_value_output_is_soft(VALUE_OUTPUT a) { + return reinterpret_cast(a)->soft(); +} + +void fl_value_output_set_soft(VALUE_OUTPUT a, int t) { + reinterpret_cast(a)->soft(t); +} + + + + +unsigned int fl_value_output_get_text_color(VALUE_OUTPUT v) { + return reinterpret_cast(v)->textcolor(); +} + +void fl_value_output_set_text_color(VALUE_OUTPUT v, unsigned int c) { + reinterpret_cast(v)->textcolor(static_cast(c)); +} + +int fl_value_output_get_text_font(VALUE_OUTPUT v) { + return reinterpret_cast(v)->textfont(); +} + +void fl_value_output_set_text_font(VALUE_OUTPUT v, int f) { + reinterpret_cast(v)->textfont(static_cast(f)); +} + +int fl_value_output_get_text_size(VALUE_OUTPUT v) { + return reinterpret_cast(v)->textsize(); +} + +void fl_value_output_set_text_size(VALUE_OUTPUT v, int s) { + reinterpret_cast(v)->textsize(static_cast(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; + -- cgit