Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

channeledit.C

Go to the documentation of this file.
00001 #include "batch.h"
00002 #include "channel.h"
00003 #include "channeldb.h"
00004 #include "channeledit.h"
00005 #include "channelpicker.h"
00006 #include "chantables.h"
00007 #include "clip.h"
00008 #include "condition.h"
00009 #include "language.h"
00010 #include "mainprogress.h"
00011 #include "mwindow.h"
00012 #include "mwindowgui.h"
00013 #include "picture.h"
00014 #include "record.h"
00015 #include "recordgui.h"
00016 #include "theme.h"
00017 #include "videodevice.h"
00018 #include <ctype.h>
00019 #include <string.h>
00020 #include <unistd.h>
00021 
00022 
00023 ChannelEditThread::ChannelEditThread(MWindow *mwindow, 
00024         ChannelPicker *channel_picker,
00025         ChannelDB *channeldb,
00026         Record *record)
00027  : Thread()
00028 {
00029         this->channel_picker = channel_picker;
00030         this->mwindow = mwindow;
00031         this->channeldb = channeldb;
00032         this->record = record;
00033         in_progress = 0;
00034         this->window = 0;
00035         new_channels = new ChannelDB;
00036         completion = new Condition(1, "ChannelEditThread::completion");
00037         scan_thread = 0;
00038 }
00039 ChannelEditThread::~ChannelEditThread()
00040 {
00041         channel_picker->get_subwindow()->unlock_window();
00042         delete scan_thread;
00043         channel_picker->get_subwindow()->lock_window("ChannelEditThread::~ChannelEditThread");
00044         delete new_channels;
00045         delete completion;
00046 }
00047 
00048 void ChannelEditThread::run()
00049 {
00050         int i;
00051 
00052         if(in_progress) 
00053         {
00054                 if(window)
00055                 {
00056                         window->lock_window("ChannelEditThread::run");
00057                         window->raise_window(1);
00058                         window->unlock_window();
00059                 }
00060                 return;
00061         }
00062         in_progress = 1;
00063         completion->lock("ChannelEditThread::run");
00064 
00065 // Copy master channel list to temporary.
00066         new_channels->copy_from(channel_picker->channeldb);
00067         current_channel = channel_picker->get_current_channel_number();
00068 //printf("ChannelEditThread::run 1 %d\n", current_channel);
00069 
00070 // Run the channel list window using the temporary list.
00071         ChannelEditWindow window(mwindow, this, channel_picker);
00072         window.create_objects();
00073         this->window = &window;
00074         int result = window.run_window();
00075         this->window = 0;
00076 
00077         if(!result)
00078         {
00079 // Copy new channels to master list
00080                 channel_picker->channeldb->clear();
00081                 
00082                 channel_picker->channeldb->copy_from(new_channels);
00083                 channel_picker->update_channel_list();
00084 
00085                 if(record)
00086                 {
00087                         record->record_gui->lock_window("ChannelEditThread::run");
00088                         record->record_gui->update_batch_sources();
00089 
00090                         record->set_channel(current_channel);
00091                         record->record_gui->unlock_window();
00092                         record->save_defaults();
00093                         record->channeldb->save(record->get_channeldb_prefix());
00094                 }
00095                 mwindow->save_defaults();
00096         }
00097         else
00098         {
00099 // Rejected.
00100                 if(record)
00101                 {
00102                         record->set_channel(record->get_editing_batch()->channel);
00103                 }
00104         }
00105 
00106         window.edit_thread->close_threads();
00107         window.picture_thread->close_threads();
00108 
00109         completion->unlock();
00110         in_progress = 0;
00111 
00112 }
00113 
00114 int ChannelEditThread::close_threads()
00115 {
00116         if(in_progress && window)
00117         {
00118                 window->edit_thread->close_threads();
00119                 window->picture_thread->close_threads();
00120                 window->set_done(1);
00121                 completion->lock("ChannelEditThread::close_threads");
00122                 completion->unlock();
00123         }
00124 }
00125 
00126 char *ChannelEditThread::value_to_freqtable(int value)
00127 {
00128         switch(value)
00129         {
00130                 case NTSC_BCAST:
00131                         return _("NTSC_BCAST");
00132                         break;
00133                 case NTSC_CABLE:
00134                         return _("NTSC_CABLE");
00135                         break;
00136                 case NTSC_HRC:
00137                         return _("NTSC_HRC");
00138                         break;
00139                 case NTSC_BCAST_JP:
00140                         return _("NTSC_BCAST_JP");
00141                         break;
00142                 case NTSC_CABLE_JP:
00143                         return _("NTSC_CABLE_JP");
00144                         break;
00145                 case PAL_AUSTRALIA:
00146                         return _("PAL_AUSTRALIA");
00147                         break;
00148                 case PAL_EUROPE:
00149                         return _("PAL_EUROPE");
00150                         break;
00151                 case PAL_E_EUROPE:
00152                         return _("PAL_E_EUROPE");
00153                         break;
00154                 case PAL_ITALY:
00155                         return _("PAL_ITALY");
00156                         break;
00157                 case PAL_IRELAND:
00158                         return _("PAL_IRELAND");
00159                         break;
00160                 case PAL_NEWZEALAND:
00161                         return _("PAL_NEWZEALAND");
00162                         break;
00163         }
00164 }
00165 
00166 char* ChannelEditThread::value_to_norm(int value)
00167 {
00168         switch(value)
00169         {
00170                 case NTSC:
00171                         return _("NTSC");
00172                         break;
00173                 case PAL:
00174                         return _("PAL");
00175                         break;
00176                 case SECAM:
00177                         return _("SECAM");
00178                         break;
00179         }
00180 }
00181 
00182 char* ChannelEditThread::value_to_input(int value)
00183 {
00184         if(channel_picker->get_video_inputs()->total > value)
00185                 return channel_picker->get_video_inputs()->values[value]->device_name;
00186         else
00187                 return _("None");
00188 }
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 ChannelEditWindow::ChannelEditWindow(MWindow *mwindow, 
00197         ChannelEditThread *thread, 
00198         ChannelPicker *channel_picker)
00199  : BC_Window(PROGRAM_NAME ": Channels", 
00200         mwindow->gui->get_abs_cursor_x(1) - 330, 
00201         mwindow->gui->get_abs_cursor_y(1), 
00202         350, 
00203         400, 
00204         350, 
00205         400,
00206         0,
00207         0,
00208         1)
00209 {
00210         this->thread = thread;
00211         this->channel_picker = channel_picker;
00212         this->mwindow = mwindow;
00213         scan_confirm_thread = 0;
00214 }
00215 ChannelEditWindow::~ChannelEditWindow()
00216 {
00217         int i;
00218         for(i = 0; i < channel_list.total; i++)
00219         {
00220                 delete channel_list.values[i];
00221         }
00222         channel_list.remove_all();
00223         delete edit_thread;
00224         delete picture_thread;
00225         delete scan_confirm_thread;
00226 }
00227 
00228 int ChannelEditWindow::create_objects()
00229 {
00230         int x = 10, y = 10, i;
00231         char string[1024];
00232 
00233 // Create channel list
00234         for(i = 0; i < thread->new_channels->size(); i++)
00235         {
00236                 channel_list.append(new BC_ListBoxItem(thread->new_channels->get(i)->title));
00237         }
00238 
00239         add_subwindow(list_box = new ChannelEditList(mwindow, this, x, y));
00240         x += 200;
00241         if(thread->record)
00242         {
00243                 add_subwindow(new ChannelEditSelect(mwindow, this, x, y));
00244                 y += 30;
00245         }
00246         add_subwindow(new ChannelEditAdd(mwindow, this, x, y));
00247         y += 30;
00248         add_subwindow(new ChannelEdit(mwindow, this, x, y));
00249         y += 30;
00250         add_subwindow(new ChannelEditMoveUp(mwindow, this, x, y));
00251         y += 30;
00252         add_subwindow(new ChannelEditMoveDown(mwindow, this, x, y));
00253         y += 30;
00254         add_subwindow(new ChannelEditSort(mwindow, this, x, y));
00255         y += 30;
00256 
00257         Channel *channel_usage = channel_picker->get_channel_usage();
00258         if(channel_usage->has_scanning)
00259         {
00260                 add_subwindow(new ChannelEditScan(mwindow, this, x, y));
00261                 y += 30;
00262         }
00263         add_subwindow(new ChannelEditDel(mwindow, this, x, y));
00264         y += 30;
00265         add_subwindow(new ChannelEditPicture(mwindow, this, x, y));
00266         y += 100;
00267         x = 10;
00268         add_subwindow(new BC_OKButton(this));
00269         x += 150;
00270         add_subwindow(new BC_CancelButton(this));
00271 
00272 
00273         edit_thread = new ChannelEditEditThread(this, 
00274                 channel_picker, 
00275                 thread->record);
00276         picture_thread = new ChannelEditPictureThread(channel_picker, this);
00277         show_window();
00278         return 0;
00279 }
00280 
00281 int ChannelEditWindow::close_event()
00282 {
00283         set_done(0);
00284 }
00285 
00286 int ChannelEditWindow::add_channel()
00287 {
00288         Channel *new_channel;
00289         Channel *prev_channel = 0;
00290 
00291 // Create new channel
00292         new_channel = new Channel;
00293 
00294 // Reuse parameters from previous channel
00295         if(thread->new_channels->size()) 
00296         {
00297                 prev_channel = thread->new_channels->get(
00298                                 thread->new_channels->size() - 1);
00299                 new_channel->copy_settings(prev_channel);
00300         }
00301         else
00302 // Use default channel parameters
00303         if(thread->record)
00304         {
00305                 new_channel->copy_settings(thread->record->master_channel);
00306         }
00307 
00308 // Copy device usage.  Need the same thing for playback.
00309         if(thread->record)
00310         {
00311                 new_channel->copy_usage(thread->record->master_channel);
00312         }
00313 
00314 // Add to channel table
00315         channel_list.append(new BC_ListBoxItem(new_channel->title));
00316         thread->new_channels->append(new_channel);
00317         update_list();
00318 
00319 // Start common routing
00320         edit_thread->edit_channel(new_channel, 0);
00321         return 0;
00322 }
00323 
00324 int ChannelEditWindow::update_list()
00325 {
00326 // Create channel list
00327         channel_list.remove_all_objects();
00328         for(int i = 0; i < thread->new_channels->size(); i++)
00329         {
00330                 channel_list.append(
00331                         new BC_ListBoxItem(
00332                                 thread->new_channels->get(i)->title));
00333         }
00334 
00335         list_box->update(&channel_list, 0, 0, 1, list_box->get_yposition());
00336 }
00337 
00338 int ChannelEditWindow::update_list(Channel *channel)
00339 {
00340         int i;
00341         for(i = 0; i < thread->new_channels->size(); i++)
00342                 if(thread->new_channels->get(i) == channel) break;
00343 
00344         if(i < thread->new_channels->size())
00345         {
00346                 channel_list.values[i]->set_text(channel->title);
00347         }
00348 
00349         update_list();
00350 }
00351 
00352 
00353 int ChannelEditWindow::edit_channel()
00354 {
00355         if(list_box->get_selection_number(0, 0) > -1)
00356         {
00357                 thread->current_channel = list_box->get_selection_number(0, 0);
00358                 edit_thread->edit_channel(
00359                         thread->new_channels->get(
00360                                 list_box->get_selection_number(0, 0)), 
00361                         1);
00362         }
00363 }
00364 
00365 int ChannelEditWindow::edit_picture()
00366 {
00367         picture_thread->edit_picture();
00368 }
00369 
00370 void ChannelEditWindow::scan_confirm()
00371 {
00372         thread->scan_params.load_defaults(mwindow->defaults);
00373         if(!scan_confirm_thread) scan_confirm_thread = new ConfirmScanThread(this);
00374         unlock_window();
00375         scan_confirm_thread->start();
00376         lock_window("ChannelEditWindow::scan_confirm");
00377 }
00378 
00379 void ChannelEditWindow::scan()
00380 {
00381         thread->new_channels->clear();
00382         update_list();
00383 
00384         if(!thread->scan_thread) thread->scan_thread = new ScanThread(thread);
00385         thread->scan_thread->start();
00386 }
00387 
00388 
00389 void ChannelEditWindow::sort()
00390 {
00391         int done = 0;
00392         while(!done)
00393         {
00394                 done = 1;
00395                 for(int i = 0; i < thread->new_channels->size() - 1; i++)
00396                 {
00397                         Channel *channel1 = thread->new_channels->get(i);
00398                         Channel *channel2 = thread->new_channels->get(i + 1);
00399                         int is_num = 1;
00400                         for(int j = 0; j < strlen(channel1->title); j++)
00401                                 if(!isdigit(channel1->title[j])) is_num = 0;
00402                         for(int j = 0; j < strlen(channel2->title); j++)
00403                                 if(!isdigit(channel2->title[j])) is_num = 0;
00404                         if(is_num && atoi(channel1->title) > atoi(channel2->title) ||
00405                                 !is_num && strcasecmp(channel2->title, channel1->title) < 0)
00406                         {
00407                                 thread->new_channels->set(i, channel2);
00408                                 thread->new_channels->set(i + 1, channel1);
00409                                 done = 0;
00410                         }
00411                 }
00412         }
00413         update_list();
00414 }
00415 
00416 
00417 int ChannelEditWindow::delete_channel(int number)
00418 {
00419         delete thread->new_channels->get(number);
00420         channel_list.remove_number(number);
00421         thread->new_channels->remove_number(number);
00422         update_list();
00423 }
00424 
00425 int ChannelEditWindow::delete_channel(Channel *channel)
00426 {
00427         int i;
00428         for(i = 0; i < thread->new_channels->size(); i++)
00429         {
00430                 if(thread->new_channels->get(i) == channel)
00431                 {
00432                         break;
00433                 }
00434         }
00435         if(i < thread->new_channels->size()) delete_channel(i);
00436         return 0;
00437 }
00438 
00439 int ChannelEditWindow::move_channel_up()
00440 {
00441         if(list_box->get_selection_number(0, 0) > -1)
00442         {
00443                 int number2 = list_box->get_selection_number(0, 0);
00444                 int number1 = number2 - 1;
00445                 Channel *temp;
00446                 BC_ListBoxItem *temp_text;
00447 
00448                 if(number1 < 0) number1 = thread->new_channels->size() - 1;
00449 
00450                 temp = thread->new_channels->get(number1);
00451                 thread->new_channels->set(number1, thread->new_channels->get(number2));
00452                 thread->new_channels->set(number2, temp);
00453 
00454                 temp_text = channel_list.values[number1];
00455                 channel_list.values[number1] = channel_list.values[number2];
00456                 channel_list.values[number2] = temp_text;
00457                 list_box->update(&channel_list, 
00458                         0, 
00459                         0, 
00460                         1, 
00461                         list_box->get_xposition(), 
00462                         list_box->get_yposition(), 
00463                         number1,
00464                         1);
00465         }
00466         return 0;
00467 }
00468 
00469 int ChannelEditWindow::move_channel_down()
00470 {
00471         if(list_box->get_selection_number(0, 0) > -1)
00472         {
00473                 int number2 = list_box->get_selection_number(0, 0);
00474                 int number1 = number2 + 1;
00475                 Channel *temp;
00476                 BC_ListBoxItem *temp_text;
00477 
00478                 if(number1 > thread->new_channels->size() - 1) number1 = 0;
00479 
00480                 temp = thread->new_channels->get(number1);
00481                 thread->new_channels->set(number1, thread->new_channels->get(number2));
00482                 thread->new_channels->set(number2, temp);
00483                 temp_text = channel_list.values[number1];
00484                 channel_list.values[number1] = channel_list.values[number2];
00485                 channel_list.values[number2] = temp_text;
00486                 list_box->update(&channel_list, 
00487                         0, 
00488                         0, 
00489                         1, 
00490                         list_box->get_xposition(), 
00491                         list_box->get_yposition(), 
00492                         number1,
00493                         1);
00494         }
00495         return 0;
00496 }
00497 
00498 int ChannelEditWindow::change_channel_from_list(int channel_number)
00499 {
00500         Channel *channel;
00501         if(channel_number > -1 && channel_number < thread->new_channels->size())
00502         {
00503                 thread->current_channel = channel_number;
00504                 channel_picker->set_channel(thread->new_channels->get(channel_number));
00505         }
00506 }
00507 
00508 ChannelEditSelect::ChannelEditSelect(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
00509  : BC_GenericButton(x, y, _("Select"))
00510 {
00511         this->window = window;
00512 }
00513 ChannelEditSelect::~ChannelEditSelect()
00514 {
00515 }
00516 int ChannelEditSelect::handle_event()
00517 {
00518         window->change_channel_from_list(
00519                 window->list_box->get_selection_number(0, 0));
00520 }
00521 
00522 ChannelEditAdd::ChannelEditAdd(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
00523  : BC_GenericButton(x, y, _("Add..."))
00524 {
00525         this->window = window;
00526 }
00527 ChannelEditAdd::~ChannelEditAdd()
00528 {
00529 }
00530 int ChannelEditAdd::handle_event()
00531 {
00532         window->add_channel();
00533 }
00534 
00535 ChannelEditList::ChannelEditList(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
00536  : BC_ListBox(x, 
00537                         y, 
00538                         185, 
00539                         window->get_h() - BC_OKButton::calculate_h() - y - 10, 
00540                         LISTBOX_TEXT, 
00541                         &(window->channel_list))
00542 {
00543         this->window = window;
00544 }
00545 ChannelEditList::~ChannelEditList()
00546 {
00547 }
00548 int ChannelEditList::handle_event()
00549 {
00550         window->edit_channel();
00551 }
00552 
00553 ChannelEditMoveUp::ChannelEditMoveUp(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
00554  : BC_GenericButton(x, y, _("Move up"))
00555 {
00556         this->window = window;
00557 }
00558 ChannelEditMoveUp::~ChannelEditMoveUp()
00559 {
00560 }
00561 int ChannelEditMoveUp::handle_event()
00562 {
00563         lock_window("ChannelEditMoveUp::handle_event");
00564         window->move_channel_up();
00565         unlock_window();
00566 }
00567 
00568 ChannelEditMoveDown::ChannelEditMoveDown(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
00569  : BC_GenericButton(x, y, _("Move down"))
00570 {
00571         this->window = window;
00572 }
00573 ChannelEditMoveDown::~ChannelEditMoveDown()
00574 {
00575 }
00576 int ChannelEditMoveDown::handle_event()
00577 {
00578         lock_window("ChannelEditMoveDown::handle_event");
00579         window->move_channel_down();
00580         unlock_window();
00581 }
00582 
00583 ChannelEditSort::ChannelEditSort(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
00584  : BC_GenericButton(x, y, _("Sort"))
00585 {
00586         this->window = window;
00587 }
00588 int ChannelEditSort::handle_event()
00589 {
00590         lock_window("ChannelEditSort::handle_event");
00591         window->sort();
00592         unlock_window();
00593 }
00594 
00595 ChannelEditScan::ChannelEditScan(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
00596  : BC_GenericButton(x, y, _("Scan"))
00597 {
00598         this->window = window;
00599 }
00600 int ChannelEditScan::handle_event()
00601 {
00602         window->scan_confirm();
00603 }
00604 
00605 ChannelEditDel::ChannelEditDel(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
00606  : BC_GenericButton(x, y, _("Delete"))
00607 {
00608         this->window = window;
00609 }
00610 ChannelEditDel::~ChannelEditDel()
00611 {
00612 }
00613 int ChannelEditDel::handle_event()
00614 {
00615         if(window->list_box->get_selection_number(0, 0) > -1) window->delete_channel(window->list_box->get_selection_number(0, 0));
00616 }
00617 
00618 ChannelEdit::ChannelEdit(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
00619  : BC_GenericButton(x, y, _("Edit..."))
00620 {
00621         this->window = window;
00622 }
00623 ChannelEdit::~ChannelEdit()
00624 {
00625 }
00626 int ChannelEdit::handle_event()
00627 {
00628         window->edit_channel();
00629 }
00630 
00631 ChannelEditPicture::ChannelEditPicture(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
00632  : BC_GenericButton(x, y, _("Picture..."))
00633 {
00634         this->window = window;
00635 }
00636 ChannelEditPicture::~ChannelEditPicture()
00637 {
00638 }
00639 int ChannelEditPicture::handle_event()
00640 {
00641         window->edit_picture();
00642 }
00643 
00644 
00645 
00646 
00647 
00648 
00649 
00650 
00651 
00652 
00653 
00654 
00655 // ========================= confirm overwrite by channel scannin
00656 
00657 
00658 ConfirmScan::ConfirmScan(ChannelEditWindow *gui, int x, int y)
00659  : BC_Window(PROGRAM_NAME ": Scan confirm",
00660         x,
00661         y,
00662         350,
00663         BC_OKButton::calculate_h() + 130,
00664         0,
00665         0,
00666         0,
00667         0,
00668         1)
00669 {
00670         this->gui = gui;
00671 }
00672 
00673 void ConfirmScan::create_objects()
00674 {
00675         int x = 10, y = 10;
00676         int y2 = 0, x2 = 0;
00677         BC_Title *title;
00678         add_subwindow(title = new BC_Title(x, y, _("Set parameters for channel scanning.")));
00679         y += title->get_h() + 10;
00680         y2 = y;
00681 
00682         add_subwindow(title = new BC_Title(x, y, _("Frequency table:")));
00683         x2 = title->get_w();
00684         y += BC_PopupMenu::calculate_h();
00685         add_subwindow(title = new BC_Title(x, y, _("Norm:")));
00686         x2 = MAX(x2, title->get_w());
00687         y += BC_PopupMenu::calculate_h();
00688         add_subwindow(title = new BC_Title(x, y, _("Input:")));
00689         x2 = MAX(x2, title->get_w());
00690         y += BC_PopupMenu::calculate_h();
00691         x2 += x + 5;
00692 
00693         y = y2;
00694         x = x2;
00695         ChannelEditEditFreqtable *table;
00696         add_subwindow(table = new ChannelEditEditFreqtable(x, 
00697                 y, 
00698                 0, 
00699                 gui->thread));
00700         table->add_items();
00701         y += table->get_h() + 10;
00702 
00703         ChannelEditEditNorm *norm;
00704         add_subwindow(norm = new ChannelEditEditNorm(x, 
00705                 y, 
00706                 0,
00707                 gui->thread));
00708         norm->add_items();
00709         y += norm->get_h() + 10;
00710 
00711         ChannelEditEditInput *input;
00712         add_subwindow(input = new ChannelEditEditInput(x, 
00713                 y, 
00714                 0, 
00715                 gui->thread));
00716         input->add_items();
00717 
00718 
00719         add_subwindow(new BC_OKButton(this));
00720         add_subwindow(new BC_CancelButton(this));
00721         show_window();
00722 }
00723 
00724 
00725 
00726 
00727 
00728 
00729 
00730 ConfirmScanThread::ConfirmScanThread(ChannelEditWindow *gui)
00731  : BC_DialogThread()
00732 {
00733         this->gui = gui;
00734 }
00735 
00736 void ConfirmScanThread::handle_done_event(int result)
00737 {
00738         gui->thread->scan_params.save_defaults(gui->thread->mwindow->defaults);
00739         if(!result)
00740         {
00741                 get_gui()->hide_window();
00742                 gui->lock_window("ConfirmScanThread::handle_done_event");
00743                 gui->scan();
00744                 gui->unlock_window();
00745         }
00746 }
00747 
00748 BC_Window* ConfirmScanThread::new_gui()
00749 {
00750         int x = gui->get_abs_cursor_x(1);
00751         int y = gui->get_abs_cursor_y(1);
00752         ConfirmScan *result = new ConfirmScan(gui, x, y);
00753         result->create_objects();
00754         return result;
00755 }
00756 
00757 
00758 
00759 
00760 
00761 
00762 ScanThread::ScanThread(ChannelEditThread *edit)
00763  : Thread(1, 0, 0)
00764 {
00765         this->edit = edit;
00766         interrupt = 0;
00767         progress = 0;
00768 }
00769 
00770 ScanThread::~ScanThread()
00771 {
00772         interrupt = 1;
00773         Thread::join();
00774 
00775         delete progress;
00776 }
00777 
00778 
00779 void ScanThread::start()
00780 {
00781 // Cancel previous job
00782         interrupt = 1;
00783         Thread::join();
00784         delete progress;
00785         interrupt = 0;
00786 
00787 
00788         progress = edit->mwindow->mainprogress->start_progress("Scanning", 
00789                 chanlists[edit->scan_params.freqtable].count, 
00790                 1);
00791         Thread::start();
00792 }
00793 
00794 void ScanThread::run()
00795 {
00796         for(int i = 0; 
00797                 i < chanlists[edit->scan_params.freqtable].count &&
00798                         !interrupt && 
00799                         !progress->is_cancelled();
00800                 i++)
00801         {
00802                 edit->scan_params.entry = i;
00803                 char string[BCTEXTLEN];
00804                 sprintf(edit->scan_params.title, 
00805                         "%s", 
00806                         chanlists[edit->scan_params.freqtable].list[i].name);
00807                 sprintf(string, 
00808                         "Scanning %s", 
00809                         edit->scan_params.title);
00810                 progress->update_title(string);
00811                 progress->update(i);
00812                 edit->channel_picker->set_channel(&edit->scan_params);
00813 
00814 
00815                 sleep(2);
00816 
00817             int got_signal = edit->channel_picker->has_signal();
00818                 if(got_signal)
00819                 {
00820                         Channel *new_channel = new Channel;
00821                         new_channel->copy_usage(&edit->scan_params);
00822                         new_channel->copy_settings(&edit->scan_params);
00823                         edit->window->lock_window("ScanThread::run");
00824                         edit->new_channels->append(new_channel);
00825                         edit->window->update_list();
00826                         edit->window->unlock_window();
00827                 }
00828         }
00829         delete progress;
00830         progress = 0;
00831 }
00832 
00833 
00834 
00835 
00836 
00837 
00838 
00839 // ================================= Edit a single channel
00840 
00841 
00842 
00843 ChannelEditEditThread::ChannelEditEditThread(ChannelEditWindow *window, 
00844         ChannelPicker *channel_picker,
00845         Record *record)
00846  : Thread()
00847 {
00848         this->window = window;
00849         this->channel_picker = channel_picker;
00850         this->record = record;
00851         in_progress = 0;
00852         edit_window = 0;
00853         editing = 0;
00854         completion = new Condition(1, "ChannelEditEditThread::completion");
00855 }
00856 
00857 ChannelEditEditThread::~ChannelEditEditThread()
00858 {
00859         delete completion;
00860 }
00861 
00862 int ChannelEditEditThread::close_threads()
00863 {
00864         if(edit_window)
00865         {
00866                 edit_window->set_done(1);
00867                 completion->lock("ChannelEditEditThread::close_threads");
00868                 completion->unlock();
00869         }
00870 }
00871 
00872 int ChannelEditEditThread::edit_channel(Channel *channel, int editing)
00873 {
00874         if(in_progress) 
00875         {
00876                 edit_window->lock_window("ChannelEditEditThread::edit_channel");
00877                 edit_window->raise_window(1);
00878                 edit_window->unlock_window();
00879                 return 1;
00880         }
00881         in_progress = 1;
00882 
00883 // Copy the channel to edit into a temporary
00884         completion->lock("ChannelEditEditThread::edit_channel");
00885         this->editing = editing;
00886         this->output_channel = channel;
00887         new_channel.copy_settings(output_channel);
00888         new_channel.copy_usage(output_channel);
00889 
00890         if(editing && new_channel.title[0])
00891                 user_title = 1;
00892         else
00893                 user_title = 0;
00894         set_synchronous(0);
00895         Thread::start();
00896 }
00897 
00898 
00899 void ChannelEditEditThread::set_device()
00900 {
00901         channel_picker->set_channel(&new_channel);
00902 }
00903 
00904 int ChannelEditEditThread::change_source(char *source_name)
00905 {
00906         int i, result;
00907         for(i = 0; i < chanlists[new_channel.freqtable].count; i++)
00908         {
00909                 if(!strcasecmp(chanlists[new_channel.freqtable].list[i].name, source_name))
00910                 {
00911                         new_channel.entry = i;
00912                         i = chanlists[new_channel.freqtable].count;
00913                         set_device();
00914                 }
00915         }
00916         if(!user_title)
00917         {
00918                 strcpy(new_channel.title, source_name);
00919                 if(edit_window->title_text)
00920                 {
00921                         edit_window->title_text->update(source_name);
00922                 }
00923         }
00924 }
00925 
00926 int ChannelEditEditThread::source_up()
00927 {
00928         new_channel.entry++;
00929         if(new_channel.entry > chanlists[new_channel.freqtable].count - 1) new_channel.entry = 0;
00930         source_text->update(chanlists[new_channel.freqtable].list[new_channel.entry].name);
00931         set_device();
00932 }
00933 
00934 int ChannelEditEditThread::source_down()
00935 {
00936         new_channel.entry--;
00937         if(new_channel.entry < 0) new_channel.entry = chanlists[new_channel.freqtable].count - 1;
00938         source_text->update(chanlists[new_channel.freqtable].list[new_channel.entry].name);
00939         set_device();
00940 }
00941 
00942 int ChannelEditEditThread::set_input(int value)
00943 {
00944         new_channel.input = value;
00945         set_device();
00946 }
00947 
00948 int ChannelEditEditThread::set_norm(int value)
00949 {
00950         new_channel.norm = value;
00951         set_device();
00952 }
00953 
00954 int ChannelEditEditThread::set_freqtable(int value)
00955 {
00956         new_channel.freqtable = value;
00957         if(new_channel.entry > chanlists[new_channel.freqtable].count - 1) new_channel.entry = 0;
00958         source_text->update(chanlists[new_channel.freqtable].list[new_channel.entry].name);
00959         set_device();
00960 }
00961 
00962 void ChannelEditEditThread::run()
00963 {
00964         ChannelEditEditWindow edit_window(this, window, channel_picker);
00965         edit_window.create_objects(&new_channel);
00966         this->edit_window = &edit_window;
00967         int result = edit_window.run_window();
00968         this->edit_window = 0;
00969 
00970 // Done editing channel.  Keep channel.
00971         if(!result)
00972         {
00973                 output_channel->copy_settings(&new_channel);
00974                 window->lock_window();
00975                 window->update_list(output_channel);
00976                 window->unlock_window();
00977         }
00978         else
00979         {
00980 // Discard channel.
00981                 if(!editing)
00982                 {
00983                         window->lock_window();
00984                         window->delete_channel(output_channel);
00985                         window->unlock_window();
00986                 }
00987         }
00988         editing = 0;
00989         completion->unlock();
00990         in_progress = 0;
00991 }
00992 
00993 ChannelEditEditWindow::ChannelEditEditWindow(ChannelEditEditThread *thread, 
00994         ChannelEditWindow *window,
00995         ChannelPicker *channel_picker)
00996  : BC_Window(PROGRAM_NAME ": Edit Channel", 
00997         channel_picker->mwindow->gui->get_abs_cursor_x(1), 
00998         channel_picker->mwindow->gui->get_abs_cursor_y(1), 
00999         390, 
01000         300, 
01001         390, 
01002         300,
01003         0,
01004         0,
01005         1)
01006 {
01007         this->channel_picker = channel_picker;
01008         this->window = window;
01009         this->thread = thread;
01010 }
01011 ChannelEditEditWindow::~ChannelEditEditWindow()
01012 {
01013 }
01014 int ChannelEditEditWindow::create_objects(Channel *channel)
01015 {
01016         this->new_channel = channel;
01017         Channel *channel_usage = channel_picker->get_channel_usage();
01018         title_text = 0;
01019 
01020         int x = 10, y = 10;
01021         if(!channel_usage ||
01022                 (!channel_usage->use_frequency && 
01023                 !channel_usage->use_fine && 
01024                 !channel_usage->use_norm && 
01025                 !channel_usage->use_input))
01026         {
01027                 add_subwindow(new BC_Title(x, y, "Device has no input selection."));
01028                 y += 30;
01029         }
01030         else
01031         {
01032                 add_subwindow(new BC_Title(x, y, _("Title:")));
01033                 add_subwindow(title_text = new ChannelEditEditTitle(x, y + 20, thread));
01034                 y += 50;
01035         }
01036 
01037         if(channel_usage->use_frequency)
01038         {
01039                 add_subwindow(new BC_Title(x, y, _("Channel:")));
01040                 y += 20;
01041                 add_subwindow(thread->source_text = new ChannelEditEditSource(x, y, thread));
01042                 add_subwindow(new ChannelEditEditSourceTumbler(x + 160, y, thread));
01043                 y += 40;
01044 
01045                 add_subwindow(new BC_Title(x, y, _("Frequency table:")));
01046                 ChannelEditEditFreqtable *table;
01047                 add_subwindow(table = new ChannelEditEditFreqtable(x + 130, 
01048                         y, 
01049                         thread, 
01050                         window->thread));
01051                 table->add_items();
01052                 y += 30;
01053         }
01054 
01055         if(channel_usage->use_fine)
01056         {
01057                 add_subwindow(new BC_Title(x, y, _("Fine:")));
01058                 add_subwindow(new ChannelEditEditFine(x + 130, y, thread));
01059                 y += 30;
01060         }
01061 
01062         if(channel_usage->use_norm)
01063         {
01064                 add_subwindow(new BC_Title(x, y, _("Norm:")));
01065                 ChannelEditEditNorm *norm;
01066                 add_subwindow(norm = new ChannelEditEditNorm(x + 130, 
01067                         y, 
01068                         thread,
01069                         window->thread));
01070                 norm->add_items();
01071                 y += 30;
01072         }
01073 
01074         if(channel_usage->use_input)
01075         {
01076                 add_subwindow(new BC_Title(x, y, _("Input:")));
01077                 ChannelEditEditInput *input;
01078                 add_subwindow(input = new ChannelEditEditInput(x + 130, 
01079                         y, 
01080                         thread, 
01081                         window->thread));
01082                 input->add_items();
01083                 y += 30;
01084         }
01085 
01086         add_subwindow(new BC_OKButton(this));
01087         x += 200;
01088         add_subwindow(new BC_CancelButton(this));
01089         show_window();
01090         return 0;
01091 }
01092 
01093 ChannelEditEditTitle::ChannelEditEditTitle(int x, 
01094         int y, 
01095         ChannelEditEditThread *thread)
01096  : BC_TextBox(x, y, 150, 1, thread->new_channel.title)
01097 {
01098         this->thread = thread;
01099 }
01100 ChannelEditEditTitle::~ChannelEditEditTitle()
01101 {
01102 }
01103 int ChannelEditEditTitle::handle_event()
01104 {
01105         if(strlen(get_text()) < 1024)
01106         {
01107                 strcpy(thread->new_channel.title, get_text());
01108         }
01109         if(get_text()[0]) 
01110                 thread->user_title = 1;
01111         else
01112                 thread->user_title = 0;
01113         return 1;
01114 }
01115 
01116 
01117 ChannelEditEditSource::ChannelEditEditSource(int x, int y, ChannelEditEditThread *thread)
01118  : BC_TextBox(x, y, 150, 1, chanlists[thread->new_channel.freqtable].list[thread->new_channel.entry].name)
01119 {
01120         this->thread = thread;
01121 }
01122 
01123 ChannelEditEditSource::~ChannelEditEditSource()
01124 {
01125 }
01126 int ChannelEditEditSource::handle_event()
01127 {
01128         thread->change_source(get_text());
01129 }
01130 
01131 
01132 ChannelEditEditSourceTumbler::ChannelEditEditSourceTumbler(int x, int y, ChannelEditEditThread *thread)
01133  : BC_Tumbler(x, y)
01134 {
01135         this->thread = thread;
01136 }
01137 ChannelEditEditSourceTumbler::~ChannelEditEditSourceTumbler()
01138 {
01139 }
01140 int ChannelEditEditSourceTumbler::handle_up_event()
01141 {
01142         thread->source_up();
01143 }
01144 int ChannelEditEditSourceTumbler::handle_down_event()
01145 {
01146         thread->source_down();
01147 }
01148 
01149 ChannelEditEditInput::ChannelEditEditInput(int x, 
01150         int y, 
01151         ChannelEditEditThread *thread, 
01152         ChannelEditThread *edit)
01153  : BC_PopupMenu(x, 
01154         y, 
01155         150, 
01156         edit->value_to_input(thread ? thread->new_channel.input : edit->scan_params.input))
01157 {
01158         this->thread = thread;
01159         this->edit = edit;
01160 }
01161 ChannelEditEditInput::~ChannelEditEditInput()
01162 {
01163 }
01164 int ChannelEditEditInput::add_items()
01165 {
01166         ArrayList<Channel*> *inputs;
01167         inputs = edit->channel_picker->get_video_inputs();
01168 
01169         if(inputs)
01170                 for(int i = 0; i < inputs->total; i++)
01171                 {
01172                         add_item(new ChannelEditEditInputItem(thread, 
01173                                 edit,
01174                                 inputs->values[i]->device_name, 
01175                                 i));
01176                 }
01177 }
01178 int ChannelEditEditInput::handle_event()
01179 {
01180         return 0;
01181 }
01182 
01183 ChannelEditEditInputItem::ChannelEditEditInputItem(ChannelEditEditThread *thread, 
01184         ChannelEditThread *edit,
01185         char *text, 
01186         int value)
01187  : BC_MenuItem(text)
01188 {
01189         this->thread = thread;
01190         this->edit = edit;
01191         this->value = value;
01192 }
01193 ChannelEditEditInputItem::~ChannelEditEditInputItem()
01194 {
01195 }
01196 int ChannelEditEditInputItem::handle_event()
01197 {
01198         get_popup_menu()->set_text(get_text());
01199         if(thread && !thread->user_title)
01200         {
01201                 strcpy(thread->new_channel.title, get_text());
01202                 if(thread->edit_window->title_text)
01203                 {
01204                         thread->edit_window->title_text->update(get_text());
01205                 }
01206         }
01207         if(thread) 
01208                 thread->set_input(value);
01209         else
01210                 edit->scan_params.input = value;
01211 }
01212 
01213 ChannelEditEditNorm::ChannelEditEditNorm(int x, 
01214         int y, 
01215         ChannelEditEditThread *thread,
01216         ChannelEditThread *edit)
01217  : BC_PopupMenu(x, 
01218         y, 
01219         100, 
01220         edit->value_to_norm(thread ? thread->new_channel.norm : edit->scan_params.norm))
01221 {
01222         this->thread = thread;
01223         this->edit = edit;
01224 }
01225 ChannelEditEditNorm::~ChannelEditEditNorm()
01226 {
01227 }
01228 int ChannelEditEditNorm::add_items()
01229 {
01230         add_item(new ChannelEditEditNormItem(thread, 
01231                 edit, 
01232                 edit->value_to_norm(NTSC), NTSC));
01233         add_item(new ChannelEditEditNormItem(thread, 
01234                 edit, 
01235                 edit->value_to_norm(PAL), PAL));
01236         add_item(new ChannelEditEditNormItem(thread, 
01237                 edit, 
01238                 edit->value_to_norm(SECAM), SECAM));
01239         return 0;
01240 }
01241 
01242 
01243 ChannelEditEditNormItem::ChannelEditEditNormItem(ChannelEditEditThread *thread, 
01244         ChannelEditThread *edit,
01245         char *text, 
01246         int value)
01247  : BC_MenuItem(text)
01248 {
01249         this->value = value;
01250         this->edit = edit;
01251         this->thread = thread;
01252 }
01253 ChannelEditEditNormItem::~ChannelEditEditNormItem()
01254 {
01255 }
01256 int ChannelEditEditNormItem::handle_event()
01257 {
01258         get_popup_menu()->set_text(get_text());
01259         if(thread)
01260                 thread->set_norm(value);
01261         else
01262                 edit->scan_params.norm = value;
01263 }
01264 
01265 
01266 ChannelEditEditFreqtable::ChannelEditEditFreqtable(int x, 
01267         int y, 
01268         ChannelEditEditThread *thread,
01269         ChannelEditThread *edit)
01270  : BC_PopupMenu(x, 
01271         y, 
01272         150, 
01273         edit->value_to_freqtable(thread ? thread->new_channel.freqtable : edit->scan_params.freqtable))
01274 {
01275         this->thread = thread;
01276         this->edit = edit;
01277 }
01278 ChannelEditEditFreqtable::~ChannelEditEditFreqtable()
01279 {
01280 }
01281 int ChannelEditEditFreqtable::add_items()
01282 {
01283         add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_BCAST), NTSC_BCAST));
01284         add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_CABLE), NTSC_CABLE));
01285         add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_HRC), NTSC_HRC));
01286         add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_BCAST_JP), NTSC_BCAST_JP));
01287         add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_CABLE_JP), NTSC_CABLE_JP));
01288         add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_AUSTRALIA), PAL_AUSTRALIA));
01289         add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_EUROPE), PAL_EUROPE));
01290         add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_E_EUROPE), PAL_E_EUROPE));
01291         add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_ITALY), PAL_ITALY));
01292         add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_IRELAND), PAL_IRELAND));
01293         add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_NEWZEALAND), PAL_NEWZEALAND));
01294         return 0;
01295 }
01296 
01297 ChannelEditEditFreqItem::ChannelEditEditFreqItem(ChannelEditEditThread *thread, 
01298         ChannelEditThread *edit,
01299         char *text, int value)
01300  : BC_MenuItem(text)
01301 {
01302         this->value = value;
01303         this->edit = edit;
01304         this->thread = thread;
01305 }
01306 ChannelEditEditFreqItem::~ChannelEditEditFreqItem()
01307 {
01308 }
01309 int ChannelEditEditFreqItem::handle_event()
01310 {
01311         get_popup_menu()->set_text(get_text());
01312         if(thread)
01313                 thread->set_freqtable(value);
01314         else
01315                 edit->scan_params.freqtable = value;
01316 }
01317 
01318 
01319 
01320 ChannelEditEditFine::ChannelEditEditFine(int x, 
01321         int y, 
01322         ChannelEditEditThread *thread)
01323  : BC_ISlider(x, 
01324                 y, 
01325                 0, 
01326                 240, 
01327                 240, 
01328                 -100, 
01329                 100, 
01330                 thread->new_channel.fine_tune)
01331 {
01332         this->thread = thread;
01333 }
01334 ChannelEditEditFine::~ChannelEditEditFine()
01335 {
01336 }
01337 int ChannelEditEditFine::handle_event()
01338 {
01339         thread->new_channel.fine_tune = get_value();
01340         thread->set_device();
01341 }
01342 
01343 
01344 // ========================== picture quality
01345 
01346 ChannelEditPictureThread::ChannelEditPictureThread(ChannelPicker *channel_picker, ChannelEditWindow *window)
01347  : Thread()
01348 {
01349         this->channel_picker = channel_picker;
01350         this->window = window;
01351         in_progress = 0;
01352         edit_window = 0;
01353         completion = new Condition(1, "ChannelEditPictureThread::completion");
01354 }
01355 ChannelEditPictureThread::~ChannelEditPictureThread()
01356 {
01357         delete completion;
01358 }
01359 
01360 int ChannelEditPictureThread::edit_picture()
01361 {
01362         if(in_progress) 
01363         {
01364                 edit_window->lock_window("ChannelEditPictureThread::edit_picture");
01365                 edit_window->raise_window(1);
01366                 edit_window->unlock_window();
01367                 return 1;
01368         }
01369         in_progress = 1;
01370         completion->lock("ChannelEditPictureThread::edit_picture");
01371         set_synchronous(0);
01372         Thread::start();
01373 }
01374 
01375 void ChannelEditPictureThread::run()
01376 {
01377         ChannelEditPictureWindow edit_window(this, 
01378                 channel_picker);
01379         edit_window.create_objects();
01380         this->edit_window = &edit_window;
01381         int result = edit_window.run_window();
01382         this->edit_window = 0;
01383         completion->unlock();
01384         in_progress = 0;
01385 }
01386 
01387 int ChannelEditPictureThread::close_threads()
01388 {
01389         if(edit_window)
01390         {
01391                 edit_window->set_done(1);
01392                 completion->lock("ChannelEditPictureThread::close_threads");
01393                 completion->unlock();
01394         }
01395 }
01396 
01397 
01398 ChannelEditPictureWindow::ChannelEditPictureWindow(ChannelEditPictureThread *thread, 
01399         ChannelPicker *channel_picker)
01400  : BC_Window(PROGRAM_NAME ": Picture", 
01401         channel_picker->mwindow->gui->get_abs_cursor_x(1) - 200, 
01402         channel_picker->mwindow->gui->get_abs_cursor_y(1) - 220, 
01403         200, 
01404         calculate_h(channel_picker), 
01405         200, 
01406         calculate_h(channel_picker))
01407 {
01408         this->thread = thread;
01409         this->channel_picker = channel_picker;
01410 }
01411 ChannelEditPictureWindow::~ChannelEditPictureWindow()
01412 {
01413 }
01414 
01415 int ChannelEditPictureWindow::calculate_h(ChannelPicker *channel_picker)
01416 {
01417         PictureConfig *picture_usage = channel_picker->get_picture_usage();
01418         int pad = BC_Pot::calculate_h();
01419         int result = 20 + BC_OKButton::calculate_h();
01420 
01421         if(picture_usage->use_brightness)
01422                 result += pad;
01423         if(picture_usage->use_contrast)
01424                 result += pad;
01425         if(picture_usage->use_color)
01426                 result += pad;
01427         if(picture_usage->use_hue)
01428                 result += pad;
01429         if(picture_usage->use_whiteness)
01430                 result += pad;
01431         result += channel_picker->get_controls() * pad;
01432         return result;
01433 }
01434 
01435 int ChannelEditPictureWindow::create_objects()
01436 {
01437         int x = 10, y = 10;
01438         int x1 = 110, x2 = 145;
01439         int pad = BC_Pot::calculate_h();
01440 #define SWAP_X x1 ^= x2; x2 ^= x1; x1 ^= x2;
01441 
01442         PictureConfig *picture_usage = channel_picker->get_picture_usage();
01443 
01444         if(!picture_usage ||
01445                 (!picture_usage->use_brightness &&
01446                 !picture_usage->use_contrast &&
01447                 !picture_usage->use_color &&
01448                 !picture_usage->use_hue &&
01449                 !picture_usage->use_whiteness &&
01450                 !channel_picker->get_controls()))
01451         {
01452                 add_subwindow(new BC_Title(x, y, "Device has no picture controls."));
01453                 y += 50;
01454         }
01455 
01456         if(picture_usage->use_brightness)
01457         {
01458                 add_subwindow(new BC_Title(x, y + 10, _("Brightness:")));
01459                 add_subwindow(new ChannelEditBright(x1, y, channel_picker, channel_picker->get_brightness()));
01460                 y += pad;
01461                 SWAP_X
01462                 
01463         }
01464 
01465         if(picture_usage->use_contrast)
01466         {
01467                 add_subwindow(new BC_Title(x, y + 10, _("Contrast:")));
01468                 add_subwindow(new ChannelEditContrast(x1, y, channel_picker, channel_picker->get_contrast()));
01469                 y += pad;
01470                 SWAP_X
01471         }
01472 
01473         if(picture_usage->use_color)
01474         {
01475                 add_subwindow(new BC_Title(x, y + 10, _("Color:")));
01476                 add_subwindow(new ChannelEditColor(x1, y, channel_picker, channel_picker->get_color()));
01477                 y += pad;
01478                 SWAP_X
01479         }
01480 
01481         if(picture_usage->use_hue)
01482         {
01483                 add_subwindow(new BC_Title(x, y + 10, _("Hue:")));
01484                 add_subwindow(new ChannelEditHue(x1, y, channel_picker, channel_picker->get_hue()));
01485                 y += pad;
01486                 SWAP_X
01487         }
01488 
01489         if(picture_usage->use_whiteness)
01490         {
01491                 add_subwindow(new BC_Title(x, y + 10, _("Whiteness:")));
01492                 add_subwindow(new ChannelEditWhiteness(x1, y, channel_picker, channel_picker->get_whiteness()));
01493                 y += pad;
01494                 SWAP_X
01495         }
01496 
01497         for(int i = 0; i < channel_picker->get_controls(); i++)
01498         {
01499                 add_subwindow(new BC_Title(x, 
01500                         y + 10, 
01501                         _(channel_picker->get_control(i)->name)));
01502                 add_subwindow(new ChannelEditCommon(x1, 
01503                         y, 
01504                         channel_picker,
01505                         channel_picker->get_control(i)));
01506                 y += pad;
01507                 SWAP_X
01508         }
01509 
01510 
01511         y += pad;
01512         add_subwindow(new BC_OKButton(this));
01513         return 0;
01514 }
01515 
01516 
01517 
01518 ChannelEditBright::ChannelEditBright(int x, int y, ChannelPicker *channel_picker, int value)
01519  : BC_IPot(x, 
01520                 y, 
01521                 value, 
01522                 -100, 
01523                 100)
01524 {
01525         this->channel_picker = channel_picker;
01526 }
01527 ChannelEditBright::~ChannelEditBright() {}
01528 int ChannelEditBright::handle_event()
01529 {
01530         return 1;
01531 }
01532 int ChannelEditBright::button_release_event()
01533 {
01534         if(BC_Pot::button_release_event())
01535         {
01536                 channel_picker->set_brightness(get_value());
01537                 return 1;
01538         }
01539         return 0;
01540 }
01541 
01542 ChannelEditContrast::ChannelEditContrast(int x, int y, ChannelPicker *channel_picker, int value)
01543  : BC_IPot(x, 
01544                 y, 
01545                 value, 
01546                 -100, 
01547                 100)
01548 {
01549         this->channel_picker = channel_picker;
01550 }
01551 ChannelEditContrast::~ChannelEditContrast() {}
01552 int ChannelEditContrast::handle_event()
01553 {
01554         return 1;
01555 }
01556 int ChannelEditContrast::button_release_event()
01557 {
01558         if(BC_Pot::button_release_event())
01559         {
01560                 channel_picker->set_contrast(get_value());
01561                 return 1;
01562         }
01563         return 0;
01564 }
01565 
01566 
01567 ChannelEditColor::ChannelEditColor(int x, int y, ChannelPicker *channel_picker, int value)
01568  : BC_IPot(x, 
01569                 y, 
01570                 value, 
01571                 -100, 
01572                 100)
01573 {
01574         this->channel_picker = channel_picker;
01575 }
01576 ChannelEditColor::~ChannelEditColor() {}
01577 int ChannelEditColor::handle_event()
01578 {
01579         return 1;
01580 }
01581 int ChannelEditColor::button_release_event()
01582 {
01583         if(BC_Pot::button_release_event())
01584         {
01585                 channel_picker->set_color(get_value());
01586                 return 1;
01587         }
01588         return 0;
01589 }
01590 
01591 ChannelEditHue::ChannelEditHue(int x, int y, ChannelPicker *channel_picker, int value)
01592  : BC_IPot(x, 
01593                 y, 
01594                 value, 
01595                 -100, 
01596                 100)
01597 {
01598         this->channel_picker = channel_picker;
01599 }
01600 ChannelEditHue::~ChannelEditHue() {}
01601 int ChannelEditHue::handle_event()
01602 {
01603         return 1;
01604 }
01605 int ChannelEditHue::button_release_event()
01606 {
01607         if(BC_Pot::button_release_event())
01608         {
01609                 channel_picker->set_hue(get_value());
01610                 return 1;
01611         }
01612         return 0;
01613 }
01614 
01615 ChannelEditWhiteness::ChannelEditWhiteness(int x, int y, ChannelPicker *channel_picker, int value)
01616  : BC_IPot(x, 
01617                 y, 
01618                 value, 
01619                 -100, 
01620                 100)
01621 {
01622         this->channel_picker = channel_picker;
01623 }
01624 ChannelEditWhiteness::~ChannelEditWhiteness() 
01625 {
01626 }
01627 int ChannelEditWhiteness::handle_event()
01628 {
01629         return 1;
01630 }
01631 int ChannelEditWhiteness::button_release_event()
01632 {
01633         if(BC_Pot::button_release_event())
01634         {
01635                 channel_picker->set_whiteness(get_value());
01636                 return 1;
01637         }
01638         return 0;
01639 }
01640 
01641 
01642 
01643 ChannelEditCommon::ChannelEditCommon(int x, 
01644         int y, 
01645         ChannelPicker *channel_picker,
01646         PictureItem *item)
01647  : BC_IPot(x, 
01648                 y, 
01649                 item->value, 
01650                 item->min, 
01651                 item->max)
01652 {
01653         this->channel_picker = channel_picker;
01654         this->device_id = item->device_id;
01655 }
01656 
01657 ChannelEditCommon::~ChannelEditCommon() 
01658 {
01659 }
01660 
01661 int ChannelEditCommon::handle_event()
01662 {
01663         return 1;
01664 }
01665 
01666 int ChannelEditCommon::button_release_event()
01667 {
01668         if(BC_Pot::button_release_event())
01669         {
01670                 channel_picker->set_picture(device_id, get_value());
01671                 return 1;
01672         }
01673         return 0;
01674 }
01675 
01676 
01677 

Generated on Sun Jan 8 13:38:51 2006 for Cinelerra-svn by  doxygen 1.4.4