[Amis-vcs] SF.net SVN: amis: [2417] branches/amis3/AmisGuiMFC2
Brought to you by:
julienq,
marisademeglio
From: <dan...@us...> - 2008-03-17 20:39:39
|
Revision: 2417 http://amis.svn.sourceforge.net/amis/?rev=2417&view=rev Author: daniel_weck Date: 2008-03-17 13:39:20 -0700 (Mon, 17 Mar 2008) Log Message: ----------- implemented a series of small hacks to make sure that undefined dialogs in AccessibleUi.xml still deliver a minimum set of meaningful info to the end-user, such as OK and CANCEL buttons. Also improved the text-field self-voicing a little bit, although it's not perfect yet. Oh yes, and also fixed a couple of issues related to the RETURN and ESCAPE key generating MFC actions on KEY_DOWN rather than KEY_UP, which tends to mess-up the self-voicing (i.e. a dialog closes on KEY_DOWN, then on KEY_UP the main window picks-up the event and overrides the "dialogClosed" prompt...and the user is all confused !). This does not happen with the SPACE key, as it triggers the MFC action on KEY_UP only. There was a similar problem with SHIFT+TAB combo for navigating widgets. Now fixed. Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/gui/dialogs/AmisDialogBase.h branches/amis3/AmisGuiMFC2/include/gui/dialogs/OpenUrlDialog.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/GoToPageDialog.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/OpenUrlDialog.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequence.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/PreTranslateMessageHandler.cpp Modified: branches/amis3/AmisGuiMFC2/include/gui/dialogs/AmisDialogBase.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/AmisDialogBase.h 2008-03-17 17:33:11 UTC (rev 2416) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/AmisDialogBase.h 2008-03-17 20:39:20 UTC (rev 2417) @@ -42,6 +42,7 @@ INT_PTR do_modal(); void setFirstDraw(bool); + BOOL PreTranslateMessageTextField(MSG* pMsg, UINT id); virtual BOOL PreTranslateMessage(MSG* pMsg); protected: bool mbFlag_FirstDraw; Modified: branches/amis3/AmisGuiMFC2/include/gui/dialogs/OpenUrlDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/OpenUrlDialog.h 2008-03-17 17:33:11 UTC (rev 2416) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/OpenUrlDialog.h 2008-03-17 20:39:20 UTC (rev 2417) @@ -43,6 +43,8 @@ CString getUrl(); enum { IDD = IDD_OPENURL }; + virtual BOOL PreTranslateMessage(MSG* pMsg); + protected: virtual void DoDataExchange(CDataExchange* pDX); CString mUrl; Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h 2008-03-17 17:33:11 UTC (rev 2416) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h 2008-03-17 20:39:20 UTC (rev 2417) @@ -86,6 +86,9 @@ static void fillSequenceContents(AudioSequence* seq, PromptItemBase* pi); static void resolvePromptVariables(Prompt*); + +private: + static void fillOK_CANCEL(AudioSequence * seq, UINT ctrlId); }; } Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-17 17:33:11 UTC (rev 2416) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-17 20:39:20 UTC (rev 2417) @@ -273,6 +273,9 @@ amis::util::Log::Instance()->DestroyInstance(); TRACE("\nEXIT.\n\n"); + + Sleep(1000); + return CWinApp::ExitInstance(); } Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp 2008-03-17 17:33:11 UTC (rev 2416) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp 2008-03-17 20:39:20 UTC (rev 2417) @@ -31,6 +31,47 @@ IMPLEMENT_DYNAMIC(AmisDialogBase, CDialog) //IMPLEMENT_DYNCREATE(AmisDialogBase, CDialog) +BOOL AmisDialogBase::PreTranslateMessageTextField(MSG* pMsg, UINT id) +{ + if (Preferences::Instance()->getIsSelfVoicing() == false) + return CDialog::PreTranslateMessage(pMsg); + + if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) + { + CWnd* cwnd = this->GetFocus(); + if (cwnd) + { + //int id = cwnd->GetDlgCtrlID(); + CEdit* p_edit = (CEdit*)GetDlgItem(id); + if (cwnd == p_edit) { + + CString str; + p_edit->GetWindowText(str); + + + if (!str.IsEmpty()) { + + CString strFULL = str; + + int nStartChar = -1; + int nEndChar = -1; + p_edit->GetSel(nStartChar, nEndChar); + + str = mCommonPreTranslateMessageHandler->normalizeTextEntry(str, nStartChar, nEndChar); + + if (!str.IsEmpty()) { // && (pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN || pMsg->wParam == VK_LEFT || pMsg->wParam == VK_RIGHT)) { + mCommonPreTranslateMessageHandler->handle(pMsg, (cwnd == NULL ? -1 : cwnd->GetDlgCtrlID()),false,true,str, strFULL, false); + return CDialog::PreTranslateMessage(pMsg); + } + } + } + + mCommonPreTranslateMessageHandler->handle(pMsg, (cwnd == NULL ? -1 : cwnd->GetDlgCtrlID())); + } + } + + return CDialog::PreTranslateMessage(pMsg); +} BOOL AmisDialogBase::PreTranslateMessage(MSG* pMsg) { if (Preferences::Instance()->getIsSelfVoicing() == false) Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/GoToPageDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/GoToPageDialog.cpp 2008-03-17 17:33:11 UTC (rev 2416) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/GoToPageDialog.cpp 2008-03-17 20:39:20 UTC (rev 2417) @@ -81,10 +81,9 @@ BOOL GoToPageDialog::PreTranslateMessage(MSG* pMsg) { - if (Preferences::Instance()->getIsSelfVoicing() == false) { - return CDialog::PreTranslateMessage(pMsg); - } + return AmisDialogBase::PreTranslateMessageTextField(pMsg, IDC_PAGENUM); + /* if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) { CWnd* cwnd = this->GetFocus(); @@ -119,4 +118,5 @@ } return CDialog::PreTranslateMessage(pMsg); + */ } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/OpenUrlDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/OpenUrlDialog.cpp 2008-03-17 17:33:11 UTC (rev 2416) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/OpenUrlDialog.cpp 2008-03-17 20:39:20 UTC (rev 2417) @@ -72,4 +72,9 @@ CWnd::DefWindowProc( WM_PAINT, (WPARAM)dc.m_hDC, 0 ); //call the base class on_paint function on_paint(); +} + +BOOL OpenUrlDialog::PreTranslateMessage(MSG* pMsg) +{ + return AmisDialogBase::PreTranslateMessageTextField(pMsg, IDC_URL); } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequence.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequence.cpp 2008-03-17 17:33:11 UTC (rev 2416) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequence.cpp 2008-03-17 20:39:20 UTC (rev 2417) @@ -30,7 +30,7 @@ } void AudioSequence::append(CString strTTS) { if (strTTS.IsEmpty()) { - TRACE(L"???????????????????????????"); + return; } AudioSequenceComponent* comp = new AudioSequenceComponent; comp->m_isAudioClip = false; @@ -41,7 +41,7 @@ void AudioSequence::prepend(CString strTTS) { if (strTTS.IsEmpty()) { - TRACE(L"???????????????????????????"); + return; } AudioSequenceComponent* comp = new AudioSequenceComponent; comp->m_isAudioClip = false; Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-17 17:33:11 UTC (rev 2416) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-17 20:39:20 UTC (rev 2417) @@ -1064,6 +1064,52 @@ } } + +void AudioSequencePlayer::fillOK_CANCEL(AudioSequence * seq, UINT ctrlId) { + if (ctrlId == IDCANCEL) { + PromptItem* p_prompt = DataTree::Instance()->findPromptItem("cancel_button_caption"); + if (p_prompt != NULL) + { + fillSequenceContents(seq, p_prompt); + //CString text = p_prompt->concatAllText().c_str(); + //seq->append(text); + } + p_prompt = DataTree::Instance()->findPromptItem("cancel_button_description"); + if (p_prompt != NULL) + { + fillSequenceContents(seq, p_prompt); + //CString text = p_prompt->concatAllText().c_str(); + //seq->append(text); + } + + } else if (ctrlId == IDOK) { + PromptItem* p_prompt = DataTree::Instance()->findPromptItem("ok_button_caption"); + if (p_prompt != NULL) + { + fillSequenceContents(seq, p_prompt); + //CString text = p_prompt->concatAllText().c_str(); + //seq->append(text); + } + p_prompt = DataTree::Instance()->findPromptItem("ok_button_description"); + if (p_prompt != NULL) + { + fillSequenceContents(seq, p_prompt); + //CString text = p_prompt->concatAllText().c_str(); + //seq->append(text); + } + + + /* Dialog* p_dialog = DataTree::Instance()->findDialog(IDD_ABOUTBOX); + if (p_dialog != NULL) { + DialogControl* control = p_dialog->findControl(IDOK); + + if (control != NULL) { + fillSequenceCaptionAndDescription(seq, control); + } + }*/ + } +} + //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // This works for Dialogs @@ -1077,49 +1123,7 @@ AudioSequence * seq = new AudioSequence; if (dlgID == -1) { - if (ctrlId == IDCANCEL) { - PromptItem* p_prompt = DataTree::Instance()->findPromptItem("cancel_button_caption"); - if (p_prompt != NULL) - { - fillSequenceContents(seq, p_prompt); - //CString text = p_prompt->concatAllText().c_str(); - //seq->append(text); - } - p_prompt = DataTree::Instance()->findPromptItem("cancel_button_description"); - if (p_prompt != NULL) - { - fillSequenceContents(seq, p_prompt); - //CString text = p_prompt->concatAllText().c_str(); - //seq->append(text); - } - - } else if (ctrlId == IDOK) { - PromptItem* p_prompt = DataTree::Instance()->findPromptItem("ok_button_caption"); - if (p_prompt != NULL) - { - fillSequenceContents(seq, p_prompt); - //CString text = p_prompt->concatAllText().c_str(); - //seq->append(text); - } - p_prompt = DataTree::Instance()->findPromptItem("ok_button_description"); - if (p_prompt != NULL) - { - fillSequenceContents(seq, p_prompt); - //CString text = p_prompt->concatAllText().c_str(); - //seq->append(text); - } - - - /* Dialog* p_dialog = DataTree::Instance()->findDialog(IDD_ABOUTBOX); - if (p_dialog != NULL) { - DialogControl* control = p_dialog->findControl(IDOK); - - if (control != NULL) { - fillSequenceCaptionAndDescription(seq, control); - } - }*/ - } - + fillOK_CANCEL(seq, ctrlId); } else { Dialog* p_dialog = DataTree::Instance()->findDialog(dlgID); if (p_dialog != NULL) { @@ -1128,6 +1132,8 @@ if (control != NULL) { fillSequenceCaptionAndDescription(seq, control); } + } else { + fillOK_CANCEL(seq, ctrlId); } } Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/PreTranslateMessageHandler.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/PreTranslateMessageHandler.cpp 2008-03-17 17:33:11 UTC (rev 2416) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/PreTranslateMessageHandler.cpp 2008-03-17 20:39:20 UTC (rev 2417) @@ -107,7 +107,8 @@ return L"control"; } else if (ch == VK_SHIFT) { - return L"shift"; + //return L"shift"; + return L""; // Because when this key is used in combination with TAB to reverse-navigate, it overrides the prompt for the dialog that is reached. } else if (ch == VK_LEFT) { if (!ignoreArrowKeys) return L"left"; @@ -122,16 +123,18 @@ if (!ignoreArrowKeys) return L"down"; } else if (ch == VK_ESCAPE) { - return L"escape"; + //return L"escape"; + return L""; // Because this key activates the corresponding MFC action (i.e. close a dialog) on KEY_DOWN, as opposed to KEY_UP, which means that the "dialogClosed" prompt would be overridden. The SPACE key does not have this problem. + } else if (ch == VK_RETURN) + { + //return L"return"; + return L""; // Because this key activates the corresponding MFC action (i.e. close a dialog) on KEY_DOWN, as opposed to KEY_UP, which means that the "dialogClosed" prompt would be overridden. The SPACE key does not have this problem. } else if (ch == VK_HOME) { if (!ignoreArrowKeys) return L"home"; } else if (ch == VK_END) { if (!ignoreArrowKeys) return L"end"; - } else if (ch == VK_RETURN) - { - return L"return"; } else if (ch == VK_TAB) { @@ -300,24 +303,35 @@ } else if (idUiFocus >= 0) { - /* - AudioSequence * mSeq = new AudioSequence(); - if (! strTextField.IsEmpty()) { - if (strTextField.GetLength() == 1) { - strTextField = convertKeystrokeToSpeakableString(strTextField.GetAt(0)); - } - mSeq->append(strTextField); - //if (playNow) AudioSequencePlayer::Instance()->Play(seq); - }*/ AudioSequence * mSeq = AudioSequencePlayer::Instance()->playDialogControlFromUiIds(m_instructionsDialogID, idUiFocus, false); + if (mSeq == NULL) { + + mSeq = new AudioSequence(); + + if (idUiFocus == IDC_URL && strTextFieldFULL.IsEmpty() && strTextField.IsEmpty()) { + + mSeq->append("text"); + } + } + if (! strTextFieldFULL.IsEmpty()) { if (strTextFieldFULL.GetLength() == 1) { strTextFieldFULL = convertKeystrokeToSpeakableString(strTextFieldFULL.GetAt(0)); } mSeq->prepend(strTextFieldFULL); + } else if (! strTextField.IsEmpty()) { + if (strTextField.GetLength() == 1) { + strTextField = convertKeystrokeToSpeakableString(strTextField.GetAt(0)); + } + mSeq->prepend(strTextField); } + + if (mSeq->GetCount() == 0) { + delete mSeq; + } else { AudioSequencePlayer::Instance()->Play(mSeq); + } return; } @@ -340,7 +354,7 @@ } //if (playNow) AudioSequencePlayer::Instance()->Play(seq); } - if (!(mSeq->IsEmpty()) && wasSameKey) { + if (!(mSeq->IsEmpty())) { // && wasSameKey) { AudioSequencePlayer::Instance()->Play(mSeq, true); return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |