aboutsummaryrefslogtreecommitdiff
path: root/src/lib/FL/Fl_Native_File_Chooser_WIN32.H
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/FL/Fl_Native_File_Chooser_WIN32.H')
-rw-r--r--src/lib/FL/Fl_Native_File_Chooser_WIN32.H114
1 files changed, 114 insertions, 0 deletions
diff --git a/src/lib/FL/Fl_Native_File_Chooser_WIN32.H b/src/lib/FL/Fl_Native_File_Chooser_WIN32.H
new file mode 100644
index 0000000..ead87df
--- /dev/null
+++ b/src/lib/FL/Fl_Native_File_Chooser_WIN32.H
@@ -0,0 +1,114 @@
1//
2// Fl_Native_File_Chooser_WINDOWS.H -- FLTK native OS file chooser widget
3//
4// Copyright 2004 by Greg Ercolano.
5// April 2005 - API changes, improved filter processing by Nathan Vander Wilt
6//
7// This library is free software; you can redistribute it and/or
8// modify it under the terms of the GNU Library General Public
9// License as published by the Free Software Foundation; either
10// version 2 of the License, or (at your option) any later version.
11//
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15// Library General Public License for more details.
16//
17// You should have received a copy of the GNU Library General Public
18// License along with this library; if not, write to the Free Software
19// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20// USA.
21//
22#ifndef _FL_NATIVE_FILE_BROWSER_H
23#define _FL_NATIVE_FILE_BROWSER_H
24
25// #define _WIN32_WINNT 0x0501 // needed for OPENFILENAME's 'FlagsEx'
26#include <stdio.h>
27#include <stdlib.h> // malloc
28#include <windows.h>
29#include <commdlg.h> // OPENFILENAME, GetOpenFileName()
30#include <shlobj.h> // BROWSEINFO, SHBrowseForFolder()
31
32#define MAXFILTERS 80
33
34class Fl_Native_File_Chooser {
35public:
36 enum Type {
37 BROWSE_FILE = 0,
38 BROWSE_DIRECTORY,
39 BROWSE_MULTI_FILE,
40 BROWSE_MULTI_DIRECTORY,
41 BROWSE_SAVE_FILE,
42 BROWSE_SAVE_DIRECTORY
43 };
44 enum Option {
45 NO_OPTIONS = 0x0000, // no options enabled
46 SAVEAS_CONFIRM = 0x0001, // Show native 'Save As' overwrite
47 // confirm dialog (if supported)
48 NEW_FOLDER = 0x0002, // Show 'New Folder' icon
49 // (if supported)
50 PREVIEW = 0x0004, // enable preview mode
51 };
52private:
53 int _btype; // kind-of browser to show()
54 int _options; // general options
55 OPENFILENAME _ofn; // GetOpenFileName() & GetSaveFileName() struct
56 BROWSEINFO _binf; // SHBrowseForFolder() struct
57 char **_pathnames; // array of pathnames
58 int _tpathnames; // total pathnames
59 char *_directory; // default pathname to use
60 char *_title; // title for window
61 char *_filter; // user-side search filter
62 char *_parsedfilt; // filter parsed for Windows dialog
63 int _nfilters; // number of filters parse_filter counted
64 char *_preset_file; // the file to preselect
65 char *_errmsg; // error message
66
67 // Private methods
68 void errmsg(const char *msg);
69
70 void clear_pathnames();
71 void set_single_pathname(const char *s);
72 void add_pathname(const char *s);
73
74 void FreePIDL(ITEMIDLIST *pidl);
75 void ClearOFN();
76 void ClearBINF();
77 void Win2Unix(char *s);
78 void Unix2Win(char *s);
79 int showfile();
80 static int CALLBACK Dir_CB(HWND win, UINT msg, LPARAM param, LPARAM data);
81 int showdir();
82
83 void parse_filter(const char *);
84 void clear_filters();
85 void add_filter(const char *, const char *);
86
87public:
88 Fl_Native_File_Chooser(int val = BROWSE_FILE);
89 ~Fl_Native_File_Chooser();
90
91 // Public methods
92 void type(int val);
93 int type() const;
94 void options(int);
95 int options() const;
96 int count() const;
97 const char *filename() const;
98 const char *filename(int i) const;
99 void directory(const char *val);
100 const char *directory() const;
101 void title(const char *val);
102 const char *title() const;
103 const char *filter() const;
104 void filter(const char *val);
105 int filters() const { return _nfilters; }
106 void filter_value(int i);
107 int filter_value() const;
108 void preset_file(const char *);
109 const char *preset_file() const;
110 const char *errmsg() const;
111 int show();
112};
113
114#endif /*_FL_NATIVE_FILE_BROWSER_H*/