From e70e81e7f08105474a01858b38a7e27d028a1972 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Thu, 3 Aug 2017 20:08:23 +1000 Subject: Added the first of event handling functions, to figure out what key was pressed --- src/c_fl_event.cpp | 10 ++++++++++ src/c_fl_event.h | 11 +++++++++++ src/fltk-event.adb | 26 ++++++++++++++++++++++++++ src/fltk-event.ads | 11 +++++++++++ src/fltk-widgets.ads | 5 ----- src/fltk.ads | 7 +++++++ 6 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 src/c_fl_event.cpp create mode 100644 src/c_fl_event.h create mode 100644 src/fltk-event.adb create mode 100644 src/fltk-event.ads diff --git a/src/c_fl_event.cpp b/src/c_fl_event.cpp new file mode 100644 index 0000000..526ed44 --- /dev/null +++ b/src/c_fl_event.cpp @@ -0,0 +1,10 @@ + + +#include +#include "c_fl_event.h" + + +int fl_event_key() { + return Fl::event_key(); +} + diff --git a/src/c_fl_event.h b/src/c_fl_event.h new file mode 100644 index 0000000..c71618e --- /dev/null +++ b/src/c_fl_event.h @@ -0,0 +1,11 @@ + + +#ifndef FL_EVENT_GUARD +#define FL_EVENT_GUARD + + +extern "C" int fl_event_key(); + + +#endif + diff --git a/src/fltk-event.adb b/src/fltk-event.adb new file mode 100644 index 0000000..a62f0ee --- /dev/null +++ b/src/fltk-event.adb @@ -0,0 +1,26 @@ + + +with + + Interfaces.C; + + +package body FLTK.Event is + + + function fl_event_key + return Interfaces.C.int; + pragma Import (C, fl_event_key, "fl_event_key"); + + + + + function Last_Keypress + return Shortcut_Key is + begin + return C_To_Key (Interfaces.C.unsigned_long (fl_event_key)); + end Last_Keypress; + + +end FLTK.Event; + diff --git a/src/fltk-event.ads b/src/fltk-event.ads new file mode 100644 index 0000000..7a640fe --- /dev/null +++ b/src/fltk-event.ads @@ -0,0 +1,11 @@ + + +package FLTK.Event is + + + function Last_Keypress + return Shortcut_Key; + + +end FLTK.Event; + diff --git a/src/fltk-widgets.ads b/src/fltk-widgets.ads index 5205106..3cea435 100644 --- a/src/fltk-widgets.ads +++ b/src/fltk-widgets.ads @@ -23,11 +23,6 @@ package FLTK.Widgets is type Widget_Callback is access procedure (Item : in out Widget'Class); - type Font_Size is new Natural; - Normal_Size : constant Font_Size := 14; - - type Event_Outcome is (Not_Handled, Handled); - diff --git a/src/fltk.ads b/src/fltk.ads index d07435e..8a6a933 100644 --- a/src/fltk.ads +++ b/src/fltk.ads @@ -144,6 +144,10 @@ package FLTK is Free_Font); + type Font_Size is new Natural; + Normal_Size : constant Font_Size := 14; + + type Label_Kind is (Normal_Label, No_Label, @@ -185,6 +189,9 @@ package FLTK is Fullscreen); + type Event_Outcome is (Not_Handled, Handled); + + private -- cgit