refactoredCPPNeuronMesher
tinyfiledialogs.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Zlib
2 Copyright (c) 2014 - 2024 Guillaume Vareille http://ysengrin.com
3  ____________________________________________________________________
4  | |
5  | 100% compatible C C++ -> You can rename tinfiledialogs.c as .cpp |
6  |____________________________________________________________________|
7 
8 ********* TINY FILE DIALOGS OFFICIAL WEBSITE IS ON SOURCEFORGE *********
9  _________
10  / \ tinyfiledialogs.h v3.19.1 [Jan 27, 2025]
11  |tiny file| Unique header file created [November 9, 2014]
12  | dialogs |
13  \____ ___/ http://tinyfiledialogs.sourceforge.net
14  \| git clone http://git.code.sf.net/p/tinyfiledialogs/code tinyfd
15  ____________________________________________
16 | |
17 | email: tinyfiledialogs at ysengrin.com |
18 |____________________________________________|
19  ________________________________________________________________________________
20 | ____________________________________________________________________________ |
21 | | | |
22 | | - in tinyfiledialogs, char is UTF-8 by default (since v3.6) | |
23 | | | |
24 | | on windows: | |
25 | | - for UTF-16, use the wchar_t functions at the bottom of the header file | |
26 | | | |
27 | | - _wfopen() requires wchar_t | |
28 | | - fopen() uses char but expects ASCII or MBCS (not UTF-8) | |
29 | | - if you want char to be MBCS: set tinyfd_winUtf8 to 0 | |
30 | | | |
31 | | - alternatively, tinyfiledialogs provides | |
32 | | functions to convert between UTF-8, UTF-16 and MBCS | |
33 | |____________________________________________________________________________| |
34 |________________________________________________________________________________|
35 
36 If you like tinyfiledialogs, please upvote my stackoverflow answer
37 https://stackoverflow.com/a/47651444
38 
39 - License -
40 This software is provided 'as-is', without any express or implied
41 warranty. In no event will the authors be held liable for any damages
42 arising from the use of this software.
43 Permission is granted to anyone to use this software for any purpose,
44 including commercial applications, and to alter it and redistribute it
45 freely, subject to the following restrictions:
46 1. The origin of this software must not be misrepresented; you must not
47 claim that you wrote the original software. If you use this software
48 in a product, an acknowledgment in the product documentation would be
49 appreciated but is not required.
50 2. Altered source versions must be plainly marked as such, and must not be
51 misrepresented as being the original software.
52 3. This notice may not be removed or altered from any source distribution.
53 
54  __________________________________________
55  | ______________________________________ |
56  | | | |
57  | | DO NOT USE USER INPUT IN THE DIALOGS | |
58  | |______________________________________| |
59  |__________________________________________|
60 */
61 
62 #ifndef TINYFILEDIALOGS_H
63 #define TINYFILEDIALOGS_H
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 /******************************************************************************************************/
70 /**************************************** UTF-8 on Windows ********************************************/
71 /******************************************************************************************************/
72 #ifdef _WIN32
73 /* On windows, if you want to use UTF-8 ( instead of the UTF-16/wchar_t functions at the end of this file )
74 Make sure your code is really prepared for UTF-8 (on windows, functions like fopen() expect MBCS and not UTF-8) */
75 extern int tinyfd_winUtf8; /* on windows char strings can be 1:UTF-8(default) or 0:MBCS */
76 /* for MBCS change this to 0, in tinyfiledialogs.c or in your code */
77 
78 /* Here are some functions to help you convert between UTF-16 UTF-8 MBSC */
79 char * tinyfd_utf8toMbcs(char const * aUtf8string);
80 char * tinyfd_utf16toMbcs(wchar_t const * aUtf16string);
81 wchar_t * tinyfd_mbcsTo16(char const * aMbcsString);
82 char * tinyfd_mbcsTo8(char const * aMbcsString);
83 wchar_t * tinyfd_utf8to16(char const * aUtf8string);
84 char * tinyfd_utf16to8(wchar_t const * aUtf16string);
85 #endif
86 /******************************************************************************************************/
87 /******************************************************************************************************/
88 /******************************************************************************************************/
89 
90 /************* 3 funtions for C# (you don't need this in C or C++) : */
91 char const * tinyfd_getGlobalChar(char const * aCharVariableName); /* returns NULL on error */
92 int tinyfd_getGlobalInt(char const * aIntVariableName); /* returns -1 on error */
93 int tinyfd_setGlobalInt(char const * aIntVariableName, int aValue); /* returns -1 on error */
94 /* aCharVariableName: "tinyfd_version" "tinyfd_needs" "tinyfd_response"
95  aIntVariableName : "tinyfd_verbose" "tinyfd_silent" "tinyfd_allowCursesDialogs"
96  "tinyfd_forceConsole" "tinyfd_assumeGraphicDisplay" "tinyfd_winUtf8"
97 **************/
98 
99 extern char tinyfd_version[8]; /* contains tinyfd current version number */
100 extern char tinyfd_needs[]; /* info about requirements */
101 extern int tinyfd_verbose; /* 0 (default) or 1 : on unix, prints the command line calls */
102 extern int tinyfd_silent; /* 1 (default) or 0 : on unix, hide errors and warnings from called dialogs */
103 
106 extern int tinyfd_allowCursesDialogs; /* 0 (default) or 1 */
107 
108 extern int tinyfd_forceConsole; /* 0 (default) or 1 */
109 /* for unix & windows: 0 (graphic mode) or 1 (console mode).
110 0: try to use a graphic solution, if it fails then it uses console mode.
111 1: forces all dialogs into console mode even when an X server is present.
112  if enabled, it can use the package Dialog or dialog.exe.
113  on windows it only make sense for console applications */
114 
115 /* extern int tinyfd_assumeGraphicDisplay; */ /* 0 (default) or 1 */
116 /* some systems don't set the environment variable DISPLAY even when a graphic display is present.
117 set this to 1 to tell tinyfiledialogs to assume the existence of a graphic display */
118 
119 extern char tinyfd_response[1024];
120 /* if you pass "tinyfd_query" as aTitle,
121 the functions will not display the dialogs
122 but will return 0 for console mode, 1 for graphic mode.
123 tinyfd_response is then filled with the retain solution.
124 possible values for tinyfd_response are (all lowercase)
125 for graphic mode:
126  windows_wchar windows applescript kdialog zenity zenity3 yad matedialog
127  shellementary qarma python2-tkinter python3-tkinter python-dbus
128  perl-dbus gxmessage gmessage xmessage xdialog gdialog dunst
129 for console mode:
130  dialog whiptail basicinput no_solution */
131 
132 void tinyfd_beep(void);
133 
135  char const * aTitle, /* NULL or "" */
136  char const * aMessage, /* NULL or "" may contain \n \t */
137  char const * aIconType); /* "info" "warning" "error" */
138  /* return has only meaning for tinyfd_query */
139 
141  char const * aTitle , /* NULL or "" */
142  char const * aMessage , /* NULL or "" may contain \n \t */
143  char const * aDialogType , /* "ok" "okcancel" "yesno" "yesnocancel" */
144  char const * aIconType , /* "info" "warning" "error" "question" */
145  int aDefaultButton ) ;
146  /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
147 
148 char * tinyfd_inputBox(
149  char const * aTitle , /* NULL or "" */
150  char const * aMessage , /* NULL or "" (\n and \t have no effect) */
151  char const * aDefaultInput ) ; /* NULL = passwordBox, "" = inputbox */
152  /* returns NULL on cancel */
153 
154 char * tinyfd_saveFileDialog(
155  char const * aTitle , /* NULL or "" */
156  char const * aDefaultPathAndOrFile , /* NULL or "" , ends with / to set only a directory */
157  int aNumOfFilterPatterns , /* 0 (1 in the following example) */
158  char const * const * aFilterPatterns , /* NULL or char const * lFilterPatterns[1]={"*.txt"} */
159  char const * aSingleFilterDescription ) ; /* NULL or "text files" */
160  /* returns NULL on cancel */
161 
162 char * tinyfd_openFileDialog(
163  char const * aTitle, /* NULL or "" */
164  char const * aDefaultPathAndOrFile, /* NULL or "" , ends with / to set only a directory */
165  int aNumOfFilterPatterns , /* 0 (2 in the following example) */
166  char const * const * aFilterPatterns, /* NULL or char const * lFilterPatterns[2]={"*.png","*.jpg"}; */
167  char const * aSingleFilterDescription, /* NULL or "image files" */
168  int aAllowMultipleSelects ) ; /* 0 or 1 */
169  /* in case of multiple files, the separator is | */
170  /* returns NULL on cancel */
171 
173  char const * aTitle, /* NULL or "" */
174  char const * aDefaultPath); /* NULL or "" */
175  /* returns NULL on cancel */
176 
177 char * tinyfd_colorChooser(
178  char const * aTitle, /* NULL or "" */
179  char const * aDefaultHexRGB, /* NULL or "" or "#FF0000" */
180  unsigned char const aDefaultRGB[3] , /* unsigned char lDefaultRGB[3] = { 0 , 128 , 255 }; */
181  unsigned char aoResultRGB[3] ) ; /* unsigned char lResultRGB[3]; */
182  /* aDefaultRGB is used only if aDefaultHexRGB is absent */
183  /* aDefaultRGB and aoResultRGB can be the same array */
184  /* returns NULL on cancel */
185  /* returns the hexcolor as a string "#FF0000" */
186  /* aoResultRGB also contains the result */
187 
188 
189 /************ WINDOWS ONLY SECTION ************************/
190 #ifdef _WIN32
191 
192 /* windows only - utf-16 version */
193 int tinyfd_notifyPopupW(
194  wchar_t const * aTitle, /* NULL or L"" */
195  wchar_t const * aMessage, /* NULL or L"" may contain \n \t */
196  wchar_t const * aIconType); /* L"info" L"warning" L"error" */
197 
198 /* windows only - utf-16 version */
199 int tinyfd_messageBoxW(
200  wchar_t const * aTitle, /* NULL or L"" */
201  wchar_t const * aMessage, /* NULL or L"" may contain \n \t */
202  wchar_t const * aDialogType, /* L"ok" L"okcancel" L"yesno" */
203  wchar_t const * aIconType, /* L"info" L"warning" L"error" L"question" */
204  int aDefaultButton ); /* 0 for cancel/no , 1 for ok/yes */
205  /* returns 0 for cancel/no , 1 for ok/yes */
206 
207 /* windows only - utf-16 version */
208 wchar_t * tinyfd_inputBoxW(
209  wchar_t const * aTitle, /* NULL or L"" */
210  wchar_t const * aMessage, /* NULL or L"" (\n nor \t not respected) */
211  wchar_t const * aDefaultInput); /* NULL passwordBox, L"" inputbox */
212 
213 /* windows only - utf-16 version */
214 wchar_t * tinyfd_saveFileDialogW(
215  wchar_t const * aTitle, /* NULL or L"" */
216  wchar_t const * aDefaultPathAndOrFile, /* NULL or L"" , ends with / to set only a directory */
217  int aNumOfFilterPatterns, /* 0 (1 in the following example) */
218  wchar_t const * const * aFilterPatterns, /* NULL or wchar_t const * lFilterPatterns[1]={L"*.txt"} */
219  wchar_t const * aSingleFilterDescription); /* NULL or L"text files" */
220  /* returns NULL on cancel */
221 
222 /* windows only - utf-16 version */
223 wchar_t * tinyfd_openFileDialogW(
224  wchar_t const * aTitle, /* NULL or L"" */
225  wchar_t const * aDefaultPathAndOrFile, /* NULL or L"" , ends with / to set only a directory */
226  int aNumOfFilterPatterns , /* 0 (2 in the following example) */
227  wchar_t const * const * aFilterPatterns, /* NULL or wchar_t const * lFilterPatterns[2]={L"*.png","*.jpg"} */
228  wchar_t const * aSingleFilterDescription, /* NULL or L"image files" */
229  int aAllowMultipleSelects ) ; /* 0 or 1 */
230  /* in case of multiple files, the separator is | */
231  /* returns NULL on cancel */
232 
233 /* windows only - utf-16 version */
234 wchar_t * tinyfd_selectFolderDialogW(
235  wchar_t const * aTitle, /* NULL or L"" */
236  wchar_t const * aDefaultPath); /* NULL or L"" */
237  /* returns NULL on cancel */
238 
239 /* windows only - utf-16 version */
240 wchar_t * tinyfd_colorChooserW(
241  wchar_t const * aTitle, /* NULL or L"" */
242  wchar_t const * aDefaultHexRGB, /* NULL or L"#FF0000" */
243  unsigned char const aDefaultRGB[3], /* unsigned char lDefaultRGB[3] = { 0 , 128 , 255 }; */
244  unsigned char aoResultRGB[3]); /* unsigned char lResultRGB[3]; */
245  /* returns the hexcolor as a string L"#FF0000" */
246  /* aoResultRGB also contains the result */
247  /* aDefaultRGB is used only if aDefaultHexRGB is NULL */
248  /* aDefaultRGB and aoResultRGB can be the same array */
249  /* returns NULL on cancel */
250 
251 #endif /*_WIN32 */
252 
253 #ifdef __cplusplus
254 } /*extern "C"*/
255 #endif
256 
257 #endif /* TINYFILEDIALOGS_H */
258 
259 /*
260  ________________________________________________________________________________
261 | ____________________________________________________________________________ |
262 | | | |
263 | | on windows: | |
264 | | - for UTF-16, use the wchar_t functions at the bottom of the header file | |
265 | | - _wfopen() requires wchar_t | |
266 | | | |
267 | | - in tinyfiledialogs, char is UTF-8 by default (since v3.6) | |
268 | | - but fopen() expects MBCS (not UTF-8) | |
269 | | - if you want char to be MBCS: set tinyfd_winUtf8 to 0 | |
270 | | | |
271 | | - alternatively, tinyfiledialogs provides | |
272 | | functions to convert between UTF-8, UTF-16 and MBCS | |
273 | |____________________________________________________________________________| |
274 |________________________________________________________________________________|
275 
276 - This is not for ios nor android (it works in termux though).
277 - The files can be renamed with extension ".cpp" as the code is 100% compatible C C++
278  (just comment out << extern "C" >> in the header file)
279 - Windows is fully supported from XP to 10 (maybe even older versions)
280 - C# & LUA via dll, see files in the folder EXTRAS
281 - OSX supported from 10.4 to latest (maybe even older versions)
282 - Do not use " and ' as the dialogs will be displayed with a warning
283  instead of the title, message, etc...
284 - There's one file filter only, it may contain several patterns.
285 - If no filter description is provided,
286  the list of patterns will become the description.
287 - On windows link against Comdlg32.lib and Ole32.lib
288  (on windows the no linking claim is a lie)
289 - On unix: it tries command line calls, so no such need (NO LINKING).
290 - On unix you need one of the following:
291  applescript, kdialog, zenity, matedialog, shellementary, qarma, yad,
292  python (2 or 3)/tkinter/python-dbus (optional), Xdialog
293  or curses dialogs (opens terminal if running without console).
294 - One of those is already included on most (if not all) desktops.
295 - In the absence of those it will use gdialog, gxmessage or whiptail
296  with a textinputbox. If nothing is found, it switches to basic console input,
297  it opens a console if needed (requires xterm + bash).
298 - for curses dialogs you must set tinyfd_allowCursesDialogs=1
299 - You can query the type of dialog that will be used (pass "tinyfd_query" as aTitle)
300 - String memory is preallocated statically for all the returned values.
301 - File and path names are tested before return, they should be valid.
302 - tinyfd_forceConsole=1; at run time, forces dialogs into console mode.
303 - On windows, console mode only make sense for console applications.
304 - On windows, console mode is not implemented for wchar_T UTF-16.
305 - Mutiple selects are not possible in console mode.
306 - The package dialog must be installed to run in curses dialogs in console mode.
307  It is already installed on most unix systems.
308 - On osx, the package dialog can be installed via
309  http://macappstore.org/dialog or http://macports.org
310 - On windows, for curses dialogs console mode,
311  dialog.exe should be copied somewhere on your executable path.
312  It can be found at the bottom of the following page:
313  http://andrear.altervista.org/home/cdialog.php
314 */
int tinyfd_allowCursesDialogs
Definition: tinyfiledialogs.c:130
void tinyfd_beep(void)
Definition: tinyfiledialogs.c:4393
int tinyfd_setGlobalInt(char const *aIntVariableName, int aValue)
Definition: tinyfiledialogs.c:485
int tinyfd_getGlobalInt(char const *aIntVariableName)
Definition: tinyfiledialogs.c:470
char const * tinyfd_getGlobalChar(char const *aCharVariableName)
Definition: tinyfiledialogs.c:460
char * tinyfd_colorChooser(char const *aTitle, char const *aDefaultHexRGB, unsigned char const aDefaultRGB[3], unsigned char aoResultRGB[3])
Definition: tinyfiledialogs.c:7608
char tinyfd_needs[]
Definition: tinyfiledialogs.c:172
int tinyfd_forceConsole
Definition: tinyfiledialogs.c:131
char * tinyfd_inputBox(char const *aTitle, char const *aMessage, char const *aDefaultInput)
Definition: tinyfiledialogs.c:5679
char * tinyfd_saveFileDialog(char const *aTitle, char const *aDefaultPathAndOrFile, int aNumOfFilterPatterns, char const *const *aFilterPatterns, char const *aSingleFilterDescription)
Definition: tinyfiledialogs.c:6264
char * tinyfd_openFileDialog(char const *aTitle, char const *aDefaultPathAndOrFile, int aNumOfFilterPatterns, char const *const *aFilterPatterns, char const *aSingleFilterDescription, int aAllowMultipleSelects)
Definition: tinyfiledialogs.c:6721
char tinyfd_response[1024]
Definition: tinyfiledialogs.c:143
int tinyfd_silent
Definition: tinyfiledialogs.c:127
char * tinyfd_selectFolderDialog(char const *aTitle, char const *aDefaultPath)
Definition: tinyfiledialogs.c:7295
char tinyfd_version[8]
Definition: tinyfiledialogs.c:111
int tinyfd_messageBox(char const *aTitle, char const *aMessage, char const *aDialogType, char const *aIconType, int aDefaultButton)
Definition: tinyfiledialogs.c:4463
int tinyfd_notifyPopup(char const *aTitle, char const *aMessage, char const *aIconType)
Definition: tinyfiledialogs.c:5453
int tinyfd_verbose
Definition: tinyfiledialogs.c:126