⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interface.cpp

📁 uclinux 下的vlc播放器源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
#endif#endif    p_intf->b_interaction = VLC_FALSE;    var_DelCallback( p_intf, "interaction", InteractCallback, this );    if( p_intf->p_sys->p_wxwindow ) delete p_intf->p_sys->p_wxwindow;    /* Clean up */    delete timer;}void Interface::Init(){    /* Misc init */    SetupHotkeys();}void Interface::Update(){    /* Misc updates */    if( !(i_update_counter % 10) ) ((VLCVolCtrl *)volctrl)->UpdateVolume();    if( playlist_manager ) playlist_manager->Update();    i_update_counter++;}void Interface::OnControlEvent( wxCommandEvent& event ){    switch( event.GetId() )    {    case 0:        main_sizer->Layout();        main_sizer->Fit( this );        break;    case 1:        long i_style = GetWindowStyle();        if( event.GetInt() ) i_style |= wxSTAY_ON_TOP;        else i_style &= ~wxSTAY_ON_TOP;        SetWindowStyle( i_style );        break;    }}/***************************************************************************** * Private methods. *****************************************************************************/void Interface::CreateOurMenuBar(){    int minimal = config_GetInt( p_intf, "wx-minimal" );    /* Create the "File" menu */    wxMenu *file_menu = new wxMenu;    if (!minimal)    {    file_menu->Append( OpenFileSimple_Event,                       wxU(_("Quick &Open File...\tCtrl-O")) );    file_menu->AppendSeparator();    file_menu->Append( OpenFile_Event, wxU(_("Open &File...\tCtrl-F")) );    file_menu->Append( OpenDir_Event, wxU(_("Open Dir&ectory...\tCtrl-E")) );    file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...\tCtrl-D")) );    file_menu->Append( OpenNet_Event,                       wxU(_("Open &Network Stream...\tCtrl-N")) );    file_menu->Append( OpenCapture_Event,                       wxU(_("Open C&apture Device...\tCtrl-A")) );    file_menu->AppendSeparator();    file_menu->Append( Wizard_Event, wxU(_("&Wizard...\tCtrl-W")) );    file_menu->AppendSeparator();    }    file_menu->Append( Exit_Event, wxU(_("E&xit\tCtrl-X")) );    /* Create the "View" menu */    wxMenu *view_menu = new wxMenu;    if (!minimal)    {    view_menu->Append( Playlist_Event, wxU(_("&Playlist...\tCtrl-P")) );    }    view_menu->Append( Logs_Event, wxU(_("&Messages...\tCtrl-M")) );    view_menu->Append( FileInfo_Event,                       wxU(_("Stream and Media &Info...\tCtrl-I")) );    view_menu->Append( VLM_Event,                       wxU(_("VLM Control...\tCtrl-V")) );    /* Create the "Auto-generated" menus */    p_settings_menu = SettingsMenu( p_intf, this );    p_audio_menu = AudioMenu( p_intf, this );    p_video_menu = VideoMenu( p_intf, this );    p_navig_menu = NavigMenu( p_intf, this );    /* Create the "Help" menu */    wxMenu *help_menu = new wxMenu;    help_menu->Append( About_Event, wxU(_("About...")) );    help_menu->AppendSeparator();    help_menu->Append( UpdateVLC_Event, wxU(_("Check for Updates...")) );    /* Append the freshly created menus to the menu bar... */    wxMenuBar *menubar = new wxMenuBar();    menubar->Append( file_menu, wxU(_("&File")) );    menubar->Append( view_menu, wxU(_("&View")) );    menubar->Append( p_settings_menu, wxU(_("&Settings")) );    menubar->Append( p_audio_menu, wxU(_("&Audio")) );    menubar->Append( p_video_menu, wxU(_("&Video")) );    menubar->Append( p_navig_menu, wxU(_("&Navigation")) );    menubar->Append( help_menu, wxU(_("&Help")) );    /* Attach the menu bar to the frame */    SetMenuBar( menubar );    /* Find out size of menu bar */    int i_size = 0;    for( unsigned int i = 0; i < menubar->GetMenuCount(); i++ )    {        int i_width, i_height;        menubar->GetTextExtent( menubar->GetLabelTop(i), &i_width, &i_height );        i_size += i_width +#if defined(__WXGTK__)            22 /* approximate margin */;#else#if (wxMAJOR_VERSION <= 2) && (wxMINOR_VERSION <= 5) && (wxRELEASE_NUMBER < 3)            4 /* approximate margin */;#else            18 /* approximate margin */;#endif#endif    }/* Patch by zcot for menu wrapping */#if defined(WIN32)    /* Find out size of msw menu bar */    i_size = 0;    SIZE sizing;    HDC hdc = GetDC( NULL );    for( unsigned int i = 0; i < menubar->GetMenuCount(); i++ )    {        GetTextExtentPoint32( hdc, menubar->GetLabelTop(i).c_str(),                                menubar->GetLabelTop(i).Length(), &sizing );        // [ SM_CXDLGFRAME + pixels + textextent + pixels + SM_CXDLGFRAME ]        i_size += sizing.cx + 2 + GetSystemMetrics( SM_CXDLGFRAME ) * 2;    }    ReleaseDC( NULL, hdc );    i_size += GetSystemMetrics( SM_CXSIZEFRAME ) * 2 + 4;#endif/* End patch by zcot */    panel_sizer->SetMinSize( i_size, -1 );    /* Intercept all menu events in our custom event handler */    PushEventHandler( new MenuEvtHandler( p_intf, this ) );#if wxUSE_DRAG_AND_DROP    /* Associate drop targets with the menubar */    menubar->SetDropTarget( new DragAndDrop( p_intf ) );#endif}void Interface::CreateOurToolBar(){#define HELP_OPEN N_("Open")#define HELP_STOP N_("Stop")#define HELP_PLAY N_("Play")#define HELP_PAUSE N_("Pause")#define HELP_PLO N_("Playlist")#define HELP_SPLO N_("Embedded playlist")#define HELP_PLP N_("Previous playlist item")#define HELP_PLN N_("Next playlist item")#define HELP_SLOW N_("Play slower")#define HELP_FAST N_("Play faster")#define LABEL_OPEN N_("Open")#define LABEL_STOP N_("Stop")#define LABEL_PLAY N_("Play")#define LABEL_PAUSE N_("Pause")#define LABEL_PLO N_("Playlist")#define LABEL_SPLO N_("Embedded playlist")#define LABEL_PLP N_("Previous")#define LABEL_PLN N_("Next")#define LABEL_SLOW N_("Slower")#define LABEL_FAST N_("Faster")    int minimal = config_GetInt( p_intf, "wx-minimal" );    bool label = config_GetInt( p_intf, "wx-labels" );    wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32                         * version because we don't include wx.rc */    wxToolBar *toolbar =        CreateToolBar( label?wxTB_HORIZONTAL | wxTB_FLAT |wxTB_TEXT:                       wxTB_HORIZONTAL | wxTB_FLAT );    toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );    if (!minimal)    {    toolbar->AddTool( OpenFile_Event, wxU(LABEL_OPEN),                      wxBitmap( eject_xpm ), wxU(_(HELP_OPEN)) );    toolbar->AddSeparator();    }    wxToolBarToolBase *p_tool = toolbar->AddTool( PlayStream_Event, wxU(LABEL_PLAY),                      wxBitmap( play_xpm ), wxU(_(HELP_PLAY)), wxITEM_CHECK );    p_tool->SetClientData( p_tool );    if (!minimal)    {    toolbar->AddTool( StopStream_Event, wxU(LABEL_STOP), wxBitmap( stop_xpm ),                      wxU(_(HELP_STOP)) );    toolbar->AddSeparator();    toolbar->AddTool( PrevStream_Event, wxU(LABEL_PLP),                      wxBitmap( prev_xpm ), wxU(_(HELP_PLP)) );    toolbar->AddTool( SlowStream_Event, wxU(LABEL_SLOW),                      wxBitmap( slow_xpm ), wxU(_(HELP_SLOW)) );    toolbar->AddTool( FastStream_Event, wxU(LABEL_FAST),                      wxBitmap( fast_xpm ), wxU(_(HELP_FAST)) );    toolbar->AddTool( NextStream_Event, wxU(LABEL_PLN), wxBitmap( next_xpm ),                      wxU(_(HELP_PLN)) );    toolbar->AddSeparator();    if( config_GetInt( p_intf, "wx-playlist-view" ) != 1 )        toolbar->AddTool( Playlist_Event, wxU(LABEL_PLO),                          wxBitmap( playlist_xpm ), wxU(_(HELP_PLO)) );    if( config_GetInt( p_intf, "wx-playlist-view" ) >= 1 )        toolbar->AddTool( PlaylistSmall_Event, wxU(LABEL_SPLO),                          wxBitmap( playlist_small_xpm ), wxU(_(HELP_SPLO)) );    }    wxControl *p_dummy_ctrl =        new wxControl( toolbar, -1, wxDefaultPosition,                       wxSize(16, 16 ), wxBORDER_NONE );    toolbar->AddControl( p_dummy_ctrl );    volctrl = new VLCVolCtrl( p_intf, toolbar );    toolbar->AddControl( volctrl );    toolbar->Realize();#if wxUSE_DRAG_AND_DROP    /* Associate drop targets with the toolbar */    toolbar->SetDropTarget( new DragAndDrop( p_intf ) );#endif}static int ConvertHotkeyModifiers( int i_hotkey ){    int i_accel_flags = 0;    if( i_hotkey & KEY_MODIFIER_ALT ) i_accel_flags |= wxACCEL_ALT;    if( i_hotkey & KEY_MODIFIER_CTRL ) i_accel_flags |= wxACCEL_CTRL;    if( i_hotkey & KEY_MODIFIER_SHIFT ) i_accel_flags |= wxACCEL_SHIFT;    if( !i_accel_flags ) i_accel_flags = wxACCEL_NORMAL;    return i_accel_flags;}static int ConvertHotkey( int i_hotkey ){    int i_key = i_hotkey & ~KEY_MODIFIER;    if( i_key & KEY_ASCII ) return i_key & KEY_ASCII;    else if( i_key & KEY_SPECIAL )    {        switch ( i_key )        {        case KEY_LEFT: return WXK_LEFT;        case KEY_RIGHT: return WXK_RIGHT;        case KEY_UP: return WXK_UP;        case KEY_DOWN: return WXK_DOWN;        case KEY_SPACE: return WXK_SPACE;        case KEY_ENTER: return WXK_RETURN;        case KEY_F1: return WXK_F1;        case KEY_F2: return WXK_F2;        case KEY_F3: return WXK_F3;        case KEY_F4: return WXK_F4;        case KEY_F5: return WXK_F5;        case KEY_F6: return WXK_F6;        case KEY_F7: return WXK_F7;        case KEY_F8: return WXK_F8;        case KEY_F9: return WXK_F9;        case KEY_F10: return WXK_F10;        case KEY_F11: return WXK_F11;        case KEY_F12: return WXK_F12;        case KEY_HOME: return WXK_HOME;        case KEY_END: return WXK_END;        case KEY_INSERT: return WXK_INSERT;        case KEY_DELETE: return WXK_DELETE;        case KEY_MENU: return WXK_MENU;        case KEY_ESC: return WXK_ESCAPE;        case KEY_PAGEUP: return WXK_PRIOR;        case KEY_PAGEDOWN: return WXK_NEXT;        case KEY_TAB: return WXK_TAB;        case KEY_BACKSPACE: return WXK_BACK;        }    }    return WXK_F24;}void Interface::SetupHotkeys(){    struct vlc_t::hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;    int i_hotkeys;    /* Count number of hoteys */    for( i_hotkeys = 0; p_hotkeys[i_hotkeys].psz_action != NULL; i_hotkeys++ );    p_intf->p_sys->i_first_hotkey_event = wxID_HIGHEST + 7000;    p_intf->p_sys->i_hotkeys = i_hotkeys;    wxAcceleratorEntry *p_entries = new wxAcceleratorEntry[i_hotkeys];    /* Setup the hotkeys as accelerators */    for( int i = 0; i < i_hotkeys; i++ )    {        int i_mod = ConvertHotkeyModifiers( p_hotkeys[i].i_key );        int i_key = ConvertHotkey( p_hotkeys[i].i_key );#ifdef WIN32        if( !(p_hotkeys[i].i_key & KEY_SPECIAL) && i_mod )            i_key = toupper(i_key);#endif        p_entries[i].Set( i_mod, i_key,                          p_intf->p_sys->i_first_hotkey_event + i );    }    wxAcceleratorTable accel( i_hotkeys, p_entries );    if( !accel.Ok() )    {        msg_Err( p_intf, "invalid accelerator table" );    }    else    {        SetAcceleratorTable( accel );    }    delete [] p_entries;}void Interface::SetIntfMinSize(){    wxSize ms = main_min_size;    if( extra_frame && extra_frame->IsShown() )    {        ms.SetHeight( ms.GetHeight() + ext_min_size.GetHeight() );        if( ext_min_size.GetWidth() > ms.GetWidth() )            ms.SetWidth( ext_min_size.GetWidth() );    }    SetSizeHints( ms.GetWidth(), ms.GetHeight() );}/***************************************************************************** * Event Handlers. *****************************************************************************/void Interface::OnMenuOpen( wxMenuEvent& event ){#if defined( __WXMSW__ )#   define GetEventObject GetMenu#endif    if( event.GetEventObject() == p_settings_menu )    {        p_settings_menu = SettingsMenu( p_intf, this, p_settings_menu );        /* Add static items */        p_settings_menu->AppendCheckItem( Extended_Event,            wxU(_("Extended &GUI\tCtrl-G") ) );        if( b_extra ) p_settings_menu->Check( Extended_Event, TRUE );        p_settings_menu->Append( Bookmarks_Event,                                 wxU(_("&Bookmarks...\tCtrl-B") ) );        p_settings_menu->Append( Prefs_Event,                                 wxU(_("Preference&s...\tCtrl-S")) );    }    else if( event.GetEventObject() == p_audio_menu )    {        p_audio_menu = AudioMenu( p_intf, this, p_audio_menu );    }    else if( event.GetEventObject() == p_video_menu )    {        p_video_menu = VideoMenu( p_intf, this, p_video_menu );    }    else if( event.GetEventObject() == p_navig_menu )    {        p_navig_menu = NavigMenu( p_intf, this, p_navig_menu );    }#if defined( __WXMSW__ )#   undef GetEventObject#endif}#if defined( __WXMSW__ ) || defined( __WXMAC__ )void Interface::OnContextMenu2(wxContextMenuEvent& event){    /* Only show the context menu for the main interface */    if( GetId() != event.GetId() )    {        event.Skip();        return;    }    if( p_intf->p_sys->pf_show_dialog )        p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );}#endifvoid Interface::OnContextMenu(wxMouseEvent& event){    if( p_intf->p_sys->pf_show_dialog )        p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );}void Interface::OnExit( wxCommandEvent& WXUNUSED(event) ){    /* TRUE is to force the frame to close. */    Close(TRUE);}void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) ){    wxString msg;    msg.Printf( wxString(wxT("VLC media player " PACKAGE_VERSION)) +        wxU(_(" (wxWidgets interface)\n\n")) +        wxU(_("(c) 1996-2006 - the VideoLAN Team\n\n")) +       wxU(_("Compiled by "))+ wxU(VLC_CompileBy())+ wxU("@") +       wxU(VLC_CompileHost())+ wxT(".")+ wxU(VLC_CompileDomain())+ wxT(".\n") +       wxU(_("Compiler: "))+ wxU(VLC_Compiler())+wxT( ".\n") +#ifndef HAVE_SHARED_LIBVLC       wxU(_("Based on SVN revision: "))+wxU(VLC_Changeset())+wxT(".\n\n") +#endif#ifdef __WXMSW__        wxU( vlc_wraptext(LICENSE_MSG,WRAPCOUNT) ) + wxT("\n\n") +#else        wxU( LICENSE_MSG ) + wxT("\n\n") +#endif        wxU(_("The VideoLAN team <videolan@videolan.org>\n"              "http://www.videolan.org/\n\n")) );    wxMessageBox( msg, wxString::Format(wxU(_("About %s")),                  wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );}void Interface::OnShowDialog( wxCommandEvent& event ){    if( p_intf->p_sys->pf_show_dialog )    {        int i_id;        switch( event.GetId() )        {        case OpenFileSimple_Event:            i_id = INTF_DIALOG_FILE_SIMPLE;            break;        case OpenAdv_Event:            i_id = INTF_DIALOG_FILE;            break;        case OpenFile_Event:            i_id = INTF_DIALOG_FILE;            break;        case OpenDir_Event:            i_id = INTF_DIALOG_DIRECTORY;            break;        case OpenDisc_Event:            i_id = INTF_DIALOG_DISC;            break;        case OpenNet_Event:            i_id = INTF_DIALOG_NET;            break;        case OpenCapture_Event:            i_id = INTF_DIALOG_CAPTURE;            break;        case OpenSat_Event:            i_id = INTF_DIALOG_SAT;            break;        case Playlist_Event:            i_id = INTF_DIALOG_PLAYLIST;            break;        case Logs_Event:            i_id = INTF_DIALOG_MESSAGES;            break;        case FileInfo_Event:            i_id = INTF_DIALOG_FILEINFO;            break;        case Prefs_Event:            i_id = INTF_DIALOG_PREFS;            break;        case Wizard_Event:            i_id = INTF_DIALOG_WIZARD;            break;        case Bookmarks_Event:            i_id = INTF_DIALOG_BOOKMARKS;            break;        case UpdateVLC_Event:            i_id = INTF_DIALOG_UPDATEVLC;            break;        case VLM_Event:            i_id = INTF_DIALOG_VLM;            break;        default:            i_id = INTF_DIALOG_FILE;            break;        }        p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -