1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 16:48:44 +02:00

Rewrite uses of wxEventHandler::(Dis)Connect with (Un)Bind

This commit is contained in:
Paul Licameli 2018-02-12 21:16:11 -05:00
commit 89d8f0df63
45 changed files with 214 additions and 554 deletions

@ -240,7 +240,7 @@ It handles initialization and termination by subclassing wxApp.
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
DEFINE_EVENT_TYPE(EVT_OPEN_AUDIO_FILE); DEFINE_EVENT_TYPE(EVT_OPEN_AUDIO_FILE);
DEFINE_EVENT_TYPE(EVT_LANGUAGE_CHANGE); wxDEFINE_EVENT(EVT_LANGUAGE_CHANGE, wxCommandEvent);
#if 0 #if 0
#ifdef __WXGTK__ #ifdef __WXGTK__

@ -57,11 +57,6 @@ AudacityLogger::AudacityLogger()
mUpdated = false; mUpdated = false;
} }
AudacityLogger::~AudacityLogger()
{
Destroy();
}
void AudacityLogger::Flush() void AudacityLogger::Flush()
{ {
if (mUpdated && mFrame && mFrame->IsShown()) { if (mUpdated && mFrame && mFrame->IsShown()) {
@ -95,50 +90,6 @@ void AudacityLogger::DoLogText(const wxString & str)
} }
} }
void AudacityLogger::Destroy()
{
if (mFrame) {
mFrame->Disconnect(LoggerID_Save,
wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(AudacityLogger::OnSave),
NULL,
this);
mFrame->Disconnect(LoggerID_Clear,
wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(AudacityLogger::OnClear),
NULL,
this);
mFrame->Disconnect(LoggerID_Close,
wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(AudacityLogger::OnClose),
NULL,
this);
mFrame->Disconnect(LoggerID_Save,
wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(AudacityLogger::OnSave),
NULL,
this);
mFrame->Disconnect(LoggerID_Clear,
wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(AudacityLogger::OnClear),
NULL,
this);
mFrame->Disconnect(LoggerID_Close,
wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(AudacityLogger::OnClose),
NULL,
this);
mFrame->Disconnect(wxEVT_CLOSE_WINDOW,
wxCloseEventHandler(AudacityLogger::OnCloseWindow),
NULL,
this);
mFrame.reset();
}
}
void AudacityLogger::Show(bool show) void AudacityLogger::Show(bool show)
{ {
// Hide the frame if created, otherwise do nothing // Hide the frame if created, otherwise do nothing
@ -215,42 +166,28 @@ void AudacityLogger::Show(bool show)
frame->Layout(); frame->Layout();
// Hook into the frame events // Hook into the frame events
frame->Connect(wxEVT_CLOSE_WINDOW, frame->Bind(wxEVT_CLOSE_WINDOW,
wxCloseEventHandler(AudacityLogger::OnCloseWindow), wxCloseEventHandler(AudacityLogger::OnCloseWindow),
NULL,
this); this);
frame->Connect(LoggerID_Save, frame->Bind( wxEVT_COMMAND_MENU_SELECTED,
wxEVT_COMMAND_MENU_SELECTED, &AudacityLogger::OnSave,
wxCommandEventHandler(AudacityLogger::OnSave), this, LoggerID_Save);
NULL, frame->Bind( wxEVT_COMMAND_MENU_SELECTED,
this); &AudacityLogger::OnClear,
frame->Connect(LoggerID_Clear, this, LoggerID_Clear);
wxEVT_COMMAND_MENU_SELECTED, frame->Bind( wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(AudacityLogger::OnClear), &AudacityLogger::OnClose,
NULL, this, LoggerID_Close);
this); frame->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
frame->Connect(LoggerID_Close, &AudacityLogger::OnSave,
wxEVT_COMMAND_MENU_SELECTED, this, LoggerID_Save);
wxCommandEventHandler(AudacityLogger::OnClose), frame->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
NULL, &AudacityLogger::OnClear,
this); this, LoggerID_Clear);
frame->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
frame->Connect(LoggerID_Save, &AudacityLogger::OnClose,
wxEVT_COMMAND_BUTTON_CLICKED, this, LoggerID_Close);
wxCommandEventHandler(AudacityLogger::OnSave),
NULL,
this);
frame->Connect(LoggerID_Clear,
wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(AudacityLogger::OnClear),
NULL,
this);
frame->Connect(LoggerID_Close,
wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(AudacityLogger::OnClose),
NULL,
this);
mFrame = std::move( frame ); mFrame = std::move( frame );
@ -272,7 +209,7 @@ void AudacityLogger::OnCloseWindow(wxCloseEvent & WXUNUSED(e))
// On the Mac, destroy the window rather than hiding it since the // On the Mac, destroy the window rather than hiding it since the
// log menu will override the root windows menu if there is no // log menu will override the root windows menu if there is no
// project window open. // project window open.
Destroy(); mFrame.reset();
#else #else
Show(false); Show(false);
#endif #endif

@ -28,10 +28,8 @@
class AudacityLogger final : public wxEvtHandler, public wxLog { class AudacityLogger final : public wxEvtHandler, public wxLog {
public: public:
AudacityLogger(); AudacityLogger();
virtual ~AudacityLogger();
void Show(bool show = true); void Show(bool show = true);
void Destroy();
#if defined(EXPERIMENTAL_CRASH_REPORT) #if defined(EXPERIMENTAL_CRASH_REPORT)
wxString GetLog(); wxString GetLog();

@ -480,9 +480,9 @@ using std::min;
std::unique_ptr<AudioIO> ugAudioIO; std::unique_ptr<AudioIO> ugAudioIO;
AudioIO *gAudioIO{}; AudioIO *gAudioIO{};
DEFINE_EVENT_TYPE(EVT_AUDIOIO_PLAYBACK); wxDEFINE_EVENT(EVT_AUDIOIO_PLAYBACK, wxCommandEvent);
DEFINE_EVENT_TYPE(EVT_AUDIOIO_CAPTURE); wxDEFINE_EVENT(EVT_AUDIOIO_CAPTURE, wxCommandEvent);
DEFINE_EVENT_TYPE(EVT_AUDIOIO_MONITOR); wxDEFINE_EVENT(EVT_AUDIOIO_MONITOR, wxCommandEvent);
// static // static
int AudioIO::mNextStreamToken = 0; int AudioIO::mNextStreamToken = 0;

@ -91,9 +91,12 @@ class AudioIOListener;
#define AILA_DEF_NUMBER_ANALYSIS 5 #define AILA_DEF_NUMBER_ANALYSIS 5
#endif #endif
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_AUDIOIO_PLAYBACK, -1); wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_AUDIOIO_CAPTURE, -1); EVT_AUDIOIO_PLAYBACK, wxCommandEvent);
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_AUDIOIO_MONITOR, -1); wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
EVT_AUDIOIO_CAPTURE, wxCommandEvent);
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
EVT_AUDIOIO_MONITOR, wxCommandEvent);
// PRL: // PRL:
// If we always run a portaudio output stream (even just to produce silence) // If we always run a portaudio output stream (even just to produce silence)

