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

📄 options.cpp

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// Options.cpp : implementation file//#include "stdafx.h"#include "Osmo4.h"#include <gpac/options.h>#include <gpac/modules/audio_out.h>#include <gpac/modules/codec.h>#include <gpac/modules/font.h>#include <gpac/constants.h>#include <gpac/iso639.h>#include "Options.h"#include <gx.h>#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// COptions dialogCOptions::COptions(CWnd* pParent /*=NULL*/)	: CDialog(COptions::IDD, pParent){	//{{AFX_DATA_INIT(COptions)	//}}AFX_DATA_INIT	m_bNeedsReload = 0;}void COptions::DoDataExchange(CDataExchange* pDX){	CDialog::DoDataExchange(pDX);	//{{AFX_DATA_MAP(COptions)	DDX_Control(pDX, IDC_COMBOSEL, m_Selection);	//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(COptions, CDialog)	//{{AFX_MSG_MAP(COptions)	ON_BN_CLICKED(IDC_SAVEOPT, OnSaveopt)	ON_CBN_SELCHANGE(IDC_COMBOSEL, OnSelchangeCombosel)	//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// COptions message handlersvoid COptions::OnSelchangeCombosel() {	HideAll();	switch (m_Selection.GetCurSel()) {	case 0: m_general.ShowWindow(SW_SHOW); break;	case 1: m_systems.ShowWindow(SW_SHOW); break;	case 2: m_decoder.ShowWindow(SW_SHOW); break;	case 3: m_render.ShowWindow(SW_SHOW); break;	case 4: m_render3D.ShowWindow(SW_SHOW); break;	case 5: m_audio.ShowWindow(SW_SHOW); break;	case 6: m_font.ShowWindow(SW_SHOW); break;	case 7: m_http.ShowWindow(SW_SHOW); break;	case 8: m_stream.ShowWindow(SW_SHOW); break;	}}void COptions::HideAll(){	m_general.ShowWindow(SW_HIDE);	m_systems.ShowWindow(SW_HIDE);	m_render.ShowWindow(SW_HIDE);	m_render3D.ShowWindow(SW_HIDE);	m_audio.ShowWindow(SW_HIDE);	m_http.ShowWindow(SW_HIDE);	m_font.ShowWindow(SW_HIDE);	m_stream.ShowWindow(SW_HIDE);	m_decoder.ShowWindow(SW_HIDE);}BOOL COptions::OnInitDialog() {	CDialog::OnInitDialog();		m_general.Create(IDD_OPT_GEN, this);	m_systems.Create(IDD_OPT_SYSTEMS, this);	m_decoder.Create(IDD_OPT_DECODER, this);	m_render.Create(IDD_OPT_RENDER, this);	m_render3D.Create(IDD_OPT_RENDER3D, this);	m_audio.Create(IDD_OPT_AUDIO, this);	m_http.Create(IDD_OPT_HTTP, this);	m_font.Create(IDD_OPT_FONT, this);	m_stream.Create(IDD_OPT_STREAM, this);	m_Selection.AddString(_T("General"));	m_Selection.AddString(_T("MPEG-4 Systems"));	m_Selection.AddString(_T("Decoders"));	m_Selection.AddString(_T("Rendering"));	m_Selection.AddString(_T("3D Rendering"));	m_Selection.AddString(_T("Audio"));	m_Selection.AddString(_T("Text"));	m_Selection.AddString(_T("Download"));	m_Selection.AddString(_T("Streaming"));	HideAll();	const char *sOpt = gf_cfg_get_key(GetApp()->m_user.config, "General", "ConfigPanel");	u32 sel = sOpt ? atoi(sOpt) : 0;	if (sel>8) sel=8;	m_Selection.SetCurSel(sel);	OnSelchangeCombosel();	SetFocus();	return TRUE;  }void COptions::OnSaveopt() {	m_general.SaveOptions();	m_systems.SaveOptions();	m_render.SaveOptions();	m_render3D.SaveOptions();	m_audio.SaveOptions();	m_http.SaveOptions();	m_font.SaveOptions();	m_stream.SaveOptions();	m_decoder.SaveOptions();	COsmo4 *gpac = GetApp();	gf_term_set_option(gpac->m_term, GF_OPT_RELOAD_CONFIG, 1);	m_bNeedsReload = m_render3D.m_bNeedsReload;}void COptions::OnOK() {	char str[20];	sprintf(str, "%d", m_Selection.GetCurSel());	gf_cfg_set_key(GetApp()->m_user.config, "General", "ConfigPanel", str);	EndDialog(IDCANCEL);}COptAudio::COptAudio(CWnd* pParent /*=NULL*/)	: CDialog(COptAudio::IDD, pParent){	//{{AFX_DATA_INIT(COptAudio)	//}}AFX_DATA_INIT}void COptAudio::DoDataExchange(CDataExchange* pDX){	CDialog::DoDataExchange(pDX);	//{{AFX_DATA_MAP(COptAudio)	DDX_Control(pDX, IDC_DRIVER_LIST, m_DriverList);	DDX_Control(pDX, IDC_AUDIO_RESYNC, m_AudioResync);	DDX_Control(pDX, IDC_AUDIO_DUR, m_AudioDur);	DDX_Control(pDX, IDC_SPIN_DUR, m_SpinDur);	DDX_Control(pDX, IDC_FORCE_AUDIO, m_ForceConfig);	DDX_Control(pDX, IDC_SPIN_AUDIO, m_AudioSpin);	DDX_Control(pDX, IDC_EDIT_AUDIO, m_AudioEdit);	//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(COptAudio, CDialog)	//{{AFX_MSG_MAP(COptAudio)	ON_BN_CLICKED(IDC_FORCE_AUDIO, OnForceAudio)	//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// COptAudio message handlersBOOL COptAudio::OnInitDialog() {	CDialog::OnInitDialog();	m_AudioSpin.SetBuddy(& m_AudioEdit);	m_SpinDur.SetBuddy(& m_AudioDur);	m_SpinDur.SetRange(0, 1000);	COsmo4 *gpac = GetApp();	const char *sOpt;	TCHAR wTmp[500];	sOpt = gf_cfg_get_key(gpac->m_user.config, "Audio", "ForceConfig");	m_ForceConfig.SetCheck( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0);	sOpt = gf_cfg_get_key(gpac->m_user.config, "Audio", "NumBuffers");	if (sOpt) {		CE_CharToWide((char *)sOpt, wTmp);		m_AudioEdit.SetWindowText(wTmp);	} else {		m_AudioEdit.SetWindowText(_T("2"));	}	sOpt = gf_cfg_get_key(gpac->m_user.config, "Audio", "TotalDuration");	if (sOpt) {		CE_CharToWide((char *)sOpt, wTmp);		m_AudioDur.SetWindowText(wTmp);	} else {		m_AudioDur.SetWindowText(_T("200"));	}	OnForceAudio();	sOpt = gf_cfg_get_key(gpac->m_user.config, "Audio", "NoResync");	if (sOpt && !stricmp(sOpt, "yes")) {		m_AudioResync.SetCheck(1);	} else {		m_AudioResync.SetCheck(0);	}		/*driver enum*/	while (m_DriverList.GetCount()) m_DriverList.DeleteString(0);	sOpt = gf_cfg_get_key(gpac->m_user.config, "Audio", "DriverName");	u32 count = gf_modules_get_count(gpac->m_user.modules);	GF_BaseInterface *ifce;	s32 select = 0;	s32 to_sel = 0;	for (u32 i=0; i<count; i++) {		ifce = gf_modules_load_interface(gpac->m_user.modules, i, GF_AUDIO_OUTPUT_INTERFACE);		if (!ifce) continue;		if (sOpt && !stricmp(((GF_BaseInterface *)ifce)->module_name, sOpt)) select = to_sel;		CE_CharToWide((char *) ((GF_BaseInterface *)ifce)->module_name, wTmp);		m_DriverList.AddString(wTmp);		gf_modules_close_interface(ifce);		to_sel++;	}	m_DriverList.SetCurSel(select);			return TRUE;  }void COptAudio::SaveOptions(){	COsmo4 *gpac = GetApp();	TCHAR wstr[50];	char str[50];	gf_cfg_set_key(gpac->m_user.config, "Audio", "ForceConfig", m_ForceConfig.GetCheck() ? "yes" : "no");	gf_cfg_set_key(gpac->m_user.config, "Audio", "NoResync", m_AudioResync.GetCheck() ? "yes" : "no");	m_AudioEdit.GetWindowText(wstr, 20);	CE_WideToChar(wstr, str);	gf_cfg_set_key(gpac->m_user.config, "Audio", "NumBuffers", str);	m_AudioDur.GetWindowText(wstr, 20);	CE_WideToChar(wstr, str);	gf_cfg_set_key(gpac->m_user.config, "Audio", "TotalDuration", str);	m_DriverList.GetWindowText(wstr, 50);	CE_WideToChar(wstr, str);	gf_cfg_set_key(gpac->m_user.config, "Audio", "DriverName", str);}void COptAudio::OnForceAudio() {	BOOL en = m_ForceConfig.GetCheck();	m_AudioSpin.EnableWindow(en);	m_AudioEdit.EnableWindow(en);	m_SpinDur.EnableWindow(en);	m_AudioDur.EnableWindow(en);}COptDecoder::COptDecoder(CWnd* pParent /*=NULL*/)	: CDialog(COptDecoder::IDD, pParent){	//{{AFX_DATA_INIT(COptDecoder)		// NOTE: the ClassWizard will add member initialization here	//}}AFX_DATA_INIT}void COptDecoder::DoDataExchange(CDataExchange* pDX){	CDialog::DoDataExchange(pDX);	//{{AFX_DATA_MAP(COptDecoder)	DDX_Control(pDX, IDC_VIDEC_LIST, m_Video);	DDX_Control(pDX, IDC_AUDEC_LIST, m_Audio);	//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(COptDecoder, CDialog)	//{{AFX_MSG_MAP(COptDecoder)	//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// COptDecoder message handlersBOOL COptDecoder::OnInitDialog() {	CDialog::OnInitDialog();		COsmo4 *gpac = GetApp();	const char *sOpt;	/*audio dec enum*/	while (m_Audio.GetCount()) m_Audio.DeleteString(0);	sOpt = gf_cfg_get_key(gpac->m_user.config, "Systems", "DefAudioDec");	u32 count = gf_modules_get_count(gpac->m_user.modules);	GF_BaseDecoder *ifce;	s32 select = 0;	s32 to_sel = 0;	for (u32 i=0; i<count; i++) {		ifce = (GF_BaseDecoder *) gf_modules_load_interface(gpac->m_user.modules, i, GF_MEDIA_DECODER_INTERFACE);		if (!ifce) continue;		if (ifce->CanHandleStream(ifce, GF_STREAM_AUDIO, 0, NULL, 0, 0)) {			if (sOpt && !stricmp(((GF_BaseInterface *)ifce)->module_name, sOpt)) select = to_sel;			TCHAR wzTmp[500];			CE_CharToWide((char *) ifce->module_name, wzTmp);			m_Audio.AddString(wzTmp);			to_sel++;		}		gf_modules_close_interface((GF_BaseInterface *) ifce);	}	m_Audio.SetCurSel(select);	/*audio dec enum*/	while (m_Video.GetCount()) m_Video.DeleteString(0);	sOpt = gf_cfg_get_key(gpac->m_user.config, "Systems", "DefVideoDec");	count = gf_modules_get_count(gpac->m_user.modules);	select = 0;	to_sel = 0;	for (i=0; i<count; i++) {		ifce  = (GF_BaseDecoder *) gf_modules_load_interface(gpac->m_user.modules, i, GF_MEDIA_DECODER_INTERFACE);		if (!ifce) continue;		if (ifce->CanHandleStream(ifce, GF_STREAM_VISUAL, 0, NULL, 0, 0)) {			if (sOpt && !stricmp(((GF_BaseInterface *)ifce)->module_name, sOpt)) select = to_sel;			TCHAR wzTmp[500];			CE_CharToWide((char *) ifce->module_name, wzTmp);			m_Video.AddString(wzTmp);			to_sel++;		}		gf_modules_close_interface((GF_BaseInterface *) ifce);	}	m_Video.SetCurSel(select);	return TRUE;}void COptDecoder::SaveOptions(){	COsmo4 *gpac = GetApp();	TCHAR wstr[100];	char str[100];	m_Audio.GetWindowText(wstr, 50);	CE_WideToChar(wstr, str);	gf_cfg_set_key(gpac->m_user.config, "Systems", "DefAudioDec", str);	m_Video.GetWindowText(wstr, 50);	CE_WideToChar(wstr, str);	gf_cfg_set_key(gpac->m_user.config, "Systems", "DefVideoDec", str);}COptFont::COptFont(CWnd* pParent /*=NULL*/)	: CDialog(COptFont::IDD, pParent){	//{{AFX_DATA_INIT(COptFont)	//}}AFX_DATA_INIT}void COptFont::DoDataExchange(CDataExchange* pDX){	CDialog::DoDataExchange(pDX);	//{{AFX_DATA_MAP(COptFont)	DDX_Control(pDX, IDC_USE_TEXTURE, m_UseTexture);	DDX_Control(pDX, IDC_FONT_LIST, m_Fonts);	DDX_Control(pDX, IDC_BROWSE_FONT, m_BrowseFont);	//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(COptFont, CDialog)	//{{AFX_MSG_MAP(COptFont)	ON_BN_CLICKED(IDC_BROWSE_FONT, OnBrowseFont)	//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// COptFont message handlersBOOL COptFont::OnInitDialog() {	u32 i;	GF_BaseInterface *ifce;		CDialog::OnInitDialog();		COsmo4 *gpac = GetApp();	TCHAR wTmp[500];	const char *sOpt;	/*video drivers enum*/	while (m_Fonts.GetCount()) m_Fonts.DeleteString(0);	sOpt = gf_cfg_get_key(gpac->m_user.config, "FontEngine", "DriverName");	s32 to_sel = 0;	s32 select = 0;	u32 count = gf_modules_get_count(gpac->m_user.modules);	for (i=0; i<count; i++) {		ifce = gf_modules_load_interface(gpac->m_user.modules, i, GF_FONT_RASTER_INTERFACE);

⌨️ 快捷键说明

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