filedialogimpl-win32.h revision 78a4fd75621ab829ed0005b043f7262ebec13f69
/**
* 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>
{
{
{
/*#########################################################################
### 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.
{
/// 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
gchar const *preferenceBase);
/// Destructor
/// 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
/// Get the path of the current directory
/// The dialog type
/// 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
/// The result of the call to GetOpenFileName. If true
/// the user clicked OK, if false the user clicked cancel
bool _result;
/// The parent window
/// The windows handle of the parent window
/// The path of the directory that is currently being
/// browsed
/// The title of the dialog in UTF-16
/// The path of the currently selected file in UTF-16
/// The filter string for GetOpenFileName in UTF-16
/// 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.
int _filter_index;
/// The number of filters registered
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/
/// The currently selected extension. Valid after an [OK]
};
/*#########################################################################
### F I L E O P E N
#########################################################################*/
/// An Inkscape compatible wrapper around MS Windows GetOpenFileName API
{
/// 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
const char *title);
/// Destructor
/// 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
/// Get the path of the current directory
{ 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
{ return FileDialogBaseWin32::getSelectionType(); }
/// Create a filter menu for this type of dialog
void createFilterMenu();
/// The handle of the preview pane window
/// The handle of the file dialog window
/// A pointer to the standard window proc of the
/// unhooked file dialog
/// The handle of the bitmap of the "show preview"
/// toggle button
/// The handle of the toolbar's window
/// 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
/// The windows shell icon for the selected file
/// 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
/// A GDK Pixbuf of the rendered preview to be displayed
/// 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
/// 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
/// 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
/// Loads the preview for a raster image
/// Main app thread only.
/// @return Returns true if the image loaded successfully
bool set_image_preview();
/// 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
};
/*#########################################################################
### F I L E S A V E
#########################################################################*/
/// An Inkscape compatible wrapper around MS Windows GetSaveFileName API
{
const char *title,
/// Destructor
/// 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
{ 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
{ return FileDialogBaseWin32::getSelectionType(); }
/// Create a filter menu for this type of dialog
void createFilterMenu();
/// The controller function for the thread which calls
/// GetSaveFileName
void GetSaveFileName_thread();
};
}
}
}
#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 :