+ 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_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 )
+ {
+ wxOpenPanelDelegate* del = [[wxOpenPanelDelegate alloc]init];
+ [del setFileDialog:this];
+ [panel setDelegate:del];
+ m_delegate = del;
+ }
+ }
+ }
+ else
+ {
+ m_filterPanel = NULL;
+ m_filterChoice = NULL;
+ if ( extracontrol != nil )
+ accView = extracontrol->GetHandle();
+ }
+
+ if ( accView != nil )
+ {
+ [accView removeFromSuperview];
+ [panel setAccessoryView:accView];
+ }
+ else
+ {
+ [panel setAccessoryView:nil];
+ }
+}