]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/filedlgg.cpp
delete_ --> delete
[wxWidgets.git] / src / generic / filedlgg.cpp
index 334e2370df1e2b40291376d1298e54c96926be69..0cf73c397e1c52f98b76b56234f8c715bda5cb66 100644 (file)
@@ -135,7 +135,7 @@ int wxCALLBACK wxFileDataTimeCompare( long data1, long data2, long data)
      return fd1->GetDateTime().IsLaterThan(fd2->GetDateTime()) ? int(data) : -int(data);
 }
 
-#if defined(__UNIX__) && !defined(__OS2__)
+#if defined(__UNIX__) && !defined(__OS2__) && !defined(__CYGWIN__)
 #define IsTopMostDir(dir)   (dir == wxT("/"))
 #endif
 
@@ -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] ) );
     }
@@ -1239,16 +1267,19 @@ void wxGenericFileDialog::HandleAction( const wxString &fn )
     }
 #endif // __UNIX__
 
-    if ((filename.Find(wxT('*')) != wxNOT_FOUND) ||
-        (filename.Find(wxT('?')) != wxNOT_FOUND))
+    if (!(m_dialogStyle & wxSAVE))
     {
-        if (filename.Find(wxFILE_SEP_PATH) != wxNOT_FOUND)
+        if ((filename.Find(wxT('*')) != wxNOT_FOUND) ||
+            (filename.Find(wxT('?')) != wxNOT_FOUND))
         {
-            wxMessageBox(_("Illegal file specification."), _("Error"), wxOK | wxICON_ERROR );
+            if (filename.Find(wxFILE_SEP_PATH) != wxNOT_FOUND)
+            {
+                wxMessageBox(_("Illegal file specification."), _("Error"), wxOK | wxICON_ERROR );
+                return;
+            }
+            m_list->SetWild( filename );
             return;
         }
-        m_list->SetWild( filename );
-        return;
     }
 
     if (!IsTopMostDir(dir))