1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-18 16:41:14 +02:00

Round 5 of wx3 changes

FileDialog now complete on Linux.  Needs some fine tuning on
Windows and OSX.
Builds with wx3 and gtk2 or gtk3.
Still more effect work to do.
This commit is contained in:
Leland Lucius
2015-07-14 23:33:53 -05:00
parent 2f760c4bac
commit 9b9c8cc073
43 changed files with 3271 additions and 5352 deletions

View File

@@ -16,28 +16,10 @@ custom controls.
#include "FileDialog.h"
/////////////////////////////////////////////////////////////////////////////
// Name: common/fldlgcmn.cpp
// Purpose: wxFileDialog common functions
// Author: John Labenski
// Modified by: Leland Lucius
// Created: 14.06.03 (extracted from src/*/filedlg.cpp)
// RCS-ID: $Id: FileDialog.cpp,v 1.8 2008-10-05 14:48:59 richardash1981 Exp $
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
//
// Modified for Audacity to support an additional button on Save dialogs
//
/////////////////////////////////////////////////////////////////////////////
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;
m_userdata = 0;
}
bool FileDialogBase::HasUserPaneCreator() const
@@ -63,62 +45,107 @@ void FileDialogBase::CreateUserPane(wxWindow *parent)
// FileDialog convenience functions
//----------------------------------------------------------------------------
wxString FileSelector(const wxString & title,
const wxString & defaultDir,
const wxString & defaultFileName,
const wxString & defaultExtension,
const wxString & filter,
/////////////////////////////////////////////////////////////////////////////
// Name: src/common/fldlgcmn.cpp
// Purpose: wxFileDialog common functions
// Author: John Labenski
// Modified by: Leland Lucius for use with Audacity
// Created: 14.06.03 (extracted from src/*/filedlg.cpp)
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
wxString FileSelector(const wxString& title,
const wxString& defaultDir,
const wxString& defaultFileName,
const wxString& defaultExtension,
const wxString& filter,
int flags,
wxWindow *parent)
wxWindow *parent,
int x, int y)
{
// The defaultExtension, if non-empty, is
// appended to the filename if the user fails to type an extension. The new
// implementation (taken from wxFileSelectorEx) appends the extension
// automatically, by looking at the filter specification. In fact this
// should be better than the native Microsoft implementation because
// Windows only allows *one* default extension, whereas here we do the
// right thing depending on the filter the user has chosen.
// The defaultExtension, if non-empty, is
// appended to the filename if the user fails to type an extension. The new
// implementation (taken from FileSelectorEx) appends the extension
// automatically, by looking at the filter specification. In fact this
// should be better than the native Microsoft implementation because
// Windows only allows *one* default extension, whereas here we do the
// right thing depending on the filter the user has chosen.
// If there's a default extension specified but no filter, we create a
// suitable filter.
// If there's a default extension specified but no filter, we create a
// suitable filter.
wxString filter2;
if (!defaultExtension.empty() && filter.empty())
filter2 = wxString(wxT("*.")) + defaultExtension;
else if (!filter.empty())
filter2 = filter;
wxString filter2;
if ( !defaultExtension.empty() && filter.empty() )
filter2 = wxString(wxT("*.")) + defaultExtension;
else if ( !filter.empty() )
filter2 = filter;
FileDialog fileDialog(parent, title, defaultDir,
defaultFileName, filter2,
flags);
FileDialog fileDialog(parent, title, defaultDir,
defaultFileName, filter2,
flags, wxPoint(x, y));
// if filter is of form "All files (*)|*|..." set correct filter index
if (!defaultExtension.empty() && filter2.find(wxT('|')) != wxString::npos)
{
int filterIndex = 0;
wxArrayString descriptions, filters;
// don't care about errors, handled already by FileDialog
(void)wxParseCommonDialogsFilter(filter2, descriptions, filters);
for (size_t n=0; n<filters.GetCount(); n++)
{
if (filters[n].Contains(defaultExtension))
{
filterIndex = (int)n; // Convert to int to avoid compiler warning, because we probably do not need many tens of thousands of filters.
break;
}
}
if (filterIndex > 0)
fileDialog.SetFilterIndex(filterIndex);
}
wxString filename;
if (fileDialog.ShowModal() == wxID_OK)
{
filename = fileDialog.GetPath();
}
return filename;
// if filter is of form "All files (*)|*|..." set correct filter index
if ( !defaultExtension.empty() && filter2.find(wxT('|')) != wxString::npos )
{
int filterIndex = 0;
wxArrayString descriptions, filters;
// don't care about errors, handled already by FileDialog
(void)wxParseCommonDialogsFilter(filter2, descriptions, filters);
for (size_t n=0; n<filters.GetCount(); n++)
{
if (filters[n].Contains(defaultExtension))
{
filterIndex = n;
break;
}
}
if (filterIndex > 0)
fileDialog.SetFilterIndex(filterIndex);
}
wxString filename;
if ( fileDialog.ShowModal() == wxID_OK )
{
filename = fileDialog.GetPath();
}
return filename;
}
//----------------------------------------------------------------------------
// FileSelectorEx
//----------------------------------------------------------------------------
wxString FileSelectorEx(const wxString& title,
const wxString& defaultDir,
const wxString& defaultFileName,
int* defaultFilterIndex,
const wxString& filter,
int flags,
wxWindow* parent,
int x,
int y)
{
FileDialog fileDialog(parent,
title,
defaultDir,
defaultFileName,
filter,
flags, wxPoint(x, y));
wxString filename;
if ( fileDialog.ShowModal() == wxID_OK )
{
if ( defaultFilterIndex )
*defaultFilterIndex = fileDialog.GetFilterIndex();
filename = fileDialog.GetPath();
}
return filename;
}