@ -95,11 +95,15 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
{ {
// FIXME: Textbox labels have inconsistent capitalization // FIXME: Textbox labels have inconsistent capitalization
mTotal = S.Id(ID_TOTAL).AddTextBox(_("&Total space used"), wxT("0"), 10); mTotal = S.Id(ID_TOTAL).AddTextBox(_("&Total space used"), wxT("0"), 10);
mTotal->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar)); mTotal->Bind(wxEVT_KEY_DOWN,
// ignore it
[](wxEvent&){});
S.AddVariableText( {} )->Hide(); S.AddVariableText( {} )->Hide();
mAvail = S.Id(ID_AVAIL).AddTextBox(_("&Undo Levels Available"), wxT("0"), 10); mAvail = S.Id(ID_AVAIL).AddTextBox(_("&Undo Levels Available"), wxT("0"), 10);
mAvail->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar)); mAvail->Bind(wxEVT_KEY_DOWN,
// ignore it
[](wxEvent&){});
S.AddVariableText( {} )->Hide(); S.AddVariableText( {} )->Hide();
S.AddPrompt(_("&Levels To Discard")); S.AddPrompt(_("&Levels To Discard"));
@ -117,7 +121,9 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
mDiscard = S.Id(ID_DISCARD).AddButton(_("&Discard")); mDiscard = S.Id(ID_DISCARD).AddButton(_("&Discard"));
mClipboard = S.AddTextBox(_("Clipboard space used"), wxT("0"), 10); mClipboard = S.AddTextBox(_("Clipboard space used"), wxT("0"), 10);
mClipboard->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar)); mClipboard->Bind(wxEVT_KEY_DOWN,
// ignore it
[](wxEvent&){});
S.Id(ID_DISCARD_CLIPBOARD).AddButton(_("Discard")); S.Id(ID_DISCARD_CLIPBOARD).AddButton(_("Discard"));
} }
S.EndMultiColumn(); S.EndMultiColumn();
@ -141,32 +147,15 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
mList->SetColumnWidth(0, mList->GetClientSize().x - mList->GetColumnWidth(1)); mList->SetColumnWidth(0, mList->GetClientSize().x - mList->GetColumnWidth(1));
mList->SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); mList->SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK, wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK,
wxCommandEventHandler(HistoryWindow::OnAudioIO), &HistoryWindow::OnAudioIO,
NULL,
this); this);
wxTheApp->Connect(EVT_AUDIOIO_CAPTURE, wxTheApp->Bind(EVT_AUDIOIO_CAPTURE,
wxCommandEventHandler(HistoryWindow::OnAudioIO), &HistoryWindow::OnAudioIO,
NULL,
this); this);
} }
HistoryWindow::~HistoryWindow()
{
wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK,
wxCommandEventHandler(HistoryWindow::OnAudioIO),
NULL,
this);
wxTheApp->Disconnect(EVT_AUDIOIO_CAPTURE,
wxCommandEventHandler(HistoryWindow::OnAudioIO),
NULL,
this);
mAvail->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar));
}
void HistoryWindow::OnAudioIO(wxCommandEvent& evt) void HistoryWindow::OnAudioIO(wxCommandEvent& evt)
{ {
evt.Skip(); evt.Skip();
@ -309,9 +298,3 @@ void HistoryWindow::OnSize(wxSizeEvent & WXUNUSED(event))
if (mList->GetItemCount() > 0) if (mList->GetItemCount() > 0)
mList->EnsureVisible(mSelected); mList->EnsureVisible(mSelected);
} }
void HistoryWindow::OnChar(wxKeyEvent &event)
{
event.Skip(false);
return;
}

@ -28,7 +28,6 @@ class HistoryWindow final : public wxDialogWrapper {
public: public:
HistoryWindow(AudacityProject * parent, UndoManager *manager); HistoryWindow(AudacityProject * parent, UndoManager *manager);
~HistoryWindow();
void UpdateDisplay(); void UpdateDisplay();
@ -39,7 +38,6 @@ class HistoryWindow final : public wxDialogWrapper {
void OnSize(wxSizeEvent & event); void OnSize(wxSizeEvent & event);
void OnCloseWindow(wxCloseEvent & WXUNUSED(event)); void OnCloseWindow(wxCloseEvent & WXUNUSED(event));
void OnChar(wxKeyEvent & event);
void OnItemSelected(wxListEvent & event); void OnItemSelected(wxListEvent & event);
void OnDiscard(wxCommandEvent & event); void OnDiscard(wxCommandEvent & event);
void OnDiscardClipboard(wxCommandEvent & event); void OnDiscardClipboard(wxCommandEvent & event);

@ -126,21 +126,12 @@ LyricsWindow::LyricsWindow(AudacityProject *parent):
//} //}
// Events from the project don't propagate directly to this other frame, so... // Events from the project don't propagate directly to this other frame, so...
mProject->Connect(EVT_TRACK_PANEL_TIMER, mProject->Bind(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(LyricsWindow::OnTimer), &LyricsWindow::OnTimer,
NULL,
this); this);
Center(); Center();
} }
LyricsWindow::~LyricsWindow()
{
mProject->Disconnect(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(LyricsWindow::OnTimer),
NULL,
this);
}
void LyricsWindow::OnCloseWindow(wxCloseEvent & WXUNUSED(event)) void LyricsWindow::OnCloseWindow(wxCloseEvent & WXUNUSED(event))
{ {
this->Hide(); this->Hide();

@ -23,7 +23,6 @@ class LyricsWindow final : public wxFrame {
public: public:
LyricsWindow(AudacityProject* parent); LyricsWindow(AudacityProject* parent);
virtual ~LyricsWindow();
LyricsPanel *GetLyricsPanel() { return mLyricsPanel; }; LyricsPanel *GetLyricsPanel() { return mLyricsPanel; };

@ -928,20 +928,8 @@ MixerBoard::MixerBoard(AudacityProject* pProject,
mTracks = mProject->GetTracks(); mTracks = mProject->GetTracks();
// Events from the project don't propagate directly to this other frame, so... // Events from the project don't propagate directly to this other frame, so...
mProject->Connect(EVT_TRACK_PANEL_TIMER, mProject->Bind(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(MixerBoard::OnTimer), &MixerBoard::OnTimer,
NULL,
this);
}
MixerBoard::~MixerBoard()
{
// private data members
mMusicalInstruments.clear();
mProject->Disconnect(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(MixerBoard::OnTimer),
NULL,
this); this);
} }

@ -206,7 +206,6 @@ public:
wxFrame* parent, wxFrame* parent,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize); const wxSize& size = wxDefaultSize);
virtual ~MixerBoard();
void UpdatePrefs(); void UpdatePrefs();

@ -423,7 +423,6 @@ class PluginRegistrationDialog final : public wxDialogWrapper
public: public:
// constructors and destructors // constructors and destructors
PluginRegistrationDialog(wxWindow *parent, EffectType type); PluginRegistrationDialog(wxWindow *parent, EffectType type);
virtual ~PluginRegistrationDialog();
private: private:
void Populate(); void Populate();
@ -501,14 +500,6 @@ PluginRegistrationDialog::PluginRegistrationDialog(wxWindow *parent, EffectType
Populate(); Populate();
} }
PluginRegistrationDialog::~PluginRegistrationDialog()
{
mEffects->Disconnect(wxEVT_KEY_DOWN,
wxKeyEventHandler(PluginRegistrationDialog::OnListChar),
NULL,
this);
}
void PluginRegistrationDialog::Populate() void PluginRegistrationDialog::Populate()
{ {
//------------------------- Main section -------------------- //------------------------- Main section --------------------
@ -565,9 +556,8 @@ void PluginRegistrationDialog::PopulateOrExchange(ShuttleGui &S)
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES ); S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES );
mEffects = S.Id(ID_List).AddListControlReportMode(); mEffects = S.Id(ID_List).AddListControlReportMode();
mEffects->Connect(wxEVT_KEY_DOWN, mEffects->Bind(wxEVT_KEY_DOWN,
wxKeyEventHandler(PluginRegistrationDialog::OnListChar), &PluginRegistrationDialog::OnListChar,
NULL,
this); this);
#if wxUSE_ACCESSIBILITY #if wxUSE_ACCESSIBILITY
mEffects->SetAccessible(mAx = safenew CheckListAx(mEffects)); mEffects->SetAccessible(mAx = safenew CheckListAx(mEffects));

