1 /*****************************************************************************
2 * menus.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2004 the VideoLAN team
7 * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
32 #include <vlc_common.h>
33 #include <vlc_interface.h>
34 #include <vlc_playlist.h>
38 /*****************************************************************************
40 *****************************************************************************/
42 /* IDs for the controls and the menu commands */
46 MenuDummy_Event = 1000,
47 OpenFileSimple_Event = 1100,
51 FirstAutoGenerated_Event = 1999,
52 SettingsMenu_Events = 2000,
53 AudioMenu_Events = 3000,
54 VideoMenu_Events = 4000,
55 NavigMenu_Events = 5000,
56 PopupMenu_Events = 6000
59 HMENU OpenStreamMenu( intf_thread_t *p_intf )
61 HMENU hmenu = CreatePopupMenu();
62 AppendMenu( hmenu, MF_STRING, ID_FILE_QUICKOPEN,
63 _T("Quick &Open File...") );
64 AppendMenu( hmenu, MF_STRING, ID_FILE_OPENFILE,
65 _T("Open &File...") );
66 AppendMenu( hmenu, MF_STRING, ID_FILE_OPENNET,
67 _T("Open &Network Stream...") );
71 HMENU MiscMenu( intf_thread_t *p_intf )
73 HMENU hmenu = CreatePopupMenu();
74 AppendMenu( hmenu, MF_STRING, ID_VIEW_STREAMINFO, _T("Media &Info...") );
75 AppendMenu( hmenu, MF_STRING, ID_VIEW_MESSAGES, _T("&Messages...") );
76 AppendMenu( hmenu, MF_STRING, ID_PREFERENCES, _T("&Preferences...") );
80 void PopupMenu( intf_thread_t *p_intf, HWND p_parent, POINT point )
82 #define MAX_POPUP_ITEMS 45
84 vlc_object_t *p_object, *p_input;
85 char *ppsz_varnames[MAX_POPUP_ITEMS];
86 vlc_object_t * pi_objects[MAX_POPUP_ITEMS];
87 int i = 0, i_last_separator = 0;
90 memset( pi_objects, 0, MAX_POPUP_ITEMS * sizeof(vlc_object_t *) );
92 ppsz_varnames[i] = "VLC media player";
94 ppsz_varnames[i++] = NULL; /* Separator */
98 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
100 if( p_object != NULL )
102 ppsz_varnames[i] = "bookmark";
103 pi_objects[i++] = p_object;
104 ppsz_varnames[i] = "title";
105 pi_objects[i++] = p_object;
106 ppsz_varnames[i] = "chapter";
107 pi_objects[i++] = p_object;
108 ppsz_varnames[i] = "program";
109 pi_objects[i++] = p_object;
110 ppsz_varnames[i] = "navigation";
111 pi_objects[i++] = p_object;
112 ppsz_varnames[i] = "dvd_menus";
113 pi_objects[i++] = p_object;
115 ppsz_varnames[i] = "video-es";
116 pi_objects[i++] = p_object;
117 ppsz_varnames[i] = "audio-es";
118 pi_objects[i++] = p_object;
119 ppsz_varnames[i] = "spu-es";
120 pi_objects[i++] = p_object;
123 if( !p_input ) goto interfacemenu;
126 if( i != i_last_separator ) ppsz_varnames[i++] = NULL; /* Separator */
127 i_last_separator = i;
129 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
131 if( p_object != NULL )
133 vlc_object_t *p_dec_obj;
135 ppsz_varnames[i] = "fullscreen";
136 pi_objects[i++] = p_object;
137 ppsz_varnames[i] = "zoom";
138 pi_objects[i++] = p_object;
139 ppsz_varnames[i] = "deinterlace-mode";
140 pi_objects[i++] = p_object;
141 ppsz_varnames[i] = "aspect-ratio";
142 pi_objects[i++] = p_object;
143 ppsz_varnames[i] = "crop";
144 pi_objects[i++] = p_object;
145 ppsz_varnames[i] = "video-on-top";
146 pi_objects[i++] = p_object;
147 ppsz_varnames[i] = "directx-wallpaper";
148 pi_objects[i++] = p_object;
149 ppsz_varnames[i] = "video-snapshot";
150 pi_objects[i++] = p_object;
152 p_dec_obj = (vlc_object_t *)vlc_object_find( p_object,
155 if( p_dec_obj != NULL )
157 ppsz_varnames[i] = "ffmpeg-pp-q";
158 pi_objects[i++] = p_dec_obj;
159 vlc_object_release( p_dec_obj );
162 vlc_object_release( p_object );
166 if( i != i_last_separator ) ppsz_varnames[i++] = NULL; /* Separator */
167 i_last_separator = i;
169 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
171 if( p_object != NULL )
173 ppsz_varnames[i] = "audio-device";
174 pi_objects[i++] = p_object;
175 ppsz_varnames[i] = "audio-channels";
176 pi_objects[i++] = p_object;
177 ppsz_varnames[i] = "visual";
178 pi_objects[i++] = p_object;
179 ppsz_varnames[i] = "equalizer";
180 pi_objects[i++] = p_object;
181 vlc_object_release( p_object );
186 if( i != i_last_separator ) ppsz_varnames[i++] = NULL; /* Separator */
187 i_last_separator = i;
191 vector<MenuItemExt*> popup_menu;
192 HMENU hmenu = CreatePopupMenu();
193 RefreshMenu( p_intf, &popup_menu, hmenu, i,
194 ppsz_varnames, pi_objects, PopupMenu_Events );
195 MenuItemExt::ClearList( &popup_menu );
198 /* Add static entries */
199 if( p_input != NULL )
202 AppendMenu( hmenu, MF_SEPARATOR, 0, _T("") );
203 AppendMenu( hmenu, MF_STRING, StopStream_Event, _T("Stop") );
204 AppendMenu( hmenu, MF_STRING, PrevStream_Event, _T("Previous") );
205 AppendMenu( hmenu, MF_STRING, NextStream_Event, _T("Next") );
207 var_Get( p_input, "state", &val );
208 if( val.i_int == PAUSE_S )
209 AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Play") );
211 AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Pause") );
213 vlc_object_release( p_input );
217 playlist_t * p_playlist = pl_Hold( p_intf );
218 if( p_playlist && !playlist_IsEmpty( p_playlist ) )
220 AppendMenu( hmenu, MF_SEPARATOR, 0, _T("") );
221 AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Play") );
223 if( p_playlist ) pl_Release( p_intf );
226 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)MiscMenu( p_intf ),
227 _T("Miscellaneous") );
228 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)OpenStreamMenu( p_intf ),
231 TrackPopupMenu( hmenu, 0, point.x, point.y, 0, p_parent, 0 );
232 PostMessage( p_parent, WM_NULL, 0, 0 );
233 DestroyMenu( hmenu );
236 void RefreshAudioMenu( intf_thread_t *p_intf, HMENU hMenu )
238 #define MAX_AUDIO_ITEMS 10
240 vlc_object_t *p_object;
241 char *ppsz_varnames[MAX_AUDIO_ITEMS];
242 vlc_object_t * pi_objects[MAX_AUDIO_ITEMS];
245 /* Delete old menu */
246 int count = wce_GetMenuItemCount( hMenu );
247 for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
249 if( p_intf->p_sys->p_audio_menu )
250 MenuItemExt::ClearList( p_intf->p_sys->p_audio_menu );
251 else p_intf->p_sys->p_audio_menu = new vector<MenuItemExt*>;
254 /* Initializations */
255 memset( pi_objects, 0, MAX_AUDIO_ITEMS * sizeof(vlc_object_t *) );
258 p_object = (vlc_object_t *)
259 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
260 if( p_object != NULL )
262 ppsz_varnames[i] = "audio-es";
263 pi_objects[i++] = p_object;
264 vlc_object_release( p_object );
267 p_object = (vlc_object_t *)
268 vlc_object_find( p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE );
269 if( p_object != NULL )
271 ppsz_varnames[i] = "audio-device";
272 pi_objects[i++] = p_object;
273 ppsz_varnames[i] = "audio-channels";
274 pi_objects[i++] = p_object;
275 ppsz_varnames[i] = "visual";
276 pi_objects[i++] = p_object;
277 vlc_object_release( p_object );
281 RefreshMenu( p_intf, p_intf->p_sys->p_audio_menu,
282 hMenu, i, ppsz_varnames, pi_objects, AudioMenu_Events );
285 void RefreshVideoMenu( intf_thread_t *p_intf, HMENU hMenu )
287 #define MAX_VIDEO_ITEMS 15
289 vlc_object_t *p_object;
290 char *ppsz_varnames[MAX_VIDEO_ITEMS];
291 vlc_object_t * pi_objects[MAX_VIDEO_ITEMS];
294 /* Delete old menu */
295 int count = wce_GetMenuItemCount( hMenu );
296 for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
298 if( p_intf->p_sys->p_video_menu )
299 MenuItemExt::ClearList( p_intf->p_sys->p_video_menu );
300 else p_intf->p_sys->p_video_menu = new vector<MenuItemExt*>;
302 /* Initializations */
303 memset( pi_objects, 0, MAX_VIDEO_ITEMS * sizeof(vlc_object_t *) );
306 p_object = (vlc_object_t *)
307 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
308 if( p_object != NULL )
310 ppsz_varnames[i] = "video-es";
311 pi_objects[i++] = p_object;
312 ppsz_varnames[i] = "spu-es";
313 pi_objects[i++] = p_object;
314 vlc_object_release( p_object );
317 p_object = (vlc_object_t *)
318 vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
319 if( p_object != NULL )
321 vlc_object_t *p_dec_obj;
323 ppsz_varnames[i] = "fullscreen";
324 pi_objects[i++] = p_object;
326 ppsz_varnames[i] = "transform";
327 pi_objects[i++] = p_object;
329 ppsz_varnames[i] = "zoom";
330 pi_objects[i++] = p_object;
331 ppsz_varnames[i] = "deinterlace-mode";
332 pi_objects[i++] = p_object;
333 ppsz_varnames[i] = "aspect-ratio";
334 pi_objects[i++] = p_object;
335 ppsz_varnames[i] = "crop";
336 pi_objects[i++] = p_object;
337 ppsz_varnames[i] = "directx-on-top";
338 pi_objects[i++] = p_object;
340 p_dec_obj = (vlc_object_t *)
341 vlc_object_find( p_object, VLC_OBJECT_DECODER, FIND_PARENT );
342 if( p_dec_obj != NULL )
344 ppsz_varnames[i] = "ffmpeg-pp-q";
345 pi_objects[i++] = p_dec_obj;
346 vlc_object_release( p_dec_obj );
349 vlc_object_release( p_object );
353 RefreshMenu( p_intf, p_intf->p_sys->p_video_menu, hMenu, i,
354 ppsz_varnames, pi_objects, VideoMenu_Events );
357 void RefreshNavigMenu( intf_thread_t *p_intf, HMENU hMenu )
359 #define MAX_NAVIG_ITEMS 10
361 vlc_object_t *p_object;
362 char *ppsz_varnames[MAX_NAVIG_ITEMS];
363 vlc_object_t * pi_objects[MAX_NAVIG_ITEMS];
366 /* Delete old menu */
367 int count = wce_GetMenuItemCount( hMenu );
368 for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
370 if( p_intf->p_sys->p_navig_menu )
371 MenuItemExt::ClearList( p_intf->p_sys->p_navig_menu );
372 else p_intf->p_sys->p_navig_menu = new vector<MenuItemExt*>;
374 /* Initializations */
375 memset( pi_objects, 0, MAX_NAVIG_ITEMS * sizeof(vlc_object_t *) );
378 p_object = (vlc_object_t *)
379 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
380 if( p_object != NULL )
382 ppsz_varnames[i] = "title";
383 pi_objects[i++] = p_object;
384 ppsz_varnames[i] = "chapter";
385 pi_objects[i++] = p_object;
386 ppsz_varnames[i] = "program";
387 pi_objects[i++] = p_object;
388 ppsz_varnames[i] = "navigation";
389 pi_objects[i++] = p_object;
390 ppsz_varnames[i] = "dvd_menus";
391 pi_objects[i++] = p_object;
393 ppsz_varnames[i] = "prev-title";
394 pi_objects[i++] = p_object;
395 ppsz_varnames[i] = "next-title";
396 pi_objects[i++] = p_object;
397 ppsz_varnames[i] = "prev-chapter";
398 pi_objects[i++] = p_object;
399 ppsz_varnames[i] = "next-chapter";
400 pi_objects[i++] = p_object;
402 vlc_object_release( p_object );
406 RefreshMenu( p_intf, p_intf->p_sys->p_navig_menu, hMenu, i,
407 ppsz_varnames, pi_objects, NavigMenu_Events );
410 void RefreshSettingsMenu( intf_thread_t *p_intf, HMENU hMenu )
412 #define MAX_SETTINGS_ITEMS 10
414 vlc_object_t *p_object;
415 char *ppsz_varnames[MAX_SETTINGS_ITEMS];
416 vlc_object_t * pi_objects[MAX_SETTINGS_ITEMS];
419 /* Delete old menu */
420 int count = wce_GetMenuItemCount( hMenu );
421 for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
423 if( p_intf->p_sys->p_settings_menu )
424 MenuItemExt::ClearList( p_intf->p_sys->p_settings_menu );
425 else p_intf->p_sys->p_settings_menu = new vector<MenuItemExt*>;
427 /* Initializations */
428 memset( pi_objects, 0, MAX_SETTINGS_ITEMS * sizeof(vlc_object_t *) );
431 AppendMenu( hMenu, MF_STRING, ID_PREFERENCES, _T("&Preferences...") );
433 /* Other interfaces */
434 /*FIXME: copy the Qt way of mapping menus and objects */
435 /*p_object = (vlc_object_t *) NULL;
436 //vlc_object_find_name( p_intf, "wince", FIND_PARENT );
437 if( p_object != NULL )
439 ppsz_varnames[i] = "intf-add";
440 pi_objects[i++] = p_object;
441 vlc_object_release( p_object );
446 RefreshMenu( p_intf, p_intf->p_sys->p_settings_menu, hMenu, i,
447 ppsz_varnames, pi_objects, SettingsMenu_Events );
450 /*****************************************************************************
452 *****************************************************************************/
453 void RefreshMenu( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list,
454 HMENU hMenu , int i_count, char **ppsz_varnames,
455 vlc_object_t **pi_objects, int i_start_id )
457 vlc_object_t *p_object;
458 bool b_section_empty = false;
461 /* Initializations */
462 int i_item_id = i_start_id;
464 for( i = 0; i < i_count; i++ )
466 if( !ppsz_varnames[i] )
468 if( b_section_empty )
470 AppendMenu( hMenu, MF_GRAYED | MF_STRING,
471 MenuDummy_Event + i, _T("Empty") );
474 AppendMenu( hMenu, MF_SEPARATOR, 0, _T("") );
475 b_section_empty = true;
481 AppendMenu( hMenu, MF_GRAYED | MF_STRING,
482 MenuDummy_Event, _FROMMB(ppsz_varnames[i]) );
484 b_section_empty = false;
488 p_object = pi_objects[i];
489 if( p_object == NULL ) continue;
491 b_section_empty = false;
492 CreateMenuItem( p_intf, p_menu_list, hMenu, ppsz_varnames[i],
493 p_object, &i_item_id );
494 vlc_object_release( p_object );
497 /* Special case for empty menus */
498 if( wce_GetMenuItemCount(hMenu) == 0 || b_section_empty )
500 AppendMenu( hMenu, MF_GRAYED | MF_STRING,
501 MenuDummy_Event + i, _T("Empty") );
505 /*****************************************************************************
507 *****************************************************************************/
508 void CreateMenuItem( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list,
509 HMENU hMenu, char *psz_var, vlc_object_t *p_object,
512 MenuItemExt *pMenuItemExt;
514 vlc_value_t val, text;
517 /* Check the type of the object variable */
518 i_type = var_Type( p_object, psz_var );
520 switch( i_type & VLC_VAR_TYPE )
524 case VLC_VAR_VARIABLE:
526 case VLC_VAR_INTEGER:
530 /* Variable doesn't exist or isn't handled */
534 /* Make sure we want to display the variable */
535 if( i_type & VLC_VAR_HASCHOICE )
537 var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
538 if( val.i_int == 0 ) return;
539 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
543 /* Get the descriptive name of the variable */
544 var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
546 var_Get( p_object, psz_var, &val );
548 if( i_type & VLC_VAR_HASCHOICE )
550 hMenuItem = CreateChoicesMenu( p_intf, p_menu_list, psz_var,
551 p_object, pi_item_id );
552 AppendMenu( hMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem,
553 _FROMMB(text.psz_string ? text.psz_string : psz_var) );
554 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
555 free( text.psz_string );
559 switch( i_type & VLC_VAR_TYPE )
562 AppendMenu( hMenu, MF_STRING , ++(*pi_item_id),
563 _FROMMB(text.psz_string ? text.psz_string : psz_var) );
564 pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
565 p_object, val, i_type );
566 p_menu_list->push_back( pMenuItemExt );
570 val.b_bool = !val.b_bool;
571 AppendMenu( hMenu, MF_STRING | MF_CHECKED, ++(*pi_item_id),
572 _FROMMB(text.psz_string ? text.psz_string : psz_var) );
573 pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
574 p_object, val, i_type );
575 p_menu_list->push_back( pMenuItemExt );
576 CheckMenuItem( hMenu, *pi_item_id ,
577 ( val.b_bool ? MF_UNCHECKED : MF_CHECKED ) |
582 free( text.psz_string );
586 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
587 free( text.psz_string );
590 HMENU CreateChoicesMenu( intf_thread_t *p_intf,
591 vector<MenuItemExt*> *p_menu_list, char *psz_var,
592 vlc_object_t *p_object, int *pi_item_id )
594 MenuItemExt *pMenuItemExt;
595 vlc_value_t val, val_list, text_list;
597 HMENU hSubMenu = CreatePopupMenu();
599 /* Check the type of the object variable */
600 i_type = var_Type( p_object, psz_var );
602 /* Make sure we want to display the variable */
603 if( i_type & VLC_VAR_HASCHOICE )
605 var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
606 if( val.i_int == 0 ) return NULL;
607 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
615 switch( i_type & VLC_VAR_TYPE )
619 case VLC_VAR_VARIABLE:
621 case VLC_VAR_INTEGER:
624 /* Variable doesn't exist or isn't handled */
628 if( var_Get( p_object, psz_var, &val ) < 0 ) return NULL;
630 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
631 &val_list, &text_list ) < 0 )
633 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
637 for( i = 0; i < val_list.p_list->i_count; i++ )
639 vlc_value_t another_val;
643 switch( i_type & VLC_VAR_TYPE )
645 case VLC_VAR_VARIABLE:
646 hMenuItem = CreateChoicesMenu( p_intf, p_menu_list,
647 val_list.p_list->p_values[i].psz_string, p_object, pi_item_id );
648 AppendMenu( hSubMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem,
649 _FROMMB(text_list.p_list->p_values[i].psz_string ?
650 text_list.p_list->p_values[i].psz_string :
651 val_list.p_list->p_values[i].psz_string) );
655 another_val.psz_string =
656 strdup(val_list.p_list->p_values[i].psz_string);
657 AppendMenu( hSubMenu, MF_STRING, ++(*pi_item_id),
658 _FROMMB(text_list.p_list->p_values[i].psz_string ?
659 text_list.p_list->p_values[i].psz_string :
660 val_list.p_list->p_values[i].psz_string) );
661 pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
662 p_object, another_val, i_type );
663 p_menu_list->push_back( pMenuItemExt );
665 if( !(i_type & VLC_VAR_ISCOMMAND) && val.psz_string &&
666 !strcmp( val.psz_string,
667 val_list.p_list->p_values[i].psz_string ) )
668 CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND);
671 case VLC_VAR_INTEGER:
672 asprintf( &psz_tmp, "%d", val_list.p_list->p_values[i].i_int );
673 AppendMenu( hSubMenu, MF_STRING, ++(*pi_item_id),
674 _FROMMB(text_list.p_list->p_values[i].psz_string ?
675 text_list.p_list->p_values[i].psz_string : psz_tmp));
676 pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
677 p_object, val_list.p_list->p_values[i], i_type );
678 p_menu_list->push_back( pMenuItemExt );
680 if( val_list.p_list->p_values[i].i_int == val.i_int )
681 CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND);
689 /* Clean up everything */
690 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
691 var_FreeList( &val_list, &text_list );
696 int wce_GetMenuItemCount(HMENU hMenu)
698 const int MAX_NUM_ITEMS = 256;
702 memset( (char *)&mii, 0, sizeof(MENUITEMINFO) );
703 mii.cbSize = sizeof(MENUITEMINFO);
706 for( iPos = 0; iPos < MAX_NUM_ITEMS; iPos++ )
708 if( !GetMenuItemInfo(hMenu, (UINT)iPos, TRUE, &mii) ) break;
715 void OnMenuEvent( intf_thread_t *p_intf, int id )
717 MenuItemExt *p_menuitemext = NULL;
718 vector<MenuItemExt*>::iterator iter;
720 if( p_intf->p_sys->p_settings_menu )
721 for( iter = p_intf->p_sys->p_settings_menu->begin();
722 iter != p_intf->p_sys->p_settings_menu->end(); iter++ )
723 if( (*iter)->id == id )
725 p_menuitemext = *iter;
729 if( p_intf->p_sys->p_audio_menu && !p_menuitemext )
730 for( iter = p_intf->p_sys->p_audio_menu->begin();
731 iter != p_intf->p_sys->p_audio_menu->end(); iter++ )
732 if( (*iter)->id == id )
734 p_menuitemext = *iter;
738 if( p_intf->p_sys->p_video_menu && !p_menuitemext )
739 for( iter = p_intf->p_sys->p_video_menu->begin();
740 iter != p_intf->p_sys->p_video_menu->end(); iter++ )
741 if( (*iter)->id == id )
743 p_menuitemext = *iter;
747 if( p_intf->p_sys->p_navig_menu && !p_menuitemext )
748 for( iter = p_intf->p_sys->p_navig_menu->begin();
749 iter != p_intf->p_sys->p_navig_menu->end(); iter++ )
750 if( (*iter)->id == id )
752 p_menuitemext = *iter;
758 vlc_object_t *p_object = p_menuitemext->p_object;
759 if( p_object == NULL ) return;
761 var_Set( p_object, p_menuitemext->psz_var, p_menuitemext->val );
762 int i_type = var_Type( p_object, p_menuitemext->psz_var );
763 switch( i_type & VLC_VAR_TYPE )
767 case VLC_VAR_VARIABLE:
769 case VLC_VAR_INTEGER:
772 /* Variable doesn't exist or isn't handled */
776 vlc_object_release( p_object );
780 /*****************************************************************************
781 * A small helper class which encapsulate wxMenuitem with some other useful
783 *****************************************************************************/
784 MenuItemExt::MenuItemExt( intf_thread_t *p_intf, int _id, char *_psz_var,
785 vlc_object_t * _p_object, vlc_value_t _val, int _i_val_type )
787 /* Initializations */
790 psz_var = strdup( _psz_var );
791 i_val_type = _i_val_type;
792 p_object = _p_object;
796 MenuItemExt::~MenuItemExt()
799 if( ( i_val_type & VLC_VAR_TYPE ) == VLC_VAR_STRING )
800 free( val.psz_string );
803 void MenuItemExt::ClearList( vector<MenuItemExt*> *p_menu_list )
805 vector<MenuItemExt*>::iterator iter;
807 if( !p_menu_list ) return;
808 for( iter = p_menu_list->begin(); iter != p_menu_list->end(); iter++ )
812 p_menu_list->clear();