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

📄 preferencespagetts.cpp

📁 Powerful and Portable GPS application -- support Linux, Windows, Windows CE GPS navigation and Map m
💻 CPP
字号:
/* *  Roadnav *  PreferencesPageTTS.cpp * *  Copyright (c) 2004 - 2007 Richard L. Lynch <rllynch@users.sourceforge.net> * *  This program is free software; you can redistribute it and/or *  modify it under the terms of version 2 of the GNU General Public License *  as published by the Free Software Foundation. * *  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 St, Fifth Floor, Boston, MA  02110-1301  USA *////////////////////////////////////////////////////////////////////////////////// \file////// Contains the TTS page of the preferences dialog box./////////////////////////////////////////////////////////////////////////////////#ifdef HAVE_CONFIG_H#  include <config.h>#endif#ifdef _MSC_VER#pragma warning(disable: 4786)#pragma warning(disable: 4800)#endif#include <wx/wx.h>#include "App.h"#include "PreferencesPageTTS.h"#include "TTSFactory.h"using namespace std;enum {	idTTSType,	idTestTTS};//////////////////////////////////////////////////////////////////////////////////// PreferencesPageTTS event table/////////////////////////////////////////////////////////////////////////////////BEGIN_EVENT_TABLE(PreferencesPageTTS, wxPanel)	EVT_BUTTON(idTestTTS, PreferencesPageTTS::OnTestTTS)END_EVENT_TABLE()//////////////////////////////////////////////////////////////////////////////////// \brief PreferencesPageTTS constructor - create controls and initialize them/////////////////////////////////////////////////////////////////////////////////PreferencesPageTTS::PreferencesPageTTS(wxWindow *parent)             : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL){	wxBoxSizer * psizerWnd;	wxFlexGridSizer * psizerGrid;		psizerGrid = new wxFlexGridSizer(2, 5, 10);	//////////////////////////////////////////////////////////////////////////	// TTS Type Label	//////////////////////////////////////////////////////////////////////////	psizerGrid->Add(		new wxStaticText(this, -1, wxT("TTS Type")),		0,		wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,		0	);		//////////////////////////////////////////////////////////////////////////	// TTS Type selection	//////////////////////////////////////////////////////////////////////////	wxArrayString arOptions;	int iTTSType;	wxString strSelTTSType = wxT("None");		m_pctlTTSType = new wxComboBox(this, idTTSType, wxT(""), wxDefaultPosition, wxSize(200, -1), arOptions, wxCB_DROPDOWN | wxCB_READONLY);		for (iTTSType = FIRST_TTSTYPE; iTTSType <= LAST_TTSTYPE; iTTSType++)	{		ETTSType eTTSType = (ETTSType) iTTSType;		ITTS * pcTTS;				pcTTS = ConstructTTS(eTTSType);				if (eTTSType == TTSTypeNone || pcTTS->Name() != wxT("None"))		{			m_pctlTTSType->Append(pcTTS->Name());						if (eTTSType == g_pConfig->Read(wxT("TTSType"), (long) TTSTypeUseAny))				strSelTTSType = pcTTS->Name();		}				delete pcTTS;	}		// add to the sizer	psizerGrid->Add(m_pctlTTSType,				0,				wxGROW,				0	);	m_pctlTTSType->SetValue(strSelTTSType);	//////////////////////////////////////////////////////////////////////////	// Test TTS button	//////////////////////////////////////////////////////////////////////////	psizerGrid->Add(		new wxButton(this, idTestTTS, wxT("Test TTS")),		0,		wxALIGN_RIGHT,		0	);	//////////////////////////////////////////////////////////////////////////	// Test phrase	//////////////////////////////////////////////////////////////////////////	m_pctlTestPhrase = new wxTextCtrl(this, -1, wxT("Test phrase"), wxDefaultPosition, wxSize(250, -1));	psizerGrid->Add(		m_pctlTestPhrase,		0,		wxALIGN_LEFT,		0	);		//////////////////////////////////////////////////////////////////////////	// Verbalize directions label	//////////////////////////////////////////////////////////////////////////	psizerGrid->Add(		new wxStaticText(this, -1, wxT("Verbalize directions")),		0,		wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,		0	);		//////////////////////////////////////////////////////////////////////////	// Verbalize directions check box	//////////////////////////////////////////////////////////////////////////	m_pctlLiveDirectionsTTS = new wxCheckBox(this, -1, wxT(""));	m_pctlLiveDirectionsTTS->SetValue(g_pConfig->Read(wxT("LiveDirectionsTTS"), (long) 1));	psizerGrid->Add(		m_pctlLiveDirectionsTTS, 		0,		wxALIGN_LEFT,		0	);	//////////////////////////////////////////////////////////////////////////	// psizerWnd just adds a border to psizerGrid	//////////////////////////////////////////////////////////////////////////		psizerWnd = new wxBoxSizer(wxVERTICAL);	psizerWnd->Add(		psizerGrid,		0,		wxALL | wxGROW,		10	);		//////////////////////////////////////////////////////////////////////////	// Set up the sizer	//////////////////////////////////////////////////////////////////////////	m_pctlTTSType->SetFocus();	psizerWnd->Fit(this);	SetSizer(psizerWnd);	Layout();	psizerWnd->SetSizeHints(this);	}//////////////////////////////////////////////////////////////////////////////////// \brief Ok was pressed .. save the settings/////////////////////////////////////////////////////////////////////////////////void PreferencesPageTTS::OnOk(wxCommandEvent& event){	g_pConfig->Write(wxT("TTSType"), (long) GetSelectedTTSType());	g_pConfig->Write(wxT("LiveDirectionsTTS"), m_pctlLiveDirectionsTTS->GetValue());}//////////////////////////////////////////////////////////////////////////////////// \brief Retrieves the GPS type selected in the dialog/////////////////////////////////////////////////////////////////////////////////ETTSType PreferencesPageTTS::GetSelectedTTSType(){	int iTTSType;		for (iTTSType = FIRST_TTSTYPE; iTTSType <= LAST_TTSTYPE; iTTSType++)	{		ETTSType eTTSType = (ETTSType) iTTSType;		ITTS * pcTTS;				pcTTS = ConstructTTS(eTTSType);				if (pcTTS->Name() == m_pctlTTSType->GetValue())		{			delete pcTTS;			return eTTSType;		}				delete pcTTS;	}	wxASSERT(0);		return TTSTypeNone;}//////////////////////////////////////////////////////////////////////////////////// \brief Test out selected engine/////////////////////////////////////////////////////////////////////////////////void PreferencesPageTTS::OnTestTTS(wxCommandEvent& event){	ITTS * pcTTS = ConstructTTS(GetSelectedTTSType());		if (pcTTS->Speak(m_pctlTestPhrase->GetValue()) != ITTS::TTSStatusOK)	{		::wxMessageBox(pcTTS->GetLastError(),						wxT("Error"),						wxOK | wxICON_ERROR,						this);	}		delete pcTTS;}

⌨️ 快捷键说明

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