@ -1098,9 +1098,8 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
// because it must // because it must
// attach its timer event handler later (so that its handler is invoked // attach its timer event handler later (so that its handler is invoked
// earlier) // earlier)
this->Connect(EVT_TRACK_PANEL_TIMER, this->Bind(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(ViewInfo::OnTimer), &ViewInfo::OnTimer,
NULL,
&mViewInfo); &mViewInfo);
// Add the overlays, in the sequence in which they will be painted // Add the overlays, in the sequence in which they will be painted
@ -1227,9 +1226,8 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
mTrackPanel->SetDropTarget(safenew DropTarget(this)); mTrackPanel->SetDropTarget(safenew DropTarget(this));
#endif #endif
wxTheApp->Connect(EVT_AUDIOIO_CAPTURE, wxTheApp->Bind(EVT_AUDIOIO_CAPTURE,
wxCommandEventHandler(AudacityProject::OnCapture), &AudacityProject::OnCapture,
NULL,
this); this);
//Initialize the last selection adjustment time. //Initialize the last selection adjustment time.
@ -1258,11 +1256,6 @@ AudacityProject::~AudacityProject()
mTrackPanel->RemoveOverlay(mCursorOverlay.get()); mTrackPanel->RemoveOverlay(mCursorOverlay.get());
mTrackPanel->RemoveOverlay(mIndicatorOverlay.get()); mTrackPanel->RemoveOverlay(mIndicatorOverlay.get());
} }
wxTheApp->Disconnect(EVT_AUDIOIO_CAPTURE,
wxCommandEventHandler(AudacityProject::OnCapture),
NULL,
this);
} }
void AudacityProject::ApplyUpdatedTheme() void AudacityProject::ApplyUpdatedTheme()
@ -2715,11 +2708,6 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event)
#endif #endif
} }
this->Disconnect(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(ViewInfo::OnTimer),
NULL,
&mViewInfo);
// Destroys this // Destroys this
pSelf.reset(); pSelf.reset();
mRuler = nullptr; mRuler = nullptr;
@ -6032,20 +6020,11 @@ double AudacityProject::GetZoomOfPref( const wxString & PresetPrefName, int defa
AudacityProject::PlaybackScroller::PlaybackScroller(AudacityProject *project) AudacityProject::PlaybackScroller::PlaybackScroller(AudacityProject *project)
: mProject(project) : mProject(project)
{ {
mProject->Connect(EVT_TRACK_PANEL_TIMER, mProject->Bind(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(PlaybackScroller::OnTimer), &PlaybackScroller::OnTimer,
NULL,
this); this);
} }
AudacityProject::PlaybackScroller::~PlaybackScroller()
{
mProject->Disconnect(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(PlaybackScroller::OnTimer),
NULL,
this);
}
void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event) void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event)
{ {
// Let other listeners get the notification // Let other listeners get the notification

@ -793,7 +793,6 @@ public:
{ {
public: public:
explicit PlaybackScroller(AudacityProject *project); explicit PlaybackScroller(AudacityProject *project);
~PlaybackScroller();
enum class Mode { enum class Mode {
Off, Off,

@ -770,11 +770,11 @@ Track *SyncLockedTracksIterator::Last(bool skiplinked)
// //
// The TrackList sends events whenever certain updates occur to the list it // The TrackList sends events whenever certain updates occur to the list it
// is managing. Any other classes that may be interested in get these updates // is managing. Any other classes that may be interested in get these updates
// should use TrackList::Connect() and TrackList::Disconnect(). // should use TrackList::Connect() or TrackList::Bind().
// //
DEFINE_EVENT_TYPE(EVT_TRACKLIST_PERMUTED); wxDEFINE_EVENT(EVT_TRACKLIST_PERMUTED, wxCommandEvent);
DEFINE_EVENT_TYPE(EVT_TRACKLIST_RESIZING); wxDEFINE_EVENT(EVT_TRACKLIST_RESIZING, wxCommandEvent);
DEFINE_EVENT_TYPE(EVT_TRACKLIST_DELETION); wxDEFINE_EVENT(EVT_TRACKLIST_DELETION, wxCommandEvent);
// same value as in the default constructed TrackId: // same value as in the default constructed TrackId:
long TrackList::sCounter = -1; long TrackList::sCounter = -1;

@ -596,15 +596,18 @@ struct TrackListEvent : public wxCommandEvent
}; };
// Posted when tracks are reordered but otherwise unchanged. // Posted when tracks are reordered but otherwise unchanged.
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TRACKLIST_PERMUTED, -1); wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
EVT_TRACKLIST_PERMUTED, wxCommandEvent);
// Posted when some track was added or changed its height. // Posted when some track was added or changed its height.
// Cast to TrackListEvent and examine mpTrack to retrieve it. // Cast to TrackListEvent and examine mpTrack to retrieve it.
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TRACKLIST_RESIZING, -1); wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
EVT_TRACKLIST_RESIZING, wxCommandEvent);
// Posted when a track has been deleted from a tracklist. // Posted when a track has been deleted from a tracklist.
// Also posted when one track replaces another // Also posted when one track replaces another
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TRACKLIST_DELETION, -1); wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
EVT_TRACKLIST_DELETION, wxCommandEvent);
class TrackList final : public wxEvtHandler, public ListOfTracks class TrackList final : public wxEvtHandler, public ListOfTracks
{ {

@ -186,7 +186,7 @@ is time to refresh some aspect of the screen.
#include "widgets/Ruler.h" #include "widgets/Ruler.h"
#include <algorithm> #include <algorithm>
DEFINE_EVENT_TYPE(EVT_TRACK_PANEL_TIMER) wxDEFINE_EVENT(EVT_TRACK_PANEL_TIMER, wxCommandEvent);
/* /*
@ -341,17 +341,14 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
GetProject()->Bind(wxEVT_IDLE, &TrackPanel::OnIdle, this); GetProject()->Bind(wxEVT_IDLE, &TrackPanel::OnIdle, this);
// Register for tracklist updates // Register for tracklist updates
mTracks->Connect(EVT_TRACKLIST_RESIZING, mTracks->Bind(EVT_TRACKLIST_RESIZING,
wxCommandEventHandler(TrackPanel::OnTrackListResizing), &TrackPanel::OnTrackListResizing,
NULL,
this); this);
mTracks->Connect(EVT_TRACKLIST_DELETION, mTracks->Bind(EVT_TRACKLIST_DELETION,
wxCommandEventHandler(TrackPanel::OnTrackListDeletion), &TrackPanel::OnTrackListDeletion,
NULL,
this); this);
wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK, wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK,
wxCommandEventHandler(TrackPanel::OnPlayback), &TrackPanel::OnPlayback,
NULL,
this); this);
} }
@ -360,20 +357,6 @@ TrackPanel::~TrackPanel()
{ {
mTimer.Stop(); mTimer.Stop();
// Unregister for tracklist updates
mTracks->Disconnect(EVT_TRACKLIST_DELETION,
wxCommandEventHandler(TrackPanel::OnTrackListDeletion),
NULL,
this);
mTracks->Disconnect(EVT_TRACKLIST_RESIZING,
wxCommandEventHandler(TrackPanel::OnTrackListResizing),
NULL,
this);
wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK,
wxCommandEventHandler(TrackPanel::OnPlayback),
NULL,
this);
// This can happen if a label is being edited and the user presses // This can happen if a label is being edited and the user presses
// ALT+F4 or Command+Q // ALT+F4 or Command+Q
if (HasCapture()) if (HasCapture())

@ -78,7 +78,8 @@ enum class UndoPush : unsigned char;
#pragma warning( disable: 4251 ) #pragma warning( disable: 4251 )
#endif #endif
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TRACK_PANEL_TIMER, -1); wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
EVT_TRACK_PANEL_TIMER, wxCommandEvent);
enum { enum {
kTimerInterval = 50, // milliseconds kTimerInterval = 50, // milliseconds

@ -16,7 +16,7 @@ Paul Licameli
class wxArrayString; class wxArrayString;
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_LANGUAGE_CHANGE, -1); wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_LANGUAGE_CHANGE, wxCommandEvent);
/* /*
This class can maintain a static table containing user visible strings that updates This class can maintain a static table containing user visible strings that updates
@ -37,18 +37,8 @@ public:
TranslatableArray() TranslatableArray()
{ {
if (wxTheApp) if (wxTheApp)
wxTheApp->Connect(EVT_LANGUAGE_CHANGE, wxTheApp->Bind(EVT_LANGUAGE_CHANGE,
wxCommandEventHandler(TranslatableArray::Invalidate), &TranslatableArray::Invalidate,
NULL,
this);
}
~TranslatableArray()
{
if (wxTheApp)
wxTheApp->Disconnect(EVT_LANGUAGE_CHANGE,
wxCommandEventHandler(TranslatableArray::Invalidate),
NULL,
this); this);
} }

@ -152,6 +152,20 @@ BEGIN_EVENT_TABLE(ContrastDialog,wxDialogWrapper)
EVT_BUTTON(wxID_CANCEL, ContrastDialog::OnClose) EVT_BUTTON(wxID_CANCEL, ContrastDialog::OnClose)
END_EVENT_TABLE() END_EVENT_TABLE()
static void OnChar(wxKeyEvent & event)
{
// Is this still required?
if (event.GetKeyCode() == WXK_TAB) {
// pass to next handler
event.Skip();
return;
}
// ignore any other key
event.Skip(false);
return;
}
/* i18n-hint: WCAG2 is the 'Web Content Accessibility Guidelines (WCAG) 2.0', see http://www.w3.org/TR/WCAG20/ */ /* i18n-hint: WCAG2 is the 'Web Content Accessibility Guidelines (WCAG) 2.0', see http://www.w3.org/TR/WCAG20/ */
ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
const wxString & title, const wxString & title,
@ -235,7 +249,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
m_pButton_UseCurrentF = S.Id(ID_BUTTON_USECURRENTF).AddButton(_("&Measure selection")); m_pButton_UseCurrentF = S.Id(ID_BUTTON_USECURRENTF).AddButton(_("&Measure selection"));
mForegroundRMSText=S.Id(ID_FOREGROUNDDB_TEXT).AddTextBox( {}, wxT(""), 17); mForegroundRMSText=S.Id(ID_FOREGROUNDDB_TEXT).AddTextBox( {}, wxT(""), 17);
mForegroundRMSText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); mForegroundRMSText->Bind(wxEVT_KEY_DOWN, OnChar);
//Background //Background
S.AddFixedText(_("&Background:")); S.AddFixedText(_("&Background:"));
@ -267,7 +281,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
m_pButton_UseCurrentB = S.Id(ID_BUTTON_USECURRENTB).AddButton(_("Mea&sure selection")); m_pButton_UseCurrentB = S.Id(ID_BUTTON_USECURRENTB).AddButton(_("Mea&sure selection"));
mBackgroundRMSText = S.Id(ID_BACKGROUNDDB_TEXT).AddTextBox( {}, wxT(""), 17); mBackgroundRMSText = S.Id(ID_BACKGROUNDDB_TEXT).AddTextBox( {}, wxT(""), 17);
mBackgroundRMSText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); mBackgroundRMSText->Bind(wxEVT_KEY_DOWN, OnChar);
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }
@ -280,11 +294,11 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
{ {
S.AddFixedText(_("Co&ntrast Result:")); S.AddFixedText(_("Co&ntrast Result:"));
mPassFailText = S.Id(ID_RESULTS_TEXT).AddTextBox( {}, wxT(""), 50); mPassFailText = S.Id(ID_RESULTS_TEXT).AddTextBox( {}, wxT(""), 50);
mPassFailText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); mPassFailText->Bind(wxEVT_KEY_DOWN, OnChar);
m_pButton_Reset = S.Id(ID_BUTTON_RESET).AddButton(_("R&eset")); m_pButton_Reset = S.Id(ID_BUTTON_RESET).AddButton(_("R&eset"));
S.AddFixedText(_("&Difference:")); S.AddFixedText(_("&Difference:"));
mDiffText = S.Id(ID_RESULTSDB_TEXT).AddTextBox( {}, wxT(""), 50); mDiffText = S.Id(ID_RESULTSDB_TEXT).AddTextBox( {}, wxT(""), 50);
mDiffText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); mDiffText->Bind(wxEVT_KEY_DOWN, OnChar);
m_pButton_Export = S.Id(ID_BUTTON_EXPORT).AddButton(_("E&xport...")); m_pButton_Export = S.Id(ID_BUTTON_EXPORT).AddButton(_("E&xport..."));
} }
S.EndMultiColumn(); S.EndMultiColumn();
@ -307,14 +321,6 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
Center(); Center();
} }
ContrastDialog::~ContrastDialog()
{
mForegroundRMSText->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar));
mBackgroundRMSText->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar));
mPassFailText->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar));
mDiffText->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar));
}
void ContrastDialog::OnGetURL(wxCommandEvent & WXUNUSED(event)) void ContrastDialog::OnGetURL(wxCommandEvent & WXUNUSED(event))
{ {
// Original help page is back on-line (March 2016), but the manual should be more reliable. // Original help page is back on-line (March 2016), but the manual should be more reliable.
@ -596,15 +602,3 @@ void ContrastDialog::OnReset(wxCommandEvent & /*event*/)
mPassFailText->ChangeValue(wxT("")); mPassFailText->ChangeValue(wxT(""));
mDiffText->ChangeValue(wxT("")); mDiffText->ChangeValue(wxT(""));
} }
void ContrastDialog::OnChar(wxKeyEvent & event)
{
// Is this still required?
if (event.GetKeyCode() == WXK_TAB) {
event.Skip();
return;
}
event.Skip(false);
return;
}

