Code

daefc9387c9c9ac74dca442a5be9fb6f4c3ec410
[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>
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
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;
176 }; //FileSaveDialog
181 /**
182  * This class provides an implementation-independent API for
183  * file "Export" dialogs.  Saving as these types will not affect
184  * the original file.
185  */
186 class FileExportDialog
188 public:
190     typedef enum
191         {
192         SCOPE_DOCUMENT,
193         SCOPE_PAGE,
194         SCOPE_SELECTION,
195         SCOPE_CUSTOM
196         } ScopeType;
198     /**
199      * Constructor.  Do not call directly .   Use the factory.
200      * @param path the directory where to start searching
201      * @param fileTypes one of FileDialogTypes
202      * @param title the title of the dialog
203      * @param key a list of file types from which the user can select
204      */
205     FileExportDialog()
206         {}
208     /**
209      * Factory.
210      * @param path the directory where to start searching
211      * @param fileTypes one of FileDialogTypes
212      * @param title the title of the dialog
213      * @param key a list of file types from which the user can select
214      */
215     static FileExportDialog *create(const Glib::ustring &path,
216                                     FileDialogType fileTypes,
217                                     const Glib::ustring &title,
218                                     const Glib::ustring &default_key);
221     /**
222      * Destructor.
223      * Perform any necessary cleanups.
224      */
225     virtual ~FileExportDialog () {};
228     /**
229      * Show an SaveAs file selector.
230      * @return the selected path if user selected one, else NULL
231      */
232     virtual bool show() =0;
234     /**
235      * Return the 'key' (filetype) of the selection, if any
236      * @return a pointer to a string if successful (which must
237      * be later freed with g_free(), else NULL.
238      */
239     virtual Inkscape::Extension::Extension * getSelectionType() = 0;
241     /**
242      * Return the selected filename, if any.  If not, return ""
243      */
244     virtual Glib::ustring getFilename () =0;
245     
246     /**
247      * Return the scope of the export.  One of the enumerated types
248      * in ScopeType     
249      */
250     virtual ScopeType getScope() = 0;
251     
252     /**
253      * Return left side of the exported region
254      */
255     virtual double getSourceX() = 0;
256     
257     /**
258      * Return the top of the exported region
259      */
260     virtual double getSourceY() = 0;
261     
262     /**
263      * Return the width of the exported region
264      */
265     virtual double getSourceWidth() = 0;
266     
267     /**
268      * Return the height of the exported region
269      */
270     virtual double getSourceHeight() = 0;
272     /**
273      * Return the units of the coordinates of exported region
274      */
275     virtual Glib::ustring getSourceUnits() = 0;
277     /**
278      * Return the width of the destination document
279      */
280     virtual double getDestinationWidth() = 0;
282     /**
283      * Return the height of the destination document
284      */
285     virtual double getDestinationHeight() = 0;
287     /**
288      * Return the height of the exported region
289      */
290     virtual Glib::ustring getDestinationUnits() = 0;
292     /**
293      * Return the destination DPI image resulution, if bitmap
294      */
295     virtual double getDestinationDPI() = 0;
297     /**
298      * Return whether we should use Cairo for rendering
299      */
300     virtual bool getUseCairo() = 0;
302     /**
303      * Return whether we should use antialiasing
304      */
305     virtual bool getUseAntialias() = 0;
307     /**
308      * Return the background color for exporting
309      */
310     virtual unsigned long getBackground() = 0;
312     
314 }; //FileExportDialog
317 } //namespace Dialog
318 } //namespace UI
319 } //namespace Inkscape
322 #endif /* __FILE_DIALOG_H__ */
324 /*
325   Local Variables:
326   mode:c++
327   c-file-style:"stroustrup"
328   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
329   indent-tabs-mode:nil
330   fill-column:99
331   End:
332 */
333 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :