initial commit
[goodguy/history.git] / cinelerra-5.0 / cinelerra / vdeviceprefs.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2011 Adam Williams <broadcast at earthling dot net>
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #include "bcsignals.h"
23 #include "channeldb.h"
24 #include "channelpicker.h"
25 #include "edl.h"
26 #include "edlsession.h"
27 #include "formattools.h"
28 #include "../hvirtual_config.h"
29 #include "language.h"
30 #include "mwindow.h"
31 #include "mainsession.h"
32 #include "vdeviceprefs.h"
33 #include "videoconfig.h"
34 #include "videodevice.inc"
35 #include "overlayframe.inc"
36 #include "playbackconfig.h"
37 #include "preferences.h"
38 #include "preferencesthread.h"
39 #include "recordconfig.h"
40 #include "recordprefs.h"
41 #include <string.h>
42
43
44 VDevicePrefs::VDevicePrefs(int x, 
45         int y, 
46         PreferencesWindow *pwindow, 
47         PreferencesDialog *dialog, 
48         VideoOutConfig *out_config,
49         VideoInConfig *in_config,
50         int mode)
51 {
52         this->pwindow = pwindow;
53         this->dialog = dialog;
54         this->driver = -1;
55         this->mode = mode;
56         this->out_config = out_config;
57         this->in_config = in_config;
58         this->x = x;
59         this->y = y;
60         menu = 0;
61         reset_objects();
62
63 }
64
65 VDevicePrefs::~VDevicePrefs()
66 {
67         delete_objects();
68         if(menu) delete menu;
69         int config = -1;
70         switch( pwindow->thread->current_dialog ) {
71         case PreferencesThread::PLAYBACK_A:  config = 0;  break;
72         case PreferencesThread::PLAYBACK_B:  config = 1;  break;
73         }
74         if( config >= 0 )
75                 pwindow->mwindow->session->save_x11_host(config, out_config->x11_host);
76         pwindow->mwindow->channeldb_buz->save("channeldb_buz");
77 }
78
79
80 void VDevicePrefs::reset_objects()
81 {
82         device_title = 0;
83         port_title = 0;
84         follow_video_config = 0;        
85         dvb_adapter_title = 0;  
86         dvb_adapter_device = 0; 
87         channel_title = 0;
88         output_title = 0;
89         syt_title = 0;
90
91         device_text = 0;
92         firewire_port = 0;
93         firewire_channel = 0;
94         firewire_channels = 0;
95         firewire_syt = 0;
96         firewire_path = 0;
97         fields_title = 0;
98         device_fields = 0;
99
100         buz_swap_channels = 0;
101         channel_picker = 0;
102 }
103
104 int VDevicePrefs::initialize(int creation)
105 {
106         int *driver = 0;
107         delete_objects();
108
109         switch(mode)
110         {
111                 case MODEPLAY:
112                         driver = &out_config->driver;
113                         break;
114
115                 case MODERECORD:
116                         driver = &in_config->driver;
117                         break;
118         }
119         this->driver = *driver;
120
121         if(!menu)
122         {
123                 dialog->add_subwindow(menu = new VDriverMenu(x,
124                         y + 10,
125                         this, 
126                         (mode == MODERECORD), 
127                         driver));
128                 menu->create_objects();
129         }
130
131         switch(this->driver)
132         {
133                 case VIDEO4LINUX:
134                         create_v4l_objs();
135                         break;
136                 case VIDEO4LINUX2:
137                 case CAPTURE_JPEG_WEBCAM:
138                 case CAPTURE_YUYV_WEBCAM:
139                         create_v4l2_objs();
140                         break;
141                 case VIDEO4LINUX2JPEG:
142                         create_v4l2jpeg_objs();
143                         break;
144                 case VIDEO4LINUX2MPEG:
145                         create_v4l2mpeg_objs();
146                         break;
147                 case SCREENCAPTURE:
148                         create_screencap_objs();
149                         break;
150                 case CAPTURE_LML:
151                         create_lml_objs();
152                         break;
153                 case CAPTURE_BUZ:
154                 case PLAYBACK_BUZ:
155                         create_buz_objs();
156                         break;
157                 case PLAYBACK_X11:
158                 case PLAYBACK_X11_XV:
159                 case PLAYBACK_X11_GL:
160                         create_x11_objs();
161                         break;
162                 case PLAYBACK_DV1394:
163                 case PLAYBACK_FIREWIRE:
164                 case PLAYBACK_IEC61883:
165                 case CAPTURE_FIREWIRE:
166                 case CAPTURE_IEC61883:
167                         create_firewire_objs();
168                         break;
169                 case CAPTURE_DVB:
170                         create_dvb_objs();
171                         break;
172         }
173
174
175
176 // Update driver dependancies in file format
177         if(mode == MODERECORD && dialog && !creation)
178         {
179                 RecordPrefs *record_prefs = (RecordPrefs*)dialog;
180                 record_prefs->recording_format->update_driver(this->driver);
181         }
182
183         return 0;
184 }
185
186 int VDevicePrefs::delete_objects()
187 {
188         delete output_title;
189         delete channel_picker;
190         delete buz_swap_channels;
191         delete device_title;
192         delete device_text;
193         delete dvb_adapter_device;
194         delete follow_video_config;
195         delete dvb_adapter_title;
196
197         delete port_title;
198
199         if(firewire_port) delete firewire_port;
200         if(channel_title) delete channel_title;
201         if(firewire_channel) delete firewire_channel;
202         if(firewire_path) delete firewire_path;
203         if(syt_title) delete syt_title;
204         if(firewire_syt) delete firewire_syt;
205         if(fields_title) delete fields_title;
206         if(device_fields) delete device_fields;
207
208         reset_objects();
209         driver = -1;
210         return 0;
211 }
212
213 int VDevicePrefs::create_dvb_objs()
214 {
215         int x1 = x + menu->get_w() + 30;
216         int y1 = y + 10;
217         char *output_char = in_config->dvb_in_adapter;
218         int y2 = y1 - BC_Title::calculate_h(dialog, _("DVB Adapter:"), MEDIUMFONT) - 5;
219         BC_Resources *resources = BC_WindowBase::get_resources();
220         dvb_adapter_title = new BC_Title(x1, y2, _("DVB Adapter:"),
221                         MEDIUMFONT, resources->text_default);
222         dialog->add_subwindow(dvb_adapter_title);
223         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y1, output_char));
224         int x2 = x1 + device_text->get_w() + 5;
225         device_title = new BC_Title(x2, y2, _("dev:"),
226                         MEDIUMFONT, resources->text_default);
227         dialog->add_subwindow(device_title);
228         int *output_int = &in_config->dvb_in_device;
229         dvb_adapter_device = new VDeviceTumbleBox(this, x2, y1, output_int, 0, 9, 20);
230         dvb_adapter_device->create_objects();
231         x1 += 64;  y1 += device_text->get_h() + 5;
232         follow_video_config = new BC_CheckBox(x1, y1,
233                         &in_config->follow_video, _("Follow video config"));
234         dialog->add_subwindow(follow_video_config);
235         return 0;
236 }
237
238 int VDevicePrefs::create_lml_objs()
239 {
240         char *output_char = 0;
241         int x1 = x + menu->get_w() + 5;
242         BC_Resources *resources = BC_WindowBase::get_resources();
243
244         switch(mode)
245         {
246                 case MODEPLAY: 
247                         output_char = out_config->lml_out_device;
248                         break;
249                 case MODERECORD:
250                         output_char = in_config->lml_in_device;
251                         break;
252         }
253         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
254         x1 += device_title->get_w() + 10;
255         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
256         return 0;
257 }
258
259 int VDevicePrefs::create_buz_objs()
260 {
261 #ifdef HAVE_VIDEO4LINUX
262
263
264         char *output_char = 0;
265         int x1 = x + menu->get_w() + 5;
266         int x2 = x1 + 210;
267         int y1 = y;
268         BC_Resources *resources = BC_WindowBase::get_resources();
269
270         switch(mode)
271         {
272                 case MODEPLAY: 
273                         output_char = out_config->buz_out_device;
274                         break;
275                 case MODERECORD:
276                         output_char = in_config->buz_in_device;
277                         break;
278         }
279         dialog->add_subwindow(device_title = new BC_Title(x1, y1, _("Device path:"), MEDIUMFONT, resources->text_default));
280
281         y1 += 20;
282         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y1, output_char));
283
284         if(driver == PLAYBACK_BUZ)
285         {
286                 dialog->add_subwindow(buz_swap_channels = 
287                         new VDeviceCheckBox(x2, y1, &out_config->buz_swap_fields, _("Swap fields")));
288         }
289         y1 += 30;
290         if(driver == PLAYBACK_BUZ)
291         {
292                 dialog->add_subwindow(output_title = new BC_Title(x1, y1, _("Output channel:")));
293                 y1 += 20;
294                 channel_picker = new PrefsChannelPicker(pwindow->mwindow, 
295                         this, 
296                         pwindow->mwindow->channeldb_buz, 
297                         x1,
298                         y1);
299                 channel_picker->create_objects();
300         }
301 #endif // HAVE_VIDEO4LINUX
302
303         return 0;
304 }
305
306 int VDevicePrefs::create_firewire_objs()
307 {
308         int *output_int = 0;
309         char *output_char = 0;
310         int x1 = x + menu->get_w() + 5;
311         BC_Resources *resources = BC_WindowBase::get_resources();
312
313 // Firewire path
314         switch(mode)
315         {
316                 case MODEPLAY:
317                         if(driver == PLAYBACK_DV1394)
318                                 output_char = out_config->dv1394_path;
319                         else
320                         if(driver == PLAYBACK_FIREWIRE)
321                                 output_char = out_config->firewire_path;
322                         break;
323                 case MODERECORD:
324 // Our version of raw1394 doesn't support changing the input path
325                         output_char = 0;
326                         break;
327         }
328
329         if(output_char)
330         {
331                 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device Path:"), MEDIUMFONT, resources->text_default));
332                 dialog->add_subwindow(firewire_path = new VDeviceTextBox(x1, y + 20, output_char));
333                 x1 += firewire_path->get_w() + 5;
334         }
335
336 // Firewire port
337         switch(mode)
338         {
339                 case MODEPLAY:
340                         if(driver == PLAYBACK_DV1394)
341                                 output_int = &out_config->dv1394_port;
342                         else
343                                 output_int = &out_config->firewire_port;
344                         break;
345                 case MODERECORD:
346                         output_int = &in_config->firewire_port;
347                         break;
348         }
349         dialog->add_subwindow(port_title = new BC_Title(x1, y, _("Port:"), MEDIUMFONT, resources->text_default));
350         dialog->add_subwindow(firewire_port = new VDeviceIntBox(x1, y + 20, output_int));
351         x1 += firewire_port->get_w() + 5;
352
353 // Firewire channel
354         switch(mode)
355         {
356                 case MODEPLAY:
357                         if(driver == PLAYBACK_DV1394)
358                                 output_int = &out_config->dv1394_channel;
359                         else
360                                 output_int = &out_config->firewire_channel;
361                         break;
362                 case MODERECORD:
363                         output_int = &in_config->firewire_channel;
364                         break;
365         }
366
367         dialog->add_subwindow(channel_title = new BC_Title(x1, y, _("Channel:"), MEDIUMFONT, resources->text_default));
368         dialog->add_subwindow(firewire_channel = new VDeviceIntBox(x1, y + 20, output_int));
369         x1 += firewire_channel->get_w() + 5;
370
371
372 // Firewire syt
373         switch(mode)
374         {
375                 case MODEPLAY:
376                         if(driver == PLAYBACK_DV1394)
377                                 output_int = &out_config->dv1394_syt;
378                         else
379                         if(driver == PLAYBACK_FIREWIRE)
380                                 output_int = &out_config->firewire_syt;
381                         else
382                                 output_int = 0;
383                         break;
384                 case MODERECORD:
385                         output_int = 0;
386                         break;
387         }
388         if(output_int)
389         {
390                 dialog->add_subwindow(syt_title = new BC_Title(x1, y, _("Syt Offset:"), MEDIUMFONT, resources->text_default));
391                 dialog->add_subwindow(firewire_syt = new VDeviceIntBox(x1, y + 20, output_int));
392         }
393
394         return 0;
395 }
396
397 int VDevicePrefs::create_v4l_objs()
398 {
399 #ifdef HAVE_VIDEO4LINUX
400
401
402         char *output_char;
403         BC_Resources *resources = BC_WindowBase::get_resources();
404         int x1 = x + menu->get_w() + 5;
405         output_char = pwindow->thread->edl->session->vconfig_in->v4l_in_device;
406         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
407         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
408
409
410 #endif // HAVE_VIDEO4LINUX
411         return 0;
412 }
413
414 int VDevicePrefs::create_v4l2_objs()
415 {
416         char *output_char;
417         BC_Resources *resources = BC_WindowBase::get_resources();
418         int x1 = x + menu->get_w() + 5;
419         output_char = pwindow->thread->edl->session->vconfig_in->v4l2_in_device;
420         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
421         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
422
423         return 0;
424 }
425
426 int VDevicePrefs::create_v4l2jpeg_objs()
427 {
428         BC_Resources *resources = BC_WindowBase::get_resources();
429         int x1 = x + menu->get_w() + 5;
430         char *output_char = &pwindow->thread->edl->session->vconfig_in->v4l2jpeg_in_device[0];
431         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
432         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
433         x1 += max(device_title->get_w(),device_text->get_w()) + 5;
434         int *output_int = &pwindow->thread->edl->session->vconfig_in->v4l2jpeg_in_fields;
435         fields_title = new BC_Title(x1, y, _("Fields:"), MEDIUMFONT, resources->text_default);
436         dialog->add_subwindow(fields_title);
437         device_fields = new VDeviceTumbleBox(this, x1, y + 20, output_int, 1, 2, 20);
438         device_fields->create_objects();
439         return 0;
440 }
441
442 int VDevicePrefs::create_v4l2mpeg_objs()
443 {
444         char *output_char;
445         BC_Resources *resources = BC_WindowBase::get_resources();
446         int x1 = x + menu->get_w() + 5;
447         output_char = pwindow->thread->edl->session->vconfig_in->v4l2mpeg_in_device;
448         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
449         int y1 = y + 20;
450         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y1, output_char));
451         x1 += 64;  y1 += device_text->get_h() + 5;
452         follow_video_config = new BC_CheckBox(x1, y1,
453                         &in_config->follow_video, _("Follow video config"));
454         dialog->add_subwindow(follow_video_config);
455         return 0;
456 }
457
458
459 int VDevicePrefs::create_screencap_objs()
460 {
461         char *output_char;
462         BC_Resources *resources = BC_WindowBase::get_resources();
463         int x1 = x + menu->get_w() + 5;
464         output_char = pwindow->thread->edl->session->vconfig_in->screencapture_display;
465         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Display:"), MEDIUMFONT, resources->text_default));
466         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
467         return 0;
468 }
469
470 int VDevicePrefs::create_x11_objs()
471 {
472         char *output_char;
473         BC_Resources *resources = BC_WindowBase::get_resources();
474         int x1 = x + menu->get_w() + 5;
475         output_char = out_config->x11_host;
476         const char *x11_display;
477         switch( pwindow->thread->current_dialog ) {
478         default:
479         case PreferencesThread::PLAYBACK_A:
480                 x11_display = _("Default A Display:");  break;
481                 break;
482         case PreferencesThread::PLAYBACK_B:
483                 x11_display = _("Default B Display:");  break;
484                 break;
485         }
486         dialog->add_subwindow(device_title = new BC_Title(x1, y, x11_display,
487                         MEDIUMFONT, resources->text_default));
488         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + 20, output_char));
489         return 0;
490 }
491
492
493
494
495 VDriverMenu::VDriverMenu(int x, 
496         int y, 
497         VDevicePrefs *device_prefs, 
498         int do_input, 
499         int *output)
500  : BC_PopupMenu(x, y, 200, driver_to_string(*output))
501 {
502         this->output = output;
503         this->do_input = do_input;
504         this->device_prefs = device_prefs;
505 }
506
507 VDriverMenu::~VDriverMenu()
508 {
509 }
510
511 char* VDriverMenu::driver_to_string(int driver)
512 {
513         switch(driver)
514         {
515                 case VIDEO4LINUX:
516                         sprintf(string, VIDEO4LINUX_TITLE);
517                         break;
518                 case VIDEO4LINUX2:
519                         sprintf(string, VIDEO4LINUX2_TITLE);
520                         break;
521                 case CAPTURE_JPEG_WEBCAM:
522                         sprintf(string, CAPTURE_JPEG_WEBCAM_TITLE);
523                         break;
524                 case CAPTURE_YUYV_WEBCAM:
525                         sprintf(string, CAPTURE_YUYV_WEBCAM_TITLE);
526                         break;
527                 case VIDEO4LINUX2JPEG:
528                         sprintf(string, VIDEO4LINUX2JPEG_TITLE);
529                         break;
530                 case VIDEO4LINUX2MPEG:
531                         sprintf(string, VIDEO4LINUX2MPEG_TITLE);
532                         break;
533                 case SCREENCAPTURE:
534                         sprintf(string, SCREENCAPTURE_TITLE);
535                         break;
536                 case CAPTURE_BUZ:
537                         sprintf(string, CAPTURE_BUZ_TITLE);
538                         break;
539                 case CAPTURE_LML:
540                         sprintf(string, CAPTURE_LML_TITLE);
541                         break;
542                 case CAPTURE_FIREWIRE:
543                         sprintf(string, CAPTURE_FIREWIRE_TITLE);
544                         break;
545                 case CAPTURE_IEC61883:
546                         sprintf(string, CAPTURE_IEC61883_TITLE);
547                         break;
548                 case CAPTURE_DVB:
549                         sprintf(string, CAPTURE_DVB_TITLE);
550                         break;
551                 case PLAYBACK_X11:
552                         sprintf(string, PLAYBACK_X11_TITLE);
553                         break;
554                 case PLAYBACK_X11_XV:
555                         sprintf(string, PLAYBACK_X11_XV_TITLE);
556                         break;
557                 case PLAYBACK_X11_GL:
558                         sprintf(string, PLAYBACK_X11_GL_TITLE);
559                         break;
560                 case PLAYBACK_LML:
561                         sprintf(string, PLAYBACK_LML_TITLE);
562                         break;
563                 case PLAYBACK_BUZ:
564                         sprintf(string, PLAYBACK_BUZ_TITLE);
565                         break;
566                 case PLAYBACK_FIREWIRE:
567                         sprintf(string, PLAYBACK_FIREWIRE_TITLE);
568                         break;
569                 case PLAYBACK_DV1394:
570                         sprintf(string, PLAYBACK_DV1394_TITLE);
571                         break;
572                 case PLAYBACK_IEC61883:
573                         sprintf(string, PLAYBACK_IEC61883_TITLE);
574                         break;
575                 default:
576                         string[0] = 0;
577                         break;
578         }
579         return string;
580 }
581
582 void VDriverMenu::create_objects()
583 {
584         if(do_input)
585         {
586 #ifdef HAVE_VIDEO4LINUX
587                 add_item(new VDriverItem(this, VIDEO4LINUX_TITLE, VIDEO4LINUX));
588 #endif
589
590 #ifdef HAVE_VIDEO4LINUX2
591                 add_item(new VDriverItem(this, VIDEO4LINUX2_TITLE, VIDEO4LINUX2));
592                 add_item(new VDriverItem(this, CAPTURE_JPEG_WEBCAM_TITLE, CAPTURE_JPEG_WEBCAM));
593                 add_item(new VDriverItem(this, CAPTURE_YUYV_WEBCAM_TITLE, CAPTURE_YUYV_WEBCAM));
594                 add_item(new VDriverItem(this, VIDEO4LINUX2JPEG_TITLE, VIDEO4LINUX2JPEG));
595                 add_item(new VDriverItem(this, VIDEO4LINUX2MPEG_TITLE, VIDEO4LINUX2MPEG));
596 #endif
597
598                 add_item(new VDriverItem(this, SCREENCAPTURE_TITLE, SCREENCAPTURE));
599 #ifdef HAVE_VIDEO4LINUX
600                 add_item(new VDriverItem(this, CAPTURE_BUZ_TITLE, CAPTURE_BUZ));
601 #endif
602                 add_item(new VDriverItem(this, CAPTURE_FIREWIRE_TITLE, CAPTURE_FIREWIRE));
603                 add_item(new VDriverItem(this, CAPTURE_IEC61883_TITLE, CAPTURE_IEC61883));
604                 add_item(new VDriverItem(this, CAPTURE_DVB_TITLE, CAPTURE_DVB));
605         }
606         else
607         {
608                 add_item(new VDriverItem(this, PLAYBACK_X11_TITLE, PLAYBACK_X11));
609                 add_item(new VDriverItem(this, PLAYBACK_X11_XV_TITLE, PLAYBACK_X11_XV));
610 #ifdef HAVE_GL
611                 add_item(new VDriverItem(this, PLAYBACK_X11_GL_TITLE, PLAYBACK_X11_GL));
612 #endif
613                 add_item(new VDriverItem(this, PLAYBACK_BUZ_TITLE, PLAYBACK_BUZ));
614                 add_item(new VDriverItem(this, PLAYBACK_FIREWIRE_TITLE, PLAYBACK_FIREWIRE));
615                 add_item(new VDriverItem(this, PLAYBACK_DV1394_TITLE, PLAYBACK_DV1394));
616                 add_item(new VDriverItem(this, PLAYBACK_IEC61883_TITLE, PLAYBACK_IEC61883));
617         }
618 }
619
620
621 VDriverItem::VDriverItem(VDriverMenu *popup, const char *text, int driver)
622  : BC_MenuItem(text)
623 {
624         this->popup = popup;
625         this->driver = driver;
626 }
627
628 VDriverItem::~VDriverItem()
629 {
630 }
631
632 int VDriverItem::handle_event()
633 {
634         popup->set_text(get_text());
635         *(popup->output) = driver;
636         popup->device_prefs->initialize(0);
637         popup->device_prefs->pwindow->show_dialog();
638         return 1;
639 }
640
641
642
643
644 VDeviceTextBox::VDeviceTextBox(int x, int y, char *output)
645  : BC_TextBox(x, y, 200, 1, output)
646
647         this->output = output; 
648 }
649
650 int VDeviceTextBox::handle_event() 
651
652 // Suggestions
653         calculate_suggestions(0);
654
655         strcpy(output, get_text()); 
656         return 1;
657 }
658
659 VDeviceTumbleBox::VDeviceTumbleBox(VDevicePrefs *prefs, 
660         int x, int y, int *output, int min, int max, int text_w)
661  : BC_TumbleTextBox(prefs->dialog, *output, min, max, x, y, text_w)
662
663         this->output = output; 
664 }
665
666 int VDeviceTumbleBox::handle_event() 
667 {
668         *output = atol(get_text()); 
669         return 1;
670 }
671
672
673
674
675
676
677 VDeviceIntBox::VDeviceIntBox(int x, int y, int *output)
678  : BC_TextBox(x, y, 60, 1, *output)
679
680         this->output = output; 
681 }
682
683 int VDeviceIntBox::handle_event() 
684
685         *output = atol(get_text()); 
686         return 1;
687 }
688
689
690
691
692
693 VDeviceCheckBox::VDeviceCheckBox(int x, int y, int *output, char *text)
694  : BC_CheckBox(x, y, *output, text)
695 {
696         this->output = output;
697 }
698 int VDeviceCheckBox::handle_event()
699 {
700         *output = get_value();
701         return 1;
702 }
703
704
705
706
707 VScalingItem::VScalingItem(VScalingEquation *popup, int interpolation)
708  : BC_MenuItem(popup->interpolation_to_string(interpolation))
709 {
710         this->popup = popup;
711         this->interpolation = interpolation;
712 }
713
714 VScalingItem::~VScalingItem()
715 {
716 }
717
718 int VScalingItem::handle_event()
719 {
720         popup->set_text(get_text());
721         *(popup->output) = interpolation;
722         return 1;
723 }
724
725
726 VScalingEquation::VScalingEquation(int x, int y, int *output)
727  : BC_PopupMenu(x, y, 175, interpolation_to_string(*output))
728 {
729         this->output = output;
730 }
731
732 VScalingEquation::~VScalingEquation()
733 {
734 }
735
736 const char *VScalingEquation::interpolation_to_string(int type)
737 {
738         switch( type ) {
739         case NEAREST_NEIGHBOR:  return "Nearest Neighbor";
740         case CUBIC_CUBIC:       return "BiCubic / BiCubic";
741         case CUBIC_LINEAR:      return "BiCubic / BiLinear";
742         case LINEAR_LINEAR:     return "BiLinear / BiLinear";
743         case LANCZOS_LANCZOS:   return "Lanczos / Lanczos";
744         }
745         return "Unknown";
746 }
747
748 void VScalingEquation::create_objects()
749 {
750         add_item(new VScalingItem(this, NEAREST_NEIGHBOR));
751         add_item(new VScalingItem(this, CUBIC_CUBIC));
752         add_item(new VScalingItem(this, CUBIC_LINEAR));
753         add_item(new VScalingItem(this, LINEAR_LINEAR));
754         add_item(new VScalingItem(this, LANCZOS_LANCZOS));
755 }
756