@ -32,7 +32,6 @@ public:
// constructors and destructors // constructors and destructors
ContrastDialog(wxWindow * parent, wxWindowID id, ContrastDialog(wxWindow * parent, wxWindowID id,
const wxString & title, const wxPoint & pos); const wxString & title, const wxPoint & pos);
~ContrastDialog();
wxButton * m_pButton_UseCurrentF; wxButton * m_pButton_UseCurrentF;
wxButton * m_pButton_UseCurrentB; wxButton * m_pButton_UseCurrentB;
@ -63,7 +62,6 @@ private:
void results(); void results();
void OnReset(wxCommandEvent & event); void OnReset(wxCommandEvent & event);
void OnClose(wxCommandEvent & event); void OnClose(wxCommandEvent & event);
void OnChar(wxKeyEvent &event);
wxTextCtrl *mForegroundRMSText; wxTextCtrl *mForegroundRMSText;
wxTextCtrl *mBackgroundRMSText; wxTextCtrl *mBackgroundRMSText;

@ -3827,14 +3827,12 @@ void EffectUIHost::InitializeRealtime()
{ {
EffectManager::Get().RealtimeAddEffect(mEffect); EffectManager::Get().RealtimeAddEffect(mEffect);
wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK, wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK,
wxCommandEventHandler(EffectUIHost::OnPlayback), &EffectUIHost::OnPlayback,
NULL,
this); this);
wxTheApp->Connect(EVT_AUDIOIO_CAPTURE, wxTheApp->Bind(EVT_AUDIOIO_CAPTURE,
wxCommandEventHandler(EffectUIHost::OnCapture), &EffectUIHost::OnCapture,
NULL,
this); this);
mInitialized = true; mInitialized = true;
@ -3845,16 +3843,6 @@ void EffectUIHost::CleanupRealtime()
{ {
if (mSupportsRealtime && mInitialized) if (mSupportsRealtime && mInitialized)
{ {
wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK,
wxCommandEventHandler(EffectUIHost::OnPlayback),
NULL,
this);
wxTheApp->Disconnect(EVT_AUDIOIO_CAPTURE,
wxCommandEventHandler(EffectUIHost::OnCapture),
NULL,
this);
EffectManager::Get().RealtimeRemoveEffect(mEffect); EffectManager::Get().RealtimeRemoveEffect(mEffect);
mInitialized = false; mInitialized = false;

@ -717,7 +717,9 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
mSliders[i] = safenew wxSlider(mGraphicPanel, ID_Slider + i, 0, -20, +20, mSliders[i] = safenew wxSlider(mGraphicPanel, ID_Slider + i, 0, -20, +20,
wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE); wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE);
mSliders[i]->Connect(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(EffectEqualization::OnErase)); mSliders[i]->Bind(wxEVT_ERASE_BACKGROUND,
// ignore it
[](wxEvent&){});
#if wxUSE_ACCESSIBILITY #if wxUSE_ACCESSIBILITY
wxString name; wxString name;
if( kThirdOct[i] < 1000.) if( kThirdOct[i] < 1000.)
@ -2592,11 +2594,6 @@ void EffectEqualization::OnSize(wxSizeEvent & event)
event.Skip(); event.Skip();
} }
void EffectEqualization::OnErase(wxEraseEvent & WXUNUSED(event))
{
// Ignore it
}
void EffectEqualization::OnSlider(wxCommandEvent & event) void EffectEqualization::OnSlider(wxCommandEvent & event)
{ {
wxSlider *s = (wxSlider *)event.GetEventObject(); wxSlider *s = (wxSlider *)event.GetEventObject();

@ -172,7 +172,6 @@ private:
double splint(double x[], double y[], size_t n, double y2[], double xr); double splint(double x[], double y[], size_t n, double y2[], double xr);
void OnSize( wxSizeEvent & event ); void OnSize( wxSizeEvent & event );
void OnErase( wxEraseEvent & event );
void OnSlider( wxCommandEvent & event ); void OnSlider( wxCommandEvent & event );
void OnInterp( wxCommandEvent & event ); void OnInterp( wxCommandEvent & event );
void OnSliderM( wxCommandEvent & event ); void OnSliderM( wxCommandEvent & event );

@ -171,7 +171,7 @@ void VSTControl::CreateCarbon()
{ {
OSStatus result; OSStatus result;
Connect(wxEVT_SIZE, wxSizeEventHandler(VSTControl::OnSize)); Bind(wxEVT_SIZE, &VSTControl::OnSize, this);
VstRect *rect; VstRect *rect;

@ -2755,6 +2755,24 @@ void VSTEffect::RemoveHandler()
{ {
} }
static void OnSize(wxSizeEvent & evt)
{
evt.Skip();
// Once the parent dialog reaches its final size as indicated by
// a non-default minimum size, we set the maximum size to match.
// This is a bit of a hack to prevent VSTs GUI windows from resizing
// there's no real reason to allow it. But, there should be a better
// way of handling it.
wxWindow *w = (wxWindow *) evt.GetEventObject();
wxSize sz = w->GetMinSize();
if (sz != wxDefaultSize)
{
w->SetMaxSize(sz);
}
}
void VSTEffect::BuildFancy() void VSTEffect::BuildFancy()
{ {
// Turn the power on...some effects need this when the editor is open // Turn the power on...some effects need this when the editor is open
@ -2782,7 +2800,7 @@ void VSTEffect::BuildFancy()
NeedEditIdle(true); NeedEditIdle(true);
mDialog->Connect(wxEVT_SIZE, wxSizeEventHandler(VSTEffect::OnSize)); mDialog->Bind(wxEVT_SIZE, OnSize);
#ifdef __WXMAC__ #ifdef __WXMAC__
#ifdef __WX_EVTLOOP_BUSY_WAITING__ #ifdef __WX_EVTLOOP_BUSY_WAITING__
@ -2968,24 +2986,6 @@ void VSTEffect::RefreshParameters(int skip)
} }
} }
void VSTEffect::OnSize(wxSizeEvent & evt)
{
evt.Skip();
// Once the parent dialog reaches it's final size as indicated by
// a non-default minimum size, we set the maximum size to match.
// This is a bit of a hack to prevent VSTs GUI windows from resizing
// there's no real reason to allow it. But, there should be a better
// way of handling it.
wxWindow *w = (wxWindow *) evt.GetEventObject();
wxSize sz = w->GetMinSize();
if (sz != wxDefaultSize)
{
w->SetMaxSize(sz);
}
}
void VSTEffect::OnSizeWindow(wxCommandEvent & evt) void VSTEffect::OnSizeWindow(wxCommandEvent & evt)
{ {
if (!mControl) if (!mControl)

@ -195,7 +195,6 @@ private:
// UI // UI
void OnSlider(wxCommandEvent & evt); void OnSlider(wxCommandEvent & evt);
void OnSize(wxSizeEvent & evt);
void OnSizeWindow(wxCommandEvent & evt); void OnSizeWindow(wxCommandEvent & evt);
void OnUpdateDisplay(wxCommandEvent & evt); void OnUpdateDisplay(wxCommandEvent & evt);

@ -89,37 +89,6 @@ KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent, wxWindowID winid,
} }
} }
KeyConfigPrefs::~KeyConfigPrefs()
{
if (mKey)
{
mKey->Disconnect(wxEVT_KEY_DOWN,
wxKeyEventHandler(KeyConfigPrefs::OnHotkeyKeyDown),
NULL,
this);
mKey->Disconnect(wxEVT_CHAR,
wxKeyEventHandler(KeyConfigPrefs::OnHotkeyChar),
NULL,
this);
mKey->Disconnect(wxEVT_KILL_FOCUS,
wxFocusEventHandler(KeyConfigPrefs::OnHotkeyKillFocus),
NULL,
this);
}
if (mFilter)
{
mKey->Disconnect(wxEVT_KEY_DOWN,
wxKeyEventHandler(KeyConfigPrefs::OnFilterKeyDown),
NULL,
this);
mKey->Disconnect(wxEVT_CHAR,
wxKeyEventHandler(KeyConfigPrefs::OnFilterChar),
NULL,
this);
}
}
void KeyConfigPrefs::Populate() void KeyConfigPrefs::Populate()
{ {
ShuttleGui S(this, eIsCreatingFromPrefs); ShuttleGui S(this, eIsCreatingFromPrefs);
@ -217,13 +186,11 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
#endif #endif
wxTE_PROCESS_ENTER); wxTE_PROCESS_ENTER);
mFilter->SetName(wxStripMenuCodes(mFilterLabel->GetLabel())); mFilter->SetName(wxStripMenuCodes(mFilterLabel->GetLabel()));
mFilter->Connect(wxEVT_KEY_DOWN, mFilter->Bind(wxEVT_KEY_DOWN,
wxKeyEventHandler(KeyConfigPrefs::OnFilterKeyDown), &KeyConfigPrefs::OnFilterKeyDown,
NULL,
this); this);
mFilter->Connect(wxEVT_CHAR, mFilter->Bind(wxEVT_CHAR,
wxKeyEventHandler(KeyConfigPrefs::OnFilterChar), &KeyConfigPrefs::OnFilterChar,
NULL,
this); this);
} }
S.AddWindow(mFilter, wxALIGN_NOT | wxALIGN_LEFT); S.AddWindow(mFilter, wxALIGN_NOT | wxALIGN_LEFT);
@ -259,17 +226,14 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
wxTE_PROCESS_ENTER); wxTE_PROCESS_ENTER);
mKey->SetName(_("Short cut")); mKey->SetName(_("Short cut"));
mKey->Connect(wxEVT_KEY_DOWN, mKey->Bind(wxEVT_KEY_DOWN,
wxKeyEventHandler(KeyConfigPrefs::OnHotkeyKeyDown), &KeyConfigPrefs::OnHotkeyKeyDown,
NULL,
this); this);
mKey->Connect(wxEVT_CHAR, mKey->Bind(wxEVT_CHAR,
wxKeyEventHandler(KeyConfigPrefs::OnHotkeyChar), &KeyConfigPrefs::OnHotkeyChar,
NULL,
this); this);
mKey->Connect(wxEVT_KILL_FOCUS, mKey->Bind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(KeyConfigPrefs::OnHotkeyKillFocus), &KeyConfigPrefs::OnHotkeyKillFocus,
NULL,
this); this);
} }
S.AddWindow(mKey); S.AddWindow(mKey);

