Code

ace3361776068993c82751f3dbbc0d4a229dae0c
[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) 2004-2006, Inkscape Authors
12  *
13  * Released under GNU GPL, read the file 'COPYING' for more information
14  */
16 #include <glibmm.h>
17 #include <vector>
21 class Inkscape::Extension::Extension;
24 namespace Inkscape
25 {
26 namespace UI
27 {
28 namespace Dialog
29 {
32 /**
33  * Used for setting filters and options, and
34  * reading them back from user selections.
35  */
36 typedef enum {
37     SVG_TYPES,
38     IMPORT_TYPES,
39     EXPORT_TYPES
40     } FileDialogType;
42 /**
43  * Used for returning the type selected in a SaveAs
44  */
45 typedef enum {
46     SVG_NAMESPACE,
47     SVG_NAMESPACE_WITH_EXTENSIONS
48     } FileDialogSelectionType;
50 /**
51  * Architecture-specific data
52  */
53 typedef struct FileOpenNativeData_def FileOpenNativeData;
56 /**
57  * This class provides an implementation-independent API for
58  * file "Open" dialogs.  Using a standard interface obviates the need
59  * for ugly #ifdefs in file open code
60  */
61 class FileOpenDialog
62 {
63 public:
66     /**
67      * Constructor ..  do not call directly
68      * @param path the directory where to start searching
69      * @param fileTypes one of FileDialogTypes
70      * @param title the title of the dialog
71      */
72     FileOpenDialog()
73         {};
75     /**
76      * Factory.
77      * @param path the directory where to start searching
78      * @param fileTypes one of FileDialogTypes
79      * @param title the title of the dialog
80      */
81     static FileOpenDialog *create(const Glib::ustring &path,
82                                   FileDialogType fileTypes,
83                                   const Glib::ustring &title);
86     /**
87      * Destructor.
88      * Perform any necessary cleanups.
89      */
90     virtual ~FileOpenDialog() {};
92     /**
93      * Show an OpenFile file selector.
94      * @return the selected path if user selected one, else NULL
95      */
96     virtual bool show() =0;
98     /**
99      * Return the 'key' (filetype) of the selection, if any
100      * @return a pointer to a string if successful (which must
101      * be later freed with g_free(), else NULL.
102      */
103     virtual Inkscape::Extension::Extension * getSelectionType() = 0;
105     virtual Glib::ustring getFilename () =0;
107     virtual std::vector<Glib::ustring> getFilenames () = 0;
109 }; //FileOpenDialog
116 /**
117  * This class provides an implementation-independent API for
118  * file "Save" dialogs.
119  */
120 class FileSaveDialog
122 public:
124     /**
125      * Constructor.  Do not call directly .   Use the factory.
126      * @param path the directory where to start searching
127      * @param fileTypes one of FileDialogTypes
128      * @param title the title of the dialog
129      * @param key a list of file types from which the user can select
130      */
131     FileSaveDialog ()
132         {};
134     /**
135      * Factory.
136      * @param path the directory where to start searching
137      * @param fileTypes one of FileDialogTypes
138      * @param title the title of the dialog
139      * @param key a list of file types from which the user can select
140      */
141     static FileSaveDialog *create(const Glib::ustring &path,
142                                   FileDialogType fileTypes,
143                                   const Glib::ustring &title,
144                                   const Glib::ustring &default_key);
147     /**
148      * Destructor.
149      * Perform any necessary cleanups.
150      */
151     virtual ~FileSaveDialog() {};
154     /**
155      * Show an SaveAs file selector.
156      * @return the selected path if user selected one, else NULL
157      */
158     virtual bool show() =0;
160     /**
161      * Return the 'key' (filetype) of the selection, if any
162      * @return a pointer to a string if successful (which must
163      * be later freed with g_free(), else NULL.
164      */
165     virtual Inkscape::Extension::Extension * getSelectionType() = 0;
167     virtual Glib::ustring getFilename () =0;
170 }; //FileSaveDialog
175 /**
176  * This class provides an implementation-independent API for
177  * file "Export" dialogs.  Saving as these types will not affect
178  * the original file.
179  */
180 class FileExportDialog
182 public:
184     typedef enum
185         {
186         SCOPE_DOCUMENT,
187         SCOPE_PAGE,
188         SCOPE_SELECTION,
189         SCOPE_CUSTOM
190         } ScopeType;
192     /**
193      * Constructor.  Do not call directly .   Use the factory.
194      * @param path the directory where to start searching
195      * @param fileTypes one of FileDialogTypes
196      * @param title the title of the dialog
197      * @param key a list of file types from which the user can select
198      */
199     FileExportDialog()
200         {}
202     /**
203      * 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     static FileExportDialog *create(const Glib::ustring &path,
210                                     FileDialogType fileTypes,
211                                     const Glib::ustring &title,
212                                     const Glib::ustring &default_key);
215     /**
216      * Destructor.
217      * Perform any necessary cleanups.
218      */
219     virtual ~FileExportDialog () {};
222     /**
223      * Show an SaveAs file selector.
224      * @return the selected path if user selected one, else NULL
225      */
226     virtual bool show() =0;
228     /**
229      * Return the 'key' (filetype) of the selection, if any
230      * @return a pointer to a string if successful (which must
231      * be later freed with g_free(), else NULL.
232      */
233     virtual Inkscape::Extension::Extension * getSelectionType() = 0;
235     /**
236      * Return the selected filename, if any.  If not, return ""
237      */
238     virtual Glib::ustring getFilename () =0;
239     
240     /**
241      * Return the scope of the export.  One of the enumerated types
242      * in ScopeType     
243      */
244     virtual ScopeType getScope() = 0;
245     
246     /**
247      * Return left side of the exported region
248      */
249     virtual double getSourceX() = 0;
250     
251     /**
252      * Return the top of the exported region
253      */
254     virtual double getSourceY() = 0;
255     
256     /**
257      * Return the width of the exported region
258      */
259     virtual double getSourceWidth() = 0;
260     
261     /**
262      * Return the height of the exported region
263      */
264     virtual double getSourceHeight() = 0;
266     /**
267      * Return the units of the coordinates of exported region
268      */
269     virtual Glib::ustring getSourceUnits() = 0;
271     /**
272      * Return the width of the destination document
273      */
274     virtual double getDestinationWidth() = 0;
276     /**
277      * Return the height of the destination document
278      */
279     virtual double getDestinationHeight() = 0;
281     /**
282      * Return the height of the exported region
283      */
284     virtual Glib::ustring getDestinationUnits() = 0;
286     /**
287      * Return the destination DPI image resulution, if bitmap
288      */
289     virtual double getDestinationDPI() = 0;
291     /**
292      * Return whether we should use Cairo for rendering
293      */
294     virtual bool getUseCairo() = 0;
296     /**
297      * Return whether we should use antialiasing
298      */
299     virtual bool getUseAntialias() = 0;
301     /**
302      * Return the background color for exporting
303      */
304     virtual unsigned long getBackground() = 0;
306     
308 }; //FileExportDialog
311 } //namespace Dialog
312 } //namespace UI
313 } //namespace Inkscape
316 #endif /* __FILE_DIALOG_H__ */
318 /*
319   Local Variables:
320   mode:c++
321   c-file-style:"stroustrup"
322   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
323   indent-tabs-mode:nil
324   fill-column:99
325   End:
326 */
327 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :