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>
22 class Inkscape::Extension::Extension;
25 namespace Inkscape
26 {
27 namespace UI
28 {
29 namespace Dialog
30 {
33 /**
34 * Used for setting filters and options, and
35 * reading them back from user selections.
36 */
37 typedef enum {
38 SVG_TYPES,
39 IMPORT_TYPES,
40 EXPORT_TYPES
41 } FileDialogType;
43 /**
44 * Used for returning the type selected in a SaveAs
45 */
46 typedef enum {
47 SVG_NAMESPACE,
48 SVG_NAMESPACE_WITH_EXTENSIONS
49 } FileDialogSelectionType;
51 /**
52 * Architecture-specific data
53 */
54 typedef struct FileOpenNativeData_def FileOpenNativeData;
57 /**
58 * This class provides an implementation-independent API for
59 * file "Open" dialogs. Using a standard interface obviates the need
60 * for ugly #ifdefs in file open code
61 */
62 class FileOpenDialog
63 {
64 public:
67 /**
68 * Constructor .. do not call directly
69 * @param path the directory where to start searching
70 * @param fileTypes one of FileDialogTypes
71 * @param title the title of the dialog
72 */
73 FileOpenDialog()
74 {};
76 /**
77 * Factory.
78 * @param path the directory where to start searching
79 * @param fileTypes one of FileDialogTypes
80 * @param title the title of the dialog
81 */
82 static FileOpenDialog *create(const Glib::ustring &path,
83 FileDialogType fileTypes,
84 const Glib::ustring &title);
87 /**
88 * Destructor.
89 * Perform any necessary cleanups.
90 */
91 virtual ~FileOpenDialog() {};
93 /**
94 * Show an OpenFile file selector.
95 * @return the selected path if user selected one, else NULL
96 */
97 virtual bool show() =0;
99 /**
100 * Return the 'key' (filetype) of the selection, if any
101 * @return a pointer to a string if successful (which must
102 * be later freed with g_free(), else NULL.
103 */
104 virtual Inkscape::Extension::Extension * getSelectionType() = 0;
106 virtual Glib::ustring getFilename () =0;
108 virtual std::vector<Glib::ustring> getFilenames () = 0;
110 }; //FileOpenDialog
117 /**
118 * This class provides an implementation-independent API for
119 * file "Save" dialogs.
120 */
121 class FileSaveDialog
122 {
123 public:
125 /**
126 * Constructor. Do not call directly . Use the factory.
127 * @param path the directory where to start searching
128 * @param fileTypes one of FileDialogTypes
129 * @param title the title of the dialog
130 * @param key a list of file types from which the user can select
131 */
132 FileSaveDialog ()
133 {};
135 /**
136 * Factory.
137 * @param path the directory where to start searching
138 * @param fileTypes one of FileDialogTypes
139 * @param title the title of the dialog
140 * @param key a list of file types from which the user can select
141 */
142 static FileSaveDialog *create(const Glib::ustring &path,
143 FileDialogType fileTypes,
144 const Glib::ustring &title,
145 const Glib::ustring &default_key);
148 /**
149 * Destructor.
150 * Perform any necessary cleanups.
151 */
152 virtual ~FileSaveDialog() {};
155 /**
156 * Show an SaveAs file selector.
157 * @return the selected path if user selected one, else NULL
158 */
159 virtual bool show() =0;
161 /**
162 * Return the 'key' (filetype) of the selection, if any
163 * @return a pointer to a string if successful (which must
164 * be later freed with g_free(), else NULL.
165 */
166 virtual Inkscape::Extension::Extension * getSelectionType() = 0;
168 virtual Glib::ustring getFilename () =0;
170 /**
171 * Change the window title.
172 */
173 virtual void change_title(const Glib::ustring& title) =0;
175 /**
176 * Change the default save path location.
177 */
178 virtual void change_path(const Glib::ustring& path) =0;
180 }; //FileSaveDialog
185 /**
186 * This class provides an implementation-independent API for
187 * file "Export" dialogs. Saving as these types will not affect
188 * the original file.
189 */
190 class FileExportDialog
191 {
192 public:
194 typedef enum
195 {
196 SCOPE_DOCUMENT,
197 SCOPE_PAGE,
198 SCOPE_SELECTION,
199 SCOPE_CUSTOM
200 } ScopeType;
202 /**
203 * Constructor. Do not call directly . Use the factory.
204 * @param path the directory where to start searching
205 * @param fileTypes one of FileDialogTypes
206 * @param title the title of the dialog
207 * @param key a list of file types from which the user can select
208 */
209 FileExportDialog()
210 {}
212 /**
213 * Factory.
214 * @param path the directory where to start searching
215 * @param fileTypes one of FileDialogTypes
216 * @param title the title of the dialog
217 * @param key a list of file types from which the user can select
218 */
219 static FileExportDialog *create(const Glib::ustring &path,
220 FileDialogType fileTypes,
221 const Glib::ustring &title,
222 const Glib::ustring &default_key);
225 /**
226 * Destructor.
227 * Perform any necessary cleanups.
228 */
229 virtual ~FileExportDialog () {};
232 /**
233 * Show an SaveAs file selector.
234 * @return the selected path if user selected one, else NULL
235 */
236 virtual bool show() =0;
238 /**
239 * Return the 'key' (filetype) of the selection, if any
240 * @return a pointer to a string if successful (which must
241 * be later freed with g_free(), else NULL.
242 */
243 virtual Inkscape::Extension::Extension * getSelectionType() = 0;
245 /**
246 * Return the selected filename, if any. If not, return ""
247 */
248 virtual Glib::ustring getFilename () =0;
250 /**
251 * Return the scope of the export. One of the enumerated types
252 * in ScopeType
253 */
254 virtual ScopeType getScope() = 0;
256 /**
257 * Return left side of the exported region
258 */
259 virtual double getSourceX() = 0;
261 /**
262 * Return the top of the exported region
263 */
264 virtual double getSourceY() = 0;
266 /**
267 * Return the width of the exported region
268 */
269 virtual double getSourceWidth() = 0;
271 /**
272 * Return the height of the exported region
273 */
274 virtual double getSourceHeight() = 0;
276 /**
277 * Return the units of the coordinates of exported region
278 */
279 virtual Glib::ustring getSourceUnits() = 0;
281 /**
282 * Return the width of the destination document
283 */
284 virtual double getDestinationWidth() = 0;
286 /**
287 * Return the height of the destination document
288 */
289 virtual double getDestinationHeight() = 0;
291 /**
292 * Return the height of the exported region
293 */
294 virtual Glib::ustring getDestinationUnits() = 0;
296 /**
297 * Return the destination DPI image resulution, if bitmap
298 */
299 virtual double getDestinationDPI() = 0;
301 /**
302 * Return whether we should use Cairo for rendering
303 */
304 virtual bool getUseCairo() = 0;
306 /**
307 * Return whether we should use antialiasing
308 */
309 virtual bool getUseAntialias() = 0;
311 /**
312 * Return the background color for exporting
313 */
314 virtual unsigned long getBackground() = 0;
318 }; //FileExportDialog
321 } //namespace Dialog
322 } //namespace UI
323 } //namespace Inkscape
326 #endif /* __FILE_DIALOG_H__ */
328 /*
329 Local Variables:
330 mode:c++
331 c-file-style:"stroustrup"
332 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
333 indent-tabs-mode:nil
334 fill-column:99
335 End:
336 */
337 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :