1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     interface of wxFileCtrl 
   4 // Author:      wxWidgets team 
   6 // Licence:     wxWindows license 
   7 ///////////////////////////////////////////////////////////////////////////// 
  12     This control allows the user to select a file. 
  14     Two implemetations exist, one for Gtk and another generic one for anything 
  15     other than Gtk. It is only available if @c wxUSE_FILECTRL is set to 1. 
  18     @style{wxFC_DEFAULT_STYLE} 
  19            The default style: wxFC_OPEN 
  21            Creates an file control suitable for opening files. Cannot be 
  22            combined with wxFC_SAVE. 
  24            Creates an file control suitable for saving files. Cannot be 
  25            combined with wxFC_OPEN. 
  27            For open control only, Allows selecting multiple files. Cannot be 
  28            combined with wxFC_SAVE 
  29     @style{wxFC_NOSHOWHIDDEN} 
  30            Hides the "Show Hidden Files" checkbox (Generic only) 
  34     @beginEventTable{wxFileCtrlEvent} 
  35     @event{EVT_FILECTRL_FILEACTIVATED(id, func)} 
  36         The user activated a file(by double-clicking or pressing Enter) 
  37     @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)} 
  38         The user changed the current selection(by selecting or deselecting a file) 
  39     @event{EVT_FILECTRL_FOLDERCHANGED(id, func)} 
  40         The current folder of the file control has been changed 
  50 class wxFileCtrl 
: public wxWindow
 
  56         Constructs the window. 
  59             Parent window, must not be non-@NULL. 
  61             The identifier for the control. 
  62         @param defaultDirectory 
  63             The initial directory shown in the control. 
  64             Must be a valid path to a directory or the empty string. 
  65             In case it is the empty string, the current working directory is used. 
  66         @param defaultFilename 
  67             The default filename, or the empty string. 
  69             A wildcard specifying which files can be selected, 
  70             such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif". 
  72             The window style, see wxFC_* flags. 
  80         @return @true if the control was successfully created or @false if 
  84     wxFileCtrl(wxWindow
* parent
, wxWindowID id
, 
  85                const wxString
& defaultDirectory 
= wxEmptyString
, 
  86                const wxString
& defaultFilename 
= wxEmptyString
, 
  87                const wxPoint
& wildCard 
= wxFileSelectorDefaultWildcardStr
, 
  88                long style 
= wxFC_DEFAULT_STYLE
, 
  89                const wxPoint
& pos 
= wxDefaultPosition
, 
  90                const wxSize
& size 
= wxDefaultSize
, 
  91                const wxString
& name 
= wxFileCtrlNameStr
); 
  94         Create function for two-step construction. See wxFileCtrl() for details. 
  96     bool Create(wxWindow
* parent
, wxWindowID id
, 
  97                 const wxString
& defaultDirectory 
= wxEmptyString
, 
  98                 const wxString
& defaultFilename 
= wxEmptyString
, 
  99                 const wxString
& wildCard 
= wxFileSelectorDefaultWildcardStr
, 
 100                 long style 
= wxFC_DEFAULT_STYLE
, const wxPoint
& pos 
= wxDefaultPosition
, 
 101                 const wxSize
& size 
= wxDefaultSize
, 
 102                 const wxString
& name 
= wxFileCtrlNameStr
); 
 105         Returns the current directory of the file control (i.e. the directory shown by it). 
 107     virtual wxString 
GetDirectory() const; 
 110         Returns the currently selected filename. 
 112         For the controls having the @c wxFC_MULTIPLE style, use GetFilenames() instead. 
 114     virtual wxString 
GetFilename() const; 
 117         Fills the array @a filenames with the filenames only of selected items. 
 119         This function should only be used with the controls having the @c wxFC_MULTIPLE 
 120         style, use GetFilename() for the others. 
 122         @remarks filenames is emptied first. 
 124     virtual void GetFilenames(wxArrayString
& filenames
) const; 
 127         Returns the zero-based index of the currently selected filter. 
 129     virtual int GetFilterIndex() const; 
 132         Returns the full path (directory and filename) of the currently selected file. 
 133         For the controls having the @c wxFC_MULTIPLE style, use GetPaths() instead. 
 135     virtual wxString 
GetPath() const; 
 138         Fills the array @a paths with the full paths of the files chosen. 
 140         This function should be used with the controls having the @c wxFC_MULTIPLE style, 
 141         use GetPath() otherwise. 
 143         @remarks paths is emptied first. 
 145     virtual void GetPaths(wxArrayString
& paths
) const; 
 148         Returns the current wildcard. 
 150     virtual wxString 
GetWildcard() const; 
 153         Sets(changes) the current directory displayed in the control. 
 155         @return Returns @true on success, @false otherwise. 
 157     virtual bool SetDirectory(const wxString
& directory
); 
 160         Selects a certain file. 
 162         @return Returns @true on success, @false otherwise 
 164     virtual bool SetFilename(const wxString
& filename
); 
 167         Sets the current filter index, starting from zero. 
 169     virtual void SetFilterIndex(int filterIndex
); 
 172         Sets the wildcard, which can contain multiple file types, for example: 
 173         "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif" 
 175     virtual void SetWildcard(const wxString
& wildCard
); 
 178         Sets whether hidden files and folders are shown or not. 
 180     virtual void ShowHidden(bool show
); 
 186     @class wxFileCtrlEvent 
 188     A file control event holds information about events associated with 
 191     @beginEventTable{wxFileCtrlEvent} 
 192     @event{EVT_FILECTRL_FILEACTIVATED(id, func)} 
 193         The user activated a file(by double-clicking or pressing Enter) 
 194     @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)} 
 195         The user changed the current selection(by selecting or deselecting a file) 
 196     @event{EVT_FILECTRL_FOLDERCHANGED(id, func)} 
 197         The current folder of the file control has been changed 
 203 class wxFileCtrlEvent 
: public wxCommandEvent
 
 209     wxFileCtrlEvent(wxEventType type
, wxObject 
*evtObject
, int id
); 
 212         Returns the current directory. 
 214         In case of a @b EVT_FILECTRL_FOLDERCHANGED, this method returns the new 
 217     wxString 
GetDirectory() const; 
 220         Returns the file selected (assuming it is only one file). 
 222     wxString 
GetFile() const; 
 225         Returns the files selected. 
 227         In case of a @b EVT_FILECTRL_SELECTIONCHANGED, this method returns the 
 228         files selected after the event. 
 230     wxArrayString 
GetFiles() const; 
 233         Sets the files changed by this event. 
 235     void SetFiles(const wxArrayString
& files
); 
 239         Sets the directory of this event. 
 241     void SetDirectory( const wxString 
&directory 
);