Code

Add option to align & distribute dialog to treat the selection as a group (closes...
[inkscape.git] / src / ui / dialog / filedialogimpl-win32.h
index 1b69c19931481e1ee1a55571f88b240a89f73c97..3a0c3775bf4d276ebfcec5bde6ead81d73beaa22 100644 (file)
-/**\r
- * Implementation of the file dialog interfaces defined in filedialog.h for Win32\r
- *\r
- * Authors:\r
- *   Joel Holdsworth\r
- *   The Inkscape Organization\r
- *\r
- * Copyright (C) 2004-2007 The Inkscape Organization\r
- *\r
- * Released under GNU GPL, read the file 'COPYING' for more information\r
- */\r
\r
-#ifdef WIN32\r
-\r
-#include "gc-core.h"\r
-#include <windows.h>\r
-\r
-namespace Inkscape\r
-{\r
-namespace UI\r
-{\r
-namespace Dialog\r
-{\r
-\r
-/*#########################################################################\r
-### F I L E     D I A L O G    B A S E    C L A S S\r
-#########################################################################*/\r
-\r
-/// This class is the base implementation of a MS Windows\r
-/// file dialog.\r
-class FileDialogBaseWin32\r
-{\r
-protected:\r
-    /// Abstract Constructor\r
-    /// @param parent The parent window for the dialog\r
-    /// @param dir The directory to begin browing from\r
-    /// @param title The title caption for the dialog in UTF-8\r
-    /// @param type The dialog type\r
-    /// @param preferenceBase The preferences key\r
-    FileDialogBaseWin32(Gtk::Window &parent, const Glib::ustring &dir,\r
-        const char *title, FileDialogType type,\r
-        gchar const *preferenceBase);\r
-\r
-    /// Destructor\r
-    ~FileDialogBaseWin32();\r
-    \r
-public:\r
-\r
-    /// Gets the currently selected extension. Valid after an [OK]\r
-    /// @return Returns a pointer to the selected extension, or NULL\r
-    /// if the selected filter requires an automatic type detection\r
-    Inkscape::Extension::Extension* getSelectionType();\r
-    \r
-    /// Get the path of the current directory\r
-    Glib::ustring getCurrentDirectory();\r
\r
-protected:\r
-    /// The dialog type\r
-    FileDialogType dialogType;\r
-    \r
-    /// This mutex is used to ensure that the worker thread\r
-    /// that calls GetOpenFileName cannot collide with the\r
-    /// main Inkscape thread\r
-    Glib::Mutex *_mutex;\r
-    \r
-    /// This flag is set true when the GetOpenFileName call\r
-    /// has returned\r
-    bool _finished;\r
-    \r
-    /// A pointer to the GTK main-loop context object. This\r
-    /// is used to keep the rest of the inkscape UI running\r
-    /// while the file dialog is displayed\r
-    GMainLoop *_main_loop;\r
-    \r
-    /// The result of the call to GetOpenFileName. If true\r
-    /// the user clicked OK, if false the user clicked cancel\r
-    bool _result;\r
-    \r
-    /// The parent window\r
-    Gtk::Window &parent;\r
-    \r
-    /// The windows handle of the parent window\r
-    HWND _ownerHwnd;\r
-    \r
-    /// The path of the directory that is currently being\r
-    /// browsed\r
-    Glib::ustring _current_directory;\r
-    \r
-    /// The title of the dialog in UTF-16\r
-    wchar_t *_title;\r
-    \r
-    /// The path of the currently selected file in UTF-16\r
-    wchar_t _path_string[_MAX_PATH];\r
-    \r
-    /// The filter string for GetOpenFileName in UTF-16\r
-    wchar_t *_filter;\r
-    \r
-    /// The index of the currently selected filter\r
-    int _filterIndex;\r
-    \r
-    /// An array of the extensions associated with the\r
-    /// file types of each filter. So the Nth entry of\r
-    /// this array corresponds to the extension of the Nth\r
-    /// filter in the list. NULL if no specific extension is\r
-    /// specified/\r
-    Inkscape::Extension::Extension **_extension_map;\r
-\r
-    /// The currently selected extension. Valid after an [OK]\r
-    Inkscape::Extension::Extension *_extension;\r
-};\r
-\r
-\r
-/*#########################################################################\r
-### F I L E    O P E N\r
-#########################################################################*/\r
-\r
-/// An Inkscape compatible wrapper around MS Windows GetOpenFileName API\r
-class FileOpenDialogImplWin32 : public FileOpenDialog, public FileDialogBaseWin32\r
-{\r
-public:\r
-    /// Constructor\r
-    /// @param parent The parent window for the dialog\r
-    /// @param dir The directory to begin browing from\r
-    /// @param title The title caption for the dialog in UTF-8\r
-    /// @param type The dialog type\r
-    FileOpenDialogImplWin32(Gtk::Window &parent, \r
-                       const Glib::ustring &dir,\r
-                       FileDialogType fileTypes,\r
-                       const char *title);\r
-\r
-    /// Destructor\r
-    virtual ~FileOpenDialogImplWin32();\r
-\r
-    /// Shows the file dialog, and blocks until a file\r
-    /// has been selected.\r
-    /// @return Returns true if the the user selected a\r
-    /// file, or false if the user pressed cancel.\r
-    bool show();\r
-\r
-    /// Gets a list of the selected file names\r
-    /// @return Returns an STL vector filled with the\r
-    /// GTK names of the selected files\r
-    std::vector<Glib::ustring> getFilenames();\r
-    \r
-    /// Get the path of the current directory\r
-    virtual Glib::ustring getCurrentDirectory()\r
-        { return FileDialogBaseWin32::getCurrentDirectory(); }\r
-\r
-    /// Gets the currently selected extension. Valid after an [OK]\r
-    /// @return Returns a pointer to the selected extension, or NULL\r
-    /// if the selected filter requires an automatic type detection\r
-    virtual Inkscape::Extension::Extension* getSelectionType()\r
-        { return FileDialogBaseWin32::getSelectionType(); }\r
-\r
-private:\r
-\r
-    /// Create a filter menu for this type of dialog\r
-    void createFilterMenu();\r
-    \r
-    /// The handle of the preview pane window\r
-    HWND _preview_wnd;\r
-    \r
-    /// The handle of the file dialog window\r
-    HWND _file_dialog_wnd;\r
-    \r
-    /// A pointer to the standard window proc of the\r
-    /// unhooked file dialog\r
-    WNDPROC _base_window_proc;\r
-    \r
-    /// The handle of the bitmap of the "show preview"\r
-    /// toggle button\r
-    HBITMAP _show_preview_button_bitmap;\r
-    \r
-    /// The handle of the toolbar's window\r
-    HWND _toolbar_wnd;\r
-    \r
-    /// This flag is set true when the preview should be\r
-    /// shown, or false when it should be hidden\r
-    static bool _show_preview;\r
-    \r
-    \r
-    /// The current width of the preview pane in pixels\r
-    int _preview_width;\r
-    \r
-    /// The current height of the preview pane in pixels\r
-    int _preview_height;\r
-    \r
-    /// The handle of the windows to display within the\r
-    /// preview pane, or NULL if no image should be displayed\r
-    HBITMAP _preview_bitmap;\r
-    \r
-    /// The windows shell icon for the selected file\r
-    HICON _preview_file_icon;\r
-    \r
-    /// The size of the preview file in kilobytes\r
-    unsigned long _preview_file_size;\r
-\r
-    \r
-    /// The width of the document to be shown in the preview panel\r
-    double _preview_document_width;\r
-    \r
-    /// The width of the document to be shown in the preview panel\r
-    double _preview_document_height;\r
-    \r
-    /// The width of the rendered preview image in pixels\r
-    int _preview_image_width;\r
-    \r
-    /// The height of the rendered preview image in pixels\r
-    int _preview_image_height;\r
-\r
-    /// A GDK Pixbuf of the rendered preview to be displayed\r
-    Glib::RefPtr<Gdk::Pixbuf> _preview_bitmap_image;\r
-    \r
-    /// This flag is set true if a file has been selected\r
-    bool _file_selected;\r
-    \r
-    \r
-    /// The controller function for the thread which calls\r
-    /// GetOpenFileName\r
-    void GetOpenFileName_thread();\r
-    \r
-    /// Registers the Windows Class of the preview panel window\r
-    static void register_preview_wnd_class();\r
-    \r
-    /// A message proc which is called by the standard dialog\r
-    /// proc\r
-    static UINT_PTR CALLBACK GetOpenFileName_hookproc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);\r
-    \r
-    /// A message proc which wraps the standard dialog proc,\r
-    /// but intercepts some calls\r
-    static LRESULT CALLBACK file_dialog_subclass_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\r
-    \r
-    /// The message proc for the preview panel window\r
-    static LRESULT CALLBACK preview_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\r
-    \r
-    /// Lays out the controls in the file dialog given it's\r
-    /// current size\r
-    /// GetOpenFileName thread only.\r
-    void layout_dialog();\r
-    \r
-    /// Enables or disables the file preview.\r
-    /// GetOpenFileName thread only.\r
-    void enable_preview(bool enable);\r
-    \r
-    /// This function is called in the App thread when a file had\r
-    /// been selected\r
-    void file_selected();\r
-    \r
-    /// Loads and renders the unshrunk preview image.\r
-    /// Main app thread only.\r
-    void load_preview();\r
-    \r
-    /// Frees all the allocated objects associated with the file\r
-    /// currently being previewed\r
-    /// Main app thread only.\r
-    void free_preview();\r
-    \r
-    /// Loads preview for an SVG or SVGZ file.\r
-    /// Main app thread only.\r
-    /// @return Returns true if the SVG loaded successfully\r
-    bool set_svg_preview();\r
-    \r
-    /// A callback to allow this class to dispose of the\r
-    /// memory block of the rendered SVG bitmap\r
-    /// @buffer buffer The buffer to free\r
-    static void destroy_svg_rendering(const guint8 *buffer);\r
-    \r
-    /// Loads the preview for a raster image\r
-    /// Main app thread only.\r
-    /// @return Returns true if the image loaded successfully\r
-    bool set_image_preview();\r
-    \r
-    /// Renders the unshrunk preview image to a windows HTBITMAP\r
-    /// which can be painted in the preview pain.\r
-    /// Main app thread only.\r
-    void render_preview();\r
-    \r
-    /// Formats the caption in UTF-16 for the preview image\r
-    /// @param caption The buffer to format the caption string into\r
-    /// @param caption_size The number of wchar_ts in the caption buffer \r
-    /// @return Returns the number of characters in caption string\r
-    int format_caption(wchar_t *caption, int caption_size);\r
-};\r
-\r
-\r
-/*#########################################################################\r
-### F I L E    S A V E\r
-#########################################################################*/\r
-\r
-/// An Inkscape compatible wrapper around MS Windows GetSaveFileName API\r
-class FileSaveDialogImplWin32 : public FileSaveDialog, public FileDialogBaseWin32\r
-{\r
-\r
-public:\r
-    FileSaveDialogImplWin32(Gtk::Window &parent, \r
-                       const Glib::ustring &dir,\r
-                       FileDialogType fileTypes,\r
-                       const char *title,\r
-                       const Glib::ustring &default_key);\r
-\r
-    /// Destructor\r
-    virtual ~FileSaveDialogImplWin32();\r
-\r
-    /// Shows the file dialog, and blocks until a file\r
-    /// has been selected.\r
-    /// @return Returns true if the the user selected a\r
-    /// file, or false if the user pressed cancel.\r
-    bool show();\r
-    \r
-    /// Get the path of the current directory\r
-    virtual Glib::ustring getCurrentDirectory()\r
-        { return FileDialogBaseWin32::getCurrentDirectory(); }\r
-\r
-    /// Gets the currently selected extension. Valid after an [OK]\r
-    /// @return Returns a pointer to the selected extension, or NULL\r
-    /// if the selected filter requires an automatic type detection\r
-    virtual Inkscape::Extension::Extension* getSelectionType()\r
-        { return FileDialogBaseWin32::getSelectionType(); }\r
-\r
-    virtual void setSelectionType( Inkscape::Extension::Extension *key );\r
-    \r
-private:\r
-\r
-    /**\r
-     *  Create a filter menu for this type of dialog\r
-     */\r
-    void createFilterMenu();\r
-\r
-    void GetSaveFileName_thread();\r
-};\r
-\r
-\r
-}\r
-}\r
-}\r
-\r
-#endif\r
-\r
-/*\r
-  Local Variables:\r
-  mode:c++\r
-  c-file-style:"stroustrup"\r
-  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
-  indent-tabs-mode:nil\r
-  fill-column:99\r
-  End:\r
-*/\r
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :\r
+/**
+ * Implementation of the file dialog interfaces defined in filedialog.h for Win32
+ *
+ * Authors:
+ *   Joel Holdsworth
+ *   The Inkscape Organization
+ *
+ * Copyright (C) 2004-2008 The Inkscape Organization
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef WIN32
+
+#include "gc-core.h"
+#include <windows.h>
+
+namespace Inkscape
+{
+namespace UI
+{
+namespace Dialog
+{
+
+/*#########################################################################
+### F I L E     D I A L O G    B A S E    C L A S S
+#########################################################################*/
+
+/// This class is the base implementation of a MS Windows
+/// file dialog.
+class FileDialogBaseWin32
+{
+protected:
+    /// Abstract Constructor
+    /// @param parent The parent window for the dialog
+    /// @param dir The directory to begin browing from
+    /// @param title The title caption for the dialog in UTF-8
+    /// @param type The dialog type
+    /// @param preferenceBase The preferences key
+    FileDialogBaseWin32(Gtk::Window &parent, const Glib::ustring &dir,
+        const char *title, FileDialogType type,
+        gchar const *preferenceBase);
+
+    /// Destructor
+    ~FileDialogBaseWin32();
+
+public:
+
+    /// Gets the currently selected extension. Valid after an [OK]
+    /// @return Returns a pointer to the selected extension, or NULL
+    /// if the selected filter requires an automatic type detection
+    Inkscape::Extension::Extension* getSelectionType();
+
+    /// Get the path of the current directory
+    Glib::ustring getCurrentDirectory();
+
+protected:
+    /// The dialog type
+    FileDialogType dialogType;
+
+       /// A pointer to the GTK main-loop context object. This
+    /// is used to keep the rest of the inkscape UI running
+    /// while the file dialog is displayed
+    GMainLoop *_main_loop;
+
+    /// The result of the call to GetOpenFileName. If true
+    /// the user clicked OK, if false the user clicked cancel
+    bool _result;
+
+    /// The parent window
+    Gtk::Window &parent;
+
+    /// The windows handle of the parent window
+    HWND _ownerHwnd;
+
+    /// The path of the directory that is currently being
+    /// browsed
+    Glib::ustring _current_directory;
+
+    /// The title of the dialog in UTF-16
+    wchar_t *_title;
+
+    /// The path of the currently selected file in UTF-16
+    wchar_t _path_string[_MAX_PATH];
+
+    /// The filter string for GetOpenFileName in UTF-16
+    wchar_t *_filter;
+
+    /// The index of the currently selected filter.
+       /// This value must be greater than or equal to 1,
+       /// and less than or equal to _filter_count.
+    unsigned int _filter_index;
+
+       /// The number of filters registered
+       unsigned int _filter_count;
+
+    /// An array of the extensions associated with the
+    /// file types of each filter. So the Nth entry of
+    /// this array corresponds to the extension of the Nth
+    /// filter in the list. NULL if no specific extension is
+    /// specified/
+    Inkscape::Extension::Extension **_extension_map;
+
+       /// The currently selected extension. Valid after an [OK]
+    Inkscape::Extension::Extension *_extension;
+};
+
+
+/*#########################################################################
+### F I L E    O P E N
+#########################################################################*/
+
+/// An Inkscape compatible wrapper around MS Windows GetOpenFileName API
+class FileOpenDialogImplWin32 : public FileOpenDialog, public FileDialogBaseWin32
+{
+public:
+    /// Constructor
+    /// @param parent The parent window for the dialog
+    /// @param dir The directory to begin browing from
+    /// @param title The title caption for the dialog in UTF-8
+    /// @param type The dialog type
+    FileOpenDialogImplWin32(Gtk::Window &parent,
+                       const Glib::ustring &dir,
+                       FileDialogType fileTypes,
+                       const char *title);
+
+    /// Destructor
+    virtual ~FileOpenDialogImplWin32();
+
+    /// Shows the file dialog, and blocks until a file
+    /// has been selected.
+    /// @return Returns true if the the user selected a
+    /// file, or false if the user pressed cancel.
+    bool show();
+
+    /// Gets a list of the selected file names
+    /// @return Returns an STL vector filled with the
+    /// GTK names of the selected files
+    std::vector<Glib::ustring> getFilenames();
+
+    /// Get the path of the current directory
+    virtual Glib::ustring getCurrentDirectory()
+        { return FileDialogBaseWin32::getCurrentDirectory(); }
+
+    /// Gets the currently selected extension. Valid after an [OK]
+    /// @return Returns a pointer to the selected extension, or NULL
+    /// if the selected filter requires an automatic type detection
+    virtual Inkscape::Extension::Extension* getSelectionType()
+        { return FileDialogBaseWin32::getSelectionType(); }
+
+private:
+
+    /// Create a filter menu for this type of dialog
+    void createFilterMenu();
+
+    /// The handle of the preview pane window
+    HWND _preview_wnd;
+
+    /// The handle of the file dialog window
+    HWND _file_dialog_wnd;
+
+    /// A pointer to the standard window proc of the
+    /// unhooked file dialog
+    WNDPROC _base_window_proc;
+
+    /// The handle of the bitmap of the "show preview"
+    /// toggle button
+    HBITMAP _show_preview_button_bitmap;
+
+    /// The handle of the toolbar's window
+    HWND _toolbar_wnd;
+
+    /// This flag is set true when the preview should be
+    /// shown, or false when it should be hidden
+    static bool _show_preview;
+
+
+    /// The current width of the preview pane in pixels
+    int _preview_width;
+
+    /// The current height of the preview pane in pixels
+    int _preview_height;
+
+    /// The handle of the windows to display within the
+    /// preview pane, or NULL if no image should be displayed
+    HBITMAP _preview_bitmap;
+
+    /// The windows shell icon for the selected file
+    HICON _preview_file_icon;
+
+    /// The size of the preview file in kilobytes
+    unsigned long _preview_file_size;
+
+
+    /// The width of the document to be shown in the preview panel
+    double _preview_document_width;
+
+    /// The width of the document to be shown in the preview panel
+    double _preview_document_height;
+
+    /// The width of the rendered preview image in pixels
+    int _preview_image_width;
+
+    /// The height of the rendered preview image in pixels
+    int _preview_image_height;
+
+    /// A GDK Pixbuf of the rendered preview to be displayed
+    Glib::RefPtr<Gdk::Pixbuf> _preview_bitmap_image;
+
+    /// This flag is set true if a file has been selected
+    bool _file_selected;
+
+       /// This flag is set true when the GetOpenFileName call
+    /// has returned
+    bool _finished;
+
+    /// This mutex is used to ensure that the worker thread
+    /// that calls GetOpenFileName cannot collide with the
+    /// main Inkscape thread
+    Glib::Mutex *_mutex;
+
+
+    /// The controller function for the thread which calls
+    /// GetOpenFileName
+    void GetOpenFileName_thread();
+
+    /// Registers the Windows Class of the preview panel window
+    static void register_preview_wnd_class();
+
+    /// A message proc which is called by the standard dialog
+    /// proc
+    static UINT_PTR CALLBACK GetOpenFileName_hookproc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+
+    /// A message proc which wraps the standard dialog proc,
+    /// but intercepts some calls
+    static LRESULT CALLBACK file_dialog_subclass_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+    /// The message proc for the preview panel window
+    static LRESULT CALLBACK preview_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+    /// Lays out the controls in the file dialog given it's
+    /// current size
+    /// GetOpenFileName thread only.
+    void layout_dialog();
+
+    /// Enables or disables the file preview.
+    /// GetOpenFileName thread only.
+    void enable_preview(bool enable);
+
+    /// This function is called in the App thread when a file had
+    /// been selected
+    void file_selected();
+
+    /// Loads and renders the unshrunk preview image.
+    /// Main app thread only.
+    void load_preview();
+
+    /// Frees all the allocated objects associated with the file
+    /// currently being previewed
+    /// Main app thread only.
+    void free_preview();
+
+    /// Loads preview for an SVG or SVGZ file.
+    /// Main app thread only.
+    /// @return Returns true if the SVG loaded successfully
+    bool set_svg_preview();
+
+    /// A callback to allow this class to dispose of the
+    /// memory block of the rendered SVG bitmap
+    /// @buffer buffer The buffer to free
+    static void destroy_svg_rendering(const guint8 *buffer);
+
+    /// Loads the preview for a raster image
+    /// Main app thread only.
+    /// @return Returns true if the image loaded successfully
+    bool set_image_preview();
+
+    /// Loads the preview for a meta file
+    /// Main app thread only.
+    /// @return Returns true if the image loaded successfully
+    bool set_emf_preview();
+
+    /// This flag is set true when a meta file is previewed
+    bool _preview_emf_image;
+
+    /// Renders the unshrunk preview image to a windows HTBITMAP
+    /// which can be painted in the preview pain.
+    /// Main app thread only.
+    void render_preview();
+
+    /// Formats the caption in UTF-16 for the preview image
+    /// @param caption The buffer to format the caption string into
+    /// @param caption_size The number of wchar_ts in the caption buffer
+    /// @return Returns the number of characters in caption string
+    int format_caption(wchar_t *caption, int caption_size);
+};
+
+
+/*#########################################################################
+### F I L E    S A V E
+#########################################################################*/
+
+/// An Inkscape compatible wrapper around MS Windows GetSaveFileName API
+class FileSaveDialogImplWin32 : public FileSaveDialog, public FileDialogBaseWin32
+{
+
+public:
+    FileSaveDialogImplWin32(Gtk::Window &parent,
+                       const Glib::ustring &dir,
+                       FileDialogType fileTypes,
+                       const char *title,
+                       const Glib::ustring &default_key,
+                       const char *docTitle);
+
+    /// Destructor
+    virtual ~FileSaveDialogImplWin32();
+
+    /// Shows the file dialog, and blocks until a file
+    /// has been selected.
+    /// @return Returns true if the the user selected a
+    /// file, or false if the user pressed cancel.
+    bool show();
+
+    /// Get the path of the current directory
+    virtual Glib::ustring getCurrentDirectory()
+        { return FileDialogBaseWin32::getCurrentDirectory(); }
+
+    /// Gets the currently selected extension. Valid after an [OK]
+    /// @return Returns a pointer to the selected extension, or NULL
+    /// if the selected filter requires an automatic type detection
+    virtual Inkscape::Extension::Extension* getSelectionType()
+        { return FileDialogBaseWin32::getSelectionType(); }
+
+    virtual void setSelectionType( Inkscape::Extension::Extension *key );
+
+private:
+       /// A handle to the title label and edit box
+    HWND _title_label;
+    HWND _title_edit;
+
+    /// Create a filter menu for this type of dialog
+    void createFilterMenu();
+
+    /// The controller function for the thread which calls
+    /// GetSaveFileName
+    void GetSaveFileName_thread();
+
+    /// A message proc which is called by the standard dialog
+    /// proc
+    static UINT_PTR CALLBACK GetSaveFileName_hookproc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+
+};
+
+
+}
+}
+}
+
+#endif
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :