Add "filter changed" event to wxFileCtrl.
Generate an event when the selection in the filter combobox of wxFileCtrl changes. Closes #12099. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64429 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -63,6 +63,7 @@ public:
|
||||
virtual void ShowHidden(bool show) = 0;
|
||||
};
|
||||
|
||||
void GenerateFilterChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd );
|
||||
void GenerateFolderChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd );
|
||||
void GenerateSelectionChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd );
|
||||
void GenerateFileActivatedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd, const wxString filename = wxEmptyString );
|
||||
@@ -76,6 +77,8 @@ void GenerateFileActivatedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd, const
|
||||
#endif
|
||||
|
||||
// Some documentation
|
||||
// On wxEVT_FILECTRL_FILTERCHANGED, only the value returned by GetFilterIndex is
|
||||
// valid and it represents the (new) current filter index for the wxFileCtrl.
|
||||
// On wxEVT_FILECTRL_FOLDERCHANGED, only the value returned by GetDirectory is
|
||||
// valid and it represents the (new) current directory for the wxFileCtrl.
|
||||
// On wxEVT_FILECTRL_FILEACTIVATED, GetDirectory returns the current directory
|
||||
@@ -100,13 +103,16 @@ public:
|
||||
|
||||
void SetFiles( const wxArrayString &files ) { m_files = files; }
|
||||
void SetDirectory( const wxString &directory ) { m_directory = directory; }
|
||||
void SetFilterIndex( int filterIndex ) { m_filterIndex = filterIndex; }
|
||||
|
||||
wxArrayString GetFiles() const { return m_files; }
|
||||
wxString GetDirectory() const { return m_directory; }
|
||||
int GetFilterIndex() const { return m_filterIndex; }
|
||||
|
||||
wxString GetFile() const;
|
||||
|
||||
protected:
|
||||
int m_filterIndex;
|
||||
wxString m_directory;
|
||||
wxArrayString m_files;
|
||||
|
||||
@@ -118,6 +124,7 @@ typedef void ( wxEvtHandler::*wxFileCtrlEventFunction )( wxFileCtrlEvent& );
|
||||
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_SELECTIONCHANGED, wxFileCtrlEvent );
|
||||
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_FILEACTIVATED, wxFileCtrlEvent );
|
||||
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_FOLDERCHANGED, wxFileCtrlEvent );
|
||||
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_FILTERCHANGED, wxFileCtrlEvent );
|
||||
|
||||
#define wxFileCtrlEventHandler(func) \
|
||||
wxEVENT_HANDLER_CAST( wxFileCtrlEventFunction, func )
|
||||
@@ -131,6 +138,9 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_FILECTRL_FOLDERCHANGED, wxFile
|
||||
#define EVT_FILECTRL_FOLDERCHANGED(id, fn) \
|
||||
wx__DECLARE_EVT1(wxEVT_FILECTRL_FOLDERCHANGED, id, wxFileCtrlEventHandler(fn))
|
||||
|
||||
#define EVT_FILECTRL_FILTERCHANGED(id, fn) \
|
||||
wx__DECLARE_EVT1(wxEVT_FILECTRL_FILTERCHANGED, id, wxFileCtrlEventHandler(fn))
|
||||
|
||||
#endif // wxUSE_FILECTRL
|
||||
|
||||
#endif // _WX_FILECTRL_H_BASE_
|
||||
|
@@ -32,7 +32,7 @@ typedef struct _GtkFileChooser GtkFileChooser;
|
||||
class WXDLLIMPEXP_CORE wxGtkFileChooser
|
||||
{
|
||||
public:
|
||||
wxGtkFileChooser() {}
|
||||
wxGtkFileChooser() { m_ignoreNextFilterEvent = false; }
|
||||
|
||||
void SetWidget(GtkFileChooser *w);
|
||||
|
||||
@@ -48,6 +48,10 @@ public:
|
||||
void SetWildcard( const wxString& wildCard );
|
||||
void SetFilterIndex( int filterIndex );
|
||||
|
||||
bool HasFilterChoice() const;
|
||||
|
||||
bool ShouldIgnoreNextFilterEvent() const { return m_ignoreNextFilterEvent; }
|
||||
|
||||
wxString GetCurrentWildCard() const
|
||||
{ return m_wildcards[GetFilterIndex()]; }
|
||||
|
||||
@@ -56,6 +60,10 @@ private:
|
||||
// First wildcard in filter, to be used when the user
|
||||
// saves a file without giving an extension.
|
||||
wxArrayString m_wildcards;
|
||||
|
||||
// If true, ignore the next event because it was generated by us and not
|
||||
// the user.
|
||||
bool m_ignoreNextFilterEvent;
|
||||
};
|
||||
|
||||
#if wxUSE_FILECTRL
|
||||
@@ -110,6 +118,14 @@ public:
|
||||
virtual bool HasMultipleFileSelection() const { return HasFlag( wxFC_MULTIPLE ); }
|
||||
virtual void ShowHidden(bool show);
|
||||
|
||||
virtual bool HasFilterChoice() const
|
||||
{ return m_fc.HasFilterChoice(); }
|
||||
|
||||
|
||||
// Implementation only from now on.
|
||||
bool GTKShouldIgnoreNextFilterEvent() const
|
||||
{ return m_fc.ShouldIgnoreNextFilterEvent(); }
|
||||
|
||||
bool m_checkNextSelEvent;
|
||||
bool m_ignoreNextFolderChangeEvent;
|
||||
|
||||
|
Reference in New Issue
Block a user