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
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-17 13:00:36 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
wxFC_OPEN = 0x0001,
|
|
|
|
wxFC_SAVE = 0x0002,
|
|
|
|
wxFC_MULTIPLE = 0x0004,
|
|
|
|
wxFC_NOSHOWHIDDEN = 0x0008
|
|
|
|
};
|
|
|
|
|
|
|
|
#define wxFC_DEFAULT_STYLE wxFC_OPEN
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@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.
|
|
|
|
|
2010-06-19 05:22:39 -04:00
|
|
|
Two implementations of this class exist, one for Gtk and another generic
|
|
|
|
one for all the other ports.
|
|
|
|
|
|
|
|
This class 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
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
@beginEventEmissionTable{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
|
2010-05-29 06:35:47 -04:00
|
|
|
@event{EVT_FILECTRL_FILTERCHANGED(id, func)}
|
2010-06-22 05:50:40 -04:00
|
|
|
The current file filter of the file control has been changed.
|
|
|
|
@since 2.9.1.
|
|
|
|
|
2008-04-01 09:55:38 -04:00
|
|
|
@endEventTable
|
|
|
|
|
2012-01-15 07:28:50 -05:00
|
|
|
@library{wxcore}
|
2009-02-20 06:34:52 -05:00
|
|
|
@category{ctrl}
|
2012-11-03 14:32:50 -04:00
|
|
|
@appearance{filectrl}
|
2009-01-06 08:52:15 -05:00
|
|
|
|
|
|
|
@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
|
|
|
*/
|
2009-02-20 06:34:52 -05:00
|
|
|
class wxFileCtrl : public wxControl
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
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,
|
2012-02-14 19:35:29 -05:00
|
|
|
const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
|
2008-03-08 09:43:31 -05:00
|
|
|
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
|
|
|
|
|
|
|
/**
|
2012-11-30 19:14:07 -05: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
|
|
|
|
2012-04-17 13:00:36 -04:00
|
|
|
/**
|
|
|
|
Changes to a certain directory and selects a certain file.
|
2015-05-09 13:05:05 -04:00
|
|
|
|
|
|
|
If @a path includes the directory part, it must exist, otherwise @false
|
|
|
|
is returned and nothing else is done.
|
2012-04-17 13:00:36 -04:00
|
|
|
|
|
|
|
@return Returns @true on success, @false otherwise
|
|
|
|
*/
|
|
|
|
virtual bool SetPath(const wxString& path);
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-04-17 13:00:36 -04:00
|
|
|
wxEventType wxEVT_FILECTRL_SELECTIONCHANGED;
|
|
|
|
wxEventType wxEVT_FILECTRL_FILEACTIVATED;
|
|
|
|
wxEventType wxEVT_FILECTRL_FOLDERCHANGED;
|
|
|
|
wxEventType wxEVT_FILECTRL_FILTERCHANGED;
|
|
|
|
|
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
|
2010-05-29 06:35:47 -04:00
|
|
|
@event{EVT_FILECTRL_FILTERCHANGED(id, func)}
|
|
|
|
The current file filter of the file control has been changed
|
2008-04-01 09:55:38 -04:00
|
|
|
@endEventTable
|
|
|
|
|
2012-10-14 21:17:21 -04:00
|
|
|
@library{wxcore}
|
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
|
|
|
|
2010-05-29 06:35:47 -04:00
|
|
|
/**
|
|
|
|
Returns the current file filter index.
|
|
|
|
|
|
|
|
For a @b EVT_FILECTRL_FILTERCHANGED event, this method returns the new
|
|
|
|
file filter index.
|
|
|
|
|
|
|
|
@since 2.9.1
|
|
|
|
*/
|
|
|
|
int GetFilterIndex() 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 );
|
2010-05-29 06:35:47 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the filter index changed by this event.
|
|
|
|
|
|
|
|
@since 2.9.1
|
|
|
|
*/
|
|
|
|
void SetFilterIndex(int index);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|