+}
+
+// Create a panel with the file type drop down list
+// If extra controls need to be added (see wxFileDialog::SetExtraControlCreator), add
+// them to the panel as well
+// Returns the newly created wxPanel
+
+wxWindow* wxFileDialog::CreateFilterPanel(wxWindow *extracontrol)
+{
+ wxPanel *extrapanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
+ wxBoxSizer *verticalSizer = new wxBoxSizer(wxVERTICAL);
+ extrapanel->SetSizer(verticalSizer);
+
+ // the file type control
+ {
+ wxBoxSizer *horizontalSizer = new wxBoxSizer(wxHORIZONTAL);
+ verticalSizer->Add(horizontalSizer, 0, wxEXPAND, 0);
+ wxStaticText *stattext = new wxStaticText( extrapanel, wxID_ANY, _("File type:") );
+ horizontalSizer->Add(stattext, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ m_filterChoice = new wxChoice(extrapanel, wxID_ANY);
+ horizontalSizer->Add(m_filterChoice, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ m_filterChoice->Append(m_filterNames);
+ if( m_filterNames.GetCount() > 0)
+ {
+ if ( m_firstFileTypeFilter >= 0 )
+ m_filterChoice->SetSelection(m_firstFileTypeFilter);
+ }
+ m_filterChoice->Connect(wxEVT_CHOICE, 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;