tinyfiledialogs.h
Go to the documentation of this file.
1 /*_________
2  / \ tinyfiledialogs.h v3.4.1 [Oct 29, 2019] zlib licence
3  |tiny file| Unique header file created [November 9, 2014]
4  | dialogs | Copyright (c) 2014 - 2018 Guillaume Vareille http://ysengrin.com
5  \____ ___/ http://tinyfiledialogs.sourceforge.net
6  \| git clone http://git.code.sf.net/p/tinyfiledialogs/code tinyfd
7  ____________________________________________
8  | |
9  | email: tinyfiledialogs at ysengrin.com |
10  |____________________________________________|
11  ________________________________________________________________________
12  | |
13  | the windows only wchar_t UTF-16 prototypes are at the end of this file |
14  |________________________________________________________________________|
15 
16 Please upvote my stackoverflow answer https://stackoverflow.com/a/47651444
17 
18 tiny file dialogs (cross-platform C C++)
19 InputBox PasswordBox MessageBox ColorPicker
20 OpenFileDialog SaveFileDialog SelectFolderDialog
21 Native dialog library for WINDOWS MAC OSX GTK+ QT CONSOLE & more
22 SSH supported via automatic switch to console mode or X11 forwarding
23 
24 one C file + a header (add them to your C or C++ project) with 8 functions:
25 - beep
26 - notify popup (tray)
27 - message & question
28 - input & password
29 - save file
30 - open file(s)
31 - select folder
32 - color picker
33 
34 Complements OpenGL Vulkan GLFW GLUT GLUI VTK SFML TGUI
35 SDL Ogre Unity3d ION OpenCV CEGUI MathGL GLM CPW GLOW
36 Open3D IMGUI MyGUI GLT NGL STB & GUI less programs
37 
38 NO INIT
39 NO MAIN LOOP
40 NO LINKING
41 NO INCLUDE
42 
43 The dialogs can be forced into console mode
44 
45 Windows (XP to 10) ASCII MBCS UTF-8 UTF-16
46 - native code & vbs create the graphic dialogs
47 - enhanced console mode can use dialog.exe from
48 http://andrear.altervista.org/home/cdialog.php
49 - basic console input
50 
51 Unix (command line calls) ASCII UTF-8
52 - applescript, kdialog, zenity
53 - python (2 or 3) + tkinter + python-dbus (optional)
54 - dialog (opens a console if needed)
55 - basic console input
56 The same executable can run across desktops & distributions
57 
58 C89 & C++98 compliant: tested with C & C++ compilers
59 VisualStudio MinGW-gcc GCC Clang TinyCC OpenWatcom-v2 BorlandC SunCC ZapCC
60 on Windows Mac Linux Bsd Solaris Minix Raspbian
61 using Gnome Kde Enlightenment Mate Cinnamon Budgie Unity Lxde Lxqt Xfce
62 WindowMaker IceWm Cde Jds OpenBox Awesome Jwm Xdm
63 
64 Bindings for LUA and C# dll, Haskell
65 Included in LWJGL(java), Rust, Allegrobasic
66 
67 - License -
68 
69 This software is provided 'as-is', without any express or implied
70 warranty. In no event will the authors be held liable for any damages
71 arising from the use of this software.
72 
73 Permission is granted to anyone to use this software for any purpose,
74 including commercial applications, and to alter it and redistribute it
75 freely, subject to the following restrictions:
76 
77 1. The origin of this software must not be misrepresented; you must not
78 claim that you wrote the original software. If you use this software
79 in a product, an acknowledgment in the product documentation would be
80 appreciated but is not required.
81 2. Altered source versions must be plainly marked as such, and must not be
82 misrepresented as being the original software.
83 3. This notice may not be removed or altered from any source distribution.
84 */
85 
86 #ifndef TINYFILEDIALOGS_H
87 #define TINYFILEDIALOGS_H
88 
89 /* #define TINYFD_NOLIB */
90 /* On windows, define TINYFD_NOLIB here
91 if you don't want to include the code creating the graphic dialogs.
92 Then you won't need to link against Comdlg32.lib and Ole32.lib */
93 
94 /* if tinydialogs.c is compiled as C++ code rather than C code,
95 you may need to comment out:
96 extern "C" {
97 and the corresponding closing bracket near the end of this file:
98 }
99 */
100 #ifdef __cplusplus
101 extern "C" {
102 #endif
103 
104 extern char const tinyfd_version[8]; /* contains tinyfd current version number */
105 extern char const tinyfd_needs[]; /* info about requirements */
106 extern int tinyfd_verbose; /* 0 (default) or 1 : on unix, prints the command line calls */
107 extern int tinyfd_silent; /* 1 (default) or 0 : on unix,
108  hide errors and warnings from called dialog*/
109 
110 #ifdef _WIN32
111 /* for UTF-16 use the functions at the end of this files */
112 extern int tinyfd_winUtf8; /* 0 (default MBCS) or 1 (UTF-8)*/
113 /* on windows string char can be 0:MBCS or 1:UTF-8
114 unless your code is really prepared for UTF-8 on windows, leave this on MBSC.
115 Or you can use the UTF-16 (wchar) prototypes at the end of ths file.*/
116 #endif
117 
118 extern int tinyfd_forceConsole; /* 0 (default) or 1 */
119 /* for unix & windows: 0 (graphic mode) or 1 (console mode).
120 0: try to use a graphic solution, if it fails then it uses console mode.
121 1: forces all dialogs into console mode even when an X server is present,
122  if the package dialog (and a console is present) or dialog.exe is installed.
123  on windows it only make sense for console applications */
124 
125 extern char tinyfd_response[1024];
126 /* if you pass "tinyfd_query" as aTitle,
127 the functions will not display the dialogs
128 but will return 0 for console mode, 1 for graphic mode.
129 tinyfd_response is then filled with the retain solution.
130 possible values for tinyfd_response are (all lowercase)
131 for graphic mode:
132  windows_wchar windows
133  applescript kdialog zenity zenity3 matedialog qarma
134  python2-tkinter python3-tkinter python-dbus perl-dbus
135  gxmessage gmessage xmessage xdialog gdialog
136 for console mode:
137  dialog whiptail basicinput no_solution */
138 
139 void tinyfd_beep(void);
140 
142  char const * const aTitle, /* NULL or "" */
143  char const * const aMessage, /* NULL or "" may contain \n \t */
144  char const * const aIconType); /* "info" "warning" "error" */
145  /* return has only meaning for tinyfd_query */
146 
148  char const * const aTitle , /* NULL or "" */
149  char const * const aMessage , /* NULL or "" may contain \n \t */
150  char const * const aDialogType , /* "ok" "okcancel" "yesno" "yesnocancel" */
151  char const * const aIconType , /* "info" "warning" "error" "question" */
152  int const aDefaultButton ) ;
153  /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
154 
155 char const * tinyfd_inputBox(
156  char const * const aTitle , /* NULL or "" */
157  char const * const aMessage , /* NULL or "" may NOT contain \n \t on windows */
158  char const * const aDefaultInput ) ; /* "" , if NULL it's a passwordBox */
159  /* returns NULL on cancel */
160 
161 char const * tinyfd_saveFileDialog(
162  char const * const aTitle , /* NULL or "" */
163  char const * const aDefaultPathAndFile , /* NULL or "" */
164  int const aNumOfFilterPatterns , /* 0 */
165  char const * const * const aFilterPatterns , /* NULL | {"*.jpg","*.png"} */
166  char const * const aSingleFilterDescription ) ; /* NULL | "text files" */
167  /* returns NULL on cancel */
168 
169 char const * tinyfd_openFileDialog(
170  char const * const aTitle , /* NULL or "" */
171  char const * const aDefaultPathAndFile , /* NULL or "" */
172  int const aNumOfFilterPatterns , /* 0 */
173  char const * const * const aFilterPatterns , /* NULL | {"*.jpg","*.png"} */
174  char const * const aSingleFilterDescription , /* NULL | "image files" */
175  int const aAllowMultipleSelects ) ; /* 0 or 1 */
176  /* in case of multiple files, the separator is | */
177  /* returns NULL on cancel */
178 
179 char const * tinyfd_selectFolderDialog(
180  char const * const aTitle , /* NULL or "" */
181  char const * const aDefaultPath ) ; /* NULL or "" */
182  /* returns NULL on cancel */
183 
184 char const * tinyfd_colorChooser(
185  char const * const aTitle , /* NULL or "" */
186  char const * const aDefaultHexRGB , /* NULL or "#FF0000" */
187  unsigned char const aDefaultRGB[3] , /* { 0 , 255 , 255 } */
188  unsigned char aoResultRGB[3] ) ; /* { 0 , 0 , 0 } */
189  /* returns the hexcolor as a string "#FF0000" */
190  /* aoResultRGB also contains the result */
191  /* aDefaultRGB is used only if aDefaultHexRGB is NULL */
192  /* aDefaultRGB and aoResultRGB can be the same array */
193  /* returns NULL on cancel */
194 
195 
196 /************ NOT CROSS PLATFORM SECTION STARTS HERE ************************/
197 #ifdef _WIN32
198 #ifndef TINYFD_NOLIB
199 
200 /* windows only - utf-16 version */
201 int tinyfd_notifyPopupW(
202  wchar_t const * const aTitle, /* NULL or L"" */
203  wchar_t const * const aMessage, /* NULL or L"" may contain \n \t */
204  wchar_t const * const aIconType); /* L"info" L"warning" L"error" */
205 
206 /* windows only - utf-16 version */
207 int tinyfd_messageBoxW(
208  wchar_t const * const aTitle , /* NULL or L"" */
209  wchar_t const * const aMessage, /* NULL or L"" may contain \n \t */
210  wchar_t const * const aDialogType, /* L"ok" L"okcancel" L"yesno" */
211  wchar_t const * const aIconType, /* L"info" L"warning" L"error" L"question" */
212  int const aDefaultButton ); /* 0 for cancel/no , 1 for ok/yes */
213  /* returns 0 for cancel/no , 1 for ok/yes */
214 
215 /* windows only - utf-16 version */
216 wchar_t const * tinyfd_inputBoxW(
217  wchar_t const * const aTitle, /* NULL or L"" */
218  wchar_t const * const aMessage, /* NULL or L"" may NOT contain \n nor \t */
219  wchar_t const * const aDefaultInput ); /* L"" , if NULL it's a passwordBox */
220 
221 /* windows only - utf-16 version */
222 wchar_t const * tinyfd_saveFileDialogW(
223  wchar_t const * const aTitle, /* NULL or L"" */
224  wchar_t const * const aDefaultPathAndFile, /* NULL or L"" */
225  int const aNumOfFilterPatterns, /* 0 */
226  wchar_t const * const * const aFilterPatterns, /* NULL or {L"*.jpg",L"*.png"} */
227  wchar_t const * const aSingleFilterDescription); /* NULL or L"image files" */
228  /* returns NULL on cancel */
229 
230 /* windows only - utf-16 version */
231 wchar_t const * tinyfd_openFileDialogW(
232  wchar_t const * const aTitle, /* NULL or L"" */
233  wchar_t const * const aDefaultPathAndFile, /* NULL or L"" */
234  int const aNumOfFilterPatterns , /* 0 */
235  wchar_t const * const * const aFilterPatterns, /* NULL {L"*.jpg",L"*.png"} */
236  wchar_t const * const aSingleFilterDescription, /* NULL or L"image files" */
237  int const aAllowMultipleSelects ) ; /* 0 or 1 */
238  /* in case of multiple files, the separator is | */
239  /* returns NULL on cancel */
240 
241 /* windows only - utf-16 version */
242 wchar_t const * tinyfd_selectFolderDialogW(
243  wchar_t const * const aTitle, /* NULL or L"" */
244  wchar_t const * const aDefaultPath); /* NULL or L"" */
245  /* returns NULL on cancel */
246 
247 /* windows only - utf-16 version */
248 wchar_t const * tinyfd_colorChooserW(
249  wchar_t const * const aTitle, /* NULL or L"" */
250  wchar_t const * const aDefaultHexRGB, /* NULL or L"#FF0000" */
251  unsigned char const aDefaultRGB[3] , /* { 0 , 255 , 255 } */
252  unsigned char aoResultRGB[3] ) ; /* { 0 , 0 , 0 } */
253  /* returns the hexcolor as a string L"#FF0000" */
254  /* aoResultRGB also contains the result */
255  /* aDefaultRGB is used only if aDefaultHexRGB is NULL */
256  /* aDefaultRGB and aoResultRGB can be the same array */
257  /* returns NULL on cancel */
258 
259 
260 #endif /*TINYFD_NOLIB*/
261 #else /*_WIN32*/
262 
263 /* unix zenity only */
264 char const * tinyfd_arrayDialog(
265  char const * const aTitle , /* NULL or "" */
266  int const aNumOfColumns , /* 2 */
267  char const * const * const aColumns, /* {"Column 1","Column 2"} */
268  int const aNumOfRows, /* 2 */
269  char const * const * const aCells);
270  /* {"Row1 Col1","Row1 Col2","Row2 Col1","Row2 Col2"} */
271 
272 #endif /*_WIN32 */
273 
274 #ifdef __cplusplus
275 }
276 #endif
277 
278 #endif /* TINYFILEDIALOGS_H */
279 
280 /*
281 - This is not for android nor ios.
282 - The code is pure C, perfectly compatible with C++.
283 - the windows only wchar_t (utf-16) prototypes are in the header file
284 - windows is fully supported from XP to 10 (maybe even older versions)
285 - C# & LUA via dll, see example files
286 - OSX supported from 10.4 to latest (maybe even older versions)
287 - Avoid using " and ' in titles and messages.
288 - There's one file filter only, it may contain several patterns.
289 - If no filter description is provided,
290  the list of patterns will become the description.
291 - char const * filterPatterns[3] = { "*.obj" , "*.stl" , "*.dxf" } ;
292 - On windows char defaults to MBCS, set tinyfd_winUtf8=1 to use UTF-8
293 - On windows link against Comdlg32.lib and Ole32.lib
294  This linking is not compulsary for console mode (see above).
295 - On unix: it tries command line calls, so no such need.
296 - On unix you need one of the following:
297  applescript, kdialog, zenity, matedialog, shellementary, qarma,
298  python (2 or 3)/tkinter/python-dbus (optional), Xdialog
299  or dialog (opens terminal if running without console) or xterm.
300 - One of those is already included on most (if not all) desktops.
301 - In the absence of those it will use gdialog, gxmessage or whiptail
302  with a textinputbox.
303 - If nothing is found, it switches to basic console input,
304  it opens a console if needed (requires xterm + bash).
305 - Use windows separators on windows and unix separators on unix.
306 - String memory is preallocated statically for all the returned values.
307 - File and path names are tested before return, they are valid.
308 - If you pass only a path instead of path + filename,
309  make sure it ends with a separator.
310 - tinyfd_forceConsole=1; at run time, forces dialogs into console mode.
311 - On windows, console mode only make sense for console applications.
312 - On windows, Console mode is not implemented for wchar_T UTF-16.
313 - Mutiple selects are not allowed in console mode.
314 - The package dialog must be installed to run in enhanced console mode.
315  It is already installed on most unix systems.
316 - On osx, the package dialog can be installed via
317  http://macappstore.org/dialog or http://macports.org
318 - On windows, for enhanced console mode,
319  dialog.exe should be copied somewhere on your executable path.
320  It can be found at the bottom of the following page:
321  http://andrear.altervista.org/home/cdialog.php
322 - If dialog is missing, it will switch to basic console input.
323 - You can query the type of dialog that will be use (pass "tinyfd_query" as aTitle)
324 */
int tinyfd_silent
char const * tinyfd_colorChooser(char const *const aTitle, char const *const aDefaultHexRGB, unsigned char const aDefaultRGB[3], unsigned char aoResultRGB[3])
char tinyfd_response[1024]
int tinyfd_forceConsole
char const * tinyfd_inputBox(char const *const aTitle, char const *const aMessage, char const *const aDefaultInput)
char const * tinyfd_selectFolderDialog(char const *const aTitle, char const *const aDefaultPath)
void tinyfd_beep(void)
char const * tinyfd_arrayDialog(char const *const aTitle, int const aNumOfColumns, char const *const *const aColumns, int const aNumOfRows, char const *const *const aCells)
int tinyfd_notifyPopup(char const *const aTitle, char const *const aMessage, char const *const aIconType)
int tinyfd_verbose
char const tinyfd_needs[]
char const tinyfd_version[8]
char const * tinyfd_openFileDialog(char const *const aTitle, char const *const aDefaultPathAndFile, int const aNumOfFilterPatterns, char const *const *const aFilterPatterns, char const *const aSingleFilterDescription, int const aAllowMultipleSelects)
char const * tinyfd_saveFileDialog(char const *const aTitle, char const *const aDefaultPathAndFile, int const aNumOfFilterPatterns, char const *const *const aFilterPatterns, char const *const aSingleFilterDescription)
int tinyfd_messageBox(char const *const aTitle, char const *const aMessage, char const *const aDialogType, char const *const aIconType, int const aDefaultButton)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:12