Code

06d68fa72e05275ffb85cd71eb6c0cff6e291dc6
[inkscape.git] / src / ui / dialog / filedialog.h
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;
63 /**
64  * This class provides an implementation-independent API for
65  * file "Open" dialogs.  Using a standard interface obviates the need
66  * for ugly #ifdefs in file open code
67  */
68 class FileOpenDialog
69 {
70 public:
73     /**
74      * Constructor ..  do not call directly
75      * @param path the directory where to start searching
76      * @param fileTypes one of FileDialogTypes
77      * @param title the title of the dialog
78      */
79     FileOpenDialog()
80         {};
82     /**
83      * Factory.
84      * @param path the directory where to start searching
85      * @param fileTypes one of FileDialogTypes
86      * @param title the title of the dialog
87      */
88     static FileOpenDialog *create(Gtk::Window& parentWindow, 
89                                   const Glib::ustring &path,
90                                   FileDialogType fileTypes,
91                                   const Glib::ustring &title);
94     /**
95      * Destructor.
96      * Perform any necessary cleanups.
97      */
98     virtual ~FileOpenDialog() {};
100     /**
101      * Show an OpenFile file selector.
102      * @return the selected path if user selected one, else NULL
103      */
104     virtual bool show() =0;
106     /**
107      * Return the 'key' (filetype) of the selection, if any
108      * @return a pointer to a string if successful (which must
109      * be later freed with g_free(), else NULL.
110      */
111     virtual Inkscape::Extension::Extension * getSelectionType() = 0;
113     virtual Glib::ustring getFilename () =0;
115     virtual std::vector<Glib::ustring> getFilenames () = 0;
117 }; //FileOpenDialog
124 /**
125  * This class provides an implementation-independent API for
126  * file "Save" dialogs.
127  */
128 class FileSaveDialog
130 public:
132     /**
133      * Constructor.  Do not call directly .   Use the factory.
134      * @param path the directory where to start searching
135      * @param fileTypes one of FileDialogTypes
136      * @param title the title of the dialog
137      * @param key a list of file types from which the user can select
138      */
139     FileSaveDialog ()
140         {};
142     /**
143      * Factory.
144      * @param path the directory where to start searching
145      * @param fileTypes one of FileDialogTypes
146      * @param title the title of the dialog
147      * @param key a list of file types from which the user can select
148      */
149     static FileSaveDialog *create(Gtk::Window& parentWindow, 
150                                                           const Glib::ustring &path,
151                                   FileDialogType fileTypes,
152                                   const Glib::ustring &title,
153                                   const Glib::ustring &default_key);
156     /**
157      * Destructor.
158      * Perform any necessary cleanups.
159      */
160     virtual ~FileSaveDialog() {};
163     /**
164      * Show an SaveAs file selector.
165      * @return the selected path if user selected one, else NULL
166      */
167     virtual bool show() =0;
169     /**
170      * Return the 'key' (filetype) of the selection, if any
171      * @return a pointer to a string if successful (which must
172      * be later freed with g_free(), else NULL.
173      */
174     virtual Inkscape::Extension::Extension * getSelectionType() = 0;
176     virtual void setSelectionType( Inkscape::Extension::Extension * key ) = 0;
178     virtual Glib::ustring getFilename () =0;
180     /**
181      * Change the window title.
182      */
183     virtual void change_title(const Glib::ustring& title) =0;
185     /**
186      * Change the default save path location.
187      */
188     virtual void change_path(const Glib::ustring& path) =0;
190 }; //FileSaveDialog
195 /**
196  * This class provides an implementation-independent API for
197  * file "Export" dialogs.  Saving as these types will not affect
198  * the original file.
199  */
200 class FileExportDialog
202 public:
204     typedef enum
205         {
206         SCOPE_DOCUMENT,
207         SCOPE_PAGE,
208         SCOPE_SELECTION,
209         SCOPE_CUSTOM
210         } ScopeType;
212     /**
213      * Constructor.  Do not call directly .   Use the 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     FileExportDialog()
220         {}
222     /**
223      * Factory.
224      * @param path the directory where to start searching
225      * @param fileTypes one of FileDialogTypes
226      * @param title the title of the dialog
227      * @param key a list of file types from which the user can select
228      */
229     static FileExportDialog *create(Gtk::Window& parentWindow, 
230                                         const Glib::ustring &path,
231                                     FileDialogType fileTypes,
232                                     const Glib::ustring &title,
233                                     const Glib::ustring &default_key);
236     /**
237      * Destructor.
238      * Perform any necessary cleanups.
239      */
240     virtual ~FileExportDialog () {};
243     /**
244      * Show an SaveAs file selector.
245      * @return the selected path if user selected one, else NULL
246      */
247     virtual bool show() =0;
249     /**
250      * Return the 'key' (filetype) of the selection, if any
251      * @return a pointer to a string if successful (which must
252      * be later freed with g_free(), else NULL.
253      */
254     virtual Inkscape::Extension::Extension * getSelectionType() = 0;
256     /**
257      * Return the selected filename, if any.  If not, return ""
258      */
259     virtual Glib::ustring getFilename () =0;
260     
261     /**
262      * Return the scope of the export.  One of the enumerated types
263      * in ScopeType     
264      */
265     virtual ScopeType getScope() = 0;
266     
267     /**
268      * Return left side of the exported region
269      */
270     virtual double getSourceX() = 0;
271     
272     /**
273      * Return the top of the exported region
274      */
275     virtual double getSourceY() = 0;
276     
277     /**
278      * Return the width of the exported region
279      */
280     virtual double getSourceWidth() = 0;
281     
282     /**
283      * Return the height of the exported region
284      */
285     virtual double getSourceHeight() = 0;
287     /**
288      * Return the units of the coordinates of exported region
289      */
290     virtual Glib::ustring getSourceUnits() = 0;
292     /**
293      * Return the width of the destination document
294      */
295     virtual double getDestinationWidth() = 0;
297     /**
298      * Return the height of the destination document
299      */
300     virtual double getDestinationHeight() = 0;
302     /**
303      * Return the height of the exported region
304      */
305     virtual Glib::ustring getDestinationUnits() = 0;
307     /**
308      * Return the destination DPI image resulution, if bitmap
309      */
310     virtual double getDestinationDPI() = 0;
312     /**
313      * Return whether we should use Cairo for rendering
314      */
315     virtual bool getUseCairo() = 0;
317     /**
318      * Return whether we should use antialiasing
319      */
320     virtual bool getUseAntialias() = 0;
322     /**
323      * Return the background color for exporting
324      */
325     virtual unsigned long getBackground() = 0;
327     
329 }; //FileExportDialog
332 /**
333  * This class provides an implementation-independent API for
334  * file "ExportToOCAL" dialogs.
335  */
336 class FileExportToOCALDialog
338 public:
340     /**
341      * Constructor.  Do not call directly .   Use the factory.
342      * @param fileTypes one of FileDialogTypes
343      * @param title the title of the dialog
344      * @param key a list of file types from which the user can select
345      */
346     FileExportToOCALDialog ()
347         {};
349     /**
350      * Factory.
351      * @param fileTypes one of FileDialogTypes
352      * @param title the title of the dialog
353      * @param key a list of file types from which the user can select
354      */
355     static FileExportToOCALDialog *create(Gtk::Window& parentWindow, 
356                                      FileDialogType fileTypes,
357                                      const Glib::ustring &title,
358                                      const Glib::ustring &default_key);
361     /**
362      * Destructor.
363      * Perform any necessary cleanups.
364      */
365     virtual ~FileExportToOCALDialog() {};
368     /**
369      * Show an SaveAs file selector.
370      * @return the selected path if user selected one, else NULL
371      */
372     virtual bool show() =0;
374     /**
375      * Return the 'key' (filetype) of the selection, if any
376      * @return a pointer to a string if successful (which must
377      * be later freed with g_free(), else NULL.
378      */
379     virtual Inkscape::Extension::Extension * getSelectionType() = 0;
381     virtual void setSelectionType( Inkscape::Extension::Extension * key ) = 0;
383     virtual Glib::ustring getFilename () =0;
385     /**
386      * Change the window title.
387      */
388     virtual void change_title(const Glib::ustring& title) =0;
391 }; //FileExportToOCAL
395 } //namespace Dialog
396 } //namespace UI
397 } //namespace Inkscape
400 #endif /* __FILE_DIALOG_H__ */
402 /*
403   Local Variables:
404   mode:c++
405   c-file-style:"stroustrup"
406   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
407   indent-tabs-mode:nil
408   fill-column:99
409   End:
410 */
411 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :