Debian Codegraph @

pt_pal_editor/src/tinyfiledialogs/tinyfiledialogs.h

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