class FileSel : public WithFileSelectorLayout<TopWindow>
Dialog for selecting files or directories.
Callback3<bool, const String&, Image&> WhenIcon
This callback can be used to alter icons for files. First parameter designates directory, second is the filename. Client code can alter Image passed as third parameter.
void (*WhenIconLazy)(const String& path, Image& result)
When not NULL, this function is called in separate thread for additional resolving of file icon. Note that FileSel, when closed/destroyed, does not wait for this function to finish, so it should not rely on any data outside of function. Only available when MT is active.
void Serialize(Stream& s)
Serializes current settings of FileSel. That includes current directory, currently selected file type, size of FileSel window, LRU list of visited directories and "Sort by" switch state.
bool ExecuteOpen(const char *title = NULL)
Executes "Open file" dialog. title can specify alternate caption of dialog. If user selects a file to open, returns true.
bool ExecuteSaveAs(const char *title = NULL)
Executes "Save as" dialog. title can specify alternate caption of dialog. If user selects a destination file, returns true.
bool ExecuteSelectDir(const char *title = NULL)
Executes directory selection dialog. title can specify alternate caption of dialog. If user selects a file to open, returns true.
String Get() const
Returns the path of the first chosen file. If there is none, returns empty String.
void Set(const String& s)
Sets s to be the chosen file: if it contains a full path, file selector goes to the directory, filename is put into the file name editor of file selector.
void Set(const Vector<String>& s)
Sets a group of files to be chosen.
operator String() const
Same as Get().
void operator=(const String& s)
Same as Set(s).
String operator~() const
Same as Get().
void operator<<=(const String& s)
Same as Set(s).
int GetCount() const
Returns a count of chosen files.
String GetFile(int i) const
Returns a chosen file i.
String operator(int i) const
Same as GetFile(i).
Clear the selection of files.
bool GetReadOnly() const
Returns the status of read-only option. (Usually this option is used to open files in read only mode).
String GetActiveDir() const
Returns the active directory of file selector.
int GetActiveType() const
Returns the active file type index of file selector.
void Filesystem(FileSystemInfo& fsys)
Sets the file system to browse. Default is normal local file system.
FileSystemInfo& GetFilesystem() const
Returns the file system used in file selector.
FileSel& Type(const char *name, const char *ext)
Adds a file type displayed as name. ext contains a set of file masks separated by spaces. Example: Type("Source files", "*.c *.h").
FileSel& Types(const char *d)
Adds a number of file types using simple text format: '\n' is used to separate types, '\t' is used to separate file type description and file mask. If there is no '\t', text is used for both file description and the file mask.
Examples: Types("All files\t*.*\nText files\t*.txt\nImage files\t*.bmp *.png *.jpg *.gif")).
Same as Type("All files", "*.*").
Removes all file types from FileSel.
FileSel& ActiveDir(const String& d)
Sets the active directory of file selector (directory where file selector starts).
FileSel& ActiveType(int i)
Sets the active file type.
FileSel& PreSelect(const String& path)
Preselects the file path.
FileSel& DefaultExt(const char *ext)
Sets the file extension to add for "Save as" dialog if none is specified.
FileSel& Multi(bool b = true)
In this mode, more than single file can be selected. Default is false.
FileSel& ReadOnlyOption(bool b = true)
Makes "Read only" option visible. Default is false.
FileSel& MkDirOption(bool b = true)
Makes "Make directory" button visible. Default is true.
Same as MkDirOption(false).
FileSel& BaseDir(const char *dir)
Sets dir to be the base directory. If used, files can be selected only inside this base directory (or its subdirectories) and selected file paths are relative to it.
FileSel& Asking(bool b = true)
If active, file selector asks before returning the path of existing file in "Save as" dialog. Default is active.
Same as Asking(false).
FileSel& EditFileName(bool b)
If active, user can type files into filename edit field. Default is active.
Same as EditFileName(false).
FileSel& AppModal(bool b = true)
If active (default), dialog is run as application modal.
FileSel& Preview(Ctrl& ctrl)
Sets ctrl to be provide a preview of currently selected file. This widget is placed into FileSel and receives the path of file via SetData to be previewed or Null if there is nothing to preview.
FileSel& Preview(const Display& d)
Sets d to be provide a preview of currently selected file. This Display is by FileSel to show the preview, the Value in Paint method is either the path of file or Null if there is nothing to preview.
Empties the list of special folders (platform specific, usually folders like Video, Pictures, Downloads are in the default list). The list, if not empty, is displayed in the left part of dialog.
FileSel& AddPlace(const String& path, const Image& m, const String& name, const char* group = NULL, int row = -1)
FileSel& AddPlace(const String& path, const String& name, const char* group = NULL, int row = -1)
FileSel& AddPlace(const String& path, const char* group = NULL, int row = -1)
Adds a folder path to the list of special folders with name and icon m. group and row must at the moment be left to its default values (they are only used internally). If name or icon m is not specified, they are created based on path.
Adds horizontal separator line to the list of special folders.
Adds default special folders to the list. Called by FileSel constructor.
FileSel& FileCtrl(Ctrl& ext, int cx)
FileSel& FileCtrl(Ctrl& ext)
Provides a way to extend the FileSel: Adds a widget after the filename widget. The height of widget is set to be the same as the filename, width is cx. Variant without cx gets the width from GetMinSize().