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

📄 vlm_panel.cpp

📁 uclinux 下的vlc播放器源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** * vlm_panel.cpp: VLM Panel ***************************************************************************** * Copyright (C) 2000-2005 the VideoLAN team * $Id: vlm_panel.cpp 17953 2006-11-22 14:24:13Z md $ * * Authors: Clément Stenac <zorglub@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. *****************************************************************************/#include "dialogs/vlm/vlm_panel.hpp"#include "dialogs/vlm/vlm_wrapper.hpp"#include "dialogs/vlm/vlm_stream.hpp"#include "dialogs/vlm/vlm_streampanel.hpp"#include <wx/statline.h>#include "charset.h"enum{    Notebook_Event,    Timer_Event,    Load_Event,};BEGIN_EVENT_TABLE( VLMPanel, wxPanel)   EVT_TIMER( Timer_Event, VLMPanel::OnTimer )   EVT_BUTTON( wxID_CLOSE, VLMPanel::OnClose )   EVT_BUTTON( Load_Event, VLMPanel::OnLoad )   EVT_BUTTON( wxID_SAVE, VLMPanel::OnSave )END_EVENT_TABLE()VLMPanel::VLMPanel( intf_thread_t *_p_intf, wxWindow *_p_parent ) :        wxPanel( _p_parent, -1, wxDefaultPosition, wxDefaultSize ),       timer( this, Timer_Event ){    p_intf = _p_intf;    p_parent = _p_parent;    p_vlm = new VLMWrapper( p_intf );    p_vlm->AttachVLM();    SetAutoLayout( TRUE );    wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );    p_notebook = new wxNotebook( this, Notebook_Event );#if (!wxCHECK_VERSION(2,5,0))    wxNotebookSizer *notebook_sizer = new wxNotebookSizer( p_notebook );#endif    p_notebook->AddPage( BroadcastPanel( p_notebook ), wxU( _("Broadcasts") ) );#if 0    p_notebook->AddPage( VODPanel( p_notebook ), wxU( _("VOD") ) );#endif#if (!wxCHECK_VERSION(2,5,0))    panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );#else    panel_sizer->Add( p_notebook, 1 , wxEXPAND | wxALL, 5 );#endif    wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );    button_sizer->Add( new wxButton( this, wxID_CLOSE, wxU(_("&Close") ) ) );    button_sizer->Add( 0, 0, 1 );    button_sizer->Add( new wxButton( this, Load_Event, wxU(_("Load") ) ), 0, wxRIGHT, 10 );    button_sizer->Add( new wxButton( this, wxID_SAVE, wxU(_("&Save") ) ) );    panel_sizer->Add( button_sizer, 0 , wxEXPAND | wxALL, 5 );    panel_sizer->Layout();    SetSizerAndFit( panel_sizer );    Update();    timer.Start( 300 );}VLMPanel::~VLMPanel(){    delete p_vlm;}void VLMPanel::OnTimer( wxTimerEvent& event ){    Update();}void VLMPanel::Update(){    unsigned int i;    for( i = 0 ; i < broadcasts.size(); i++ )    {        ((VLMBroadcastStreamPanel *)broadcasts[i])->b_found = VLC_FALSE;    }    for( i = 0 ; i < vods.size(); i++ )    {        ((VLMVODStreamPanel *)vods[i])->b_found = VLC_FALSE;    }    p_vlm->LockVLM();    /* Iterate over the media, to find the panels to add / remove */    /* FIXME: This code should be better wrapped */    for( i = 0; i < p_vlm->NbMedia(); i++ )    {        vlm_media_t *p_media = p_vlm->GetMedia( i );        if( p_media->i_type == BROADCAST_TYPE )        {            vlc_bool_t b_foundthis = VLC_FALSE;            for( unsigned int j = 0 ; j < broadcasts.size(); j++ )            {                VLMBroadcastStreamPanel *p_streamp =                       (VLMBroadcastStreamPanel *)(broadcasts[j]);                /* FIXME: dangerous .. */                if( p_streamp->GetStream()->p_media ==  p_media )                {                    p_streamp->b_found = VLC_TRUE;                    b_foundthis = VLC_TRUE;                    break;                }            }            /* Create the stream */            if( !b_foundthis )            {                VLMBroadcastStream *p_broadcast =                        new VLMBroadcastStream( p_intf, p_media, p_vlm );                AppendBroadcast( p_broadcast );            }        }        else if( p_media->i_type == VOD_TYPE )        {            vlc_bool_t b_foundthis = VLC_FALSE;            for( unsigned int j = 0 ; i < vods.size(); i++ )            {                VLMVODStreamPanel *p_streamp = (VLMVODStreamPanel *)( vods[j] );                if(  p_streamp->GetStream()->p_media ==  p_media )                {                    p_streamp->b_found = VLC_TRUE;                    b_foundthis = VLC_TRUE;                    break;                }            }            /* Create it */            if( !b_foundthis )            {                VLMVODStream *p_vod = new VLMVODStream(p_intf, p_media, p_vlm );                AppendVOD( p_vod );            }        }    }    /* Those not marked as found must be removed */    vector<VLMBroadcastStreamPanel *>::iterator it = broadcasts.begin();    while( it < broadcasts.end() )    {        if( (*it)->b_found == VLC_FALSE )        {            vector<VLMBroadcastStreamPanel *>::iterator rem = it;            it++;            VLMBroadcastStreamPanel *p_remove = *rem;            broadcasts.erase( rem );            RemoveBroadcast( p_remove );            delete p_remove;        }        else            it++;    }    vector<VLMVODStreamPanel *>::iterator it2 = vods.begin();    while( it2 < vods.end() )    {        if( (*it2)->b_found == VLC_FALSE )        {            vector<VLMVODStreamPanel *>::iterator rem = it2;            it2++;            VLMVODStreamPanel *p_remove = *rem;            vods.erase( rem );            RemoveVOD( p_remove );            delete p_remove;        }        else            it2++;    }    /* Update sliders*/    for( unsigned int j = 0 ; j < broadcasts.size(); j++ )    {        VLMBroadcastStreamPanel *p_streamp =                (VLMBroadcastStreamPanel *)( broadcasts[j] );        p_streamp->Update();    }    p_vlm->UnlockVLM();}void VLMPanel::OnClose( wxCommandEvent &event ){    ((VLMFrame*)p_parent)->OnClose( *( new wxCloseEvent() ) );}void VLMPanel::OnLoad( wxCommandEvent &event ){    p_file_dialog = new wxFileDialog( NULL, wxT(""), wxT(""), wxT(""),                                      wxT("*"), wxOPEN | wxMULTIPLE );    if( p_file_dialog == NULL ) return;    p_file_dialog->SetTitle( wxU(_("Load Configuration") ) );    if( p_file_dialog->ShowModal() == wxID_OK )    {        vlm_Load( p_vlm->GetVLM(), p_file_dialog->GetPath().mb_str(wxConvUTF8));    }    Update();}void VLMPanel::OnSave( wxCommandEvent &event ){    p_file_dialog = new wxFileDialog( NULL, wxT(""), wxT(""), wxT(""),                                      wxT("*"), wxSAVE | wxOVERWRITE_PROMPT );    if( p_file_dialog == NULL ) return;    p_file_dialog->SetTitle( wxU(_("Save Configuration") ) );    if( p_file_dialog->ShowModal() == wxID_OK )    {        vlm_Save( p_vlm->GetVLM(), p_file_dialog->GetPath().mb_str(wxConvUTF8));    }}/************************* * Broadcasts management *************************/wxPanel * VLMPanel::BroadcastPanel( wxWindow *parent ){     broadcasts_panel = new wxPanel( parent, -1, wxDefaultPosition, wxSize( 500, 350 ) );     broadcasts_sizer = new wxBoxSizer( wxVERTICAL );     wxStaticBox *add_box = new wxStaticBox( broadcasts_panel, -1,                                            wxU( _( "New broadcast") ) );     wxStaticBoxSizer *box_sizer = new wxStaticBoxSizer( add_box, wxHORIZONTAL );     box_sizer->Add( AddBroadcastPanel( broadcasts_panel), 0, wxEXPAND|wxALL, 5 );     box_sizer->Layout();     broadcasts_sizer->Add( box_sizer, 0, wxEXPAND|wxALL, 5 );     wxStaticLine *static_line = new wxStaticLine( broadcasts_panel, wxID_ANY );     broadcasts_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );     scrolled_broadcasts = new wxScrolledWindow( broadcasts_panel, -1,                                wxDefaultPosition, wxDefaultSize,                                wxBORDER_NONE | wxVSCROLL );     scrolled_broadcasts_sizer = new wxBoxSizer( wxVERTICAL );     scrolled_broadcasts->SetAutoLayout( TRUE );     scrolled_broadcasts->SetScrollRate( 5,5 );     scrolled_broadcasts->SetSizerAndFit( scrolled_broadcasts_sizer );     broadcasts_sizer->Add( scrolled_broadcasts, 1, wxEXPAND| wxALL, 5 );     broadcasts_sizer->Layout();     broadcasts_panel->SetSizerAndFit( broadcasts_sizer );     return broadcasts_panel;}wxPanel * VLMPanel::AddBroadcastPanel( wxPanel *panel ){     return new VLMAddStreamPanel( p_intf, panel, p_vlm, VLC_FALSE,                                   VLC_TRUE );}void VLMPanel::AppendBroadcast( VLMBroadcastStream *p_broadcast ){    VLMBroadcastStreamPanel *p_new =                   new VLMBroadcastStreamPanel( p_intf, scrolled_broadcasts,                                                p_broadcast );    p_new->b_found = VLC_TRUE;    scrolled_broadcasts_sizer->Add( p_new, 0, wxEXPAND | wxALL, 5 );    scrolled_broadcasts_sizer->Layout();    scrolled_broadcasts->FitInside();    broadcasts.push_back( p_new );}

⌨️ 快捷键说明

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