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

📄 interface.cpp

📁 uclinux 下的vlc播放器源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************** * interface.cpp : wxWidgets plugin for vlc ***************************************************************************** * Copyright (C) 2000-2006 the VideoLAN team * $Id: interface.cpp 16457 2006-08-31 20:51:12Z hartman $ * * Authors: Gildas Bazin <gbazin@videolan.org> * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include "interface.hpp"#include "playlist_manager.hpp"#include "extrapanel.hpp"#include "timer.hpp"#include "video.hpp"#include <vlc_keys.h>#include "charset.h"#include <vlc/aout.h>#include "charset.h"#include <vlc_interaction.h>#include <wx/splitter.h>/* include the toolbar graphics */#include "bitmaps/play.xpm"#include "bitmaps/pause.xpm"#include "bitmaps/stop.xpm"#include "bitmaps/prev.xpm"#include "bitmaps/next.xpm"#include "bitmaps/eject.xpm"#include "bitmaps/slow.xpm"#include "bitmaps/fast.xpm"#include "bitmaps/playlist.xpm"#include "bitmaps/playlist_small.xpm"#include "bitmaps/speaker.xpm"#include "bitmaps/speaker_mute.xpm"#define TOOLBAR_BMP_WIDTH 16#define TOOLBAR_BMP_HEIGHT 16/* include the icon graphic */#include "../../../share/vlc32x32.xpm"/* include a small icon graphic for the systray icon */#ifdef wxHAS_TASK_BAR_ICON#include "../../../share/vlc16x16.xpm"#endif/***************************************************************************** * Local prototypes *****************************************************************************/static int InteractCallback( vlc_object_t *, const char *, vlc_value_t,                             vlc_value_t, void *);/***************************************************************************** * Local class declarations. *****************************************************************************/class wxMenuExt: public wxMenu{public:    /* Constructor */    wxMenuExt( 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 ~wxMenuExt() {};    char *psz_var;    int  i_val_type;    int  i_object_id;    vlc_value_t val;private:};class wxVolCtrl;class VLCVolCtrl : public wxControl{public:    VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent );    virtual ~VLCVolCtrl() {};    virtual void OnPaint( wxPaintEvent &event );    void OnChange( wxMouseEvent& event );    void UpdateVolume();  private:    DECLARE_EVENT_TABLE()    wxVolCtrl *gauge;    int i_y_offset;    vlc_bool_t b_mute;    intf_thread_t *p_intf;};BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)    EVT_PAINT(VLCVolCtrl::OnPaint)    /* Mouse events */    EVT_LEFT_UP(VLCVolCtrl::OnChange)END_EVENT_TABLE()class Splitter : public wxSplitterWindow{public:    Splitter( wxWindow *p_parent, intf_thread_t *_p_intf )      : wxSplitterWindow( p_parent, -1, wxDefaultPosition, wxSize(0,0),#if defined( __WXMSW__ )                          wxCLIP_CHILDREN ),#else                          wxCLIP_CHILDREN | wxSP_3DSASH ),#endif        p_intf(_p_intf), b_video(0), i_delay(0)    {        SetSashSize( 0 );        wxSize size = wxSize(-1, 150);        wxPoint p = wxPoint(0,0);        bool b_dummy;        WindowSettings *ws = p_intf->p_sys->p_window_settings;        ws->GetSettings( WindowSettings::ID_SMALL_PLAYLIST, b_dummy, p, size );        i_width = size.GetWidth();        i_sash_position = size.GetHeight();        b_show_on_start = !!p.x;    }    virtual ~Splitter()    {        WindowSettings *ws = p_intf->p_sys->p_window_settings;        ws->SetSettings( WindowSettings::ID_SMALL_PLAYLIST, true,                         wxPoint(!!GetWindow2(),0),                         wxSize(i_width, i_sash_position) );    };    virtual bool Split( wxWindow* window1, wxWindow* window2 )    {        SetSashSize( 0 );        wxSize size = wxSize( i_width, i_sash_position );        if( window2->GetSizer() ) window2->GetSizer()->SetMinSize( size );        return wxSplitterWindow::SplitHorizontally( window1, window2,                                                    -i_sash_position );    }    virtual bool Unsplit( wxWindow* window )    {        SetSashSize( 0 );        return wxSplitterWindow::Unsplit( window );    }    bool ShowOnStart() { return b_show_on_start; }private:    DECLARE_EVENT_TABLE()    void OnSize( wxSizeEvent &event )    {        /* If we display video, then resize the video window */        if( GetWindow2() &&            p_intf->p_sys->p_video_window && p_intf->p_sys->p_video_sizer &&            p_intf->p_sys->p_video_sizer->GetMinSize() != wxSize(0,0) )        {            if( !b_video ) i_delay = mdate() + 1000000;            b_video = VLC_TRUE;            SetSashSize( -1 );#if defined( __WXMSW__ )            SetSashPosition( event.GetSize().GetHeight() - i_sash_position );#else            SetSashPosition( event.GetSize().GetHeight() -                             i_sash_position - GetSashSize() );#endif        }        else if( GetWindow2() && GetWindow1() && GetWindow1()->GetSizer() )        {            wxSize size = GetWindow1()->GetSizer()->GetMinSize();            if( b_video ) i_delay = mdate() + 1000000;            b_video = VLC_FALSE;            if( event.GetSize().GetHeight() - size.GetHeight() )            {                SetSashSize( 0 );                SetSashPosition( size.GetHeight() ? size.GetHeight() : 1 );                if( i_delay < mdate() )                {                    i_sash_position = event.GetSize().GetHeight() -                        size.GetHeight();                    i_width = event.GetSize().GetWidth();                    size = wxSize( i_width, i_sash_position );                    if( GetWindow2()->GetSizer() )                        GetWindow2()->GetSizer()->SetMinSize( size );                }            }        }        event.Skip();    }    void OnSashPosChanged( wxSplitterEvent &event )    {        if( !GetSize().GetHeight() ){ event.Skip(); return; }        if( i_delay < mdate() )        {            i_sash_position = GetSize().GetHeight() - event.GetSashPosition();            wxSize size = wxSize( i_width, i_sash_position );            if( GetWindow2()->GetSizer() )                GetWindow2()->GetSizer()->SetMinSize( size );        }        event.Skip();    }    intf_thread_t *p_intf;    int i_sash_position;    int i_width;    vlc_bool_t b_video;    mtime_t i_delay;    vlc_bool_t b_show_on_start;};BEGIN_EVENT_TABLE(Splitter, wxSplitterWindow)    EVT_SIZE( Splitter::OnSize )    EVT_SPLITTER_SASH_POS_CHANGED(-1, Splitter::OnSashPosChanged)END_EVENT_TABLE()/***************************************************************************** * Event Table. *****************************************************************************/DEFINE_LOCAL_EVENT_TYPE( wxEVT_INTF );/* IDs for the controls and the menu commands */enum{    /* menu items */    MenuDummy_Event = wxID_HIGHEST + 1000,    Exit_Event = wxID_HIGHEST,    OpenFileSimple_Event,    OpenAdv_Event,    OpenFile_Event,    OpenDir_Event,    OpenDisc_Event,    OpenNet_Event,    OpenCapture_Event,    OpenSat_Event,    OpenOther_Event,    EjectDisc_Event,    Wizard_Event,    Playlist_Event,    PlaylistSmall_Event,    Logs_Event,    FileInfo_Event,    Prefs_Event,    Extended_Event,    Bookmarks_Event,    Skins_Event,    StopStream_Event,    PlayStream_Event,    PrevStream_Event,    NextStream_Event,    SlowStream_Event,    FastStream_Event,    /* it is important for the id corresponding to the "About" command to have     * this standard value as otherwise it won't be handled properly under Mac     * (where it is special and put into the "Apple" menu) */    About_Event = wxID_ABOUT,    UpdateVLC_Event,    VLM_Event,    Iconize_Event,};DEFINE_LOCAL_EVENT_TYPE( wxEVT_INTERACTION );BEGIN_EVENT_TABLE(Interface, wxFrame)    /* Menu events */    EVT_MENU(Exit_Event, Interface::OnExit)    EVT_MENU(About_Event, Interface::OnAbout)    EVT_MENU(UpdateVLC_Event, Interface::OnShowDialog)    EVT_MENU(VLM_Event, Interface::OnShowDialog)    EVT_MENU(Playlist_Event, Interface::OnShowDialog)    EVT_MENU(PlaylistSmall_Event, Interface::OnSmallPlaylist)    EVT_MENU(Logs_Event, Interface::OnShowDialog)    EVT_MENU(FileInfo_Event, Interface::OnShowDialog)    EVT_MENU(Prefs_Event, Interface::OnShowDialog)    EVT_MENU_OPEN(Interface::OnMenuOpen)    EVT_MENU( Extended_Event, Interface::OnExtended )    EVT_MENU( Bookmarks_Event, Interface::OnShowDialog)#if defined( __WXMSW__ ) || defined( __WXMAC__ )    EVT_CONTEXT_MENU(Interface::OnContextMenu2)#endif    EVT_RIGHT_UP(Interface::OnContextMenu)    /* Toolbar events */    EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)    EVT_MENU(OpenAdv_Event, Interface::OnShowDialog)    EVT_MENU(OpenFile_Event, Interface::OnShowDialog)    EVT_MENU(OpenDir_Event, Interface::OnShowDialog)    EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)    EVT_MENU(OpenNet_Event, Interface::OnShowDialog)    EVT_MENU(OpenCapture_Event, Interface::OnShowDialog)    EVT_MENU(OpenSat_Event, Interface::OnShowDialog)    EVT_MENU(Wizard_Event, Interface::OnShowDialog)    EVT_MENU(StopStream_Event, Interface::OnStopStream)    EVT_MENU(PlayStream_Event, Interface::OnPlayStream)    EVT_MENU(PrevStream_Event, Interface::OnPrevStream)    EVT_MENU(NextStream_Event, Interface::OnNextStream)    EVT_MENU(SlowStream_Event, Interface::OnSlowStream)    EVT_MENU(FastStream_Event, Interface::OnFastStream)    /* Custom events */    EVT_COMMAND(0, wxEVT_INTF, Interface::OnControlEvent)    EVT_COMMAND(1, wxEVT_INTF, Interface::OnControlEvent)    EVT_COMMAND( -1, wxEVT_INTERACTION, Interface::OnInteraction )END_EVENT_TABLE()/***************************************************************************** * Constructor. *****************************************************************************/Interface::Interface( intf_thread_t *_p_intf, long style ):    wxFrame( NULL, -1, wxT("VLC media player"),             wxDefaultPosition, wxSize(700,100), style ){    /* Initializations */    p_intf = _p_intf;    b_extra = VLC_FALSE;    extra_frame = 0;    playlist_manager = 0;    i_update_counter = 0;    /* Give our interface a nice little icon */    SetIcon( wxIcon( vlc_xpm ) );    /* Create a splitter window that will fill in the interface window.     * We need a splitter bar in order to make the embedded playlist     * resizable. */    splitter = new Splitter( this, p_intf );    main_sizer = new wxBoxSizer( wxVERTICAL );    main_sizer->Add( splitter, 1, wxEXPAND );    SetSizer( main_sizer );    /* Create a main panel that will fill in the interface window */    main_panel = new wxPanel( splitter, -1, wxPoint(0,0), wxSize(0,0),                              wxCLIP_CHILDREN );    main_panel->SetFocus();#if defined(__WXGTK20__) && wxCHECK_VERSION(2,5,6)    /* As ugly as your butt! Please remove when wxWidgets 2.6 fixed their     * Accelerators bug. */    main_panel->m_imData = 0;    m_imData = 0;#endif    /* Create a sizer for the main frame */    panel_sizer = new wxBoxSizer( wxVERTICAL );    main_panel->SetSizer( panel_sizer );    /* Put this in the splitter */    splitter->Initialize( main_panel );/* wxCocoa pretends to support this, but at least 2.6.x doesn't */#ifndef __APPLE__#ifdef wxHAS_TASK_BAR_ICON    /* Systray integration */    p_systray = NULL;    if( config_GetInt( p_intf, "wx-systray" ) )    {        p_systray = new Systray( this, p_intf );    }#endif#endif    /* Creation of the menu bar */    CreateOurMenuBar();    /* Creation of the tool bar */    CreateOurToolBar();    /* Creation of the status bar     * Helptext for menu items and toolbar tools will automatically get     * displayed here. */    int i_status_width[3] = {100, 40, -1};    statusbar = CreateStatusBar( 3 );                            /* 2 fields */    statusbar->SetStatusWidths( 3, i_status_width );    statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );    /* Get minimum window size to prevent user from glitching it */    splitter->SetSizeHints( -1, 0 );    panel_sizer->Layout(); panel_sizer->Fit( main_panel );    main_sizer->Layout(); main_sizer->Fit( this );    main_min_size = GetSize();    /* FIXME HACK as far as i understan (i.e. not a lot) the toolbar     * doesn't take the labels into account when it returns its size */    if( config_GetInt(p_intf, "wx-labels") )    {        main_min_size.SetWidth(800);    }    splitter->SetSizeHints( -1, -1 );    /* Video window */    video_window = 0;    if( config_GetInt( p_intf, "wx-embed" ) )    {        video_window = CreateVideoWindow( p_intf, main_panel );        panel_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND, 0 );    }    /* Creation of the input manager panel */    input_manager = new InputManager( p_intf, this, main_panel );    panel_sizer->Add( input_manager, 0, wxEXPAND , 0 );    /* Layout everything */    splitter->SetSizeHints( -1, 0 );    panel_sizer->Layout(); panel_sizer->Fit( main_panel );    main_sizer->Layout(); main_sizer->Fit( this );    splitter->SetSizeHints( -1, -1 );#if wxUSE_DRAG_AND_DROP    /* Associate drop targets with the main interface */    SetDropTarget( new DragAndDrop( p_intf ) );#endif    SetupHotkeys();    /* Start timer */    timer = new Timer( p_intf, this );    /* Restore previous position / settings */    WindowSettings *ws = p_intf->p_sys->p_window_settings;    wxPoint p;    wxSize s;    bool b_shown;    ws->SetScreen( wxSystemSettings::GetMetric( wxSYS_SCREEN_X ),                   wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) );    if( ws->GetSettings( WindowSettings::ID_MAIN, b_shown, p, s ) ) Move( p );    /* Show extended GUI if requested */    wxCommandEvent dummy;    if( config_GetInt( p_intf, "wx-extended" ) ) OnExtended( dummy );    SetIntfMinSize();    var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );    var_AddCallback( p_intf, "interaction", InteractCallback, this );    p_intf->b_interaction = VLC_TRUE;    /* Show embedded playlist if requested */    if( splitter->ShowOnStart() ) OnSmallPlaylist( dummy );}Interface::~Interface(){    WindowSettings *ws = p_intf->p_sys->p_window_settings;    if( !IsIconized() )    {        ws->SetSettings( WindowSettings::ID_MAIN, true,                         GetPosition(), GetSize() );    }    PopEventHandler(true);    if( video_window ) delete video_window;/* wxCocoa pretends to support this, but at least 2.6.x doesn't */#ifndef __APPLE__#ifdef wxHAS_TASK_BAR_ICON    if( p_systray ) delete p_systray;

⌨️ 快捷键说明

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