r105: This commit was manufactured by cvs2svn to create tag
[cinelerra_cv/mob.git] / hvirtual / cinelerra / setsamplerate.C
blob54b3038dd0fa0527a91dfb636cad17ac0d867f7a
1 #include "mwindow.h"
2 #include "mwindowgui.h"
3 #include "mainsession.h"
4 #include "setsamplerate.h"
6 #include <libintl.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();
23         if(!result)
24         {
25                 if(sample_rate >= 4000 && sample_rate <= 200000)
26                 {
27                         mwindow->session->sample_rate = sample_rate;
28                         mwindow->session->changes_made = 1;
29                         mwindow->redraw_time_dependancies();
30                 }
31         }
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(), 
39         340, 
40         140)
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));
55         
56         char string[1024];
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());