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>
37 /*****************************************************************************
39 *****************************************************************************/
41 /* IDs for the controls and the menu commands */
45 MenuDummy_Event = 1000,
46 OpenFileSimple_Event = 1100,
50 FirstAutoGenerated_Event = 1999,
51 SettingsMenu_Events = 2000,
52 AudioMenu_Events = 3000,
53 VideoMenu_Events = 4000,
54 NavigMenu_Events = 5000,
55 PopupMenu_Events = 6000
58 HMENU OpenStreamMenu( intf_thread_t *p_intf )
60 HMENU hmenu = CreatePopupMenu();
61 AppendMenu( hmenu, MF_STRING, ID_FILE_QUICKOPEN,
62 _T("Quick &Open File...") );
63 AppendMenu( hmenu, MF_STRING, ID_FILE_OPENFILE,
64 _T("Open &File...") );
65 AppendMenu( hmenu, MF_STRING, ID_FILE_OPENNET,
66 _T("Open &Network Stream...") );
70 HMENU MiscMenu( intf_thread_t *p_intf )
72 HMENU hmenu = CreatePopupMenu();
73 AppendMenu( hmenu, MF_STRING, ID_VIEW_STREAMINFO, _T("Media &Info...") );
74 AppendMenu( hmenu, MF_STRING, ID_VIEW_MESSAGES, _T("&Messages...") );
75 AppendMenu( hmenu, MF_STRING, ID_PREFERENCES, _T("&Preferences...") );
79 void PopupMenu( intf_thread_t *p_intf, HWND p_parent, POINT point )
81 #define MAX_POPUP_ITEMS 45
83 vlc_object_t *p_object, *p_input;
84 char *ppsz_varnames[MAX_POPUP_ITEMS];
85 int pi_objects[MAX_POPUP_ITEMS];
86 int i = 0, i_last_separator = 0;
89 memset( pi_objects, 0, MAX_POPUP_ITEMS * sizeof(int) );
91 ppsz_varnames[i] = "VLC media player";
93 ppsz_varnames[i++] = NULL; /* Separator */
97 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
99 if( p_object != NULL )
101 ppsz_varnames[i] = "bookmark";
102 pi_objects[i++] = p_object->i_object_id;
103 ppsz_varnames[i] = "title";
104 pi_objects[i++] = p_object->i_object_id;
105 ppsz_varnames[i] = "chapter";
106 pi_objects[i++] = p_object->i_object_id;
107 ppsz_varnames[i] = "program";
108 pi_objects[i++] = p_object->i_object_id;
109 ppsz_varnames[i] = "navigation";
110 pi_objects[i++] = p_object->i_object_id;
111 ppsz_varnames[i] = "dvd_menus";
112 pi_objects[i++] = p_object->i_object_id;
114 ppsz_varnames[i] = "video-es";
115 pi_objects[i++] = p_object->i_object_id;
116 ppsz_varnames[i] = "audio-es";
117 pi_objects[i++] = p_object->i_object_id;
118 ppsz_varnames[i] = "spu-es";
119 pi_objects[i++] = p_object->i_object_id;
122 if( !p_input ) goto interfacemenu;
125 if( i != i_last_separator ) ppsz_varnames[i++] = NULL; /* Separator */
126 i_last_separator = i;
128 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
130 if( p_object != NULL )
132 vlc_object_t *p_dec_obj;
134 ppsz_varnames[i] = "fullscreen";
135 pi_objects[i++] = p_object->i_object_id;
136 ppsz_varnames[i] = "zoom";
137 pi_objects[i++] = p_object->i_object_id;
138 ppsz_varnames[i] = "deinterlace";
139 pi_objects[i++] = p_object->i_object_id;
140 ppsz_varnames[i] = "aspect-ratio";
141 pi_objects[i++] = p_object->i_object_id;
142 ppsz_varnames[i] = "crop";
143 pi_objects[i++] = p_object->i_object_id;
144 ppsz_varnames[i] = "video-on-top";
145 pi_objects[i++] = p_object->i_object_id;
146 ppsz_varnames[i] = "directx-wallpaper";
147 pi_objects[i++] = p_object->i_object_id;
148 ppsz_varnames[i] = "video-snapshot";
149 pi_objects[i++] = p_object->i_object_id;
151 p_dec_obj = (vlc_object_t *)vlc_object_find( p_object,
154 if( p_dec_obj != NULL )
156 ppsz_varnames[i] = "ffmpeg-pp-q";
157 pi_objects[i++] = p_dec_obj->i_object_id;
158 vlc_object_release( p_dec_obj );
161 vlc_object_release( p_object );
165 if( i != i_last_separator ) ppsz_varnames[i++] = NULL; /* Separator */
166 i_last_separator = i;
168 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
170 if( p_object != NULL )
172 ppsz_varnames[i] = "audio-device";
173 pi_objects[i++] = p_object->i_object_id;
174 ppsz_varnames[i] = "audio-channels";
175 pi_objects[i++] = p_object->i_object_id;
176 ppsz_varnames[i] = "visual";
177 pi_objects[i++] = p_object->i_object_id;
178 ppsz_varnames[i] = "equalizer";
179 pi_objects[i++] = p_object->i_object_id;
180 vlc_object_release( p_object );
185 if( i != i_last_separator ) ppsz_varnames[i++] = NULL; /* Separator */
186 i_last_separator = i;
188 /* vlc_object_find is needed because of the dialogs provider case */
189 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INTF,
191 if( p_object != NULL )
193 /* Nothing for now */
194 vlc_object_release( p_object );
198 vector<MenuItemExt*> popup_menu;
199 HMENU hmenu = CreatePopupMenu();
200 RefreshMenu( p_intf, &popup_menu, hmenu, i,
201 ppsz_varnames, pi_objects, PopupMenu_Events );
202 MenuItemExt::ClearList( &popup_menu );
205 /* Add static entries */
206 if( p_input != NULL )
209 AppendMenu( hmenu, MF_SEPARATOR, 0, _T("") );
210 AppendMenu( hmenu, MF_STRING, StopStream_Event, _T("Stop") );
211 AppendMenu( hmenu, MF_STRING, PrevStream_Event, _T("Previous") );
212 AppendMenu( hmenu, MF_STRING, NextStream_Event, _T("Next") );
214 var_Get( p_input, "state", &val );
215 if( val.i_int == PAUSE_S )
216 AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Play") );
218 AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Pause") );
220 vlc_object_release( p_input );
224 playlist_t * p_playlist = pl_Yield( p_intf );
225 if( p_playlist && p_playlist->i_size )
227 AppendMenu( hmenu, MF_SEPARATOR, 0, _T("") );
228 AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Play") );
230 if( p_playlist ) pl_Release( p_intf );
233 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)MiscMenu( p_intf ),
234 _T("Miscellaneous") );
235 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)OpenStreamMenu( p_intf ),
238 TrackPopupMenu( hmenu, 0, point.x, point.y, 0, p_parent, 0 );
239 PostMessage( p_parent, WM_NULL, 0, 0 );
240 DestroyMenu( hmenu );
243 void RefreshAudioMenu( intf_thread_t *p_intf, HMENU hMenu )
245 #define MAX_AUDIO_ITEMS 10
247 vlc_object_t *p_object;
248 char *ppsz_varnames[MAX_AUDIO_ITEMS];
249 int pi_objects[MAX_AUDIO_ITEMS];
252 /* Delete old menu */
253 int count = wce_GetMenuItemCount( hMenu );
254 for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
256 if( p_intf->p_sys->p_audio_menu )
257 MenuItemExt::ClearList( p_intf->p_sys->p_audio_menu );
258 else p_intf->p_sys->p_audio_menu = new vector<MenuItemExt*>;
261 /* Initializations */
262 memset( pi_objects, 0, MAX_AUDIO_ITEMS * sizeof(int) );
265 p_object = (vlc_object_t *)
266 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
267 if( p_object != NULL )
269 ppsz_varnames[i] = "audio-es";
270 pi_objects[i++] = p_object->i_object_id;
271 vlc_object_release( p_object );
274 p_object = (vlc_object_t *)
275 vlc_object_find( p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE );
276 if( p_object != NULL )
278 ppsz_varnames[i] = "audio-device";
279 pi_objects[i++] = p_object->i_object_id;
280 ppsz_varnames[i] = "audio-channels";
281 pi_objects[i++] = p_object->i_object_id;
282 ppsz_varnames[i] = "visual";
283 pi_objects[i++] = p_object->i_object_id;
284 vlc_object_release( p_object );
288 RefreshMenu( p_intf, p_intf->p_sys->p_audio_menu,
289 hMenu, i, ppsz_varnames, pi_objects, AudioMenu_Events );
292 void RefreshVideoMenu( intf_thread_t *p_intf, HMENU hMenu )
294 #define MAX_VIDEO_ITEMS 15
296 vlc_object_t *p_object;
297 char *ppsz_varnames[MAX_VIDEO_ITEMS];
298 int pi_objects[MAX_VIDEO_ITEMS];
301 /* Delete old menu */
302 int count = wce_GetMenuItemCount( hMenu );
303 for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
305 if( p_intf->p_sys->p_video_menu )
306 MenuItemExt::ClearList( p_intf->p_sys->p_video_menu );
307 else p_intf->p_sys->p_video_menu = new vector<MenuItemExt*>;
309 /* Initializations */
310 memset( pi_objects, 0, MAX_VIDEO_ITEMS * sizeof(int) );
313 p_object = (vlc_object_t *)
314 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
315 if( p_object != NULL )
317 ppsz_varnames[i] = "video-es";
318 pi_objects[i++] = p_object->i_object_id;
319 ppsz_varnames[i] = "spu-es";
320 pi_objects[i++] = p_object->i_object_id;
321 vlc_object_release( p_object );
324 p_object = (vlc_object_t *)
325 vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
326 if( p_object != NULL )
328 vlc_object_t *p_dec_obj;
330 ppsz_varnames[i] = "fullscreen";
331 pi_objects[i++] = p_object->i_object_id;
333 ppsz_varnames[i] = "transform";
334 pi_objects[i++] = p_object->i_object_id;
336 ppsz_varnames[i] = "zoom";
337 pi_objects[i++] = p_object->i_object_id;
338 ppsz_varnames[i] = "deinterlace";
339 pi_objects[i++] = p_object->i_object_id;
340 ppsz_varnames[i] = "aspect-ratio";
341 pi_objects[i++] = p_object->i_object_id;
342 ppsz_varnames[i] = "crop";
343 pi_objects[i++] = p_object->i_object_id;
344 ppsz_varnames[i] = "directx-on-top";
345 pi_objects[i++] = p_object->i_object_id;
347 p_dec_obj = (vlc_object_t *)
348 vlc_object_find( p_object, VLC_OBJECT_DECODER, FIND_PARENT );
349 if( p_dec_obj != NULL )
351 ppsz_varnames[i] = "ffmpeg-pp-q";
352 pi_objects[i++] = p_dec_obj->i_object_id;
353 vlc_object_release( p_dec_obj );
356 vlc_object_release( p_object );
360 RefreshMenu( p_intf, p_intf->p_sys->p_video_menu, hMenu, i,
361 ppsz_varnames, pi_objects, VideoMenu_Events );
364 void RefreshNavigMenu( intf_thread_t *p_intf, HMENU hMenu )
366 #define MAX_NAVIG_ITEMS 10
368 vlc_object_t *p_object;
369 char *ppsz_varnames[MAX_NAVIG_ITEMS];
370 int pi_objects[MAX_NAVIG_ITEMS];
373 /* Delete old menu */
374 int count = wce_GetMenuItemCount( hMenu );
375 for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
377 if( p_intf->p_sys->p_navig_menu )
378 MenuItemExt::ClearList( p_intf->p_sys->p_navig_menu );
379 else p_intf->p_sys->p_navig_menu = new vector<MenuItemExt*>;
381 /* Initializations */
382 memset( pi_objects, 0, MAX_NAVIG_ITEMS * sizeof(int) );
385 p_object = (vlc_object_t *)
386 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
387 if( p_object != NULL )
389 ppsz_varnames[i] = "title";
390 pi_objects[i++] = p_object->i_object_id;
391 ppsz_varnames[i] = "chapter";
392 pi_objects[i++] = p_object->i_object_id;
393 ppsz_varnames[i] = "program";
394 pi_objects[i++] = p_object->i_object_id;
395 ppsz_varnames[i] = "navigation";
396 pi_objects[i++] = p_object->i_object_id;
397 ppsz_varnames[i] = "dvd_menus";
398 pi_objects[i++] = p_object->i_object_id;
400 ppsz_varnames[i] = "prev-title";
401 pi_objects[i++] = p_object->i_object_id;
402 ppsz_varnames[i] = "next-title";
403 pi_objects[i++] = p_object->i_object_id;
404 ppsz_varnames[i] = "prev-chapter";
405 pi_objects[i++] = p_object->i_object_id;
406 ppsz_varnames[i] = "next-chapter";
407 pi_objects[i++] = p_object->i_object_id;
409 vlc_object_release( p_object );
413 RefreshMenu( p_intf, p_intf->p_sys->p_navig_menu, hMenu, i,
414 ppsz_varnames, pi_objects, NavigMenu_Events );
417 void RefreshSettingsMenu( intf_thread_t *p_intf, HMENU hMenu )
419 #define MAX_SETTINGS_ITEMS 10
421 vlc_object_t *p_object;
422 char *ppsz_varnames[MAX_SETTINGS_ITEMS];
423 int pi_objects[MAX_SETTINGS_ITEMS];
426 /* Delete old menu */
427 int count = wce_GetMenuItemCount( hMenu );
428 for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
430 if( p_intf->p_sys->p_settings_menu )
431 MenuItemExt::ClearList( p_intf->p_sys->p_settings_menu );
432 else p_intf->p_sys->p_settings_menu = new vector<MenuItemExt*>;
434 /* Initializations */
435 memset( pi_objects, 0, MAX_SETTINGS_ITEMS * sizeof(int) );
438 AppendMenu( hMenu, MF_STRING, ID_PREFERENCES, _T("&Preferences...") );
440 p_object = (vlc_object_t *)
441 vlc_object_find( p_intf, VLC_OBJECT_INTF, FIND_PARENT );
442 if( p_object != NULL )
444 ppsz_varnames[i] = "intf-add";
445 pi_objects[i++] = p_object->i_object_id;
446 vlc_object_release( p_object );
450 RefreshMenu( p_intf, p_intf->p_sys->p_settings_menu, hMenu, i,
451 ppsz_varnames, pi_objects, SettingsMenu_Events );
454 /*****************************************************************************
456 *****************************************************************************/
457 void RefreshMenu( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list,
458 HMENU hMenu , int i_count, char **ppsz_varnames,
459 int *pi_objects, int i_start_id )
461 vlc_object_t *p_object;
462 bool b_section_empty = false;
465 /* Initializations */
466 int i_item_id = i_start_id;
468 for( i = 0; i < i_count; i++ )
470 if( !ppsz_varnames[i] )
472 if( b_section_empty )
474 AppendMenu( hMenu, MF_GRAYED | MF_STRING,
475 MenuDummy_Event + i, _T("Empty") );
478 AppendMenu( hMenu, MF_SEPARATOR, 0, _T("") );
479 b_section_empty = true;
485 AppendMenu( hMenu, MF_GRAYED | MF_STRING,
486 MenuDummy_Event, _FROMMB(ppsz_varnames[i]) );
488 b_section_empty = false;
492 p_object = (vlc_object_t *)vlc_object_get( pi_objects[i] );
493 if( p_object == NULL ) continue;
495 b_section_empty = false;
496 CreateMenuItem( p_intf, p_menu_list, hMenu, ppsz_varnames[i],
497 p_object, &i_item_id );
498 vlc_object_release( p_object );
501 /* Special case for empty menus */
502 if( wce_GetMenuItemCount(hMenu) == 0 || b_section_empty )
504 AppendMenu( hMenu, MF_GRAYED | MF_STRING,
505 MenuDummy_Event + i, _T("Empty") );
509 /*****************************************************************************
511 *****************************************************************************/
512 void CreateMenuItem( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list,
513 HMENU hMenu, char *psz_var, vlc_object_t *p_object,
516 MenuItemExt *pMenuItemExt;
518 vlc_value_t val, text;
521 /* Check the type of the object variable */
522 i_type = var_Type( p_object, psz_var );
524 switch( i_type & VLC_VAR_TYPE )
528 case VLC_VAR_VARIABLE:
530 case VLC_VAR_INTEGER:
534 /* Variable doesn't exist or isn't handled */
538 /* Make sure we want to display the variable */
539 if( i_type & VLC_VAR_HASCHOICE )
541 var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
542 if( val.i_int == 0 ) return;
543 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
547 /* Get the descriptive name of the variable */
548 var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
550 var_Get( p_object, psz_var, &val );
552 if( i_type & VLC_VAR_HASCHOICE )
554 hMenuItem = CreateChoicesMenu( p_intf, p_menu_list, psz_var,
555 p_object, pi_item_id );
556 AppendMenu( hMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem,
557 _FROMMB(text.psz_string ? text.psz_string : psz_var) );
558 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
559 free( text.psz_string );
563 switch( i_type & VLC_VAR_TYPE )
566 AppendMenu( hMenu, MF_STRING , ++(*pi_item_id),
567 _FROMMB(text.psz_string ? text.psz_string : psz_var) );
568 pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
569 p_object->i_object_id, val, i_type );
570 p_menu_list->push_back( pMenuItemExt );
574 val.b_bool = !val.b_bool;
575 AppendMenu( hMenu, MF_STRING | MF_CHECKED, ++(*pi_item_id),
576 _FROMMB(text.psz_string ? text.psz_string : psz_var) );
577 pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
578 p_object->i_object_id, val, i_type );
579 p_menu_list->push_back( pMenuItemExt );
580 CheckMenuItem( hMenu, *pi_item_id ,
581 ( val.b_bool ? MF_UNCHECKED : MF_CHECKED ) |
586 free( text.psz_string );
590 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
591 free( text.psz_string );
594 HMENU CreateChoicesMenu( intf_thread_t *p_intf,
595 vector<MenuItemExt*> *p_menu_list, char *psz_var,
596 vlc_object_t *p_object, int *pi_item_id )
598 MenuItemExt *pMenuItemExt;
599 vlc_value_t val, val_list, text_list;
601 HMENU hSubMenu = CreatePopupMenu();
603 /* Check the type of the object variable */
604 i_type = var_Type( p_object, psz_var );
606 /* Make sure we want to display the variable */
607 if( i_type & VLC_VAR_HASCHOICE )
609 var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
610 if( val.i_int == 0 ) return NULL;
611 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
619 switch( i_type & VLC_VAR_TYPE )
623 case VLC_VAR_VARIABLE:
625 case VLC_VAR_INTEGER:
628 /* Variable doesn't exist or isn't handled */
632 if( var_Get( p_object, psz_var, &val ) < 0 ) return NULL;
634 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
635 &val_list, &text_list ) < 0 )
637 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
641 for( i = 0; i < val_list.p_list->i_count; i++ )
643 vlc_value_t another_val;
647 switch( i_type & VLC_VAR_TYPE )
649 case VLC_VAR_VARIABLE:
650 hMenuItem = CreateChoicesMenu( p_intf, p_menu_list,
651 val_list.p_list->p_values[i].psz_string, p_object, pi_item_id );
652 AppendMenu( hSubMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem,
653 _FROMMB(text_list.p_list->p_values[i].psz_string ?
654 text_list.p_list->p_values[i].psz_string :
655 val_list.p_list->p_values[i].psz_string) );
659 another_val.psz_string =
660 strdup(val_list.p_list->p_values[i].psz_string);
661 AppendMenu( hSubMenu, MF_STRING, ++(*pi_item_id),
662 _FROMMB(text_list.p_list->p_values[i].psz_string ?
663 text_list.p_list->p_values[i].psz_string :
664 val_list.p_list->p_values[i].psz_string) );
665 pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
666 p_object->i_object_id, another_val, i_type );
667 p_menu_list->push_back( pMenuItemExt );
669 if( !(i_type & VLC_VAR_ISCOMMAND) && val.psz_string &&
670 !strcmp( val.psz_string,
671 val_list.p_list->p_values[i].psz_string ) )
672 CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND);
675 case VLC_VAR_INTEGER:
676 asprintf( &psz_tmp, "%d", val_list.p_list->p_values[i].i_int );
677 AppendMenu( hSubMenu, MF_STRING, ++(*pi_item_id),
678 _FROMMB(text_list.p_list->p_values[i].psz_string ?
679 text_list.p_list->p_values[i].psz_string : psz_tmp));
680 pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
681 p_object->i_object_id, val_list.p_list->p_values[i], i_type );
682 p_menu_list->push_back( pMenuItemExt );
684 if( val_list.p_list->p_values[i].i_int == val.i_int )
685 CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND);
693 /* Clean up everything */
694 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
695 var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list );
700 int wce_GetMenuItemCount(HMENU hMenu)
702 const int MAX_NUM_ITEMS = 256;
706 memset( (char *)&mii, 0, sizeof(MENUITEMINFO) );
707 mii.cbSize = sizeof(MENUITEMINFO);
710 for( iPos = 0; iPos < MAX_NUM_ITEMS; iPos++ )
712 if( !GetMenuItemInfo(hMenu, (UINT)iPos, TRUE, &mii) ) break;
719 void OnMenuEvent( intf_thread_t *p_intf, int id )
721 MenuItemExt *p_menuitemext = NULL;
722 vector<MenuItemExt*>::iterator iter;
724 if( p_intf->p_sys->p_settings_menu )
725 for( iter = p_intf->p_sys->p_settings_menu->begin();
726 iter != p_intf->p_sys->p_settings_menu->end(); iter++ )
727 if( (*iter)->id == id )
729 p_menuitemext = *iter;
733 if( p_intf->p_sys->p_audio_menu && !p_menuitemext )
734 for( iter = p_intf->p_sys->p_audio_menu->begin();
735 iter != p_intf->p_sys->p_audio_menu->end(); iter++ )
736 if( (*iter)->id == id )
738 p_menuitemext = *iter;
742 if( p_intf->p_sys->p_video_menu && !p_menuitemext )
743 for( iter = p_intf->p_sys->p_video_menu->begin();
744 iter != p_intf->p_sys->p_video_menu->end(); iter++ )
745 if( (*iter)->id == id )
747 p_menuitemext = *iter;
751 if( p_intf->p_sys->p_navig_menu && !p_menuitemext )
752 for( iter = p_intf->p_sys->p_navig_menu->begin();
753 iter != p_intf->p_sys->p_navig_menu->end(); iter++ )
754 if( (*iter)->id == id )
756 p_menuitemext = *iter;
762 vlc_object_t *p_object = (vlc_object_t *)
763 vlc_object_get( p_menuitemext->i_object_id );
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 int _i_object_id, vlc_value_t _val, int _i_val_type )
792 /* Initializations */
795 psz_var = strdup( _psz_var );
796 i_val_type = _i_val_type;
797 i_object_id = _i_object_id;
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();