+ if ( m_firstFileTypeFilter >= 0 )
+ m_filterChoice->SetSelection(m_firstFileTypeFilter);
+ }
+ m_filterChoice->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(wxFileDialog::OnFilterSelected), NULL, this);
+ }
+
+ if(extracontrol)
+ {
+ wxBoxSizer *horizontalSizer = new wxBoxSizer(wxHORIZONTAL);
+ verticalSizer->Add(horizontalSizer, 0, wxEXPAND, 0);
+
+ extracontrol->Reparent(extrapanel);
+ horizontalSizer->Add(extracontrol);
+ }
+
+ verticalSizer->Layout();
+ verticalSizer->SetSizeHints(extrapanel);
+ return extrapanel;
+}
+
+void wxFileDialog::DoOnFilterSelected(int index)
+{
+ NSArray* types = GetTypesFromExtension(m_filterExtensions[index],m_currentExtensions);
+ NSSavePanel* panel = (NSSavePanel*) GetWXWindow();
+ if ( m_delegate )
+ [panel validateVisibleColumns];
+ else
+ [panel setAllowedFileTypes:types];
+}
+
+// An item has been selected in the file filter wxChoice:
+void wxFileDialog::OnFilterSelected( wxCommandEvent &WXUNUSED(event) )
+{
+ DoOnFilterSelected( m_filterChoice->GetSelection() );
+}
+
+bool wxFileDialog::CheckFile( const wxString& filename )
+{
+ if ( m_currentExtensions.GetCount() == 0 )
+ return true;
+
+ wxString ext = filename.AfterLast('.').Lower();
+
+ for ( size_t i = 0; i < m_currentExtensions.GetCount(); ++i )
+ {
+ if ( ext == m_currentExtensions[i] )
+ return true;
+ }
+ return false;
+}
+
+void wxFileDialog::SetupExtraControls(WXWindow nativeWindow)
+{
+ NSSavePanel* panel = (NSSavePanel*) nativeWindow;
+
+ wxNonOwnedWindow::Create( GetParent(), nativeWindow );
+ wxWindow* extracontrol = NULL;
+ if ( HasExtraControlCreator() )
+ {
+ CreateExtraControl();
+ extracontrol = GetExtraControl();
+ }
+
+ NSView* accView = nil;
+ m_delegate = nil;
+
+ if ( m_useFileTypeFilter )
+ {
+ m_filterPanel = CreateFilterPanel(extracontrol);
+ accView = m_filterPanel->GetHandle();
+ if( HasFlag(wxFD_OPEN) )
+ {
+ if ( UMAGetSystemVersion() < 0x1060 || !HasAppKit_10_6() )