Allow retrieving current filter from wxFileDialog extra controls

Add wxFileDialog::GetCurrentlySelectedFilterIndex() similar to the
existing GetCurrentlySelectedFilename(), which can be used to retrieve
the index of the currently selected filter and update the state of the
extra controls in wxFileDialog accordingly.

Implement this for wxMSW only by updating the internally stored value
from the native CDN_TYPECHANGE notification and also generating a
wxEVT_UPDATE_UI event to allow the extra controls to update themselves.

Closes https://github.com/wxWidgets/wxWidgets/pull/1310
This commit is contained in:
QuentinC
2019-04-30 21:55:15 +02:00
committed by Vadim Zeitlin
parent 1916442956
commit 413abb066e
5 changed files with 56 additions and 0 deletions

View File

@@ -114,6 +114,9 @@ public:
virtual wxString GetCurrentlySelectedFilename() const
{ return m_currentlySelectedFilename; }
virtual int GetCurrentlySelectedFilterIndex () const
{ return m_currentlySelectedFilterIndex; }
// this function is called with wxFileDialog as parameter and should
// create the window containing the extra controls we want to show in it
typedef wxWindow *(*ExtraControlCreatorFunction)(wxWindow*);
@@ -153,6 +156,12 @@ protected:
// GetCurrentlySelectedFilename().
wxString m_currentlySelectedFilename;
// Currently selected, but not yet necessarily accepted by the user, file
// type (a.k.a. filter) index. This should be updated whenever the
// selection in the control changes by the platform-specific code to
// provide a useful implementation of GetCurrentlySelectedFilterIndex().
int m_currentlySelectedFilterIndex;
wxWindow* m_extraControl;
// returns true if control is created (if it already exists returns false)