3 /////////////////////////////////////////////////////////////////////////////
5 // Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge.
7 /////////////////////////////////////////////////////////////////////////////
12 #include "../resource.h"
14 #include <utility> // for std::pair
16 using namespace Dasher
;
19 // Track memory leaks on Windows to the line that new'd the memory
22 #define DEBUG_NEW new( _NORMAL_BLOCK, THIS_FILE, __LINE__ )
25 static char THIS_FILE
[] = __FILE__
;
29 CLMPage::CLMPage(HWND Parent
, CDasherInterfaceBase
*DI
, CAppSettings
*pAppSettings
)
30 :CPrefsPageBase(Parent
, DI
, pAppSettings
) {
34 void CLMPage::PopulateList() {
36 EnableWindow(GetDlgItem(m_hwnd
, IDC_LM_JAPANESE
), FALSE
);
39 slider
= GetDlgItem(m_hwnd
, IDC_UNIFORMSLIDER
);
40 SendMessage(slider
, TBM_SETPAGESIZE
, 0L, 20); // PgUp and PgDown change bitrate by reasonable amount
41 SendMessage(slider
, TBM_SETTICFREQ
, 10, 0L);
42 SendMessage(slider
, TBM_SETRANGE
, FALSE
, (LPARAM
) MAKELONG(0, 1000));
44 uniformbox
= GetDlgItem(m_hwnd
, IDC_UNIFORMVAL
);
46 if(m_pAppSettings
->GetBoolParameter(BP_LM_ADAPTIVE
)) {
47 SendMessage(GetDlgItem(m_hwnd
, IDC_ADAPTIVE
), BM_SETCHECK
, BST_CHECKED
, 0);
50 SendMessage(GetDlgItem(m_hwnd
, IDC_ADAPTIVE
), BM_SETCHECK
, BST_UNCHECKED
, 0);
53 SendMessage(slider
, TBM_SETPOS
, TRUE
, (LPARAM
) m_pAppSettings
->GetLongParameter(LP_UNIFORM
));
55 _sntprintf(m_tcBuffer
, 100, TEXT("%0.1f"), m_pAppSettings
->GetLongParameter(LP_UNIFORM
) / 10.0);
56 SendMessage(uniformbox
, WM_SETTEXT
, 0, (LPARAM
) m_tcBuffer
);
58 switch(m_pAppSettings
->GetLongParameter(LP_LANGUAGE_MODEL_ID
)) {
60 SendMessage(GetDlgItem(m_hwnd
, IDC_LM_PPM
), BM_SETCHECK
, BST_CHECKED
, 0);
63 SendMessage(GetDlgItem(m_hwnd
, IDC_LM_WORD
), BM_SETCHECK
, BST_CHECKED
, 0);
66 SendMessage(GetDlgItem(m_hwnd
, IDC_LM_MIXTURE
), BM_SETCHECK
, BST_CHECKED
, 0);
70 SendMessage(GetDlgItem(m_hwnd
, IDC_LM_JAPANESE
), BM_SETCHECK
, BST_CHECKED
, 0);
77 bool CLMPage::Validate() {
78 // Return false if something is wrong to prevent user from clicking to a different page. Please also pop up a dialogue informing the user at this point.
82 bool CLMPage::Apply() {
83 m_pAppSettings
->SetBoolParameter( BP_LM_ADAPTIVE
, SendMessage(GetDlgItem(m_hwnd
, IDC_ADAPTIVE
), BM_GETCHECK
, 0, 0)!=0 );
86 NewUniform
= SendMessage(slider
, TBM_GETPOS
, 0, 0);
87 m_pAppSettings
->SetLongParameter( LP_UNIFORM
, NewUniform
);
89 if(SendMessage(GetDlgItem(m_hwnd
, IDC_LM_PPM
), BM_GETCHECK
, 0, 0))
90 m_pAppSettings
->SetLongParameter(LP_LANGUAGE_MODEL_ID
, 0);
91 else if(SendMessage(GetDlgItem(m_hwnd
, IDC_LM_WORD
), BM_GETCHECK
, 0, 0))
92 m_pAppSettings
->SetLongParameter(LP_LANGUAGE_MODEL_ID
, 2);
93 else if(SendMessage(GetDlgItem(m_hwnd
, IDC_LM_MIXTURE
), BM_GETCHECK
, 0, 0))
94 m_pAppSettings
->SetLongParameter(LP_LANGUAGE_MODEL_ID
, 3);
96 else if(SendMessage(GetDlgItem(m_hwnd
, IDC_LM_JAPANESE
), BM_GETCHECK
, 0, 0))
97 m_pAppSettings
->SetLongParameter(LP_LANGUAGE_MODEL_ID
, 4);
100 // Return false (and notify the user) if something is wrong.
104 LRESULT
CLMPage::WndProc(HWND Window
, UINT message
, WPARAM wParam
, LPARAM lParam
) {
108 // most things we pass on to CPrefsPageBase, but we need to handle slider motion
112 if((LOWORD(wParam
) == SB_THUMBPOSITION
) | (LOWORD(wParam
) == SB_THUMBTRACK
)) {
113 // Some messages give the new postion
114 NewUniform
= HIWORD(wParam
);
117 // Otherwise we have to ask for it
118 long Pos
= SendMessage(slider
, TBM_GETPOS
, 0, 0);
122 _sntprintf(m_tcBuffer
, 100, TEXT("%0.1f"), NewUniform
/ 10);
123 SendMessage(uniformbox
, WM_SETTEXT
, 0, (LPARAM
) m_tcBuffer
);
128 return CPrefsPageBase::WndProc(Window
, message
, wParam
, lParam
);