@ -36,7 +36,6 @@ class KeyConfigPrefs final : public PrefsPanel
{ {
public: public:
KeyConfigPrefs(wxWindow * parent, wxWindowID winid, const wxString &name); KeyConfigPrefs(wxWindow * parent, wxWindowID winid, const wxString &name);
~KeyConfigPrefs();
bool Commit() override; bool Commit() override;
void Cancel() override; void Cancel() override;
wxString HelpPageName() override; wxString HelpPageName() override;

@ -125,37 +125,29 @@ void DeviceToolBar::Populate()
mHost->Connect(wxEVT_SET_FOCUS, mHost->Bind(wxEVT_SET_FOCUS,
wxFocusEventHandler(DeviceToolBar::OnFocus), &DeviceToolBar::OnFocus,
NULL,
this); this);
mHost->Connect(wxEVT_KILL_FOCUS, mHost->Bind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(DeviceToolBar::OnFocus), &DeviceToolBar::OnFocus,
NULL,
this); this);
mOutput->Connect(wxEVT_SET_FOCUS, mOutput->Bind(wxEVT_SET_FOCUS,
wxFocusEventHandler(DeviceToolBar::OnFocus), &DeviceToolBar::OnFocus,
NULL,
this); this);
mOutput->Connect(wxEVT_KILL_FOCUS, mOutput->Bind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(DeviceToolBar::OnFocus), &DeviceToolBar::OnFocus,
NULL,
this); this);
mInput->Connect(wxEVT_SET_FOCUS, mInput->Bind(wxEVT_SET_FOCUS,
wxFocusEventHandler(DeviceToolBar::OnFocus), &DeviceToolBar::OnFocus,
NULL,
this); this);
mInput->Connect(wxEVT_KILL_FOCUS, mInput->Bind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(DeviceToolBar::OnFocus), &DeviceToolBar::OnFocus,
NULL,
this); this);
mInputChannels->Connect(wxEVT_SET_FOCUS, mInputChannels->Bind(wxEVT_SET_FOCUS,
wxFocusEventHandler(DeviceToolBar::OnFocus), &DeviceToolBar::OnFocus,
NULL,
this); this);
mInputChannels->Connect(wxEVT_KILL_FOCUS, mInputChannels->Bind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(DeviceToolBar::OnFocus), &DeviceToolBar::OnFocus,
NULL,
this); this);
SetNames(); SetNames();

