class WXDLLEXPORT wxFileDialogBase: public wxDialog
{
public:
- wxFileDialogBase () {}
+ wxFileDialogBase () { Init(); }
wxFileDialogBase(wxWindow *parent,
- const wxString& message = wxFileSelectorPromptStr,
- const wxString& defaultDir = wxEmptyString,
- const wxString& defaultFile = wxEmptyString,
- const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
- long style = 0,
- const wxPoint& pos = wxDefaultPosition);
+ const wxString& message = wxFileSelectorPromptStr,
+ const wxString& defaultDir = wxEmptyString,
+ const wxString& defaultFile = wxEmptyString,
+ const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
+ long style = 0,
+ const wxPoint& pos = wxDefaultPosition) : wxDialog()
+ {
+ Init();
+ Create(parent, message, defaultDir, defaultFile, wildCard, style, pos);
+ }
+
+ bool Create(wxWindow *parent,
+ const wxString& message = wxFileSelectorPromptStr,
+ const wxString& defaultDir = wxEmptyString,
+ const wxString& defaultFile = wxEmptyString,
+ const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
+ long style = 0,
+ const wxPoint& pos = wxDefaultPosition);
virtual void SetMessage(const wxString& message) { m_message = message; }
virtual void SetPath(const wxString& path) { m_path = path; }
int m_filterIndex;
private:
+ void Init();
DECLARE_DYNAMIC_CLASS(wxFileDialogBase)
DECLARE_NO_COPY_CLASS(wxFileDialogBase)
};
class WXDLLEXPORT wxGenericFileDialog: public wxFileDialogBase
{
public:
- wxGenericFileDialog() { }
+ wxGenericFileDialog() : wxFileDialogBase() { Init(); }
wxGenericFileDialog(wxWindow *parent,
- const wxString& message = wxFileSelectorPromptStr,
+ const wxString& message = wxFileSelectorPromptStr,
const wxString& defaultDir = wxEmptyString,
const wxString& defaultFile = wxEmptyString,
- const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
- long style = 0,
- const wxPoint& pos = wxDefaultPosition,
- bool bypassGenericImpl = false );
+ const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
+ long style = 0,
+ const wxPoint& pos = wxDefaultPosition,
+ bool bypassGenericImpl = false );
+
bool Create( wxWindow *parent,
const wxString& message = wxFileSelectorPromptStr,
- const wxString& defaultDir = wxEmptyString,
- const wxString& defaultFile = wxEmptyString,
+ const wxString& defaultDir = wxEmptyString,
+ const wxString& defaultFile = wxEmptyString,
const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
long style = 0,
- const wxPoint& pos = wxDefaultPosition );
+ const wxPoint& pos = wxDefaultPosition,
+ bool bypassGenericImpl = false );
+
virtual ~wxGenericFileDialog();
virtual void SetMessage(const wxString& message) { SetTitle(message); }
wxBitmapButton *m_newDirButton;
private:
+ void Init();
DECLARE_DYNAMIC_CLASS(wxGenericFileDialog)
DECLARE_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFileDialogBase, wxDialog)
-wxFileDialogBase::wxFileDialogBase(wxWindow *parent,
- const wxString& message,
- const wxString& defaultDir,
- const wxString& defaultFile,
- const wxString& wildCard,
- long style,
- const wxPoint& WXUNUSED(pos))
- : m_message(message),
- m_dir(defaultDir),
- m_fileName(defaultFile),
- m_wildCard(wildCard)
+void wxFileDialogBase::Init()
+{
+ m_filterIndex = m_dialogStyle = 0;
+ m_parent = NULL;
+}
+
+bool wxFileDialogBase::Create(wxWindow *parent,
+ const wxString& message,
+ const wxString& defaultDir,
+ const wxString& defaultFile,
+ const wxString& wildCard,
+ long style,
+ const wxPoint& WXUNUSED(pos))
{
+ m_message = message;
+ m_dir = defaultDir;
+ m_fileName = defaultFile;
+ m_wildCard = wildCard;
+
m_parent = parent;
m_dialogStyle = style;
m_filterIndex = 0;
);
}
}
+
+ return true;
}
#if WXWIN_COMPATIBILITY_2_4
long wxGenericFileDialog::ms_lastViewStyle = wxLC_LIST;
bool wxGenericFileDialog::ms_lastShowHidden = false;
+void wxGenericFileDialog::Init()
+{
+ m_bypassGenericImpl = false;
+
+ m_choice = NULL;
+ m_text = NULL;
+ m_list = NULL;
+ m_check = NULL;
+ m_static = NULL;
+ m_upDirButton = NULL;
+ m_newDirButton = NULL;
+}
+
wxGenericFileDialog::wxGenericFileDialog(wxWindow *parent,
const wxString& message,
const wxString& defaultDir,
const wxString& defaultFile,
const wxString& wildCard,
- long style,
+ long style,
const wxPoint& pos,
- bool bypassGenericImpl )
- :wxFileDialogBase(parent, message, defaultDir, defaultFile, wildCard, style, pos)
+ bool bypassGenericImpl ) : wxFileDialogBase()
{
- m_bypassGenericImpl = bypassGenericImpl;
-
- if (!m_bypassGenericImpl)
- Create( parent, message, defaultDir, defaultFile, wildCard, style, pos );
+ Init();
+ Create( parent, message, defaultDir, defaultFile, wildCard, style, pos, bypassGenericImpl );
}
bool wxGenericFileDialog::Create( wxWindow *parent,
const wxString& message,
- const wxString& WXUNUSED(defaultDir),
+ const wxString& defaultDir,
const wxString& defaultFile,
const wxString& wildCard,
- long WXUNUSED(style),
- const wxPoint& pos )
+ long style,
+ const wxPoint& pos,
+ bool bypassGenericImpl )
{
+ m_bypassGenericImpl = bypassGenericImpl;
+
+ if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFile,
+ wildCard, style, pos))
+ {
+ return false;
+ }
+
+ if (m_bypassGenericImpl)
+ return true;
+
if (!wxDialog::Create( parent, wxID_ANY, message, pos, wxDefaultSize,
- wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ))
+ wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ))
{
return false;
}
wildFilters);
wxCHECK_RET( count, wxT("wxFileDialog: bad wildcard string") );
- m_choice->Clear();
- for ( size_t n = 0; n < count; n++ )
+ size_t n, old_count = m_choice->GetCount();
+ for ( n = 0; n < count; n++ )
+ {
+ delete (wxString *)m_choice->GetClientData(n);
+ }
+
+ for ( n = 0; n < count; n++ )
{
m_choice->Append( wildDescriptions[n], new wxString( wildFilters[n] ) );
}