2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: filectrl.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxFileCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxFileCtrl
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-01 09:55:38 -04:00
|
|
|
This control allows the user to select a file.
|
|
|
|
|
|
|
|
Two implemetations exist, one for Gtk and another generic one for anything
|
|
|
|
other than Gtk. It is only available if @c wxUSE_FILECTRL is set to 1.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFC_DEFAULT_STYLE}
|
2008-03-08 08:52:38 -05:00
|
|
|
The default style: wxFC_OPEN
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFC_OPEN}
|
2008-03-08 08:52:38 -05:00
|
|
|
Creates an file control suitable for opening files. Cannot be
|
|
|
|
combined with wxFC_SAVE.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFC_SAVE}
|
2008-03-08 08:52:38 -05:00
|
|
|
Creates an file control suitable for saving files. Cannot be
|
|
|
|
combined with wxFC_OPEN.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFC_MULTIPLE}
|
2008-03-08 08:52:38 -05:00
|
|
|
For open control only, Allows selecting multiple files. Cannot be
|
|
|
|
combined with wxFC_SAVE
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFC_NOSHOWHIDDEN}
|
2008-03-08 08:52:38 -05:00
|
|
|
Hides the "Show Hidden Files" checkbox (Generic only)
|
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-01 09:55:38 -04:00
|
|
|
@beginEventTable{wxFileCtrlEvent}
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_FILECTRL_FILEACTIVATED(id, func)}
|
2008-04-01 09:55:38 -04:00
|
|
|
The user activated a file(by double-clicking or pressing Enter)
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
|
2008-04-01 09:55:38 -04:00
|
|
|
The user changed the current selection(by selecting or deselecting a file)
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
|
2008-04-01 09:55:38 -04:00
|
|
|
The current folder of the file control has been changed
|
|
|
|
@endEventTable
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
2008-04-01 09:55:38 -04:00
|
|
|
@category{miscwnd}
|
2009-01-06 08:52:15 -05:00
|
|
|
@appearance{filectrl.png}
|
|
|
|
|
|
|
|
@nativeimpl{wxgtk}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxGenericDirCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFileCtrl : public wxWindow
|
|
|
|
{
|
|
|
|
public:
|
2008-04-01 09:55:38 -04:00
|
|
|
wxFileCtrl();
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-01 09:55:38 -04:00
|
|
|
Constructs the window.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window, must not be non-@NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
The identifier for the control.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param defaultDirectory
|
2008-10-04 16:49:51 -04:00
|
|
|
The initial directory shown in the control.
|
|
|
|
Must be a valid path to a directory or the empty string.
|
2008-03-09 08:33:59 -04:00
|
|
|
In case it is the empty string, the current working directory is used.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param defaultFilename
|
2008-03-09 08:33:59 -04:00
|
|
|
The default filename, or the empty string.
|
2008-10-04 16:49:51 -04:00
|
|
|
@param wildCard
|
2008-03-09 08:33:59 -04:00
|
|
|
A wildcard specifying which files can be selected,
|
|
|
|
such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
The window style, see wxFC_* flags.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial size.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Control name.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the control was successfully created or @false if
|
2008-03-09 08:33:59 -04:00
|
|
|
creation failed.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-01 09:55:38 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFileCtrl(wxWindow* parent, wxWindowID id,
|
2008-03-08 09:43:31 -05:00
|
|
|
const wxString& defaultDirectory = wxEmptyString,
|
|
|
|
const wxString& defaultFilename = wxEmptyString,
|
|
|
|
const wxPoint& wildCard = wxFileSelectorDefaultWildcardStr,
|
|
|
|
long style = wxFC_DEFAULT_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2008-11-09 11:46:52 -05:00
|
|
|
const wxString& name = wxFileCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create function for two-step construction. See wxFileCtrl() for details.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxString& defaultDirectory = wxEmptyString,
|
|
|
|
const wxString& defaultFilename = wxEmptyString,
|
2008-10-28 11:36:26 -04:00
|
|
|
const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
|
|
|
|
long style = wxFC_DEFAULT_STYLE, const wxPoint& pos = wxDefaultPosition,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxSize& size = wxDefaultSize,
|
2008-10-28 11:36:26 -04:00
|
|
|
const wxString& name = wxFileCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-01 09:55:38 -04:00
|
|
|
Returns the current directory of the file control (i.e. the directory shown by it).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetDirectory() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the currently selected filename.
|
2008-04-01 09:55:38 -04:00
|
|
|
|
|
|
|
For the controls having the @c wxFC_MULTIPLE style, use GetFilenames() instead.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetFilename() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-01 09:55:38 -04:00
|
|
|
Fills the array @a filenames with the filenames only of selected items.
|
|
|
|
|
|
|
|
This function should only be used with the controls having the @c wxFC_MULTIPLE
|
|
|
|
style, use GetFilename() for the others.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks filenames is emptied first.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void GetFilenames(wxArrayString& filenames) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the zero-based index of the currently selected filter.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual int GetFilterIndex() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the full path (directory and filename) of the currently selected file.
|
2008-04-01 09:55:38 -04:00
|
|
|
For the controls having the @c wxFC_MULTIPLE style, use GetPaths() instead.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetPath() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-01 09:55:38 -04:00
|
|
|
Fills the array @a paths with the full paths of the files chosen.
|
|
|
|
|
|
|
|
This function should be used with the controls having the @c wxFC_MULTIPLE style,
|
2008-03-08 08:52:38 -05:00
|
|
|
use GetPath() otherwise.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks paths is emptied first.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void GetPaths(wxArrayString& paths) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the current wildcard.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetWildcard() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets(changes) the current directory displayed in the control.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return Returns @true on success, @false otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool SetDirectory(const wxString& directory);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Selects a certain file.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return Returns @true on success, @false otherwise
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool SetFilename(const wxString& filename);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the current filter index, starting from zero.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetFilterIndex(int filterIndex);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the wildcard, which can contain multiple file types, for example:
|
|
|
|
"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetWildcard(const wxString& wildCard);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets whether hidden files and folders are shown or not.
|
|
|
|
*/
|
2008-10-28 11:36:26 -04:00
|
|
|
virtual void ShowHidden(bool show);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxFileCtrlEvent
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
A file control event holds information about events associated with
|
|
|
|
wxFileCtrl objects.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-01 09:55:38 -04:00
|
|
|
@beginEventTable{wxFileCtrlEvent}
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_FILECTRL_FILEACTIVATED(id, func)}
|
2008-04-01 09:55:38 -04:00
|
|
|
The user activated a file(by double-clicking or pressing Enter)
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
|
2008-04-01 09:55:38 -04:00
|
|
|
The user changed the current selection(by selecting or deselecting a file)
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
|
2008-04-01 09:55:38 -04:00
|
|
|
The current folder of the file control has been changed
|
|
|
|
@endEventTable
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
2008-04-01 09:55:38 -04:00
|
|
|
@category{events}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFileCtrlEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
2008-11-09 11:46:52 -05:00
|
|
|
wxFileCtrlEvent(wxEventType type, wxObject *evtObject, int id);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the current directory.
|
2008-04-01 09:55:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
In case of a @b EVT_FILECTRL_FOLDERCHANGED, this method returns the new
|
|
|
|
directory.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxString GetDirectory() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-01 09:55:38 -04:00
|
|
|
Returns the file selected (assuming it is only one file).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxString GetFile() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the files selected.
|
2008-04-01 09:55:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
In case of a @b EVT_FILECTRL_SELECTIONCHANGED, this method returns the
|
|
|
|
files selected after the event.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxArrayString GetFiles() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the files changed by this event.
|
|
|
|
*/
|
2008-10-28 11:36:26 -04:00
|
|
|
void SetFiles(const wxArrayString& files);
|
2008-04-01 09:55:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the directory of this event.
|
|
|
|
*/
|
|
|
|
void SetDirectory( const wxString &directory );
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|