avoid overloaded casting pun tripping compiler
[goodguy/history.git] / cinelerra-5.1 / cinelerra / interfaceprefs.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 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 "deleteallindexes.h"
23 #include "edl.h"
24 #include "edlsession.h"
25 #include "language.h"
26 #include "mwindow.h"
27 #include "preferences.h"
28 #include "preferencesthread.h"
29 #include "interfaceprefs.h"
30 #include "shbtnprefs.h"
31 #include "theme.h"
32
33 #if 0
34 N_("Drag all following edits")
35 N_("Drag only one edit")
36 N_("Drag source only")
37 N_("No effect")
38 #endif
39
40 #define MOVE_ALL_EDITS_TITLE "Drag all following edits"
41 #define MOVE_ONE_EDIT_TITLE "Drag only one edit"
42 #define MOVE_NO_EDITS_TITLE "Drag source only"
43 #define MOVE_EDITS_DISABLED_TITLE "No effect"
44
45 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
46  : PreferencesDialog(mwindow, pwindow)
47 {
48         hms = 0;
49         hmsf = 0;
50         samples = 0;
51         frames = 0;
52         hex = 0;
53         feet = 0;
54         min_db = 0;
55         max_db = 0;
56 //      vu_db = 0;
57 //      vu_int = 0;
58         thumbnails = 0;
59         shbtn_dialog = 0;
60 }
61
62 InterfacePrefs::~InterfacePrefs()
63 {
64         delete hms;
65         delete hmsf;
66         delete samples;
67         delete frames;
68         delete hex;
69         delete feet;
70         delete min_db;
71         delete max_db;
72 //      delete vu_db;
73 //      delete vu_int;
74         delete thumbnails;
75         delete shbtn_dialog;
76 }
77
78
79 void InterfacePrefs::create_objects()
80 {
81         int x, y;
82         BC_Resources *resources = BC_WindowBase::get_resources();
83         int margin = mwindow->theme->widget_border;
84         char string[BCTEXTLEN];
85         x = mwindow->theme->preferencesoptions_x;
86         y = mwindow->theme->preferencesoptions_y;
87
88         add_subwindow(new BC_Title(x, y, 
89                 _("Time Format"), 
90                 LARGEFONT, 
91                 resources->text_default));
92
93         y += get_text_height(LARGEFONT) + 5;
94
95         int y1 = y;
96
97         add_subwindow(hms = new TimeFormatHMS(pwindow, this, 
98                 pwindow->thread->edl->session->time_format == TIME_HMS, 
99                 x, y));
100         y += 20;
101         add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this, 
102                 pwindow->thread->edl->session->time_format == TIME_HMSF, 
103                 x, y));
104         y += 20;
105         add_subwindow(samples = new TimeFormatSamples(pwindow, this, 
106                 pwindow->thread->edl->session->time_format == TIME_SAMPLES, 
107                 x, y));
108         y += 20;
109         add_subwindow(hex = new TimeFormatHex(pwindow, this, 
110                 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX, 
111                 x, y));
112         y += 20;
113         add_subwindow(frames = new TimeFormatFrames(pwindow, this, 
114                 pwindow->thread->edl->session->time_format == TIME_FRAMES, 
115                 x, y));
116         y += 20;
117         int x1 = x;
118         add_subwindow(feet = new TimeFormatFeet(pwindow, this, 
119                 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES, 
120                 x1, y));
121         x1 += feet->get_w() + margin;
122         BC_Title *title;
123         add_subwindow(title = new BC_Title(x1, y, _("Frames per foot:")));
124         x1 += title->get_w() + margin;
125         sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
126         add_subwindow(new TimeFormatFeetSetting(pwindow, 
127                 x1, y - 5,      string));
128         y += 20;
129         add_subwindow(seconds = new TimeFormatSeconds(pwindow, this, 
130                 pwindow->thread->edl->session->time_format == TIME_SECONDS, 
131                 x, y));
132         y += 35;
133
134         x1 = get_w()/2;
135         UseTipWindow *tip_win = new UseTipWindow(pwindow, x1, y1);
136         add_subwindow(tip_win);
137         y1 += tip_win->get_h() + 5;
138         UseWarnIndecies *idx_win = new UseWarnIndecies(pwindow, x1, y1);
139         add_subwindow(idx_win);
140         y1 += idx_win->get_h() + 25;
141
142         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
143         y += 5;
144
145         add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, resources->text_default));
146
147
148         y += 25;
149         add_subwindow(new BC_Title(x, y + 5, 
150                 _("Index files go here:"), MEDIUMFONT, resources->text_default));
151         add_subwindow(ipathtext = new IndexPathText(x + 230, y, 
152                 pwindow, 
153                 pwindow->thread->preferences->index_directory));
154         add_subwindow(ipath = new BrowseButton(mwindow, this,
155                 ipathtext, 
156                 x + 230 + ipathtext->get_w(), y, 
157                 pwindow->thread->preferences->index_directory,
158                 _("Index Path"), 
159                 _("Select the directory for index files"),
160                 1));
161
162         y += 30;
163         add_subwindow(new BC_Title(x, y + 5, 
164                 _("Size of index file:"), 
165                 MEDIUMFONT, 
166                 resources->text_default));
167         sprintf(string, "%jd", pwindow->thread->preferences->index_size);
168         add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
169         add_subwindow(new ScanCommercials(pwindow, 350,y));
170         y += 30;
171         add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, resources->text_default));
172         sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
173         add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
174         add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
175
176
177
178
179
180         y += 35;
181         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
182         y += 5;
183
184         add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, resources->text_default));
185
186         y1 = y + 5;
187         y += 35;
188         add_subwindow(title = new BC_Title(x, y, _("Keyframe reticle:")));
189         x1 = x + title->get_w() + 10;
190         keyframe_reticle = new KeyframeReticle(x1, y, &pwindow->thread->preferences->keyframe_reticle);
191         add_subwindow(keyframe_reticle);
192         keyframe_reticle->create_objects();
193
194         int x2 = x + 400, y2 = y;
195         add_subwindow(thumbnails = new ViewThumbnails(x2, y1, pwindow));
196         AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y2);
197         add_subwindow(android_remote);
198         y2 += android_remote->get_h() + 10;
199         add_subwindow(title = new BC_Title(x2, y2, _("Port:")));
200         int x3 = x2 + title->get_w() + margin;
201         AndroidPort *android_port = new AndroidPort(pwindow, x3, y2);
202         add_subwindow(android_port);
203         y2 += title->get_h() + 10;
204         add_subwindow(title = new BC_Title(x2, y2, _("PIN:")));
205         AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y2);
206         add_subwindow(android_pin);
207
208         y2 += title->get_h() + 30;
209         ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y2);
210         add_subwindow(shbtn_prefs);
211
212         y2 += shbtn_prefs->get_h() + 30;
213         StillImageUseDuration *use_stduration = new StillImageUseDuration(pwindow,
214                 pwindow->thread->edl->session->si_useduration, x2, y2);
215         add_subwindow(use_stduration);
216         int tw = 0, th = 0;
217         BC_CheckBox::calculate_extents(this, &tw, &th, 0, 0);
218         x2 += tw + 3;
219         y2 += use_stduration->get_h() + 3;
220         StillImageDuration *stduration = new StillImageDuration(pwindow, x2, y2);
221         add_subwindow(stduration);
222         x2 += stduration->get_w() + 10;
223         y2 += 3;
224         add_subwindow(new BC_Title(x2, y2, _("Seconds")));
225
226         y += 35;
227         add_subwindow(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
228         y += 25;
229         add_subwindow(new BC_Title(x, y, _("Button 1:")));
230         
231         ViewBehaviourText *text;
232         add_subwindow(text = new ViewBehaviourText(80, y - 5, 
233                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]), 
234                         pwindow, 
235                         &(pwindow->thread->edl->session->edit_handle_mode[0])));
236         text->create_objects();
237         y += 30;
238         add_subwindow(new BC_Title(x, y, _("Button 2:")));
239         add_subwindow(text = new ViewBehaviourText(80, 
240                 y - 5, 
241                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]), 
242                         pwindow, 
243                         &(pwindow->thread->edl->session->edit_handle_mode[1])));
244         text->create_objects();
245         y += 30;
246         add_subwindow(new BC_Title(x, y, _("Button 3:")));
247         add_subwindow(text = new ViewBehaviourText(80, 
248                 y - 5, 
249                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]), 
250                         pwindow, 
251                         &(pwindow->thread->edl->session->edit_handle_mode[2])));
252         text->create_objects();
253
254         y += 40;
255         x1 = x;
256         add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
257         x += title->get_w() + 10;
258         sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
259         add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
260
261         x += min_db->get_w() + 10;
262         add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
263         x += title->get_w() + 10;
264         sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
265         add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
266
267         x = x1;
268         y += 30;
269         ViewTheme *theme;
270         add_subwindow(new BC_Title(x, y, _("Theme:")));
271         x += 60;
272         add_subwindow(theme = new ViewTheme(x, y, pwindow));
273         theme->create_objects();
274
275 }
276
277 const char* InterfacePrefs::behavior_to_text(int mode)
278 {
279         switch(mode)
280         {
281                 case MOVE_ALL_EDITS:
282                         return _(MOVE_ALL_EDITS_TITLE);
283                         break;
284                 case MOVE_ONE_EDIT:
285                         return _(MOVE_ONE_EDIT_TITLE);
286                         break;
287                 case MOVE_NO_EDITS:
288                         return _(MOVE_NO_EDITS_TITLE);
289                         break;
290                 case MOVE_EDITS_DISABLED:
291                         return _(MOVE_EDITS_DISABLED_TITLE);
292                         break;
293                 default:
294                         return "";
295                         break;
296         }
297 }
298
299 int InterfacePrefs::update(int new_value)
300 {
301         pwindow->thread->redraw_times = 1;
302         pwindow->thread->edl->session->time_format = new_value;
303         hms->update(new_value == TIME_HMS);
304         hmsf->update(new_value == TIME_HMSF);
305         samples->update(new_value == TIME_SAMPLES);
306         hex->update(new_value == TIME_SAMPLES_HEX);
307         frames->update(new_value == TIME_FRAMES);
308         feet->update(new_value == TIME_FEET_FRAMES);
309         seconds->update(new_value == TIME_SECONDS);
310         return 0;
311 }
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327 IndexPathText::IndexPathText(int x, 
328         int y, 
329         PreferencesWindow *pwindow, 
330         char *text)
331  : BC_TextBox(x, y, 240, 1, text)
332 {
333         this->pwindow = pwindow; 
334 }
335
336 IndexPathText::~IndexPathText() {}
337
338 int IndexPathText::handle_event()
339 {
340         strcpy(pwindow->thread->preferences->index_directory, get_text());
341         return 1;
342 }
343
344
345
346
347 IndexSize::IndexSize(int x, 
348         int y, 
349         PreferencesWindow *pwindow, 
350         char *text)
351  : BC_TextBox(x, y, 100, 1, text)
352
353         this->pwindow = pwindow; 
354 }
355
356 int IndexSize::handle_event()
357 {
358         long result;
359
360         result = atol(get_text());
361         if(result < 64000) result = 64000;
362         //if(result < 500000) result = 500000;
363         pwindow->thread->preferences->index_size = result;
364         return 0;
365 }
366
367
368
369 IndexCount::IndexCount(int x, 
370         int y, 
371         PreferencesWindow *pwindow, 
372         char *text)
373  : BC_TextBox(x, y, 100, 1, text)
374
375         this->pwindow = pwindow; 
376 }
377
378 int IndexCount::handle_event()
379 {
380         long result;
381
382         result = atol(get_text());
383         if(result < 1) result = 1;
384         pwindow->thread->preferences->index_count = result;
385         return 0;
386 }
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
403  : BC_Radial(x, y, value, TIME_HMS_TEXT)
404 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
405
406 int TimeFormatHMS::handle_event()
407 {
408         tfwindow->update(TIME_HMS);
409         return 1;
410 }
411
412 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
413  : BC_Radial(x, y, value, TIME_HMSF_TEXT)
414 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
415
416 int TimeFormatHMSF::handle_event()
417 {
418         tfwindow->update(TIME_HMSF);
419         return 1;
420 }
421
422 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
423  : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
424 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
425
426 int TimeFormatSamples::handle_event()
427 {
428         tfwindow->update(TIME_SAMPLES);
429         return 1;
430 }
431
432 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
433  : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
434 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
435
436 int TimeFormatFrames::handle_event()
437 {
438         tfwindow->update(TIME_FRAMES);
439         return 1;
440 }
441
442 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
443  : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
444 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
445
446 int TimeFormatHex::handle_event()
447 {
448         tfwindow->update(TIME_SAMPLES_HEX);
449         return 1;
450 }
451
452 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
453  : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
454
455         this->pwindow = pwindow; 
456         this->tfwindow = tfwindow; 
457 }
458
459 int TimeFormatSeconds::handle_event()
460 {
461         tfwindow->update(TIME_SECONDS);
462         return 1;
463 }
464
465 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
466  : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
467 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
468
469 int TimeFormatFeet::handle_event()
470 {
471         tfwindow->update(TIME_FEET_FRAMES);
472         return 1;
473 }
474
475 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
476  : BC_TextBox(x, y, 90, 1, string)
477 { this->pwindow = pwindow; }
478
479 int TimeFormatFeetSetting::handle_event()
480 {
481         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
482         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
483         return 0;
484 }
485
486
487
488
489 ViewBehaviourText::ViewBehaviourText(int x, 
490         int y, 
491         const char *text, 
492         PreferencesWindow *pwindow, 
493         int *output)
494  : BC_PopupMenu(x, y, 200, text)
495 {
496         this->output = output;
497 }
498
499 ViewBehaviourText::~ViewBehaviourText()
500 {
501 }
502
503 int ViewBehaviourText::handle_event()
504 {
505         return 0;
506 }
507
508 void ViewBehaviourText::create_objects()
509 {
510 // Video4linux versions are automatically detected
511         add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
512         add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
513         add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
514         add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
515 }
516
517
518 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
519  : BC_MenuItem(text)
520 {
521         this->popup = popup;
522         this->behaviour = behaviour;
523 }
524
525 ViewBehaviourItem::~ViewBehaviourItem()
526 {
527 }
528
529 int ViewBehaviourItem::handle_event()
530 {
531         popup->set_text(get_text());
532         *(popup->output) = behaviour;
533         return 1;
534 }
535
536
537
538
539 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
540  : BC_TextBox(x, y, 50, 1, text)
541
542         this->pwindow = pwindow; 
543 }
544
545 int MeterMinDB::handle_event()
546
547         pwindow->thread->redraw_meters = 1;
548         pwindow->thread->edl->session->min_meter_db = atol(get_text()); 
549         return 0;
550 }
551
552
553
554
555 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
556  : BC_TextBox(x, y, 50, 1, text)
557
558         this->pwindow = pwindow; 
559 }
560
561 int MeterMaxDB::handle_event()
562
563         pwindow->thread->redraw_meters = 1;
564         pwindow->thread->edl->session->max_meter_db = atol(get_text()); 
565         return 0;
566 }
567
568
569
570
571
572 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
573  : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
574
575         this->pwindow = pwindow; 
576 }
577
578 int MeterVUDB::handle_event() 
579
580         pwindow->thread->redraw_meters = 1;
581 //      vu_int->update(0); 
582         pwindow->thread->edl->session->meter_format = METER_DB; 
583         return 1;
584 }
585
586 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
587  : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
588
589         this->pwindow = pwindow; 
590 }
591
592 int MeterVUInt::handle_event() 
593
594         pwindow->thread->redraw_meters = 1;
595         vu_db->update(0); 
596         pwindow->thread->edl->session->meter_format = METER_INT; 
597         return 1;
598 }
599
600
601
602
603 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
604  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
605 {
606         this->pwindow = pwindow;
607 }
608 ViewTheme::~ViewTheme()
609 {
610 }
611
612 void ViewTheme::create_objects()
613 {
614         ArrayList<PluginServer*> themes;
615         MWindow::search_plugindb(0, 
616                 0, 
617                 0, 
618                 0,
619                 1,
620                 themes);
621
622         for(int i = 0; i < themes.total; i++)
623         {
624                 add_item(new ViewThemeItem(this, themes.values[i]->title));
625         }
626 }
627
628 int ViewTheme::handle_event()
629 {
630         return 1;
631 }
632
633
634
635
636
637 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
638  : BC_MenuItem(text)
639 {
640         this->popup = popup;
641 }
642
643 int ViewThemeItem::handle_event()
644 {
645         popup->set_text(get_text());
646         strcpy(popup->pwindow->thread->preferences->theme, get_text());
647         popup->handle_event();
648         return 1;
649 }
650
651 ViewThumbnails::ViewThumbnails(int x, 
652         int y, 
653         PreferencesWindow *pwindow)
654  : BC_CheckBox(x, 
655         y, 
656         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
657 {
658         this->pwindow = pwindow;
659 }
660
661 int ViewThumbnails::handle_event()
662 {
663         pwindow->thread->preferences->use_thumbnails = get_value();
664         return 1;
665 }
666
667
668
669 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
670  : BC_CheckBox(x, 
671         y, 
672         pwindow->thread->preferences->use_tipwindow, 
673         _("Show tip of the day"))
674 {
675         this->pwindow = pwindow;
676 }
677 int UseTipWindow::handle_event()
678 {
679         pwindow->thread->preferences->use_tipwindow = get_value();
680         return 1;
681 }
682
683
684 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
685  : BC_CheckBox(x, 
686         y, 
687         pwindow->thread->preferences->warn_indexes, 
688         _("ffmpeg probe warns rebuild indexes"))
689 {
690         this->pwindow = pwindow;
691 }
692
693 int UseWarnIndecies::handle_event()
694 {
695         pwindow->thread->preferences->warn_indexes = get_value();
696         return 1;
697 }
698
699
700 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
701  : BC_CheckBox(x, 
702         y, 
703         pwindow->thread->preferences->scan_commercials, 
704         _("Scan for commercials during toc build"))
705 {
706         this->pwindow = pwindow;
707 }
708 int ScanCommercials::handle_event()
709 {
710         pwindow->thread->preferences->scan_commercials = get_value();
711         return 1;
712 }
713
714
715 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
716  : BC_CheckBox(x, y, 
717         pwindow->thread->preferences->android_remote, 
718         _("Android Remote Control"))
719 {
720         this->pwindow = pwindow;
721 }
722 int AndroidRemote::handle_event()
723 {
724         pwindow->thread->preferences->android_remote = get_value();
725         return 1;
726 }
727
728 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
729  : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
730 {
731         this->pwindow = pwindow;
732 }
733
734 int AndroidPIN::handle_event()
735 {
736         char *txt = pwindow->thread->preferences->android_pin;
737         int len = sizeof(pwindow->thread->preferences->android_pin);
738         strncpy(txt, get_text(), len);
739         return 1;
740 }
741
742
743 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
744  : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
745 {
746         this->pwindow = pwindow;
747 }
748
749 int AndroidPort::handle_event()
750 {
751         unsigned short port = atoi(get_text());
752         if( port < 1024 ) port = 1024;
753         pwindow->thread->preferences->android_port = port;
754         char str[BCSTRLEN];
755         sprintf(str,"%u",port);
756         update(str);
757         return 1;
758 }
759
760 int InterfacePrefs::start_shbtn_dialog()
761 {
762         if( !shbtn_dialog )
763                 shbtn_dialog = new ShBtnEditDialog(pwindow);
764         shbtn_dialog->start();
765         return 1;
766 }
767
768 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
769  : BC_GenericButton(x, y, _("Shell Commands"))
770 {
771         this->pwindow = pwindow;
772         this->iface_prefs = iface_prefs;
773         set_tooltip(_("Main Menu Shell Commands"));
774 }
775
776 int ShBtnPrefs::handle_event()
777 {
778         return iface_prefs->start_shbtn_dialog();
779 }
780
781
782 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
783  : BC_CheckBox(x, y, value, _("Import images with a duration of"))
784
785         this->pwindow = pwindow; 
786 }
787
788 int StillImageUseDuration::handle_event()
789 {
790         pwindow->thread->edl->session->si_useduration = get_value();
791         return 1;
792 }
793
794 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
795  : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->si_duration)
796 {
797         this->pwindow = pwindow;
798 }
799 int StillImageDuration::handle_event()
800 {
801         pwindow->thread->edl->session->si_duration = atof(get_text());
802         return 1;
803 }
804
805
806 HairlineItem::HairlineItem(KeyframeReticle *popup, int hairline)
807  : BC_MenuItem(popup->hairline_to_string(hairline))
808 {
809         this->popup = popup;
810         this->hairline = hairline;
811 }
812
813 HairlineItem::~HairlineItem()
814 {
815 }
816
817 int HairlineItem::handle_event()
818 {
819         popup->set_text(get_text());
820         *(popup->output) = hairline;
821         return 1;
822 }
823
824
825 KeyframeReticle::KeyframeReticle(int x, int y, int *output)
826  : BC_PopupMenu(x, y, 175, hairline_to_string(*output))
827 {
828         this->output = output;
829 }
830
831 KeyframeReticle::~KeyframeReticle()
832 {
833 }
834
835 const char *KeyframeReticle::hairline_to_string(int type)
836 {
837         switch( type ) {
838         case HAIRLINE_NEVER:    return _("Never");
839         case HAIRLINE_DRAGGING: return _("Dragging");
840         case HAIRLINE_ALWAYS:   return _("Always");
841         }
842         return _("Unknown");
843 }
844
845 void KeyframeReticle::create_objects()
846 {
847         add_item(new HairlineItem(this, HAIRLINE_NEVER));
848         add_item(new HairlineItem(this, HAIRLINE_DRAGGING));
849         add_item(new HairlineItem(this, HAIRLINE_ALWAYS));
850 }
851