]> git.sesse.net Git - vlc/blob - plugins/win32/mainframe.cpp
* ./AUTHORS: added myself :)
[vlc] / plugins / win32 / mainframe.cpp
1 /*****************************************************************************\r
2  * mainframe.cpp: Win32 interface plugin for vlc\r
3  *****************************************************************************\r
4  * Copyright (C) 2002 VideoLAN\r
5  *\r
6  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>\r
7  *\r
8  * This program is free software; you can redistribute it and/or modify\r
9  * it under the terms of the GNU General Public License as published by\r
10  * the Free Software Foundation; either version 2 of the License, or\r
11  * (at your option) any later version.\r
12  *\r
13  * This program is distributed in the hope that it will be useful,\r
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
16  * GNU General Public License for more details.\r
17  *\r
18  * You should have received a copy of the GNU General Public License\r
19  * along with this program; if not, write to the Free Software\r
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.\r
21  *****************************************************************************/\r
22 \r
23 #include <vcl.h>\r
24 #pragma hdrstop\r
25 \r
26 #include <videolan/vlc.h>\r
27 \r
28 #include "stream_control.h"\r
29 #include "input_ext-intf.h"\r
30 \r
31 #include "video.h"\r
32 #include "video_output.h"\r
33 \r
34 #include "interface.h"\r
35 #include "intf_playlist.h"\r
36 #include "intf_eject.h"\r
37 \r
38 #include "mainframe.h"\r
39 #include "menu.h"\r
40 #include "control.h"\r
41 #include "disc.h"\r
42 #include "network.h"\r
43 #include "about.h"\r
44 #include "preferences.h"\r
45 #include "messages.h"\r
46 #include "playlist.h"\r
47 #include "win32_common.h"\r
48 \r
49 #include "netutils.h"\r
50 \r
51 //---------------------------------------------------------------------------\r
52 //#pragma package(smart_init)\r
53 #pragma resource "*.dfm"\r
54 \r
55 extern struct intf_thread_s *p_intfGlobal;\r
56 extern int Win32Manage( intf_thread_t *p_intf );\r
57 \r
58 //---------------------------------------------------------------------------\r
59 __fastcall TMainFrameDlg::TMainFrameDlg( TComponent* Owner )\r
60         : TForm( Owner )\r
61 {\r
62     Application->ShowHint = true;\r
63     Application->OnHint = DisplayHint;\r
64 \r
65     TimerManage->Interval = INTF_IDLE_SLEEP / 1000;\r
66 \r
67     TrackBar->Max = SLIDER_MAX_VALUE;\r
68 \r
69     /* default height */\r
70     ClientHeight = 37 + ToolBar->Height;\r
71 \r
72     StringListPref = new TStringList();\r
73 }\r
74 //---------------------------------------------------------------------------\r
75 __fastcall TMainFrameDlg::~TMainFrameDlg()\r
76 {\r
77     delete StringListPref;\r
78 }\r
79 //---------------------------------------------------------------------------\r
80 \r
81 \r
82 /*****************************************************************************\r
83  * Event handlers\r
84  ****************************************************************************/\r
85 void __fastcall TMainFrameDlg::TimerManageTimer( TObject *Sender )\r
86 {\r
87     Win32Manage( p_intfGlobal );\r
88 }\r
89 //---------------------------------------------------------------------------\r
90 void __fastcall TMainFrameDlg::DisplayHint( TObject *Sender )\r
91 {\r
92     StatusBar->SimpleText = GetLongHint( Application->Hint );\r
93 }\r
94 //---------------------------------------------------------------------------\r
95 void __fastcall TMainFrameDlg::TrackBarChange( TObject *Sender )\r
96 {\r
97     /* This function displays the current date related to the position in\r
98      * the stream. It is called whenever the slider changes its value.\r
99      * The lock has to be taken before the function is called */\r
100 \r
101 //    vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
102 \r
103     if( p_input_bank->pp_input[0] != NULL )\r
104     {\r
105 #define p_area p_input_bank->pp_input[0]->stream.p_selected_area\r
106         char psz_time[ OFFSETTOTIME_MAX_SIZE ];\r
107         off_t Value = TrackBar->Position;\r
108 \r
109         GroupBoxSlider->Caption =\r
110                 input_OffsetToTime( p_input_bank->pp_input[0], psz_time,\r
111                         ( p_area->i_size * Value ) / (off_t)SLIDER_MAX_VALUE );\r
112 #undef p_area\r
113      }\r
114 \r
115 //    vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
116 }\r
117 //---------------------------------------------------------------------------\r
118 void __fastcall TMainFrameDlg::FormClose( TObject *Sender,\r
119       TCloseAction &Action )\r
120 {\r
121     intf_thread_t *p_intf = p_intfGlobal;\r
122 \r
123     vlc_mutex_lock( &p_intf->change_lock );\r
124     p_intf->b_die = 1;\r
125     vlc_mutex_unlock( &p_intf->change_lock );\r
126 \r
127     /* we don't destroy the form immediatly */\r
128     Action = caHide;\r
129 }\r
130 //---------------------------------------------------------------------------\r
131 \r
132 \r
133 /*****************************************************************************\r
134  * Menu callbacks\r
135  ****************************************************************************/\r
136 void __fastcall TMainFrameDlg::MenuOpenFileClick( TObject *Sender )\r
137 {\r
138     int             i_end = p_main->p_playlist->i_size;\r
139     AnsiString      FileName;\r
140     if( OpenDialog1->Execute() )\r
141     {\r
142         /* add the new file to the interface playlist */\r
143         FileName = OpenDialog1->FileName;\r
144         intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END,\r
145             (char*)FileName.c_str() );\r
146 \r
147         /* update the plugin display */\r
148         p_intfGlobal->p_sys->p_playlist->UpdateGrid( p_main->p_playlist );\r
149 \r
150         /* end current item, select added item  */\r
151         if( p_input_bank->pp_input[0] != NULL )\r
152         {\r
153             p_input_bank->pp_input[0]->b_eof = 1;\r
154         }\r
155 \r
156         intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );\r
157     };\r
158 }\r
159 //---------------------------------------------------------------------------\r
160 void __fastcall TMainFrameDlg::MenuOpenDiscClick( TObject *Sender )\r
161 {\r
162     TDiscDlg *p_disc = p_intfGlobal->p_sys->p_disc;\r
163     if( p_disc == NULL )\r
164     {\r
165         p_disc = new TDiscDlg( this );\r
166         p_intfGlobal->p_sys->p_disc = p_disc;\r
167     }\r
168     p_disc->Show();\r
169 }\r
170 //---------------------------------------------------------------------------\r
171 void __fastcall TMainFrameDlg::MenuNetworkStreamClick( TObject *Sender )\r
172 {\r
173     TNetworkDlg *p_network = p_intfGlobal->p_sys->p_network;\r
174     if( p_network == NULL )\r
175     {\r
176         p_network = new TNetworkDlg( this );\r
177         p_intfGlobal->p_sys->p_network = p_network;\r
178     }\r
179     p_network->Show();\r
180 }\r
181 //---------------------------------------------------------------------------\r
182 void __fastcall TMainFrameDlg::MenuExitClick( TObject *Sender )\r
183 {\r
184     Close();\r
185 }\r
186 //---------------------------------------------------------------------------\r
187 void __fastcall TMainFrameDlg::MenuFullscreenClick( TObject *Sender )\r
188 {\r
189     if( p_vout_bank->i_count )\r
190     {\r
191         vlc_mutex_lock( &p_vout_bank->pp_vout[0]->change_lock );\r
192 \r
193         p_vout_bank->pp_vout[0]->i_changes |= VOUT_FULLSCREEN_CHANGE;\r
194 \r
195         vlc_mutex_unlock( &p_vout_bank->pp_vout[0]->change_lock );\r
196     }\r
197 }\r
198 //---------------------------------------------------------------------------\r
199 void __fastcall TMainFrameDlg::MenuPlaylistClick( TObject *Sender )\r
200 {\r
201     TPlaylistDlg *p_playlist = p_intfGlobal->p_sys->p_playlist;\r
202     if( p_playlist->Visible )\r
203     {\r
204         p_playlist->Hide();\r
205     }\r
206     else\r
207     {\r
208         p_playlist->UpdateGrid( p_main->p_playlist );\r
209         p_playlist->Show();\r
210     }\r
211 }\r
212 //---------------------------------------------------------------------------\r
213 void __fastcall TMainFrameDlg::MenuMessagesClick( TObject *Sender )\r
214 {\r
215      p_intfGlobal->p_sys->p_messages->Show();\r
216 }\r
217 //---------------------------------------------------------------------------\r
218 void __fastcall TMainFrameDlg::MenuPreferencesClick( TObject *Sender )\r
219 {\r
220     CreatePreferences( "main" );\r
221 }\r
222 //---------------------------------------------------------------------------\r
223 void __fastcall TMainFrameDlg::MenuAboutClick( TObject *Sender )\r
224 {\r
225     p_intfGlobal->p_sys->p_about = new TAboutDlg( this );\r
226     p_intfGlobal->p_sys->p_about->ShowModal();\r
227     delete p_intfGlobal->p_sys->p_about;\r
228 }\r
229 //---------------------------------------------------------------------------\r
230 \r
231 \r
232 /*****************************************************************************\r
233  * Toolbar callbacks\r
234  ****************************************************************************/\r
235 void __fastcall TMainFrameDlg::ToolButtonFileClick( TObject *Sender )\r
236 {\r
237     MenuOpenFileClick( Sender );\r
238 }\r
239 //---------------------------------------------------------------------------\r
240 void __fastcall TMainFrameDlg::ToolButtonDiscClick( TObject *Sender )\r
241 {\r
242     MenuOpenDiscClick( Sender );\r
243 }\r
244 //---------------------------------------------------------------------------\r
245 void __fastcall TMainFrameDlg::ToolButtonNetClick( TObject *Sender )\r
246 {\r
247     MenuNetworkStreamClick( Sender );\r
248 }\r
249 //---------------------------------------------------------------------------\r
250 void __fastcall TMainFrameDlg::ToolButtonPlaylistClick( TObject *Sender )\r
251 {\r
252     MenuPlaylistClick( Sender );\r
253 }\r
254 //---------------------------------------------------------------------------\r
255 void __fastcall TMainFrameDlg::ToolButtonBackClick( TObject *Sender )\r
256 {\r
257     ControlBack( Sender );\r
258 }\r
259 //---------------------------------------------------------------------------\r
260 void __fastcall TMainFrameDlg::ToolButtonStopClick( TObject *Sender )\r
261 {\r
262     ControlStop( Sender );\r
263 }\r
264 //---------------------------------------------------------------------------\r
265 void __fastcall TMainFrameDlg::ToolButtonPlayClick( TObject *Sender )\r
266 {\r
267     ControlPlay( Sender );\r
268 }\r
269 //---------------------------------------------------------------------------\r
270 void __fastcall TMainFrameDlg::ToolButtonPauseClick( TObject *Sender )\r
271 {\r
272     ControlPause( Sender );\r
273 }\r
274 //---------------------------------------------------------------------------\r
275 void __fastcall TMainFrameDlg::ToolButtonSlowClick( TObject *Sender )\r
276 {\r
277     ControlSlow( Sender );\r
278 }\r
279 //---------------------------------------------------------------------------\r
280 void __fastcall TMainFrameDlg::ToolButtonFastClick( TObject *Sender )\r
281 {\r
282     ControlFast( Sender );\r
283 }\r
284 //---------------------------------------------------------------------------\r
285 void __fastcall TMainFrameDlg::ToolButtonPrevClick( TObject *Sender )\r
286 {\r
287     p_intfGlobal->p_sys->p_playlist->Previous();\r
288 }\r
289 //---------------------------------------------------------------------------\r
290 void __fastcall TMainFrameDlg::ToolButtonNextClick( TObject *Sender )\r
291 {\r
292     p_intfGlobal->p_sys->p_playlist->Next();\r
293 }\r
294 //---------------------------------------------------------------------------\r
295 void __fastcall TMainFrameDlg::ToolButtonEjectClick( TObject *Sender )\r
296 {\r
297     AnsiString Device = "";\r
298 \r
299     /*\r
300      * Get the active input\r
301      * Determine whether we can eject a media, ie it's a VCD or DVD\r
302      * If it's neither a VCD nor a DVD, then return\r
303      */\r
304 \r
305     if( p_main->p_playlist->current.psz_name != NULL )\r
306     {\r
307         if( strncmp( p_main->p_playlist->current.psz_name, "dvd", 3 )\r
308             || strncmp( p_main->p_playlist->current.psz_name, "vcd", 3 ) )\r
309         {\r
310             /* Determine the device name by omitting the first 4 characters\r
311              * and keeping 3 characters */\r
312             Device = strdup( ( p_main->p_playlist->current.psz_name + 4 ) );\r
313             Device = Device.SubString( 1, 2 );\r
314         }\r
315     }\r
316 \r
317     if( Device == "" )\r
318     {\r
319         return;\r
320     }\r
321 \r
322     /* If there's a stream playing, we aren't allowed to eject ! */\r
323     if( p_input_bank->pp_input[0] == NULL )\r
324     {\r
325         intf_WarnMsg( 4, "intf: ejecting %s", Device.c_str() );\r
326 \r
327         intf_Eject( Device.c_str() );\r
328     }\r
329 }\r
330 //--------------------------------------------------------------------------\r
331 \r
332 \r
333 /*****************************************************************************\r
334  * Popup callbacks\r
335  ****************************************************************************/\r
336 void __fastcall TMainFrameDlg::PopupCloseClick( TObject *Sender )\r
337 {\r
338     /* We do nothing, we just need a click on a menu item\r
339      * to close the popup. Don't ask me why... */\r
340     return;\r
341 }\r
342 //---------------------------------------------------------------------------\r
343 void __fastcall TMainFrameDlg::PopupPlayClick( TObject *Sender )\r
344 {\r
345     ToolButtonPlayClick( Sender );\r
346 }\r
347 //---------------------------------------------------------------------------\r
348 void __fastcall TMainFrameDlg::PopupPauseClick( TObject *Sender )\r
349 {\r
350     ToolButtonPauseClick( Sender );\r
351 }\r
352 //---------------------------------------------------------------------------\r
353 void __fastcall TMainFrameDlg::PopupStopClick( TObject *Sender )\r
354 {\r
355     ToolButtonStopClick( Sender );\r
356 }\r
357 //---------------------------------------------------------------------------\r
358 void __fastcall TMainFrameDlg::PopupBackClick( TObject *Sender )\r
359 {\r
360     ToolButtonBackClick( Sender );\r
361 }\r
362 //---------------------------------------------------------------------------\r
363 void __fastcall TMainFrameDlg::PopupSlowClick( TObject *Sender )\r
364 {\r
365     ToolButtonSlowClick( Sender );\r
366 }\r
367 //---------------------------------------------------------------------------\r
368 void __fastcall TMainFrameDlg::PopupFastClick( TObject *Sender )\r
369 {\r
370     ToolButtonFastClick( Sender );\r
371 }\r
372 //---------------------------------------------------------------------------\r
373 void __fastcall TMainFrameDlg::PopupToggleInterfaceClick( TObject *Sender )\r
374 {\r
375     this->BringToFront();\r
376 }\r
377 //---------------------------------------------------------------------------\r
378 void __fastcall TMainFrameDlg::PopupFullscreenClick( TObject *Sender )\r
379 {\r
380     MenuFullscreenClick( Sender );\r
381 }\r
382 //---------------------------------------------------------------------------\r
383 void __fastcall TMainFrameDlg::PopupNextClick( TObject *Sender )\r
384 {\r
385     ToolButtonNextClick( Sender );\r
386 }\r
387 //---------------------------------------------------------------------------\r
388 void __fastcall TMainFrameDlg::PopupPrevClick( TObject *Sender )\r
389 {\r
390     ToolButtonPrevClick( Sender );\r
391 }\r
392 //---------------------------------------------------------------------------\r
393 void __fastcall TMainFrameDlg::PopupJumpClick( TObject *Sender )\r
394 {\r
395     // TODO\r
396 }\r
397 //---------------------------------------------------------------------------\r
398 void __fastcall TMainFrameDlg::PopupPlaylistClick( TObject *Sender )\r
399 {\r
400     MenuPlaylistClick( Sender );\r
401 }\r
402 //---------------------------------------------------------------------------\r
403 void __fastcall TMainFrameDlg::PopupPreferencesClick( TObject *Sender )\r
404 {\r
405     MenuPreferencesClick( Sender );\r
406 }\r
407 //---------------------------------------------------------------------------\r
408 void __fastcall TMainFrameDlg::PopupExitClick( TObject *Sender )\r
409 {\r
410     MenuExitClick( Sender );\r
411 }\r
412 //---------------------------------------------------------------------------\r
413 void __fastcall TMainFrameDlg::PopupOpenFileClick( TObject *Sender )\r
414 {\r
415     MenuOpenFileClick( Sender );\r
416 }\r
417 //---------------------------------------------------------------------------\r
418 void __fastcall TMainFrameDlg::PopupOpenDiscClick( TObject *Sender )\r
419 {\r
420     MenuOpenDiscClick( Sender );\r
421 }\r
422 //---------------------------------------------------------------------------\r
423 void __fastcall TMainFrameDlg::PopupNetworkStreamClick( TObject *Sender )\r
424 {\r
425     MenuNetworkStreamClick( Sender );\r
426 }\r
427 //---------------------------------------------------------------------------\r
428 \r
429 \r
430 /*****************************************************************************\r
431  * Callbacks for DVD/VCD navigation\r
432  ****************************************************************************/\r
433 void __fastcall TMainFrameDlg::ButtonTitlePrevClick( TObject *Sender )\r
434 {\r
435     intf_thread_t * p_intf;\r
436     input_area_t  * p_area;\r
437     int             i_id;\r
438 \r
439     p_intf = p_intfGlobal;\r
440     i_id = p_input_bank->pp_input[0]->stream.p_selected_area->i_id - 1;\r
441 \r
442     /* Disallow area 0 since it is used for video_ts.vob */\r
443     if( i_id > 0 )\r
444     {\r
445         p_area = p_input_bank->pp_input[0]->stream.pp_areas[i_id];\r
446         input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );\r
447 \r
448         input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );\r
449 \r
450         p_intf->p_sys->b_title_update = 1;\r
451         vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
452         SetupMenus( p_intf );\r
453         vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
454     }\r
455 }\r
456 //---------------------------------------------------------------------------\r
457 void __fastcall TMainFrameDlg::ButtonTitleNextClick( TObject *Sender )\r
458 {\r
459     intf_thread_t * p_intf;\r
460     input_area_t  * p_area;\r
461     int             i_id;\r
462 \r
463     p_intf = p_intfGlobal;\r
464     i_id = p_input_bank->pp_input[0]->stream.p_selected_area->i_id + 1;\r
465 \r
466     if( i_id < p_input_bank->pp_input[0]->stream.i_area_nb )\r
467     {\r
468         p_area = p_input_bank->pp_input[0]->stream.pp_areas[i_id];   \r
469         input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );\r
470                   \r
471         input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );\r
472 \r
473         p_intf->p_sys->b_title_update = 1;\r
474         vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
475         SetupMenus( p_intf );\r
476         vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
477     }\r
478 }\r
479 //---------------------------------------------------------------------------\r
480 void __fastcall TMainFrameDlg::ButtonChapterPrevClick( TObject *Sender )\r
481 {\r
482     intf_thread_t * p_intf = p_intfGlobal;\r
483     input_area_t  * p_area;\r
484 \r
485     p_area = p_input_bank->pp_input[0]->stream.p_selected_area;\r
486 \r
487     if( p_area->i_part > 0 )\r
488     {\r
489         p_area->i_part--;\r
490         input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );\r
491 \r
492         input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );\r
493 \r
494         p_intf->p_sys->b_chapter_update = 1;\r
495         vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
496         SetupMenus( p_intf );\r
497         vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
498     }\r
499 }\r
500 //---------------------------------------------------------------------------\r
501 void __fastcall TMainFrameDlg::ButtonChapterNextClick( TObject *Sender )\r
502 {\r
503     intf_thread_t * p_intf = p_intfGlobal;\r
504     input_area_t  * p_area;\r
505 \r
506     p_area = p_input_bank->pp_input[0]->stream.p_selected_area;\r
507     \r
508     if( p_area->i_part < p_area->i_part_nb )\r
509     {\r
510         p_area->i_part++;\r
511         input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );\r
512 \r
513         input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );\r
514 \r
515         p_intf->p_sys->b_chapter_update = 1;\r
516         vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
517         SetupMenus( p_intf );\r
518         vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
519     }\r
520 }\r
521 //---------------------------------------------------------------------------\r
522 \r
523 \r
524 /*****************************************************************************\r
525  * Callback for the 'go!' button\r
526  ****************************************************************************/\r
527 void __fastcall TMainFrameDlg::ButtonGoClick( TObject *Sender )\r
528 {\r
529     intf_thread_t *p_intf = p_intfGlobal;\r
530     int i_channel;\r
531 \r
532     i_channel = UpDownChannel->Position;\r
533     intf_WarnMsg( 3, "intf info: joining channel %d", i_channel );\r
534 \r
535     vlc_mutex_lock( &p_intf->change_lock );\r
536     if( p_input_bank->pp_input[0] != NULL )\r
537     {\r
538         /* end playing item */\r
539         p_input_bank->pp_input[0]->b_eof = 1;\r
540 \r
541         /* update playlist */\r
542         vlc_mutex_lock( &p_main->p_playlist->change_lock );\r
543 \r
544         p_main->p_playlist->i_index--;\r
545         p_main->p_playlist->b_stopped = 1;\r
546 \r
547         vlc_mutex_unlock( &p_main->p_playlist->change_lock );\r
548 \r
549         /* FIXME: ugly hack to close input and outputs */\r
550         p_intf->pf_manage( p_intf );\r
551     }\r
552 \r
553     network_ChannelJoin( i_channel );\r
554 \r
555     /* FIXME 2 */\r
556     p_main->p_playlist->b_stopped = 0;\r
557     p_intf->pf_manage( p_intf );\r
558 \r
559     vlc_mutex_unlock( &p_intf->change_lock );\r
560 \r
561 //    input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );\r
562 }\r
563 //---------------------------------------------------------------------------\r
564 \r
565 \r
566 /*****************************************************************************\r
567  * ModeManage: actualise the aspect of the interface whenever the input\r
568  *             changes.\r
569  *****************************************************************************\r
570  * The lock has to be taken before you call the function.\r
571  *****************************************************************************/\r
572 void __fastcall TMainFrameDlg::ModeManage()\r
573 {\r
574     intf_thread_t * p_intf = p_intfGlobal;\r
575     TGroupBox     * ActiveGB;\r
576     int             i_Height;\r
577     bool            b_control;\r
578 \r
579     /* hide all boxes */\r
580     GroupBoxFile->Visible = false;\r
581     GroupBoxNetwork->Visible = false;\r
582     GroupBoxDisc->Visible = false;\r
583 \r
584     /* hide slider */\r
585     GroupBoxSlider->Hide();\r
586 \r
587     /* controls unavailable */\r
588     b_control = 0;\r
589 \r
590     /* show the box related to current input mode */\r
591     if( p_input_bank->pp_input[0] != NULL )\r
592     {\r
593         switch( p_input_bank->pp_input[0]->stream.i_method & 0xf0 )\r
594         {    \r
595             case INPUT_METHOD_FILE:\r
596                 GroupBoxFile->Visible = true;\r
597                 ActiveGB = GroupBoxFile;\r
598                 LabelFileName->Caption = p_input_bank->pp_input[0]->psz_source;\r
599                 break;\r
600             case INPUT_METHOD_DISC:\r
601                 GroupBoxDisc->Visible = true;\r
602                 ActiveGB = GroupBoxDisc;\r
603                 break;\r
604             case INPUT_METHOD_NETWORK:\r
605                 GroupBoxNetwork->Visible = true;\r
606                 ActiveGB = GroupBoxNetwork;\r
607                 LabelServer->Caption = p_input_bank->pp_input[0]->psz_source;\r
608                 if( config_GetIntVariable( "network_channel" ) )\r
609                 {\r
610                     LabelChannel->Visible = true;\r
611                 }\r
612                 else\r
613                 {\r
614                     LabelChannel->Visible = false;\r
615                 }\r
616                 break;\r
617             default:\r
618                 intf_WarnMsg( 3, "intf: can't determine input method" );\r
619                 GroupBoxFile->Visible = true;\r
620                 ActiveGB = GroupBoxFile;\r
621                 LabelFileName->Caption = p_input_bank->pp_input[0]->psz_source;\r
622                 break;\r
623         }\r
624 \r
625         i_Height = StatusBar->Height + ActiveGB->Height + ToolBar->Height + 47;\r
626 \r
627         /* initialize and show slider for seekable streams */\r
628         if( p_input_bank->pp_input[0]->stream.b_seekable )\r
629         {\r
630             TrackBar->Position = p_intf->p_sys->OldValue = 0;\r
631             GroupBoxSlider->Show();\r
632             i_Height += GroupBoxSlider->Height;\r
633         }\r
634 \r
635         /* control buttons for free pace streams */\r
636         b_control = p_input_bank->pp_input[0]->stream.b_pace_control;\r
637 \r
638         /* get ready for menu regeneration */\r
639         p_intf->p_sys->b_program_update = 1;\r
640         p_intf->p_sys->b_title_update = 1;\r
641         p_intf->p_sys->b_chapter_update = 1;\r
642         p_intf->p_sys->b_audio_update = 1;\r
643         p_intf->p_sys->b_spu_update = 1;\r
644         p_intf->p_sys->i_part = 0;\r
645 \r
646         p_input_bank->pp_input[0]->stream.b_changed = 0;\r
647         intf_WarnMsg( 3, "intf: stream has changed, refreshing interface" );\r
648     }\r
649     else\r
650     {\r
651         i_Height = StatusBar->Height + ToolBar->Height + 47;\r
652 \r
653         if( config_GetIntVariable( "network_channel" ) )\r
654         {\r
655             GroupBoxNetwork->Visible = true;\r
656             LabelChannel->Visible = true;\r
657             i_Height += GroupBoxNetwork->Height;\r
658         }\r
659         else\r
660         {\r
661             /* unsensitize menus */\r
662             MenuProgram->Enabled = false;\r
663             MenuTitle->Enabled = false;\r
664             MenuChapter->Enabled = false;\r
665             MenuAudio->Enabled = false;\r
666             MenuSubtitles->Enabled = false;\r
667             PopupNavigation->Enabled = false;\r
668             PopupAudio->Enabled = false;\r
669             PopupSubtitles->Enabled = false;\r
670         }\r
671     }\r
672 \r
673     /* resize main window */\r
674     this->Height = i_Height;\r
675 \r
676     /* set control items */\r
677     ToolButtonBack->Enabled = false;\r
678     ToolButtonStop->Enabled = true;\r
679     ToolButtonEject->Enabled = !b_control;\r
680     ToolButtonPause->Enabled = b_control;\r
681     ToolButtonSlow->Enabled = b_control;\r
682     ToolButtonFast->Enabled = b_control;\r
683     PopupBack->Enabled = false;\r
684     PopupPause->Enabled = b_control;\r
685     PopupSlow->Enabled = b_control;\r
686     PopupFast->Enabled = b_control;\r
687 }\r
688 //---------------------------------------------------------------------------\r
689 \r
690 \r
691 /*****************************************************************************\r
692  * CreateConfig: create a configuration dialog and save it for further use\r
693  *****************************************************************************\r
694  * Check if the dialog box is already opened, if so this will save us\r
695  * quite a bit of work. (the interface will be destroyed when you actually\r
696  * close the main window, but remember that it is only hidden if you\r
697  * clicked on the action buttons). This trick also allows us not to\r
698  * duplicate identical dialog windows.\r
699  *****************************************************************************/\r
700 void __fastcall TMainFrameDlg::CreatePreferences( AnsiString Name )\r
701 {\r
702     TPreferencesDlg *Preferences;\r
703     int i_index, i_pos;\r
704 \r
705     i_index = StringListPref->IndexOf( Name );\r
706     if( i_index != -1 )\r
707     {\r
708         /* config dialog already exists */\r
709         Preferences = (TPreferencesDlg *)StringListPref->Objects[i_index];\r
710     }\r
711     else\r
712     {\r
713         /* create the config dialog */\r
714         Preferences = new TPreferencesDlg( this );\r
715         Preferences->CreateConfigDialog( Name.c_str() );\r
716 \r
717         /* save it */\r
718         i_pos = StringListPref->Add( Name );\r
719         StringListPref->Objects[i_pos] = Preferences;\r
720     }\r
721 \r
722     /* display the dialog */\r
723     Preferences->Show();\r
724 }\r
725 //---------------------------------------------------------------------------\r
726 \r