summaryrefslogtreecommitdiffabout
path: root/SoundsPage.cpp
Unidiff
Diffstat (limited to 'SoundsPage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--SoundsPage.cpp148
1 files changed, 148 insertions, 0 deletions
diff --git a/SoundsPage.cpp b/SoundsPage.cpp
new file mode 100644
index 0000000..ba81736
--- a/dev/null
+++ b/SoundsPage.cpp
@@ -0,0 +1,148 @@
1// SoundsPage.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "T42.h"
6#include "SoundsPage.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// CSoundsPage property page
16
17IMPLEMENT_DYNCREATE(CSoundsPage, CPropertyPage)
18
19CSoundsPage::CSoundsPage() : CPropertyPage(CSoundsPage::IDD)
20{
21 //{{AFX_DATA_INIT(CSoundsPage)
22 m_T42Bell = _T("");
23 m_T42Prompt = _T("");
24 m_bT42PromptLoop = FALSE;
25 m_T42Wake = _T("");
26 //}}AFX_DATA_INIT
27}
28
29CSoundsPage::~CSoundsPage()
30{
31}
32
33void CSoundsPage::DoDataExchange(CDataExchange* pDX)
34{
35 CPropertyPage::DoDataExchange(pDX);
36 //{{AFX_DATA_MAP(CSoundsPage)
37 DDX_Control(pDX, IDC_T42WAKE_PLAY, m_T42WakePlayCtl);
38 DDX_Control(pDX, IDC_T42PROMPT_PLAY, m_T42PromptPlayCtl);
39 DDX_Control(pDX, IDC_T42BELL_PLAY, m_T42BellPlayCtl);
40 DDX_Control(pDX, IDC_T42WAKE_BROWSE, m_T42WakeBrowseCtl);
41 DDX_Control(pDX, IDC_T42WAKE, m_T42WakeCtl);
42 DDX_Control(pDX, IDC_T42PROMPT_BROWSE, m_T42PromptBrowseCtl);
43 DDX_Control(pDX, IDC_T42PROMPT, m_T42PromptCtl);
44 DDX_Control(pDX, IDC_T42BELL_BROWSE, m_T42BellBrowseCtl);
45 DDX_Control(pDX, IDC_T42BELL, m_T42BellCtl);
46 DDX_CBString(pDX, IDC_T42BELL, m_T42Bell);
47 DDX_CBString(pDX, IDC_T42PROMPT, m_T42Prompt);
48 DDX_Check(pDX, IDC_T42PROMPT_LOOP, m_bT42PromptLoop);
49 DDX_CBString(pDX, IDC_T42WAKE, m_T42Wake);
50 //}}AFX_DATA_MAP
51}
52
53
54BEGIN_MESSAGE_MAP(CSoundsPage, CPropertyPage)
55 //{{AFX_MSG_MAP(CSoundsPage)
56 ON_BN_CLICKED(IDC_T42BELL_BROWSE, OnT42bellBrowse)
57 ON_BN_CLICKED(IDC_T42PROMPT_BROWSE, OnT42promptBrowse)
58 ON_BN_CLICKED(IDC_T42WAKE_BROWSE, OnT42wakeBrowse)
59 ON_BN_CLICKED(IDC_T42BELL_PLAY, OnT42bellPlay)
60 ON_BN_CLICKED(IDC_T42PROMPT_PLAY, OnT42promptPlay)
61 ON_BN_CLICKED(IDC_T42WAKE_PLAY, OnT42wakePlay)
62 //}}AFX_MSG_MAP
63END_MESSAGE_MAP()
64
65/////////////////////////////////////////////////////////////////////////////
66// CSoundsPage message handlers
67
68BOOL CSoundsPage::OnInitDialog()
69{
70 CPropertyPage::OnInitDialog();
71
72CT42App* app = (CT42App*)AfxGetApp();
73 ASSERT(app);
74 m_T42BellCtl.ResetContent();
75 m_T42BellCtl.AddString(app->m_sndTeaDrop);
76 m_T42PromptCtl.ResetContent();
77 m_T42PromptCtl.AddString(app->m_sndBoilingTeapot);
78 m_T42WakeCtl.ResetContent();
79 m_T42WakeCtl.AddString(app->m_sndTeapotWhistle);
80
81HICON i = app->LoadIcon(IDI_BROWSE);
82 m_T42BellBrowseCtl.SetIcon(i);
83 m_T42PromptBrowseCtl.SetIcon(i);
84 m_T42WakeBrowseCtl.SetIcon(i);
85 i = app->LoadIcon(IDI_PREPLAY);
86 m_T42BellPlayCtl.SetIcon(i);
87 m_T42PromptPlayCtl.SetIcon(i);
88 m_T42WakePlayCtl.SetIcon(i);
89
90 UpdateData(FALSE);
91
92 return TRUE; // return TRUE unless you set the focus to a control
93 // EXCEPTION: OCX Property Pages should return FALSE
94}
95
96void CSoundsPage::OnT42bellBrowse()
97{
98 BrowseForSound(m_T42BellCtl);
99}
100
101void CSoundsPage::OnT42promptBrowse()
102{
103 BrowseForSound(m_T42PromptCtl);
104}
105
106void CSoundsPage::OnT42wakeBrowse()
107{
108 BrowseForSound(m_T42WakeCtl);
109}
110
111void CSoundsPage::BrowseForSound(CComboBox& ctl)
112{
113CString f;
114 ctl.GetWindowText(f);
115CString filter;
116 filter.LoadString(IDS_FILTER_WAV);
117CFileDialog fd(TRUE,NULL,(LPCTSTR)f,
118 OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY
119 |OFN_LONGNAMES|OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST,
120 filter,this);
121CString title;
122 title.LoadString(IDS_TITLE_WAV);
123 fd.m_ofn.lpstrTitle=(LPCTSTR)title;
124 if(fd.DoModal()==IDOK)
125 ctl.SetWindowText(fd.GetPathName());
126}
127
128void CSoundsPage::OnT42bellPlay()
129{
130 PlayIt(m_T42BellCtl);
131}
132void CSoundsPage::OnT42promptPlay()
133{
134 PlayIt(m_T42PromptCtl);
135}
136void CSoundsPage::OnT42wakePlay()
137{
138 PlayIt(m_T42WakeCtl);
139}
140
141void CSoundsPage::PlayIt(CComboBox& ctl,BOOL bLoop)
142{
143CString s;
144 ctl.GetWindowText(s);
145CT42App* app = (CT42App*)AfxGetApp();
146 ASSERT(app);
147 app->StartSound(s,bLoop);
148}