author | Michael Krelin <hacker@klever.net> | 2004-07-05 01:53:09 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2004-07-05 01:53:09 (UTC) |
commit | 955d4e00adc9f39ab93bf21f07506eb75b013c70 (patch) (unidiff) | |
tree | 92493a2c9ac206b822e24a9e5a6f6b1589be6afb /SoundsPage.cpp | |
download | T42-955d4e00adc9f39ab93bf21f07506eb75b013c70.zip T42-955d4e00adc9f39ab93bf21f07506eb75b013c70.tar.gz T42-955d4e00adc9f39ab93bf21f07506eb75b013c70.tar.bz2 |
initial commit into svn repository
git-svn-id: http://svn.klever.net/kin/T42/trunk@1 fe716a7a-6dde-0310-88d9-d003556173a8
-rw-r--r-- | SoundsPage.cpp | 148 |
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 | ||
11 | static char THIS_FILE[] = __FILE__; | ||
12 | #endif | ||
13 | |||
14 | ///////////////////////////////////////////////////////////////////////////// | ||
15 | // CSoundsPage property page | ||
16 | |||
17 | IMPLEMENT_DYNCREATE(CSoundsPage, CPropertyPage) | ||
18 | |||
19 | CSoundsPage::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 | |||
29 | CSoundsPage::~CSoundsPage() | ||
30 | { | ||
31 | } | ||
32 | |||
33 | void 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 | |||
54 | BEGIN_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 | ||
63 | END_MESSAGE_MAP() | ||
64 | |||
65 | ///////////////////////////////////////////////////////////////////////////// | ||
66 | // CSoundsPage message handlers | ||
67 | |||
68 | BOOL CSoundsPage::OnInitDialog() | ||
69 | { | ||
70 | CPropertyPage::OnInitDialog(); | ||
71 | |||
72 | CT42App* 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 | |||
81 | HICON 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 | |||
96 | void CSoundsPage::OnT42bellBrowse() | ||
97 | { | ||
98 | BrowseForSound(m_T42BellCtl); | ||
99 | } | ||
100 | |||
101 | void CSoundsPage::OnT42promptBrowse() | ||
102 | { | ||
103 | BrowseForSound(m_T42PromptCtl); | ||
104 | } | ||
105 | |||
106 | void CSoundsPage::OnT42wakeBrowse() | ||
107 | { | ||
108 | BrowseForSound(m_T42WakeCtl); | ||
109 | } | ||
110 | |||
111 | void CSoundsPage::BrowseForSound(CComboBox& ctl) | ||
112 | { | ||
113 | CString f; | ||
114 | ctl.GetWindowText(f); | ||
115 | CString filter; | ||
116 | filter.LoadString(IDS_FILTER_WAV); | ||
117 | CFileDialog fd(TRUE,NULL,(LPCTSTR)f, | ||
118 | OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY | ||
119 | |OFN_LONGNAMES|OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST, | ||
120 | filter,this); | ||
121 | CString 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 | |||
128 | void CSoundsPage::OnT42bellPlay() | ||
129 | { | ||
130 | PlayIt(m_T42BellCtl); | ||
131 | } | ||
132 | void CSoundsPage::OnT42promptPlay() | ||
133 | { | ||
134 | PlayIt(m_T42PromptCtl); | ||
135 | } | ||
136 | void CSoundsPage::OnT42wakePlay() | ||
137 | { | ||
138 | PlayIt(m_T42WakeCtl); | ||
139 | } | ||
140 | |||
141 | void CSoundsPage::PlayIt(CComboBox& ctl,BOOL bLoop) | ||
142 | { | ||
143 | CString s; | ||
144 | ctl.GetWindowText(s); | ||
145 | CT42App* app = (CT42App*)AfxGetApp(); | ||
146 | ASSERT(app); | ||
147 | app->StartSound(s,bLoop); | ||
148 | } | ||