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

channelpicker.C

Go to the documentation of this file.
00001 #include "channel.h"
00002 #include "channeldb.h"
00003 #include "channeledit.h"
00004 #include "channelpicker.h"
00005 #include "chantables.h"
00006 #include "clip.h"
00007 #include "keys.h"
00008 #include "language.h"
00009 #include "mwindow.h"
00010 #include "picture.h"
00011 #include "playbackconfig.h"
00012 #include "preferencesthread.h"
00013 #include "record.h"
00014 #include "recordmonitor.h"
00015 #include "theme.h"
00016 #include "vdevicebuz.h"
00017 #include "vdeviceprefs.h"
00018 
00019 
00020 
00021 PrefsChannelPicker::PrefsChannelPicker(MWindow *mwindow, 
00022                 VDevicePrefs *prefs, 
00023                 ChannelDB *channeldb, 
00024                 int x,
00025                 int y)
00026  : ChannelPicker(mwindow, 
00027                 0, 
00028                 0,
00029                 channeldb, 
00030                 x,
00031                 y)
00032 {
00033 //      printf("PrefsChannelPicker::PrefsChannelPicker 1\n");
00034         this->prefs = prefs;
00035         VDeviceBUZ::get_inputs(&input_sources);
00036 }
00037 
00038 PrefsChannelPicker::~PrefsChannelPicker()
00039 {
00040         input_sources.remove_all_objects();
00041 }
00042 
00043 BC_WindowBase* PrefsChannelPicker::get_subwindow()
00044 {
00045         return prefs->dialog;
00046 }
00047 
00048 Channel* PrefsChannelPicker::get_current_channel_struct()
00049 {
00050         int number = get_current_channel_number();
00051 
00052         if(number >= 0 && number < channeldb->size())
00053         {
00054                 return channeldb->get(number);
00055         }
00056         return 0;
00057 }
00058 
00059 int PrefsChannelPicker::get_current_channel_number()
00060 {
00061         return prefs->out_config->buz_out_channel;
00062 }
00063 
00064 ArrayList<Channel*>* PrefsChannelPicker::get_video_inputs()
00065 {
00066         return &input_sources;
00067 }
00068 
00069 Channel* PrefsChannelPicker::get_channel_usage()
00070 {
00071         return 0;
00072 }
00073 
00074 
00075 void PrefsChannelPicker::set_channel(Channel *channel)
00076 {
00077         if(channel)
00078                 channel_text->update(channel->title);
00079 }
00080 
00081 void PrefsChannelPicker::set_channel_number(int number)
00082 {
00083         CLAMP(number, 0, channeldb->size() - 1);
00084         prefs->out_config->buz_out_channel = number;
00085         set_channel(get_current_channel_struct());
00086 }
00087 
00088 int PrefsChannelPicker::has_signal()
00089 {
00090         return 0;
00091 }
00092 
00093 int PrefsChannelPicker::set_brightness(int value)
00094 {
00095         prefs->out_config->brightness = value;
00096 }
00097 
00098 int PrefsChannelPicker::set_hue(int value)
00099 {
00100         prefs->out_config->hue = value;
00101 }
00102 
00103 int PrefsChannelPicker::set_color(int value)
00104 {
00105         prefs->out_config->color = value;
00106 }
00107 
00108 int PrefsChannelPicker::set_contrast(int value)
00109 {
00110         prefs->out_config->contrast = value;
00111 }
00112 
00113 int PrefsChannelPicker::set_whiteness(int value)
00114 {
00115         prefs->out_config->whiteness = value;
00116 }
00117 
00118 int PrefsChannelPicker::get_brightness()
00119 {
00120         return prefs->out_config->brightness;
00121 }
00122 
00123 int PrefsChannelPicker::get_hue()
00124 {
00125         return prefs->out_config->hue;
00126 }
00127 
00128 int PrefsChannelPicker::get_color()
00129 {
00130         return prefs->out_config->color;
00131 }
00132 
00133 int PrefsChannelPicker::get_contrast()
00134 {
00135         return prefs->out_config->contrast;
00136 }
00137 
00138 int PrefsChannelPicker::get_whiteness()
00139 {
00140         return prefs->out_config->whiteness;
00141 }
00142 
00143 int PrefsChannelPicker::set_picture(int device_id, int value)
00144 {
00145         return 0;
00146 }
00147 
00148 int PrefsChannelPicker::get_controls()
00149 {
00150         return 0;
00151 }
00152 
00153 PictureItem* PrefsChannelPicker::get_control(int i)
00154 {
00155         return 0;
00156 }
00157 
00158 PictureConfig* PrefsChannelPicker::get_picture_usage()
00159 {
00160         return 0;
00161 }
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 ChannelPicker::ChannelPicker(MWindow *mwindow, 
00170                 Record *record, 
00171                 RecordMonitor *record_monitor,
00172                 ChannelDB *channeldb, 
00173                 int x,
00174                 int y)
00175 {
00176         this->mwindow = mwindow;
00177         this->record = record;
00178         this->record_monitor = record_monitor;
00179         this->x = x;
00180         this->y = y;
00181         this->channeldb = channeldb;
00182         current_channel = new Channel;
00183         channel_text = 0;
00184         update_channel_list();
00185 }
00186 
00187 ChannelPicker::~ChannelPicker()
00188 {
00189         delete channel_text;
00190         delete channel_select;
00191         delete channel_button;
00192         delete current_channel;
00193         channel_listitems.remove_all_objects();
00194 }
00195 
00196 void ChannelPicker::update_channel_list()
00197 {
00198 //printf("ChannelPicker::update_channel_list 1\n");
00199         channel_listitems.remove_all_objects();
00200         for(int i = 0; i < channeldb->size(); i++)
00201         {
00202                 channel_listitems.append(new BC_ListBoxItem(channeldb->get(i)->title));
00203         }
00204 
00205         if(channel_text)
00206                 channel_text->update_list(&channel_listitems);
00207 //printf("ChannelPicker::update_channel_list 2\n");
00208 }
00209 
00210 
00211 
00212 
00213 
00214 
00215 
00216 
00217 BC_WindowBase* ChannelPicker::get_subwindow()
00218 {
00219         if(record_monitor) return record_monitor->window;
00220         return 0;
00221 }
00222 
00223 Channel* ChannelPicker::get_current_channel_struct()
00224 {
00225 //printf("ChannelPicker::get_current_channel_struct 1\n");
00226         if(record) return record->get_current_channel_struct();
00227         return 0;
00228 }
00229 
00230 int ChannelPicker::get_current_channel_number()
00231 {
00232         if(record) return record->get_editing_channel();
00233         return 0;
00234 }
00235 
00236 ArrayList<Channel*>* ChannelPicker::get_video_inputs() 
00237 {
00238         if(record) return record->get_video_inputs();
00239         return 0;
00240 }
00241 
00242 Channel* ChannelPicker::get_channel_usage()
00243 {
00244         if(record) return record->master_channel;
00245         return 0;
00246 }
00247 
00248 void ChannelPicker::set_channel_number(int number)
00249 {
00250         if(record) record->set_channel(number);
00251 }
00252 
00253 void ChannelPicker::set_channel(Channel *channel)
00254 {
00255         if(record) record->set_channel(channel);
00256 }
00257 
00258 int ChannelPicker::has_signal()
00259 {
00260         if(record) return record->has_signal();
00261         return 0;
00262 }
00263 
00264 int ChannelPicker::set_brightness(int value)
00265 {
00266         if(record)
00267         {
00268                 record->picture->brightness = value;
00269                 record->set_video_picture();
00270         }
00271         return 0;
00272 }
00273 
00274 int ChannelPicker::set_hue(int value)
00275 {
00276         if(record)
00277         {
00278                 record->picture->hue = value;
00279                 record->set_video_picture();
00280         }
00281         return 0;
00282 }
00283 
00284 int ChannelPicker::set_color(int value)
00285 {
00286         if(record)
00287         {
00288                 record->picture->color = value;
00289                 record->set_video_picture();
00290         }
00291         return 0;
00292 }
00293 
00294 int ChannelPicker::set_contrast(int value)
00295 {
00296         if(record)
00297         {
00298                 record->picture->contrast = value;
00299                 record->set_video_picture();
00300         }
00301         return 0;
00302 }
00303 
00304 int ChannelPicker::set_whiteness(int value)
00305 {
00306         if(record)
00307         {
00308                 record->picture->whiteness = value;
00309                 record->set_video_picture();
00310         }
00311         return 0;
00312 }
00313 
00314 int ChannelPicker::set_picture(int device_id, int value)
00315 {
00316         if(record) 
00317         {
00318                 record->picture->set_item(device_id, value);
00319                 record->set_video_picture();
00320         }
00321         return 0;
00322 }
00323 
00324 int ChannelPicker::get_brightness()
00325 {
00326         if(record) return record->picture->brightness;
00327         return 0;
00328 }
00329 
00330 int ChannelPicker::get_hue()
00331 {
00332         if(record) return record->picture->hue;
00333         return 0;
00334 }
00335 
00336 int ChannelPicker::get_color()
00337 {
00338         if(record) return record->picture->color;
00339         return 0;
00340 }
00341 
00342 int ChannelPicker::get_contrast()
00343 {
00344         if(record) return record->picture->contrast;
00345         return 0;
00346 }
00347 
00348 int ChannelPicker::get_whiteness()
00349 {
00350         if(record) return record->picture->whiteness;
00351         return 0;
00352 }
00353 
00354 int ChannelPicker::get_controls()
00355 {
00356         if(record) return record->picture->controls.total;
00357         return 0;
00358 }
00359 
00360 PictureItem* ChannelPicker::get_control(int i)
00361 {
00362         if(record) return record->picture->controls.values[i];
00363         return 0;
00364 }
00365 
00366 PictureConfig* ChannelPicker::get_picture_usage()
00367 {
00368         if(record) return record->picture;
00369         return 0;
00370 }
00371 
00372 
00373 
00374 
00375 
00376 
00377 
00378 
00379 int ChannelPicker::create_objects()
00380 {
00381         channel_text = 0;
00382         update_channel_list();
00383         channel_text = new ChannelText(mwindow, this, x, y);
00384         channel_text->create_objects();
00385         x += channel_text->get_w();
00386         get_subwindow()->add_subwindow(channel_select = new ChannelTumbler(mwindow, this, x, y));
00387         x += channel_select->get_w() + 5;
00388         get_subwindow()->add_subwindow(channel_button = new ChannelButton(mwindow, this, x, y - 1));
00389         return 0;
00390 }
00391 
00392 int ChannelPicker::reposition()
00393 {
00394         channel_text->reposition_window(channel_text->get_x(),
00395                 channel_text->get_y());
00396         channel_select->reposition_window(channel_select->get_x(),
00397                 channel_select->get_y());
00398         channel_button->reposition_window(channel_button->get_x(),
00399                 channel_button->get_y());
00400         return 0;
00401 }
00402 
00403 int ChannelPicker::close_threads()
00404 {
00405         channel_button->thread->close_threads();
00406         return 0;
00407 }
00408 
00409 char* ChannelPicker::get_source_name(Channel *channel)
00410 {
00411         if(channel->entry < chanlists[channel->freqtable].count)
00412                 return chanlists[channel->freqtable].list[channel->entry].name;
00413         else
00414                 return chanlists[channel->freqtable].list[0].name;
00415 }
00416 
00417 char* ChannelPicker::current_channel_name()
00418 {
00419         if(get_current_channel_struct())
00420         {
00421                 return get_current_channel_struct()->title;
00422         }
00423         else
00424                 return _("Channel");
00425 }
00426 
00427 int ChannelPicker::channel_down()
00428 {
00429         int number = get_current_channel_number() - 1;
00430         if(number < 0) number = 0;
00431         CLAMP(number, 0, channeldb->size() - 1);
00432         set_channel_number(number);
00433         return 0;
00434 }
00435 
00436 int ChannelPicker::channel_up()
00437 {
00438         int number = get_current_channel_number() + 1;
00439         if(number >= channeldb->size()) number = channeldb->size() - 1;
00440         CLAMP(number, 0, channeldb->size() - 1);
00441         set_channel_number(number);
00442         return 0;
00443 }
00444 
00445 
00446 
00447 ChannelButton::ChannelButton(MWindow *mwindow, ChannelPicker *channel_picker, int x, int y)
00448  : BC_Button(x, y, mwindow->theme->get_image_set("channel"))
00449 {
00450         this->channel_picker = channel_picker;
00451         this->mwindow = mwindow;
00452         thread = new ChannelEditThread(mwindow, 
00453                 channel_picker, 
00454                 channel_picker->channeldb,
00455                 channel_picker->record);
00456         set_tooltip(_("Edit channels"));
00457 }
00458 
00459 ChannelButton::~ChannelButton()
00460 {
00461         delete thread;
00462 }
00463 
00464 int ChannelButton::handle_event()
00465 {
00466         thread->start();
00467         return 1;
00468 }
00469 
00470 
00471 ChannelText::ChannelText(MWindow *mwindow, 
00472         ChannelPicker *channel_picker, 
00473         int x, 
00474         int y)
00475  : BC_PopupTextBox(channel_picker->get_subwindow(),
00476         &channel_picker->channel_listitems,
00477         channel_picker->current_channel_name(),
00478         x, 
00479         y, 
00480         150, 
00481         300)
00482 {
00483 
00484         this->channel_picker = channel_picker;
00485         this->mwindow = mwindow;
00486 }
00487 
00488 ChannelText::~ChannelText()
00489 {
00490 }
00491 
00492 int ChannelText::handle_event()
00493 {
00494         channel_picker->set_channel_number(get_number());
00495         return 0;
00496 }
00497 
00498 
00499 
00500 
00501 ChannelList::ChannelList(MWindow *mwindow, ChannelPicker *channel_picker, int x, int y)
00502  : BC_ListBox(x, 
00503                 y, 
00504                 100, 
00505                 200,
00506                 LISTBOX_TEXT,                   // Display text list or icons
00507                 &channel_picker->channel_listitems, // Each column has an ArrayList of BC_ListBoxItems.
00508                 0,                       // Titles for columns.  Set to 0 for no titles
00509                 0,                      // width of each column
00510                 1,                     // Total columns.
00511                 0,                    // Pixel of top of window.
00512                 1)                   // If this listbox is a popup window
00513 {
00514         this->mwindow = mwindow;
00515         this->channel_picker = channel_picker;
00516 }
00517 
00518 ChannelList::~ChannelList()
00519 {
00520 }
00521         
00522 int ChannelList::handle_event()
00523 {
00524         return 0;
00525 }
00526 
00527 
00528 
00529 ChannelTumbler::ChannelTumbler(MWindow *mwindow, 
00530         ChannelPicker *channel_picker, 
00531         int x, 
00532         int y)
00533  : BC_Tumbler(x, y)
00534 {
00535         this->mwindow = mwindow;
00536         this->channel_picker = channel_picker;
00537 }
00538 ChannelTumbler::~ChannelTumbler()
00539 {
00540 }
00541 int ChannelTumbler::handle_up_event()
00542 {
00543         channel_picker->channel_up();
00544         return 1;
00545 }
00546 int ChannelTumbler::handle_down_event()
00547 {
00548         channel_picker->channel_down();
00549         return 1;
00550 }
00551 int ChannelTumbler::keypress_event()
00552 {
00553         if(get_keypress() == PGUP)
00554         {
00555                 handle_up_event();
00556                 return 1;
00557         }
00558         else
00559         if(get_keypress() == PGDN)
00560         {
00561                 handle_down_event();
00562                 return 1;
00563         }
00564         else
00565         return 0;
00566 }
00567 
00568 

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