Code

5499603d3926a5481108a34cd907cb39a6f6606c
[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(Gtk::Window& parentWindow, 
83                                   const Glib::ustring &path,
84                                   FileDialogType fileTypes,
85                                   const Glib::ustring &title);
88     /**
89      * Destructor.
90      * Perform any necessary cleanups.
91      */
92     virtual ~FileOpenDialog() {};
94     /**
95      * Show an OpenFile file selector.
96      * @return the selected path if user selected one, else NULL
97      */
98     virtual bool show() =0;
100     /**
101      * Return the 'key' (filetype) of the selection, if any
102      * @return a pointer to a string if successful (which must
103      * be later freed with g_free(), else NULL.
104      */
105     virtual Inkscape::Extension::Extension * getSelectionType() = 0;
107     virtual Glib::ustring getFilename () =0;
109     virtual std::vector<Glib::ustring> getFilenames () = 0;
111 }; //FileOpenDialog
118 /**
119  * This class provides an implementation-independent API for
120  * file "Save" dialogs.
121  */
122 class FileSaveDialog
124 public:
126     /**
127      * Constructor.  Do not call directly .   Use the factory.
128      * @param path the directory where to start searching
129      * @param fileTypes one of FileDialogTypes
130      * @param title the title of the dialog
131      * @param key a list of file types from which the user can select
132      */
133     FileSaveDialog ()
134         {};
136     /**
137      * Factory.
138      * @param path the directory where to start searching
139      * @param fileTypes one of FileDialogTypes
140      * @param title the title of the dialog
141      * @param key a list of file types from which the user can select
142      */
143     static FileSaveDialog *create(Gtk::Window& parentWindow, 
144                                                           const Glib::ustring &path,
145                                   FileDialogType fileTypes,
146                                   const Glib::ustring &title,
147                                   const Glib::ustring &default_key);
150     /**
151      * Destructor.
152      * Perform any necessary cleanups.
153      */
154     virtual ~FileSaveDialog() {};
157     /**
158      * Show an SaveAs file selector.
159      * @return the selected path if user selected one, else NULL
160      */
161     virtual bool show() =0;
163     /**
164      * Return the 'key' (filetype) of the selection, if any
165      * @return a pointer to a string if successful (which must
166      * be later freed with g_free(), else NULL.
167      */
168     virtual Inkscape::Extension::Extension * getSelectionType() = 0;
170     virtual void setSelectionType( Inkscape::Extension::Extension * key ) = 0;
172     virtual Glib::ustring getFilename () =0;
174     /**
175      * Change the window title.
176      */
177     virtual void change_title(const Glib::ustring& title) =0;
179     /**
180      * Change the default save path location.
181      */
182     virtual void change_path(const Glib::ustring& path) =0;
184 }; //FileSaveDialog
189 /**
190  * This class provides an implementation-independent API for
191  * file "Export" dialogs.  Saving as these types will not affect
192  * the original file.
193  */
194 class FileExportDialog
196 public:
198     typedef enum
199         {
200         SCOPE_DOCUMENT,
201         SCOPE_PAGE,
202         SCOPE_SELECTION,
203         SCOPE_CUSTOM
204         } ScopeType;
206     /**
207      * Constructor.  Do not call directly .   Use the factory.
208      * @param path the directory where to start searching
209      * @param fileTypes one of FileDialogTypes
210      * @param title the title of the dialog
211      * @param key a list of file types from which the user can select
212      */
213     FileExportDialog()
214         {}
216     /**
217      * Factory.
218      * @param path the directory where to start searching
219      * @param fileTypes one of FileDialogTypes
220      * @param title the title of the dialog
221      * @param key a list of file types from which the user can select
222      */
223     static FileExportDialog *create(Gtk::Window& parentWindow, 
224                                         const Glib::ustring &path,
225                                     FileDialogType fileTypes,
226                                     const Glib::ustring &title,
227                                     const Glib::ustring &default_key);
230     /**
231      * Destructor.
232      * Perform any necessary cleanups.
233      */
234     virtual ~FileExportDialog () {};
237     /**
238      * Show an SaveAs file selector.
239      * @return the selected path if user selected one, else NULL
240      */
241     virtual bool show() =0;
243     /**
244      * Return the 'key' (filetype) of the selection, if any
245      * @return a pointer to a string if successful (which must
246      * be later freed with g_free(), else NULL.
247      */
248     virtual Inkscape::Extension::Extension * getSelectionType() = 0;
250     /**
251      * Return the selected filename, if any.  If not, return ""
252      */
253     virtual Glib::ustring getFilename () =0;
254     
255     /**
256      * Return the scope of the export.  One of the enumerated types
257      * in ScopeType     
258      */
259     virtual ScopeType getScope() = 0;
260     
261     /**
262      * Return left side of the exported region
263      */
264     virtual double getSourceX() = 0;
265     
266     /**
267      * Return the top of the exported region
268      */
269     virtual double getSourceY() = 0;
270     
271     /**
272      * Return the width of the exported region
273      */
274     virtual double getSourceWidth() = 0;
275     
276     /**
277      * Return the height of the exported region
278      */
279     virtual double getSourceHeight() = 0;
281     /**
282      * Return the units of the coordinates of exported region
283      */
284     virtual Glib::ustring getSourceUnits() = 0;
286     /**
287      * Return the width of the destination document
288      */
289     virtual double getDestinationWidth() = 0;
291     /**
292      * Return the height of the destination document
293      */
294     virtual double getDestinationHeight() = 0;
296     /**
297      * Return the height of the exported region
298      */
299     virtual Glib::ustring getDestinationUnits() = 0;
301     /**
302      * Return the destination DPI image resulution, if bitmap
303      */
304     virtual double getDestinationDPI() = 0;
306     /**
307      * Return whether we should use Cairo for rendering
308      */
309     virtual bool getUseCairo() = 0;
311     /**
312      * Return whether we should use antialiasing
313      */
314     virtual bool getUseAntialias() = 0;
316     /**
317      * Return the background color for exporting
318      */
319     virtual unsigned long getBackground() = 0;
321     
323 }; //FileExportDialog
326 } //namespace Dialog
327 } //namespace UI
328 } //namespace Inkscape
331 #endif /* __FILE_DIALOG_H__ */
333 /*
334   Local Variables:
335   mode:c++
336   c-file-style:"stroustrup"
337   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
338   indent-tabs-mode:nil
339   fill-column:99
340   End:
341 */
342 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :