FLTK 1.3.2
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
Fl_Native_File_Chooser.H
Go to the documentation of this file.
1
//
2
// "$Id: Fl_Native_File_Chooser.H 9825 2013-02-19 15:19:58Z manolo $"
3
//
4
// FLTK native OS file chooser widget
5
//
6
// Copyright 1998-2010 by Bill Spitzak and others.
7
// Copyright 2004 Greg Ercolano.
8
//
9
// This library is free software. Distribution and use rights are outlined in
10
// the file "COPYING" which should have been included with this file. If this
11
// file is missing or damaged, see the license at:
12
//
13
// http://www.fltk.org/COPYING.php
14
//
15
// Please report all bugs and problems on the following page:
16
//
17
// http://www.fltk.org/str.php
18
//
19
23
#ifndef FL_NATIVE_FILE_CHOOSER_H
24
#define FL_NATIVE_FILE_CHOOSER_H
25
26
/* \file
27
Fl_Native_File_Chooser widget. */
28
29
// Use Windows' chooser
30
#ifdef WIN32
31
// #define _WIN32_WINNT 0x0501 // needed for OPENFILENAME's 'FlagsEx'
32
#include <stdio.h>
33
#include <stdlib.h>
// malloc
34
#include <windows.h>
35
#include <commdlg.h>
// OPENFILENAME, GetOpenFileName()
36
#include <shlobj.h>
// BROWSEINFO, SHBrowseForFolder()
37
#endif
38
39
// Use Apple's chooser
40
#ifdef __APPLE__
41
#define MAXFILTERS 80
42
#endif
43
44
// All else falls back to FLTK's own chooser
45
#if ! defined(__APPLE__) && !defined(WIN32)
46
#include <FL/Fl_File_Chooser.H>
47
#include <unistd.h>
// _POSIX_NAME_MAX
48
#else
49
#include <
FL/filename.H
>
// FL_EXPORT
50
#endif
51
52
105
class
FL_EXPORT
Fl_Native_File_Chooser
{
106
public
:
107
enum
Type
{
108
BROWSE_FILE = 0,
109
BROWSE_DIRECTORY
,
110
BROWSE_MULTI_FILE
,
111
BROWSE_MULTI_DIRECTORY
,
112
BROWSE_SAVE_FILE
,
113
BROWSE_SAVE_DIRECTORY
114
};
115
enum
Option
{
116
NO_OPTIONS = 0x0000,
117
SAVEAS_CONFIRM = 0x0001,
118
NEW_FOLDER = 0x0002,
119
PREVIEW = 0x0004,
120
USE_FILTER_EXT = 0x0008
121
};
123
static
const
char
*
file_exists_message
;
124
125
public
:
126
Fl_Native_File_Chooser
(
int
val=BROWSE_FILE);
127
~
Fl_Native_File_Chooser
();
128
129
// Public methods
130
void
type(
int
);
131
int
type()
const
;
132
void
options(
int
);
133
int
options()
const
;
134
int
count()
const
;
135
const
char
*filename()
const
;
136
const
char
*filename(
int
i)
const
;
137
void
directory(
const
char
*val);
138
const
char
*directory()
const
;
139
void
title(
const
char
*);
140
const
char
* title()
const
;
141
const
char
*filter()
const
;
142
void
filter(
const
char
*);
143
int
filters()
const
;
144
void
filter_value(
int
i);
145
int
filter_value()
const
;
146
void
preset_file(
const
char
*);
147
const
char
* preset_file()
const
;
148
const
char
*errmsg()
const
;
149
int
show();
150
151
#ifdef WIN32
152
private
:
153
int
_btype;
// kind-of browser to show()
154
int
_options;
// general options
155
OPENFILENAMEW _ofn;
// GetOpenFileName() & GetSaveFileName() struct
156
BROWSEINFO _binf;
// SHBrowseForFolder() struct
157
char
**_pathnames;
// array of pathnames
158
int
_tpathnames;
// total pathnames
159
char
*_directory;
// default pathname to use
160
char
*_title;
// title for window
161
char
*_filter;
// user-side search filter
162
char
*_parsedfilt;
// filter parsed for Windows dialog
163
int
_nfilters;
// number of filters parse_filter counted
164
char
*_preset_file;
// the file to preselect
165
char
*_errmsg;
// error message
166
167
// Private methods
168
void
errmsg(
const
char
*msg);
169
170
void
clear_pathnames();
171
void
set_single_pathname(
const
char
*s);
172
void
add_pathname(
const
char
*s);
173
174
void
FreePIDL(LPITEMIDLIST pidl);
175
void
ClearOFN();
176
void
ClearBINF();
177
void
Win2Unix(
char
*s);
178
void
Unix2Win(
char
*s);
179
int
showfile();
180
static
int
CALLBACK Dir_CB(HWND win, UINT msg, LPARAM param, LPARAM data);
181
int
showdir();
182
183
void
parse_filter(
const
char
*);
184
void
clear_filters();
185
void
add_filter(
const
char
*,
const
char
*);
186
#endif
187
188
#ifdef __APPLE__
189
private
:
190
int
_btype;
// kind-of browser to show()
191
int
_options;
// general options
192
void
*_panel;
193
char
**_pathnames;
// array of pathnames
194
int
_tpathnames;
// total pathnames
195
char
*_directory;
// default pathname to use
196
char
*_title;
// title for window
197
char
*_preset_file;
// the 'save as' filename
198
199
char
*_filter;
// user-side search filter, eg:
200
// C Files\t*.[ch]\nText Files\t*.txt"
201
202
char
*_filt_names;
// filter names (tab delimited)
203
// eg. "C Files\tText Files"
204
205
char
*_filt_patt[MAXFILTERS];
206
// array of filter patterns, eg:
207
// _filt_patt[0]="*.{cxx,h}"
208
// _filt_patt[1]="*.txt"
209
210
int
_filt_total;
// parse_filter() # of filters loaded
211
int
_filt_value;
// index of the selected filter
212
char
*_errmsg;
// error message
213
214
// Private methods
215
void
errmsg(
const
char
*msg);
216
void
clear_pathnames();
217
void
set_single_pathname(
const
char
*s);
218
int
get_saveas_basename(
void
);
219
void
clear_filters();
220
void
add_filter(
const
char
*,
const
char
*);
221
void
parse_filter(
const
char
*from);
222
int
post();
223
int
runmodal();
224
#endif
225
226
#if ! defined(__APPLE__) && !defined(WIN32)
227
private
:
228
int
_btype;
// kind-of browser to show()
229
int
_options;
// general options
230
int
_nfilters;
231
char
*_filter;
// user supplied filter
232
char
*_parsedfilt;
// parsed filter
233
int
_filtvalue;
// selected filter
234
char
*_preset_file;
235
char
*_prevvalue;
// Returned filename
236
char
*_directory;
237
char
*_errmsg;
// error message
238
Fl_File_Chooser
*_file_chooser;
239
240
// Private methods
241
void
errmsg(
const
char
*msg);
242
int
type_fl_file(
int
);
243
void
parse_filter();
244
void
keeplocation();
245
int
exist_dialog();
246
#endif
247
};
248
249
250
#endif
/*FL_NATIVE_FILE_CHOOSER_H*/
251
252
//
253
// End of "$Id: Fl_Native_File_Chooser.H 9825 2013-02-19 15:19:58Z manolo $".
254
//
© 1998-2012 by Bill Spitzak and others.