1 #ifndef __FILE_DIALOG_H__
2 #define __FILE_DIALOG_H__
3 /**
4 * Defines the FileOpenDialog, FileSaveDialog, and FileExportDialog
5 * and their supporting classes.
6 *
7 * Authors:
8 * Bob Jamison <rwjj@earthlink.net>
9 * Inkscape Guys
10 *
11 * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
12 * Copyright (C) 2004-2006, Inkscape Authors
13 *
14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */
17 #include <glibmm.h>
18 #include <vector>
19 #include <gtkmm.h>
21 namespace Inkscape {
22 namespace Extension {
23 class Extension;
24 }
25 }
30 namespace Inkscape
31 {
32 namespace UI
33 {
34 namespace Dialog
35 {
39 /**
40 * Used for setting filters and options, and
41 * reading them back from user selections.
42 */
43 typedef enum {
44 SVG_TYPES,
45 IMPORT_TYPES,
46 EXPORT_TYPES
47 } FileDialogType;
49 /**
50 * Used for returning the type selected in a SaveAs
51 */
52 typedef enum {
53 SVG_NAMESPACE,
54 SVG_NAMESPACE_WITH_EXTENSIONS
55 } FileDialogSelectionType;
57 /**
58 * Architecture-specific data
59 */
60 typedef struct FileOpenNativeData_def FileOpenNativeData;
62 /**
63 * This class provides an implementation-independent API for
64 * file "Open" dialogs. Using a standard interface obviates the need
65 * for ugly #ifdefs in file open code
66 */
67 class FileOpenDialog
68 {
69 public:
72 /**
73 * Constructor .. do not call directly
74 * @param path the directory where to start searching
75 * @param fileTypes one of FileDialogTypes
76 * @param title the title of the dialog
77 */
78 FileOpenDialog()
79 {};
81 /**
82 * Factory.
83 * @param path the directory where to start searching
84 * @param fileTypes one of FileDialogTypes
85 * @param title the title of the dialog
86 */
87 static FileOpenDialog *create(Gtk::Window& parentWindow,
88 const Glib::ustring &path,
89 FileDialogType fileTypes,
90 const Glib::ustring &title);
93 /**
94 * Destructor.
95 * Perform any necessary cleanups.
96 */
97 virtual ~FileOpenDialog() {};
99 /**
100 * Show an OpenFile file selector.
101 * @return the selected path if user selected one, else NULL
102 */
103 virtual bool show() =0;
105 /**
106 * Return the 'key' (filetype) of the selection, if any
107 * @return a pointer to a string if successful (which must
108 * be later freed with g_free(), else NULL.
109 */
110 virtual Inkscape::Extension::Extension * getSelectionType() = 0;
112 virtual Glib::ustring getFilename () =0;
114 virtual std::vector<Glib::ustring> getFilenames () = 0;
116 }; //FileOpenDialog
123 /**
124 * This class provides an implementation-independent API for
125 * file "Save" dialogs.
126 */
127 class FileSaveDialog
128 {
129 public:
131 /**
132 * Constructor. Do not call directly . Use the factory.
133 * @param path the directory where to start searching
134 * @param fileTypes one of FileDialogTypes
135 * @param title the title of the dialog
136 * @param key a list of file types from which the user can select
137 */
138 FileSaveDialog ()
139 {};
141 /**
142 * Factory.
143 * @param path the directory where to start searching
144 * @param fileTypes one of FileDialogTypes
145 * @param title the title of the dialog
146 * @param key a list of file types from which the user can select
147 */
148 static FileSaveDialog *create(Gtk::Window& parentWindow,
149 const Glib::ustring &path,
150 FileDialogType fileTypes,
151 const Glib::ustring &title,
152 const Glib::ustring &default_key);
155 /**
156 * Destructor.
157 * Perform any necessary cleanups.
158 */
159 virtual ~FileSaveDialog() {};
162 /**
163 * Show an SaveAs file selector.
164 * @return the selected path if user selected one, else NULL
165 */
166 virtual bool show() =0;
168 /**
169 * Return the 'key' (filetype) of the selection, if any
170 * @return a pointer to a string if successful (which must
171 * be later freed with g_free(), else NULL.
172 */
173 virtual Inkscape::Extension::Extension * getSelectionType() = 0;
175 virtual void setSelectionType( Inkscape::Extension::Extension * key ) = 0;
177 virtual Glib::ustring getFilename () =0;
179 /**
180 * Change the window title.
181 */
182 virtual void change_title(const Glib::ustring& title) =0;
184 /**
185 * Change the default save path location.
186 */
187 virtual void change_path(const Glib::ustring& path) =0;
189 }; //FileSaveDialog
194 /**
195 * This class provides an implementation-independent API for
196 * file "Export" dialogs. Saving as these types will not affect
197 * the original file.
198 */
199 class FileExportDialog
200 {
201 public:
203 typedef enum
204 {
205 SCOPE_DOCUMENT,
206 SCOPE_PAGE,
207 SCOPE_SELECTION,
208 SCOPE_CUSTOM
209 } ScopeType;
211 /**
212 * Constructor. Do not call directly . Use the factory.
213 * @param path the directory where to start searching
214 * @param fileTypes one of FileDialogTypes
215 * @param title the title of the dialog
216 * @param key a list of file types from which the user can select
217 */
218 FileExportDialog()
219 {}
221 /**
222 * Factory.
223 * @param path the directory where to start searching
224 * @param fileTypes one of FileDialogTypes
225 * @param title the title of the dialog
226 * @param key a list of file types from which the user can select
227 */
228 static FileExportDialog *create(Gtk::Window& parentWindow,
229 const Glib::ustring &path,
230 FileDialogType fileTypes,
231 const Glib::ustring &title,
232 const Glib::ustring &default_key);
235 /**
236 * Destructor.
237 * Perform any necessary cleanups.
238 */
239 virtual ~FileExportDialog () {};
242 /**
243 * Show an SaveAs file selector.
244 * @return the selected path if user selected one, else NULL
245 */
246 virtual bool show() =0;
248 /**
249 * Return the 'key' (filetype) of the selection, if any
250 * @return a pointer to a string if successful (which must
251 * be later freed with g_free(), else NULL.
252 */
253 virtual Inkscape::Extension::Extension * getSelectionType() = 0;
255 /**
256 * Return the selected filename, if any. If not, return ""
257 */
258 virtual Glib::ustring getFilename () =0;
260 /**
261 * Return the scope of the export. One of the enumerated types
262 * in ScopeType
263 */
264 virtual ScopeType getScope() = 0;
266 /**
267 * Return left side of the exported region
268 */
269 virtual double getSourceX() = 0;
271 /**
272 * Return the top of the exported region
273 */
274 virtual double getSourceY() = 0;
276 /**
277 * Return the width of the exported region
278 */
279 virtual double getSourceWidth() = 0;
281 /**
282 * Return the height of the exported region
283 */
284 virtual double getSourceHeight() = 0;
286 /**
287 * Return the units of the coordinates of exported region
288 */
289 virtual Glib::ustring getSourceUnits() = 0;
291 /**
292 * Return the width of the destination document
293 */
294 virtual double getDestinationWidth() = 0;
296 /**
297 * Return the height of the destination document
298 */
299 virtual double getDestinationHeight() = 0;
301 /**
302 * Return the height of the exported region
303 */
304 virtual Glib::ustring getDestinationUnits() = 0;
306 /**
307 * Return the destination DPI image resulution, if bitmap
308 */
309 virtual double getDestinationDPI() = 0;
311 /**
312 * Return whether we should use Cairo for rendering
313 */
314 virtual bool getUseCairo() = 0;
316 /**
317 * Return whether we should use antialiasing
318 */
319 virtual bool getUseAntialias() = 0;
321 /**
322 * Return the background color for exporting
323 */
324 virtual unsigned long getBackground() = 0;
328 }; //FileExportDialog
331 } //namespace Dialog
332 } //namespace UI
333 } //namespace Inkscape
336 #endif /* __FILE_DIALOG_H__ */
338 /*
339 Local Variables:
340 mode:c++
341 c-file-style:"stroustrup"
342 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
343 indent-tabs-mode:nil
344 fill-column:99
345 End:
346 */
347 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :