2 #include "mwindowgui.h"
3 #include "mainsession.h"
4 #include "setsamplerate.h"
7 #define _(String) gettext(String)
8 #define gettext_noop(String) String
9 #define N_(String) gettext_noop (String)
11 SetSampleRate::SetSampleRate(MWindow *mwindow)
12 : BC_MenuItem(_("Sample rate..."), ""), Thread()
13 { this->mwindow = mwindow; }
15 int SetSampleRate::handle_event() { start(); }
17 void SetSampleRate::run()
19 SetSampleRateWindow window(mwindow, this);
20 sample_rate = mwindow->session->sample_rate;
21 window.create_objects();
22 int result = window.run_window();
25 if(sample_rate >= 4000 && sample_rate <= 200000)
27 mwindow->session->sample_rate = sample_rate;
28 mwindow->session->changes_made = 1;
29 mwindow->redraw_time_dependancies();
35 SetSampleRateWindow::SetSampleRateWindow(MWindow *mwindow, SetSampleRate *thread)
36 : BC_Window(PROGRAM_NAME ": Sample Rate",
37 mwindow->gui->get_abs_cursor_x(),
38 mwindow->gui->get_abs_cursor_y(),
42 this->thread = thread;
43 this->mwindow = mwindow;
46 SetSampleRateWindow::~SetSampleRateWindow()
50 int SetSampleRateWindow::create_objects()
52 add_subwindow(new BC_Title(5, 5, _("Enter the sample rate to use:")));
53 add_subwindow(new BC_OKButton(10, get_h() - 40));
54 add_subwindow(new BC_CancelButton(get_w() - 100, get_h() - 40));
57 sprintf(string, "%d", thread->sample_rate);
58 add_subwindow(new SetSampleRateTextBox(mwindow, this, string));
61 SetSampleRateTextBox::SetSampleRateTextBox(MWindow *mwindow, SetSampleRateWindow *srwindow, char *text)
62 : BC_TextBox(10, 40, 100, 1, text)
64 this->mwindow = mwindow;
65 this->srwindow = srwindow;
68 int SetSampleRateTextBox::handle_event()
70 srwindow->thread->sample_rate = atol(get_text());