menus.cpp
来自「VLC媒体播放程序」· C++ 代码 · 共 818 行 · 第 1/2 页
CPP
818 行
/***************************************************************************** * menus.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2004 VideoLAN * $Id: menus.cpp,v 1.33 2004/02/26 12:04:14 gbazin Exp $ * * Authors: Gildas Bazin <gbazin@netcourrier.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <stdlib.h> /* malloc(), free() */#include <errno.h> /* ENOMEM */#include <string.h> /* strerror() */#include <stdio.h>#include <vlc/vlc.h>#include <vlc/intf.h>#include "wxwindows.h"class wxMenuItemExt: public wxMenuItem{public: /* Constructor */ wxMenuItemExt( wxMenu* parentMenu, int id, const wxString& text, const wxString& helpString, wxItemKind kind, char *_psz_var, int _i_object_id, vlc_value_t _val, int _i_val_type ); virtual ~wxMenuItemExt(); char *psz_var; int i_val_type; int i_object_id; vlc_value_t val;private:};/***************************************************************************** * Event Table. *****************************************************************************//* IDs for the controls and the menu commands */enum{ /* menu items */ MenuDummy_Event = wxID_HIGHEST + 1000, OpenFileSimple_Event = wxID_HIGHEST + 1100, OpenFile_Event, OpenDisc_Event, OpenNet_Event, FirstAutoGenerated_Event = wxID_HIGHEST + 1999, SettingsMenu_Events = wxID_HIGHEST + 5000, AudioMenu_Events = wxID_HIGHEST + 2000, VideoMenu_Events = wxID_HIGHEST + 3000, NavigMenu_Events = wxID_HIGHEST + 4000, PopupMenu_Events = wxID_HIGHEST + 6000};BEGIN_EVENT_TABLE(Menu, wxMenu)END_EVENT_TABLE()BEGIN_EVENT_TABLE(MenuEvtHandler, wxEvtHandler) EVT_MENU(OpenFileSimple_Event, MenuEvtHandler::OnShowDialog) EVT_MENU(OpenFile_Event, MenuEvtHandler::OnShowDialog) EVT_MENU(OpenDisc_Event, MenuEvtHandler::OnShowDialog) EVT_MENU(OpenNet_Event, MenuEvtHandler::OnShowDialog) EVT_MENU(-1, MenuEvtHandler::OnMenuEvent)END_EVENT_TABLE()wxMenu *OpenStreamMenu( intf_thread_t *p_intf ){ wxMenu *menu = new wxMenu; menu->Append( OpenFileSimple_Event, wxU(_("Quick &Open File...")) ); menu->Append( OpenFile_Event, wxU(_("Open &File...")) ); menu->Append( OpenDisc_Event, wxU(_("Open &Disc...")) ); menu->Append( OpenNet_Event, wxU(_("Open &Network Stream...")) ); return menu;}void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent, const wxPoint& pos ){#define MAX_POPUP_ITEMS 35 vlc_object_t *p_object; char *ppsz_varnames[MAX_POPUP_ITEMS]; int pi_objects[MAX_POPUP_ITEMS]; int i = 0; /* Initializations */ memset( pi_objects, 0, MAX_POPUP_ITEMS * sizeof(int) ); /* Audio menu */ ppsz_varnames[i++] = _("Audio menu"); ppsz_varnames[i++] = NULL; /* Separator */ p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE ); if( p_object != NULL ) { ppsz_varnames[i] = "audio-device"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "audio-channels"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "visual"; pi_objects[i++] = p_object->i_object_id; vlc_object_release( p_object ); } /* Video menu */ ppsz_varnames[i++] = NULL; /* Separator */ ppsz_varnames[i++] = _("Video menu"); ppsz_varnames[i++] = NULL; /* Separator */ p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); if( p_object != NULL ) { vlc_object_t *p_dec_obj; ppsz_varnames[i] = "fullscreen"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "deinterlace"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "aspect-ratio"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "crop"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "video-on-top"; pi_objects[i++] = p_object->i_object_id; p_dec_obj = (vlc_object_t *)vlc_object_find( p_object, VLC_OBJECT_DECODER, FIND_PARENT ); if( p_dec_obj != NULL ) { ppsz_varnames[i] = "ffmpeg-pp-q"; pi_objects[i++] = p_dec_obj->i_object_id; vlc_object_release( p_dec_obj ); } vlc_object_release( p_object ); } /* Input menu */ ppsz_varnames[i++] = NULL; /* Separator */ ppsz_varnames[i++] = _("Input menu"); ppsz_varnames[i++] = NULL; /* Separator */ p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_object != NULL ) { ppsz_varnames[i] = "title"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "chapter"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "program"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "navigation"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "dvd_menus"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "video-es"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "audio-es"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "spu-es"; pi_objects[i++] = p_object->i_object_id; vlc_object_release( p_object ); } /* Interface menu */ ppsz_varnames[i++] = NULL; /* Separator */ ppsz_varnames[i++] = _("Interface menu"); ppsz_varnames[i++] = NULL; /* Separator */ /* vlc_object_find is needed because of the dialogs provider case */ p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INTF, FIND_PARENT ); if( p_object != NULL ) { ppsz_varnames[i] = "intf-switch"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "intf-add"; pi_objects[i++] = p_object->i_object_id; vlc_object_release( p_object ); } /* Build menu */ Menu popupmenu( p_intf, p_parent, i, ppsz_varnames, pi_objects, PopupMenu_Events );#if 1 /* Add static entries */ popupmenu.AppendSeparator(); popupmenu.Append( MenuDummy_Event, wxU("Open..."), OpenStreamMenu( p_intf ), wxT("") );#endif p_intf->p_sys->p_popup_menu = &popupmenu; p_parent->PopupMenu( &popupmenu, pos.x, pos.y ); p_intf->p_sys->p_popup_menu = NULL;}wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent ){#define MAX_AUDIO_ITEMS 10 vlc_object_t *p_object; char *ppsz_varnames[MAX_AUDIO_ITEMS]; int pi_objects[MAX_AUDIO_ITEMS]; int i = 0; /* Initializations */ memset( pi_objects, 0, MAX_AUDIO_ITEMS * sizeof(int) ); p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_object != NULL ) { ppsz_varnames[i] = "audio-es"; pi_objects[i++] = p_object->i_object_id; vlc_object_release( p_object ); } p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE ); if( p_object != NULL ) { ppsz_varnames[i] = "audio-device"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "audio-channels"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "visual"; pi_objects[i++] = p_object->i_object_id; vlc_object_release( p_object ); } /* Build menu */ return new Menu( _p_intf, p_parent, i, ppsz_varnames, pi_objects, AudioMenu_Events );}wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent ){#define MAX_VIDEO_ITEMS 15 vlc_object_t *p_object; char *ppsz_varnames[MAX_VIDEO_ITEMS]; int pi_objects[MAX_VIDEO_ITEMS]; int i = 0; /* Initializations */ memset( pi_objects, 0, MAX_VIDEO_ITEMS * sizeof(int) ); p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_object != NULL ) { ppsz_varnames[i] = "video-es"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "spu-es"; pi_objects[i++] = p_object->i_object_id; vlc_object_release( p_object ); } p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); if( p_object != NULL ) { vlc_object_t *p_dec_obj; ppsz_varnames[i] = "fullscreen"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "deinterlace"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "aspect-ratio"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "crop"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "directx-on-top"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "xvideo-on-top"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "x11-on-top"; pi_objects[i++] = p_object->i_object_id; p_dec_obj = (vlc_object_t *)vlc_object_find( p_object, VLC_OBJECT_DECODER, FIND_PARENT ); if( p_dec_obj != NULL ) { ppsz_varnames[i] = "ffmpeg-pp-q"; pi_objects[i++] = p_dec_obj->i_object_id; vlc_object_release( p_dec_obj ); } vlc_object_release( p_object ); } /* Build menu */ return new Menu( _p_intf, p_parent, i, ppsz_varnames, pi_objects, VideoMenu_Events );}wxMenu *NavigMenu( intf_thread_t *_p_intf, wxWindow *p_parent ){#define MAX_NAVIG_ITEMS 10 vlc_object_t *p_object; char *ppsz_varnames[MAX_NAVIG_ITEMS]; int pi_objects[MAX_NAVIG_ITEMS]; int i = 0; /* Initializations */ memset( pi_objects, 0, MAX_NAVIG_ITEMS * sizeof(int) ); p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_object != NULL ) { ppsz_varnames[i] = "title"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "chapter"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "program"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "navigation"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "dvd_menus"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "prev-title"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "next-title"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "prev-chapter"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "next-chapter"; pi_objects[i++] = p_object->i_object_id; vlc_object_release( p_object ); } /* Build menu */ return new Menu( _p_intf, p_parent, i, ppsz_varnames, pi_objects, NavigMenu_Events );}wxMenu *SettingsMenu( intf_thread_t *_p_intf, wxWindow *p_parent ){#define MAX_SETTINGS_ITEMS 10 vlc_object_t *p_object; char *ppsz_varnames[MAX_SETTINGS_ITEMS]; int pi_objects[MAX_SETTINGS_ITEMS]; int i = 0; /* Initializations */ memset( pi_objects, 0, MAX_SETTINGS_ITEMS * sizeof(int) ); p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INTF, FIND_PARENT ); if( p_object != NULL ) { ppsz_varnames[i] = "intf-switch"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "intf-add"; pi_objects[i++] = p_object->i_object_id; vlc_object_release( p_object ); } /* Build menu */ return new Menu( _p_intf, p_parent, i, ppsz_varnames, pi_objects, SettingsMenu_Events );}/***************************************************************************** * Constructor. *****************************************************************************/Menu::Menu( intf_thread_t *_p_intf, wxWindow *p_parent, int i_count, char **ppsz_varnames, int *pi_objects, int i_start_id ): wxMenu( ){ vlc_object_t *p_object; vlc_bool_t b_section_empty = VLC_FALSE;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?