diff --git a/src/C++/g_unicode.cpp b/src/C++/g_unicode.cpp index db0413c..32e50e4 100644 --- a/src/C++/g_unicode.cpp +++ b/src/C++/g_unicode.cpp @@ -535,7 +535,7 @@ extern "C" LV_DLL_EXPORT gu_result gu_is_text_utf8(const char* str, int32_t* is_ // Dialog API // //////////////// -extern "C" LV_DLL_EXPORT gu_result gu_open_file_dialog(const char* title, const char* default_path, int32_t num_filter_patterns, const char** filter_patterns, const char* filter_description, int32_t allow_multi_select, int32_t* cancelled, intptr_t* path_pointer, int32_t* path_length, intptr_t* paths_pointer, int32_t* num_paths) +extern "C" LV_DLL_EXPORT gu_result gu_open_file_dialog(const char* title, const char* default_path, int32_t num_filter_patterns, const char* filter_patterns, const char* filter_description, int32_t allow_multi_select, int32_t* cancelled, intptr_t* path_pointer, int32_t* path_length, intptr_t* paths_pointer, int32_t* num_paths) { *path_length = 0; *path_pointer = 0; @@ -543,11 +543,22 @@ extern "C" LV_DLL_EXPORT gu_result gu_open_file_dialog(const char* title, const *num_paths = 0; *cancelled = 0; - std::string _title = (strlen(title) > 0) ? title : "Choose or Enter Path of Folder"; + std::string _title = (strlen(title) > 0) ? title : "Choose or Enter Path of File"; std::string _default_path = (strlen(default_path) > 0) ? default_path : pfd::path::home(); pfd::opt _option = allow_multi_select ? pfd::opt::multiselect : pfd::opt::none; - auto selection = pfd::open_file(_title, _default_path, { "All Files (*.*)", "*" }, _option).result(); + std::vector filters = { "All Files (*.*)", "*" }; // Valeur par défaut des filtres + std::string filter_patterns_str(filter_patterns); + std::string filter_description_str(filter_description); + + if (!filter_patterns_str.empty()) { + filters.clear(); // Clear default filters if specific filters are provided + + filters.push_back(filter_description_str); + filters.push_back(filter_patterns_str); + } + + auto selection = pfd::open_file(_title, _default_path, filters, _option).result(); // User cancelled the dialog if (selection.size() == 0) diff --git a/src/C++/g_unicode.h b/src/C++/g_unicode.h index aa549f6..b6a597c 100644 --- a/src/C++/g_unicode.h +++ b/src/C++/g_unicode.h @@ -98,7 +98,7 @@ extern "C" LV_DLL_EXPORT gu_result gu_is_text_utf8(const char* str, int32_t* is_ //////////////// // Dialog API // //////////////// -extern "C" LV_DLL_EXPORT gu_result gu_open_file_dialog(const char* title, const char* default_path, int32_t num_filter_patterns, const char** filter_patterns, const char* filter_description, int32_t allow_multi_select, int32_t* cancelled, intptr_t* path_pointer, int32_t* path_length, intptr_t* paths_pointer, int32_t* num_paths); +extern "C" LV_DLL_EXPORT gu_result gu_open_file_dialog(const char* title, const char* default_path, int32_t num_filter_patterns, const char* filter_patterns, const char* filter_description, int32_t allow_multi_select, int32_t* cancelled, intptr_t* path_pointer, int32_t* path_length, intptr_t* paths_pointer, int32_t* num_paths); extern "C" LV_DLL_EXPORT gu_result gu_select_folder_dialog(const char* title, const char* default_path, int32_t* cancelled, intptr_t* path_pointer, int32_t* path_length); extern "C" LV_DLL_EXPORT gu_result gu_message_box(const char* title, const char* message, int32_t choice, int32_t icon, int32_t* user_selection); extern "C" LV_DLL_EXPORT gu_result gu_input_box(const char* title, const char* message, const char* default_input, intptr_t* input_pointer, int32_t* input_size); diff --git a/src/C++/g_unicode.rc b/src/C++/g_unicode.rc index 5d3149a..25305ac 100644 --- a/src/C++/g_unicode.rc +++ b/src/C++/g_unicode.rc @@ -1,98 +1,98 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,3,0,0 - PRODUCTVERSION 0,3,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "G-Unicode" - VALUE "FileVersion", "0.3.0.0" - VALUE "InternalName", "g_unicode.dll" - VALUE "OriginalFilename", "g_unicode.dll" - VALUE "ProductName", "G-Unicode" - VALUE "ProductVersion", "0.3.0.0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Anglais (États-Unis) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 0,3,0,1 + PRODUCTVERSION 0,3,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "G-Unicode" + VALUE "FileVersion", "0.3.0.1" + VALUE "InternalName", "g_unicode.dll" + VALUE "OriginalFilename", "g_unicode.dll" + VALUE "ProductName", "G-Unicode" + VALUE "ProductVersion", "0.3.0.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // Anglais (États-Unis) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/LabVIEW/G-Unicode.lvproj b/src/LabVIEW/G-Unicode.lvproj index 484311e..cc032fd 100644 --- a/src/LabVIEW/G-Unicode.lvproj +++ b/src/LabVIEW/G-Unicode.lvproj @@ -70,7 +70,6 @@ - @@ -79,6 +78,7 @@ + @@ -165,6 +165,8 @@ true + + diff --git a/src/LabVIEW/G-Unicode/Examples/Unicode Open File With Filters.vi b/src/LabVIEW/G-Unicode/Examples/Unicode Open File With Filters.vi new file mode 100644 index 0000000..78cf370 Binary files /dev/null and b/src/LabVIEW/G-Unicode/Examples/Unicode Open File With Filters.vi differ diff --git a/src/LabVIEW/G-Unicode/File IO/File Dialog (Unicode).vim b/src/LabVIEW/G-Unicode/File IO/File Dialog (Unicode).vim index b06f15c..660451d 100644 Binary files a/src/LabVIEW/G-Unicode/File IO/File Dialog (Unicode).vim and b/src/LabVIEW/G-Unicode/File IO/File Dialog (Unicode).vim differ diff --git a/src/LabVIEW/G-Unicode/Private/Library/gu_open_file_dialog.vi b/src/LabVIEW/G-Unicode/Private/Library/gu_open_file_dialog.vi index b925124..b23fd34 100644 Binary files a/src/LabVIEW/G-Unicode/Private/Library/gu_open_file_dialog.vi and b/src/LabVIEW/G-Unicode/Private/Library/gu_open_file_dialog.vi differ diff --git a/src/LabVIEW/G-Unicode/lib/g_unicode_32.dll b/src/LabVIEW/G-Unicode/lib/g_unicode_32.dll index 1c5f7bc..ecb3aa8 100644 Binary files a/src/LabVIEW/G-Unicode/lib/g_unicode_32.dll and b/src/LabVIEW/G-Unicode/lib/g_unicode_32.dll differ diff --git a/src/LabVIEW/G-Unicode/lib/g_unicode_64.dll b/src/LabVIEW/G-Unicode/lib/g_unicode_64.dll index f3fa1b0..31df9d4 100644 Binary files a/src/LabVIEW/G-Unicode/lib/g_unicode_64.dll and b/src/LabVIEW/G-Unicode/lib/g_unicode_64.dll differ