]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/filedlg.mm
fixing searchctrl on osx_cocoa, changing type for peer to wxSearchCtrl
[wxWidgets.git] / src / osx / cocoa / filedlg.mm
index b4decc5dcd16a48ec2d467141ec57f5c90067b73..3e5de2867b0597aa3fd9084a293e1a3f19f6bb30 100644 (file)
@@ -52,6 +52,11 @@ wxFileDialog::wxFileDialog(
 {
 }
 
+bool wxFileDialog::SupportsExtraControl() const
+{
+    return true;
+}
+
 NSArray* GetTypesFromFilter( const wxString filter )
 {
     NSMutableArray* types = nil;
@@ -116,6 +121,10 @@ NSArray* GetTypesFromFilter( const wxString filter )
                 if (extension.length() && (extension.GetChar(0) == '.'))
                     extension = extension.Mid( 1 );
 
+                // Remove leading '*', this is for handling *.*
+                if (extension.length() && (extension.GetChar(0) == '*'))
+                    extension = extension.Mid( 1 );
+
                 if ( extension.IsEmpty() )
                 {
                     if ( types != nil )
@@ -158,6 +167,9 @@ void wxFileDialog::ShowWindowModal()
     if (HasFlag(wxFD_SAVE))
     {
         NSSavePanel* sPanel = [NSSavePanel savePanel];
+
+        SetupExtraControls(sPanel);
+
         // makes things more convenient:
         [sPanel setCanCreateDirectories:YES];
         [sPanel setMessage:cf.AsNSString()];
@@ -178,6 +190,9 @@ void wxFileDialog::ShowWindowModal()
     {
         NSArray* types = GetTypesFromFilter( m_wildCard ) ;
         NSOpenPanel* oPanel = [NSOpenPanel openPanel];
+        
+        SetupExtraControls(oPanel);
+
         [oPanel setTreatsFilePackagesAsDirectories:NO];
         [oPanel setCanChooseDirectories:NO];
         [oPanel setResolvesAliases:YES];
@@ -195,10 +210,31 @@ void wxFileDialog::ShowWindowModal()
     }
 }
 
-int wxFileDialog::ShowModal()
+void wxFileDialog::SetupExtraControls(WXWindow nativeWindow)
 {
-    NSSavePanel *panel = nil;
+    NSSavePanel* panel = (NSSavePanel*) nativeWindow;
+    
+    wxNonOwnedWindow::Create( GetParent(), nativeWindow );
+    
+    if (HasExtraControlCreator())
+    {
+        CreateExtraControl();
+        wxWindow* control = GetExtraControl();
+        if ( control )
+        {
+            NSView* accView = control->GetHandle();
+            [accView removeFromSuperview];
+            [panel setAccessoryView:accView];
+        }
+        else
+        {
+            [panel setAccessoryView:nil];
+        }
+    }
+}
 
+int wxFileDialog::ShowModal()
+{
     wxCFStringRef cf( m_message );
 
     wxCFStringRef dir( m_dir );
@@ -221,6 +257,9 @@ int wxFileDialog::ShowModal()
     if (HasFlag(wxFD_SAVE))
     {
         NSSavePanel* sPanel = [NSSavePanel savePanel];
+
+        SetupExtraControls(sPanel);
+
         // makes things more convenient:
         [sPanel setCanCreateDirectories:YES];
         [sPanel setMessage:cf.AsNSString()];
@@ -235,11 +274,17 @@ int wxFileDialog::ShowModal()
 
         returnCode = [sPanel runModalForDirectory:dir.AsNSString() file:file.AsNSString() ];
         ModalFinishedCallback(sPanel, returnCode);
+
+        UnsubclassWin();
+        [sPanel setAccessoryView:nil];
     }
     else
     {
         NSArray* types = GetTypesFromFilter( m_wildCard ) ;
         NSOpenPanel* oPanel = [NSOpenPanel openPanel];
+        
+        SetupExtraControls(oPanel);
+                
         [oPanel setTreatsFilePackagesAsDirectories:NO];
         [oPanel setCanChooseDirectories:NO];
         [oPanel setResolvesAliases:YES];
@@ -251,6 +296,9 @@ int wxFileDialog::ShowModal()
 
         ModalFinishedCallback(oPanel, returnCode);
         
+        UnsubclassWin();
+        [oPanel setAccessoryView:nil];
+        
         if ( types != nil )
             [types release];
     }
@@ -299,6 +347,8 @@ void wxFileDialog::ModalFinishedCallback(void* panel, int returnCode)
     
     if (GetModality() == wxDIALOG_MODALITY_WINDOW_MODAL)
         SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED  );
+    
+    [(NSSavePanel*) panel setAccessoryView:nil];
 }
 
 #endif // wxUSE_FILEDLG