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