Add clear button to shifting history

Originally committed to SVN as r820.
This commit is contained in:
Dan Donovan 2007-01-17 06:18:12 +00:00
parent 2b27078cf4
commit 12e558bcfc
3 changed files with 21 additions and 6 deletions

View file

@ -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) {

View file

@ -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
};

View file

@ -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;