summaryrefslogtreecommitdiffabout
path: root/SoundsPage.cpp
blob: ba817366da3b1a41304f2fe15b1c157c79b247c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// SoundsPage.cpp : implementation file
//

#include "stdafx.h"
#include "T42.h"
#include "SoundsPage.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSoundsPage property page

IMPLEMENT_DYNCREATE(CSoundsPage, CPropertyPage)

CSoundsPage::CSoundsPage() : CPropertyPage(CSoundsPage::IDD)
{
	//{{AFX_DATA_INIT(CSoundsPage)
	m_T42Bell = _T("");
	m_T42Prompt = _T("");
	m_bT42PromptLoop = FALSE;
	m_T42Wake = _T("");
	//}}AFX_DATA_INIT
}

CSoundsPage::~CSoundsPage()
{
}

void CSoundsPage::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSoundsPage)
	DDX_Control(pDX, IDC_T42WAKE_PLAY, m_T42WakePlayCtl);
	DDX_Control(pDX, IDC_T42PROMPT_PLAY, m_T42PromptPlayCtl);
	DDX_Control(pDX, IDC_T42BELL_PLAY, m_T42BellPlayCtl);
	DDX_Control(pDX, IDC_T42WAKE_BROWSE, m_T42WakeBrowseCtl);
	DDX_Control(pDX, IDC_T42WAKE, m_T42WakeCtl);
	DDX_Control(pDX, IDC_T42PROMPT_BROWSE, m_T42PromptBrowseCtl);
	DDX_Control(pDX, IDC_T42PROMPT, m_T42PromptCtl);
	DDX_Control(pDX, IDC_T42BELL_BROWSE, m_T42BellBrowseCtl);
	DDX_Control(pDX, IDC_T42BELL, m_T42BellCtl);
	DDX_CBString(pDX, IDC_T42BELL, m_T42Bell);
	DDX_CBString(pDX, IDC_T42PROMPT, m_T42Prompt);
	DDX_Check(pDX, IDC_T42PROMPT_LOOP, m_bT42PromptLoop);
	DDX_CBString(pDX, IDC_T42WAKE, m_T42Wake);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSoundsPage, CPropertyPage)
	//{{AFX_MSG_MAP(CSoundsPage)
	ON_BN_CLICKED(IDC_T42BELL_BROWSE, OnT42bellBrowse)
	ON_BN_CLICKED(IDC_T42PROMPT_BROWSE, OnT42promptBrowse)
	ON_BN_CLICKED(IDC_T42WAKE_BROWSE, OnT42wakeBrowse)
	ON_BN_CLICKED(IDC_T42BELL_PLAY, OnT42bellPlay)
	ON_BN_CLICKED(IDC_T42PROMPT_PLAY, OnT42promptPlay)
	ON_BN_CLICKED(IDC_T42WAKE_PLAY, OnT42wakePlay)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSoundsPage message handlers

BOOL CSoundsPage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
CT42App* app = (CT42App*)AfxGetApp();
	ASSERT(app);
	m_T42BellCtl.ResetContent();
	m_T42BellCtl.AddString(app->m_sndTeaDrop);
	m_T42PromptCtl.ResetContent();
	m_T42PromptCtl.AddString(app->m_sndBoilingTeapot);
	m_T42WakeCtl.ResetContent();
	m_T42WakeCtl.AddString(app->m_sndTeapotWhistle);

HICON i = app->LoadIcon(IDI_BROWSE);
	m_T42BellBrowseCtl.SetIcon(i);
	m_T42PromptBrowseCtl.SetIcon(i);
	m_T42WakeBrowseCtl.SetIcon(i);
	i = app->LoadIcon(IDI_PREPLAY);
	m_T42BellPlayCtl.SetIcon(i);
	m_T42PromptPlayCtl.SetIcon(i);
	m_T42WakePlayCtl.SetIcon(i);

	UpdateData(FALSE);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSoundsPage::OnT42bellBrowse() 
{
	BrowseForSound(m_T42BellCtl);
}

void CSoundsPage::OnT42promptBrowse() 
{
	BrowseForSound(m_T42PromptCtl);
}

void CSoundsPage::OnT42wakeBrowse() 
{
	BrowseForSound(m_T42WakeCtl);
}

void CSoundsPage::BrowseForSound(CComboBox& ctl)
{
CString f;
	ctl.GetWindowText(f);
CString filter;
	filter.LoadString(IDS_FILTER_WAV);
CFileDialog fd(TRUE,NULL,(LPCTSTR)f,
			   OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY
			   |OFN_LONGNAMES|OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST,
			   filter,this);
CString title;
	title.LoadString(IDS_TITLE_WAV);
	fd.m_ofn.lpstrTitle=(LPCTSTR)title;
	if(fd.DoModal()==IDOK)
		ctl.SetWindowText(fd.GetPathName());
}

void CSoundsPage::OnT42bellPlay() 
{
	PlayIt(m_T42BellCtl);
}
void CSoundsPage::OnT42promptPlay() 
{
	PlayIt(m_T42PromptCtl);
}
void CSoundsPage::OnT42wakePlay() 
{
	PlayIt(m_T42WakeCtl);
}

void CSoundsPage::PlayIt(CComboBox& ctl,BOOL bLoop)
{
CString s;
	ctl.GetWindowText(s);
CT42App* app = (CT42App*)AfxGetApp();
	ASSERT(app);
	app->StartSound(s,bLoop);
}