diff options
-rw-r--r-- | c_fl_double_window.cpp | 5 | ||||
-rw-r--r-- | c_fl_double_window.h | 1 | ||||
-rw-r--r-- | c_fl_popup.cpp | 32 | ||||
-rw-r--r-- | c_fl_popup.h | 15 | ||||
-rw-r--r-- | c_fl_text_buffer.cpp | 35 | ||||
-rw-r--r-- | c_fl_text_buffer.h | 7 | ||||
-rw-r--r-- | c_fl_text_editor.cpp | 13 | ||||
-rw-r--r-- | c_fl_text_editor.h | 9 | ||||
-rw-r--r-- | c_fl_window.cpp | 10 | ||||
-rw-r--r-- | c_fl_window.h | 2 | ||||
-rw-r--r-- | fltk-popups.adb | 113 | ||||
-rw-r--r-- | fltk-popups.ads | 32 | ||||
-rw-r--r-- | fltk-text_buffers.adb | 123 | ||||
-rw-r--r-- | fltk-text_buffers.ads | 34 | ||||
-rw-r--r-- | fltk-widgets-groups-text_displays-text_editors.adb | 13 | ||||
-rw-r--r-- | fltk-widgets-groups-text_displays-text_editors.ads | 4 | ||||
-rw-r--r-- | fltk-widgets-groups-windows-double.adb | 13 | ||||
-rw-r--r-- | fltk-widgets-groups-windows-double.ads | 4 | ||||
-rw-r--r-- | fltk-widgets-groups-windows.adb | 28 | ||||
-rw-r--r-- | fltk-widgets-groups-windows.ads | 9 |
20 files changed, 492 insertions, 10 deletions
diff --git a/c_fl_double_window.cpp b/c_fl_double_window.cpp index 67d0736..7f29af8 100644 --- a/c_fl_double_window.cpp +++ b/c_fl_double_window.cpp @@ -25,3 +25,8 @@ void fl_double_window_show(DOUBLEWINDOW d) { reinterpret_cast<Fl_Double_Window*>(d)->show(); } + +void fl_double_window_hide(DOUBLEWINDOW d) { + reinterpret_cast<Fl_Double_Window*>(d)->hide(); +} + diff --git a/c_fl_double_window.h b/c_fl_double_window.h index 81b136a..3be3588 100644 --- a/c_fl_double_window.h +++ b/c_fl_double_window.h @@ -12,6 +12,7 @@ extern "C" DOUBLEWINDOW new_fl_double_window2(int w, int h); extern "C" void free_fl_double_window(DOUBLEWINDOW d); extern "C" void fl_double_window_show(DOUBLEWINDOW d); +extern "C" void fl_double_window_hide(DOUBLEWINDOW d); #endif diff --git a/c_fl_popup.cpp b/c_fl_popup.cpp new file mode 100644 index 0000000..913ec51 --- /dev/null +++ b/c_fl_popup.cpp @@ -0,0 +1,32 @@ + + +#include <FL/fl_ask.H> +#include <FL/Fl_File_Chooser.H> +#include <FL/Fl_Color_Chooser.H> +#include "c_fl_popup.h" + + +void popup_fl_alert(const char * m) { + fl_alert(m); +} + + +int popup_fl_choice(const char * m, const char * a, const char * b, const char * c) { + return fl_choice(m, a, b, c); +} + + +char * popup_fl_file_chooser(const char * m, const char * p, const char * d, int r) { + return fl_file_chooser(m, p, d, r); +} + + +const char * popup_fl_input(const char * m, const char * d) { + return fl_input(m, d); +} + + +void popup_fl_message(const char * m) { + fl_message(m); +} + diff --git a/c_fl_popup.h b/c_fl_popup.h new file mode 100644 index 0000000..ff0f9ac --- /dev/null +++ b/c_fl_popup.h @@ -0,0 +1,15 @@ + + +#ifndef FL_POPUP_GUARD +#define FL_POPUP_GUARD + + +extern "C" void popup_fl_alert(const char * m); +extern "C" int popup_fl_choice(const char * m, const char * a, const char * b, const char * c); +extern "C" char * popup_fl_file_chooser(const char * m, const char * p, const char * d, int r); +extern "C" const char * popup_fl_input(const char * m, const char * d); +extern "C" void popup_fl_message(const char * m); + + +#endif + diff --git a/c_fl_text_buffer.cpp b/c_fl_text_buffer.cpp index 0da63c2..089ca33 100644 --- a/c_fl_text_buffer.cpp +++ b/c_fl_text_buffer.cpp @@ -24,3 +24,38 @@ void fl_text_buffer_add_predelete_callback(TEXTBUFFER tb, void * cb, void * ud) reinterpret_cast<Fl_Text_Buffer*>(tb)->add_predelete_callback(reinterpret_cast<Fl_Text_Predelete_Cb>(cb), ud); } + +void fl_text_buffer_call_modify_callbacks(TEXTBUFFER tb) { + reinterpret_cast<Fl_Text_Buffer*>(tb)->call_modify_callbacks(); +} + + +void fl_text_buffer_call_predelete_callbacks(TEXTBUFFER tb) { + reinterpret_cast<Fl_Text_Buffer*>(tb)->call_predelete_callbacks(); +} + + +int fl_text_buffer_length(TEXTBUFFER tb) { + return reinterpret_cast<Fl_Text_Buffer*>(tb)->length(); +} + + +int fl_text_buffer_loadfile(TEXTBUFFER tb, char * n) { + return reinterpret_cast<Fl_Text_Buffer*>(tb)->loadfile(n); +} + + +void fl_text_buffer_remove_selection(TEXTBUFFER tb) { + reinterpret_cast<Fl_Text_Buffer*>(tb)->remove_selection(); +} + + +int fl_text_buffer_savefile(TEXTBUFFER tb, char * n) { + return reinterpret_cast<Fl_Text_Buffer*>(tb)->savefile(n); +} + + +void fl_text_buffer_select(TEXTBUFFER tb, int s, int e) { + reinterpret_cast<Fl_Text_Buffer*>(tb)->select(s, e); +} + diff --git a/c_fl_text_buffer.h b/c_fl_text_buffer.h index 8c1483e..906ef8c 100644 --- a/c_fl_text_buffer.h +++ b/c_fl_text_buffer.h @@ -13,6 +13,13 @@ extern "C" void free_fl_text_buffer(TEXTBUFFER tb); extern "C" void fl_text_buffer_add_modify_callback(TEXTBUFFER tb, void * cb, void * ud); extern "C" void fl_text_buffer_add_predelete_callback(TEXTBUFFER tb, void * cb, void * ud); +extern "C" void fl_text_buffer_call_modify_callbacks(TEXTBUFFER tb); +extern "C" void fl_text_buffer_call_predelete_callbacks(TEXTBUFFER tb); +extern "C" int fl_text_buffer_length(TEXTBUFFER tb); +extern "C" int fl_text_buffer_loadfile(TEXTBUFFER tb, char * n); +extern "C" void fl_text_buffer_remove_selection(TEXTBUFFER tb); +extern "C" int fl_text_buffer_savefile(TEXTBUFFER tb, char * n); +extern "C" void fl_text_buffer_select(TEXTBUFFER tb, int s, int e); #endif diff --git a/c_fl_text_editor.cpp b/c_fl_text_editor.cpp index 6754695..1290e7b 100644 --- a/c_fl_text_editor.cpp +++ b/c_fl_text_editor.cpp @@ -17,22 +17,27 @@ void free_fl_text_editor(TEXTEDITOR te) { -void fl_text_editor_cut (TEXTEDITOR te) { +void fl_text_editor_undo(TEXTEDITOR te) { + Fl_Text_Editor::kf_undo(0, reinterpret_cast<Fl_Text_Editor*>(te)); +} + + +void fl_text_editor_cut(TEXTEDITOR te) { Fl_Text_Editor::kf_cut(0, reinterpret_cast<Fl_Text_Editor*>(te)); } -void fl_text_editor_copy (TEXTEDITOR te) { +void fl_text_editor_copy(TEXTEDITOR te) { Fl_Text_Editor::kf_copy(0, reinterpret_cast<Fl_Text_Editor*>(te)); } -void fl_text_editor_paste (TEXTEDITOR te) { +void fl_text_editor_paste(TEXTEDITOR te) { Fl_Text_Editor::kf_paste(0, reinterpret_cast<Fl_Text_Editor*>(te)); } -void fl_text_editor_delete (TEXTEDITOR te) { +void fl_text_editor_delete(TEXTEDITOR te) { Fl_Text_Editor::kf_delete(0, reinterpret_cast<Fl_Text_Editor*>(te)); } diff --git a/c_fl_text_editor.h b/c_fl_text_editor.h index 7c7cee5..8c7dba0 100644 --- a/c_fl_text_editor.h +++ b/c_fl_text_editor.h @@ -11,10 +11,11 @@ extern "C" TEXTEDITOR new_fl_text_editor(int x, int y, int w, int h, char* label extern "C" void free_fl_text_editor(TEXTEDITOR te); -extern "C" void fl_text_editor_cut (TEXTEDITOR te); -extern "C" void fl_text_editor_copy (TEXTEDITOR te); -extern "C" void fl_text_editor_paste (TEXTEDITOR te); -extern "C" void fl_text_editor_delete (TEXTEDITOR te); +extern "C" void fl_text_editor_undo(TEXTEDITOR te); +extern "C" void fl_text_editor_cut(TEXTEDITOR te); +extern "C" void fl_text_editor_copy(TEXTEDITOR te); +extern "C" void fl_text_editor_paste(TEXTEDITOR te); +extern "C" void fl_text_editor_delete(TEXTEDITOR te); #endif diff --git a/c_fl_window.cpp b/c_fl_window.cpp index f409e34..5b2d0ff 100644 --- a/c_fl_window.cpp +++ b/c_fl_window.cpp @@ -25,3 +25,13 @@ void fl_window_show(WINDOW n) { reinterpret_cast<Fl_Window*>(n)->show(); } + +void fl_window_hide(WINDOW n) { + reinterpret_cast<Fl_Window*>(n)->hide(); +} + + +void fl_window_set_label(WINDOW n, char* text) { + reinterpret_cast<Fl_Window*>(n)->copy_label(text); +} + diff --git a/c_fl_window.h b/c_fl_window.h index 658d3ef..8d38de0 100644 --- a/c_fl_window.h +++ b/c_fl_window.h @@ -12,6 +12,8 @@ extern "C" WINDOW new_fl_window2(int w, int h); extern "C" void free_fl_window(WINDOW n); extern "C" void fl_window_show(WINDOW n); +extern "C" void fl_window_hide(WINDOW n); +extern "C" void fl_window_set_label(WINDOW n, char* text); #endif diff --git a/fltk-popups.adb b/fltk-popups.adb new file mode 100644 index 0000000..40a8d3e --- /dev/null +++ b/fltk-popups.adb @@ -0,0 +1,113 @@ + + +with Interfaces.C; +with Interfaces.C.Strings; +use type Interfaces.C.Strings.chars_ptr; + + +package body FLTK.Popups is + + + procedure popup_fl_alert + (M : in Interfaces.C.char_array); + pragma Import (C, popup_fl_alert, "popup_fl_alert"); + + function popup_fl_choice + (M, A, B, C : in Interfaces.C.char_array) + return Interfaces.C.int; + pragma Import (C, popup_fl_choice, "popup_fl_choice"); + + function popup_fl_file_chooser + (M, P, D : in Interfaces.C.char_array; + R : in Interfaces.C.int) + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, popup_fl_file_chooser, "popup_fl_file_chooser"); + + function popup_fl_input + (M, D : in Interfaces.C.char_array) + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, popup_fl_input, "popup_fl_input"); + + procedure popup_fl_message + (M : in Interfaces.C.char_array); + pragma Import (C, popup_fl_message, "popup_fl_message"); + + + + + procedure Alert + (Message : String) is + begin + popup_fl_alert (Interfaces.C.To_C (Message)); + end Alert; + + + + + function Three_Way_Choice + (Message, Button1, Button2, Button3 : in String) + return Choice is + + Result : Interfaces.C.int := popup_fl_choice + (Interfaces.C.To_C (Message), + Interfaces.C.To_C (Button1), + Interfaces.C.To_C (Button2), + Interfaces.C.To_C (Button3)); + + begin + return Choice'Val (Result); + end Three_Way_Choice; + + + + + function File_Chooser + (Message, Filter_Pattern, Default : in String; + Relative : in Boolean := False) + return String is + + Result : Interfaces.C.Strings.chars_ptr := popup_fl_file_chooser + (Interfaces.C.To_C (Message), + Interfaces.C.To_C (Filter_Pattern), + Interfaces.C.To_C (Default), + Boolean'Pos (Relative)); + + begin + if Result = Interfaces.C.Strings.Null_Ptr then + return ""; + else + return Interfaces.C.Strings.Value (Result); + end if; + end File_Chooser; + + + + + function Text_Input + (Message, Default : in String) + return String is + + Result : Interfaces.C.Strings.chars_ptr := popup_fl_input + (Interfaces.C.To_C (Message), + Interfaces.C.To_C (Default)); + + begin + if Result = Interfaces.C.Strings.Null_Ptr then + return ""; + else + return Interfaces.C.Strings.Value (Result); + end if; + end Text_Input; + + + + + procedure Message_Box + (Message : in String) is + begin + popup_fl_message (Interfaces.C.To_C (Message)); + end Message_Box; + + +end FLTK.Popups; + diff --git a/fltk-popups.ads b/fltk-popups.ads new file mode 100644 index 0000000..bee5d99 --- /dev/null +++ b/fltk-popups.ads @@ -0,0 +1,32 @@ + + +package FLTK.Popups is + + + procedure Alert + (Message : String); + + + type Choice is (First, Second, Third); + function Three_Way_Choice + (Message, Button1, Button2, Button3 : in String) + return Choice; + + + function File_Chooser + (Message, Filter_Pattern, Default : in String; + Relative : in Boolean := False) + return String; + + + function Text_Input + (Message, Default : in String) + return String; + + + procedure Message_Box + (Message : in String); + + +end FLTK.Popups; + diff --git a/fltk-text_buffers.adb b/fltk-text_buffers.adb index fa2a259..6a25399 100644 --- a/fltk-text_buffers.adb +++ b/fltk-text_buffers.adb @@ -36,6 +36,42 @@ package body FLTK.Text_Buffers is pragma Import (C, fl_text_buffer_add_predelete_callback, "fl_text_buffer_add_predelete_callback"); + procedure fl_text_buffer_call_modify_callbacks + (TB : in System.Address); + pragma Import (C, fl_text_buffer_call_modify_callbacks, + "fl_text_buffer_call_modify_callbacks"); + + procedure fl_text_buffer_call_predelete_callbacks + (TB : in System.Address); + pragma Import (C, fl_text_buffer_call_predelete_callbacks, + "fl_text_buffer_call_predelete_callbacks"); + + function fl_text_buffer_length + (TB : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_text_buffer_length, "fl_text_buffer_length"); + + function fl_text_buffer_loadfile + (TB : in System.Address; + N : in Interfaces.C.char_array) + return Interfaces.C.int; + pragma Import (C, fl_text_buffer_loadfile, "fl_text_buffer_loadfile"); + + procedure fl_text_buffer_remove_selection + (TB : in System.Address); + pragma Import (C, fl_text_buffer_remove_selection, "fl_text_buffer_remove_selection"); + + function fl_text_buffer_savefile + (TB : in System.Address; + N : in Interfaces.C.char_array) + return Interfaces.C.int; + pragma Import (C, fl_text_buffer_savefile, "fl_text_buffer_savefile"); + + procedure fl_text_buffer_select + (TB : in System.Address; + S, E : in Interfaces.C.int); + pragma Import (C, fl_text_buffer_select, "fl_text_buffer_select"); + @@ -88,7 +124,8 @@ package body FLTK.Text_Buffers is Length := Natural (Restyled); Action := Restyle; else - raise Program_Error; + Length := 0; + Action := None; end if; for CB of Ada_Text_Buffer.Modify_CBs loop @@ -171,5 +208,89 @@ package body FLTK.Text_Buffers is end Add_Predelete_Callback; + + + procedure Call_Modify_Callbacks + (This : in out Text_Buffer) is + begin + fl_text_buffer_call_modify_callbacks (This.Void_Ptr); + end Call_Modify_Callbacks; + + + + + procedure Call_Predelete_Callbacks + (This : in out Text_Buffer) is + begin + fl_text_buffer_call_predelete_callbacks (This.Void_Ptr); + end Call_Predelete_Callbacks; + + + + + function Length + (This : in Text_Buffer) + return Natural is + begin + return Natural (fl_text_buffer_length (This.Void_Ptr)); + end Length; + + + + + procedure Load_File + (This : in Text_Buffer; + Name : in String) is + + Err_No : Interfaces.C.int := fl_text_buffer_loadfile + (This.Void_Ptr, + Interfaces.C.To_C (Name)); + + begin + if Err_No /= 0 then + raise Storage_Error; + end if; + end Load_File; + + + + + procedure Remove_Selected_Text + (This : in out Text_Buffer) is + begin + fl_text_buffer_remove_selection (This.Void_Ptr); + end Remove_Selected_Text; + + + + + procedure Save_File + (This : in Text_Buffer; + Name : in String) is + + Err_No : Interfaces.C.int := fl_text_buffer_savefile + (This.Void_Ptr, + Interfaces.C.To_C (Name)); + + begin + if Err_No /= 0 then + raise Storage_Error; + end if; + end Save_File; + + + + + procedure Set_Selection + (This : in out Text_Buffer; + Start, Finish : in Natural) is + begin + fl_text_buffer_select + (This.Void_Ptr, + Interfaces.C.int (Start), + Interfaces.C.int (Finish)); + end Set_Selection; + + end FLTK.Text_Buffers; diff --git a/fltk-text_buffers.ads b/fltk-text_buffers.ads index aa6a49f..eea9b73 100644 --- a/fltk-text_buffers.ads +++ b/fltk-text_buffers.ads @@ -15,7 +15,7 @@ package FLTK.Text_Buffers is type Position is new Natural; - type Modification is (Insert, Restyle, Delete); + type Modification is (Insert, Restyle, Delete, None); type Modify_Callback is interface; procedure Call (This : in Modify_Callback; @@ -48,6 +48,38 @@ package FLTK.Text_Buffers is Func : not null access Predelete_Callback'Class); + procedure Call_Modify_Callbacks + (This : in out Text_Buffer); + + + procedure Call_Predelete_Callbacks + (This : in out Text_Buffer); + + + function Length + (This : in Text_Buffer) + return Natural; + + + procedure Load_File + (This : in Text_Buffer; + Name : in String); + + + procedure Remove_Selected_Text + (This : in out Text_Buffer); + + + procedure Save_File + (This : in Text_Buffer; + Name : in String); + + + procedure Set_Selection + (This : in out Text_Buffer; + Start, Finish : in Natural); + + private diff --git a/fltk-widgets-groups-text_displays-text_editors.adb b/fltk-widgets-groups-text_displays-text_editors.adb index 7969f27..ce7684c 100644 --- a/fltk-widgets-groups-text_displays-text_editors.adb +++ b/fltk-widgets-groups-text_displays-text_editors.adb @@ -18,6 +18,10 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is (TE : in System.Address); pragma Import (C, free_fl_text_editor, "free_fl_text_editor"); + procedure fl_text_editor_undo + (TE : in System.Address); + pragma Import (C, fl_text_editor_undo, "fl_text_editor_undo"); + procedure fl_text_editor_cut (TE : in System.Address); pragma Import (C, fl_text_editor_cut, "fl_text_editor_cut"); @@ -73,6 +77,15 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is + procedure Undo + (This : in out Text_Editor) is + begin + fl_text_editor_undo (This.Void_Ptr); + end Undo; + + + + procedure Cut (This : in out Text_Editor) is begin diff --git a/fltk-widgets-groups-text_displays-text_editors.ads b/fltk-widgets-groups-text_displays-text_editors.ads index 37e5464..5e3ff01 100644 --- a/fltk-widgets-groups-text_displays-text_editors.ads +++ b/fltk-widgets-groups-text_displays-text_editors.ads @@ -12,6 +12,10 @@ package FLTK.Widgets.Groups.Text_Displays.Text_Editors is return Text_Editor; + procedure Undo + (This : in out Text_Editor); + + procedure Cut (This : in out Text_Editor); diff --git a/fltk-widgets-groups-windows-double.adb b/fltk-widgets-groups-windows-double.adb index a6a8a83..407c018 100644 --- a/fltk-widgets-groups-windows-double.adb +++ b/fltk-widgets-groups-windows-double.adb @@ -27,6 +27,10 @@ package body FLTK.Widgets.Groups.Windows.Double is (W : in System.Address); pragma Import (C, fl_double_window_show, "fl_double_window_show"); + procedure fl_double_window_hide + (W : in System.Address); + pragma Import (C, fl_double_window_hide, "fl_double_window_hide"); + @@ -91,5 +95,14 @@ package body FLTK.Widgets.Groups.Windows.Double is end Show; + + + procedure Hide + (This : in Double_Window) is + begin + fl_double_window_hide (This.Void_Ptr); + end Hide; + + end FLTK.Widgets.Groups.Windows.Double; diff --git a/fltk-widgets-groups-windows-double.ads b/fltk-widgets-groups-windows-double.ads index 20b5362..214f698 100644 --- a/fltk-widgets-groups-windows-double.ads +++ b/fltk-widgets-groups-windows-double.ads @@ -21,6 +21,10 @@ package FLTK.Widgets.Groups.Windows.Double is (This : in Double_Window); + procedure Hide + (This : in Double_Window); + + private diff --git a/fltk-widgets-groups-windows.adb b/fltk-widgets-groups-windows.adb index 1c29f9b..4ecda66 100644 --- a/fltk-widgets-groups-windows.adb +++ b/fltk-widgets-groups-windows.adb @@ -27,6 +27,15 @@ package body FLTK.Widgets.Groups.Windows is (W : in System.Address); pragma Import (C, fl_window_show, "fl_window_show"); + procedure fl_window_hide + (W : in System.Address); + pragma Import (C, fl_window_hide, "fl_window_hide"); + + procedure fl_window_set_label + (W : in System.Address; + T : in Interfaces.C.char_array); + pragma Import (C, fl_window_set_label, "fl_window_set_label"); + @@ -91,5 +100,24 @@ package body FLTK.Widgets.Groups.Windows is end Show; + + + procedure Hide + (This : in Window) is + begin + fl_window_hide (This.Void_Ptr); + end Hide; + + + + + procedure Set_Label + (This : in out Window; + Text : in String) is + begin + fl_window_set_label (This.Void_Ptr, Interfaces.C.To_C (Text)); + end Set_Label; + + end FLTK.Widgets.Groups.Windows; diff --git a/fltk-widgets-groups-windows.ads b/fltk-widgets-groups-windows.ads index 54d855f..0999b21 100644 --- a/fltk-widgets-groups-windows.ads +++ b/fltk-widgets-groups-windows.ads @@ -21,6 +21,15 @@ package FLTK.Widgets.Groups.Windows is (This : in Window); + procedure Hide + (This : in Window); + + + procedure Set_Label + (This : in out Window; + Text : in String); + + private |