r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / channeledit.C
blob94c3f43a168b2874217847b0876b17b28bd911d0
1 #include "batch.h"
2 #include "channel.h"
3 #include "channeledit.h"
4 #include "channelpicker.h"
5 #include "chantables.h"
6 #include "mwindow.h"
7 #include "mwindowgui.h"
8 #include "record.h"
9 #include "recordgui.h"
10 #include "theme.h"
12 #include <string.h>
13 #include <libintl.h>
14 #define _(String) gettext(String)
15 #define gettext_noop(String) String
16 #define N_(String) gettext_noop (String)
18 ChannelEditThread::ChannelEditThread(MWindow *mwindow, 
19         ChannelPicker *channel_picker,
20         ArrayList<Channel*> *channeldb,
21         Record *record)
22  : Thread()
24         this->channel_picker = channel_picker;
25         this->mwindow = mwindow;
26         this->channeldb = channeldb;
27         this->record = record;
28         in_progress = 0;
29         this->window = 0;
31 ChannelEditThread::~ChannelEditThread()
35 void ChannelEditThread::run()
37         int i;
38 //printf("ChannelEditThread::run 1\n");
40         if(in_progress) 
41         {
42                 if(window)
43                 {
44                         window->lock_window();
45                         window->raise_window();
46                         window->flush();
47                         window->unlock_window();
48                 }
49                 return;
50         }
51         in_progress = 1;
52         completion.lock();
53 //printf("ChannelEditThread::run 1\n");
55 // Copy master channel list to temporary.
56         new_channels = new ArrayList <Channel*>;
57         for(i = 0; i < channel_picker->channeldb->total; i++)
58         {
59                 new_channels->append(new Channel(channel_picker->channeldb->values[i]));
60         }
61         current_channel = channel_picker->get_current_channel_number();
63 //printf("ChannelEditThread::run 1\n");
64 // Run the window using the temporary.
65         ChannelEditWindow window(mwindow, this, channel_picker);
66         window.create_objects();
67         this->window = &window;
68         int result = window.run_window();
69         this->window = 0;
71 //printf("ChannelEditThread::run 1\n");
72         if(!result)
73         {
74 // Copy new channels to master list
75                 channel_picker->channeldb->remove_all_objects();
76                 
77                 for(i = 0; i < new_channels->total; i++)
78                 {
79                         channel_picker->channeldb->append(new Channel(new_channels->values[i]));
80                 }
81                 channel_picker->update_channel_list();
82                 if(record)
83                 {
84                         record->record_gui->lock_window();
85                         record->record_gui->update_batch_sources();
86                         record->set_channel(current_channel);
87                         record->record_gui->unlock_window();
88                         record->save_defaults();
89                 }
90                 mwindow->save_defaults();
91                 
92         }
93         else
94         {
95 // Rejected.
96                 if(record)
97                 {
98                         record->set_channel(record->get_editing_batch()->channel);
99                 }
100         }
102 //printf("ChannelEditThread::run 1\n");
103         window.edit_thread->close_threads();
104         window.picture_thread->close_threads();
106 //printf("ChannelEditThread::run 2\n");
107         new_channels->remove_all_objects();
108         delete new_channels;
109         completion.unlock();
110         in_progress = 0;
111 //printf("ChannelEditThread::run 3\n");
114 int ChannelEditThread::close_threads()
116         if(in_progress && window)
117         {
118                 window->edit_thread->close_threads();
119                 window->picture_thread->close_threads();
120                 window->set_done(1);
121                 completion.lock();
122                 completion.unlock();
123         }
127 ChannelEditWindow::ChannelEditWindow(MWindow *mwindow, 
128         ChannelEditThread *thread, 
129         ChannelPicker *channel_picker)
130  : BC_Window(PROGRAM_NAME ": Channels", 
131         mwindow->gui->get_abs_cursor_x() - 330, 
132         mwindow->gui->get_abs_cursor_y(), 
133         330, 
134         330, 
135         330, 
136         330,
137         0,
138         0,
139         1)
141         this->thread = thread;
142         this->channel_picker = channel_picker;
143         this->mwindow = mwindow;
145 ChannelEditWindow::~ChannelEditWindow()
147         int i;
148         for(i = 0; i < channel_list.total; i++)
149         {
150                 delete channel_list.values[i];
151         }
152         channel_list.remove_all();
153         delete edit_thread;
154         delete picture_thread;
157 int ChannelEditWindow::create_objects()
159         int x = 10, y = 10, i;
160         char string[1024];
162 // Create channel list
163         for(i = 0; i < thread->new_channels->total; i++)
164         {
165                 channel_list.append(new BC_ListBoxItem(thread->new_channels->values[i]->title));
166         }
168         add_subwindow(list_box = new ChannelEditList(mwindow, this, x, y));
169         x += 200;
170         if(thread->record)
171         {
172                 add_subwindow(new ChannelEditSelect(mwindow, this, x, y));
173                 y += 30;
174         }
175         add_subwindow(new ChannelEditAdd(mwindow, this, x, y));
176         y += 30;
177         add_subwindow(new ChannelEdit(mwindow, this, x, y));
178         y += 30;
179         add_subwindow(new ChannelEditMoveUp(mwindow, this, x, y));
180         y += 30;
181         add_subwindow(new ChannelEditMoveDown(mwindow, this, x, y));
182         y += 30;
183         add_subwindow(new ChannelEditDel(mwindow, this, x, y));
184         y += 30;
185         add_subwindow(new ChannelEditPicture(mwindow, this, x, y));
186         y += 100;
187         x = 10;
188         add_subwindow(new BC_OKButton(this));
189         x += 150;
190         add_subwindow(new BC_CancelButton(this));
191         
192         edit_thread = new ChannelEditEditThread(this, 
193                 channel_picker, 
194                 thread->record);
195         picture_thread = new ChannelEditPictureThread(channel_picker, this);
196         show_window();
197         return 0;
200 int ChannelEditWindow::close_event()
202         set_done(0);
205 int ChannelEditWindow::add_channel()
207         Channel *new_channel;
208         
209         new_channel = new Channel;
210         if(thread->new_channels->total) *new_channel = *(thread->new_channels->values[thread->new_channels->total - 1]);
211         channel_list.append(new BC_ListBoxItem(new_channel->title));
212         thread->new_channels->append(new_channel);
213         update_list();
214         edit_thread->edit_channel(new_channel, 0);
215         return 0;
218 int ChannelEditWindow::update_list()
220         list_box->update(&channel_list, 0, 0, 1, list_box->get_yposition());
223 int ChannelEditWindow::update_list(Channel *channel)
225         int i;
226         for(i = 0; i < thread->new_channels->total; i++)
227                 if(thread->new_channels->values[i] == channel) break;
229         if(i < thread->new_channels->total)
230         {
231                 channel_list.values[i]->set_text(channel->title);
232         }
234         update_list();
238 int ChannelEditWindow::edit_channel()
240         if(list_box->get_selection_number(0, 0) > -1)
241         {
242                 
243                 edit_thread->edit_channel(thread->new_channels->values[list_box->get_selection_number(0, 0)], 1);
244         }
247 int ChannelEditWindow::edit_picture()
249         picture_thread->edit_picture();
252 int ChannelEditWindow::delete_channel(int number)
254         delete thread->new_channels->values[number];
255         channel_list.remove_number(number);
256         thread->new_channels->remove_number(number);
257         update_list();
260 int ChannelEditWindow::delete_channel(Channel *channel)
262         int i;
263         for(i = 0; i < thread->new_channels->total; i++)
264         {
265                 if(thread->new_channels->values[i] == channel)
266                 {
267                         break;
268                 }
269         }
270         if(i < thread->new_channels->total) delete_channel(i);
271         return 0;
274 int ChannelEditWindow::move_channel_up()
276         if(list_box->get_selection_number(0, 0) > -1)
277         {
278                 int number2 = list_box->get_selection_number(0, 0);
279                 int number1 = number2 - 1;
280                 Channel *temp;
281                 BC_ListBoxItem *temp_text;
283                 if(number1 < 0) number1 = thread->new_channels->total - 1;
285                 temp = thread->new_channels->values[number1];
286                 thread->new_channels->values[number1] = thread->new_channels->values[number2];
287                 thread->new_channels->values[number2] = temp;
289                 temp_text = channel_list.values[number1];
290                 channel_list.values[number1] = channel_list.values[number2];
291                 channel_list.values[number2] = temp_text;
292                 list_box->update(&channel_list, 
293                         0, 
294                         0, 
295                         1, 
296                         list_box->get_xposition(), 
297                         list_box->get_yposition(), 
298                         number1,
299                         1);
300         }
301         return 0;
304 int ChannelEditWindow::move_channel_down()
306         if(list_box->get_selection_number(0, 0) > -1)
307         {
308                 int number2 = list_box->get_selection_number(0, 0);
309                 int number1 = number2 + 1;
310                 Channel *temp;
311                 BC_ListBoxItem *temp_text;
313                 if(number1 > thread->new_channels->total - 1) number1 = 0;
315                 temp = thread->new_channels->values[number1];
316                 thread->new_channels->values[number1] = thread->new_channels->values[number2];
317                 thread->new_channels->values[number2] = temp;
318                 temp_text = channel_list.values[number1];
319                 channel_list.values[number1] = channel_list.values[number2];
320                 channel_list.values[number2] = temp_text;
321                 list_box->update(&channel_list, 
322                         0, 
323                         0, 
324                         1, 
325                         list_box->get_xposition(), 
326                         list_box->get_yposition(), 
327                         number1,
328                         1);
329         }
330         return 0;
333 int ChannelEditWindow::change_channel_from_list(int channel_number)
335         Channel *channel;
336         if(channel_number > -1 && channel_number < thread->new_channels->total)
337         {
338                 thread->current_channel = channel_number;
339                 channel_picker->set_channel(thread->new_channels->values[channel_number]);
340         }
343 ChannelEditSelect::ChannelEditSelect(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
344  : BC_GenericButton(x, y, _("Select"))
346         this->window = window;
348 ChannelEditSelect::~ChannelEditSelect()
351 int ChannelEditSelect::handle_event()
353         window->change_channel_from_list(
354                 window->list_box->get_selection_number(0, 0));
357 ChannelEditAdd::ChannelEditAdd(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
358  : BC_GenericButton(x, y, _("Add..."))
360         this->window = window;
362 ChannelEditAdd::~ChannelEditAdd()
365 int ChannelEditAdd::handle_event()
367         window->add_channel();
370 ChannelEditList::ChannelEditList(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
371  : BC_ListBox(x, 
372                         y, 
373                         185, 
374                         250, 
375                         LISTBOX_TEXT, 
376                         &(window->channel_list))
378         this->window = window;
380 ChannelEditList::~ChannelEditList()
383 int ChannelEditList::handle_event()
385         window->edit_channel();
388 ChannelEditMoveUp::ChannelEditMoveUp(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
389  : BC_GenericButton(x, y, _("Move up"))
391         this->window = window;
393 ChannelEditMoveUp::~ChannelEditMoveUp()
396 int ChannelEditMoveUp::handle_event()
398         lock_window();
399         window->move_channel_up();
400         unlock_window();
403 ChannelEditMoveDown::ChannelEditMoveDown(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
404  : BC_GenericButton(x, y, _("Move down"))
406         this->window = window;
408 ChannelEditMoveDown::~ChannelEditMoveDown()
411 int ChannelEditMoveDown::handle_event()
413         lock_window();
414         window->move_channel_down();
415         unlock_window();
418 ChannelEditDel::ChannelEditDel(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
419  : BC_GenericButton(x, y, _("Delete"))
421         this->window = window;
423 ChannelEditDel::~ChannelEditDel()
426 int ChannelEditDel::handle_event()
428         if(window->list_box->get_selection_number(0, 0) > -1) window->delete_channel(window->list_box->get_selection_number(0, 0));
431 ChannelEdit::ChannelEdit(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
432  : BC_GenericButton(x, y, _("Edit..."))
434         this->window = window;
436 ChannelEdit::~ChannelEdit()
439 int ChannelEdit::handle_event()
441         window->edit_channel();
444 ChannelEditPicture::ChannelEditPicture(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
445  : BC_GenericButton(x, y, _("Picture..."))
447         this->window = window;
449 ChannelEditPicture::~ChannelEditPicture()
452 int ChannelEditPicture::handle_event()
454         window->edit_picture();
459 // ================================= Edit a single channel
463 ChannelEditEditThread::ChannelEditEditThread(ChannelEditWindow *window, 
464         ChannelPicker *channel_picker,
465         Record *record)
466  : Thread()
468         this->window = window;
469         this->channel_picker = channel_picker;
470         this->record = record;
471         in_progress = 0;
472         edit_window = 0;
473         editing = 0;
476 ChannelEditEditThread::~ChannelEditEditThread()
480 int ChannelEditEditThread::close_threads()
482         if(edit_window)
483         {
484                 edit_window->set_done(1);
485                 completion.lock();
486                 completion.unlock();
487         }
490 int ChannelEditEditThread::edit_channel(Channel *channel, int editing)
492         if(in_progress) return 1;
493         in_progress = 1;
495         completion.lock();
496         this->editing = editing;
497         this->output_channel = channel;
498         this->new_channel = *output_channel;
499         set_synchronous(0);
500         Thread::start();
503 char *ChannelEditEditThread::value_to_freqtable(int value)
505         switch(value)
506         {
507                 case NTSC_BCAST:
508                         return _("NTSC_BCAST");
509                         break;
510                 case NTSC_CABLE:
511                         return _("NTSC_CABLE");
512                         break;
513                 case NTSC_HRC:
514                         return _("NTSC_HRC");
515                         break;
516                 case NTSC_BCAST_JP:
517                         return _("NTSC_BCAST_JP");
518                         break;
519                 case NTSC_CABLE_JP:
520                         return _("NTSC_CABLE_JP");
521                         break;
522                 case PAL_AUSTRALIA:
523                         return _("PAL_AUSTRALIA");
524                         break;
525                 case PAL_EUROPE:
526                         return _("PAL_EUROPE");
527                         break;
528                 case PAL_E_EUROPE:
529                         return _("PAL_E_EUROPE");
530                         break;
531                 case PAL_ITALY:
532                         return _("PAL_ITALY");
533                         break;
534                 case PAL_IRELAND:
535                         return _("PAL_IRELAND");
536                         break;
537                 case PAL_NEWZEALAND:
538                         return _("PAL_NEWZEALAND");
539                         break;
540         }
543 char* ChannelEditEditThread::value_to_norm(int value)
545         switch(value)
546         {
547                 case NTSC:
548                         return _("NTSC");
549                         break;
550                 case PAL:
551                         return _("PAL");
552                         break;
553                 case SECAM:
554                         return _("SECAM");
555                         break;
556         }
559 char* ChannelEditEditThread::value_to_input(int value)
561         if(channel_picker->get_video_inputs()->total > value)
562                 return channel_picker->get_video_inputs()->values[value];
563         else
564                 return _("None");
567 void ChannelEditEditThread::set_device()
569         channel_picker->set_channel(&new_channel);
572 int ChannelEditEditThread::change_source(char *source_name)
574         int i, result;
575         for(i = 0; i < chanlists[new_channel.freqtable].count; i++)
576         {
577                 if(!strcasecmp(chanlists[new_channel.freqtable].list[i].name, source_name))
578                 {
579                         new_channel.entry = i;
580                         i = chanlists[new_channel.freqtable].count;
581                         set_device();
582                 }
583         }
586 int ChannelEditEditThread::source_up()
588         new_channel.entry++;
589         if(new_channel.entry > chanlists[new_channel.freqtable].count - 1) new_channel.entry = 0;
590         source_text->update(chanlists[new_channel.freqtable].list[new_channel.entry].name);
591         set_device();
594 int ChannelEditEditThread::source_down()
596         new_channel.entry--;
597         if(new_channel.entry < 0) new_channel.entry = chanlists[new_channel.freqtable].count - 1;
598         source_text->update(chanlists[new_channel.freqtable].list[new_channel.entry].name);
599         set_device();
602 int ChannelEditEditThread::set_input(int value)
604         new_channel.input = value;
605         set_device();
608 int ChannelEditEditThread::set_norm(int value)
610         new_channel.norm = value;
611         set_device();
614 int ChannelEditEditThread::set_freqtable(int value)
616         new_channel.freqtable = value;
617         if(new_channel.entry > chanlists[new_channel.freqtable].count - 1) new_channel.entry = 0;
618         source_text->update(chanlists[new_channel.freqtable].list[new_channel.entry].name);
619         set_device();
622 void ChannelEditEditThread::run()
624         ChannelEditEditWindow edit_window(this, window, channel_picker);
625         edit_window.create_objects(&new_channel);
626         this->edit_window = &edit_window;
627         int result = edit_window.run_window();
628         this->edit_window = 0;
629         if(!result)
630         {
631                 *output_channel = new_channel;
632                 window->lock_window();
633                 window->update_list(output_channel);
634                 window->unlock_window();
635         }
636         else
637         {
638                 if(!editing)
639                 {
640                         window->lock_window();
641                         window->delete_channel(output_channel);
642                         window->unlock_window();
643                 }
644         }
645         editing = 0;
646         completion.unlock();
647         in_progress = 0;
650 ChannelEditEditWindow::ChannelEditEditWindow(ChannelEditEditThread *thread, 
651         ChannelEditWindow *window,
652         ChannelPicker *channel_picker)
653  : BC_Window(PROGRAM_NAME ": Edit Channel", 
654         channel_picker->mwindow->gui->get_abs_cursor_x(), 
655         channel_picker->mwindow->gui->get_abs_cursor_y(), 
656         390, 
657         235, 
658         390, 
659         235,
660         0,
661         0,
662         1)
664         this->channel_picker = channel_picker;
665         this->window = window;
666         this->thread = thread;
668 ChannelEditEditWindow::~ChannelEditEditWindow()
671 int ChannelEditEditWindow::create_objects(Channel *channel)
673         this->new_channel = channel;
675         int x = 10, y = 10;
676         add_subwindow(new BC_Title(x, y, _("Title:")));
677         add_subwindow(new ChannelEditEditTitle(x, y + 20, thread));
678         x += 170;
679         add_subwindow(new BC_Title(x, y, _("Source:")));
680         y += 20;
681         add_subwindow(thread->source_text = new ChannelEditEditSource(x, y, thread));
682         x += 160;
683         add_subwindow(new ChannelEditEditSourceTumbler(x, y, thread));
684         y += 40;
685         x = 10;
686         add_subwindow(new BC_Title(x, y, _("Fine:")));
687         add_subwindow(new ChannelEditEditFine(x + 130, y, thread));
688         y += 30;
689         add_subwindow(new BC_Title(x, y, _("Norm:")));
690         ChannelEditEditNorm *norm;
691         add_subwindow(norm = new ChannelEditEditNorm(x + 130, y, thread));
692         norm->add_items();
694         y += 30;
695         add_subwindow(new BC_Title(x, y, _("Frequency table:")));
696         ChannelEditEditFreqtable *table;
697         add_subwindow(table = new ChannelEditEditFreqtable(x + 130, y, thread));
698         table->add_items();
700         y += 30;
701         add_subwindow(new BC_Title(x, y, _("Input:")));
702         ChannelEditEditInput *input;
703         add_subwindow(input = new ChannelEditEditInput(x + 130, y, thread, thread->record));
704         input->add_items();
706         y += 30;
707         add_subwindow(new BC_OKButton(x, y));
708         x += 200;
709         add_subwindow(new BC_CancelButton(x, y));
710         show_window();
711         return 0;
714 ChannelEditEditTitle::ChannelEditEditTitle(int x, int y, ChannelEditEditThread *thread)
715  : BC_TextBox(x, y, 150, 1, thread->new_channel.title)
717         this->thread = thread;
719 ChannelEditEditTitle::~ChannelEditEditTitle()
722 int ChannelEditEditTitle::handle_event()
724         if(strlen(get_text()) < 1024)
725                 strcpy(thread->new_channel.title, get_text());
729 ChannelEditEditSource::ChannelEditEditSource(int x, int y, ChannelEditEditThread *thread)
730  : BC_TextBox(x, y, 150, 1, chanlists[thread->new_channel.freqtable].list[thread->new_channel.entry].name)
732         this->thread = thread;
735 ChannelEditEditSource::~ChannelEditEditSource()
738 int ChannelEditEditSource::handle_event()
740         thread->change_source(get_text());
744 ChannelEditEditSourceTumbler::ChannelEditEditSourceTumbler(int x, int y, ChannelEditEditThread *thread)
745  : BC_Tumbler(x, y)
747         this->thread = thread;
749 ChannelEditEditSourceTumbler::~ChannelEditEditSourceTumbler()
752 int ChannelEditEditSourceTumbler::handle_up_event()
754         thread->source_up();
756 int ChannelEditEditSourceTumbler::handle_down_event()
758         thread->source_down();
761 ChannelEditEditInput::ChannelEditEditInput(int x, int y, ChannelEditEditThread *thread, Record *record)
762  : BC_PopupMenu(x, y, 150, thread->value_to_input(thread->new_channel.input))
764         this->thread = thread;
765         this->record = record;
767 ChannelEditEditInput::~ChannelEditEditInput()
770 int ChannelEditEditInput::add_items()
772         ArrayList<char*> *inputs;
773         inputs = thread->channel_picker->get_video_inputs();
774         
775         if(inputs)
776                 for(int i = 0; i < inputs->total; i++)
777                 {
778                         add_item(new ChannelEditEditInputItem(thread, inputs->values[i], i));
779                 }
781 int ChannelEditEditInput::handle_event()
785 ChannelEditEditInputItem::ChannelEditEditInputItem(ChannelEditEditThread *thread, char *text, int value)
786  : BC_MenuItem(text)
788         this->thread = thread;
789         this->value = value;
791 ChannelEditEditInputItem::~ChannelEditEditInputItem()
794 int ChannelEditEditInputItem::handle_event()
796         get_popup_menu()->set_text(get_text());
797         thread->set_input(value);
800 ChannelEditEditNorm::ChannelEditEditNorm(int x, int y, ChannelEditEditThread *thread)
801  : BC_PopupMenu(x, y, 100, thread->value_to_norm(thread->new_channel.norm))
803         this->thread = thread;
805 ChannelEditEditNorm::~ChannelEditEditNorm()
808 int ChannelEditEditNorm::add_items()
810         add_item(new ChannelEditEditNormItem(thread, thread->value_to_norm(NTSC), NTSC));
811         add_item(new ChannelEditEditNormItem(thread, thread->value_to_norm(PAL), PAL));
812         add_item(new ChannelEditEditNormItem(thread, thread->value_to_norm(SECAM), SECAM));
813         return 0;
817 ChannelEditEditNormItem::ChannelEditEditNormItem(ChannelEditEditThread *thread, char *text, int value)
818  : BC_MenuItem(text)
820         this->value = value;
821         this->thread = thread;
823 ChannelEditEditNormItem::~ChannelEditEditNormItem()
826 int ChannelEditEditNormItem::handle_event()
828         get_popup_menu()->set_text(get_text());
829         thread->set_norm(value);
833 ChannelEditEditFreqtable::ChannelEditEditFreqtable(int x, int y, ChannelEditEditThread *thread)
834  : BC_PopupMenu(x, y, 150, thread->value_to_freqtable(thread->new_channel.freqtable))
836         this->thread = thread;
838 ChannelEditEditFreqtable::~ChannelEditEditFreqtable()
841 int ChannelEditEditFreqtable::add_items()
843         add_item(new ChannelEditEditFreqItem(thread, thread->value_to_freqtable(NTSC_BCAST), NTSC_BCAST));
844         add_item(new ChannelEditEditFreqItem(thread, thread->value_to_freqtable(NTSC_CABLE), NTSC_CABLE));
845         add_item(new ChannelEditEditFreqItem(thread, thread->value_to_freqtable(NTSC_HRC), NTSC_HRC));
846         add_item(new ChannelEditEditFreqItem(thread, thread->value_to_freqtable(NTSC_BCAST_JP), NTSC_BCAST_JP));
847         add_item(new ChannelEditEditFreqItem(thread, thread->value_to_freqtable(NTSC_CABLE_JP), NTSC_CABLE_JP));
848         add_item(new ChannelEditEditFreqItem(thread, thread->value_to_freqtable(PAL_AUSTRALIA), PAL_AUSTRALIA));
849         add_item(new ChannelEditEditFreqItem(thread, thread->value_to_freqtable(PAL_EUROPE), PAL_EUROPE));
850         add_item(new ChannelEditEditFreqItem(thread, thread->value_to_freqtable(PAL_E_EUROPE), PAL_E_EUROPE));
851         add_item(new ChannelEditEditFreqItem(thread, thread->value_to_freqtable(PAL_ITALY), PAL_ITALY));
852         add_item(new ChannelEditEditFreqItem(thread, thread->value_to_freqtable(PAL_IRELAND), PAL_IRELAND));
853         add_item(new ChannelEditEditFreqItem(thread, thread->value_to_freqtable(PAL_NEWZEALAND), PAL_NEWZEALAND));
854         return 0;
857 ChannelEditEditFreqItem::ChannelEditEditFreqItem(ChannelEditEditThread *thread, char *text, int value)
858  : BC_MenuItem(text)
860         this->value = value;
861         this->thread = thread;
863 ChannelEditEditFreqItem::~ChannelEditEditFreqItem()
866 int ChannelEditEditFreqItem::handle_event()
868         get_popup_menu()->set_text(get_text());
869         thread->set_freqtable(value);
874 ChannelEditEditFine::ChannelEditEditFine(int x, int y, ChannelEditEditThread *thread)
875  : BC_ISlider(x, 
876                 y, 
877                 0, 
878                 240, 
879                 240, 
880                 -100, 
881                 100, 
882                 thread->new_channel.fine_tune)
884         this->thread = thread;
886 ChannelEditEditFine::~ChannelEditEditFine()
889 int ChannelEditEditFine::handle_event()
891         thread->new_channel.fine_tune = get_value();
892         thread->set_device();
896 // ========================== picture quality
898 ChannelEditPictureThread::ChannelEditPictureThread(ChannelPicker *channel_picker, ChannelEditWindow *window)
899  : Thread()
901         this->channel_picker = channel_picker;
902         this->window = window;
903         in_progress = 0;
904         edit_window = 0;
906 ChannelEditPictureThread::~ChannelEditPictureThread()
910 int ChannelEditPictureThread::edit_picture()
912         if(in_progress) return 1;
913         in_progress = 1;
914         completion.lock();
915         set_synchronous(0);
916         Thread::start();
919 void ChannelEditPictureThread::run()
921         ChannelEditPictureWindow edit_window(this, channel_picker);
922         edit_window.create_objects();
923         this->edit_window = &edit_window;
924         int result = edit_window.run_window();
925         this->edit_window = 0;
926         completion.unlock();
927         in_progress = 0;
930 int ChannelEditPictureThread::close_threads()
932         if(edit_window)
933         {
934                 edit_window->set_done(1);
935                 completion.lock();
936                 completion.unlock();
937         }
941 ChannelEditPictureWindow::ChannelEditPictureWindow(ChannelEditPictureThread *thread, ChannelPicker *channel_picker)
942  : BC_Window(PROGRAM_NAME ": Picture", 
943         channel_picker->mwindow->gui->get_abs_cursor_x() - 200, 
944         channel_picker->mwindow->gui->get_abs_cursor_y() - 220, 
945         200, 
946         220, 
947         200, 
948         220)
950         this->thread = thread;
951         this->channel_picker = channel_picker;
953 ChannelEditPictureWindow::~ChannelEditPictureWindow()
956 int ChannelEditPictureWindow::create_objects()
958         int x = 10, y = 10;
959         add_subwindow(new BC_Title(x, y + 10, _("Brightness:")));
960         add_subwindow(new ChannelEditBright(x + 100, y, channel_picker, channel_picker->get_brightness()));
961         y += 30;
962         add_subwindow(new BC_Title(x, y + 10, _("Contrast:")));
963         add_subwindow(new ChannelEditContrast(x + 135, y, channel_picker, channel_picker->get_contrast()));
964         y += 30;
965         add_subwindow(new BC_Title(x, y + 10, _("Color:")));
966         add_subwindow(new ChannelEditColor(x + 100, y, channel_picker, channel_picker->get_color()));
967         y += 30;
968         add_subwindow(new BC_Title(x, y + 10, _("Hue:")));
969         add_subwindow(new ChannelEditHue(x + 135, y, channel_picker, channel_picker->get_hue()));
970         y += 30;
971         add_subwindow(new BC_Title(x, y + 10, _("Whiteness:")));
972         add_subwindow(new ChannelEditWhiteness(x + 100, y, channel_picker, channel_picker->get_whiteness()));
973         y += 50;
974         x += 70;
975         add_subwindow(new BC_OKButton(x, y));
976         return 0;
981 ChannelEditBright::ChannelEditBright(int x, int y, ChannelPicker *channel_picker, int value)
982  : BC_IPot(x, 
983                 y, 
984                 value, 
985                 -100, 
986                 100)
988         this->channel_picker = channel_picker;
990 ChannelEditBright::~ChannelEditBright() {}
991 int ChannelEditBright::handle_event()
993         channel_picker->set_brightness(get_value());
996 ChannelEditContrast::ChannelEditContrast(int x, int y, ChannelPicker *channel_picker, int value)
997  : BC_IPot(x, 
998                 y, 
999                 value, 
1000                 -100, 
1001                 100)
1003         this->channel_picker = channel_picker;
1005 ChannelEditContrast::~ChannelEditContrast() {}
1006 int ChannelEditContrast::handle_event()
1008         channel_picker->set_contrast(get_value());
1011 ChannelEditColor::ChannelEditColor(int x, int y, ChannelPicker *channel_picker, int value)
1012  : BC_IPot(x, 
1013                 y, 
1014                 value, 
1015                 -100, 
1016                 100)
1018         this->channel_picker = channel_picker;
1020 ChannelEditColor::~ChannelEditColor() {}
1021 int ChannelEditColor::handle_event()
1023         channel_picker->set_color(get_value());
1026 ChannelEditHue::ChannelEditHue(int x, int y, ChannelPicker *channel_picker, int value)
1027  : BC_IPot(x, 
1028                 y, 
1029                 value, 
1030                 -100, 
1031                 100)
1033         this->channel_picker = channel_picker;
1035 ChannelEditHue::~ChannelEditHue() {}
1036 int ChannelEditHue::handle_event()
1038         channel_picker->set_hue(get_value());
1041 ChannelEditWhiteness::ChannelEditWhiteness(int x, int y, ChannelPicker *channel_picker, int value)
1042  : BC_IPot(x, 
1043                 y, 
1044                 value, 
1045                 -100, 
1046                 100)
1048         this->channel_picker = channel_picker;
1050 ChannelEditWhiteness::~ChannelEditWhiteness() {}
1051 int ChannelEditWhiteness::handle_event()
1053         channel_picker->set_whiteness(get_value());