2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dirctrl.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxGenericDirCtrl
|
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-03-30 14:29:03 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
// Only allow directory viewing/selection, no files
|
|
|
|
wxDIRCTRL_DIR_ONLY = 0x0010,
|
|
|
|
// When setting the default path, select the first file in the directory
|
|
|
|
wxDIRCTRL_SELECT_FIRST = 0x0020,
|
2013-03-09 10:07:49 -05:00
|
|
|
// Show the filter list
|
|
|
|
wxDIRCTRL_SHOW_FILTERS = 0x0040,
|
2012-03-30 14:29:03 -04:00
|
|
|
// Use 3D borders on internal controls
|
|
|
|
wxDIRCTRL_3D_INTERNAL = 0x0080,
|
|
|
|
// Editable labels
|
|
|
|
wxDIRCTRL_EDIT_LABELS = 0x0100,
|
|
|
|
// Allow multiple selection
|
2014-09-04 08:36:14 -04:00
|
|
|
wxDIRCTRL_MULTIPLE = 0x0200,
|
|
|
|
|
|
|
|
wxDIRCTRL_DEFAULT_STYLE = wxDIRCTRL_3D_INTERNAL
|
2012-03-30 14:29:03 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxGenericDirCtrl
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 21:40:12 -04:00
|
|
|
This control can be used to place a directory listing (with optional
|
|
|
|
files) on an arbitrary window.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
The control contains a wxTreeCtrl window representing the directory
|
|
|
|
hierarchy, and optionally, a wxChoice window containing a list of filters.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 21:40:12 -04:00
|
|
|
@beginStyleTable
|
|
|
|
@style{wxDIRCTRL_DIR_ONLY}
|
|
|
|
Only show directories, and not files.
|
|
|
|
@style{wxDIRCTRL_3D_INTERNAL}
|
2014-09-04 08:36:14 -04:00
|
|
|
Use 3D borders for internal controls. This is the default.
|
2008-04-20 21:40:12 -04:00
|
|
|
@style{wxDIRCTRL_SELECT_FIRST}
|
|
|
|
When setting the default path, select the first file in the
|
|
|
|
directory.
|
2013-03-09 10:07:49 -05:00
|
|
|
@style{wxDIRCTRL_SHOW_FILTERS}
|
|
|
|
Show the drop-down filter list.
|
2008-04-20 21:40:12 -04:00
|
|
|
@style{wxDIRCTRL_EDIT_LABELS}
|
|
|
|
Allow the folder and file labels to be editable.
|
2009-06-06 10:00:51 -04:00
|
|
|
@style{wxDIRCTRL_MULTIPLE}
|
|
|
|
Allows multiple files and folders to be selected.
|
2008-04-20 21:40:12 -04:00
|
|
|
@endStyleTable
|
|
|
|
|
2011-09-17 07:06:01 -04:00
|
|
|
@library{wxcore}
|
2008-03-08 08:52:38 -05:00
|
|
|
@category{ctrl}
|
2012-11-03 14:32:50 -04:00
|
|
|
@appearance{genericdirctrl}
|
2013-09-11 06:10:36 -04:00
|
|
|
|
|
|
|
@beginEventEmissionTable
|
2013-05-16 10:33:01 -04:00
|
|
|
@event{EVT_DIRCTRL_SELECTIONCHANGED(id, func)}
|
2012-11-01 13:15:08 -04:00
|
|
|
Selected directory has changed.
|
2013-05-16 10:33:01 -04:00
|
|
|
Processes a @c wxEVT_DIRCTRL_SELECTIONCHANGED event type.
|
2012-11-01 13:15:08 -04:00
|
|
|
Notice that this event is generated even for the changes done by the
|
|
|
|
program itself and not only those done by the user.
|
2013-09-11 06:10:36 -04:00
|
|
|
Available since wxWidgets 2.9.5.
|
2013-05-16 10:33:07 -04:00
|
|
|
@event{EVT_DIRCTRL_FILEACTIVATED(id, func)}
|
|
|
|
The user activated a file by double-clicking or pressing Enter.
|
2013-09-11 06:10:36 -04:00
|
|
|
Available since wxWidgets 2.9.5.
|
|
|
|
@endEventTable
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxGenericDirCtrl : public wxControl
|
|
|
|
{
|
|
|
|
public:
|
2008-04-20 21:40:12 -04:00
|
|
|
/**
|
|
|
|
Default constructor.
|
|
|
|
*/
|
|
|
|
wxGenericDirCtrl();
|
2008-11-09 11:46:52 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Main constructor.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
Window identifier.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param dir
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial folder.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-03-09 08:33:59 -04:00
|
|
|
Size.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-04-20 21:40:12 -04:00
|
|
|
Window style. Please see wxGenericDirCtrl for a list of possible
|
|
|
|
styles.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param filter
|
2008-04-20 21:40:12 -04:00
|
|
|
A filter string, using the same syntax as that for wxFileDialog.
|
|
|
|
This may be empty if filters are not being used. Example:
|
|
|
|
@c "All files (*.*)|*.*|JPEG files (*.jpg)|*.jpg"
|
2008-03-08 09:43:31 -05:00
|
|
|
@param defaultFilter
|
2008-03-09 08:33:59 -04:00
|
|
|
The zero-indexed default filter setting.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
The window name.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2016-01-16 13:55:01 -05:00
|
|
|
wxGenericDirCtrl(wxWindow* parent, wxWindowID id = wxID_ANY,
|
2008-03-08 09:43:31 -05:00
|
|
|
const wxString& dir = wxDirDialogDefaultFolderStr,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2014-09-04 08:36:14 -04:00
|
|
|
long style = wxDIRCTRL_DEFAULT_STYLE,
|
2008-03-08 09:43:31 -05:00
|
|
|
const wxString& filter = wxEmptyString,
|
|
|
|
int defaultFilter = 0,
|
|
|
|
const wxString& name = wxTreeCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxGenericDirCtrl();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 21:40:12 -04:00
|
|
|
Collapse the given @a path.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool CollapsePath(const wxString& path);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Collapses the entire tree.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void CollapseTree();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 21:40:12 -04:00
|
|
|
Create function for two-step construction. See wxGenericDirCtrl() for
|
|
|
|
details.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2016-01-16 13:55:01 -05:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxString& dir = wxDirDialogDefaultFolderStr,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2014-09-04 08:36:14 -04:00
|
|
|
long style = wxDIRCTRL_DEFAULT_STYLE,
|
2008-09-29 06:52:37 -04:00
|
|
|
const wxString& filter = wxEmptyString, int defaultFilter = 0,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxString& name = wxTreeCtrlNameStr);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 21:40:12 -04:00
|
|
|
Tries to expand as much of the given @a path as possible, so that the
|
|
|
|
filename or directory is visible in the tree control.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool ExpandPath(const wxString& path);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the default path.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetDefaultPath() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets selected filename path only (else empty string).
|
2008-04-20 21:40:12 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This function doesn't count a directory as a selection.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetFilePath() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2009-06-06 10:00:51 -04:00
|
|
|
/**
|
|
|
|
Fills the array @a paths with the currently selected filepaths.
|
|
|
|
|
|
|
|
This function doesn't count a directory as a selection.
|
|
|
|
*/
|
|
|
|
virtual void GetFilePaths(wxArrayString& paths) const;
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Returns the filter string.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetFilter() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the current filter index (zero-based).
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual int GetFilterIndex() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a pointer to the filter list control (if present).
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxDirFilterListCtrl* GetFilterListCtrl() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the currently-selected directory or filename.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetPath() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2012-10-29 14:30:10 -04:00
|
|
|
/**
|
|
|
|
Gets the path corresponding to the given tree control item.
|
|
|
|
|
|
|
|
@since 2.9.5
|
|
|
|
*/
|
|
|
|
wxString GetPath(wxTreeItemId itemId) const;
|
|
|
|
|
2009-06-06 10:00:51 -04:00
|
|
|
/**
|
|
|
|
Fills the array @a paths with the selected directories and filenames.
|
|
|
|
*/
|
|
|
|
virtual void GetPaths(wxArrayString& paths) const;
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Returns the root id for the tree control.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxTreeItemId GetRootId();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a pointer to the tree control.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxTreeCtrl* GetTreeCtrl() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes variables.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void Init();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 21:40:12 -04:00
|
|
|
Collapse and expand the tree, thus re-creating it from scratch. May be
|
|
|
|
used to update the displayed directory content.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void ReCreateTree();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the default path.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetDefaultPath(const wxString& path);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the filter string.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetFilter(const wxString& filter);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the current filter index (zero-based).
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetFilterIndex(int n);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the current path.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetPath(const wxString& path);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
@param show
|
2008-03-09 08:33:59 -04:00
|
|
|
If @true, hidden folders and files will be displayed by the
|
|
|
|
control. If @false, they will not be displayed.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void ShowHidden(bool show);
|
2009-06-06 10:00:51 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Selects the given item.
|
|
|
|
|
|
|
|
In multiple selection controls, can be also used to deselect a
|
|
|
|
currently selected item if the value of @a select is false.
|
|
|
|
Existing selections are not changed. Only visible items can be
|
|
|
|
(de)selected, otherwise use ExpandPath().
|
|
|
|
*/
|
|
|
|
virtual void SelectPath(const wxString& path, bool select = true);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Selects only the specified paths, clearing any previous selection.
|
|
|
|
|
|
|
|
Only supported when wxDIRCTRL_MULTIPLE is set.
|
|
|
|
*/
|
|
|
|
virtual void SelectPaths(const wxArrayString& paths);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Removes the selection from all currently selected items.
|
|
|
|
*/
|
|
|
|
virtual void UnselectAll();
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2012-03-30 14:29:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
class wxDirFilterListCtrl: public wxChoice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDirFilterListCtrl();
|
2016-01-16 13:55:01 -05:00
|
|
|
wxDirFilterListCtrl(wxGenericDirCtrl* parent, wxWindowID id = wxID_ANY,
|
2012-03-30 14:29:03 -04:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0);
|
2016-01-16 13:55:01 -05:00
|
|
|
bool Create(wxGenericDirCtrl* parent, wxWindowID id = wxID_ANY,
|
2012-03-30 14:29:03 -04:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0);
|
|
|
|
|
|
|
|
virtual ~wxDirFilterListCtrl() {}
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
//// Operations
|
|
|
|
void FillFilterList(const wxString& filter, int defaultFilter);
|
|
|
|
};
|
2013-04-26 02:37:25 -04:00
|
|
|
|
2013-05-16 10:33:01 -04:00
|
|
|
wxEventType wxEVT_DIRCTRL_SELECTIONCHANGED;
|
2013-05-16 10:33:07 -04:00
|
|
|
wxEventType wxEVT_DIRCTRL_FILEACTIVATED;
|