From 4deccfc980f38e97f24f0e7911c0b776894da542 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Mon, 13 Jul 2015 12:36:40 -0500 Subject: [PATCH] Round 3 retry...helps to add the changed files to the commit --- lib-src/FileDialog/FileDialog.cpp | 25 ++ lib-src/FileDialog/FileDialog.h | 15 +- lib-src/FileDialog/mac/FileDialog.h | 25 +- lib-src/FileDialog/mac/FileDialog.mm | 393 ++++++++++++--------------- src/export/Export.cpp | 105 +++++++ src/export/Export.h | 17 +- src/export/ExportCL.cpp | 86 +++--- src/export/ExportFFmpeg.cpp | 41 ++- src/export/ExportFFmpegDialogs.cpp | 210 +++++--------- src/export/ExportFFmpegDialogs.h | 36 +-- src/export/ExportFLAC.cpp | 61 +---- src/export/ExportMP2.cpp | 65 +---- src/export/ExportMP3.cpp | 87 +++--- src/export/ExportOGG.cpp | 86 ++---- src/export/ExportPCM.cpp | 97 ++----- 15 files changed, 588 insertions(+), 761 deletions(-) diff --git a/lib-src/FileDialog/FileDialog.cpp b/lib-src/FileDialog/FileDialog.cpp index 12fdac567..7a6296817 100644 --- a/lib-src/FileDialog/FileDialog.cpp +++ b/lib-src/FileDialog/FileDialog.cpp @@ -34,6 +34,31 @@ DEFINE_EVENT_TYPE(EVT_FILEDIALOG_SELECTION_CHANGED); DEFINE_EVENT_TYPE(EVT_FILEDIALOG_FILTER_CHANGED); DEFINE_EVENT_TYPE(EVT_FILEDIALOG_ADD_CONTROLS); +FileDialogBase::FileDialogBase() +{ + m_creator = NULL; + m_userdata = NULL; +} + +bool FileDialogBase::HasUserPaneCreator() const +{ + return m_creator != NULL; +} + +void FileDialogBase::SetUserPaneCreator(UserPaneCreatorFunction creator, wxUIntPtr userdata) +{ + m_creator = creator; + m_userdata = userdata; +} + +void FileDialogBase::CreateUserPane(wxWindow *parent) +{ + if (m_creator) + { + (*m_creator)(parent, m_userdata); + } +} + void FileDialogBase::EnableButton(wxString label, fdCallback cb, void *data) { m_buttonlabel = label; diff --git a/lib-src/FileDialog/FileDialog.h b/lib-src/FileDialog/FileDialog.h index ca4a48e7f..b2ee90ba6 100644 --- a/lib-src/FileDialog/FileDialog.h +++ b/lib-src/FileDialog/FileDialog.h @@ -18,6 +18,7 @@ custom controls. #define _FILE_DIALOG_H_ #include +#include #include typedef void (*fdCallback)(void *, int); @@ -45,13 +46,25 @@ DECLARE_EVENT_TYPE(EVT_FILEDIALOG_ADD_CONTROLS, -1); class FileDialogBase : public wxFileDialogBase { public: - FileDialogBase() {}; + FileDialogBase(); virtual ~FileDialogBase() {}; + // FileDialogBase + + typedef void (*UserPaneCreatorFunction)(wxWindow *parent, wxUIntPtr userdata); + + virtual bool HasUserPaneCreator() const; + virtual void SetUserPaneCreator(UserPaneCreatorFunction creator, wxUIntPtr userdata); + virtual void EnableButton(wxString label, fdCallback cb, void *cbdata); virtual void ClickButton(int index); protected: + void CreateUserPane(wxWindow *parent); + + UserPaneCreatorFunction m_creator; + wxUIntPtr m_userdata; + wxString m_buttonlabel; fdCallback m_callback; void *m_cbdata; diff --git a/lib-src/FileDialog/mac/FileDialog.h b/lib-src/FileDialog/mac/FileDialog.h index fd6dc9102..7c42c92bb 100644 --- a/lib-src/FileDialog/mac/FileDialog.h +++ b/lib-src/FileDialog/mac/FileDialog.h @@ -31,7 +31,7 @@ protected: wxArrayString m_paths; public: - FileDialog() { Init(); } + FileDialog(); FileDialog(wxWindow *parent, const wxString& message = wxFileSelectorPromptStr, const wxString& defaultDir = wxEmptyString, @@ -40,12 +40,7 @@ public: long style = wxFD_DEFAULT_STYLE, const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize, - const wxString& name = wxFileDialogNameStr) - { - Init(); - - Create(parent,message,defaultDir,defaultFile,wildCard,style,pos,sz,name); - } + const wxString& name = wxFileDialogNameStr); void Create(wxWindow *parent, const wxString& message = wxFileSelectorPromptStr, @@ -61,16 +56,6 @@ public: ~FileDialog(); #endif - virtual void EnableButton(wxString label, fdCallback cb, void *cbdata) - { - FileDialogBase::EnableButton(label, cb, cbdata); - } - - virtual void ClickButton(int index) - { - FileDialogBase::ClickButton(index); - }; - virtual void GetPaths(wxArrayString& paths) const { paths = m_paths; } virtual void GetFilenames(wxArrayString& files) const { files = m_fileNames ; } @@ -86,8 +71,9 @@ public: // implementation only #if wxOSX_USE_COCOA - // returns true if the file can be shown as active - bool CheckFile( const wxString& filename ); + void DoSendFileActivatedEvent(void* panel); + void DoSendFolderChangedEvent(void* panel, const wxString& path); + void DoSendSelectionChangedEvent(void* panel); #endif protected: @@ -99,7 +85,6 @@ protected: void SetupExtraControls(WXWindow nativeWindow); #if wxOSX_USE_COCOA - virtual wxWindow* CreateFilterPanel(wxWindow *extracontrol); void DoOnFilterSelected(int index); virtual void OnFilterSelected(wxCommandEvent &event); diff --git a/lib-src/FileDialog/mac/FileDialog.mm b/lib-src/FileDialog/mac/FileDialog.mm index 3245e0448..64aea9adc 100644 --- a/lib-src/FileDialog/mac/FileDialog.mm +++ b/lib-src/FileDialog/mac/FileDialog.mm @@ -21,7 +21,7 @@ // ---------------------------------------------------------------------------- // For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" +#include #include "FileDialog.h" @@ -47,57 +47,28 @@ // implementation // ============================================================================ -// Open Items: -// - parameter support for descending into packages as directories (setTreatsFilePackagesAsDirectories) -// - as setAllowedFileTypes is only functional for NSOpenPanel on 10.6+, on earlier systems, the file -// type choice will not be shown, but all possible file items will be shown, if a popup must be working -// then the delegate method - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename will have to -// be implemented - -namespace -{ - -bool HasAppKit_10_6() -{ - // Even if we require 10.6, we might be loaded by an application that - // was linked against 10.5. setAllowedFileTypes will still be ignored - // in this case. From NSSavePanel.h: - // NSOpenPanel: On versions less than 10.6, this property is ignored. - // For applications that link against 10.6 and higher, this property will - // determine which files should be enabled in the open panel. - int32_t version = NSVersionOfLinkTimeLibrary("AppKit"); - if (version == -1) - { - // If we're loaded by an application that doesn't link against AppKit, - // use the runtime version instead. This check will not work for the - // case above. - version = NSVersionOfRunTimeLibrary("AppKit"); - } - - // Notice that this still works correctly even if version is -1. - return version >= 0x40e2400 /* version of 10.6 AppKit */; -} - -} // anonymous namespace - -@interface OpenPanelDelegate : NSObject wxOSX_10_6_AND_LATER() +@interface OSPanelDelegate : NSObject wxOSX_10_6_AND_LATER() { FileDialog* _dialog; + BOOL _didActivate; } - (FileDialog*) fileDialog; - (void) setFileDialog:(FileDialog*) dialog; -- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename; +- (BOOL)panel:(id)sender validateURL:(NSURL *)url error:(NSError **)outError AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER; +- (void)panel:(id)sender didChangeToDirectoryURL:(NSURL *)url AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER; +- (void)panelSelectionDidChange:(id)sender AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; @end -@implementation OpenPanelDelegate +@implementation OSPanelDelegate - (id) init { self = [super init]; _dialog = NULL; + _didActivate = NO; return self; } @@ -111,83 +82,54 @@ bool HasAppKit_10_6() _dialog = dialog; } -- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename +- (BOOL)panel:(id)sender validateURL:(NSURL *)url error:(NSError **)outError AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER { - BOOL showObject = YES; - - NSString* resolvedLink = [[NSFileManager defaultManager] pathContentOfSymbolicLinkAtPath:filename]; - if ( resolvedLink != nil ) - filename = resolvedLink; - - NSDictionary* fileAttribs = [[NSFileManager defaultManager] - fileAttributesAtPath:filename traverseLink:YES]; - if (fileAttribs) - { - // check for packages - if ([NSFileTypeDirectory isEqualTo:[fileAttribs objectForKey:NSFileType]]) - { - if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:filename] == NO) - showObject = YES; // it's a folder, OK to show - else - { - // it's a packaged directory, apply check - wxCFStringRef filecf([filename retain]); - showObject = _dialog->CheckFile(filecf.AsString()); - } - } - else - { - // the code above only solves links, not aliases, do this here: - - NSString* resolvedAlias = nil; - - CFURLRef url = CFURLCreateWithFileSystemPath (kCFAllocatorDefault, - (CFStringRef)filename, - kCFURLPOSIXPathStyle, - NO); - if (url != NULL) - { - FSRef fsRef; - if (CFURLGetFSRef(url, &fsRef)) - { - Boolean targetIsFolder, wasAliased; - OSErr err = FSResolveAliasFile (&fsRef, true, &targetIsFolder, &wasAliased); - - if ((err == noErr) && wasAliased) - { - CFURLRef resolvedUrl = CFURLCreateFromFSRef(kCFAllocatorDefault, &fsRef); - if (resolvedUrl != NULL) - { - resolvedAlias = (NSString*) CFURLCopyFileSystemPath(resolvedUrl, - kCFURLPOSIXPathStyle); - CFRelease(resolvedUrl); - } - } - } - CFRelease(url); - } + if (_didActivate == NO) + { + _dialog->DoSendFileActivatedEvent( sender ); + _didActivate = YES; + } - if (resolvedAlias != nil) - { - // recursive call - [resolvedAlias autorelease]; - showObject = [self panel:sender shouldShowFilename:resolvedAlias]; - } - else - { - wxCFStringRef filecf([filename retain]); - showObject = _dialog->CheckFile(filecf.AsString()); - } - } - } - - return showObject; + return YES; } +- (void)panel:(id)sender didChangeToDirectoryURL:(NSURL *)url AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +{ + wxString path = wxCFStringRef::AsStringWithNormalizationFormC( [url path] ); + + _dialog->DoSendFolderChangedEvent(sender, path); +} + +- (void)panelSelectionDidChange:(id)sender AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +{ + _dialog->DoSendSelectionChangedEvent(sender); +} @end IMPLEMENT_CLASS(FileDialog, FileDialogBase) +FileDialog::FileDialog() +: FileDialogBase() +{ + Init(); +} + +FileDialog::FileDialog(wxWindow *parent, + const wxString& message, + const wxString& defaultDir, + const wxString& defaultFile, + const wxString& wildCard, + long style, + const wxPoint& pos, + const wxSize& sz, + const wxString& name) +: FileDialogBase() +{ + Init(); + + Create(parent,message,defaultDir,defaultFile,wildCard,style,pos,sz,name); +} + void FileDialog::Init() { m_filterIndex = -1; @@ -382,56 +324,17 @@ void FileDialog::ShowWindowModal() } } -// Create a panel with the file type drop down list -// If extra controls need to be added (see FileDialog::SetExtraControlCreator), add -// them to the panel as well -// Returns the newly created wxPanel - -wxWindow* FileDialog::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(FileDialog::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 FileDialog::DoOnFilterSelected(int index) { NSArray* types = GetTypesFromExtension(m_filterExtensions[index],m_currentExtensions); NSSavePanel* panel = (NSSavePanel*) GetWXWindow(); - if ( m_delegate ) - [panel validateVisibleColumns]; - else - [panel setAllowedFileTypes:types]; + [panel setAllowedFileTypes:types]; + + m_filterIndex = index; + + wxFileCtrlEvent event( wxEVT_FILECTRL_FILTERCHANGED, this, GetId() ); + event.SetFilterIndex( m_filterIndex ); + GetEventHandler()->ProcessEvent( event ); } // An item has been selected in the file filter wxChoice: @@ -440,21 +343,78 @@ void FileDialog::OnFilterSelected( wxCommandEvent &WXUNUSED(event) ) DoOnFilterSelected( m_filterChoice->GetSelection() ); } -bool FileDialog::CheckFile( const wxString& filename ) +void FileDialog::DoSendFileActivatedEvent(void* panel) { - if ( m_currentExtensions.GetCount() == 0 ) - return true; - - wxString ext = filename.AfterLast('.').Lower(); - - for ( size_t i = 0; i < m_currentExtensions.GetCount(); ++i ) + wxFileCtrlEvent event( wxEVT_FILECTRL_FILEACTIVATED, this, GetId() ); + + event.SetDirectory( m_dir ); + + if ( HasFlag( wxFD_SAVE ) ) { - if ( ext == m_currentExtensions[i] ) - return true; + wxArrayString filenames; + filenames.Add( m_fileName ); + event.SetFiles( filenames ); } - return false; + else + { + event.SetFiles( m_fileNames ); + } + + GetEventHandler()->ProcessEvent( event ); } +void FileDialog::DoSendFolderChangedEvent(void* panel, const wxString & path) +{ + m_dir = wxPathOnly( path ); + + wxFileCtrlEvent event( wxEVT_FILECTRL_FOLDERCHANGED, this, GetId() ); + + event.SetDirectory( m_dir ); + + GetEventHandler()->ProcessEvent( event ); +} + +void FileDialog::DoSendSelectionChangedEvent(void* panel) +{ + if ( HasFlag( wxFD_SAVE ) ) + { + NSSavePanel* sPanel = (NSSavePanel*) panel; + NSString* path = [[sPanel URL] path]; + + m_path = wxCFStringRef::AsStringWithNormalizationFormC( path ); + m_fileName = wxFileNameFromPath( m_path ); + m_dir = wxPathOnly( m_path ); + } + else + { + NSOpenPanel* oPanel = (NSOpenPanel*) panel; + m_paths.Clear(); + m_fileNames.Clear(); + + NSArray* urls = [oPanel URLs]; + for ( size_t i = 0 ; i < [urls count] ; ++ i ) + { + NSString *path = [[urls objectAtIndex:i] path]; + wxString fnstr = wxCFStringRef::AsStringWithNormalizationFormC( path ); + m_paths.Add( fnstr ); + m_fileNames.Add( wxFileNameFromPath( fnstr ) ); + if ( i == 0 ) + { + m_path = fnstr; + m_fileName = wxFileNameFromPath( fnstr ); + m_dir = wxPathOnly( fnstr ); + } + } + } + + wxFileCtrlEvent event( wxEVT_FILECTRL_SELECTIONCHANGED, this, GetId() ); + + event.SetDirectory( m_dir ); + event.SetFiles( m_fileNames ); + + GetEventHandler()->ProcessEvent( event ); +} + void FileDialog::SetupExtraControls(WXWindow nativeWindow) { NSSavePanel* panel = (NSSavePanel*) nativeWindow; @@ -463,38 +423,58 @@ void FileDialog::SetupExtraControls(WXWindow nativeWindow) // workaround for crashes we don't support those yet if ( [panel contentView] == nil || getenv("APP_SANDBOX_CONTAINER_ID") != NULL ) return; - + + OSPanelDelegate* del = [[OSPanelDelegate alloc]init]; + [del setFileDialog:this]; + [panel setDelegate:del]; + m_delegate = del; + wxNonOwnedWindow::Create( GetParent(), nativeWindow ); - wxWindow* extracontrol = NULL; - if ( HasExtraControlCreator() ) - { - CreateExtraControl(); - extracontrol = GetExtraControl(); - } + + m_filterPanel = NULL; + m_filterChoice = NULL; NSView* accView = nil; - - if ( m_useFileTypeFilter ) + if ( m_useFileTypeFilter || HasUserPaneCreator() ) { - m_filterPanel = CreateFilterPanel(extracontrol); - accView = m_filterPanel->GetHandle(); - if( HasFlag(wxFD_OPEN) ) + wxBoxSizer *verticalSizer = new wxBoxSizer( wxVERTICAL ); + m_filterPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize ); + + if ( m_useFileTypeFilter ) { - if ( UMAGetSystemVersion() < 0x1060 || !HasAppKit_10_6() ) + wxBoxSizer *horizontalSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxStaticText *stattext = new wxStaticText( m_filterPanel, wxID_ANY, _("File type:") ); + horizontalSizer->Add( stattext, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + m_filterChoice = new wxChoice( m_filterPanel, wxID_ANY ); + m_filterChoice->Append( m_filterNames ); + if ( m_filterNames.GetCount() > 0 ) { - OpenPanelDelegate* del = [[OpenPanelDelegate alloc]init]; - [del setFileDialog:this]; - [panel setDelegate:del]; - m_delegate = del; + if ( m_firstFileTypeFilter >= 0 ) + m_filterChoice->SetSelection( m_firstFileTypeFilter ); } + m_filterChoice->Connect( wxEVT_CHOICE, wxCommandEventHandler( FileDialog::OnFilterSelected ), NULL, this ); + + horizontalSizer->Add( m_filterChoice, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + verticalSizer->Add( horizontalSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); } - } - else - { - m_filterPanel = NULL; - m_filterChoice = NULL; - if ( extracontrol != nil ) - accView = extracontrol->GetHandle(); + + if ( HasUserPaneCreator() ) + { + wxPanel *extrapanel = new wxPanel( m_filterPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize ); + CreateUserPane( extrapanel ); + + wxBoxSizer *horizontalSizer = new wxBoxSizer( wxHORIZONTAL ); + horizontalSizer->Add( extrapanel, 1, wxEXPAND, 5 ); + verticalSizer->Add( horizontalSizer, 1, wxEXPAND|wxALL, 5 ); + } + + m_filterPanel->SetSizer( verticalSizer ); + m_filterPanel->Layout(); + verticalSizer->SetSizeHints( m_filterPanel ); + + accView = m_filterPanel->GetHandle(); } if ( accView != nil ) @@ -502,10 +482,6 @@ void FileDialog::SetupExtraControls(WXWindow nativeWindow) [accView removeFromSuperview]; [panel setAccessoryView:accView]; } - else - { - [panel setAccessoryView:nil]; - } } int FileDialog::ShowModal() @@ -633,21 +609,11 @@ int FileDialog::ShowModal() [oPanel setMessage:cf.AsNSString()]; [oPanel setAllowsMultipleSelection: (HasFlag(wxFD_MULTIPLE) ? YES : NO )]; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 - if ( UMAGetSystemVersion() >= 0x1060 && HasAppKit_10_6() ) - { - [oPanel setAllowedFileTypes: (m_delegate == nil ? types : nil)]; - if ( !m_dir.IsEmpty() ) - [oPanel setDirectoryURL:[NSURL fileURLWithPath:dir.AsNSString() - isDirectory:YES]]; - returnCode = [oPanel runModal]; - } - else -#endif - { - returnCode = [oPanel runModalForDirectory:m_dir.IsEmpty() ? nil : dir.AsNSString() - file:file.AsNSString() types:(m_delegate == nil ? types : nil)]; - } + [oPanel setAllowedFileTypes:types]; + if ( !m_dir.IsEmpty() ) + [oPanel setDirectoryURL:[NSURL fileURLWithPath:dir.AsNSString() + isDirectory:YES]]; + returnCode = [oPanel runModal]; ModalFinishedCallback(oPanel, returnCode); } @@ -660,9 +626,9 @@ void FileDialog::ModalFinishedCallback(void* panel, int returnCode) int result = wxID_CANCEL; if (HasFlag(wxFD_SAVE)) { + NSSavePanel* sPanel = (NSSavePanel*)panel; if (returnCode == NSOKButton ) { - NSSavePanel* sPanel = (NSSavePanel*)panel; result = wxID_OK; m_path = wxCFStringRef::AsStringWithNormalizationFormC([sPanel filename]); @@ -673,6 +639,7 @@ void FileDialog::ModalFinishedCallback(void* panel, int returnCode) m_filterIndex = m_filterChoice->GetSelection(); } } + [sPanel setDelegate:nil]; } else { @@ -695,13 +662,15 @@ void FileDialog::ModalFinishedCallback(void* panel, int returnCode) } } } - if ( m_delegate ) - { - [oPanel setDelegate:nil]; - [m_delegate release]; - m_delegate = nil; - } + [oPanel setDelegate:nil]; } + + if ( m_delegate ) + { + [m_delegate release]; + m_delegate = nil; + } + SetReturnCode(result); if (GetModality() == wxDIALOG_MODALITY_WINDOW_MODAL) diff --git a/src/export/Export.cpp b/src/export/Export.cpp index b76c49979..692e7d5ec 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -235,6 +236,24 @@ bool ExportPlugin::DisplayOptions(wxWindow * WXUNUSED(parent), int WXUNUSED(form return false; } +wxWindow *ExportPlugin::OptionsCreate(wxWindow *parent, int format) +{ + wxPanel *p = new wxPanel(parent, wxID_ANY); + ShuttleGui S(p, eIsCreatingFromPrefs); + + S.StartHorizontalLay(wxCENTER); + { + S.StartHorizontalLay(wxCENTER, 0); + { + S.Prop(1).AddTitle(_("No format specific options")); + } + S.EndHorizontalLay(); + } + S.EndHorizontalLay(); + + return p; +} + int ExportPlugin::Export(AudacityProject *project, int channels, wxString fName, @@ -280,13 +299,20 @@ Mixer* ExportPlugin::CreateMixer(int numInputTracks, WaveTrack **inputTracks, outRate, outFormat, highQuality, mixerSpec); } + //---------------------------------------------------------------------------- // Export //---------------------------------------------------------------------------- +BEGIN_EVENT_TABLE(Exporter, wxEvtHandler) + EVT_FILECTRL_FILTERCHANGED(wxID_ANY, Exporter::OnFilterChanged) +END_EVENT_TABLE() + Exporter::Exporter() { + mActivePage = NULL; mMixerSpec = NULL; + SetFileDialogTitle( _("Export Audio") ); RegisterPlugin(New_ExportPCM()); @@ -552,7 +578,9 @@ bool Exporter::GetFilename() maskString, wxFD_SAVE | wxRESIZE_BORDER | FD_NO_ADD_EXTENSION); mDialog = &fd; + mDialog->PushEventHandler(this); + fd.SetUserPaneCreator(CreateUserPaneCallback, (wxUIntPtr) this); fd.SetFilterIndex(mFilterIndex); fd.EnableButton(_("&Options..."), ExportCallback, this); @@ -843,6 +871,83 @@ bool Exporter::ExportTracks() return (success == eProgressSuccess || success == eProgressStopped); } +void Exporter::CreateUserPaneCallback(wxWindow *parent, wxUIntPtr userdata) +{ + Exporter *self = (Exporter *) userdata; + if (self) + { + self->CreateUserPane(parent); + } +} + +void Exporter::CreateUserPane(wxWindow *parent) +{ + mUserPaneParent = parent; + + ShuttleGui S(parent, eIsCreatingFromPrefs); + + wxSize maxsz; + wxSize pageMax; + + S.StartVerticalLay(); + { + S.StartHorizontalLay(wxEXPAND); + { + S.StartStatic(_("Format Options"), 1); + { + for (size_t i = 0; i < mPlugins.GetCount(); i++) + { + for (int j = 0; j < mPlugins[i]->GetFormatCount(); j++) + { + wxWindow *page = mPlugins[i]->OptionsCreate(parent, j); + mPages.Add(page); + S.Prop(1).AddWindow(page, wxEXPAND|wxALL); + + parent->Layout(); + wxSize sz = parent->GetBestSize(); + maxsz.x = wxMax(maxsz.x, sz.x); + maxsz.y = wxMax(maxsz.y, sz.y); + + sz = page->GetBestSize(); + pageMax.x = wxMax(pageMax.x, sz.x); + pageMax.y = wxMax(pageMax.y, sz.y); + + S.GetSizer()->Hide(page); + } + } + } + S.EndStatic(); + } + S.EndHorizontalLay(); + } + S.EndHorizontalLay(); + + parent->SetMinSize(maxsz); + parent->SetSize(maxsz); + + for (size_t i = 0, cnt = mPages.GetCount(); i < cnt; i++) + { + mPages[i]->SetSize(pageMax); + } + + return; +} + +void Exporter::OnFilterChanged(wxFileCtrlEvent & evt) +{ + int index = evt.GetFilterIndex(); + + if (mActivePage) + { + mActivePage->Hide(); + mActivePage = NULL; + } + + mActivePage = mPages[index]; + mActivePage->Show(); + mUserPaneParent->Layout(); +} + //---------------------------------------------------------------------------- // ExportMixerPanel //---------------------------------------------------------------------------- diff --git a/src/export/Export.h b/src/export/Export.h index d066d4952..3f98f63b3 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -18,6 +18,8 @@ #include "../Tags.h" #include "../SampleFormat.h" +#include "FileDialog.h" + class wxMemoryDC; class wxStaticText; class AudacityProject; @@ -82,6 +84,8 @@ public: virtual bool DisplayOptions(wxWindow *parent, int format = 0); + virtual wxWindow *OptionsCreate(wxWindow *parent, int format); + virtual bool CheckFileName(wxFileName &filename, int format = 0); /** \brief called to export audio into a file. @@ -130,11 +134,12 @@ private: }; WX_DECLARE_USER_EXPORTED_OBJARRAY(ExportPlugin *, ExportPluginArray, AUDACITY_DLL_API); +WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxWindow *, WindowPtrArray, class AUDACITY_DLL_API); //---------------------------------------------------------------------------- // Exporter //---------------------------------------------------------------------------- -class AUDACITY_DLL_API Exporter +class AUDACITY_DLL_API Exporter : public wxEvtHandler { public: @@ -163,6 +168,10 @@ private: bool CheckMix(); bool ExportTracks(); + static void CreateUserPaneCallback(wxWindow *parent, wxUIntPtr userdata); + void CreateUserPane(wxWindow *parent); + void OnFilterChanged(wxFileCtrlEvent & evt); + private: FileDialog *mDialog; wxString mFileDialogTitle; @@ -185,6 +194,12 @@ private: int mNumMono; int mChannels; bool mSelectedOnly; + + wxWindow *mUserPaneParent; + WindowPtrArray mPages; + wxWindow *mActivePage; + + DECLARE_EVENT_TABLE(); }; //---------------------------------------------------------------------------- diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index f831784e0..bcc157ada 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -35,13 +36,13 @@ // ExportCLOptions //---------------------------------------------------------------------------- -class ExportCLOptions : public wxDialog +class ExportCLOptions : public wxPanel { public: + ExportCLOptions(wxWindow *parent, int format); + virtual ~ExportCLOptions(); - ExportCLOptions(wxWindow *parent); void PopulateOrExchange(ShuttleGui & S); - void OnOK(wxCommandEvent & event); void OnBrowse(wxCommandEvent & event); @@ -54,19 +55,15 @@ private: #define ID_BROWSE 5000 -BEGIN_EVENT_TABLE(ExportCLOptions, wxDialog) - EVT_BUTTON(wxID_OK, ExportCLOptions::OnOK) +BEGIN_EVENT_TABLE(ExportCLOptions, wxPanel) EVT_BUTTON(ID_BROWSE, ExportCLOptions::OnBrowse) END_EVENT_TABLE() /// /// -ExportCLOptions::ExportCLOptions(wxWindow *parent) -: wxDialog(parent, wxID_ANY, - wxString(_("Specify Command Line Encoder"))) +ExportCLOptions::ExportCLOptions(wxWindow *parent, int WXUNUSED(format)) +: wxPanel(parent, wxID_ANY) { - SetName(GetTitle()); - mHistory.Load(*gPrefs, wxT("/FileFormats/ExternalProgramHistory")); if (mHistory.GetCount() == 0) { @@ -81,6 +78,22 @@ ExportCLOptions::ExportCLOptions(wxWindow *parent) ShuttleGui S(this, eIsCreatingFromPrefs); PopulateOrExchange(S); + + parent->Layout(); +} + +ExportCLOptions::~ExportCLOptions() +{ + wxString cmd = mCmd->GetValue(); + + gPrefs->Write(wxT("/FileFormats/ExternalProgramExportCommand"), cmd); + gPrefs->Flush(); + + ShuttleGui S(this, eIsSavingToPrefs); + PopulateOrExchange(S); + + mHistory.AddFileToHistory(cmd, false); + mHistory.Save(*gPrefs, wxT("/FileFormats/ExternalProgramHistory")); } /// @@ -95,10 +108,11 @@ void ExportCLOptions::PopulateOrExchange(ShuttleGui & S) } cmd = cmds[0]; - S.StartHorizontalLay(wxEXPAND, 0); + S.StartVerticalLay(); { - S.StartStatic(_("Command Line Export Setup"), true); + S.StartHorizontalLay(wxEXPAND); { + S.SetSizerProportion(1); S.StartMultiColumn(3, wxEXPAND); { S.SetStretchyCol(1); @@ -113,41 +127,15 @@ void ExportCLOptions::PopulateOrExchange(ShuttleGui & S) false); } S.EndMultiColumn(); - - S.AddFixedText(_("Data will be piped to standard in. \"%f\" uses the file name in the export window.")); } - S.EndStatic(); + S.EndHorizontalLay(); + + S.AddTitle(_("Data will be piped to standard in. \"%f\" uses the file name in the export window.")); } - S.EndHorizontalLay(); + S.EndVerticalLay(); - S.AddStandardButtons(); - - Layout(); - Fit(); - SetMinSize(GetSize()); - Center(); - - return; -} - -/// -/// -void ExportCLOptions::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - ShuttleGui S(this, eIsSavingToPrefs); - wxString cmd = mCmd->GetValue(); - - gPrefs->Write(wxT("/FileFormats/ExternalProgramExportCommand"), cmd); - gPrefs->Flush(); - - PopulateOrExchange(S); - - mHistory.AddFileToHistory(cmd, false); - mHistory.Save(*gPrefs, wxT("/FileFormats/ExternalProgramHistory")); - - EndModal(wxID_OK); - - return; +// Layout(); +// Fit(); } /// @@ -275,8 +263,8 @@ public: void Destroy(); // Required + wxWindow *OptionsCreate(wxWindow *parent, int format); - bool DisplayOptions(wxWindow *parent, int format = 0); int Export(AudacityProject *project, int channels, wxString fName, @@ -529,13 +517,9 @@ int ExportCL::Export(AudacityProject *project, return updateResult; } -bool ExportCL::DisplayOptions(wxWindow *parent, int WXUNUSED(format)) +wxWindow *ExportCL::OptionsCreate(wxWindow *parent, int format) { - ExportCLOptions od(parent); - - od.ShowModal(); - - return true; + return new ExportCLOptions(parent, format); } ExportPlugin *New_ExportCL() diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index eb8b586c7..951b57c6d 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -57,13 +57,16 @@ function. extern FFmpegLibs *FFmpegLibsInst; -static bool CheckFFmpegPresence() +static bool CheckFFmpegPresence(bool quiet = false) { bool result = true; PickFFmpegLibs(); if (!FFmpegLibsInst->ValidLibsLoaded()) { - wxMessageBox(_("Properly configured FFmpeg is required to proceed.\nYou can configure it at Preferences > Libraries.")); + if (!quiet) + { + wxMessageBox(_("Properly configured FFmpeg is required to proceed.\nYou can configure it at Preferences > Libraries.")); + } result = false; } DropFFmpegLibs(); @@ -117,9 +120,9 @@ public: /// Flushes audio encoder bool Finalize(); - /// Shows options dialog + /// Creates options panel ///\param format - index of export type - bool DisplayOptions(wxWindow *parent, int format = 0); + wxWindow *OptionsCreate(wxWindow *parent, int format); /// Check whether or not current project sample rate is compatible with the export codec bool CheckSampleRate(int rate, int lowrate, int highrate, const int *sampRates); @@ -975,45 +978,41 @@ int ExportFFmpeg::AskResample(int bitrate, int rate, int lowrate, int highrate, return wxAtoi(choice->GetStringSelection()); } - -bool ExportFFmpeg::DisplayOptions(wxWindow *parent, int format) +wxWindow *ExportFFmpeg::OptionsCreate(wxWindow *parent, int format) { - if (!CheckFFmpegPresence()) - return false; + if (!CheckFFmpegPresence(true)) { + return ExportPlugin::OptionsCreate(parent, format); + } + // subformat index may not correspond directly to fmts[] index, convert it mSubFormat = AdjustFormatIndex(format); if (mSubFormat == FMT_M4A) { - ExportFFmpegAACOptions od(parent); - od.ShowModal(); - return true; + return new ExportFFmpegAACOptions(parent, format); } else if (mSubFormat == FMT_AC3) { - ExportFFmpegAC3Options od(parent); - od.ShowModal(); - return true; + return new ExportFFmpegAC3Options(parent, format); } else if (mSubFormat == FMT_AMRNB) { - ExportFFmpegAMRNBOptions od(parent); - od.ShowModal(); - return true; + return new ExportFFmpegAMRNBOptions(parent, format); } else if (mSubFormat == FMT_WMA2) { - ExportFFmpegWMAOptions od(parent); - od.ShowModal(); - return true; + return new ExportFFmpegWMAOptions(parent, format); } else if (mSubFormat == FMT_OTHER) { + return ExportPlugin::OptionsCreate(parent, format); +#if 0 ExportFFmpegOptions od(parent); od.ShowModal(); return true; +#endif } - return false; + return ExportPlugin::OptionsCreate(parent, format); } ExportPlugin *New_ExportFFmpeg() diff --git a/src/export/ExportFFmpegDialogs.cpp b/src/export/ExportFFmpegDialogs.cpp index aeb374f59..e8fce8360 100644 --- a/src/export/ExportFFmpegDialogs.cpp +++ b/src/export/ExportFFmpegDialogs.cpp @@ -139,28 +139,27 @@ static const wxChar *FFmpegExportCtrlIDNames[] = { // ExportFFmpegAC3Options Class //---------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(ExportFFmpegAC3Options, wxDialog) - EVT_BUTTON(wxID_OK,ExportFFmpegAC3Options::OnOK) -END_EVENT_TABLE() - // This initialises content for the static const member variables defined in // ExportFFmpegDialogs.h (note no static keyword - important!) const int ExportFFmpegAC3Options::iAC3BitRates[] = { 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000, 384000, 448000, 512000, 576000, 640000 }; const int ExportFFmpegAC3Options::iAC3SampleRates[] = { 32000, 44100, 48000, 0 }; -ExportFFmpegAC3Options::ExportFFmpegAC3Options(wxWindow *parent) -: wxDialog(parent, wxID_ANY, - wxString(_("Specify AC3 Options"))) +ExportFFmpegAC3Options::ExportFFmpegAC3Options(wxWindow *parent, int WXUNUSED(format)) +: wxPanel(parent, wxID_ANY) { - SetName(GetTitle()); - ShuttleGui S(this, eIsCreatingFromPrefs); - for (unsigned int i=0; i < (sizeof(iAC3BitRates)/sizeof(int)); i++) { mBitRateNames.Add(wxString::Format(_("%i kbps"),iAC3BitRates[i]/1000)); mBitRateLabels.Add(iAC3BitRates[i]); } + ShuttleGui S(this, eIsCreatingFromPrefs); + PopulateOrExchange(S); +} + +ExportFFmpegAC3Options::~ExportFFmpegAC3Options() +{ + ShuttleGui S(this, eIsSavingToPrefs); PopulateOrExchange(S); } @@ -168,58 +167,36 @@ ExportFFmpegAC3Options::ExportFFmpegAC3Options(wxWindow *parent) /// void ExportFFmpegAC3Options::PopulateOrExchange(ShuttleGui & S) { - S.StartHorizontalLay(wxEXPAND, 0); + S.StartVerticalLay(); { - S.StartStatic(_("AC3 Export Setup"), 0); + S.StartHorizontalLay(wxCENTER); { - S.StartTwoColumn(); + S.StartMultiColumn(2, wxCENTER); { S.TieChoice(_("Bit Rate:"), wxT("/FileFormats/AC3BitRate"), 160000, mBitRateNames, mBitRateLabels); } - S.EndTwoColumn(); + S.EndMultiColumn(); } - S.EndStatic(); + S.EndHorizontalLay(); } - S.EndHorizontalLay(); - - S.AddStandardButtons(); - - Layout(); - Fit(); - SetMinSize(GetSize()); - Center(); - - return; -} - -/// -/// -void ExportFFmpegAC3Options::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - ShuttleGui S(this, eIsSavingToPrefs); - PopulateOrExchange(S); - - EndModal(wxID_OK); - - return; + S.EndVerticalLay(); } //---------------------------------------------------------------------------- // ExportFFmpegAACOptions Class //---------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(ExportFFmpegAACOptions, wxDialog) - EVT_BUTTON(wxID_OK,ExportFFmpegAACOptions::OnOK) -END_EVENT_TABLE() - -ExportFFmpegAACOptions::ExportFFmpegAACOptions(wxWindow *parent) -: wxDialog(parent, wxID_ANY, - wxString(_("Specify AAC Options"))) +ExportFFmpegAACOptions::ExportFFmpegAACOptions(wxWindow *parent, int WXUNUSED(format)) +: wxPanel(parent, wxID_ANY) { - SetName(GetTitle()); ShuttleGui S(this, eIsCreatingFromPrefs); + PopulateOrExchange(S); +} +ExportFFmpegAACOptions::~ExportFFmpegAACOptions() +{ + ShuttleGui S(this, eIsSavingToPrefs); PopulateOrExchange(S); } @@ -227,65 +204,48 @@ ExportFFmpegAACOptions::ExportFFmpegAACOptions(wxWindow *parent) /// void ExportFFmpegAACOptions::PopulateOrExchange(ShuttleGui & S) { - S.StartStatic(_("AAC Export Setup"), 1); + S.StartVerticalLay(); { - S.StartMultiColumn(2, wxEXPAND); + S.StartHorizontalLay(wxEXPAND); { - S.SetStretchyCol(1); - S.TieSlider(_("Quality:"),wxT("/FileFormats/AACQuality"),100,500,10); + S.SetSizerProportion(1); + S.StartMultiColumn(2, wxCENTER); + { + S.SetStretchyCol(1); + S.Prop(1).TieSlider(_("Quality:"),wxT("/FileFormats/AACQuality"),100,500,10); + } + S.EndMultiColumn(); } - S.EndMultiColumn(); + S.EndHorizontalLay(); } - S.EndStatic(); - S.AddStandardButtons(); - - Layout(); - Fit(); - SetMinSize(GetSize()); - Center(); - - return; + S.EndVerticalLay(); } -/// -/// -void ExportFFmpegAACOptions::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - ShuttleGui S(this, eIsSavingToPrefs); - PopulateOrExchange(S); - - EndModal(wxID_OK); - - return; -} - - //---------------------------------------------------------------------------- // ExportFFmpegAMRNBOptions Class //---------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(ExportFFmpegAMRNBOptions, wxDialog) - EVT_BUTTON(wxID_OK,ExportFFmpegAMRNBOptions::OnOK) -END_EVENT_TABLE() - /// Bit Rates supported by libAMR-NB encoder /// Sample Rate is always 8 kHz int ExportFFmpegAMRNBOptions::iAMRNBBitRate[] = { 4750, 5150, 5900, 6700, 7400, 7950, 10200, 12200 }; -ExportFFmpegAMRNBOptions::ExportFFmpegAMRNBOptions(wxWindow *parent) -: wxDialog(parent, wxID_ANY, - wxString(_("Specify AMR-NB Options"))) +ExportFFmpegAMRNBOptions::ExportFFmpegAMRNBOptions(wxWindow *parent, int WXUNUSED(format)) +: wxPanel(parent, wxID_ANY) { - SetName(GetTitle()); - ShuttleGui S(this, eIsCreatingFromPrefs); - for (unsigned int i=0; i < (sizeof(iAMRNBBitRate)/sizeof(int)); i++) { mBitRateNames.Add(wxString::Format(_("%.2f kbps"),(float)iAMRNBBitRate[i]/1000)); mBitRateLabels.Add(iAMRNBBitRate[i]); } + ShuttleGui S(this, eIsCreatingFromPrefs); + PopulateOrExchange(S); +} + +ExportFFmpegAMRNBOptions::~ExportFFmpegAMRNBOptions() +{ + ShuttleGui S(this, eIsSavingToPrefs); PopulateOrExchange(S); } @@ -293,51 +253,26 @@ ExportFFmpegAMRNBOptions::ExportFFmpegAMRNBOptions(wxWindow *parent) /// void ExportFFmpegAMRNBOptions::PopulateOrExchange(ShuttleGui & S) { - S.StartHorizontalLay(wxEXPAND, 0); + S.StartVerticalLay(); { - S.StartStatic(_("AMR-NB Export Setup"), 0); + S.StartHorizontalLay(wxCENTER); { - S.StartTwoColumn(); + S.StartMultiColumn(2, wxCENTER); { S.TieChoice(_("Bit Rate:"), wxT("/FileFormats/AMRNBBitRate"), 12200, mBitRateNames, mBitRateLabels); } - S.EndTwoColumn(); + S.EndMultiColumn(); } - S.EndStatic(); + S.EndHorizontalLay(); } - S.EndHorizontalLay(); - - S.AddStandardButtons(); - - Layout(); - Fit(); - SetMinSize(GetSize()); - Center(); - - return; -} - -/// -/// -void ExportFFmpegAMRNBOptions::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - ShuttleGui S(this, eIsSavingToPrefs); - PopulateOrExchange(S); - - EndModal(wxID_OK); - - return; + S.EndVerticalLay(); } //---------------------------------------------------------------------------- // ExportFFmpegWMAOptions Class //---------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(ExportFFmpegWMAOptions, wxDialog) - EVT_BUTTON(wxID_OK,ExportFFmpegWMAOptions::OnOK) -END_EVENT_TABLE() - const int ExportFFmpegWMAOptions::iWMASampleRates[] = { 8000, 11025, 16000, 22050, 44100, 0}; @@ -345,20 +280,22 @@ const int ExportFFmpegWMAOptions::iWMASampleRates[] = const int ExportFFmpegWMAOptions::iWMABitRate[] = { 24000, 32000, 40000, 48000, 64000, 80000, 96000, 128000, 160000, 192000, 256000, 320000 }; - -ExportFFmpegWMAOptions::ExportFFmpegWMAOptions(wxWindow *parent) -: wxDialog(parent, wxID_ANY, - wxString(_("Specify WMA Options"))) +ExportFFmpegWMAOptions::ExportFFmpegWMAOptions(wxWindow *parent, int WXUNUSED(format)) +: wxPanel(parent, wxID_ANY) { - SetName(GetTitle()); - ShuttleGui S(this, eIsCreatingFromPrefs); - for (unsigned int i=0; i < (sizeof(iWMABitRate)/sizeof(int)); i++) { mBitRateNames.Add(wxString::Format(wxT("%i kbps"),iWMABitRate[i]/1000)); mBitRateLabels.Add(iWMABitRate[i]); } + ShuttleGui S(this, eIsCreatingFromPrefs); + PopulateOrExchange(S); +} + +ExportFFmpegWMAOptions::~ExportFFmpegWMAOptions() +{ + ShuttleGui S(this, eIsSavingToPrefs); PopulateOrExchange(S); } @@ -366,41 +303,20 @@ ExportFFmpegWMAOptions::ExportFFmpegWMAOptions(wxWindow *parent) /// void ExportFFmpegWMAOptions::PopulateOrExchange(ShuttleGui & S) { - S.StartHorizontalLay(wxEXPAND, 0); + S.StartVerticalLay(); { - S.StartStatic(_("WMA Export Setup"), 0); + S.StartHorizontalLay(wxCENTER); { - S.StartTwoColumn(); + S.StartMultiColumn(2, wxCENTER); { S.TieChoice(_("Bit Rate:"), wxT("/FileFormats/WMABitRate"), 96000, mBitRateNames, mBitRateLabels); } - S.EndTwoColumn(); + S.EndMultiColumn(); } - S.EndStatic(); + S.EndHorizontalLay(); } - S.EndHorizontalLay(); - - S.AddStandardButtons(); - - Layout(); - Fit(); - SetMinSize(GetSize()); - Center(); - - return; -} - -/// -/// -void ExportFFmpegWMAOptions::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - ShuttleGui S(this, eIsSavingToPrefs); - PopulateOrExchange(S); - - EndModal(wxID_OK); - - return; + S.EndVerticalLay(); } FFmpegPreset::FFmpegPreset(wxString &name) diff --git a/src/export/ExportFFmpegDialogs.h b/src/export/ExportFFmpegDialogs.h index b45a44e56..66bd3c305 100644 --- a/src/export/ExportFFmpegDialogs.h +++ b/src/export/ExportFFmpegDialogs.h @@ -57,13 +57,13 @@ struct CompatibilityEntry /// AC3 export options dialog -class ExportFFmpegAC3Options : public wxDialog +class ExportFFmpegAC3Options : public wxPanel { public: - ExportFFmpegAC3Options(wxWindow *parent); + ExportFFmpegAC3Options(wxWindow *parent, int format); + virtual ~ExportFFmpegAC3Options(); void PopulateOrExchange(ShuttleGui & S); - void OnOK(wxCommandEvent& event); /// Bit Rates supported by AC3 encoder static const int iAC3BitRates[]; /// Sample Rates supported by AC3 encoder (must end with zero-element) @@ -76,35 +76,29 @@ private: wxArrayInt mBitRateLabels; wxChoice *mBitRateChoice; - wxButton *mOk; int mBitRateFromChoice; - - DECLARE_EVENT_TABLE() }; -class ExportFFmpegAACOptions : public wxDialog +class ExportFFmpegAACOptions : public wxPanel { public: - ExportFFmpegAACOptions(wxWindow *parent); + ExportFFmpegAACOptions(wxWindow *parent, int format); + virtual ~ExportFFmpegAACOptions(); void PopulateOrExchange(ShuttleGui & S); - void OnOK(wxCommandEvent& event); private: wxSpinCtrl *mQualitySpin; - wxButton *mOk; - - DECLARE_EVENT_TABLE() }; -class ExportFFmpegAMRNBOptions : public wxDialog +class ExportFFmpegAMRNBOptions : public wxPanel { public: - ExportFFmpegAMRNBOptions(wxWindow *parent); + ExportFFmpegAMRNBOptions(wxWindow *parent, int format); + virtual ~ExportFFmpegAMRNBOptions(); void PopulateOrExchange(ShuttleGui & S); - void OnOK(wxCommandEvent& event); static int iAMRNBBitRate[]; @@ -114,19 +108,16 @@ private: wxArrayInt mBitRateLabels; wxChoice *mBitRateChoice; - wxButton *mOk; int mBitRateFromChoice; - - DECLARE_EVENT_TABLE() }; -class ExportFFmpegWMAOptions : public wxDialog +class ExportFFmpegWMAOptions : public wxPanel { public: - ExportFFmpegWMAOptions(wxWindow *parent); + ExportFFmpegWMAOptions(wxWindow *parent, int format); + ~ExportFFmpegWMAOptions(); void PopulateOrExchange(ShuttleGui & S); - void OnOK(wxCommandEvent& event); static const int iWMASampleRates[]; static const int iWMABitRate[]; @@ -137,10 +128,7 @@ private: wxArrayInt mBitRateLabels; wxChoice *mBitRateChoice; - wxButton *mOk; int mBitRateFromChoice; - - DECLARE_EVENT_TABLE() }; /// Entry for the Applicability table diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index 715ad5317..952493e24 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -44,32 +44,20 @@ and libvorbis examples, Monty // ExportFLACOptions Class //---------------------------------------------------------------------------- -class ExportFLACOptions : public wxDialog +class ExportFLACOptions : public wxPanel { public: - ExportFLACOptions(wxWindow *parent); + ExportFLACOptions(wxWindow *parent, int format); void PopulateOrExchange(ShuttleGui & S); - void OnOK(wxCommandEvent& event); - -private: - - DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(ExportFLACOptions, wxDialog) - EVT_BUTTON(wxID_OK, ExportFLACOptions::OnOK) -END_EVENT_TABLE() - /// /// -ExportFLACOptions::ExportFLACOptions(wxWindow *parent) -: wxDialog(parent, wxID_ANY, - wxString(_("Specify FLAC Options"))) +ExportFLACOptions::ExportFLACOptions(wxWindow *parent, int WXUNUSED(format)) +: wxPanel(parent, wxID_ANY) { - SetName(GetTitle()); ShuttleGui S(this, eIsCreatingFromPrefs); - PopulateOrExchange(S); } @@ -92,41 +80,22 @@ void ExportFLACOptions::PopulateOrExchange(ShuttleGui & S) flacBitDepthLabels.Add(wxT("16")); flacBitDepthNames.Add(_("16 bit")); flacBitDepthLabels.Add(wxT("24")); flacBitDepthNames.Add(_("24 bit")); - S.StartHorizontalLay(wxEXPAND, 0); + S.StartVerticalLay(); { - S.StartStatic(_("FLAC Export Setup"), 0); + S.StartHorizontalLay(wxCENTER); { - S.StartTwoColumn(); + S.StartMultiColumn(2, wxCENTER); { S.TieChoice(_("Level:"), wxT("/FileFormats/FLACLevel"), wxT("5"), flacLevelNames, flacLevelLabels); S.TieChoice(_("Bit depth:"), wxT("/FileFormats/FLACBitDepth"), wxT("16"), flacBitDepthNames, flacBitDepthLabels); } - S.EndTwoColumn(); + S.EndMultiColumn(); } - S.EndStatic(); + S.EndHorizontalLay(); } - S.EndHorizontalLay(); - - S.AddStandardButtons(); - - Layout(); - Fit(); - SetMinSize(GetSize()); - Center(); - - return; -} - -/// -/// -void ExportFLACOptions::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - ShuttleGui S(this, eIsSavingToPrefs); - PopulateOrExchange(S); - - EndModal(wxID_OK); + S.EndVerticalLay(); return; } @@ -178,7 +147,7 @@ public: // Required - bool DisplayOptions(wxWindow *parent, int format = 0); + wxWindow *OptionsCreate(wxWindow *parent, int format); int Export(AudacityProject *project, int channels, wxString fName, @@ -364,13 +333,9 @@ int ExportFLAC::Export(AudacityProject *project, return updateResult; } -bool ExportFLAC::DisplayOptions(wxWindow *parent, int WXUNUSED(format)) +wxWindow *ExportFLAC::OptionsCreate(wxWindow *parent, int format) { - ExportFLACOptions od(parent); - - od.ShowModal(); - - return true; + return new ExportFLACOptions(parent, format); } // LL: There's a bug in libflac++ 1.1.2 that prevents us from using diff --git a/src/export/ExportMP2.cpp b/src/export/ExportMP2.cpp index cfc6d9aa6..75adff1a5 100644 --- a/src/export/ExportMP2.cpp +++ b/src/export/ExportMP2.cpp @@ -81,42 +81,30 @@ static int iBitrates[] = { 192, 224, 256, 320, 384 }; -class ExportMP2Options : public wxDialog +class ExportMP2Options : public wxPanel { public: + ExportMP2Options(wxWindow *parent, int format); - /// - /// - ExportMP2Options(wxWindow *parent); void PopulateOrExchange(ShuttleGui & S); - void OnOK(wxCommandEvent& event); private: wxArrayString mBitRateNames; wxArrayInt mBitRateLabels; - - DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(ExportMP2Options, wxDialog) - EVT_BUTTON(wxID_OK, ExportMP2Options::OnOK) -END_EVENT_TABLE() - /// /// -ExportMP2Options::ExportMP2Options(wxWindow *parent) -: wxDialog(parent, wxID_ANY, - wxString(_("Specify MP2 Options"))) +ExportMP2Options::ExportMP2Options(wxWindow *parent, int WXUNUSED(format)) +: wxPanel(parent, wxID_ANY) { - SetName(GetTitle()); - ShuttleGui S(this, eIsCreatingFromPrefs); - for (unsigned int i=0; i < (sizeof(iBitrates)/sizeof(int)); i++) { mBitRateNames.Add(wxString::Format(_("%i kbps"),iBitrates[i])); mBitRateLabels.Add(iBitrates[i]); } + ShuttleGui S(this, eIsCreatingFromPrefs); PopulateOrExchange(S); } @@ -124,41 +112,20 @@ ExportMP2Options::ExportMP2Options(wxWindow *parent) /// void ExportMP2Options::PopulateOrExchange(ShuttleGui & S) { - S.StartHorizontalLay(wxEXPAND, 0); + S.StartVerticalLay(); { - S.StartStatic(_("MP2 Export Setup"), 0); + S.StartHorizontalLay(wxCENTER); { - S.StartTwoColumn(); + S.StartMultiColumn(2, wxCENTER); { S.TieChoice(_("Bit Rate:"), wxT("/FileFormats/MP2Bitrate"), 160, mBitRateNames, mBitRateLabels); } - S.EndTwoColumn(); + S.EndMultiColumn(); } - S.EndStatic(); + S.EndHorizontalLay(); } - S.EndHorizontalLay(); - - S.AddStandardButtons(); - - Layout(); - Fit(); - SetMinSize(GetSize()); - Center(); - - return; -} - -/// -/// -void ExportMP2Options::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - ShuttleGui S(this, eIsSavingToPrefs); - PopulateOrExchange(S); - - EndModal(wxID_OK); - - return; + S.EndVerticalLay(); } //---------------------------------------------------------------------------- @@ -174,7 +141,7 @@ public: // Required - bool DisplayOptions(wxWindow *parent, int format = 0); + wxWindow *OptionsCreate(wxWindow *parent, int format); int Export(AudacityProject *project, int channels, wxString fName, @@ -333,13 +300,9 @@ int ExportMP2::Export(AudacityProject *project, return updateResult; } -bool ExportMP2::DisplayOptions(wxWindow *parent, int WXUNUSED(format)) +wxWindow *ExportMP2::OptionsCreate(wxWindow *parent, int format) { - ExportMP2Options od(parent); - - od.ShowModal(); - - return true; + return new ExportMP2Options(parent, format); } // returns buffer len; caller frees diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index f93d1693a..ee5f09a2f 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -257,13 +257,14 @@ static void InitMP3_Statics() } } -class ExportMP3Options : public wxDialog +class ExportMP3Options : public wxPanel { public: - ExportMP3Options(wxWindow *parent); + ExportMP3Options(wxWindow *parent, int format); + virtual ~ExportMP3Options(); + void PopulateOrExchange(ShuttleGui & S); - void OnOK(wxCommandEvent& event); void OnSET(wxCommandEvent& evt); void OnVBR(wxCommandEvent& evt); void OnABR(wxCommandEvent& evt); @@ -294,23 +295,19 @@ private: DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(ExportMP3Options, wxDialog) +BEGIN_EVENT_TABLE(ExportMP3Options, wxPanel) EVT_RADIOBUTTON(ID_SET, ExportMP3Options::OnSET) EVT_RADIOBUTTON(ID_VBR, ExportMP3Options::OnVBR) EVT_RADIOBUTTON(ID_ABR, ExportMP3Options::OnABR) EVT_RADIOBUTTON(ID_CBR, ExportMP3Options::OnCBR) EVT_CHOICE(wxID_ANY, ExportMP3Options::OnQuality) - EVT_BUTTON(wxID_OK, ExportMP3Options::OnOK) END_EVENT_TABLE() /// /// -ExportMP3Options::ExportMP3Options(wxWindow *parent) -: wxDialog(parent, wxID_ANY, - wxString(_("Specify MP3 Options"))) +ExportMP3Options::ExportMP3Options(wxWindow *parent, int WXUNUSED(format)) +: wxPanel(parent, wxID_ANY) { - SetName(GetTitle()); - InitMP3_Statics(); mSetRate = gPrefs->Read(wxT("/FileFormats/MP3SetRate"), PRESET_STANDARD); @@ -319,19 +316,30 @@ ExportMP3Options::ExportMP3Options(wxWindow *parent) mCbrRate = gPrefs->Read(wxT("/FileFormats/MP3CbrRate"), 128); ShuttleGui S(this, eIsCreatingFromPrefs); - PopulateOrExchange(S); } +ExportMP3Options::~ExportMP3Options() +{ + ShuttleGui S(this, eIsSavingToPrefs); + PopulateOrExchange(S); + + gPrefs->Write(wxT("/FileFormats/MP3SetRate"), mSetRate); + gPrefs->Write(wxT("/FileFormats/MP3VbrRate"), mVbrRate); + gPrefs->Write(wxT("/FileFormats/MP3AbrRate"), mAbrRate); + gPrefs->Write(wxT("/FileFormats/MP3CbrRate"), mCbrRate); + gPrefs->Flush(); +} + /// /// void ExportMP3Options::PopulateOrExchange(ShuttleGui & S) { - S.StartHorizontalLay(wxEXPAND, 0); + S.StartVerticalLay(); { - S.StartStatic(_("MP3 Export Setup"), 0); + S.StartHorizontalLay(wxCENTER); { - S.StartMultiColumn(2, wxEXPAND); + S.StartMultiColumn(2, wxCENTER); { S.SetStretchyCol(1); S.StartTwoColumn(); @@ -349,12 +357,12 @@ void ExportMP3Options::PopulateOrExchange(ShuttleGui & S) S.EndRadioButtonGroup(); } S.EndHorizontalLay(); - + CHOICES *choices; int cnt; bool enable; int defrate; - + if (mSET->GetValue()) { choices = setRates; cnt = WXSIZEOF(setRates); @@ -380,20 +388,20 @@ void ExportMP3Options::PopulateOrExchange(ShuttleGui & S) enable = false; defrate = mCbrRate; } - + mRate = S.Id(ID_QUALITY).TieChoice(_("Quality"), wxT("/FileFormats/MP3Bitrate"), defrate, GetNames(choices, cnt), GetLabels(choices, cnt)); - + mMode = S.TieChoice(_("Variable Speed:"), wxT("/FileFormats/MP3VarMode"), ROUTINE_FAST, GetNames(varModes, WXSIZEOF(varModes)), GetLabels(varModes, WXSIZEOF(varModes))); mMode->Enable(enable); - + S.AddPrompt(_("Channel Mode:")); S.StartTwoColumn(); { @@ -410,36 +418,9 @@ void ExportMP3Options::PopulateOrExchange(ShuttleGui & S) } S.EndMultiColumn(); } - S.EndStatic(); + S.EndHorizontalLay(); } - S.EndHorizontalLay(); - - S.AddStandardButtons(); - - Layout(); - Fit(); - SetMinSize(GetSize()); - Center(); - - return; -} - -/// -/// -void ExportMP3Options::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - ShuttleGui S(this, eIsSavingToPrefs); - PopulateOrExchange(S); - - gPrefs->Write(wxT("/FileFormats/MP3SetRate"), mSetRate); - gPrefs->Write(wxT("/FileFormats/MP3VbrRate"), mVbrRate); - gPrefs->Write(wxT("/FileFormats/MP3AbrRate"), mAbrRate); - gPrefs->Write(wxT("/FileFormats/MP3CbrRate"), mCbrRate); - gPrefs->Flush(); - - EndModal(wxID_OK); - - return; + S.EndVerticalLay(); } /// @@ -1558,7 +1539,7 @@ public: // Required - bool DisplayOptions(wxWindow *parent, int format = 0); + wxWindow *OptionsCreate(wxWindow *parent, int format); int Export(AudacityProject *project, int channels, wxString fName, @@ -1847,13 +1828,9 @@ int ExportMP3::Export(AudacityProject *project, return updateResult; } -bool ExportMP3::DisplayOptions(wxWindow *parent, int WXUNUSED(format)) +wxWindow *ExportMP3::OptionsCreate(wxWindow *parent, int format) { - ExportMP3Options od(parent); - - od.ShowModal(); - - return true; + return new ExportMP3Options(parent, format); } int ExportMP3::FindValue(CHOICES *choices, int cnt, int needle, int def) diff --git a/src/export/ExportOGG.cpp b/src/export/ExportOGG.cpp index 091ac85ca..ddbb0db75 100644 --- a/src/export/ExportOGG.cpp +++ b/src/export/ExportOGG.cpp @@ -24,7 +24,8 @@ #include #include - +#include + #include #include "../FileIO.h" @@ -39,81 +40,58 @@ // ExportOGGOptions //---------------------------------------------------------------------------- -class ExportOGGOptions : public wxDialog +class ExportOGGOptions : public wxPanel { public: ExportOGGOptions(wxWindow *parent, int format); + virtual ~ExportOGGOptions(); void PopulateOrExchange(ShuttleGui & S); - void OnOK(wxCommandEvent& event); private: int mOggQualityUnscaled; - - DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(ExportOGGOptions, wxDialog) - EVT_BUTTON(wxID_OK, ExportOGGOptions::OnOK) -END_EVENT_TABLE() - /// /// ExportOGGOptions::ExportOGGOptions(wxWindow *parent, int WXUNUSED(format)) -: wxDialog(parent, wxID_ANY, - wxString(_("Specify Ogg Vorbis Options"))) +: wxPanel(parent, wxID_ANY) { - SetName(GetTitle()); - ShuttleGui S(this, eIsCreatingFromPrefs); - mOggQualityUnscaled = gPrefs->Read(wxT("/FileFormats/OggExportQuality"),50)/10; + ShuttleGui S(this, eIsCreatingFromPrefs); PopulateOrExchange(S); } -/// -/// -void ExportOGGOptions::PopulateOrExchange(ShuttleGui & S) -{ - S.StartHorizontalLay(wxEXPAND, 0); - { - S.StartStatic(_("Ogg Vorbis Export Setup"), 1); - { - S.StartMultiColumn(2, wxEXPAND); - { - S.SetStretchyCol(1); - S.TieSlider(_("Quality:"), mOggQualityUnscaled, 10); - } - S.EndMultiColumn(); - } - S.EndStatic(); - } - S.EndHorizontalLay(); - - S.AddStandardButtons(); - - Layout(); - Fit(); - SetMinSize(GetSize()); - Center(); - - return; -} - -/// -/// -void ExportOGGOptions::OnOK(wxCommandEvent& WXUNUSED(event)) +ExportOGGOptions::~ExportOGGOptions() { ShuttleGui S(this, eIsSavingToPrefs); PopulateOrExchange(S); gPrefs->Write(wxT("/FileFormats/OggExportQuality"),mOggQualityUnscaled * 10); gPrefs->Flush(); +} - EndModal(wxID_OK); - - return; +/// +/// +void ExportOGGOptions::PopulateOrExchange(ShuttleGui & S) +{ + S.StartVerticalLay(); + { + S.StartHorizontalLay(wxEXPAND); + { + S.SetSizerProportion(1); + S.StartMultiColumn(2, wxCENTER); + { + S.SetStretchyCol(1); + S.Prop(1).TieSlider(_("Quality:"), mOggQualityUnscaled, 10); + } + S.EndMultiColumn(); + } + S.EndHorizontalLay(); + } + S.EndVerticalLay(); } //---------------------------------------------------------------------------- @@ -130,8 +108,8 @@ public: void Destroy(); // Required + virtual wxWindow *OptionsCreate(wxWindow *parent, int format); - bool DisplayOptions(wxWindow *parent, int format = 0); int Export(AudacityProject *project, int channels, wxString fName, @@ -334,13 +312,9 @@ int ExportOGG::Export(AudacityProject *project, return updateResult; } -bool ExportOGG::DisplayOptions(wxWindow *parent, int format) +wxWindow *ExportOGG::OptionsCreate(wxWindow *parent, int format) { - ExportOGGOptions od(parent, format); - - od.ShowModal(); - - return true; + return new ExportOGGOptions(parent, format); } bool ExportOGG::FillComment(AudacityProject *project, vorbis_comment *comment, Tags *metadata) diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index 4789b679f..f2dbc6fac 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -53,8 +53,8 @@ struct { int format; - wxChar *name; - wxChar *desc; + const wxChar *name; + const wxChar *desc; } static const kFormats[] = { @@ -92,14 +92,13 @@ static void WriteExportFormatPref(int format) #define ID_HEADER_CHOICE 7102 #define ID_ENCODING_CHOICE 7103 -class ExportPCMOptions : public wxDialog +class ExportPCMOptions : public wxPanel { public: ExportPCMOptions(wxWindow *parent, int format); void PopulateOrExchange(ShuttleGui & S); void OnHeaderChoice(wxCommandEvent & evt); - void OnOK(wxCommandEvent& event); private: @@ -112,7 +111,6 @@ private: wxArrayString mEncodingNames; wxChoice *mHeaderChoice; wxChoice *mEncodingChoice; - wxButton *mOk; int mHeaderFromChoice; int mEncodingFromChoice; wxArrayInt mEncodingFormats; @@ -120,20 +118,14 @@ private: DECLARE_EVENT_TABLE() }; -BEGIN_EVENT_TABLE(ExportPCMOptions, wxDialog) - EVT_CHOICE(ID_HEADER_CHOICE, ExportPCMOptions::OnHeaderChoice) - EVT_BUTTON(wxID_OK, ExportPCMOptions::OnOK) +BEGIN_EVENT_TABLE(ExportPCMOptions, wxPanel) + EVT_CHOICE(ID_HEADER_CHOICE, ExportPCMOptions::OnHeaderChoice) END_EVENT_TABLE() -ExportPCMOptions::ExportPCMOptions(wxWindow * WXUNUSED(parent), int selformat) -: wxDialog(NULL, wxID_ANY, - wxString(_("Specify Uncompressed Options"))) +ExportPCMOptions::ExportPCMOptions(wxWindow *parent, int selformat) +: wxPanel(parent, wxID_ANY) { - SetName(GetTitle()); - - mOk = NULL; - - int format = 0; + int format; if (selformat < 0 || selformat >= WXSIZEOF(kFormats)) { @@ -144,23 +136,15 @@ ExportPCMOptions::ExportPCMOptions(wxWindow * WXUNUSED(parent), int selformat) format = kFormats[selformat].format; } - int i; - int num; - int sel; - - num = sf_num_headers(); - sel = 0; - for (i = 0; i < num; i++) { + mHeaderFromChoice = 0; + for (int i = 0, num = sf_num_headers(); i < num; i++) { mHeaderNames.Add(sf_header_index_name(i)); if ((format & SF_FORMAT_TYPEMASK) == (int)sf_header_index_to_type(i)) - sel = i; + mHeaderFromChoice = i; } - mHeaderFromChoice = sel; - mEncodingFormats.Clear(); - num = sf_num_encodings(); - mEncodingFromChoice = sel = 0; - for (i = 0; i < num; i++) { + mEncodingFromChoice = 0; + for (int i = 0, sel = 0, num = sf_num_encodings(); i < num; i++) { int enc = sf_encoding_index_to_subtype(i); int fmt = (format & SF_FORMAT_TYPEMASK) | enc; bool valid = ValidatePair(fmt); @@ -177,21 +161,16 @@ ExportPCMOptions::ExportPCMOptions(wxWindow * WXUNUSED(parent), int selformat) } ShuttleGui S(this, eIsCreatingFromPrefs); - PopulateOrExchange(S); - - Layout(); - Fit(); - Center(); } void ExportPCMOptions::PopulateOrExchange(ShuttleGui & S) { - S.StartHorizontalLay(wxEXPAND, true); + S.StartVerticalLay(); { - S.StartStatic(_("Uncompressed Export Setup"), true); + S.StartHorizontalLay(wxCENTER); { - S.StartMultiColumn(2, wxEXPAND); + S.StartMultiColumn(2, wxCENTER); { S.SetStretchyCol(1); mHeaderChoice = S.Id(ID_HEADER_CHOICE) @@ -204,14 +183,10 @@ void ExportPCMOptions::PopulateOrExchange(ShuttleGui & S) &mEncodingNames); } S.EndMultiColumn(); - S.AddFixedText(_("(Not all combinations of headers and encodings are possible.)")); } - S.EndStatic(); + S.EndHorizontalLay(); } - S.EndHorizontalLay(); - - S.AddStandardButtons(); - mOk = (wxButton *)wxWindow::FindWindowById(wxID_OK, this); + S.EndVerticalLay(); return; } @@ -263,15 +238,6 @@ void ExportPCMOptions::OnHeaderChoice(wxCommandEvent & WXUNUSED(evt)) ValidatePair(GetFormat()); } -void ExportPCMOptions::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - WriteExportFormatPref(GetFormat()); - - EndModal(wxID_OK); - - return; -} - int ExportPCMOptions::GetFormat() { int hdr = sf_header_index_to_type(mHeaderChoice->GetSelection()); @@ -295,10 +261,7 @@ bool ExportPCMOptions::ValidatePair(int format) info.sections = 1; info.seekable = 0; - int valid = sf_format_check(&info); - if (mOk) - mOk->Enable(valid != 0 ? true : false); - return valid != 0 ? true : false; + return sf_format_check(&info) != 0 ? true : false; } //---------------------------------------------------------------------------- @@ -314,7 +277,7 @@ public: // Required - bool DisplayOptions(wxWindow *parent, int format = 0); + wxWindow *OptionsCreate(wxWindow *parent, int format); int Export(AudacityProject *project, int channels, wxString fName, @@ -884,29 +847,15 @@ void ExportPCM::AddID3Chunk(wxString fName, Tags *tags, int sf_format) return; } -/** @param format The same information as the subformat argument to the Export - * method. Controls use of pre-defined export settings.*/ -bool ExportPCM::DisplayOptions(wxWindow *parent, int format) +wxWindow *ExportPCM::OptionsCreate(wxWindow *parent, int format) { // default, full user control if (format < 0 || format >= WXSIZEOF(kFormats)) { - ExportPCMOptions od(parent,format); - od.ShowModal(); - return true; + return new ExportPCMOptions(parent, format); } - wxString nopt, fmt, usepcm; - - nopt.Printf(_("There are no options for this format.\n")); - fmt.Printf(_("Your file will be exported as a \"%s\" file\n"), - wxGetTranslation(kFormats[format].desc)); - usepcm.Printf(_("If you need more control over the export format please use the \"%s\" format."), - _("Other uncompressed files")); - - wxMessageBox(nopt + fmt + usepcm); - - return true; + return ExportPlugin::OptionsCreate(parent, format); } wxString ExportPCM::GetExtension(int index)