@ -94,21 +94,17 @@ void MixerToolBar::Populate()
Add(mOutputSlider, 0, wxALIGN_CENTER); Add(mOutputSlider, 0, wxALIGN_CENTER);
// this bit taken from SelectionBar::Populate() // this bit taken from SelectionBar::Populate()
mInputSlider->Connect(wxEVT_SET_FOCUS, mInputSlider->Bind(wxEVT_SET_FOCUS,
wxFocusEventHandler(MixerToolBar::OnFocus), &MixerToolBar::OnFocus,
NULL,
this); this);
mInputSlider->Connect(wxEVT_KILL_FOCUS, mInputSlider->Bind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(MixerToolBar::OnFocus), &MixerToolBar::OnFocus,
NULL,
this); this);
mOutputSlider->Connect(wxEVT_SET_FOCUS, mOutputSlider->Bind(wxEVT_SET_FOCUS,
wxFocusEventHandler(MixerToolBar::OnFocus), &MixerToolBar::OnFocus,
NULL,
this); this);
mOutputSlider->Connect(wxEVT_KILL_FOCUS, mOutputSlider->Bind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(MixerToolBar::OnFocus), &MixerToolBar::OnFocus,
NULL,
this); this);
// Show or hide the input slider based on whether it works // Show or hide the input slider based on whether it works
mInputSlider->Enable(gAudioIO->InputMixerWorks()); mInputSlider->Enable(gAudioIO->InputMixerWorks());

@ -323,13 +323,11 @@ void SelectionBar::Populate()
} }
#endif #endif
mRateText->Connect(wxEVT_SET_FOCUS, mRateText->Bind(wxEVT_SET_FOCUS,
wxFocusEventHandler(SelectionBar::OnFocus), &SelectionBar::OnFocus,
NULL,
this); this);
mRateText->Connect(wxEVT_KILL_FOCUS, mRateText->Bind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(SelectionBar::OnFocus), &SelectionBar::OnFocus,
NULL,
this); this);
#ifdef __WXGTK__ #ifdef __WXGTK__
@ -361,13 +359,11 @@ void SelectionBar::Populate()
//mSnapTo->SetForegroundColour( clrText2 ); //mSnapTo->SetForegroundColour( clrText2 );
mSnapTo->SetSelection(mListener ? mListener->AS_GetSnapTo() : SNAP_OFF); mSnapTo->SetSelection(mListener ? mListener->AS_GetSnapTo() : SNAP_OFF);
mSnapTo->Connect(wxEVT_SET_FOCUS, mSnapTo->Bind(wxEVT_SET_FOCUS,
wxFocusEventHandler(SelectionBar::OnFocus), &SelectionBar::OnFocus,
NULL,
this); this);
mSnapTo->Connect(wxEVT_KILL_FOCUS, mSnapTo->Bind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(SelectionBar::OnFocus), &SelectionBar::OnFocus,
NULL,
this); this);
AddVLine( mainSizer ); AddVLine( mainSizer );

@ -382,15 +382,13 @@ ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent )
}; };
// Hook the creation event...only needed on GTK, but doesn't hurt for all // Hook the creation event...only needed on GTK, but doesn't hurt for all
mIndicator->Connect( wxEVT_CREATE, mIndicator->Bind( wxEVT_CREATE,
wxWindowCreateEventHandler( ToolManager::OnIndicatorCreate ), &ToolManager::OnIndicatorCreate,
NULL,
this ); this );
// Hook the paint event...needed for all // Hook the paint event...needed for all
mIndicator->Connect( wxEVT_PAINT, mIndicator->Bind( wxEVT_PAINT,
wxPaintEventHandler( ToolManager::OnIndicatorPaint ), &ToolManager::OnIndicatorPaint,
NULL,
this ); this );
// It's a little shy // It's a little shy
@ -398,17 +396,14 @@ ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent )
// Hook the parents mouse events...using the parent helps greatly // Hook the parents mouse events...using the parent helps greatly
// under GTK // under GTK
mParent->Connect( wxEVT_LEFT_UP, mParent->Bind( wxEVT_LEFT_UP,
wxMouseEventHandler( ToolManager::OnMouse ), &ToolManager::OnMouse,
NULL,
this ); this );
mParent->Connect( wxEVT_MOTION, mParent->Bind( wxEVT_MOTION,
wxMouseEventHandler( ToolManager::OnMouse ), &ToolManager::OnMouse,
NULL,
this ); this );
mParent->Connect( wxEVT_MOUSE_CAPTURE_LOST, mParent->Bind( wxEVT_MOUSE_CAPTURE_LOST,
wxMouseCaptureLostEventHandler( ToolManager::OnCaptureLost ), &ToolManager::OnCaptureLost,
NULL,
this ); this );
// Create the top and bottom docks // Create the top and bottom docks
@ -458,30 +453,6 @@ ToolManager::~ToolManager()
// crashing when running with Jaws on Windows 10 1703. // crashing when running with Jaws on Windows 10 1703.
mTopDock->GetConfiguration().Clear(); mTopDock->GetConfiguration().Clear();
mBotDock->GetConfiguration().Clear(); mBotDock->GetConfiguration().Clear();
// Remove handlers from parent
mParent->Disconnect( wxEVT_LEFT_UP,
wxMouseEventHandler( ToolManager::OnMouse ),
NULL,
this );
mParent->Disconnect( wxEVT_MOTION,
wxMouseEventHandler( ToolManager::OnMouse ),
NULL,
this );
mParent->Disconnect( wxEVT_MOUSE_CAPTURE_LOST,
wxMouseCaptureLostEventHandler( ToolManager::OnCaptureLost ),
NULL,
this );
// Remove our event handlers
mIndicator->Disconnect( wxEVT_CREATE,
wxWindowCreateEventHandler( ToolManager::OnIndicatorCreate ),
NULL,
this );
mIndicator->Disconnect( wxEVT_PAINT,
wxPaintEventHandler( ToolManager::OnIndicatorPaint ),
NULL,
this );
} }
// This table describes the default configuration of the toolbars as // This table describes the default configuration of the toolbars as

