]> git.sesse.net Git - vlc/blob - plugins/win32/mainframe.cpp
* Added a win32 interface plugin, developed with Borland C++ Builder.
[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 = 65;\r
71 }\r
72 //---------------------------------------------------------------------------\r
73 \r
74 \r
75 /*****************************************************************************\r
76  * Event handlers\r
77  ****************************************************************************/\r
78 void __fastcall TMainFrameDlg::TimerManageTimer( TObject *Sender )\r
79 {\r
80     Win32Manage( p_intfGlobal );\r
81 }\r
82 //---------------------------------------------------------------------------\r
83 void __fastcall TMainFrameDlg::DisplayHint( TObject *Sender )\r
84 {\r
85     StatusBar->SimpleText = GetLongHint( Application->Hint );\r
86 }\r
87 //---------------------------------------------------------------------------\r
88 void __fastcall TMainFrameDlg::TrackBarChange( TObject *Sender )\r
89 {\r
90     /* This function displays the current date related to the position in\r
91      * the stream. It is called whenever the slider changes its value.\r
92      * The lock has to be taken before the function is called */\r
93 \r
94 //    vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
95 \r
96     if( p_input_bank->pp_input[0] != NULL )\r
97     {\r
98 #define p_area p_input_bank->pp_input[0]->stream.p_selected_area\r
99         char psz_time[ OFFSETTOTIME_MAX_SIZE ];\r
100         off_t Value = TrackBar->Position;\r
101 \r
102         GroupBoxSlider->Caption =\r
103                 input_OffsetToTime( p_input_bank->pp_input[0], psz_time,\r
104                         ( p_area->i_size * Value ) / (off_t)SLIDER_MAX_VALUE );\r
105 #undef p_area\r
106      }\r
107 \r
108 //    vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
109 }\r
110 //---------------------------------------------------------------------------\r
111 void __fastcall TMainFrameDlg::FormClose( TObject *Sender,\r
112       TCloseAction &Action )\r
113 {\r
114     intf_thread_t *p_intf = p_intfGlobal;\r
115 \r
116     vlc_mutex_lock( &p_intf->change_lock );\r
117     p_intf->b_die = 1;\r
118     vlc_mutex_unlock( &p_intf->change_lock );\r
119 \r
120     /* we don't destroy the form immediatly */\r
121     Action = caHide;\r
122 }\r
123 //---------------------------------------------------------------------------\r
124 \r
125 \r
126 /*****************************************************************************\r
127  * Menu callbacks\r
128  ****************************************************************************/\r
129 void __fastcall TMainFrameDlg::MenuOpenFileClick( TObject *Sender )\r
130 {\r
131     int             i_end = p_main->p_playlist->i_size;\r
132     AnsiString      FileName;\r
133     if( OpenDialog1->Execute() )\r
134     {\r
135         /* add the new file to the interface playlist */\r
136         FileName = OpenDialog1->FileName;\r
137         intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END,\r
138             (char*)FileName.c_str() );\r
139 \r
140         /* update the plugin display */\r
141         p_intfGlobal->p_sys->p_playlist->UpdateGrid( p_main->p_playlist );\r
142 \r
143         /* end current item, select added item  */\r
144         if( p_input_bank->pp_input[0] != NULL )\r
145         {\r
146             p_input_bank->pp_input[0]->b_eof = 1;\r
147         }\r
148 \r
149         intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );\r
150     };\r
151 }\r
152 //---------------------------------------------------------------------------\r
153 void __fastcall TMainFrameDlg::MenuOpenDiscClick( TObject *Sender )\r
154 {\r
155     TDiscDlg *p_disc = p_intfGlobal->p_sys->p_disc;\r
156     if( p_disc == NULL )\r
157     {\r
158         p_disc = new TDiscDlg( this );\r
159         p_intfGlobal->p_sys->p_disc = p_disc;\r
160     }\r
161     p_disc->Show();\r
162 }\r
163 //---------------------------------------------------------------------------\r
164 void __fastcall TMainFrameDlg::MenuNetworkStreamClick( TObject *Sender )\r
165 {\r
166     TNetworkDlg *p_network = p_intfGlobal->p_sys->p_network;\r
167     if( p_network == NULL )\r
168     {\r
169         p_network = new TNetworkDlg( this );\r
170         p_intfGlobal->p_sys->p_network = p_network;\r
171     }\r
172     p_network->Show();\r
173 }\r
174 //---------------------------------------------------------------------------\r
175 void __fastcall TMainFrameDlg::MenuExitClick( TObject *Sender )\r
176 {\r
177     Close();\r
178 }\r
179 //---------------------------------------------------------------------------\r
180 void __fastcall TMainFrameDlg::MenuFullscreenClick( TObject *Sender )\r
181 {\r
182     if( p_vout_bank->i_count )\r
183     {\r
184         vlc_mutex_lock( &p_vout_bank->pp_vout[0]->change_lock );\r
185 \r
186         p_vout_bank->pp_vout[0]->i_changes |= VOUT_FULLSCREEN_CHANGE;\r
187 \r
188         vlc_mutex_unlock( &p_vout_bank->pp_vout[0]->change_lock );\r
189     }\r
190 }\r
191 //---------------------------------------------------------------------------\r
192 void __fastcall TMainFrameDlg::MenuPlaylistClick( TObject *Sender )\r
193 {\r
194     TPlaylistDlg *p_playlist = p_intfGlobal->p_sys->p_playlist;\r
195     if( p_playlist->Visible )\r
196     {\r
197         p_playlist->Hide();\r
198     }\r
199     else\r
200     {\r
201         p_playlist->UpdateGrid( p_main->p_playlist );\r
202         p_playlist->Show();\r
203     }\r
204 }\r
205 //---------------------------------------------------------------------------\r
206 void __fastcall TMainFrameDlg::MenuMessagesClick( TObject *Sender )\r
207 {\r
208      p_intfGlobal->p_sys->p_messages->Show();\r
209 }\r
210 //---------------------------------------------------------------------------\r
211 void __fastcall TMainFrameDlg::MenuPreferencesClick( TObject *Sender )\r
212 {\r
213     TPreferencesDlg *p_preferences = p_intfGlobal->p_sys->p_preferences;\r
214     if( p_preferences == NULL )\r
215     {\r
216         p_preferences = new TPreferencesDlg( this );\r
217         p_preferences->CreateConfigDialog( "main" );\r
218         p_intfGlobal->p_sys->p_preferences = p_preferences;\r
219     }\r
220     else\r
221     {\r
222         p_preferences->Show();\r
223     }\r
224 }\r
225 //---------------------------------------------------------------------------\r
226 void __fastcall TMainFrameDlg::MenuAboutClick( TObject *Sender )\r
227 {\r
228     p_intfGlobal->p_sys->p_about = new TAboutDlg( this );\r
229     p_intfGlobal->p_sys->p_about->ShowModal();\r
230     delete p_intfGlobal->p_sys->p_about;\r
231 }\r
232 //---------------------------------------------------------------------------\r
233 \r
234 \r
235 /*****************************************************************************\r
236  * Toolbar callbacks\r
237  ****************************************************************************/\r
238 void __fastcall TMainFrameDlg::ToolButtonFileClick( TObject *Sender )\r
239 {\r
240     MenuOpenFileClick( Sender );\r
241 }\r
242 //---------------------------------------------------------------------------\r
243 void __fastcall TMainFrameDlg::ToolButtonDiscClick( TObject *Sender )\r
244 {\r
245     MenuOpenDiscClick( Sender );\r
246 }\r
247 //---------------------------------------------------------------------------\r
248 void __fastcall TMainFrameDlg::ToolButtonNetClick( TObject *Sender )\r
249 {\r
250     MenuNetworkStreamClick( Sender );\r
251 }\r
252 //---------------------------------------------------------------------------\r
253 void __fastcall TMainFrameDlg::ToolButtonPlaylistClick( TObject *Sender )\r
254 {\r
255     MenuPlaylistClick( Sender );\r
256 }\r
257 //---------------------------------------------------------------------------\r
258 void __fastcall TMainFrameDlg::ToolButtonBackClick( TObject *Sender )\r
259 {\r
260     ControlBack( Sender );\r
261 }\r
262 //---------------------------------------------------------------------------\r
263 void __fastcall TMainFrameDlg::ToolButtonStopClick( TObject *Sender )\r
264 {\r
265     ControlStop( Sender );\r
266 }\r
267 //---------------------------------------------------------------------------\r
268 void __fastcall TMainFrameDlg::ToolButtonPlayClick( TObject *Sender )\r
269 {\r
270     ControlPlay( Sender );\r
271 }\r
272 //---------------------------------------------------------------------------\r
273 void __fastcall TMainFrameDlg::ToolButtonPauseClick( TObject *Sender )\r
274 {\r
275     ControlPause( Sender );\r
276 }\r
277 //---------------------------------------------------------------------------\r
278 void __fastcall TMainFrameDlg::ToolButtonSlowClick( TObject *Sender )\r
279 {\r
280     ControlSlow( Sender );\r
281 }\r
282 //---------------------------------------------------------------------------\r
283 void __fastcall TMainFrameDlg::ToolButtonFastClick( TObject *Sender )\r
284 {\r
285     ControlFast( Sender );\r
286 }\r
287 //---------------------------------------------------------------------------\r
288 void __fastcall TMainFrameDlg::ToolButtonPrevClick( TObject *Sender )\r
289 {\r
290     p_intfGlobal->p_sys->p_playlist->Previous();\r
291 }\r
292 //---------------------------------------------------------------------------\r
293 void __fastcall TMainFrameDlg::ToolButtonNextClick( TObject *Sender )\r
294 {\r
295     p_intfGlobal->p_sys->p_playlist->Next();\r
296 }\r
297 //---------------------------------------------------------------------------\r
298 void __fastcall TMainFrameDlg::ToolButtonEjectClick( TObject *Sender )\r
299 {\r
300     AnsiString Device = "";\r
301 \r
302     /*\r
303      * Get the active input\r
304      * Determine whether we can eject a media, ie it's a VCD or DVD\r
305      * If it's neither a VCD nor a DVD, then return\r
306      */\r
307 \r
308     if( p_main->p_playlist->current.psz_name != NULL )\r
309     {\r
310         if( strncmp( p_main->p_playlist->current.psz_name, "dvd", 3 )\r
311             || strncmp( p_main->p_playlist->current.psz_name, "vcd", 3 ) )\r
312         {\r
313             /* Determine the device name by omitting the first 4 characters\r
314              * and keeping 3 characters */\r
315             Device = strdup( ( p_main->p_playlist->current.psz_name + 4 ) );\r
316             Device = Device.SubString( 1, 2 );\r
317         }\r
318     }\r
319 \r
320     if( Device == "" )\r
321     {\r
322         return;\r
323     }\r
324 \r
325     /* If there's a stream playing, we aren't allowed to eject ! */\r
326     if( p_input_bank->pp_input[0] == NULL )\r
327     {\r
328         intf_WarnMsg( 4, "intf: ejecting %s", Device.c_str() );\r
329 \r
330         intf_Eject( Device.c_str() );\r
331     }\r
332 }\r
333 //--------------------------------------------------------------------------\r
334 \r
335 \r
336 /*****************************************************************************\r
337  * Popup callbacks\r
338  ****************************************************************************/\r
339 void __fastcall TMainFrameDlg::PopupCloseClick( TObject *Sender )\r
340 {\r
341     /* We do nothing, we just need a click on a menu item\r
342      * to close the popup. Don't ask me why... */\r
343     return;\r
344 }\r
345 //---------------------------------------------------------------------------\r
346 void __fastcall TMainFrameDlg::PopupPlayClick( TObject *Sender )\r
347 {\r
348     ToolButtonPlayClick( Sender );\r
349 }\r
350 //---------------------------------------------------------------------------\r
351 void __fastcall TMainFrameDlg::PopupPauseClick( TObject *Sender )\r
352 {\r
353     ToolButtonPauseClick( Sender );\r
354 }\r
355 //---------------------------------------------------------------------------\r
356 void __fastcall TMainFrameDlg::PopupStopClick( TObject *Sender )\r
357 {\r
358     ToolButtonStopClick( Sender );\r
359 }\r
360 //---------------------------------------------------------------------------\r
361 void __fastcall TMainFrameDlg::PopupBackClick( TObject *Sender )\r
362 {\r
363     ToolButtonBackClick( Sender );\r
364 }\r
365 //---------------------------------------------------------------------------\r
366 void __fastcall TMainFrameDlg::PopupSlowClick( TObject *Sender )\r
367 {\r
368     ToolButtonSlowClick( Sender );\r
369 }\r
370 //---------------------------------------------------------------------------\r
371 void __fastcall TMainFrameDlg::PopupFastClick( TObject *Sender )\r
372 {\r
373     ToolButtonFastClick( Sender );\r
374 }\r
375 //---------------------------------------------------------------------------\r
376 void __fastcall TMainFrameDlg::PopupToggleInterfaceClick( TObject *Sender )\r
377 {\r
378     this->BringToFront();\r
379 }\r
380 //---------------------------------------------------------------------------\r
381 void __fastcall TMainFrameDlg::PopupFullscreenClick( TObject *Sender )\r
382 {\r
383     MenuFullscreenClick( Sender );\r
384 }\r
385 //---------------------------------------------------------------------------\r
386 void __fastcall TMainFrameDlg::PopupNextClick( TObject *Sender )\r
387 {\r
388     ToolButtonNextClick( Sender );\r
389 }\r
390 //---------------------------------------------------------------------------\r
391 void __fastcall TMainFrameDlg::PopupPrevClick( TObject *Sender )\r
392 {\r
393     ToolButtonPrevClick( Sender );\r
394 }\r
395 //---------------------------------------------------------------------------\r
396 void __fastcall TMainFrameDlg::PopupJumpClick( TObject *Sender )\r
397 {\r
398     // TODO\r
399 }\r
400 //---------------------------------------------------------------------------\r
401 void __fastcall TMainFrameDlg::PopupPlaylistClick( TObject *Sender )\r
402 {\r
403     MenuPlaylistClick( Sender );\r
404 }\r
405 //---------------------------------------------------------------------------\r
406 void __fastcall TMainFrameDlg::PopupPreferencesClick( TObject *Sender )\r
407 {\r
408     MenuPreferencesClick( Sender );\r
409 }\r
410 //---------------------------------------------------------------------------\r
411 void __fastcall TMainFrameDlg::PopupExitClick( TObject *Sender )\r
412 {\r
413     MenuExitClick( Sender );\r
414 }\r
415 //---------------------------------------------------------------------------\r
416 void __fastcall TMainFrameDlg::PopupOpenFileClick( TObject *Sender )\r
417 {\r
418     MenuOpenFileClick( Sender );\r
419 }\r
420 //---------------------------------------------------------------------------\r
421 void __fastcall TMainFrameDlg::PopupOpenDiscClick( TObject *Sender )\r
422 {\r
423     MenuOpenDiscClick( Sender );\r
424 }\r
425 //---------------------------------------------------------------------------\r
426 void __fastcall TMainFrameDlg::PopupNetworkStreamClick( TObject *Sender )\r
427 {\r
428     MenuNetworkStreamClick( Sender );\r
429 }\r
430 //---------------------------------------------------------------------------\r
431 \r
432 \r
433 /*****************************************************************************\r
434  * Callbacks for DVD/VCD navigation\r
435  ****************************************************************************/\r
436 void __fastcall TMainFrameDlg::ButtonTitlePrevClick( TObject *Sender )\r
437 {\r
438     intf_thread_t * p_intf;\r
439     input_area_t  * p_area;\r
440     int             i_id;\r
441 \r
442     p_intf = p_intfGlobal;\r
443     i_id = p_input_bank->pp_input[0]->stream.p_selected_area->i_id - 1;\r
444 \r
445     /* Disallow area 0 since it is used for video_ts.vob */\r
446     if( i_id > 0 )\r
447     {\r
448         p_area = p_input_bank->pp_input[0]->stream.pp_areas[i_id];\r
449         input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );\r
450 \r
451         input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );\r
452 \r
453         p_intf->p_sys->b_title_update = 1;\r
454         vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
455         SetupMenus( p_intf );\r
456         vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
457     }\r
458 }\r
459 //---------------------------------------------------------------------------\r
460 void __fastcall TMainFrameDlg::ButtonTitleNextClick( TObject *Sender )\r
461 {\r
462     intf_thread_t * p_intf;\r
463     input_area_t  * p_area;\r
464     int             i_id;\r
465 \r
466     p_intf = p_intfGlobal;\r
467     i_id = p_input_bank->pp_input[0]->stream.p_selected_area->i_id + 1;\r
468 \r
469     if( i_id < p_input_bank->pp_input[0]->stream.i_area_nb )\r
470     {\r
471         p_area = p_input_bank->pp_input[0]->stream.pp_areas[i_id];   \r
472         input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );\r
473                   \r
474         input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );\r
475 \r
476         p_intf->p_sys->b_title_update = 1;\r
477         vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
478         SetupMenus( p_intf );\r
479         vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
480     }\r
481 }\r
482 //---------------------------------------------------------------------------\r
483 void __fastcall TMainFrameDlg::ButtonChapterPrevClick( TObject *Sender )\r
484 {\r
485     intf_thread_t * p_intf = p_intfGlobal;\r
486     input_area_t  * p_area;\r
487 \r
488     p_area = p_input_bank->pp_input[0]->stream.p_selected_area;\r
489 \r
490     if( p_area->i_part > 0 )\r
491     {\r
492         p_area->i_part--;\r
493         input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );\r
494 \r
495         input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );\r
496 \r
497         p_intf->p_sys->b_chapter_update = 1;\r
498         vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
499         SetupMenus( p_intf );\r
500         vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
501     }\r
502 }\r
503 //---------------------------------------------------------------------------\r
504 void __fastcall TMainFrameDlg::ButtonChapterNextClick( TObject *Sender )\r
505 {\r
506     intf_thread_t * p_intf = p_intfGlobal;\r
507     input_area_t  * p_area;\r
508 \r
509     p_area = p_input_bank->pp_input[0]->stream.p_selected_area;\r
510     \r
511     if( p_area->i_part < p_area->i_part_nb )\r
512     {\r
513         p_area->i_part++;\r
514         input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );\r
515 \r
516         input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );\r
517 \r
518         p_intf->p_sys->b_chapter_update = 1;\r
519         vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
520         SetupMenus( p_intf );\r
521         vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );\r
522     }\r
523 }\r
524 //---------------------------------------------------------------------------\r
525 \r
526 \r
527 /*****************************************************************************\r
528  * Callback for the 'go!' button\r
529  ****************************************************************************/\r
530 void __fastcall TMainFrameDlg::ButtonGoClick( TObject *Sender )\r
531 {\r
532     intf_thread_t *p_intf = p_intfGlobal;\r
533     int i_channel;\r
534 \r
535     i_channel = UpDownChannel->Position;\r
536     intf_WarnMsg( 3, "intf info: joining channel %d", i_channel );\r
537 \r
538     vlc_mutex_lock( &p_intf->change_lock );\r
539     if( p_input_bank->pp_input[0] != NULL )\r
540     {\r
541         /* end playing item */\r
542         p_input_bank->pp_input[0]->b_eof = 1;\r
543 \r
544         /* update playlist */\r
545         vlc_mutex_lock( &p_main->p_playlist->change_lock );\r
546 \r
547         p_main->p_playlist->i_index--;\r
548         p_main->p_playlist->b_stopped = 1;\r
549 \r
550         vlc_mutex_unlock( &p_main->p_playlist->change_lock );\r
551 \r
552         /* FIXME: ugly hack to close input and outputs */\r
553         p_intf->pf_manage( p_intf );\r
554     }\r
555 \r
556     network_ChannelJoin( i_channel );\r
557 \r
558     /* FIXME 2 */\r
559     p_main->p_playlist->b_stopped = 0;\r
560     p_intf->pf_manage( p_intf );\r
561 \r
562     vlc_mutex_unlock( &p_intf->change_lock );\r
563 \r
564 //    input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );\r
565 }\r
566 //---------------------------------------------------------------------------\r
567 \r
568 \r
569 /*****************************************************************************\r
570  * ModeManage: actualise the aspect of the interface whenever the input\r
571  *             changes.\r
572  *****************************************************************************\r
573  * The lock has to be taken before you call the function.\r
574  *****************************************************************************/\r
575 void __fastcall TMainFrameDlg::ModeManage()\r
576 {\r
577     intf_thread_t * p_intf = p_intfGlobal;\r
578     TGroupBox     * ActiveGB;\r
579     int             i_Height;\r
580     bool            b_control;\r
581 \r
582     /* hide all boxes */\r
583     GroupBoxFile->Visible = false;\r
584     GroupBoxNetwork->Visible = false;\r
585     GroupBoxDisc->Visible = false;\r
586 \r
587     /* hide slider */\r
588     GroupBoxSlider->Hide();\r
589 \r
590     /* controls unavailable */\r
591     b_control = 0;\r
592 \r
593     /* show the box related to current input mode */\r
594     if( p_input_bank->pp_input[0] != NULL )\r
595     {\r
596         switch( p_input_bank->pp_input[0]->stream.i_method & 0xf0 )\r
597         {    \r
598             case INPUT_METHOD_FILE:\r
599                 GroupBoxFile->Visible = true;\r
600                 ActiveGB = GroupBoxFile;\r
601                 LabelFileName->Caption = p_input_bank->pp_input[0]->psz_source;\r
602                 break;\r
603             case INPUT_METHOD_DISC:\r
604                 GroupBoxDisc->Visible = true;\r
605                 ActiveGB = GroupBoxDisc;\r
606                 break;\r
607             case INPUT_METHOD_NETWORK:\r
608                 GroupBoxNetwork->Visible = true;\r
609                 ActiveGB = GroupBoxNetwork;\r
610                 LabelServer->Caption = p_input_bank->pp_input[0]->psz_source;\r
611                 if( config_GetIntVariable( "network_channel" ) )\r
612                 {\r
613                     LabelChannel->Visible = true;\r
614                 }\r
615                 else\r
616                 {\r
617                     LabelChannel->Visible = false;\r
618                 }\r
619                 break;\r
620             default:\r
621                 intf_WarnMsg( 3, "intf: can't determine input method" );\r
622                 GroupBoxFile->Visible = true;\r
623                 ActiveGB = GroupBoxFile;\r
624                 LabelFileName->Caption = p_input_bank->pp_input[0]->psz_source;\r
625                 break;\r
626         }\r
627     \r
628         i_Height = StatusBar->Height + ActiveGB->Height + 72;\r
629 \r
630         /* initialize and show slider for seekable streams */\r
631         if( p_input_bank->pp_input[0]->stream.b_seekable )\r
632         {\r
633             TrackBar->Position = p_intf->p_sys->OldValue = 0;\r
634             GroupBoxSlider->Show();\r
635             i_Height += GroupBoxSlider->Height;\r
636         }\r
637 \r
638         /* resize main window */\r
639         this->Height = i_Height;\r
640 \r
641         /* control buttons for free pace streams */\r
642         b_control = p_input_bank->pp_input[0]->stream.b_pace_control;\r
643 \r
644         /* get ready for menu regeneration */\r
645         p_intf->p_sys->b_program_update = 1;\r
646         p_intf->p_sys->b_title_update = 1;\r
647         p_intf->p_sys->b_chapter_update = 1;\r
648         p_intf->p_sys->b_audio_update = 1;\r
649         p_intf->p_sys->b_spu_update = 1;\r
650         p_intf->p_sys->i_part = 0;\r
651     \r
652         p_input_bank->pp_input[0]->stream.b_changed = 0;\r
653         intf_WarnMsg( 3, "intf: stream has changed, refreshing interface" );\r
654     }\r
655     else\r
656     {\r
657         if( config_GetIntVariable( "network_channel" ) )\r
658         {\r
659             GroupBoxNetwork->Visible = true;\r
660             LabelChannel->Visible = true;\r
661         }\r
662         else\r
663         {\r
664             /* default mode */\r
665             ClientHeight = 65;\r
666 \r
667             /* unsensitize menus */\r
668             MenuProgram->Enabled = false;\r
669             MenuTitle->Enabled = false;\r
670             MenuChapter->Enabled = false;\r
671             MenuAudio->Enabled = false;\r
672             MenuSubtitles->Enabled = false;\r
673             PopupNavigation->Enabled = false;\r
674             PopupAudio->Enabled = false;\r
675             PopupSubtitles->Enabled = false;\r
676         }\r
677     }\r
678 \r
679     /* set control items */\r
680     ToolButtonBack->Enabled = false;\r
681     ToolButtonStop->Enabled = true;\r
682     ToolButtonEject->Enabled = !b_control;\r
683     ToolButtonPause->Enabled = b_control;\r
684     ToolButtonSlow->Enabled = b_control;\r
685     ToolButtonFast->Enabled = b_control;\r
686     PopupBack->Enabled = false;\r
687     PopupPause->Enabled = b_control;\r
688     PopupSlow->Enabled = b_control;\r
689     PopupFast->Enabled = b_control;\r
690 }\r
691 \r