]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/filedlgg.cpp
Removed unnecessary casts
[wxWidgets.git] / src / generic / filedlgg.cpp
index 334e2370df1e2b40291376d1298e54c96926be69..55da3ff5ff0565559ef9c597504e38f853af5a73 100644 (file)
@@ -695,7 +695,7 @@ void wxFileCtrl::GoToHomeDir()
 
 void wxFileCtrl::GoToDir( const wxString &dir )
 {
-    if (!wxDirExists(dir)) return;
+    if (!wxPathExists(dir)) return;
 
     m_dirName = dir;
     UpdateFiles();
@@ -878,32 +878,54 @@ END_EVENT_TABLE()
 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;
     }
@@ -1129,8 +1151,14 @@ void wxGenericFileDialog::SetWildcard(const wxString& wildCard)
                                                     wildFilters);
     wxCHECK_RET( count, wxT("wxFileDialog: bad wildcard string") );
 
-    m_choice->Clear();
-    for ( size_t n = 0; n < count; n++ )
+    const size_t countOld = m_choice->GetCount();
+    size_t n;
+    for ( n = 0; n < countOld; n++ )
+    {
+        delete (wxString *)m_choice->GetClientData(n);
+    }
+
+    for ( n = 0; n < count; n++ )
     {
         m_choice->Append( wildDescriptions[n], new wxString( wildFilters[n] ) );
     }
@@ -1197,7 +1225,7 @@ void wxGenericFileDialog::OnSelected( wxListEvent &event )
     if (!IsTopMostDir(dir))
         dir += wxFILE_SEP_PATH;
     dir += filename;
-    if (wxDirExists(dir)) return;
+    if (wxPathExists(dir)) return;
 
     ignoreChanges = true;
     m_text->SetValue( filename );
@@ -1259,7 +1287,7 @@ void wxGenericFileDialog::HandleAction( const wxString &fn )
         filename = dir;
     }
 
-    if (wxDirExists(filename))
+    if (wxPathExists(filename))
     {
         m_list->GoToDir( filename );
         UpdateControls();