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

📄 wxosmo4.cpp

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* *			GPAC - Multimedia Framework C SDK * *			Copyright (c) Jean Le Feuvre 2000-2005 *					All rights reserved * *  This file is part of GPAC / Osmo4 wxWidgets GUI * *  GPAC is free software; you can redistribute it and/or modify *  it under the terms of the GNU Lesser General Public License as published by *  the Free Software Foundation; either version 2, or (at your option) *  any later version. *    *  GPAC 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 Lesser General Public License for more details. *    *  You should have received a copy of the GNU Lesser General Public *  License along with this library; see the file COPYING.  If not, write to *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  * *		 */#include "wxOsmo4.h"#include "wxGPACControl.h"#include "fileprops.h"#include "wx/image.h"#include <gpac/modules/service.h>#include <gpac/network.h>#include <gpac/constants.h>#include <gpac/options.h>IMPLEMENT_APP(wxOsmo4App)#include "osmo4.xpm"#include <wx/dnd.h>#include <wx/filename.h>#include "toolbar.xpm"#include "Playlist.h"#ifdef WIN32#define	FRAME_H	140#else#define	FRAME_H	110#endifwxString get_pref_browser(GF_Config *cfg){	const char *sOpt = gf_cfg_get_key(cfg, "General", "Browser");	if (sOpt) return wxString(sOpt, wxConvUTF8);#ifdef __WXMAC__	return wxT("safari");#else#ifdef WIN32	return wxT("explorer.exe");#else	return wxT("mozilla");#endif#endif}IMPLEMENT_DYNAMIC_CLASS(wxGPACEvent, wxEvent )wxGPACEvent::wxGPACEvent(wxWindow* win){    SetEventType(GPAC_EVENT);    SetEventObject(win);	gpac_evt.type = 0;	to_url = wxT("");}wxEvent *wxGPACEvent::Clone() const{	wxGPACEvent *evt = new wxGPACEvent((wxWindow *) m_eventObject);	evt->to_url = to_url;	evt->gpac_evt = gpac_evt;	return evt;}/*open file dlg*/BEGIN_EVENT_TABLE(OpenURLDlg, wxDialog)    EVT_BUTTON(ID_URL_GO, OpenURLDlg::OnGo)END_EVENT_TABLE()OpenURLDlg::OpenURLDlg(wxWindow *parent, GF_Config *cfg)             : wxDialog(parent, -1, wxString(wxT("Enter remote presentation location"))){#ifndef WIN32	SetSize(430, 35);#else	SetSize(430, 55);#endif	Centre();    m_url = new wxComboBox(this, -1, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN);	m_url->SetSize(0, 2, 340, 18, wxSIZE_AUTO);    m_go = new wxButton(this, ID_URL_GO, wxT("Go !"));#ifndef WIN32	m_go->SetSize(344, 2, 20, 18, wxSIZE_AUTO);#else	m_go->SetSize(364, 2, 30, 18, wxSIZE_AUTO);#endif	m_urlVal = wxT("");	m_cfg = cfg;	const char *sOpt;	u32 i=0;	while (1) {		sOpt = gf_cfg_get_key_name(m_cfg, "RecentFiles", i);		if (!sOpt) break;		m_url->Append(wxString(sOpt, wxConvUTF8) );		i++;	}}#define MAX_LAST_FILES		20void UpdateLastFiles(GF_Config *cfg, const char *URL){	u32 nb_entries;	gf_cfg_set_key(cfg, "RecentFiles", URL, NULL);	gf_cfg_insert_key(cfg, "RecentFiles", URL, "", 0);	/*remove last entry if needed*/	nb_entries = gf_cfg_get_key_count(cfg, "RecentFiles");	if (nb_entries>MAX_LAST_FILES) {		gf_cfg_set_key(cfg, "RecentFiles", gf_cfg_get_key_name(cfg, "RecentFiles", nb_entries-1), NULL);	}}void OpenURLDlg::OnGo(wxCommandEvent& event){	m_urlVal = m_url->GetValue();	UpdateLastFiles(m_cfg, m_urlVal.mb_str(wxConvUTF8));	EndModal(wxID_OK);}/*end open file dlg*/#ifdef WIN32u32 get_sys_col(int idx){	u32 res;	DWORD val = GetSysColor(idx);	res = (val)&0xFF; res<<=8;	res |= (val>>8)&0xFF; res<<=8;	res |= (val>>16)&0xFF;	return res;}#endifstatic void wxOsmo4_progress_cbk(void *usr, char *title, u32 done, u32 total){	if (!total) return;	wxOsmo4Frame *app = (wxOsmo4Frame *)usr;	s32 prog = (s32) ( (100 * (u64)done) / total);	if (app->m_last_prog < prog) {		app->m_last_prog = prog;		if (prog<100) {			/*appears to crash wxWidgets / X11 when refreshing the text too often*/			if (app->m_LastStatusTime + 200 > gf_sys_clock()) return;			char msg[1024];			sprintf(msg, "%s %02d %%)", title, prog);			//app->SetStatus(wxString(msg, wxConvUTF8));		} else {			app->SetStatus(wxT("Ready"));			app->m_last_prog = -1;		}	}}Bool GPAC_EventProc(void *ptr, GF_Event *evt){	wxCommandEvent event;	wxOsmo4Frame *app = (wxOsmo4Frame *)ptr;	switch (evt->type) {	case GF_EVENT_DURATION:		app->m_duration = (u32) (evt->duration.duration*1000);		app->m_can_seek = evt->duration.can_seek;		if (app->m_duration<1100) app->m_can_seek = 0;		app->m_pProg->Enable(app->m_can_seek ? 1 : 0);		app->m_pPlayList->SetDuration((u32) evt->duration.duration);		break;	case GF_EVENT_MESSAGE:	{		const char *servName;		if (!evt->message.service || !strcmp(evt->message.service, app->m_pPlayList->GetURL().mb_str(wxConvUTF8))) {			servName = "main service";		} else {			servName = evt->message.service;		}		if (!evt->message.message) return 0;		if (evt->message.error) {			app->SetStatus(wxString(evt->message.message, wxConvUTF8) + wxT(" (") + wxString(servName, wxConvUTF8) + wxT(")") );			if (!app->m_connected) app->m_pPlayList->SetDead();		}		else if (!app->m_console_off) {			if (strstr(evt->message.message, "100 %")) {				app->SetStatus(wxT(""));			} else {				app->SetStatus(wxString(evt->message.message, wxConvUTF8) );			}		}		/*log*/		if (evt->message.error) 			::wxLogMessage(wxString(evt->message.message, wxConvUTF8) + wxT(" (") + wxString(servName, wxConvUTF8) + wxT(") ") + wxString(gf_error_to_string(evt->message.error), wxConvUTF8) );		else			::wxLogMessage(wxString(evt->message.message, wxConvUTF8) + wxT(" (") + wxString(servName, wxConvUTF8) + wxT(")"));	}		break;	case GF_EVENT_PROGRESS:	{		char *sTitle;		if (evt->progress.progress_type==0) sTitle = "Buffer";		else if (evt->progress.progress_type==1) sTitle = "Download";		else if (evt->progress.progress_type==2) sTitle = "Import";		gf_set_progress(sTitle, evt->progress.done, evt->progress.total);	}		break;		case GF_EVENT_KEYDOWN:		if (app->m_can_seek && (evt->key.flags & GF_KEY_MOD_ALT)) {			s32 res;			switch (evt->key.key_code) {			case GF_KEY_LEFT:				res = gf_term_get_time_in_ms(app->m_term) - 5*app->m_duration/100;				if (res<0) res=0;				gf_term_play_from_time(app->m_term, res, 0);				break;			case GF_KEY_RIGHT:				res = gf_term_get_time_in_ms(app->m_term) + 5*app->m_duration/100;				if ((u32) res>=app->m_duration) res = 0;				gf_term_play_from_time(app->m_term, res, 0);				break;			case GF_KEY_DOWN:				res = gf_term_get_time_in_ms(app->m_term) - 60000;				if (res<0) res=0;				gf_term_play_from_time(app->m_term, res, 0);				break;			case GF_KEY_UP:				res = gf_term_get_time_in_ms(app->m_term) + 60000;				if ((u32) res>=app->m_duration) res = 0;				gf_term_play_from_time(app->m_term, res, 0);				break;			}		} else if (evt->key.flags & GF_KEY_MOD_CTRL) {			switch (evt->key.key_code) {			case GF_KEY_LEFT:				app->m_pPlayList->PlayPrev();				break;			case GF_KEY_RIGHT:				app->m_pPlayList->PlayNext();				break;			}		} else {			switch (evt->key.key_code) {			case GF_KEY_HOME:				gf_term_set_option(app->m_term, GF_OPT_NAVIGATION_TYPE, 1);				break;			case GF_KEY_ESCAPE:				if (gf_term_get_option(app->m_term, GF_OPT_FULLSCREEN)) 					gf_term_set_option(app->m_term, GF_OPT_FULLSCREEN, 0);				break;			default:			{				wxGPACEvent wxevt(app);				wxevt.gpac_evt = *evt;				app->AddPendingEvent(wxevt);			}				break;			}		}		break;	case GF_EVENT_CONNECT:	{		wxGPACEvent wxevt(app);		wxevt.gpac_evt.type = GF_EVENT_CONNECT;		wxevt.gpac_evt.connect.is_connected = evt->connect.is_connected;		if (!evt->connect.is_connected) app->m_duration = 0;		app->AddPendingEvent(wxevt);	}		break;	case GF_EVENT_NAVIGATE:	{		wxGPACEvent wxevt(app);		wxevt.to_url = wxString(evt->navigate.to_url, wxConvUTF8);		wxevt.gpac_evt.type = evt->type;		app->AddPendingEvent(wxevt);	}		return 1;	case GF_EVENT_QUIT:	case GF_EVENT_VIEWPOINTS:	case GF_EVENT_STREAMLIST:	case GF_EVENT_SCENE_SIZE://	case GF_EVENT_SIZE:	{		wxGPACEvent wxevt(app);		wxevt.gpac_evt = *evt;		app->AddPendingEvent(wxevt);	}		break;	case GF_EVENT_MOUSEDOUBLECLICK:		gf_term_set_option(app->m_term, GF_OPT_FULLSCREEN, !gf_term_get_option(app->m_term, GF_OPT_FULLSCREEN));		return 0;	case GF_EVENT_MOUSEDOWN:		if (!gf_term_get_option(app->m_term, GF_OPT_FULLSCREEN)) {#ifdef __WXGTK__		  app->m_pVisual->SetFocus();#else		  app->m_pView->SetFocus();#endif		}		break;	case GF_EVENT_SYS_COLORS:#ifdef WIN32		evt->sys_cols.sys_colors[0] = get_sys_col(COLOR_ACTIVEBORDER);		evt->sys_cols.sys_colors[1] = get_sys_col(COLOR_ACTIVECAPTION);		evt->sys_cols.sys_colors[2] = get_sys_col(COLOR_APPWORKSPACE);		evt->sys_cols.sys_colors[3] = get_sys_col(COLOR_BACKGROUND);		evt->sys_cols.sys_colors[4] = get_sys_col(COLOR_BTNFACE);		evt->sys_cols.sys_colors[5] = get_sys_col(COLOR_BTNHIGHLIGHT);		evt->sys_cols.sys_colors[6] = get_sys_col(COLOR_BTNSHADOW);		evt->sys_cols.sys_colors[7] = get_sys_col(COLOR_BTNTEXT);		evt->sys_cols.sys_colors[8] = get_sys_col(COLOR_CAPTIONTEXT);		evt->sys_cols.sys_colors[9] = get_sys_col(COLOR_GRAYTEXT);		evt->sys_cols.sys_colors[10] = get_sys_col(COLOR_HIGHLIGHT);		evt->sys_cols.sys_colors[11] = get_sys_col(COLOR_HIGHLIGHTTEXT);		evt->sys_cols.sys_colors[12] = get_sys_col(COLOR_INACTIVEBORDER);		evt->sys_cols.sys_colors[13] = get_sys_col(COLOR_INACTIVECAPTION);		evt->sys_cols.sys_colors[14] = get_sys_col(COLOR_INACTIVECAPTIONTEXT);		evt->sys_cols.sys_colors[15] = get_sys_col(COLOR_INFOBK);		evt->sys_cols.sys_colors[16] = get_sys_col(COLOR_INFOTEXT);		evt->sys_cols.sys_colors[17] = get_sys_col(COLOR_MENU);		evt->sys_cols.sys_colors[18] = get_sys_col(COLOR_MENUTEXT);		evt->sys_cols.sys_colors[19] = get_sys_col(COLOR_SCROLLBAR);		evt->sys_cols.sys_colors[20] = get_sys_col(COLOR_3DDKSHADOW);		evt->sys_cols.sys_colors[21] = get_sys_col(COLOR_3DFACE);		evt->sys_cols.sys_colors[22] = get_sys_col(COLOR_3DHIGHLIGHT);		evt->sys_cols.sys_colors[23] = get_sys_col(COLOR_3DLIGHT);		evt->sys_cols.sys_colors[24] = get_sys_col(COLOR_3DSHADOW);		evt->sys_cols.sys_colors[25] = get_sys_col(COLOR_WINDOW);		evt->sys_cols.sys_colors[26] = get_sys_col(COLOR_WINDOWFRAME);		evt->sys_cols.sys_colors[27] = get_sys_col(COLOR_WINDOWTEXT);		return 1;#else		memset(evt->sys_cols.sys_colors, 0, sizeof(u32)*28);		return 1;#endif	}	return 0;}bool wxOsmo4App::OnInit(){#ifdef __WXGTK__	XSynchronize((Display *) wxGetDisplay(), 1);#endif	wxFrame *frame = new wxOsmo4Frame();	frame->Show(TRUE);	SetTopWindow(frame);	return true;	}class myDropfiles : public wxFileDropTarget{public:	myDropfiles() : wxFileDropTarget() {}	virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);	wxOsmo4Frame *m_pMain;};bool myDropfiles::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames){	u32 count = filenames.GetCount();	if (count==1) {		char *ext = strrchr(filenames.Item(0).mb_str(wxConvUTF8) , '.');		/*if playing and sub d&d, open sub in current presentation*/		if (m_pMain->m_connected && ext && ( !stricmp(ext, ".srt") || !stricmp(ext, ".sub") || !stricmp(ext, ".ttxt") || !stricmp(ext, ".xml") ) ) {			m_pMain->AddSubtitle(filenames.Item(0).mb_str(wxConvUTF8) , 1);			return TRUE;		}	}	for (u32 i=0; i<count; i++) 		m_pMain->m_pPlayList->QueueURL(filenames.Item(i));	m_pMain->m_pPlayList->RefreshList();	m_pMain->m_pPlayList->PlayNext();	return TRUE;}bool GPACLogs::OnFrameClose(wxFrame *frame){	Show(FALSE);

⌨️ 快捷键说明

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