@ -200,13 +200,11 @@ void TranscriptionToolBar::Populate()
mPlaySpeedSlider->Set(mPlaySpeed / 100.0); mPlaySpeedSlider->Set(mPlaySpeed / 100.0);
mPlaySpeedSlider->SetLabel(_("Playback Speed")); mPlaySpeedSlider->SetLabel(_("Playback Speed"));
Add( mPlaySpeedSlider, 0, wxALIGN_CENTER ); Add( mPlaySpeedSlider, 0, wxALIGN_CENTER );
mPlaySpeedSlider->Connect(wxEVT_SET_FOCUS, mPlaySpeedSlider->Bind(wxEVT_SET_FOCUS,
wxFocusEventHandler(TranscriptionToolBar::OnFocus), &TranscriptionToolBar::OnFocus,
NULL,
this); this);
mPlaySpeedSlider->Connect(wxEVT_KILL_FOCUS, mPlaySpeedSlider->Bind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(TranscriptionToolBar::OnFocus), &TranscriptionToolBar::OnFocus,
NULL,
this); this);
#ifdef EXPERIMENTAL_VOICE_DETECTION #ifdef EXPERIMENTAL_VOICE_DETECTION

@ -104,9 +104,8 @@ void PlayIndicatorOverlayBase::Draw(OverlayPanel &panel, wxDC &dc)
PlayIndicatorOverlay::PlayIndicatorOverlay(AudacityProject *project) PlayIndicatorOverlay::PlayIndicatorOverlay(AudacityProject *project)
: PlayIndicatorOverlayBase(project, true) : PlayIndicatorOverlayBase(project, true)
{ {
mProject->Connect(EVT_TRACK_PANEL_TIMER, mProject->Bind(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(PlayIndicatorOverlay::OnTimer), &PlayIndicatorOverlay::OnTimer,
NULL,
this); this);
} }
@ -117,11 +116,6 @@ PlayIndicatorOverlay::~PlayIndicatorOverlay()
if(ruler) if(ruler)
ruler->RemoveOverlay(mPartner.get()); ruler->RemoveOverlay(mPartner.get());
} }
mProject->Disconnect(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(PlayIndicatorOverlay::OnTimer),
NULL,
this);
} }
void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event) void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)

