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";
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;
189 /* vlc_object_find is needed because of the dialogs provider case */
190 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INTF,
192 if( p_object != NULL )
194 /* Nothing for now */
195 vlc_object_release( p_object );
199 vector<MenuItemExt*> popup_menu;
200 HMENU hmenu = CreatePopupMenu();
201 RefreshMenu( p_intf, &popup_menu, hmenu, i,
202 ppsz_varnames, pi_objects, PopupMenu_Events );
203 MenuItemExt::ClearList( &popup_menu );
206 /* Add static entries */
207 if( p_input != NULL )
210 AppendMenu( hmenu, MF_SEPARATOR, 0, _T("") );
211 AppendMenu( hmenu, MF_STRING, StopStream_Event, _T("Stop") );
212 AppendMenu( hmenu, MF_STRING, PrevStream_Event, _T("Previous") );
213 AppendMenu( hmenu, MF_STRING, NextStream_Event, _T("Next") );
215 var_Get( p_input, "state", &val );
216 if( val.i_int == PAUSE_S )
217 AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Play") );
219 AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Pause") );
221 vlc_object_release( p_input );
225 playlist_t * p_playlist = pl_Hold( p_intf );
226 if( p_playlist && !playlist_IsEmpty( p_playlist ) )
228 AppendMenu( hmenu, MF_SEPARATOR, 0, _T("") );
229 AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Play") );
231 if( p_playlist ) pl_Release( p_intf );
234 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)MiscMenu( p_intf ),
235 _T("Miscellaneous") );
236 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)OpenStreamMenu( p_intf ),
239 TrackPopupMenu( hmenu, 0, point.x, point.y, 0, p_parent, 0 );
240 PostMessage( p_parent, WM_NULL, 0, 0 );
241 DestroyMenu( hmenu );
244 void RefreshAudioMenu( intf_thread_t *p_intf, HMENU hMenu )
246 #define MAX_AUDIO_ITEMS 10
248 vlc_object_t *p_object;
249 char *ppsz_varnames[MAX_AUDIO_ITEMS];
250 vlc_object_t * pi_objects[MAX_AUDIO_ITEMS];
253 /* Delete old menu */
254 int count = wce_GetMenuItemCount( hMenu );
255 for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
257 if( p_intf->p_sys->p_audio_menu )
258 MenuItemExt::ClearList( p_intf->p_sys->p_audio_menu );
259 else p_intf->p_sys->p_audio_menu = new vector<MenuItemExt*>;
262 /* Initializations */
263 memset( pi_objects, 0, MAX_AUDIO_ITEMS * sizeof(vlc_object_t *) );
266 p_object = (vlc_object_t *)
267 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
268 if( p_object != NULL )
270 ppsz_varnames[i] = "audio-es";
271 pi_objects[i++] = p_object;
272 vlc_object_release( p_object );
275 p_object = (vlc_object_t *)
276 vlc_object_find( p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE );
277 if( p_object != NULL )
279 ppsz_varnames[i] = "audio-device";
280 pi_objects[i++] = p_object;
281 ppsz_varnames[i] = "audio-channels";
282 pi_objects[i++] = p_object;
283 ppsz_varnames[i] = "visual";
284 pi_objects[i++] = p_object;
285 vlc_object_release( p_object );
289 RefreshMenu( p_intf, p_intf->p_sys->p_audio_menu,
290 hMenu, i, ppsz_varnames, pi_objects, AudioMenu_Events );
293 void RefreshVideoMenu( intf_thread_t *p_intf, HMENU hMenu )
295 #define MAX_VIDEO_ITEMS 15
297 vlc_object_t *p_object;
298 char *ppsz_varnames[MAX_VIDEO_ITEMS];
299 vlc_object_t * pi_objects[MAX_VIDEO_ITEMS];
302 /* Delete old menu */
303 int count = wce_GetMenuItemCount( hMenu );
304 for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
306 if( p_intf->p_sys->p_video_menu )
307 MenuItemExt::ClearList( p_intf->p_sys->p_video_menu );
308 else p_intf->p_sys->p_video_menu = new vector<MenuItemExt*>;
310 /* Initializations */
311 memset( pi_objects, 0, MAX_VIDEO_ITEMS * sizeof(vlc_object_t *) );
314 p_object = (vlc_object_t *)
315 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
316 if( p_object != NULL )
318 ppsz_varnames[i] = "video-es";
319 pi_objects[i++] = p_object;
320 ppsz_varnames[i] = "spu-es";
321 pi_objects[i++] = p_object;
322 vlc_object_release( p_object );
325 p_object = (vlc_object_t *)
326 vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
327 if( p_object != NULL )
329 vlc_object_t *p_dec_obj;
331 ppsz_varnames[i] = "fullscreen";
332 pi_objects[i++] = p_object;
334 ppsz_varnames[i] = "transform";
335 pi_objects[i++] = p_object;
337 ppsz_varnames[i] = "zoom";
338 pi_objects[i++] = p_object;
339 ppsz_varnames[i] = "deinterlace";
340 pi_objects[i++] = p_object;
341 ppsz_varnames[i] = "aspect-ratio";
342 pi_objects[i++] = p_object;
343 ppsz_varnames[i] = "crop";
344 pi_objects[i++] = p_object;
345 ppsz_varnames[i] = "directx-on-top";
346 pi_objects[i++] = p_object;
348 p_dec_obj = (vlc_object_t *)
349 vlc_object_find( p_object, VLC_OBJECT_DECODER, FIND_PARENT );
350 if( p_dec_obj != NULL )
352 ppsz_varnames[i] = "ffmpeg-pp-q";
353 pi_objects[i++] = p_dec_obj;
354 vlc_object_release( p_dec_obj );
357 vlc_object_release( p_object );
361 RefreshMenu( p_intf, p_intf->p_sys->p_video_menu, hMenu, i,
362 ppsz_varnames, pi_objects, VideoMenu_Events );
365 void RefreshNavigMenu( intf_thread_t *p_intf, HMENU hMenu )
367 #define MAX_NAVIG_ITEMS 10
369 vlc_object_t *p_object;
370 char *ppsz_varnames[MAX_NAVIG_ITEMS];
371 vlc_object_t * pi_objects[MAX_NAVIG_ITEMS];
374 /* Delete old menu */
375 int count = wce_GetMenuItemCount( hMenu );
376 for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
378 if( p_intf->p_sys->p_navig_menu )
379 MenuItemExt::ClearList( p_intf->p_sys->p_navig_menu );
380 else p_intf->p_sys->p_navig_menu = new vector<MenuItemExt*>;
382 /* Initializations */
383 memset( pi_objects, 0, MAX_NAVIG_ITEMS * sizeof(vlc_object_t *) );
386 p_object = (vlc_object_t *)
387 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
388 if( p_object != NULL )
390 ppsz_varnames[i] = "title";
391 pi_objects[i++] = p_object;
392 ppsz_varnames[i] = "chapter";
393 pi_objects[i++] = p_object;
394 ppsz_varnames[i] = "program";
395 pi_objects[i++] = p_object;
396 ppsz_varnames[i] = "navigation";
397 pi_objects[i++] = p_object;
398 ppsz_varnames[i] = "dvd_menus";
399 pi_objects[i++] = p_object;
401 ppsz_varnames[i] = "prev-title";
402 pi_objects[i++] = p_object;
403 ppsz_varnames[i] = "next-title";
404 pi_objects[i++] = p_object;
405 ppsz_varnames[i] = "prev-chapter";
406 pi_objects[i++] = p_object;
407 ppsz_varnames[i] = "next-chapter";
408 pi_objects[i++] = p_object;
410 vlc_object_release( p_object );
414 RefreshMenu( p_intf, p_intf->p_sys->p_navig_menu, hMenu, i,
415 ppsz_varnames, pi_objects, NavigMenu_Events );
418 void RefreshSettingsMenu( intf_thread_t *p_intf, HMENU hMenu )
420 #define MAX_SETTINGS_ITEMS 10
422 vlc_object_t *p_object;
423 char *ppsz_varnames[MAX_SETTINGS_ITEMS];
424 vlc_object_t * pi_objects[MAX_SETTINGS_ITEMS];
427 /* Delete old menu */
428 int count = wce_GetMenuItemCount( hMenu );
429 for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
431 if( p_intf->p_sys->p_settings_menu )
432 MenuItemExt::ClearList( p_intf->p_sys->p_settings_menu );
433 else p_intf->p_sys->p_settings_menu = new vector<MenuItemExt*>;
435 /* Initializations */
436 memset( pi_objects, 0, MAX_SETTINGS_ITEMS * sizeof(vlc_object_t *) );
439 AppendMenu( hMenu, MF_STRING, ID_PREFERENCES, _T("&Preferences...") );
441 p_object = (vlc_object_t *)
442 vlc_object_find( p_intf, VLC_OBJECT_INTF, FIND_PARENT );
443 if( p_object != NULL )
445 ppsz_varnames[i] = "intf-add";
446 pi_objects[i++] = p_object;
447 vlc_object_release( p_object );
451 RefreshMenu( p_intf, p_intf->p_sys->p_settings_menu, hMenu, i,
452 ppsz_varnames, pi_objects, SettingsMenu_Events );
455 /*****************************************************************************
457 *****************************************************************************/
458 void RefreshMenu( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list,
459 HMENU hMenu , int i_count, char **ppsz_varnames,
460 vlc_object_t **pi_objects, int i_start_id )
462 vlc_object_t *p_object;
463 bool b_section_empty = false;
466 /* Initializations */
467 int i_item_id = i_start_id;
469 for( i = 0; i < i_count; i++ )
471 if( !ppsz_varnames[i] )
473 if( b_section_empty )
475 AppendMenu( hMenu, MF_GRAYED | MF_STRING,
476 MenuDummy_Event + i, _T("Empty") );
479 AppendMenu( hMenu, MF_SEPARATOR, 0, _T("") );
480 b_section_empty = true;
486 AppendMenu( hMenu, MF_GRAYED | MF_STRING,
487 MenuDummy_Event, _FROMMB(ppsz_varnames[i]) );
489 b_section_empty = false;
493 p_object = pi_objects[i];
494 if( p_object == NULL ) continue;
496 b_section_empty = false;
497 CreateMenuItem( p_intf, p_menu_list, hMenu, ppsz_varnames[i],
498 p_object, &i_item_id );
499 vlc_object_release( p_object );
502 /* Special case for empty menus */
503 if( wce_GetMenuItemCount(hMenu) == 0 || b_section_empty )
505 AppendMenu( hMenu, MF_GRAYED | MF_STRING,
506 MenuDummy_Event + i, _T("Empty") );
510 /*****************************************************************************
512 *****************************************************************************/
513 void CreateMenuItem( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list,
514 HMENU hMenu, char *psz_var, vlc_object_t *p_object,
517 MenuItemExt *pMenuItemExt;
519 vlc_value_t val, text;
522 /* Check the type of the object variable */
523 i_type = var_Type( p_object, psz_var );
525 switch( i_type & VLC_VAR_TYPE )
529 case VLC_VAR_VARIABLE:
531 case VLC_VAR_INTEGER:
535 /* Variable doesn't exist or isn't handled */
539 /* Make sure we want to display the variable */
540 if( i_type & VLC_VAR_HASCHOICE )
542 var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
543 if( val.i_int == 0 ) return;
544 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
548 /* Get the descriptive name of the variable */
549 var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
551 var_Get( p_object, psz_var, &val );
553 if( i_type & VLC_VAR_HASCHOICE )
555 hMenuItem = CreateChoicesMenu( p_intf, p_menu_list, psz_var,
556 p_object, pi_item_id );
557 AppendMenu( hMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem,
558 _FROMMB(text.psz_string ? text.psz_string : psz_var) );
559 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
560 free( text.psz_string );
564 switch( i_type & VLC_VAR_TYPE )
567 AppendMenu( hMenu, MF_STRING , ++(*pi_item_id),
568 _FROMMB(text.psz_string ? text.psz_string : psz_var) );
569 pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
570 p_object, val, i_type );
571 p_menu_list->push_back( pMenuItemExt );
575 val.b_bool = !val.b_bool;
576 AppendMenu( hMenu, MF_STRING | MF_CHECKED, ++(*pi_item_id),
577 _FROMMB(text.psz_string ? text.psz_string : psz_var) );
578 pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
579 p_object, val, i_type );
580 p_menu_list->push_back( pMenuItemExt );
581 CheckMenuItem( hMenu, *pi_item_id ,
582 ( val.b_bool ? MF_UNCHECKED : MF_CHECKED ) |
587 free( text.psz_string );
591 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
592 free( text.psz_string );
595 HMENU CreateChoicesMenu( intf_thread_t *p_intf,
596 vector<MenuItemExt*> *p_menu_list, char *psz_var,
597 vlc_object_t *p_object, int *pi_item_id )
599 MenuItemExt *pMenuItemExt;
600 vlc_value_t val, val_list, text_list;
602 HMENU hSubMenu = CreatePopupMenu();
604 /* Check the type of the object variable */
605 i_type = var_Type( p_object, psz_var );
607 /* Make sure we want to display the variable */
608 if( i_type & VLC_VAR_HASCHOICE )
610 var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
611 if( val.i_int == 0 ) return NULL;
612 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
620 switch( i_type & VLC_VAR_TYPE )
624 case VLC_VAR_VARIABLE:
626 case VLC_VAR_INTEGER:
629 /* Variable doesn't exist or isn't handled */
633 if( var_Get( p_object, psz_var, &val ) < 0 ) return NULL;
635 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
636 &val_list, &text_list ) < 0 )
638 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
642 for( i = 0; i < val_list.p_list->i_count; i++ )
644 vlc_value_t another_val;
648 switch( i_type & VLC_VAR_TYPE )
650 case VLC_VAR_VARIABLE:
651 hMenuItem = CreateChoicesMenu( p_intf, p_menu_list,
652 val_list.p_list->p_values[i].psz_string, p_object, pi_item_id );
653 AppendMenu( hSubMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem,
654 _FROMMB(text_list.p_list->p_values[i].psz_string ?
655 text_list.p_list->p_values[i].psz_string :
656 val_list.p_list->p_values[i].psz_string) );
660 another_val.psz_string =
661 strdup(val_list.p_list->p_values[i].psz_string);
662 AppendMenu( hSubMenu, MF_STRING, ++(*pi_item_id),
663 _FROMMB(text_list.p_list->p_values[i].psz_string ?
664 text_list.p_list->p_values[i].psz_string :
665 val_list.p_list->p_values[i].psz_string) );
666 pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
667 p_object, another_val, i_type );
668 p_menu_list->push_back( pMenuItemExt );
670 if( !(i_type & VLC_VAR_ISCOMMAND) && val.psz_string &&
671 !strcmp( val.psz_string,
672 val_list.p_list->p_values[i].psz_string ) )
673 CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND);
676 case VLC_VAR_INTEGER:
677 asprintf( &psz_tmp, "%d", val_list.p_list->p_values[i].i_int );
678 AppendMenu( hSubMenu, MF_STRING, ++(*pi_item_id),
679 _FROMMB(text_list.p_list->p_values[i].psz_string ?
680 text_list.p_list->p_values[i].psz_string : psz_tmp));
681 pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
682 p_object, val_list.p_list->p_values[i], i_type );
683 p_menu_list->push_back( pMenuItemExt );
685 if( val_list.p_list->p_values[i].i_int == val.i_int )
686 CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND);
694 /* Clean up everything */
695 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
696 var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list );
701 int wce_GetMenuItemCount(HMENU hMenu)
703 const int MAX_NUM_ITEMS = 256;
707 memset( (char *)&mii, 0, sizeof(MENUITEMINFO) );
708 mii.cbSize = sizeof(MENUITEMINFO);
711 for( iPos = 0; iPos < MAX_NUM_ITEMS; iPos++ )
713 if( !GetMenuItemInfo(hMenu, (UINT)iPos, TRUE, &mii) ) break;
720 void OnMenuEvent( intf_thread_t *p_intf, int id )
722 MenuItemExt *p_menuitemext = NULL;
723 vector<MenuItemExt*>::iterator iter;
725 if( p_intf->p_sys->p_settings_menu )
726 for( iter = p_intf->p_sys->p_settings_menu->begin();
727 iter != p_intf->p_sys->p_settings_menu->end(); iter++ )
728 if( (*iter)->id == id )
730 p_menuitemext = *iter;
734 if( p_intf->p_sys->p_audio_menu && !p_menuitemext )
735 for( iter = p_intf->p_sys->p_audio_menu->begin();
736 iter != p_intf->p_sys->p_audio_menu->end(); iter++ )
737 if( (*iter)->id == id )
739 p_menuitemext = *iter;
743 if( p_intf->p_sys->p_video_menu && !p_menuitemext )
744 for( iter = p_intf->p_sys->p_video_menu->begin();
745 iter != p_intf->p_sys->p_video_menu->end(); iter++ )
746 if( (*iter)->id == id )
748 p_menuitemext = *iter;
752 if( p_intf->p_sys->p_navig_menu && !p_menuitemext )
753 for( iter = p_intf->p_sys->p_navig_menu->begin();
754 iter != p_intf->p_sys->p_navig_menu->end(); iter++ )
755 if( (*iter)->id == id )
757 p_menuitemext = *iter;
763 vlc_object_t *p_object = p_menuitemext->p_object;
764 if( p_object == NULL ) return;
766 var_Set( p_object, p_menuitemext->psz_var, p_menuitemext->val );
767 int i_type = var_Type( p_object, p_menuitemext->psz_var );
768 switch( i_type & VLC_VAR_TYPE )
772 case VLC_VAR_VARIABLE:
774 case VLC_VAR_INTEGER:
777 /* Variable doesn't exist or isn't handled */
781 vlc_object_release( p_object );
785 /*****************************************************************************
786 * A small helper class which encapsulate wxMenuitem with some other useful
788 *****************************************************************************/
789 MenuItemExt::MenuItemExt( intf_thread_t *p_intf, int _id, char *_psz_var,
790 vlc_object_t * _p_object, vlc_value_t _val, int _i_val_type )
792 /* Initializations */
795 psz_var = strdup( _psz_var );
796 i_val_type = _i_val_type;
797 p_object = _p_object;
801 MenuItemExt::~MenuItemExt()
804 if( ( i_val_type & VLC_VAR_TYPE ) == VLC_VAR_STRING )
805 free( val.psz_string );
808 void MenuItemExt::ClearList( vector<MenuItemExt*> *p_menu_list )
810 vector<MenuItemExt*>::iterator iter;
812 if( !p_menu_list ) return;
813 for( iter = p_menu_list->begin(); iter != p_menu_list->end(); iter++ )
817 p_menu_list->clear();