[Amis-vcs] SF.net SVN: amis: [2350] branches/amis3
Brought to you by:
julienq,
marisademeglio
From: <dan...@us...> - 2008-02-28 17:03:39
|
Revision: 2350 http://amis.svn.sourceforge.net/amis/?rev=2350&view=rev Author: daniel_weck Date: 2008-02-28 09:03:34 -0800 (Thu, 28 Feb 2008) Log Message: ----------- - Finally managed to extract the Menu self-voicing code to an external friend class. Compiles and runs fine in both Release and Debug modes. Modified Paths: -------------- branches/amis3/AmisCore/src/dtb/nav/NavModel.cpp branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/Action.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/Dialog.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/DialogControl.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/Label.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/UiItem.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/dialogs/SkipDialogVoicing.h branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/datamodel/Switch.cpp Added Paths: ----------- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/dialogs/MenuVoicing.h branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp Modified: branches/amis3/AmisCore/src/dtb/nav/NavModel.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/nav/NavModel.cpp 2008-02-27 23:10:17 UTC (rev 2349) +++ branches/amis3/AmisCore/src/dtb/nav/NavModel.cpp 2008-02-28 17:03:34 UTC (rev 2350) @@ -186,7 +186,7 @@ bool amis::dtb::nav::NavModel::hasPages() { - if (mpPageList->getLength() > 0) + if (mpPageList != NULL && mpPageList->getLength() > 0) { return true; } Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2008-02-27 23:10:17 UTC (rev 2349) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2008-02-28 17:03:34 UTC (rev 2350) @@ -360,6 +360,9 @@ Name="dialogs" Filter=""> <File + RelativePath=".\include\gui\self-voicing\dialogs\MenuVoicing.h"> + </File> + <File RelativePath=".\include\gui\self-voicing\dialogs\SkipDialogVoicing.h"> </File> </Filter> @@ -1084,6 +1087,21 @@ Name="dialogs" Filter=""> <File + RelativePath=".\src\gui\self-voicing\dialogs\MenuVoicing.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File RelativePath=".\src\gui\self-voicing\dialogs\SkipDialogVoicing.cpp"> <FileConfiguration Name="Debug|Win32"> Modified: branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-02-27 23:10:17 UTC (rev 2349) +++ branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-02-28 17:03:34 UTC (rev 2350) @@ -27,21 +27,22 @@ #include "gui/self-voicing/PreTranslateMessageHandler.h" #pragma once -using namespace amis::gui::spoken; - - namespace amis { namespace gui { class CMainFrame : public CMDIFrameWnd { + DECLARE_DYNAMIC(CMainFrame) + + friend class MenuVoicing; + public: CMainFrame(); CMenu* m_lastOpenPopupMenu; - std::string computeRootMenuFromFirstChildID(unsigned int firstItemId, bool playPrompt); PreTranslateMessageHandler* mCommonPreTranslateMessageHandler; + bool mbWasPlayingWhenLostFocus; virtual BOOL PreTranslateMessage(MSG* pMsg); virtual BOOL PreCreateWindow(CREATESTRUCT& cs); Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/Action.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/Action.h 2008-02-27 23:10:17 UTC (rev 2349) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/Action.h 2008-02-28 17:03:34 UTC (rev 2350) @@ -1,7 +1,7 @@ #ifndef ACTION_H #define ACTION_H -#include "../UiMediaTypes.h" +#include "gui/self-voicing/UiMediaTypes.h" #include "UiItem.h" Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/Dialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/Dialog.h 2008-02-27 23:10:17 UTC (rev 2349) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/Dialog.h 2008-02-28 17:03:34 UTC (rev 2350) @@ -2,7 +2,7 @@ #define DIALOG_H #include "UiItem.h" -#include "../Prompt.h" +#include "gui/self-voicing/Prompt.h" #include "DialogControl.h" Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/DialogControl.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/DialogControl.h 2008-02-27 23:10:17 UTC (rev 2349) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/DialogControl.h 2008-02-28 17:03:34 UTC (rev 2350) @@ -1,8 +1,8 @@ #ifndef DIALOGCONTROL_H #define DIALOGCONTROL_H -#include "../UiMediaTypes.h" -#include "../Prompt.h" +#include "gui/self-voicing/UiMediaTypes.h" +#include "gui/self-voicing/Prompt.h" #include "UiItem.h" #include "LabelList.h" Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/Label.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/Label.h 2008-02-27 23:10:17 UTC (rev 2349) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/Label.h 2008-02-28 17:03:34 UTC (rev 2350) @@ -1,7 +1,7 @@ #ifndef LABEL_H #define LABEL_H -#include "../Prompt.h" +#include "gui/self-voicing/Prompt.h" namespace amis Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/UiItem.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/UiItem.h 2008-02-27 23:10:17 UTC (rev 2349) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/datamodel/UiItem.h 2008-02-28 17:03:34 UTC (rev 2350) @@ -1,7 +1,7 @@ #ifndef UIITEM_H #define UIITEM_H -#include "../UiMediaTypes.h" +#include "gui/self-voicing/UiMediaTypes.h" #include "Label.h" #include "LabelList.h" Added: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/dialogs/MenuVoicing.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/dialogs/MenuVoicing.h (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/dialogs/MenuVoicing.h 2008-02-28 17:03:34 UTC (rev 2350) @@ -0,0 +1,24 @@ + +#include <string> +#include "stdafx.h" + +#include "gui/MainFrm.h" + +namespace amis +{ + namespace gui + { + class MenuVoicing + { + private: + CMainFrame * mFrm; + public: + MenuVoicing(CMainFrame * frm); + ~MenuVoicing(void); + + std::string computeRootMenuFromFirstChildID(unsigned int firstItemId, bool playPrompt); + void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu); + }; + } + +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/dialogs/SkipDialogVoicing.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/dialogs/SkipDialogVoicing.h 2008-02-27 23:10:17 UTC (rev 2349) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/dialogs/SkipDialogVoicing.h 2008-02-28 17:03:34 UTC (rev 2350) @@ -1,11 +1,11 @@ #include "gui/dialogs/SkipDialog.h"; -#include "../datamodel/DataTree.h" -#include "../datamodel/Dialog.h" -#include "../datamodel/Switch.h" -#include "../datamodel/Label.h" -#include "../Prompt.h" -#include "../UiMediaTypes.h" +#include "gui/self-voicing/datamodel/DataTree.h" +#include "gui/self-voicing/datamodel/Dialog.h" +#include "gui/self-voicing/datamodel/Switch.h" +#include "gui/self-voicing/datamodel/Label.h" +#include "gui/self-voicing/Prompt.h" +#include "gui/self-voicing/UiMediaTypes.h" namespace amis { Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-02-27 23:10:17 UTC (rev 2349) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-02-28 17:03:34 UTC (rev 2350) @@ -32,6 +32,8 @@ #include "io/BookmarksFileIO.h" #include "io/ToolbarIO.h" #include "util/Log.h" + +#include "gui/self-voicing/dialogs/MenuVoicing.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -78,21 +80,27 @@ static UINT indicators[] = { ID_SEPARATOR, // status line indicator - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, }; + +using namespace amis::gui::spoken; +amis::gui::MenuVoicing* mMenuVoicing; + CMainFrame::CMainFrame() { mbWasPlayingWhenLostFocus = false; m_lastOpenPopupMenu = NULL; mSavedMenu.LoadMenu(IDR_AMISTYPE); mCommonPreTranslateMessageHandler = new PreTranslateMessageHandler(-1); + mMenuVoicing = new amis::gui::MenuVoicing(this); } CMainFrame::~CMainFrame() { delete mCommonPreTranslateMessageHandler; + delete mMenuVoicing; } @@ -154,7 +162,7 @@ } mDefaultRebar.AddBar(&mDefaultToolbar); - + //create the basic toolbar amis::util::Log::Instance()->writeMessage("Loading basic toolbar", "CMainFrame::OnCreate", "AmisGuiMFC2"); toolbar_file = ambulant::net::url::from_filename("./settings/basicToolbar.xml"); @@ -171,7 +179,7 @@ return -1; } mBasicToolbar.EnableToolTips(TRUE); - + //create the basic rebar (toolbar container) if (p_settings->getPlacement() == amis::gui::toolbar::TOP) align = CBRS_TOP; else align = CBRS_BOTTOM; @@ -188,12 +196,12 @@ // Delete these three lines if you don't want the toolbar to be dockable EnableDocking(CBRS_ALIGN_ANY); - #ifdef _SCB_REPLACE_MINIFRAME - m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd); - #endif +#ifdef _SCB_REPLACE_MINIFRAME + m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd); +#endif DockControlBar(&mSidebar, AFX_IDW_DOCKBAR_LEFT); - + MainWndParts::Instance()->mpSidebar = &mSidebar; MainWndParts::Instance()->mpStatusBar = &mStatusBar; MainWndParts::Instance()->mpMainFrame = this; @@ -210,7 +218,7 @@ return FALSE; cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE - | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE | WS_SYSMENU; + | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE | WS_SYSMENU; return TRUE; } @@ -234,384 +242,13 @@ void CMainFrame::OnMenuSelect( UINT nItemID, UINT nFlags, HMENU hSysMenu ) { - USES_CONVERSION; CFrameWnd::OnMenuSelect(nItemID, nFlags, hSysMenu); if (amis::Preferences::Instance()->getIsSelfVoicing() == false) { return; } - - //CMenu* pMenu = DYNAMIC_DOWNCAST(CMenu, (CObject*)hSysMenu); - //TRACE("OnMenuSelect, hSysMenu=%p is %s\n", hSysMenu, ::IsMenu(hSysMenu) ? "HMENU" : pMenu ? "CMenu" : "unknown"); - - bool isSysMenu = false; - CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu != NULL) - { - if (pSysMenu->m_hMenu == hSysMenu) { - TRACE("System Menu !"); - isSysMenu = true; - } - } - - if (isSysMenu) { - //CMenu* p_menu = p_menu->GetSubMenu(nItemID); - CString str; - pSysMenu->GetMenuString(nItemID, str, nFlags); - TRACE(str); - AudioSequence* seq = new AudioSequence; - str.Replace(L"&", L""); - seq->append(str); - AudioSequencePlayer::Instance()->Play(seq); - return; - } - - - if (nItemID) { - // - - CString s; - } - //don't read separators - if (nFlags & MF_SEPARATOR) - { - return; - } - - CString s; - - string prompt; - - - AudioSequence* seq = NULL; - seq = new AudioSequence(); - - if ( nFlags & MF_GRAYED ) - { - PromptItem* promptNotAvailable = DataTree::Instance()->findPromptItem("not_available"); - if (promptNotAvailable != NULL) - { - - AudioSequencePlayer::fillSequenceContents(seq, promptNotAvailable); - } - } - if ( nFlags & MF_POPUP ) - { - if ( nFlags & MF_BYPOSITION ) - { - //AmisBrain::Instance()->playPromptFromUiId(nItemID); - } - if ( nFlags & MF_BYCOMMAND ) - { - //AmisBrain::Instance()->playPromptFromUiId(nItemID); - } - - - if ((nItemID == 8 || nItemID == 2) && m_lastOpenPopupMenu != NULL) { // 8 => "recent" (including separators), 2 => "show section depth" - UINT nID = m_lastOpenPopupMenu->GetMenuItemID(0); - std::string prompt = computeRootMenuFromFirstChildID(nID, false); - - s.Format(_T("\n{{{ %d"), nItemID); //DAN_MENU_DEBUG - TRACE(s); - TRACE(prompt.c_str()); - - if (prompt.compare("file") == 0 || prompt.compare("recentBooksList") == 0) { - seq = AudioSequencePlayer::playContainerPromptFromId("recentBooksList", false, seq); - - PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); - - if (p_prompt_ != NULL) - { - AudioSequencePlayer::fillSequenceContents(seq, p_prompt_); - } - else { - seq->append(_T("menu")); - } - - AudioSequencePlayer::Instance()->Play(seq); - } else if (prompt.compare("navigate") == 0 || prompt.compare("sectiondepth") == 0) { - seq = AudioSequencePlayer::playContainerPromptFromId("sectiondepth", false, seq); - - PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); - - if (p_prompt_ != NULL) - { - AudioSequencePlayer::fillSequenceContents(seq, p_prompt_); - } - else { - seq->append(_T("menu")); - } - AudioSequencePlayer::Instance()->Play(seq); - } else { - int i = 0; // NOP, for breakpoint - } - } else if (nItemID >=0 && nItemID <=6) { //TODO: Yuuk ! UGLY ! This is only a temporary workaround ! //m_lastOpenPopupMenu == NULL && - - switch (nItemID) { - case 0: - seq = AudioSequencePlayer::playContainerPromptFromId("file", false, seq); - break; - case 1: - seq = AudioSequencePlayer::playContainerPromptFromId("view", false, seq); - break; - case 2: - seq = AudioSequencePlayer::playContainerPromptFromId("play", false, seq); - break; - case 3: - seq = AudioSequencePlayer::playContainerPromptFromId("navigate", false, seq); - break; - case 4: - seq = AudioSequencePlayer::playContainerPromptFromId("bookmarks", false, seq); - break; - case 5: - seq = AudioSequencePlayer::playContainerPromptFromId("info", false, seq); - break; - case 6: - seq = AudioSequencePlayer::playContainerPromptFromId("help", false, seq); - break; - //default: seq = new AudioSequence(); - } - PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); - - if (p_prompt_ != NULL) - { - AudioSequencePlayer::fillSequenceContents(seq, p_prompt_); - } - else { - if (seq != NULL) { - seq->append(_T("menu")); - } - } - - if (seq != NULL) { - AudioSequencePlayer::Instance()->Play(seq); - } - } - } - else - { - s.Format(_T("Item %d is selected"), nItemID); //DAN_MENU_DEBUG - TRACE(s); - - -amis::RecentBooks* books = theApp.getRecentBooks(); -int nRecentBooks = (books ? books->getNumberOfEntries() : 0); - -if (nRecentBooks > 0 && (nItemID >= BOOK_BASE_ID && nItemID < BOOK_BASE_ID + nRecentBooks)) - { - int idx = nItemID - BOOK_BASE_ID; - -amis::RecentBookEntry* p_entry = theApp.getRecentBooks()->getEntry(idx); - -//DanTodo: surely, there must be a way to get a title instead of rendering the URL with TTS ??! (see bookmark methd commented below) -string str = p_entry->mPath.get_url(); - seq->append(A2T(str.c_str())); - AudioSequencePlayer::Instance()->Play(seq); - - //CString cstr_filepath = A2T(filepath.c_str()); - - /* -amis::io::BookmarksFileIO bmk_file_io; -bmk_file_io.readFromFile(&p_entry->mPath); - - amis::MediaGroup* p_title = NULL; - p_title = bmk_file_io.getBookmarkSet()->getTitle(); - - if (p_title != NULL) - { - if (p_title->hasAudio() == true) - { - amis::AudioNode* p_audio = NULL; - p_audio = (amis::AudioNode*)p_title->getAudio(0)->clone(); - if (p_audio != NULL) - { - seq->append(p_audio); - AudioSequencePlayer::Instance()->Play(seq); - - } - - - }else if (p_title->hasText() == true) - { -amis::TextNode* p_text = NULL; -p_text = p_title->getText(); - if (p_text != NULL) - { - wstring str = p_text->getTextString(); - seq->append(str.c_str()); - AudioSequencePlayer::Instance()->Play(seq); - } - - - } - - } */ - } -else - if (nItemID >= BOOKMARKS_BASE_ID && nItemID <= - BOOKMARKS_BASE_ID + MAX_ANYTHING) - { - int idx = nItemID - BOOKMARKS_BASE_ID; - - - //amis::dtb::BookmarkSet* p_bmks = amis::dtb::DtbWithHooks::Instance()->getBookmarks(); - //amis::dtb::PositionMark* p_mark = p_bmks->getItem(idx); - - amis::MediaGroup* p_note = amis::dtb::DtbWithHooks::Instance()->getBookmarks()->getItem(idx)->mpNote; - if (p_note!=NULL) - { - - if (p_note->hasAudio() == true) - { - amis::AudioNode* p_audio = NULL; - p_audio = p_note->getAudio(0); - if (p_audio != NULL) - { - seq->append(p_audio); - AudioSequencePlayer::Instance()->Play(seq); - } - } else if (p_note->hasText() == true) - { - //DanTodo: bmks generally have no audio, so how can we use the existing (open) book content to render audio voice here ? -amis::TextNode* p_text = NULL; -p_text = p_note->getText(); - if (p_text != NULL) - { - wstring str = p_text->getTextString(); - seq->append(str.c_str()); - AudioSequencePlayer::Instance()->Play(seq); - } - - - } - - } - } else - -if (nItemID > SECTION_DEPTH_BASE_ID && nItemID <= (SECTION_DEPTH_BASE_ID + MAX_ANYTHING)) - { - string strPrompt; - switch (nItemID) { - case (SECTION_DEPTH_BASE_ID+1): { - strPrompt = "numeric_one"; - break; - } - case (SECTION_DEPTH_BASE_ID+2): { - strPrompt = "numeric_two"; - break; - } - case (SECTION_DEPTH_BASE_ID+3): { - strPrompt = "numeric_three"; - break; - } - case (SECTION_DEPTH_BASE_ID+4): { - strPrompt = "numeric_four"; - break; - } - case (SECTION_DEPTH_BASE_ID+5): { - strPrompt = "numeric_five"; - break; - } - case (SECTION_DEPTH_BASE_ID+6): { - strPrompt = "numeric_six"; - break; - } - case (SECTION_DEPTH_BASE_ID+7): { - strPrompt = "numeric_seven"; - break; - } - case (SECTION_DEPTH_BASE_ID+8): { - strPrompt = "numeric_eight"; - break; - } - case (SECTION_DEPTH_BASE_ID+9): { - strPrompt = "numeric_nine"; - break; - } - } - if (!strPrompt.empty()) { - //seq->append(strPrompt.c_str()); TEST ONLY - - delete seq; - seq = AudioSequencePlayer::playPromptItemFromStringId(strPrompt, false, NULL); - - AudioSequencePlayer::Instance()->Play(seq); - } - - } - - - /* - - //is this a view menu item (sections/prodnotes/etc) - else if (nItemID >= VIEW_MENU_BASE_ID && nItemID < VIEW_MENU_BASE_ID + - MenuManip::Instance()->getNumberOfViewMenuAdditions()) - { - //first item in the list is always "sections" - if (nItemID == VIEW_MENU_BASE_ID) - { - //playPrompt("sections"); - theApp.playPromptItemFromStringId("sections"); - } - //then "pages", if exists - else if (nItemID == VIEW_MENU_BASE_ID + 1 && - NavParse::Instance()->getNavModel()->hasPages() == true) - { - //playPrompt("pages"); - theApp.playPromptItemFromStringId("pages"); - } - else - { - //otherwise it's a nav list so ask NavParse for the nav list ID - //subtract 1 because the menu items include sections, pages, navlists - //we want just the index relative to nav lists - int idx = nItemID - VIEW_MENU_BASE_ID - 1; - - //adjust again by subtracting 1 if there are pages in this book - if (NavParse::Instance()->getNavModel()->hasPages() == true) - { - idx--; - } - - std::string item_id = NavParse::Instance()->getNavModel()->getNavList(idx)->getId(); - - if (item_id.compare("prodnote") == 0 || - item_id.compare("optional-prodnote") == 0 ) - { - //playPrompt("prodnotes"); - theApp.playPromptItemFromStringId("prodnotes"); - } - else if (item_id.compare("sidebar") == 0) - { - //playPrompt("sidebars"); - theApp.playPromptItemFromStringId("sidebars"); - } - else if (item_id.compare("footnote") == 0 || - item_id.compare("noteref") == 0) - { - //playPrompt("footnotes"); - theApp.playPromptItemFromStringId("noterefs"); - } - else - { - //we can't identify it, so read its name with TTS - theApp.playPromptFromUiId(nItemID); - } - } - - } - else - */ - -else - { - AudioSequencePlayer::playPromptFromUiId(nItemID, true, seq); - - - } - - } + mMenuVoicing->OnMenuSelect(nItemID, nFlags, hSysMenu); } void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu) @@ -620,13 +257,6 @@ CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu); -if (amis::Preferences::Instance()->getIsSelfVoicing() == false) - { - return; - } - - TRACE(_T("XXXXXXX 3: on init menu popup\n")); //DAN_MENU_DEBUG - USES_CONVERSION; if (pPopupMenu == NULL) @@ -637,24 +267,24 @@ CString dbg; CString tmpstr; - + UINT nID = pPopupMenu->GetMenuItemID(0); dbg.Format(_T("\tThis popup menu's first item's ID = %d \n"), nID); TRACE(dbg); dbg.Format(_T("\t---------- This popup menu's INDEX = %d \n"), nIndex); TRACE(dbg); - + std::string prompt; //prompt = PromptsGuiIds::Instance()->lookupPromptMenuPopup(nID); - prompt = computeRootMenuFromFirstChildID(nID, false); //Preferences::Instance()->mbIsSelfVoicing); - - tmpstr = A2T(prompt.c_str()); - dbg.Format(_T("\tPrompt for this popup 1 = --%s-- \n"), tmpstr); //DAN_MENU_DEBUG - TRACE(dbg); + prompt = mMenuVoicing->computeRootMenuFromFirstChildID(nID, false); //Preferences::Instance()->mbIsSelfVoicing); - + tmpstr = A2T(prompt.c_str()); + dbg.Format(_T("\tPrompt for this popup 1 = --%s-- \n"), tmpstr); //DAN_MENU_DEBUG + TRACE(dbg); + + //if this is the view menu, set the sidebar checkmark appropriately if (prompt.compare("view") == 0) { @@ -669,7 +299,7 @@ } } - //if this is the play menu, decide if slowdown should be available or not + //TODO should this be the book speed ? if (prompt.compare("play") == 0) { if (AmisAudio::Instance()->getRate() == 1.0) @@ -679,59 +309,21 @@ } else { - + //DanToDo: menu items for slow-down / fast-up //MenuManip::Instance()->setSlowdown(true); } } - -} -void CMainFrame::OnInitMenu(CMenu* pMenu) -{ - //m_OpenMenu = pMenu; - CMDIFrameWnd::OnInitMenu(pMenu); - -if (amis::Preferences::Instance()->getIsSelfVoicing() == false) + if (amis::Preferences::Instance()->getIsSelfVoicing() == false) { return; } +} - TRACE(_T("XXXXXXX 2: on init menu\n")); //DAN_MENU_DEBUG - if (pMenu != NULL) - { - int cMenuCount = pMenu->GetMenuItemCount( ); - // Get number of menu - // Items - - for(int i=0 ; i < cMenuCount ; i++) { - //pMenu->DeleteMenu( i, MF_BYPOSITION ); - ; - } - -//MENUITEMINFO* pMenuItemInfo; -//GetMenuInfo(pMenu->GetSafeHmenu(),pMenuItemInfo); - - //pMenu->DeleteMenu(3, MF_BYPOSITION); - - /* - //DanToDo: Arghhh !!! The IDE tells me everything is fine, but the compiler cannot find MENUINFO and tells me: - //error C2039: 'GetMenuInfo' : is not a member of 'CMenu' - //Stupid bloody VisualC++ !!!!!!! - - MENUINFO menuinfo; - pMenu->GetMenuInfo(&menuinfo); - - CString dbg; - UINT nID = pMenu->GetMenuItemID(0); - dbg.Format(_T("\tINIT MENU ... This popup menu's first item's ID = %d \n"), nID); - TRACE(dbg); - */ - - //std::string prompt; - //prompt = PromptsGuiIds::Instance()->lookupPromptMenuPopup(nID); - } - +void CMainFrame::OnInitMenu(CMenu* pMenu) +{ + CMDIFrameWnd::OnInitMenu(pMenu); } @@ -739,52 +331,42 @@ { CMDIFrameWnd::OnEnterMenuLoop(bIsTrackPopupMenu); -if (amis::Preferences::Instance()->getIsSelfVoicing() == false) + if (amis::Preferences::Instance()->getIsSelfVoicing() == false) { return; } - - MmView *view = MainWndParts::Instance()->mpMmView; assert(view); // XXXJack: or what to do if view == NULL? Skip? - - - bool b_BookIsPlaying = view->isPlaying(); // BOOK Audio Player - mbWasPlayingWhenLostFocus = b_BookIsPlaying; - if (mbWasPlayingWhenLostFocus) - { - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); // XXXJack: or what to do if view == NULL? Skip? - view->OnFilePause(); - //view->OnFilePlay(); - } - - TRACE(_T("zzzzzzzz : on ENTER menu loop!\n")); //DAN_MENU_DEBUG + if (view==NULL) {return;} + bool b_BookIsPlaying = view->isPlaying(); // BOOK Audio Player + mbWasPlayingWhenLostFocus = b_BookIsPlaying; + if (mbWasPlayingWhenLostFocus) + { + view->OnFilePause(); + } } void CMainFrame::OnExitMenuLoop(BOOL bIsTrackPopupMenu) { CMDIFrameWnd::OnExitMenuLoop(bIsTrackPopupMenu); -if (amis::Preferences::Instance()->getIsSelfVoicing() == false) + if (amis::Preferences::Instance()->getIsSelfVoicing() == false) { return; } - AudioSequencePlayer::Instance()->Stop(); + AudioSequencePlayer::Instance()->Stop(); - if (mbWasPlayingWhenLostFocus) { - - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); // XXXJack: or what to do if view == NULL? Skip? - //view->OnFilePause(); - view->OnFilePlay(); - } - mbWasPlayingWhenLostFocus = false; - + if (mbWasPlayingWhenLostFocus) { - TRACE(_T("zzzzzzzz : on EXIT menu loop!\n")); //DAN_MENU_DEBUG + MmView *view = MainWndParts::Instance()->mpMmView; + assert(view); // XXXJack: or what to do if view == NULL? Skip? + if (view==NULL) {return;} + view->OnFilePlay(); + } + mbWasPlayingWhenLostFocus = false; + m_lastOpenPopupMenu = NULL; } @@ -799,135 +381,52 @@ return CFrameWnd::PreTranslateMessage(pMsg); } -//todo: replace this by something like: -// Container* container = DataTree::Instance()->findContainerWhichHasFirstItem(id) -// container.id -std::string CMainFrame::computeRootMenuFromFirstChildID(unsigned int firstItemId, bool playPrompt) +void CMainFrame::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized ) { - - CString dbg; - dbg.Format(_T("\n===firstItemId %d####\n"), firstItemId); - TRACE(dbg); - - string str_id; - - if (firstItemId == ID_MENU_FILE_OPEN) + CWnd::OnActivate( nState, pWndOther, bMinimized ); + //TODO: focus lost detection doesn't work when a modal dialog is used on top of the main application window. + // The consequence is that the book is stopped anyway because modal dialogs stop book audio by default, + // and the dialog-related speech doesn't stop. + if (Preferences::Instance()->getPauseOnLostFocus() == true) { - str_id = "file"; - } - else if (firstItemId == ID_FILE_RECENT_EMPTY || - firstItemId == BOOK_BASE_ID) { - str_id = "recentBooksList"; - } - else if(firstItemId == ID_MENU_VIEW_SIDEBAR_ONOFF) - { - str_id = "view"; - } - else if(firstItemId == ID_MENU_PLAYPAUSE) - { - str_id = "play"; - } - else if(firstItemId == ID_MENU_NAV_PREVSECTION) - { - str_id = "navigate"; - } - else if(firstItemId == ID_EMPTY || - firstItemId == SECTION_DEPTH_BASE_ID + 1) - { - str_id = "sectiondepth"; - } + MmView *view = MainWndParts::Instance()->mpMmView; + assert(view); // XXXJack: or what to do if view == NULL? Skip? - else if(firstItemId == ID_MENU_BMK_ADD) - { - str_id = "bookmarks"; - } - - else if(firstItemId == ID_MENU_INFO_SKIP) - { - str_id = "info"; - } - else if(firstItemId == ID_MENU_HELP_CONTENTS) - { - str_id = "help"; - } - else - { - str_id = ""; - } - if (!str_id.empty()) { - - if (playPrompt) { - AudioSequence* seq = AudioSequencePlayer::playContainerPromptFromId(str_id, false); - - PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); - - if (p_prompt_ != NULL) - { - AudioSequencePlayer::fillSequenceContents(seq, p_prompt_); - } - else { - seq->append(_T("menu")); - } - - AudioSequencePlayer::Instance()->Play(seq); + if (view=NULL) { + return; } - } + if ( nState == WA_INACTIVE ) { + if ( ! AfxGetMainWnd()->IsChild(pWndOther) ) { - return str_id; -} -void CMainFrame::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized ) -{ - CWnd::OnActivate( nState, pWndOther, bMinimized ); - //TODO: focus lost detection doesn't work when a modal dialog is used on top of the main application window. - // The consequence is that the book is stopped anyway because modal dialogs stop book audio by default, - // and the dialog-related speech doesn't stop. - if (Preferences::Instance()->getPauseOnLostFocus() == true) - { - if ( nState == WA_INACTIVE ) { - if ( ! AfxGetMainWnd()->IsChild(pWndOther) ) { + bool b_BookIsPlaying = view->isPlaying(); // BOOK Audio Player - - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); // XXXJack: or what to do if view == NULL? Skip? + //mbWasPlayingWhenLostFocus = b_BookIsPlaying || b_GuiIsPlaying; + mbWasPlayingWhenLostFocus = b_BookIsPlaying; - bool b_BookIsPlaying = view->isPlaying(); // BOOK Audio Player + if (mbWasPlayingWhenLostFocus) + { + view->OnFilePause(); - //mbWasPlayingWhenLostFocus = b_BookIsPlaying || b_GuiIsPlaying; - mbWasPlayingWhenLostFocus = b_BookIsPlaying; + if (amis::Preferences::Instance()->getIsSelfVoicing() == true) + { + AudioSequencePlayer::Instance()->Stop(); + } + } + } + } else { //WA_ACTIVE + if (mbWasPlayingWhenLostFocus) { - if (mbWasPlayingWhenLostFocus) - { - - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); // XXXJack: or what to do if view == NULL? Skip? - view->OnFilePause(); - //view->OnFilePlay(); - -if (amis::Preferences::Instance()->getIsSelfVoicing() == true) - { - AudioSequencePlayer::Instance()->Stop(); - } + view->OnFilePlay(); - + if (amis::Preferences::Instance()->getIsSelfVoicing() == true) + { + AudioSequencePlayer::Instance()->RepeatLast(); + } } + mbWasPlayingWhenLostFocus = false; } - } else { //WA_ACTIVE - if (mbWasPlayingWhenLostFocus) { - - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); // XXXJack: or what to do if view == NULL? Skip? - //view->OnFilePause(); - view->OnFilePlay(); - -if (amis::Preferences::Instance()->getIsSelfVoicing() == true) - { - AudioSequencePlayer::Instance()->RepeatLast(); } - } - mbWasPlayingWhenLostFocus = false; - } - } } //stop the screensaver from starting void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam) Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp 2008-02-27 23:10:17 UTC (rev 2349) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp 2008-02-28 17:03:34 UTC (rev 2350) @@ -51,7 +51,7 @@ SkipDialog::~SkipDialog() { - if (Preferences::Instance()->getIsSelfVoicing() == true) + if (mpSkipDialogVoicing != NULL) { delete mpSkipDialogVoicing; } Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/datamodel/Switch.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/datamodel/Switch.cpp 2008-02-27 23:10:17 UTC (rev 2349) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/datamodel/Switch.cpp 2008-02-28 17:03:34 UTC (rev 2350) @@ -1,7 +1,6 @@ #include "gui/self-voicing/datamodel/Switch.h" #include "../../AmisGuiMFC2/resource.h" -//#include "../AudioAudio/AmisAudio.h" #include <fstream> Added: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp 2008-02-28 17:03:34 UTC (rev 2350) @@ -0,0 +1,500 @@ +#include "../../../../resource.h" +#include "gui/self-voicing/datamodel/DataTree.h" +#include "gui/self-voicing/datamodel/Dialog.h" +#include "gui/self-voicing/datamodel/Switch.h" +#include "gui/self-voicing/datamodel/Label.h" +#include "gui/self-voicing/Prompt.h" +#include "gui/self-voicing/UiMediaTypes.h" +#include "RecentBooks.h" +#include "gui/self-voicing/dialogs/menuvoicing.h" +#include "gui/self-voicing/audiosequenceplayer.h" +#include "DtbWithHooks.h" +#include "gui/AmisApp.h" +#include "gui/MainWndParts.h" + +namespace amis +{ + namespace gui + { + MenuVoicing::MenuVoicing(CMainFrame * frm) + { + mFrm= frm; + } + + MenuVoicing::~MenuVoicing(void) + { + + } + + //todo: replace this by something like: + // Container* container = DataTree::Instance()->findContainerWhichHasFirstItem(id) + // container.id + std::string MenuVoicing::computeRootMenuFromFirstChildID(unsigned int firstItemId, bool playPrompt) + { + + CString dbg; + dbg.Format(_T("\n===firstItemId %d####\n"), firstItemId); + TRACE(dbg); + + string str_id; + + if (firstItemId == ID_MENU_FILE_OPEN) + { + str_id = "file"; + } + else if (firstItemId == ID_FILE_RECENT_EMPTY || + firstItemId == BOOK_BASE_ID) { + str_id = "recentBooksList"; + } + else if(firstItemId == ID_MENU_VIEW_SIDEBAR_ONOFF) + { + str_id = "view"; + } + else if(firstItemId == ID_MENU_PLAYPAUSE) + { + str_id = "play"; + } + else if(firstItemId == ID_MENU_NAV_PREVSECTION) + { + str_id = "navigate"; + } + else if(firstItemId == ID_EMPTY || + firstItemId == SECTION_DEPTH_BASE_ID + 1) + { + str_id = "sectiondepth"; + } + + else if(firstItemId == ID_MENU_BMK_ADD) + { + str_id = "bookmarks"; + } + + else if(firstItemId == ID_MENU_INFO_SKIP) + { + str_id = "info"; + } + else if(firstItemId == ID_MENU_HELP_CONTENTS) + { + str_id = "help"; + } + else + { + str_id = ""; + } + if (!str_id.empty()) { + + if (playPrompt) { + AudioSequence* seq = AudioSequencePlayer::playContainerPromptFromId(str_id, false); + + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); + + if (p_prompt_ != NULL) + { + AudioSequencePlayer::fillSequenceContents(seq, p_prompt_); + } + else { + seq->append(_T("menu")); + } + + AudioSequencePlayer::Instance()->Play(seq); + } + } + + return str_id; + } + + + void MenuVoicing::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu) + { + + USES_CONVERSION; + + //CMenu* pMenu = DYNAMIC_DOWNCAST(CMenu, (CObject*)hSysMenu); + //TRACE("OnMenuSelect, hSysMenu=%p is %s\n", hSysMenu, ::IsMenu(hSysMenu) ? "HMENU" : pMenu ? "CMenu" : "unknown"); + + bool isSysMenu = false; + HWND hWnd = MainWndParts::Instance()->mpMainFrame->GetSafeHwnd(); + HMENU pSysMenu = GetSystemMenu(hWnd, FALSE); + if (pSysMenu != NULL) + { + if (pSysMenu == hSysMenu) { + TRACE("System Menu !"); + isSysMenu = true; + } + } + + if (isSysMenu) { + //CMenu* p_menu = p_menu->GetSubMenu(nItemID); + + int nLen = ::GetMenuString(pSysMenu, nItemID, NULL, 0, MF_BYCOMMAND); + + if (nLen > 0) { + + LPTSTR lpszText = (LPTSTR)_alloca((nLen + 1) * sizeof(TCHAR)); + if (::GetMenuString(pSysMenu, nItemID, lpszText, nLen + 1, MF_BYCOMMAND) == nLen) { + + CString str; + + //pSysMenu->GetMenuString(nItemID, str, nFlags); + //TRACE(str); + str.Append(lpszText); + + str.Replace(L"&", L""); + + //str.Replace(CString("&"), CString("")); + + AudioSequence* seq = new AudioSequence; + seq->append(str); + AudioSequencePlayer::Instance()->Play(seq); + + + } + } + return; + } + + + if (nItemID) { + // + + CString s; + } + //don't read separators + if (nFlags & MF_SEPARATOR) + { + return; + } + + CString s; + + string prompt; + + + AudioSequence* seq = NULL; + seq = new AudioSequence(); + + if ( nFlags & MF_GRAYED ) + { + PromptItem* promptNotAvailable = DataTree::Instance()->findPromptItem("not_available"); + if (promptNotAvailable != NULL) + { + + AudioSequencePlayer::fillSequenceContents(seq, promptNotAvailable); + } + } + if ( nFlags & MF_POPUP ) + { + if ( nFlags & MF_BYPOSITION ) + { + //AmisBrain::Instance()->playPromptFromUiId(nItemID); + } + if ( nFlags & MF_BYCOMMAND ) + { + //AmisBrain::Instance()->playPromptFromUiId(nItemID); + } + + + if ((nItemID == 8 || nItemID == 2) && mFrm->m_lastOpenPopupMenu != NULL) { // 8 => "recent" (including separators), 2 => "show section depth" + UINT nID = mFrm->m_lastOpenPopupMenu->GetMenuItemID(0); + std::string prompt = computeRootMenuFromFirstChildID(nID, false); + + s.Format(_T("\n{{{ %d"), nItemID); //DAN_MENU_DEBUG + TRACE(s); + TRACE(prompt.c_str()); + + if (prompt.compare("file") == 0 || prompt.compare("recentBooksList") == 0) { + seq = AudioSequencePlayer::playContainerPromptFromId("recentBooksList", false, seq); + + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); + + if (p_prompt_ != NULL) + { + AudioSequencePlayer::fillSequenceContents(seq, p_prompt_); + } + else { + seq->append(_T("menu")); + } + + AudioSequencePlayer::Instance()->Play(seq); + } else if (prompt.compare("navigate") == 0 || prompt.compare("sectiondepth") == 0) { + seq = AudioSequencePlayer::playContainerPromptFromId("sectiondepth", false, seq); + + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); + + if (p_prompt_ != NULL) + { + AudioSequencePlayer::fillSequenceContents(seq, p_prompt_); + } + else { + seq->append(_T("menu")); + } + AudioSequencePlayer::Instance()->Play(seq); + } else { + int i = 0; // NOP, for breakpoint + } + } else if (nItemID >=0 && nItemID <=6) { //TODO: Yuuk ! UGLY ! This is only a temporary workaround ! //m_lastOpenPopupMenu == NULL && + + switch (nItemID) { + case 0: + seq = AudioSequencePlayer::playContainerPromptFromId("file", false, seq); + break; + case 1: + seq = AudioSequencePlayer::playContainerPromptFromId("view", false, seq); + break; + case 2: + seq = AudioSequencePlayer::playContainerPromptFromId("play", false, seq); + break; + case 3: + seq = AudioSequencePlayer::playContainerPromptFromId("navigate", false, seq); + break; + case 4: + seq = AudioSequencePlayer::playContainerPromptFromId("bookmarks", false, seq); + break; + case 5: + seq = AudioSequencePlayer::playContainerPromptFromId("info", false, seq); + break; + case 6: + seq = AudioSequencePlayer::playContainerPromptFromId("help", false, seq); + break; + //default: seq = new AudioSequence(); + } + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); + + if (p_prompt_ != NULL) + { + AudioSequencePlayer::fillSequenceContents(seq, p_prompt_); + } + else { + if (seq != NULL) { + seq->append(_T("menu")); + } + } + + if (seq != NULL) { + AudioSequencePlayer::Instance()->Play(seq); + } + } + } + else + { + s.Format(_T("Item %d is selected"), nItemID); //DAN_MENU_DEBUG + TRACE(s); + + + amis::RecentBooks* books = theApp.getRecentBooks(); + int nRecentBooks = (books ? books->getNumberOfEntries() : 0); + + if (nRecentBooks > 0 && (nItemID >= BOOK_BASE_ID && nItemID < BOOK_BASE_ID + nRecentBooks)) + { + int idx = nItemID - BOOK_BASE_ID; + + amis::RecentBookEntry* p_entry = theApp.getRecentBooks()->getEntry(idx); + + //DanTodo: surely, there must be a way to get a title instead of rendering the URL with TTS ??! (see bookmark methd commented below) + string str = p_entry->mPath.get_url(); + seq->append(A2T(str.c_str())); + AudioSequencePlayer::Instance()->Play(seq); + + //CString cstr_filepath = A2T(filepath.c_str()); + + /* + amis::io::BookmarksFileIO bmk_file_io; + bmk_file_io.readFromFile(&p_entry->mPath); + + amis::MediaGroup* p_title = NULL; + p_title = bmk_file_io.getBookmarkSet()->getTitle(); + + if (p_title != NULL) + { + if (p_title->hasAudio() == true) + { + amis::AudioNode* p_audio = NULL; + p_audio = (amis::AudioNode*)p_title->getAudio(0)->clone(); + if (p_audio != NULL) + { + seq->append(p_audio); + AudioSequencePlayer::Instance()->Play(seq); + + } + + + }else if (p_title->hasText() == true) + { + amis::TextNode* p_text = NULL; + p_text = p_title->getText(); + if (p_text != NULL) + { + wstring str = p_text->getTextString(); + seq->append(str.c_str()); + AudioSequencePlayer::Instance()->Play(seq); + } + + + } + + } */ + } + else + if (nItemID >= BOOKMARKS_BASE_ID && nItemID <= + BOOKMARKS_BASE_ID + MAX_ANYTHING) + { + int idx = nItemID - BOOKMARKS_BASE_ID; + + + //amis::dtb::BookmarkSet* p_bmks = amis::dtb::DtbWithHooks::Instance()->getBookmarks(); + //amis::dtb::PositionMark* p_mark = p_bmks->getItem(idx); + + amis::MediaGroup* p_note = amis::dtb::DtbWithHooks::Instance()->getBookmarks()->getItem(idx)->mpNote; + if (p_note!=NULL) + { + + if (p_note->hasAudio() == true) + { + amis::AudioNode* p_audio = NULL; + p_audio = p_note->getAudio(0); + if (p_audio != NULL) + { + seq->append(p_audio); + AudioSequencePlayer::Instance()->Play(seq); + } + } else if (p_note->hasText() == true) + { + //DanTodo: bmks generally have no audio, so how can we use the existing (open) book content to render audio voice here ? + amis::TextNode* p_text = NULL; + p_text = p_note->getText(); + if (p_text != NULL) + { + wstring str = p_text->getTextString(); + seq->append(str.c_str()); + AudioSequencePlayer::Instance()->Play(seq); + } + + + } + + } + } else + + if (nItemID > SECTION_DEPTH_BASE_ID && nItemID <= (SECTION_DEPTH_BASE_ID + MAX_ANYTHING)) + { + string strPrompt; + switch (nItemID) { + case (SECTION_DEPTH_BASE_ID+1): { + strPrompt = "numeric_one"; + break; + } + case (SECTION_DEPTH_BASE_ID+2): { + strPrompt = "numeric_two"; + break; + } + case (SECTION_DEPTH_BASE_ID+3): { + strPrompt = "numeric_three"; + break; + } + case (SECTION_DEPTH_BASE_ID+4): { + strPrompt = "numeric_four"; + break; + } + case (SECTION_DEPTH_BASE_ID+5): { + strPrompt = "numeric_five"; + break; + } + case (SECTION_DEPTH_BASE_ID+6): { + strPrompt = "numeric_six"; + break; + } + case (SECTION_DEPTH_BASE_ID+7): { + strPrompt = "numeric_seven"; + break; + } + case (SECTION_DEPTH_BASE_ID+8): { + strPrompt = "numeric_eight"; + break; + } + case (SECTION_DEPTH_BASE_ID+9): { + strPrompt = "numeric_nine"; + break; + } + } + if (!strPrompt.empty()) { + //seq->append(strPrompt.c_str()); TEST ONLY + + delete seq; + seq = AudioSequencePlayer::playPromptItemFromStringId(strPrompt, false, NULL); + + AudioSequencePlayer::Instance()->Play(seq); + } + + } + + + /* + + //is this a view menu item (sections/prodnotes/etc) + else if (nItemID >= VIEW_MENU_BASE_ID && nItemID < VIEW_MENU_BASE_ID + + MenuManip::Instance()->getNumberOfViewMenuAdditions()) + { + //first item in the list is always "sections" + if (nItemID == VIEW_MENU_BASE_ID) + { + //playPrompt("sections"); + theApp.playPromptItemFromStringId("sections"); + } + //then "pages", if exists + else if (nItemID == VIEW_MENU_BASE_ID + 1 && + NavParse::Instance()->getNavModel()->hasPages() == true) + { + //playPrompt("pages"); + theApp.playPromptItemFromStringId("pages"); + } + else + { + //otherwise it's a nav list so ask NavParse for the nav list ID + //subtract 1 because the menu items include sections, pages, navlists + //we want just the index relative to nav lists + int idx = nItemID - VIEW_MENU_BASE_ID - 1; + + //adjust again by subtracting 1 if there are pages in this book + if (NavParse::Instance()->getNavModel()->hasPages() == true) + { + idx--; + } + + std::string item_id = NavParse::Instance()->getNavModel()->getNavList(idx)->getId(); + + if (item_id.compare("prodnote") == 0 || + item_id.compare("optional-prodnote") == 0 ) + { + //playPrompt("prodnotes"); + theApp.playPromptItemFromStringId("prodnotes"); + } + else if (item_id.compare("sidebar") == 0) + { + //playPrompt("sidebars"); + theApp.playPromptItemFromStringId("sidebars"); + } + else if (item_id.compare("footnote") == 0 || + item_id.compare("noteref") == 0) + { + //playPrompt("footnotes"); + theApp.playPromptItemFromStringId("noterefs"); + } + else + { + //we can't identify it, so read its name with TTS + theApp.playPromptFromUiId(nItemID); + } + } + + } + else + */ + + else + { + AudioSequencePlayer::playPromptFromUiId(nItemID, true, seq); + } + } + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |