Warn on incompatible wxDirDialog styles

This commit is contained in:
Ian McInerney
2020-06-02 10:36:53 +01:00
committed by Vadim Zeitlin
parent 7230acd110
commit ade5030c56
4 changed files with 11 additions and 1 deletions

View File

@@ -88,7 +88,12 @@ public:
virtual void SetPath(const wxString& path) { m_path = path; } virtual void SetPath(const wxString& path) { m_path = path; }
virtual wxString GetMessage() const { return m_message; } virtual wxString GetMessage() const { return m_message; }
virtual wxString GetPath() const { return m_path; } virtual wxString GetPath() const
{
wxCHECK_MSG( !HasFlag(wxDD_MULTIPLE), wxString(), "When using wxDD_MULTIPLE, must call GetPaths() instead" );
return m_path;
}
virtual void GetPaths(wxArrayString& paths) const { paths.Empty(); paths.Add(m_path); } virtual void GetPaths(wxArrayString& paths) const { paths.Empty(); paths.Add(m_path); }
protected: protected:

View File

@@ -122,6 +122,9 @@ public:
/** /**
Returns the default or user-selected path. Returns the default or user-selected path.
@note This function can't be used with dialogs which have the @c wxDD_MULTIPLE style,
use GetPaths() instead.
*/ */
virtual wxString GetPath() const; virtual wxString GetPath() const;

View File

@@ -190,6 +190,7 @@ void wxDirDialog::SetPath(const wxString& dir)
wxString wxDirDialog::GetPath() const wxString wxDirDialog::GetPath() const
{ {
wxCHECK_MSG( !HasFlag(wxDD_MULTIPLE), wxString(), "When using wxDD_MULTIPLE, must call GetPaths() instead" );
return m_paths.Last(); return m_paths.Last();
} }

View File

@@ -173,6 +173,7 @@ void wxDirDialog::SetTitle(const wxString &title)
wxString wxDirDialog::GetPath() const wxString wxDirDialog::GetPath() const
{ {
wxCHECK_MSG( !HasFlag(wxDD_MULTIPLE), wxString(), "When using wxDD_MULTIPLE, must call GetPaths() instead" );
return m_paths.Last(); return m_paths.Last();
} }