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
|
|
|
|
// RCS-ID: $Id$
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
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}
|
|
|
|
Use 3D borders for internal controls.
|
|
|
|
@style{wxDIRCTRL_SELECT_FIRST}
|
|
|
|
When setting the default path, select the first file in the
|
|
|
|
directory.
|
|
|
|
@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
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
|
|
|
@category{ctrl}
|
2008-10-13 04:05:18 -04:00
|
|
|
@appearance{genericdirctrl.png}
|
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
|
|
|
*/
|
2008-11-09 11:46:52 -05:00
|
|
|
wxGenericDirCtrl(wxWindow* parent, const wxWindowID id = wxID_ANY,
|
2008-03-08 09:43:31 -05:00
|
|
|
const wxString& dir = wxDirDialogDefaultFolderStr,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2009-01-08 11:33:08 -05:00
|
|
|
long style = wxDIRCTRL_3D_INTERNAL,
|
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
|
|
|
*/
|
2008-09-29 06:52:37 -04:00
|
|
|
bool Create(wxWindow* parent, const wxWindowID id = wxID_ANY,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxString& dir = wxDirDialogDefaultFolderStr,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2008-09-29 06:52:37 -04:00
|
|
|
long style = wxDIRCTRL_3D_INTERNAL,
|
|
|
|
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
|
|
|
|
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
|
|
|
|