From 12e558bcfca1415e76354d157de594635787f0e0 Mon Sep 17 00:00:00 2001 From: Dan Donovan Date: Wed, 17 Jan 2007 06:18:12 +0000 Subject: [PATCH] Add clear button to shifting history Originally committed to SVN as r820. --- aegisub/dialog_shift_times.cpp | 21 +++++++++++++++++---- aegisub/dialog_shift_times.h | 4 +++- aegisub/subs_grid.cpp | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/aegisub/dialog_shift_times.cpp b/aegisub/dialog_shift_times.cpp index 1d645828a..010adccfa 100644 --- a/aegisub/dialog_shift_times.cpp +++ b/aegisub/dialog_shift_times.cpp @@ -52,6 +52,9 @@ #include "subs_edit_box.h" +#define SHIFT_HISTORY_FILE (AegisubApp::folderName + _T("shift_history.txt")) + + /////////////// // Constructor DialogShiftTimes::DialogShiftTimes (wxWindow *parent,SubtitlesGrid *_grid,VideoDisplay *vid) @@ -111,17 +114,19 @@ DialogShiftTimes::DialogShiftTimes (wxWindow *parent,SubtitlesGrid *_grid,VideoD // Buttons wxButton *CancelButton = new wxButton(this,wxID_CANCEL); wxButton *OKButton = new wxButton(this,wxID_OK); + wxButton *ClearButton = new wxButton(this,SHIFT_CLEAR_HISTORY,_("Clear")); OKButton->SetDefault(); wxSizer *ButtonSizer = new wxBoxSizer(wxHORIZONTAL); - ButtonSizer->AddStretchSpacer(1); + ButtonSizer->AddStretchSpacer(2); #ifndef __WXMAC__ - ButtonSizer->Add(OKButton,0,wxRIGHT,5); - ButtonSizer->Add(CancelButton,0,wxRIGHT,0); + ButtonSizer->Add(OKButton,0,wxALIGN_CENTER|wxRIGHT,5); + ButtonSizer->Add(CancelButton,0,wxALIGN_CENTER|wxRIGHT,0); #else ButtonSizer->Add(CancelButton,0,wxRIGHT,5); ButtonSizer->Add(OKButton,0,wxRIGHT,0); #endif ButtonSizer->AddStretchSpacer(1); + ButtonSizer->Add(ClearButton,0,wxALIGN_RIGHT|wxRIGHT,5); // General layout wxSizer *LeftSizer = new wxBoxSizer(wxVERTICAL); @@ -167,7 +172,7 @@ DialogShiftTimes::DialogShiftTimes (wxWindow *parent,SubtitlesGrid *_grid,VideoD } // Load history - LoadHistory(AegisubApp::folderName + _T("shift_history.txt")); + LoadHistory(SHIFT_HISTORY_FILE); } @@ -176,11 +181,19 @@ DialogShiftTimes::DialogShiftTimes (wxWindow *parent,SubtitlesGrid *_grid,VideoD BEGIN_EVENT_TABLE(DialogShiftTimes, wxDialog) EVT_BUTTON(wxID_CANCEL,DialogShiftTimes::OnClose) EVT_BUTTON(wxID_OK,DialogShiftTimes::OnOK) + EVT_BUTTON(SHIFT_CLEAR_HISTORY,DialogShiftTimes::OnClear) EVT_RADIOBUTTON(RADIO_TIME,DialogShiftTimes::OnRadioTime) EVT_RADIOBUTTON(RADIO_FRAME,DialogShiftTimes::OnRadioFrame) END_EVENT_TABLE() +///////////////// +// Clear History +void DialogShiftTimes::OnClear(wxCommandEvent &event) { + remove(SHIFT_HISTORY_FILE.mb_str(wxConvLocal)); + History->Clear(); +} + ////////// // Cancel void DialogShiftTimes::OnClose(wxCommandEvent &event) { diff --git a/aegisub/dialog_shift_times.h b/aegisub/dialog_shift_times.h index 7272dd649..5659b504c 100644 --- a/aegisub/dialog_shift_times.h +++ b/aegisub/dialog_shift_times.h @@ -70,6 +70,7 @@ private: void AppendToHistory(wxString text); void LoadHistory(wxString filename); + void OnClear(wxCommandEvent &event); public: DialogShiftTimes (wxWindow *parent,SubtitlesGrid *grid,VideoDisplay *vid); @@ -94,7 +95,8 @@ enum { RADIO_BACKWARD, RADIO_FORWARD, RADIO_TIME, - RADIO_FRAME + RADIO_FRAME, + SHIFT_CLEAR_HISTORY }; diff --git a/aegisub/subs_grid.cpp b/aegisub/subs_grid.cpp index d1dcae14d..ee87b2233 100644 --- a/aegisub/subs_grid.cpp +++ b/aegisub/subs_grid.cpp @@ -652,7 +652,7 @@ void SubtitlesGrid::OnAudioClip(wxCommandEvent &event) { wxString filename = wxFileSelector(_("Save audio clip"),0,0,_T("wav"),0,wxSAVE|wxOVERWRITE_PROMPT,this); if (!filename.empty()) { - std::ofstream outfile(filename,std::ios::binary); + std::ofstream outfile(filename.mb_str(wxConvLocal),std::ios::binary); size_t bufsize=(end-start)*provider->GetChannels()*provider->GetBytesPerSample(); int intval;