@ -198,9 +198,9 @@ Scrubber::Scrubber(AudacityProject *project)
{ {
if (wxTheApp) if (wxTheApp)
wxTheApp->Connect wxTheApp->Bind
(wxEVT_ACTIVATE_APP, (wxEVT_ACTIVATE_APP,
wxActivateEventHandler(Scrubber::OnActivateOrDeactivateApp), NULL, this); &Scrubber::OnActivateOrDeactivateApp, this);
mProject->PushEventHandler(&mForwarder); mProject->PushEventHandler(&mForwarder);
} }
@ -212,10 +212,6 @@ Scrubber::~Scrubber()
#endif #endif
mProject->PopEventHandler(); mProject->PopEventHandler();
if (wxTheApp)
wxTheApp->Disconnect
(wxEVT_ACTIVATE_APP,
wxActivateEventHandler(Scrubber::OnActivateOrDeactivateApp), NULL, this);
} }
namespace { namespace {
@ -730,17 +726,8 @@ ScrubbingOverlay::ScrubbingOverlay(AudacityProject *project)
, mLastScrubSpeedText() , mLastScrubSpeedText()
, mNextScrubSpeedText() , mNextScrubSpeedText()
{ {
mProject->Connect(EVT_TRACK_PANEL_TIMER, mProject->Bind(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(ScrubbingOverlay::OnTimer), &ScrubbingOverlay::OnTimer,
NULL,
this);
}
ScrubbingOverlay::~ScrubbingOverlay()
{
mProject->Disconnect(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(ScrubbingOverlay::OnTimer),
NULL,
this); this);
} }

@ -209,7 +209,6 @@ class ScrubbingOverlay final : public wxEvtHandler, public Overlay
{ {
public: public:
ScrubbingOverlay(AudacityProject *project); ScrubbingOverlay(AudacityProject *project);
virtual ~ScrubbingOverlay();
private: private:
std::pair<wxRect, bool> DoGetRectangle(wxSize size) override; std::pair<wxRect, bool> DoGetRectangle(wxSize size) override;

@ -1042,18 +1042,8 @@ public:
, mConnectedProject{ pProject } , mConnectedProject{ pProject }
{ {
if (mConnectedProject) if (mConnectedProject)
mConnectedProject->Connect(EVT_TRACK_PANEL_TIMER, mConnectedProject->Bind(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(SelectHandle::TimerHandler::OnTimer), &SelectHandle::TimerHandler::OnTimer,
NULL,
this);
}
~TimerHandler()
{
if (mConnectedProject)
mConnectedProject->Disconnect(EVT_TRACK_PANEL_TIMER,
wxCommandEventHandler(SelectHandle::TimerHandler::OnTimer),
NULL,
this); this);
} }

@ -167,13 +167,15 @@ public:
public: public:
void ConnectEvent(wxWindow *w) void ConnectEvent(wxWindow *w)
{ {
w->GetEventHandler()->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(FocusHandler::OnKillFocus)); // Need to use a named function pointer, not a lambda, so that we
// can unbind the same later
w->GetEventHandler()->Bind(wxEVT_KILL_FOCUS, OnKillFocus);
}; };
void DisconnectEvent(wxWindow *w) void DisconnectEvent(wxWindow *w)
{ {
w->GetEventHandler()->Disconnect(wxEVT_KILL_FOCUS, wxFocusEventHandler(FocusHandler::OnKillFocus)); w->GetEventHandler()->Unbind(wxEVT_KILL_FOCUS, OnKillFocus);
}; };
void OnKillFocus(wxFocusEvent & WXUNUSED(event)) static void OnKillFocus(wxFocusEvent & WXUNUSED(event))
{ {
return; return;
}; };

@ -176,7 +176,7 @@ bool MeterUpdateQueue::Get(MeterUpdateMsg &msg)
const static int gap = 2; const static int gap = 2;
// Event used to notify all meters of preference changes // Event used to notify all meters of preference changes
DEFINE_EVENT_TYPE(EVT_METER_PREFERENCES_CHANGED); wxDEFINE_EVENT(EVT_METER_PREFERENCES_CHANGED, wxCommandEvent);
const static wxChar *PrefStyles[] = const static wxChar *PrefStyles[] =
{ {
@ -270,19 +270,16 @@ MeterPanel::MeterPanel(AudacityProject *project,
mDisabledPen = wxPen(theTheme.Colour( clrMeterDisabledPen), 1, wxSOLID); mDisabledPen = wxPen(theTheme.Colour( clrMeterDisabledPen), 1, wxSOLID);
// Register for our preference update event // Register for our preference update event
wxTheApp->Connect(EVT_METER_PREFERENCES_CHANGED, wxTheApp->Bind(EVT_METER_PREFERENCES_CHANGED,
wxCommandEventHandler(MeterPanel::OnMeterPrefsUpdated), &MeterPanel::OnMeterPrefsUpdated,
NULL,
this); this);
if (mIsInput) { if (mIsInput) {
wxTheApp->Connect(EVT_AUDIOIO_MONITOR, wxTheApp->Bind(EVT_AUDIOIO_MONITOR,
wxCommandEventHandler(MeterPanel::OnAudioIOStatus), &MeterPanel::OnAudioIOStatus,
NULL,
this); this);
wxTheApp->Connect(EVT_AUDIOIO_CAPTURE, wxTheApp->Bind(EVT_AUDIOIO_CAPTURE,
wxCommandEventHandler(MeterPanel::OnAudioIOStatus), &MeterPanel::OnAudioIOStatus,
NULL,
this); this);
mPen = wxPen( theTheme.Colour( clrMeterInputPen ), 1, wxSOLID); mPen = wxPen( theTheme.Colour( clrMeterInputPen ), 1, wxSOLID);
@ -294,9 +291,8 @@ MeterPanel::MeterPanel(AudacityProject *project,
} }
else { else {
// Register for AudioIO events // Register for AudioIO events
wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK, wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK,
wxCommandEventHandler(MeterPanel::OnAudioIOStatus), &MeterPanel::OnAudioIOStatus,
NULL,
this); this);
mPen = wxPen( theTheme.Colour( clrMeterOutputPen ), 1, wxSOLID); mPen = wxPen( theTheme.Colour( clrMeterOutputPen ), 1, wxSOLID);
@ -340,35 +336,6 @@ void MeterPanel::Clear()
mQueue.Clear(); mQueue.Clear();
} }
MeterPanel::~MeterPanel()
{
if (mIsInput)
{
// Unregister for AudioIO events
wxTheApp->Disconnect(EVT_AUDIOIO_MONITOR,
wxCommandEventHandler(MeterPanel::OnAudioIOStatus),
NULL,
this);
wxTheApp->Disconnect(EVT_AUDIOIO_CAPTURE,
wxCommandEventHandler(MeterPanel::OnAudioIOStatus),
NULL,
this);
}
else
{
wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK,
wxCommandEventHandler(MeterPanel::OnAudioIOStatus),
NULL,
this);
}
// Unregister for our preference update event
wxTheApp->Disconnect(EVT_METER_PREFERENCES_CHANGED,
wxCommandEventHandler(MeterPanel::OnMeterPrefsUpdated),
NULL,
this);
}
void MeterPanel::UpdatePrefs() void MeterPanel::UpdatePrefs()
{ {
mDBRange = gPrefs->Read(ENV_DB_KEY, ENV_DB_RANGE); mDBRange = gPrefs->Read(ENV_DB_KEY, ENV_DB_RANGE);

@ -23,7 +23,8 @@
#include "Ruler.h" #include "Ruler.h"
// Event used to notify all meters of preference changes // Event used to notify all meters of preference changes
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_METER_PREFERENCES_CHANGED, -1); wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
EVT_METER_PREFERENCES_CHANGED, wxCommandEvent);
// Increase this when we add support for multichannel meters // Increase this when we add support for multichannel meters
// (most of the code is already there) // (most of the code is already there)
@ -114,8 +115,6 @@ class MeterPanel final : public wxPanelWrapper
Style style = HorizontalStereo, Style style = HorizontalStereo,
float fDecayRate = 60.0f); float fDecayRate = 60.0f);
~MeterPanel();
bool AcceptsFocus() const override { return s_AcceptsFocus; } bool AcceptsFocus() const override { return s_AcceptsFocus; }
bool AcceptsFocusFromKeyboard() const override { return true; } bool AcceptsFocusFromKeyboard() const override { return true; }

@ -13,15 +13,17 @@ Paul Licameli split from TrackPanel.cpp
PopupMenuTable::Menu::~Menu() PopupMenuTable::Menu::~Menu()
{ {
// Event connections between the parent window and the singleton table
// object must be broken when this menu is destroyed.
Disconnect(); Disconnect();
} }
void PopupMenuTable::Menu::Extend(PopupMenuTable *pTable) void PopupMenuTable::Menu::Extend(PopupMenuTable *pTable)
{ {
auto connect = [&]( const PopupMenuTable::Entry *pEntry ) { auto connect = [&]( const PopupMenuTable::Entry *pEntry ) {
this->pParent->Connect this->pParent->Bind
(pEntry->id, wxEVT_COMMAND_MENU_SELECTED, (wxEVT_COMMAND_MENU_SELECTED,
pEntry->func, NULL, pTable); pEntry->func, pTable, pEntry->id);
}; };
for (const PopupMenuTable::Entry *pEntry = &*pTable->Get().begin(); for (const PopupMenuTable::Entry *pEntry = &*pTable->Get().begin();
@ -67,8 +69,8 @@ void PopupMenuTable::Menu::DisconnectTable(PopupMenuTable *pTable)
for (const PopupMenuTable::Entry *pEntry = &*pTable->Get().begin(); for (const PopupMenuTable::Entry *pEntry = &*pTable->Get().begin();
pEntry->IsValid(); ++pEntry) { pEntry->IsValid(); ++pEntry) {
if ( pEntry->IsItem() ) if ( pEntry->IsItem() )
pParent->Disconnect( pEntry->id, wxEVT_COMMAND_MENU_SELECTED, pParent->Unbind( wxEVT_COMMAND_MENU_SELECTED,
pEntry->func, NULL, pTable ); pEntry->func, pTable, pEntry->id );
else if ( pEntry->IsSubMenu() ) else if ( pEntry->IsSubMenu() )
// recur // recur
DisconnectTable(pEntry->subTable); DisconnectTable(pEntry->subTable);

@ -36,11 +36,11 @@ struct PopupMenuTableEntry
Type type; Type type;
int id; int id;
wxString caption; wxString caption;
wxObjectEventFunction func; wxCommandEventFunction func;
PopupMenuTable *subTable; PopupMenuTable *subTable;
PopupMenuTableEntry(Type type_, int id_, wxString caption_, PopupMenuTableEntry(Type type_, int id_, wxString caption_,
wxObjectEventFunction func_, PopupMenuTable *subTable_) wxCommandEventFunction func_, PopupMenuTable *subTable_)
: type(type_) : type(type_)
, id(id_) , id(id_)
, caption(caption_) , caption(caption_)
@ -165,8 +165,7 @@ void HandlerClass::Populate() { \
type, \ type, \
id, \ id, \
string, \ string, \
(wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction) \ (wxCommandEventFunction) (&My::memFn), \
(&My::memFn), \
nullptr ) nullptr )
#define POPUP_MENU_ITEM(id, string, memFn) \ #define POPUP_MENU_ITEM(id, string, memFn) \

@ -2021,9 +2021,8 @@ AdornedRulerPanel::AdornedRulerPanel(AudacityProject* project,
wxToolTip::Enable(true); wxToolTip::Enable(true);
#endif #endif
wxTheApp->Connect(EVT_AUDIOIO_CAPTURE, wxTheApp->Bind(EVT_AUDIOIO_CAPTURE,
wxCommandEventHandler(AdornedRulerPanel::OnCapture), &AdornedRulerPanel::OnCapture,
NULL,
this); this);
} }
@ -2031,11 +2030,6 @@ AdornedRulerPanel::~AdornedRulerPanel()
{ {
if(HasCapture()) if(HasCapture())
ReleaseMouse(); ReleaseMouse();
wxTheApp->Disconnect(EVT_AUDIOIO_CAPTURE,
wxCommandEventHandler(AdornedRulerPanel::OnCapture),
NULL,
this);
} }
#if 1 #if 1

@ -27,11 +27,6 @@ public:
{ {
this->Bind(wxEVT_CHAR_HOOK, wxTabTraversalWrapperCharHook); this->Bind(wxEVT_CHAR_HOOK, wxTabTraversalWrapperCharHook);
} }
~wxTabTraversalWrapper()
{
this->Unbind(wxEVT_CHAR_HOOK, wxTabTraversalWrapperCharHook);
}
}; };
class AUDACITY_DLL_API wxPanelWrapper : public wxTabTraversalWrapper<wxPanel> class AUDACITY_DLL_API wxPanelWrapper : public wxTabTraversalWrapper<wxPanel>