diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2024-12-09 02:22:17 +1300 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2024-12-09 02:22:17 +1300 |
commit | 98abc141c9cb76bc12f8ba10f18fd87e32aae251 (patch) | |
tree | 853bd986842a3d9b2c1d84f7f60c13216fd90f41 /src | |
parent | df63542510b6912405f3709b204ad3a59548c917 (diff) |
Fl_File_Chooser bound
Diffstat (limited to 'src')
-rw-r--r-- | src/c_fl_file_chooser.cpp | 320 | ||||
-rw-r--r-- | src/c_fl_file_chooser.h | 102 | ||||
-rw-r--r-- | src/fltk-file_choosers.adb | 1210 | ||||
-rw-r--r-- | src/fltk-file_choosers.ads | 401 | ||||
-rw-r--r-- | src/fltk-widgets.ads | 4 |
5 files changed, 2037 insertions, 0 deletions
diff --git a/src/c_fl_file_chooser.cpp b/src/c_fl_file_chooser.cpp new file mode 100644 index 0000000..4cf3e8e --- /dev/null +++ b/src/c_fl_file_chooser.cpp @@ -0,0 +1,320 @@ + + +// Programmed by Jedidiah Barber +// Released into the public domain + + +#include <FL/Fl_File_Chooser.H> +#include <FL/Fl_Widget.H> +#include "c_fl_file_chooser.h" + + + + +// Flattened C API begins here + +FILECHOOSER new_fl_file_chooser(const char * n, const char * p, int k, const char * t) { + Fl_File_Chooser *f = new Fl_File_Chooser(n, p, k, t); + return f; +} + +void free_fl_file_chooser(FILECHOOSER f) { + delete reinterpret_cast<Fl_File_Chooser*>(f); +} + + + + +void * fl_file_chooser_get_user_data(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->user_data(); +} + +void fl_file_chooser_set_user_data(FILECHOOSER f, void * ud) { + reinterpret_cast<Fl_File_Chooser*>(f)->user_data(ud); +} + + + + +void * fl_file_chooser_newbutton(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->newButton; +} + +void * fl_file_chooser_previewbutton(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->previewButton; +} + +void * fl_file_chooser_showhiddenbutton(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->showHiddenButton; +} + + + + +const char * fl_file_chooser_get_add_favorites_label() { + return Fl_File_Chooser::add_favorites_label; +} + +void fl_file_chooser_set_add_favorites_label(const char * s) { + Fl_File_Chooser::add_favorites_label = s; +} + +const char * fl_file_chooser_get_all_files_label() { + return Fl_File_Chooser::all_files_label; +} + +void fl_file_chooser_set_all_files_label(const char * s) { + Fl_File_Chooser::all_files_label = s; +} + +const char * fl_file_chooser_get_custom_filter_label() { + return Fl_File_Chooser::custom_filter_label; +} + +void fl_file_chooser_set_custom_filter_label(const char * s) { + Fl_File_Chooser::custom_filter_label = s; +} + +const char * fl_file_chooser_get_existing_file_label() { + return Fl_File_Chooser::existing_file_label; +} + +void fl_file_chooser_set_existing_file_label(const char * s) { + Fl_File_Chooser::existing_file_label = s; +} + +const char * fl_file_chooser_get_favorites_label() { + return Fl_File_Chooser::favorites_label; +} + +void fl_file_chooser_set_favorites_label(const char * s) { + Fl_File_Chooser::favorites_label = s; +} + +const char * fl_file_chooser_get_filename_label() { + return Fl_File_Chooser::filename_label; +} + +void fl_file_chooser_set_filename_label(const char * s) { + Fl_File_Chooser::filename_label = s; +} + +const char * fl_file_chooser_get_filesystems_label() { + return Fl_File_Chooser::filesystems_label; +} + +void fl_file_chooser_set_filesystems_label(const char * s) { + Fl_File_Chooser::filesystems_label = s; +} + +const char * fl_file_chooser_get_hidden_label() { + return Fl_File_Chooser::hidden_label; +} + +void fl_file_chooser_set_hidden_label(const char * s) { + Fl_File_Chooser::hidden_label = s; +} + +const char * fl_file_chooser_get_manage_favorites_label() { + return Fl_File_Chooser::manage_favorites_label; +} + +void fl_file_chooser_set_manage_favorites_label(const char * s) { + Fl_File_Chooser::manage_favorites_label = s; +} + +const char * fl_file_chooser_get_new_directory_label() { + return Fl_File_Chooser::new_directory_label; +} + +void fl_file_chooser_set_new_directory_label(const char * s) { + Fl_File_Chooser::new_directory_label = s; +} + +const char * fl_file_chooser_get_new_directory_tooltip() { + return Fl_File_Chooser::new_directory_tooltip; +} + +void fl_file_chooser_set_new_directory_tooltip(const char * s) { + Fl_File_Chooser::new_directory_tooltip = s; +} + +const char * fl_file_chooser_get_preview_label() { + return Fl_File_Chooser::preview_label; +} + +void fl_file_chooser_set_preview_label(const char * s) { + Fl_File_Chooser::preview_label = s; +} + +const char * fl_file_chooser_get_save_label() { + return Fl_File_Chooser::save_label; +} + +void fl_file_chooser_set_save_label(const char * s) { + Fl_File_Chooser::save_label = s; +} + +const char * fl_file_chooser_get_show_label() { + return Fl_File_Chooser::show_label; +} + +void fl_file_chooser_set_show_label(const char * s) { + Fl_File_Chooser::show_label = s; +} + + + + +void * fl_file_chooser_add_extra(FILECHOOSER f, void * w) { + return reinterpret_cast<Fl_File_Chooser*>(f)->add_extra(reinterpret_cast<Fl_Widget*>(w)); +} + +typedef void (*Chooser_Callback)(Fl_File_Chooser *, void *); + +void fl_file_chooser_callback(FILECHOOSER f, void * c, void * u) { + reinterpret_cast<Fl_File_Chooser*>(f)->callback(reinterpret_cast<Chooser_Callback>(c), u); +} + + + + +unsigned int fl_file_chooser_get_color(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->color(); +} + +void fl_file_chooser_set_color(FILECHOOSER f, unsigned int c) { + reinterpret_cast<Fl_File_Chooser*>(f)->color(c); +} + +unsigned char fl_file_chooser_get_iconsize(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->iconsize(); +} + +void fl_file_chooser_set_iconsize(FILECHOOSER f, unsigned char i) { + reinterpret_cast<Fl_File_Chooser*>(f)->iconsize(i); +} + +const char * fl_file_chooser_get_label(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->label(); +} + +void fl_file_chooser_set_label(FILECHOOSER f, const char * t) { + reinterpret_cast<Fl_File_Chooser*>(f)->label(t); +} + +const char * fl_file_chooser_get_ok_label(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->ok_label(); +} + +void fl_file_chooser_set_ok_label(FILECHOOSER f, const char * t) { + reinterpret_cast<Fl_File_Chooser*>(f)->ok_label(t); +} + +int fl_file_chooser_get_preview(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->preview(); +} + +void fl_file_chooser_set_preview(FILECHOOSER f, int p) { + reinterpret_cast<Fl_File_Chooser*>(f)->preview(p); +} + +unsigned int fl_file_chooser_get_textcolor(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->textcolor(); +} + +void fl_file_chooser_set_textcolor(FILECHOOSER f, unsigned int c) { + reinterpret_cast<Fl_File_Chooser*>(f)->textcolor(c); +} + +int fl_file_chooser_get_textfont(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->textfont(); +} + +void fl_file_chooser_set_textfont(FILECHOOSER f, int n) { + reinterpret_cast<Fl_File_Chooser*>(f)->textfont(n); +} + +int fl_file_chooser_get_textsize(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->textsize(); +} + +void fl_file_chooser_set_textsize(FILECHOOSER f, int s) { + reinterpret_cast<Fl_File_Chooser*>(f)->textsize(s); +} + +int fl_file_chooser_get_type(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->type(); +} + +void fl_file_chooser_set_type(FILECHOOSER f, int t) { + reinterpret_cast<Fl_File_Chooser*>(f)->type(t); +} + + + + +int fl_file_chooser_count(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->count(); +} + +const char * fl_file_chooser_get_directory(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->directory(); +} + +void fl_file_chooser_set_directory(FILECHOOSER f, const char * v) { + reinterpret_cast<Fl_File_Chooser*>(f)->directory(v); +} + +const char * fl_file_chooser_get_filter(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->filter(); +} + +void fl_file_chooser_set_filter(FILECHOOSER f, const char * v) { + reinterpret_cast<Fl_File_Chooser*>(f)->filter(v); +} + +int fl_file_chooser_get_filter_value(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->filter_value(); +} + +void fl_file_chooser_set_filter_value(FILECHOOSER f, int v) { + reinterpret_cast<Fl_File_Chooser*>(f)->filter_value(v); +} + +void fl_file_chooser_rescan(FILECHOOSER f) { + reinterpret_cast<Fl_File_Chooser*>(f)->rescan(); +} + +void fl_file_chooser_rescan_keep_filename(FILECHOOSER f) { + reinterpret_cast<Fl_File_Chooser*>(f)->rescan_keep_filename(); +} + +const char * fl_file_chooser_get_value(FILECHOOSER f, int n) { + return reinterpret_cast<Fl_File_Chooser*>(f)->value(n); +} + +void fl_file_chooser_set_value(FILECHOOSER f, const char * v) { + reinterpret_cast<Fl_File_Chooser*>(f)->value(v); +} + + + + +void fl_file_chooser_show(FILECHOOSER f) { + reinterpret_cast<Fl_File_Chooser*>(f)->show(); +} + +void fl_file_chooser_hide(FILECHOOSER f) { + reinterpret_cast<Fl_File_Chooser*>(f)->hide(); +} + +int fl_file_chooser_shown(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->shown(); +} + +int fl_file_chooser_visible(FILECHOOSER f) { + return reinterpret_cast<Fl_File_Chooser*>(f)->visible(); +} + + diff --git a/src/c_fl_file_chooser.h b/src/c_fl_file_chooser.h new file mode 100644 index 0000000..34ea5dd --- /dev/null +++ b/src/c_fl_file_chooser.h @@ -0,0 +1,102 @@ + + +// Programmed by Jedidiah Barber +// Released into the public domain + + +#ifndef FL_FILE_CHOOSER_GUARD +#define FL_FILE_CHOOSER_GUARD + + +typedef void* FILECHOOSER; + + +extern "C" FILECHOOSER new_fl_file_chooser(const char * n, const char * p, int k, const char * t); +extern "C" void free_fl_file_chooser(FILECHOOSER f); + + +extern "C" void * fl_file_chooser_get_user_data(FILECHOOSER f); +extern "C" void fl_file_chooser_set_user_data(FILECHOOSER f, void * ud); + + +extern "C" void * fl_file_chooser_newbutton(FILECHOOSER f); +extern "C" void * fl_file_chooser_previewbutton(FILECHOOSER f); +extern "C" void * fl_file_chooser_showhiddenbutton(FILECHOOSER f); + + +extern "C" const char * fl_file_chooser_get_add_favorites_label(); +extern "C" void fl_file_chooser_set_add_favorites_label(const char * s); +extern "C" const char * fl_file_chooser_get_all_files_label(); +extern "C" void fl_file_chooser_set_all_file_label(const char * s); +extern "C" const char * fl_file_chooser_get_custom_filter_label(); +extern "C" void fl_file_chooser_set_custom_filter_label(const char * s); +extern "C" const char * fl_file_chooser_get_existing_file_label(); +extern "C" void fl_file_chooser_set_existing_file_label(const char * s); +extern "C" const char * fl_file_chooser_get_favorites_label(); +extern "C" void fl_file_chooser_set_favorites_label(const char * s); +extern "C" const char * fl_file_chooser_get_filename_label(); +extern "C" void fl_file_chooser_set_filename_label(const char * s); +extern "C" const char * fl_file_chooser_get_filesystems_label(); +extern "C" void fl_file_chooser_set_filesystems_label(const char * s); +extern "C" const char * fl_file_chooser_get_hidden_label(); +extern "C" void fl_file_chooser_set_hidden_label(const char * s); +extern "C" const char * fl_file_chooser_get_manage_favorites_label(); +extern "C" void fl_file_chooser_set_manage_favorites_label(const char * s); +extern "C" const char * fl_file_chooser_get_new_directory_label(); +extern "C" void fl_file_chooser_set_new_directory_label(const char * s); +extern "C" const char * fl_file_chooser_get_new_directory_tooltip(); +extern "C" void fl_file_chooser_set_new_directory_tooltip(const char * s); +extern "C" const char * fl_file_chooser_get_preview_label(); +extern "C" void fl_file_chooser_set_preview_label(const char * s); +extern "C" const char * fl_file_chooser_get_save_label(); +extern "C" void fl_file_chooser_set_save_label(const char * s); +extern "C" const char * fl_file_chooser_get_show_label(); +extern "C" void fl_file_chooser_set_show_label(const char * s); + + +extern "C" void * fl_file_chooser_add_extra(FILECHOOSER f, void * w); +extern "C" void fl_file_chooser_callback(FILECHOOSER f, void * c, void * u); + + +extern "C" unsigned int fl_file_chooser_get_color(FILECHOOSER f); +extern "C" void fl_file_chooser_set_color(FILECHOOSER f, unsigned int c); +extern "C" unsigned char fl_file_chooser_get_iconsize(FILECHOOSER f); +extern "C" void fl_file_chooser_set_iconsize(FILECHOOSER f, unsigned char i); +extern "C" const char * fl_file_chooser_get_label(FILECHOOSER f); +extern "C" void fl_file_chooser_set_label(FILECHOOSER f, const char * t); +extern "C" const char * fl_file_chooser_get_ok_label(FILECHOOSER f); +extern "C" void fl_file_chooser_set_ok_label(FILECHOOSER f, const char * t); +extern "C" int fl_file_chooser_get_preview(FILECHOOSER f); +extern "C" void fl_file_chooser_set_preview(FILECHOOSER f, int p); +extern "C" unsigned int fl_file_chooser_get_textcolor(FILECHOOSER f); +extern "C" void fl_file_chooser_set_textcolor(FILECHOOSER f, unsigned int c); +extern "C" int fl_file_chooser_get_textfont(FILECHOOSER f); +extern "C" void fl_file_chooser_set_textfont(FILECHOOSER f, int n); +extern "C" int fl_file_chooser_get_textsize(FILECHOOSER f); +extern "C" void fl_file_chooser_set_textsize(FILECHOOSER f, int s); +extern "C" int fl_file_chooser_get_type(FILECHOOSER f); +extern "C" void fl_file_chooser_set_type(FILECHOOSER f, int t); + + +extern "C" int fl_file_chooser_count(FILECHOOSER f); +extern "C" const char * fl_file_chooser_get_directory(FILECHOOSER f); +extern "C" void fl_file_chooser_set_directory(FILECHOOSER f, const char * v); +extern "C" const char * fl_file_chooser_get_filter(FILECHOOSER f); +extern "C" void fl_file_chooser_set_filter(FILECHOOSER f, const char * v); +extern "C" int fl_file_chooser_get_filter_value(FILECHOOSER f); +extern "C" void fl_file_chooser_set_filter_value(FILECHOOSER f, int v); +extern "C" void fl_file_chooser_rescan(FILECHOOSER f); +extern "C" void fl_file_chooser_rescan_keep_filename(FILECHOOSER f); +extern "C" const char * fl_file_chooser_get_value(FILECHOOSER f, int n); +extern "C" void fl_file_chooser_set_value(FILECHOOSER f, const char * v); + + +extern "C" void fl_file_chooser_show(FILECHOOSER f); +extern "C" void fl_file_chooser_hide(FILECHOOSER f); +extern "C" int fl_file_chooser_shown(FILECHOOSER f); +extern "C" int fl_file_chooser_visible(FILECHOOSER f); + + +#endif + + diff --git a/src/fltk-file_choosers.adb b/src/fltk-file_choosers.adb new file mode 100644 index 0000000..5363c51 --- /dev/null +++ b/src/fltk-file_choosers.adb @@ -0,0 +1,1210 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +with + + Interfaces.C.Strings, + System.Address_To_Access_Conversions; + +use type + + Interfaces.C.int, + Interfaces.C.Strings.chars_ptr; + + +package body FLTK.File_Choosers is + + + package File_Chooser_Convert is new System.Address_To_Access_Conversions (File_Chooser'Class); + package Widget_Convert is new System.Address_To_Access_Conversions (Widgets.Widget'Class); + + + + + ------------------------ + -- Functions From C -- + ------------------------ + + procedure fl_widget_set_user_data + (W, D : in Storage.Integer_Address); + pragma Import (C, fl_widget_set_user_data, "fl_widget_set_user_data"); + pragma Inline (fl_widget_set_user_data); + + function fl_file_chooser_get_user_data + (F : in Storage.Integer_Address) + return Storage.Integer_Address; + pragma Import (C, fl_file_chooser_get_user_data, "fl_file_chooser_get_user_data"); + pragma Inline (fl_file_chooser_get_user_data); + + procedure fl_file_chooser_set_user_data + (F, U : in Storage.Integer_Address); + pragma Import (C, fl_file_chooser_set_user_data, "fl_file_chooser_set_user_data"); + pragma Inline (fl_file_chooser_set_user_data); + + + + + function new_fl_file_chooser + (N, P : in Interfaces.C.char_array; + K : in Interfaces.C.int; + T : in Interfaces.C.char_array) + return Storage.Integer_Address; + pragma Import (C, new_fl_file_chooser, "new_fl_file_chooser"); + pragma Inline (new_fl_file_chooser); + + procedure free_fl_file_chooser + (F : in Storage.Integer_Address); + pragma Import (C, free_fl_file_chooser, "free_fl_file_chooser"); + pragma Inline (free_fl_file_chooser); + + + + + function fl_file_chooser_newbutton + (F : in Storage.Integer_Address) + return Storage.Integer_Address; + pragma Import (C, fl_file_chooser_newbutton, "fl_file_chooser_newbutton"); + pragma Inline (fl_file_chooser_newbutton); + + function fl_file_chooser_previewbutton + (F : in Storage.Integer_Address) + return Storage.Integer_Address; + pragma Import (C, fl_file_chooser_previewbutton, "fl_file_chooser_previewbutton"); + pragma Inline (fl_file_chooser_previewbutton); + + function fl_file_chooser_showhiddenbutton + (F : in Storage.Integer_Address) + return Storage.Integer_Address; + pragma Import (C, fl_file_chooser_showhiddenbutton, "fl_file_chooser_showhiddenbutton"); + pragma Inline (fl_file_chooser_showhiddenbutton); + + + + + function fl_file_chooser_get_add_favorites_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_add_favorites_label, + "fl_file_chooser_get_add_favorites_label"); + pragma Inline (fl_file_chooser_get_add_favorites_label); + + procedure fl_file_chooser_set_add_favorites_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_add_favorites_label, + "fl_file_chooser_set_add_favorites_label"); + pragma Inline (fl_file_chooser_set_add_favorites_label); + + function fl_file_chooser_get_all_files_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_all_files_label, "fl_file_chooser_get_all_files_label"); + pragma Inline (fl_file_chooser_get_all_files_label); + + procedure fl_file_chooser_set_all_files_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_all_files_label, "fl_file_chooser_set_all_files_label"); + pragma Inline (fl_file_chooser_set_all_files_label); + + function fl_file_chooser_get_custom_filter_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_custom_filter_label, + "fl_file_chooser_get_custom_filter_label"); + pragma Inline (fl_file_chooser_get_custom_filter_label); + + procedure fl_file_chooser_set_custom_filter_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_custom_filter_label, + "fl_file_chooser_set_custom_filter_label"); + pragma Inline (fl_file_chooser_set_custom_filter_label); + + function fl_file_chooser_get_existing_file_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_existing_file_label, + "fl_file_chooser_get_existing_file_label"); + pragma Inline (fl_file_chooser_get_existing_file_label); + + procedure fl_file_chooser_set_existing_file_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_existing_file_label, + "fl_file_chooser_set_existing_file_label"); + pragma Inline (fl_file_chooser_set_existing_file_label); + + function fl_file_chooser_get_favorites_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_favorites_label, "fl_file_chooser_get_favorites_label"); + pragma Inline (fl_file_chooser_get_favorites_label); + + procedure fl_file_chooser_set_favorites_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_favorites_label, "fl_file_chooser_set_favorites_label"); + pragma Inline (fl_file_chooser_set_favorites_label); + + function fl_file_chooser_get_filename_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_filename_label, "fl_file_chooser_get_filename_label"); + pragma Inline (fl_file_chooser_get_filename_label); + + procedure fl_file_chooser_set_filename_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_filename_label, "fl_file_chooser_set_filename_label"); + pragma Inline (fl_file_chooser_set_filename_label); + + function fl_file_chooser_get_filesystems_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_filesystems_label, + "fl_file_chooser_get_filesystems_label"); + pragma Inline (fl_file_chooser_get_filesystems_label); + + procedure fl_file_chooser_set_filesystems_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_filesystems_label, + "fl_file_chooser_set_filesystems_label"); + pragma Inline (fl_file_chooser_set_filesystems_label); + + function fl_file_chooser_get_hidden_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_hidden_label, "fl_file_chooser_get_hidden_label"); + pragma Inline (fl_file_chooser_get_hidden_label); + + procedure fl_file_chooser_set_hidden_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_hidden_label, "fl_file_chooser_set_hidden_label"); + pragma Inline (fl_file_chooser_set_hidden_label); + + function fl_file_chooser_get_manage_favorites_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_manage_favorites_label, + "fl_file_chooser_get_manage_favorites_label"); + pragma Inline (fl_file_chooser_get_manage_favorites_label); + + procedure fl_file_chooser_set_manage_favorites_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_manage_favorites_label, + "fl_file_chooser_set_manage_favorites_label"); + pragma Inline (fl_file_chooser_set_manage_favorites_label); + + function fl_file_chooser_get_new_directory_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_new_directory_label, + "fl_file_chooser_get_new_directory_label"); + pragma Inline (fl_file_chooser_get_new_directory_label); + + procedure fl_file_chooser_set_new_directory_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_new_directory_label, + "fl_file_chooser_set_new_directory_label"); + pragma Inline (fl_file_chooser_set_new_directory_label); + + function fl_file_chooser_get_new_directory_tooltip + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_new_directory_tooltip, + "fl_file_chooser_get_new_directory_tooltip"); + pragma Inline (fl_file_chooser_get_new_directory_tooltip); + + procedure fl_file_chooser_set_new_directory_tooltip + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_new_directory_tooltip, + "fl_file_chooser_set_new_directory_tooltip"); + pragma Inline (fl_file_chooser_set_new_directory_tooltip); + + function fl_file_chooser_get_preview_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_preview_label, "fl_file_chooser_get_preview_label"); + pragma Inline (fl_file_chooser_get_preview_label); + + procedure fl_file_chooser_set_preview_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_preview_label, "fl_file_chooser_set_preview_label"); + pragma Inline (fl_file_chooser_set_preview_label); + + function fl_file_chooser_get_save_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_save_label, "fl_file_chooser_get_save_label"); + pragma Inline (fl_file_chooser_get_save_label); + + procedure fl_file_chooser_set_save_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_save_label, "fl_file_chooser_set_save_label"); + pragma Inline (fl_file_chooser_set_save_label); + + function fl_file_chooser_get_show_label + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_show_label, "fl_file_chooser_get_show_label"); + pragma Inline (fl_file_chooser_get_show_label); + + procedure fl_file_chooser_set_show_label + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_show_label, "fl_file_chooser_set_show_label"); + pragma Inline (fl_file_chooser_set_show_label); + + + + + function fl_file_chooser_add_extra + (F, W : in Storage.Integer_Address) + return Storage.Integer_Address; + pragma Import (C, fl_file_chooser_add_extra, "fl_file_chooser_add_extra"); + pragma Inline (fl_file_chooser_add_extra); + + procedure fl_file_chooser_callback + (F, C, U : in Storage.Integer_Address); + pragma Import (C, fl_file_chooser_callback, "fl_file_chooser_callback"); + pragma Inline (fl_file_chooser_callback); + + + + + function fl_file_chooser_get_color + (F : in Storage.Integer_Address) + return Interfaces.C.unsigned; + pragma Import (C, fl_file_chooser_get_color, "fl_file_chooser_get_color"); + pragma Inline (fl_file_chooser_get_color); + + procedure fl_file_chooser_set_color + (F : in Storage.Integer_Address; + V : in Interfaces.C.unsigned); + pragma Import (C, fl_file_chooser_set_color, "fl_file_chooser_set_color"); + pragma Inline (fl_file_chooser_set_color); + + function fl_file_chooser_get_iconsize + (F : in Storage.Integer_Address) + return Interfaces.C.unsigned_char; + pragma Import (C, fl_file_chooser_get_iconsize, "fl_file_chooser_get_iconsize"); + pragma Inline (fl_file_chooser_get_iconsize); + + procedure fl_file_chooser_set_iconsize + (F : in Storage.Integer_Address; + V : in Interfaces.C.unsigned_char); + pragma Import (C, fl_file_chooser_set_iconsize, "fl_file_chooser_set_iconsize"); + pragma Inline (fl_file_chooser_set_iconsize); + + function fl_file_chooser_get_label + (F : in Storage.Integer_Address) + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_label, "fl_file_chooser_get_label"); + pragma Inline (fl_file_chooser_get_label); + + procedure fl_file_chooser_set_label + (F : in Storage.Integer_Address; + V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_label, "fl_file_chooser_set_label"); + pragma Inline (fl_file_chooser_set_label); + + function fl_file_chooser_get_ok_label + (F : in Storage.Integer_Address) + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_ok_label, "fl_file_chooser_get_ok_label"); + pragma Inline (fl_file_chooser_get_ok_label); + + procedure fl_file_chooser_set_ok_label + (F : in Storage.Integer_Address; + V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_ok_label, "fl_file_chooser_set_ok_label"); + pragma Inline (fl_file_chooser_set_ok_label); + + function fl_file_chooser_get_preview + (F : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_file_chooser_get_preview, "fl_file_chooser_get_preview"); + pragma Inline (fl_file_chooser_get_preview); + + procedure fl_file_chooser_set_preview + (F : in Storage.Integer_Address; + V : in Interfaces.C.int); + pragma Import (C, fl_file_chooser_set_preview, "fl_file_chooser_set_preview"); + pragma Inline (fl_file_chooser_set_preview); + + function fl_file_chooser_get_textcolor + (F : in Storage.Integer_Address) + return Interfaces.C.unsigned; + pragma Import (C, fl_file_chooser_get_textcolor, "fl_file_chooser_get_textcolor"); + pragma Inline (fl_file_chooser_get_textcolor); + + procedure fl_file_chooser_set_textcolor + (F : in Storage.Integer_Address; + V : in Interfaces.C.unsigned); + pragma Import (C, fl_file_chooser_set_textcolor, "fl_file_chooser_set_textcolor"); + pragma Inline (fl_file_chooser_set_textcolor); + + function fl_file_chooser_get_textfont + (F : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_file_chooser_get_textfont, "fl_file_chooser_get_textfont"); + pragma Inline (fl_file_chooser_get_textfont); + + procedure fl_file_chooser_set_textfont + (F : in Storage.Integer_Address; + V : in Interfaces.C.int); + pragma Import (C, fl_file_chooser_set_textfont, "fl_file_chooser_set_textfont"); + pragma Inline (fl_file_chooser_set_textfont); + + function fl_file_chooser_get_textsize + (F : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_file_chooser_get_textsize, "fl_file_chooser_get_textsize"); + pragma Inline (fl_file_chooser_get_textsize); + + procedure fl_file_chooser_set_textsize + (F : in Storage.Integer_Address; + V : in Interfaces.C.int); + pragma Import (C, fl_file_chooser_set_textsize, "fl_file_chooser_set_textsize"); + pragma Inline (fl_file_chooser_set_textsize); + + function fl_file_chooser_get_type + (F : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_file_chooser_get_type, "fl_file_chooser_get_type"); + pragma Inline (fl_file_chooser_get_type); + + procedure fl_file_chooser_set_type + (F : in Storage.Integer_Address; + V : in Interfaces.C.int); + pragma Import (C, fl_file_chooser_set_type, "fl_file_chooser_set_type"); + pragma Inline (fl_file_chooser_set_type); + + + + + function fl_file_chooser_count + (F : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_file_chooser_count, "fl_file_chooser_count"); + pragma Inline (fl_file_chooser_count); + + function fl_file_chooser_get_directory + (F : in Storage.Integer_Address) + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_directory, "fl_file_chooser_get_directory"); + pragma Inline (fl_file_chooser_get_directory); + + procedure fl_file_chooser_set_directory + (F : in Storage.Integer_Address; + V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_directory, "fl_file_chooser_set_directory"); + pragma Inline (fl_file_chooser_set_directory); + + function fl_file_chooser_get_filter + (F : in Storage.Integer_Address) + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_filter, "fl_file_chooser_get_filter"); + pragma Inline (fl_file_chooser_get_filter); + + procedure fl_file_chooser_set_filter + (F : in Storage.Integer_Address; + V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_file_chooser_set_filter, "fl_file_chooser_set_filter"); + pragma Inline (fl_file_chooser_set_filter); + + function fl_file_chooser_get_filter_value + (F : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_file_chooser_get_filter_value, "fl_file_chooser_get_filter_value"); + pragma Inline (fl_file_chooser_get_filter_value); + + procedure fl_file_chooser_set_filter_value + (F : in Storage.Integer_Address; + V : in Interfaces.C.int); + pragma Import (C, fl_file_chooser_set_filter_value, "fl_file_chooser_set_filter_value"); + pragma Inline (fl_file_chooser_set_filter_value); + + procedure fl_file_chooser_rescan + (F : in Storage.Integer_Address); + pragma Import (C, fl_file_chooser_rescan, "fl_file_chooser_rescan"); + pragma Inline (fl_file_chooser_rescan); + + procedure fl_file_chooser_rescan_keep_filename + (F : in Storage.Integer_Address); + pragma Import (C, fl_file_chooser_rescan_keep_filename, "fl_file_chooser_rescan_keep_filename"); + pragma Inline (fl_file_chooser_rescan_keep_filename); + + function fl_file_chooser_get_value + (F : in Storage.Integer_Address; + N : in Interfaces.C.int) + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_file_chooser_get_value, "fl_file_chooser_get_value"); + pragma Inline (fl_file_chooser_get_value); + + procedure fl_file_chooser_set_value + (F : in Storage.Integer_Address; + V : in Interfaces.C.char_array); + pragma Import (C, fl_file_chooser_set_value, "fl_file_chooser_set_value"); + pragma Inline (fl_file_chooser_set_value); + + + + + procedure fl_file_chooser_show + (F : in Storage.Integer_Address); + pragma Import (C, fl_file_chooser_show, "fl_file_chooser_show"); + pragma Inline (fl_file_chooser_show); + + procedure fl_file_chooser_hide + (F : in Storage.Integer_Address); + pragma Import (C, fl_file_chooser_hide, "fl_file_chooser_hide"); + pragma Inline (fl_file_chooser_hide); + + function fl_file_chooser_shown + (F : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_file_chooser_shown, "fl_file_chooser_shown"); + pragma Inline (fl_file_chooser_shown); + + function fl_file_chooser_visible + (F : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_file_chooser_visible, "fl_file_chooser_visible"); + pragma Inline (fl_file_chooser_visible); + + + + + procedure File_Chooser_Callback_Hook + (C_Addr, User_Data : in Storage.Integer_Address); + + pragma Convention (C, File_Chooser_Callback_Hook); + + procedure File_Chooser_Callback_Hook + (C_Addr, User_Data : in Storage.Integer_Address) + is + Ada_Obj : access File_Chooser'Class := + File_Chooser_Convert.To_Pointer (Storage.To_Address (User_Data)); + begin + if Ada_Obj.My_Callback /= null then + Ada_Obj.My_Callback (Ada_Obj.all); + end if; + end File_Chooser_Callback_Hook; + + + + + ------------------- + -- Destructors -- + ------------------- + + procedure Extra_Final + (This : in out File_Chooser) + is + use Interfaces.C.Strings; + begin + Free (This.My_Label); + Free (This.My_OK_Label); + end Extra_Final; + + + procedure Finalize + (This : in out File_Chooser) is + begin + Extra_Final (This); + if This.Void_Ptr /= Null_Pointer and This.Needs_Dealloc then + free_fl_file_chooser (This.Void_Ptr); + This.Void_Ptr := Null_Pointer; + end if; + end Finalize; + + + procedure Finalize + (This : in out File_Chooser_Final_Controller) + is + use Interfaces.C.Strings; + begin + Free (Add_Favorites_Label); + Free (All_Files_Label); + Free (Custom_Filter_Label); + Free (Existing_File_Label); + Free (Favorites_Label); + Free (Filename_Label); + Free (Filesystems_Label); + Free (Hidden_Label); + Free (Manage_Favorites_Label); + Free (New_Directory_Label); + Free (New_Directory_Tooltip); + Free (Preview_Label); + Free (Save_Label); + Free (Show_Label); + end Finalize; + + + + + -------------------- + -- Constructors -- + -------------------- + + procedure Extra_Init + (This : in out File_Chooser) is + begin + Wrapper (This.New_Butt).Void_Ptr := fl_file_chooser_newbutton (This.Void_Ptr); + Wrapper (This.New_Butt).Needs_Dealloc := False; + fl_widget_set_user_data + (Wrapper (This.New_Butt).Void_Ptr, + Storage.To_Integer (This.New_Butt'Address)); + Wrapper (This.Preview_Butt).Void_Ptr := fl_file_chooser_previewbutton (This.Void_Ptr); + Wrapper (This.Preview_Butt).Needs_Dealloc := False; + fl_widget_set_user_data + (Wrapper (This.Preview_Butt).Void_Ptr, + Storage.To_Integer (This.Preview_Butt'Address)); + Wrapper (This.Hidden_Butt).Void_Ptr := fl_file_chooser_showhiddenbutton (This.Void_Ptr); + Wrapper (This.Hidden_Butt).Needs_Dealloc := False; + fl_widget_set_user_data + (Wrapper (This.Hidden_Butt).Void_Ptr, + Storage.To_Integer (This.Hidden_Butt'Address)); + fl_file_chooser_set_user_data + (This.Void_Ptr, + Storage.To_Integer (This'Address)); + fl_file_chooser_callback + (This.Void_Ptr, + Storage.To_Integer (File_Chooser_Callback_Hook'Address), + Storage.To_Integer (This'Address)); + end Extra_Init; + + + package body Forge is + + function Create + (Title : in String; + Pattern : in String; + Pathname : in String; + Kind : in Chooser_Kind := Single) + return File_Chooser is + begin + return This : File_Chooser do + This.Void_Ptr := new_fl_file_chooser + (Interfaces.C.To_C (Pathname), + Interfaces.C.To_C (Pattern), + Chooser_Kind'Pos (Kind), + Interfaces.C.To_C (Title)); + Extra_Init (This); + end return; + end Create; + + end Forge; + + + + + ------------------ + -- Attributes -- + ------------------ + + function New_Button + (This : in out File_Chooser) + return FLTK.Widgets.Buttons.Button_Reference is + begin + return (Data => This.New_Butt'Unchecked_Access); + end New_Button; + + + function Preview_Button + (This : in out File_Chooser) + return FLTK.Widgets.Buttons.Light.Check.Check_Button_Reference is + begin + return (Data => This.Preview_Butt'Unchecked_Access); + end Preview_Button; + + + function Show_Hidden_Button + (This : in out File_Chooser) + return FLTK.Widgets.Buttons.Light.Check.Check_Button_Reference is + begin + return (Data => This.Hidden_Butt'Unchecked_Access); + end Show_Hidden_Button; + + + + + ------------------------- + -- Static Attributes -- + ------------------------- + + function Get_Add_Favorites_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_add_favorites_label); + end Get_Add_Favorites_Label; + + + procedure Set_Add_Favorites_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (Add_Favorites_Label); + Add_Favorites_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_add_favorites_label (Add_Favorites_Label); + end Set_Add_Favorites_Label; + + + function Get_All_Files_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_all_files_label); + end Get_All_Files_Label; + + + procedure Set_All_Files_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (All_Files_Label); + All_Files_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_all_files_label (All_Files_Label); + end Set_All_Files_Label; + + + function Get_Custom_Filter_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_custom_filter_label); + end Get_Custom_Filter_Label; + + + procedure Set_Custom_Filter_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (Custom_Filter_Label); + Custom_Filter_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_custom_filter_label (Custom_Filter_Label); + end Set_Custom_Filter_Label; + + + function Get_Existing_File_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_existing_file_label); + end Get_Existing_File_Label; + + + procedure Set_Existing_File_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (Existing_File_Label); + Existing_File_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_existing_file_label (Existing_File_Label); + end Set_Existing_File_Label; + + + function Get_Favorites_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_favorites_label); + end Get_Favorites_Label; + + + procedure Set_Favorites_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (Favorites_Label); + Favorites_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_favorites_label (Favorites_Label); + end Set_Favorites_Label; + + + function Get_Filename_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_filename_label); + end Get_Filename_Label; + + + procedure Set_Filename_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (Filename_Label); + Filename_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_filename_label (Filename_Label); + end Set_Filename_Label; + + + function Get_Filesystems_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_filesystems_label); + end Get_Filesystems_Label; + + + procedure Set_Filesystems_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (Filesystems_Label); + Filesystems_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_filesystems_label (Filesystems_Label); + end Set_Filesystems_Label; + + + function Get_Hidden_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_hidden_label); + end Get_Hidden_Label; + + + procedure Set_Hidden_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (Hidden_Label); + Hidden_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_hidden_label (Hidden_Label); + end Set_Hidden_Label; + + + function Get_Manage_Favorites_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_manage_favorites_label); + end Get_Manage_Favorites_Label; + + + procedure Set_Manage_Favorites_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (Manage_Favorites_Label); + Manage_Favorites_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_manage_favorites_label (Manage_Favorites_Label); + end Set_Manage_Favorites_Label; + + + function Get_New_Directory_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_new_directory_label); + end Get_New_Directory_Label; + + + procedure Set_New_Directory_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (New_Directory_Label); + New_Directory_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_new_directory_label (New_Directory_Label); + end Set_New_Directory_Label; + + + function Get_New_Directory_Tooltip + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_new_directory_tooltip); + end Get_New_Directory_Tooltip; + + + procedure Set_New_Directory_Tooltip + (Value : in String) is + begin + Interfaces.C.Strings.Free (New_Directory_Tooltip); + New_Directory_Tooltip := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_new_directory_tooltip (New_Directory_Tooltip); + end Set_New_Directory_Tooltip; + + + function Get_Preview_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_preview_label); + end Get_Preview_Label; + + + procedure Set_Preview_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (Preview_Label); + Preview_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_preview_label (Preview_Label); + end Set_Preview_Label; + + + function Get_Save_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_save_label); + end Get_Save_Label; + + + procedure Set_Save_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (Save_Label); + Save_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_save_label (Save_Label); + end Set_Save_Label; + + + function Get_Show_Label + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_show_label); + end Get_Show_Label; + + procedure Set_Show_Label + (Value : in String) is + begin + Interfaces.C.Strings.Free (Show_Label); + Show_Label := Interfaces.C.Strings.New_String (Value); + fl_file_chooser_set_show_label (Show_Label); + end Set_Show_Label; + + + + + ----------------------- + -- API Subprograms -- + ----------------------- + + procedure Add_Extra + (This : in out File_Chooser; + Item : in out Widgets.Widget'Class) + is + C_Addr : Storage.Integer_Address; + begin + C_Addr := fl_file_chooser_add_extra (This.Void_Ptr, Wrapper (Item).Void_Ptr); + end Add_Extra; + + + procedure Remove_Extra + (This : in out File_Chooser) + is + C_Addr : Storage.Integer_Address; + begin + C_Addr := fl_file_chooser_add_extra (This.Void_Ptr, Null_Pointer); + end Remove_Extra; + + + function Eject_Extra + (This : in out File_Chooser; + Item : in out Widgets.Widget'Class) + return access Widgets.Widget'Class + is + C_Addr : Storage.Integer_Address := + fl_file_chooser_add_extra (This.Void_Ptr, Wrapper (Item).Void_Ptr); + begin + return Widget_Convert.To_Pointer (Storage.To_Address (C_Addr)); + end Eject_Extra; + + + procedure Set_Callback + (This : in out File_Chooser; + Func : in Chooser_Callback) is + begin + This.My_Callback := Func; + end Set_Callback; + + + + + function Get_Background_Color + (This : in File_Chooser) + return Color is + begin + return Color (fl_file_chooser_get_color (This.Void_Ptr)); + end Get_Background_Color; + + + procedure Set_Background_Color + (This : in out File_Chooser; + Value : in Color) is + begin + fl_file_chooser_set_color (This.Void_Ptr, Interfaces.C.unsigned (Value)); + end Set_Background_Color; + + + function Get_Icon_Size + (This : in File_Chooser) + return Icon_Size is + begin + return Icon_Size (fl_file_chooser_get_iconsize (This.Void_Ptr)); + end Get_Icon_Size; + + + procedure Set_Icon_Size + (This : in out File_Chooser; + Value : in Icon_Size) is + begin + fl_file_chooser_set_iconsize (This.Void_Ptr, Interfaces.C.unsigned_char (Value)); + end Set_Icon_Size; + + + function Get_Label + (This : in File_Chooser) + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_label (This.Void_Ptr)); + end Get_Label; + + + procedure Set_Label + (This : in out File_Chooser; + Text : in String) is + begin + Interfaces.C.Strings.Free (This.My_Label); + This.My_Label := Interfaces.C.Strings.New_String (Text); + fl_file_chooser_set_label (This.Void_Ptr, This.My_Label); + end Set_Label; + + + function Get_OK_Label + (This : in File_Chooser) + return String is + begin + return Interfaces.C.Strings.Value (fl_file_chooser_get_ok_label (This.Void_Ptr)); + end Get_OK_Label; + + + procedure Set_OK_Label + (This : in out File_Chooser; + Text : in String) is + begin + Interfaces.C.Strings.Free (This.My_OK_Label); + This.My_OK_Label := Interfaces.C.Strings.New_String (Text); + fl_file_chooser_set_ok_label (This.Void_Ptr, This.My_OK_Label); + end Set_OK_Label; + + + function Has_Preview + (This : in File_Chooser) + return Boolean + is + Ret : Interfaces.C.int := fl_file_chooser_get_preview (This.Void_Ptr); + begin + if Ret not in 0 .. 1 then + raise Internal_FLTK_Error; + else + return Boolean'Val (Ret); + end if; + end Has_Preview; + + + procedure Set_Preview + (This : in out File_Chooser; + Value : in Boolean) is + begin + fl_file_chooser_set_preview (This.Void_Ptr, Boolean'Pos (Value)); + end Set_Preview; + + + function Get_Text_Color + (This : in File_Chooser) + return Color is + begin + return Color (fl_file_chooser_get_textcolor (This.Void_Ptr)); + end Get_Text_Color; + + + procedure Set_Text_Color + (This : in out File_Chooser; + Value : in Color) is + begin + fl_file_chooser_set_textcolor (This.Void_Ptr, Interfaces.C.unsigned (Value)); + end Set_Text_Color; + + + function Get_Text_Font + (This : in File_Chooser) + return Font_Kind is + begin + return Font_Kind'Val (fl_file_chooser_get_textfont (This.Void_Ptr)); + end Get_Text_Font; + + + procedure Set_Text_Font + (This : in out File_Chooser; + Font : in Font_Kind) is + begin + fl_file_chooser_set_textfont (This.Void_Ptr, Font_Kind'Pos (Font)); + end Set_Text_Font; + + + function Get_Text_Size + (This : in File_Chooser) + return Font_Size is + begin + return Font_Size (fl_file_chooser_get_textsize (This.Void_Ptr)); + end Get_Text_Size; + + + procedure Set_Text_Size + (This : in out File_Chooser; + Size : in Font_Size) is + begin + fl_file_chooser_set_textsize (This.Void_Ptr, Interfaces.C.int (Size)); + end Set_Text_Size; + + + function Get_Chooser_Kind + (This : in File_Chooser) + return Chooser_Kind + is + Ret : Interfaces.C.int := fl_file_chooser_get_type (This.Void_Ptr); + begin + if Ret not in 0 .. Chooser_Kind'Pos (Chooser_Kind'Last) then + raise Internal_FLTK_Error; + else + return Chooser_Kind'Val (Ret); + end if; + end Get_Chooser_Kind; + + + procedure Set_Chooser_Kind + (This : in out File_Chooser; + Kind : in Chooser_Kind) is + begin + fl_file_chooser_set_type (This.Void_Ptr, Chooser_Kind'Pos (Kind)); + end Set_Chooser_Kind; + + + + + function Number_Selected + (This : in File_Chooser) + return Natural is + begin + return Natural (fl_file_chooser_count (This.Void_Ptr)); + end Number_Selected; + + + function Get_Directory + (This : in File_Chooser) + return String + is + C_Ptr : Interfaces.C.Strings.chars_ptr := fl_file_chooser_get_directory (This.Void_Ptr); + begin + if C_Ptr = Interfaces.C.Strings.Null_Ptr then + return ""; + else + return Interfaces.C.Strings.Value (C_Ptr); + end if; + end Get_Directory; + + + procedure Set_Directory + (This : in out File_Chooser; + Value : in String) + is + use Interfaces.C; + C_Arr : aliased char_array := To_C (Value); + begin + if Value = "" then + fl_file_chooser_set_directory (This.Void_Ptr, Strings.Null_Ptr); + else + fl_file_chooser_set_directory + (This.Void_Ptr, + Strings.To_Chars_Ptr (C_Arr'Unchecked_Access)); + end if; + end Set_Directory; + + + function Get_Filter + (This : in File_Chooser) + return String + is + C_Ptr : Interfaces.C.Strings.chars_ptr := fl_file_chooser_get_filter (This.Void_Ptr); + begin + if C_Ptr = Interfaces.C.Strings.Null_Ptr then + return ""; + else + return Interfaces.C.Strings.Value (C_Ptr); + end if; + end Get_Filter; + + + procedure Set_Filter + (This : in out File_Chooser; + Value : in String) + is + use Interfaces.C; + C_Arr : aliased char_array := To_C (Value); + begin + if Value = "" then + fl_file_chooser_set_filter (This.Void_Ptr, Strings.Null_Ptr); + else + fl_file_chooser_set_filter + (This.Void_Ptr, + Strings.To_Chars_Ptr (C_Arr'Unchecked_Access)); + end if; + end Set_Filter; + + + function Get_Filter_Index + (This : in File_Chooser) + return Positive is + begin + return Positive (fl_file_chooser_get_filter_value (This.Void_Ptr) + 1); + end Get_Filter_Index; + + + procedure Set_Filter_Index + (This : in out File_Chooser; + Value : in Positive) is + begin + fl_file_chooser_set_filter_value (This.Void_Ptr, Interfaces.C.int (Value) - 1); + end Set_Filter_Index; + + + procedure Rescan + (This : in out File_Chooser) is + begin + fl_file_chooser_rescan (This.Void_Ptr); + end Rescan; + + + procedure Rescan_Keep_Filename + (This : in out File_Chooser) is + begin + fl_file_chooser_rescan_keep_filename (This.Void_Ptr); + end Rescan_Keep_Filename; + + + function Get_Selected + (This : in File_Chooser; + Index : in Positive := 1) + return String + is + C_Ptr : Interfaces.C.Strings.chars_ptr := + fl_file_chooser_get_value (This.Void_Ptr, Interfaces.C.int (Index)); + begin + if C_Ptr = Interfaces.C.Strings.Null_Ptr then + return ""; + else + return Interfaces.C.Strings.Value (C_Ptr); + end if; + end Get_Selected; + + + procedure Set_Selected + (This : in out File_Chooser; + Value : in String) is + begin + fl_file_chooser_set_value (This.Void_Ptr, Interfaces.C.To_C (Value)); + end Set_Selected; + + + + + procedure Show + (This : in out File_Chooser) is + begin + fl_file_chooser_show (This.Void_Ptr); + end Show; + + + procedure Hide + (This : in out File_Chooser) is + begin + fl_file_chooser_hide (This.Void_Ptr); + end Hide; + + + function Is_Shown + (This : in File_Chooser) + return Boolean is + begin + return fl_file_chooser_shown (This.Void_Ptr) /= 0; + end Is_Shown; + + + function Is_Visible + (This : in File_Chooser) + return Boolean is + begin + return fl_file_chooser_visible (This.Void_Ptr) /= 0; + end Is_Visible; + + +end FLTK.File_Choosers; + + diff --git a/src/fltk-file_choosers.ads b/src/fltk-file_choosers.ads new file mode 100644 index 0000000..b350ddc --- /dev/null +++ b/src/fltk-file_choosers.ads @@ -0,0 +1,401 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +with + + FLTK.Widgets.Buttons.Light.Check; + +private with + + Ada.Finalization, + Interfaces.C.Strings; + + +package FLTK.File_Choosers is + + + type File_Chooser is new Wrapper with private; + + type File_Chooser_Reference (Data : not null access File_Chooser'Class) is + limited null record with Implicit_Dereference => Data; + + type Chooser_Kind is (Single, Multi, Create, Directory); + + type Chooser_Callback is access procedure + (Item : in out File_Chooser'Class); + + type Icon_Size is mod 256; + + + + + package Forge is + + function Create + (Title : in String; + Pattern : in String; + Pathname : in String; + Kind : in Chooser_Kind := Single) + return File_Chooser; + + end Forge; + + + + + function New_Button + (This : in out File_Chooser) + return FLTK.Widgets.Buttons.Button_Reference; + + function Preview_Button + (This : in out File_Chooser) + return FLTK.Widgets.Buttons.Light.Check.Check_Button_Reference; + + function Show_Hidden_Button + (This : in out File_Chooser) + return FLTK.Widgets.Buttons.Light.Check.Check_Button_Reference; + + + + + function Get_Add_Favorites_Label + return String; + + procedure Set_Add_Favorites_Label + (Value : in String); + + function Get_All_Files_Label + return String; + + procedure Set_All_Files_Label + (Value : in String); + + function Get_Custom_Filter_Label + return String; + + procedure Set_Custom_Filter_Label + (Value : in String); + + function Get_Existing_File_Label + return String; + + procedure Set_Existing_File_Label + (Value : in String); + + function Get_Favorites_Label + return String; + + procedure Set_Favorites_Label + (Value : in String); + + function Get_Filename_Label + return String; + + procedure Set_Filename_Label + (Value : in String); + + function Get_Filesystems_Label + return String; + + procedure Set_Filesystems_Label + (Value : in String); + + function Get_Hidden_Label + return String; + + procedure Set_Hidden_Label + (Value : in String); + + function Get_Manage_Favorites_Label + return String; + + procedure Set_Manage_Favorites_Label + (Value : in String); + + function Get_New_Directory_Label + return String; + + procedure Set_New_Directory_Label + (Value : in String); + + function Get_New_Directory_Tooltip + return String; + + procedure Set_New_Directory_Tooltip + (Value : in String); + + function Get_Preview_Label + return String; + + procedure Set_Preview_Label + (Value : in String); + + function Get_Save_Label + return String; + + procedure Set_Save_Label + (Value : in String); + + function Get_Show_Label + return String; + + procedure Set_Show_Label + (Value : in String); + + + + + procedure Add_Extra + (This : in out File_Chooser; + Item : in out Widgets.Widget'Class); + + procedure Remove_Extra + (This : in out File_Chooser); + + function Eject_Extra + (This : in out File_Chooser; + Item : in out Widgets.Widget'Class) + return access Widgets.Widget'Class; + + procedure Set_Callback + (This : in out File_Chooser; + Func : in Chooser_Callback); + + + + + function Get_Background_Color + (This : in File_Chooser) + return Color; + + procedure Set_Background_Color + (This : in out File_Chooser; + Value : in Color); + + function Get_Icon_Size + (This : in File_Chooser) + return Icon_Size; + + procedure Set_Icon_Size + (This : in out File_Chooser; + Value : in Icon_Size); + + function Get_Label + (This : in File_Chooser) + return String; + + procedure Set_Label + (This : in out File_Chooser; + Text : in String); + + function Get_OK_Label + (This : in File_Chooser) + return String; + + procedure Set_OK_Label + (This : in out File_Chooser; + Text : in String); + + function Has_Preview + (This : in File_Chooser) + return Boolean; + + procedure Set_Preview + (This : in out File_Chooser; + Value : in Boolean); + + function Get_Text_Color + (This : in File_Chooser) + return Color; + + procedure Set_Text_Color + (This : in out File_Chooser; + Value : in Color); + + function Get_Text_Font + (This : in File_Chooser) + return Font_Kind; + + procedure Set_Text_Font + (This : in out File_Chooser; + Font : in Font_Kind); + + function Get_Text_Size + (This : in File_Chooser) + return Font_Size; + + procedure Set_Text_Size + (This : in out File_Chooser; + Size : in Font_Size); + + function Get_Chooser_Kind + (This : in File_Chooser) + return Chooser_Kind; + + procedure Set_Chooser_Kind + (This : in out File_Chooser; + Kind : in Chooser_Kind); + + + + + function Number_Selected + (This : in File_Chooser) + return Natural; + + function Get_Directory + (This : in File_Chooser) + return String; + + procedure Set_Directory + (This : in out File_Chooser; + Value : in String); + + function Get_Filter + (This : in File_Chooser) + return String; + + procedure Set_Filter + (This : in out File_Chooser; + Value : in String); + + function Get_Filter_Index + (This : in File_Chooser) + return Positive; + + procedure Set_Filter_Index + (This : in out File_Chooser; + Value : in Positive); + + procedure Rescan + (This : in out File_Chooser); + + procedure Rescan_Keep_Filename + (This : in out File_Chooser); + + function Get_Selected + (This : in File_Chooser; + Index : in Positive := 1) + return String + with Pre => Index <= This.Number_Selected; + + procedure Set_Selected + (This : in out File_Chooser; + Value : in String); + + + + + procedure Show + (This : in out File_Chooser); + + procedure Hide + (This : in out File_Chooser); + + function Is_Shown + (This : in File_Chooser) + return Boolean; + + function Is_Visible + (This : in File_Chooser) + return Boolean; + + +private + + + type File_Chooser is new Wrapper with record + New_Butt : aliased Widgets.Buttons.Button; + Preview_Butt : aliased Widgets.Buttons.Light.Check.Check_Button; + Hidden_Butt : aliased Widgets.Buttons.Light.Check.Check_Button; + My_Callback : Chooser_Callback; + My_Label : Interfaces.C.Strings.chars_ptr; + My_OK_Label : Interfaces.C.Strings.chars_ptr; + end record; + + overriding procedure Finalize + (This : in out File_Chooser); + + procedure Extra_Init + (This : in out File_Chooser); + + procedure Extra_Final + (This : in out File_Chooser); + + + Add_Favorites_Label, All_Files_Label, + Custom_Filter_Label, Existing_File_Label, + Favorites_Label, Filename_Label, + Filesystems_Label, Hidden_Label, + Manage_Favorites_Label, New_Directory_Label, + New_Directory_Tooltip, Preview_Label, + Save_Label, Show_Label : Interfaces.C.Strings.chars_ptr; + + + pragma Inline (New_Button); + pragma Inline (Preview_Button); + pragma Inline (Show_Hidden_Button); + + pragma Inline (Get_Add_Favorites_Label); + pragma Inline (Get_All_Files_Label); + pragma Inline (Get_Custom_Filter_Label); + pragma Inline (Get_Existing_File_Label); + pragma Inline (Get_Favorites_Label); + pragma Inline (Get_Filename_Label); + pragma Inline (Get_Filesystems_Label); + pragma Inline (Get_Hidden_Label); + pragma Inline (Get_Manage_Favorites_Label); + pragma Inline (Get_New_Directory_Label); + pragma Inline (Get_New_Directory_Tooltip); + pragma Inline (Get_Preview_Label); + pragma Inline (Get_Save_Label); + pragma Inline (Get_Show_Label); + + pragma Inline (Add_Extra); + pragma Inline (Remove_Extra); + pragma Inline (Eject_Extra); + pragma Inline (Set_Callback); + + pragma Inline (Get_Background_Color); + pragma Inline (Set_Background_Color); + pragma Inline (Get_Icon_Size); + pragma Inline (Set_Icon_Size); + pragma Inline (Get_Label); + pragma Inline (Get_OK_Label); + pragma Inline (Set_Preview); + 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 (Set_Chooser_Kind); + + pragma Inline (Number_Selected); + pragma Inline (Get_Filter_Index); + pragma Inline (Set_Filter_Index); + pragma Inline (Rescan); + pragma Inline (Rescan_Keep_Filename); + pragma Inline (Set_Selected); + + pragma Inline (Show); + pragma Inline (Hide); + pragma Inline (Is_Shown); + pragma Inline (Is_Visible); + + + -- Needed to ensure chars_ptr storage is properly cleaned up + type File_Chooser_Final_Controller is new Ada.Finalization.Limited_Controlled with null record; + + overriding procedure Finalize + (This : in out File_Chooser_Final_Controller); + + Cleanup : File_Chooser_Final_Controller; + + +end FLTK.File_Choosers; + + diff --git a/src/fltk-widgets.ads b/src/fltk-widgets.ads index f37870d..d7cbca8 100644 --- a/src/fltk-widgets.ads +++ b/src/fltk-widgets.ads @@ -370,6 +370,10 @@ private -- Groups.Browsers (has two internal Scrollbars) -- If weird Init/Final errors start mysteriously occuring then check there first. + -- Extra_Init functionality is also duplicated in FLTK.File_Choosers + -- for reasons of hierarchy visibility. Really, the File_Chooser should be in + -- the Widget hierarchy like Color_Chooser but for some reason it isn't. + procedure Extra_Init (This : in out Widget; X, Y, W, H : in Integer; |