Thread: [Amis-vcs] SF.net SVN: amis: [2149] branches/amis3
Brought to you by:
julienq,
marisademeglio
From: <mar...@us...> - 2007-09-15 06:01:43
|
Revision: 2149 http://amis.svn.sourceforge.net/amis/?rev=2149&view=rev Author: marisademeglio Date: 2007-09-14 23:01:42 -0700 (Fri, 14 Sep 2007) Log Message: ----------- Go to page works Modified Paths: -------------- branches/amis3/AmisCore/src/dtb/nav/PageList.cpp branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h branches/amis3/AmisGuiMFC2/include/gui/MmView.h branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/MmDoc.cpp branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp Modified: branches/amis3/AmisCore/src/dtb/nav/PageList.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/nav/PageList.cpp 2007-09-14 08:44:15 UTC (rev 2148) +++ branches/amis3/AmisCore/src/dtb/nav/PageList.cpp 2007-09-15 06:01:42 UTC (rev 2149) @@ -79,14 +79,8 @@ } } - if (b_found == true) - { - return (PageTarget*)this->getAtIndex(i); - } - else - { - return NULL; - } + if (b_found == true) return (PageTarget*)this->getAtIndex(i); + else return NULL; } void amis::dtb::nav::PageList::print() Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-09-14 08:44:15 UTC (rev 2148) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-09-15 06:01:42 UTC (rev 2149) @@ -204,6 +204,9 @@ RelativePath=".\include\gui\dialogs\AmisFileDialog.h"> </File> <File + RelativePath=".\include\gui\dialogs\GoToPageDialog.h"> + </File> + <File RelativePath=".\include\gui\dialogs\OpenUrlDialog.h"> </File> <File @@ -347,6 +350,9 @@ RelativePath=".\src\gui\dialogs\AmisFileDialog.cpp"> </File> <File + RelativePath=".\src\gui\dialogs\GoToPageDialog.cpp"> + </File> + <File RelativePath=".\src\gui\dialogs\OpenUrlDialog.cpp"> </File> <File Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-09-14 08:44:15 UTC (rev 2148) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-09-15 06:01:42 UTC (rev 2149) @@ -76,6 +76,7 @@ afx_msg void OnSkipInfo(); afx_msg void OnAddBookmark(); afx_msg void OnSelectBookmark(UINT); + afx_msg void OnGoToPage(); protected: HMENU m_hMDIMenu; HACCEL m_hMDIAccel; Modified: branches/amis3/AmisGuiMFC2/include/gui/MmView.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MmView.h 2007-09-14 08:44:15 UTC (rev 2148) +++ branches/amis3/AmisGuiMFC2/include/gui/MmView.h 2007-09-15 06:01:42 UTC (rev 2149) @@ -50,7 +50,7 @@ void SetMMDocument(LPCTSTR lpszPathName, bool autostart); void skipOptionsChanged(); void ScheduleReplaceDoc(std::string& url); - bool LocateWelcomeDoc(LPCTSTR rpath); + //bool LocateWelcomeDoc(LPCTSTR rpath); ambulant::net::datasource_factory *getDatasourceFactory(); bool expectingAudio() const { return m_expecting_audio; } UINT_PTR m_timer_id; @@ -100,16 +100,16 @@ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnFocusAdvance(); afx_msg void OnFocusActivate(); - afx_msg void OnViewSource(); - afx_msg void OnUpdateViewSource(CCmdUI *pCmdUI); - afx_msg void OnUpdateViewLog(CCmdUI *pCmdUI); - afx_msg void OnViewLog(); + //afx_msg void OnViewSource(); + //afx_msg void OnUpdateViewSource(CCmdUI *pCmdUI); + //afx_msg void OnUpdateViewLog(CCmdUI *pCmdUI); + //afx_msg void OnViewLog(); afx_msg LRESULT OnSetClientRect(WPARAM wParam, LPARAM lParam); - afx_msg void OnOpenFilter(); - afx_msg void OnViewFilter(); - afx_msg void OnUpdateViewFilter(CCmdUI *pCmdUI); + //afx_msg void OnOpenFilter(); + //afx_msg void OnViewFilter(); + //afx_msg void OnUpdateViewFilter(CCmdUI *pCmdUI); afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnUpdateOpenFilter(CCmdUI *pCmdUI); + //afx_msg void OnUpdateOpenFilter(CCmdUI *pCmdUI); #if 0 afx_msg void OnViewAutoplay(); void OnUpdateViewAutoplay(CCmdUI *pCmdUI); @@ -117,8 +117,8 @@ afx_msg BOOL OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult); virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const; - afx_msg void OnHelpWelcome(); - afx_msg void OnUpdateHelpWelcome(CCmdUI *pCmdUI); + //afx_msg void OnHelpWelcome(); + //afx_msg void OnUpdateHelpWelcome(CCmdUI *pCmdUI); afx_msg LRESULT OnReplaceDoc(WPARAM wParam, LPARAM lParam); // Daisy local navigation support Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-14 08:44:15 UTC (rev 2148) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-15 06:01:42 UTC (rev 2149) @@ -40,6 +40,8 @@ #include "gui/dialogs/AboutDialog.h" #include "gui/dialogs/OpenUrlDialog.h" #include "gui/dialogs/SkipDialog.h" +#include "gui/dialogs/GoToPageDialog.h" +#include "dtb/nav/NavModel.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -71,6 +73,7 @@ ON_COMMAND(ID_MENU_INFO_SKIP, OnSkipInfo) ON_COMMAND(ID_MENU_BMK_ADD, OnAddBookmark) ON_COMMAND_RANGE(BOOKMARKS_BASE_ID, BOOKMARKS_BASE_ID + MAX_ANYTHING, OnSelectBookmark) + ON_COMMAND(ID_MENU_NAV_GOTOPAGE, OnGoToPage) END_MESSAGE_MAP() @@ -350,17 +353,19 @@ amis::gui::dialogs::OpenUrlDialog dlg; string str_url = ""; - if (dlg.DoModal() == IDOK) str_url = T2A(dlg.getUrl()); - - ambulant::net::url book_url = ambulant::net::url::from_url(str_url); - if (amis::dtb::DtbWithHooks::Instance()->open(&book_url, &very_temporary_bookmarks_dir)) + if (dlg.DoModal() == IDOK) { - amis::dtb::DtbWithHooks::Instance()->startReading(true); + str_url = T2A(dlg.getUrl()); + ambulant::net::url book_url = ambulant::net::url::from_url(str_url); + if (amis::dtb::DtbWithHooks::Instance()->open(&book_url, &very_temporary_bookmarks_dir)) + { + amis::dtb::DtbWithHooks::Instance()->startReading(true); + } + else + { + AfxMessageBox(_T("Error opening book")); + } } - else - { - AfxMessageBox(_T("Error opening book")); - } } void CAmisGuiMFC2App::OnSkipInfo() @@ -384,4 +389,21 @@ idx = id - BOOKMARKS_BASE_ID; amis::dtb::DtbWithHooks::Instance()->loadBookmark(idx); +} + +void CAmisGuiMFC2App::OnGoToPage() +{ + amis::gui::dialogs::GoToPageDialog dialog; + if (dialog.DoModal() == IDOK) + { + wstring page_number = dialog.getPageNumber(); + amis::dtb::nav::NavModel* p_nav_model = NULL; + p_nav_model = amis::dtb::DtbWithHooks::Instance()->getNavModel(); + if (p_nav_model->hasPages() && p_nav_model->getPageList() != NULL) + { + amis::dtb::nav::PageTarget* p_page = NULL; + p_page = p_nav_model->getPageList()->findPage(page_number); + if (p_page) amis::dtb::DtbWithHooks::Instance()->loadNavNode(p_page); + } + } } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/MmDoc.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MmDoc.cpp 2007-09-14 08:44:15 UTC (rev 2148) +++ branches/amis3/AmisGuiMFC2/src/gui/MmDoc.cpp 2007-09-15 06:01:42 UTC (rev 2149) @@ -50,7 +50,6 @@ // #include "stdafx.h" -//#include "AmbulantPlayer.h" #include "gui/MmDoc.h" #include "gui/MmView.h" @@ -76,9 +75,7 @@ MmDoc::MmDoc() { ASSERT(MainWndParts::Instance()->mpMmDoc == NULL); - MainWndParts::Instance()->mpMmDoc = this; - // TODO: add one-time construction code here m_autostart = false; } @@ -88,11 +85,7 @@ BOOL MmDoc::OnNewDocument() { - if (!CDocument::OnNewDocument()) - return FALSE; - - // TODO: add reinitialization code here - // (SDI documents will reuse this document) + if (!CDocument::OnNewDocument()) return FALSE; return TRUE; } @@ -133,12 +126,9 @@ BOOL MmDoc::OnOpenDocument(LPCTSTR lpszPathName) { - //if (!CDocument::OnOpenDocument(lpszPathName)) - // return FALSE; - - // TODO: Add your specialized creation code here POSITION pos = GetFirstViewPosition(); - if(pos != NULL) { + if(pos != NULL) + { CView* pView = GetNextView(pos); ASSERT_VALID(pView); ((MmView*)pView)->SetMMDocument(lpszPathName, m_autostart); @@ -146,20 +136,26 @@ return TRUE; } -void MmDoc::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU) { - if(_tcsstr(lpszPathName, _T("://")) != 0) { +void MmDoc::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU) +{ + if(_tcsstr(lpszPathName, _T("://")) != 0) + { // seems a url m_strPathName = "URL"; m_bEmbedded = FALSE; SetTitle(_T("URL")); - } else { + } + else + { CDocument::SetPathName(lpszPathName, bAddToMRU); } } -void MmDoc::StartPlayback() { +void MmDoc::StartPlayback() +{ POSITION pos = GetFirstViewPosition(); - if(pos != NULL) { + if(pos != NULL) + { CView* pView = GetNextView(pos); ASSERT_VALID(pView); ((MmView*)pView)->OnFilePlay(); Modified: branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2007-09-14 08:44:15 UTC (rev 2148) +++ branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2007-09-15 06:01:42 UTC (rev 2149) @@ -22,8 +22,6 @@ #include "stdafx.h" #include "ambulant/gui/dx/html_bridge.h" -//AMIS removed this -//#include "AmbulantPlayer.h" #include "gui/MainFrm.h" #include "gui/MmDoc.h" @@ -75,7 +73,8 @@ const TCHAR log_name[] = TEXT("amlog.txt"); #ifdef _DEBUG -class logwindow_atltrace : public ambulant::lib::ostream { +class logwindow_atltrace : public ambulant::lib::ostream +{ bool is_open() const {return true;} void close() {} int write(const unsigned char *buffer, int nbytes) {return write("ostream use of buffer, size not implemented for MFC");} @@ -86,14 +85,14 @@ #endif //this function copied from AmbulantPlayer project and modified for AMIS -void -set_status_line(const char *message) +void set_status_line(const char *message) { if (MainWndParts::Instance()->mpMainFrame) MainWndParts::Instance()->mpMainFrame->PostMessage(WM_APP, 0, (LPARAM)message); } -static std::string get_log_filename() { +static std::string get_log_filename() +{ TCHAR buf[_MAX_PATH]; GetModuleFileName(NULL, buf, _MAX_PATH); TCHAR *p1 = text_strrchr(buf,'\\'); @@ -104,7 +103,8 @@ } #endif // WITHOUT_LOG_WINDOW -static TCHAR *get_directory(const TCHAR *fn) { +static TCHAR *get_directory(const TCHAR *fn) +{ static TCHAR buf[_MAX_PATH]; buf[0] = 0; text_strcat(buf, fn); @@ -119,7 +119,6 @@ #endif using namespace ambulant; -//#define AM_PLAYER_DG #ifdef AM_PLAYER_DG typedef gui::dg::dg_player dg_or_dx_player; @@ -133,7 +132,8 @@ static HWND s_hwnd; // A class with callbacks, also instantiated once -class my_player_callbacks : public gui_callbacks { +class my_player_callbacks : public gui_callbacks +{ public: HWND new_os_window(); void destroy_os_window(HWND hwnd); @@ -143,25 +143,26 @@ my_player_callbacks s_player_callbacks; -HWND my_player_callbacks::new_os_window() { +HWND my_player_callbacks::new_os_window() +{ // Return the handle of the single instance for now // This means paint bits of the new window // to the single instance return s_hwnd; } -void my_player_callbacks::destroy_os_window(HWND hwnd) { +void my_player_callbacks::destroy_os_window(HWND hwnd) +{ // none for now; keep the single instance } -html_browser * -my_player_callbacks::new_html_browser(int left, int top, int width, int height) +html_browser* my_player_callbacks::new_html_browser(int left, int top, int width, int height) { return ::new_html_browser(left, top, width, height); } -SIZE -my_player_callbacks::get_default_size() { +SIZE my_player_callbacks::get_default_size() +{ SIZE size; size.cx = 640; size.cy = 480; @@ -169,8 +170,8 @@ } -static dg_or_dx_player* -create_player_instance(const net::url& u, common::player_feedback *feedback) { +static dg_or_dx_player* create_player_instance(const net::url& u, common::player_feedback *feedback) +{ dg_or_dx_player *rv = new dg_or_dx_player(s_player_callbacks, feedback, u); amis::io::UrlInputSource::SetDatasourceFactory(rv->get_datasource_factory()); return rv; @@ -181,44 +182,20 @@ CWnd* topView = NULL; - // MmView - +// MmView IMPLEMENT_DYNCREATE(MmView, CView) - BEGIN_MESSAGE_MAP(MmView, CView) ON_WM_DESTROY() ON_COMMAND(ID_AMBULANT_PLAY, OnFilePlay) - //AMIS ON_UPDATE_COMMAND_UI(ID_FILE_PLAY, OnUpdateFilePlay) - //AMIS ON_COMMAND(ID_FILE_PAUSE, OnFilePause) - //AMIS ON_UPDATE_COMMAND_UI(ID_FILE_PAUSE, OnUpdateFilePause) ON_WM_TIMER() ON_WM_CREATE() ON_WM_LBUTTONDOWN() ON_WM_CHAR() - //AMIS ON_COMMAND(ID_PLAY_ADVANCEFOCUS, OnFocusAdvance) - //AMIS ON_COMMAND(ID_PLAY_ACTIVATEFOCUS, OnFocusActivate) - //AMIS ON_COMMAND(ID_VIEW_SOURCE, OnViewSource) - //AMIS ON_UPDATE_COMMAND_UI(ID_VIEW_SOURCE, OnUpdateViewSource) - //AMIS ON_UPDATE_COMMAND_UI(ID_VIEW_LOG, OnUpdateViewLog) - //AMIS ON_COMMAND(ID_VIEW_LOG, OnViewLog) ON_MESSAGE(WM_SET_CLIENT_RECT, OnSetClientRect) - //AMIS ON_COMMAND(ID_VIEW_TESTS, OnOpenFilter) - //AMIS ON_COMMAND(ID_VIEW_FILTER, OnViewFilter) - //AMIS ON_UPDATE_COMMAND_UI(ID_VIEW_FILTER, OnUpdateViewFilter) ON_WM_MOUSEMOVE() - //AMIS ON_UPDATE_COMMAND_UI(ID_VIEW_TESTS, OnUpdateOpenFilter) - //AMIS ON_COMMAND(ID_VIEW_AUTOPLAY, OnViewAutoplay) - //AMIS ON_UPDATE_COMMAND_UI(ID_VIEW_AUTOPLAY, OnUpdateViewAutoplay) - //AMIS ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify) - //AMIS ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify) - //AMIS ON_COMMAND(ID_HELP_WELCOME, OnHelpWelcome) - //AMIS ON_UPDATE_COMMAND_UI(ID_HELP_WELCOME, OnUpdateHelpWelcome) ON_MESSAGE(WM_REPLACE_DOC, OnReplaceDoc) END_MESSAGE_MAP() - -// MmView construction/destruction - MmView::MmView() { #ifndef WITHOUT_LOG_WINDOW @@ -232,7 +209,6 @@ m_recent_par_node = NULL; m_expecting_audio = false; m_previous_in_progress = false; -// lib::logger::get_logger()->set_show_message(log_show_message); ambulant::common::preferences *prefs = ambulant::common::preferences::get_preferences(); prefs->m_welcome_seen = true; @@ -279,30 +255,22 @@ BOOL MmView::PreCreateWindow(CREATESTRUCT& cs) { - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs cs.style |= WS_CLIPCHILDREN; // reduce flicker return CView::PreCreateWindow(cs); } -// MmView drawing - void MmView::OnDraw(CDC* pDC) { MmDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); - if (!pDoc) - return; + if (!pDoc) return; // TODO: add draw code for native data here - if(player) - player->redraw(m_hWnd, pDC->m_hDC); - + if(player) player->redraw(m_hWnd, pDC->m_hDC); } // MmView diagnostics - #ifdef _DEBUG void MmView::AssertValid() const { @@ -325,8 +293,7 @@ // MmView message handlers int MmView::OnCreate(LPCREATESTRUCT lpCreateStruct) { - if (CView::OnCreate(lpCreateStruct) == -1) - return -1; + if (CView::OnCreate(lpCreateStruct) == -1) return -1; m_timer_id = SetTimer(1, 500, 0); @@ -334,25 +301,7 @@ s_hwnd = GetSafeHwnd(); ModifyStyle(0, WS_CLIPCHILDREN); // reduce flicker - //Commented out for AMIS integration - /*if(LocateWelcomeDoc(TEXT("..\\..\\Extras\\Welcome\\Welcome.smil")) || - LocateWelcomeDoc(TEXT("Extras\\Welcome\\Welcome.smil")) || - LocateWelcomeDoc(TEXT("Welcome.smil"))){;} - */ - - PostMessage(WM_SET_CLIENT_RECT, - common::default_layout_width, ambulant::common::default_layout_height); - -//modified for AMIS - //CWinApp* pApp = AfxGetApp(); - //CString val = pApp->GetProfileString(_T("Settings"), _T("Welcome")); - if (1) { //if(val.IsEmpty()) { - // first time; write the string and play welcome - //pApp->WriteProfileString(_T("Settings"), _T("Welcome"), _T("1")); - if(!m_welcomeDocFilename.IsEmpty()); - //PostMessage(WM_COMMAND, ID_HELP_WELCOME); - } - + PostMessage(WM_SET_CLIENT_RECT, common::default_layout_width, ambulant::common::default_layout_height); return 0; } @@ -363,7 +312,8 @@ void MmView::OnDestroy() { - if(player) { + if(player) + { CAmisHtmlView *hv = MainWndParts::Instance()->mpHtmlView; if (hv) hv->smilPlayerDeleted(); player->stop(); @@ -375,16 +325,19 @@ CView::OnDestroy(); } -void MmView::ScheduleReplaceDoc(std::string& urlstr) { +void MmView::ScheduleReplaceDoc(std::string& urlstr) +{ PostMessage(WM_REPLACE_DOC, 1, (LPARAM)(new std::string(urlstr))); } -void MmView::SetMMDocument(LPCTSTR lpszPathName, bool autostart) { +void MmView::SetMMDocument(LPCTSTR lpszPathName, bool autostart) +{ USES_CONVERSION; dg_or_dx_player *dummy = player; player = 0; m_recent_media_node = NULL; - if(dummy) { + if(dummy) + { CAmisHtmlView *hv = MainWndParts::Instance()->mpHtmlView; if (hv) hv->smilPlayerDeleted(); dummy->stop(); @@ -402,16 +355,20 @@ net::url u; TCHAR path[_MAX_PATH]; - if (is_local_filename) { + if (is_local_filename) + { TCHAR *pFilePart = 0; GetFullPathName(lpszPathName, MAX_PATH, path, &pFilePart); u = net::url::from_filename(T2CA(path)); - } else { + } + else + { _tcscpy(path, lpszPathName); u = net::url::from_url(T2CA(path)); } - if (!u.is_absolute()) { + if (!u.is_absolute()) + { lib::logger::get_logger()->error("Cannot play from non-absolute pathname: %s", lpszPathName); return; } @@ -425,18 +382,17 @@ player = dummy; skipOptionsChanged(); set_status_line("Ready"); - if (m_previous_in_progress) { + if (m_previous_in_progress) + { // Goto last node lastPhrase(); m_previous_in_progress = false; } - if(autostart || m_autoplay) - PostMessage(WM_COMMAND, ID_AMBULANT_PLAY); + if(autostart || m_autoplay) PostMessage(WM_COMMAND, ID_AMBULANT_PLAY); } void MmView::skipOptionsChanged() { - //TODO: point to right custom test location /* amis::dtb::nav::NavModel* p_nav_model = NULL;//amis::dtb::Dtb::getNavModel(); assert(p_nav_model); @@ -464,7 +420,8 @@ /*DBG*/static in_here = 0; /*DBG*/assert(!in_here); /*DBG*/in_here++; - if(player) { + if(player) + { player->play(); needs_done_redraw = true; InvalidateRect(NULL); @@ -498,7 +455,8 @@ { // XXXX Jack: This seems a very funny way to get a final redraw... CView::OnTimer(nIDEvent); - if(player && needs_done_redraw && player->is_stop_active()) { + if(player && needs_done_redraw && player->is_stop_active()) + { player->on_done(); InvalidateRect(NULL); PostMessage(WM_INITMENUPOPUP,0, 0); @@ -516,15 +474,20 @@ void MmView::OnMouseMove(UINT nFlags, CPoint point) { #ifdef AMIS_LATER - if(player) { + if(player) + { int new_cursor_id = player->get_cursor(point.x, point.y, GetSafeHwnd()); if(new_cursor_id>0) EnableToolTips(TRUE); else CancelToolTips(); - if(new_cursor_id != m_cursor_id) { + if(new_cursor_id != m_cursor_id) + { HCURSOR new_cursor = 0; - if(new_cursor_id == 0) { + if(new_cursor_id == 0) + { new_cursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW); - } else { + } + else + { new_cursor = AfxGetApp()->LoadCursor(IDC_CURSOR_HAND); } SetClassLongPtr(GetSafeHwnd(), GCLP_HCURSOR, HandleToLong(new_cursor)); @@ -535,7 +498,8 @@ CView::OnMouseMove(nFlags, point); } -void MmView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { +void MmView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) +{ if(player) player->on_char(nChar); CView::OnChar(nChar, nRepCnt, nFlags); } @@ -549,8 +513,9 @@ { if (player) player->on_focus_activate(); } - -void MmView::OnViewSource() { +/* +void MmView::OnViewSource() +{ USES_CONVERSION; CString cmd = TEXT("Notepad.exe "); std::string ustr = T2CA(LPCTSTR(m_curDocFilename)); @@ -561,14 +526,18 @@ cmd += u.get_file().c_str(); // XXXX Incorrect WinExec(T2CA(cmd), SW_SHOW); } - -void MmView::OnUpdateViewSource(CCmdUI *pCmdUI) { +*/ +/* +void MmView::OnUpdateViewSource(CCmdUI *pCmdUI) +{ USES_CONVERSION; bool b = player && !m_curDocFilename.IsEmpty() && net::url::from_url(T2CA(LPCTSTR(m_curDocFilename))).is_local_file(); pCmdUI->Enable(b?TRUE:FALSE); } - -void MmView::OnViewLog() { +*/ +/* +void MmView::OnViewLog() +{ #ifdef WITHOUT_LOG_WINDOW // Logging to file: open the file in notepad. TCHAR buf[_MAX_PATH]; @@ -582,19 +551,20 @@ WinExec((LPCSTR)(LPCTSTR)cmd, SW_SHOW); #else // Logging to a window: show the window. - if (m_logwindow == NULL) { - m_logwindow = CLogWindow::GetLogWindowSingleton(); - } + if (m_logwindow == NULL) m_logwindow = CLogWindow::GetLogWindowSingleton(); + m_logwindow->ShowWindow(SW_SHOW); #endif } - -void MmView::OnUpdateViewLog(CCmdUI *pCmdUI) { - //pCmdUI->Enable((player && !m_curDocFilename.IsEmpty())?TRUE:FALSE); +*/ +/* +void MmView::OnUpdateViewLog(CCmdUI *pCmdUI) +{ pCmdUI->Enable(TRUE); } - -LPARAM MmView::OnSetClientRect(WPARAM wParam, LPARAM lParam) { +*/ +LPARAM MmView::OnSetClientRect(WPARAM wParam, LPARAM lParam) +{ CFrameWnd *mainWnd = (CFrameWnd*) AfxGetMainWnd(); POINT pt = {0, 0}; // margins @@ -614,7 +584,8 @@ return 0; } -LPARAM MmView::OnReplaceDoc(WPARAM wParam, LPARAM lParam) { +LPARAM MmView::OnReplaceDoc(WPARAM wParam, LPARAM lParam) +{ USES_CONVERSION; if(lParam == 0) return 0; std::string *purlstr = (std::string *)lParam; @@ -622,8 +593,9 @@ delete purlstr; return 0; } - -void MmView::OnOpenFilter() { +/* +void MmView::OnOpenFilter() +{ USES_CONVERSION; BOOL bOpenFileDialog = TRUE; TCHAR lpszDefExt[] = TEXT("*.xml"); @@ -648,12 +620,14 @@ #endif } } - +*/ +/* void MmView::OnUpdateOpenFilter(CCmdUI *pCmdUI) { pCmdUI->Enable(TRUE); } - +*/ +/* void MmView::OnViewFilter() { USES_CONVERSION; @@ -663,11 +637,13 @@ WinExec(T2CA((LPCTSTR)cmd), SW_SHOW); } } - +*/ +/* void MmView::OnUpdateViewFilter(CCmdUI *pCmdUI) { pCmdUI->Enable(!m_curFilter.IsEmpty()); } +*/ #if 0 void MmView::OnViewAutoplay() @@ -691,7 +667,8 @@ UINT_PTR nID = pNMHDR->idFrom; CString strTipText; if(pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) || - pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) { + pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) + { std::string str = player->get_pointed_node_str(); strTipText.Format(_T("Anchor: %s"), str.c_str()); if(pNMHDR->code == TTN_NEEDTEXTA) @@ -704,12 +681,16 @@ return FALSE; } -INT_PTR MmView::OnToolHitTest(CPoint point, TOOLINFO* pTI) const { - if(player) { +INT_PTR MmView::OnToolHitTest(CPoint point, TOOLINFO* pTI) const +{ + if(player) + { int new_cursor_id = player->get_cursor(point.x, point.y, GetSafeHwnd()); - if(new_cursor_id > 0) { + if(new_cursor_id > 0) + { INT_PTR nHit = 1; // node id - if (pTI != NULL) { + if (pTI != NULL) + { pTI->hwnd = m_hWnd; pTI->uId = (UINT_PTR)m_hWnd; // hWndChild; pTI->uFlags |= TTF_IDISHWND; @@ -721,8 +702,9 @@ } return -1; // not found } - -bool MmView::LocateWelcomeDoc(LPCTSTR rpath) { +/* +bool MmView::LocateWelcomeDoc(LPCTSTR rpath) +{ TCHAR buf[_MAX_PATH]; GetModuleFileName(NULL, buf, _MAX_PATH); TCHAR *p1 = text_strrchr(buf,'\\'); @@ -734,35 +716,39 @@ WIN32_FIND_DATA fd; memset(&fd, 0, sizeof(WIN32_FIND_DATA)); HANDLE hFind = FindFirstFile(path, &fd); - if(hFind != INVALID_HANDLE_VALUE){ + if(hFind != INVALID_HANDLE_VALUE) + { FindClose(hFind); m_welcomeDocFilename = path; return true; } return false; } - +*/ +/* void MmView::OnHelpWelcome() { if(!m_welcomeDocFilename.IsEmpty()) SetMMDocument(m_welcomeDocFilename, true); } - +*/ +/* void MmView::OnUpdateHelpWelcome(CCmdUI *pCmdUI) { pCmdUI->Enable(!m_welcomeDocFilename.IsEmpty()); } - +*/ // Helper routine: find "phrase" for a given node: the most recent // ancestor that is the child of a <seq> or <body>. -static const ambulant::lib::node * -_curPhrase(const ambulant::lib::node *n) +static const ambulant::lib::node* _curPhrase(const ambulant::lib::node *n) { assert(n); const ambulant::lib::node *parent = n->up(); - while (parent) { + while (parent) + { std::string tag = parent->get_local_name(); - if (tag == "seq" || tag == "body") { + if (tag == "seq" || tag == "body") + { return n; } n = parent; @@ -773,7 +759,8 @@ void MmView::nextPhrase() { - if (!m_recent_media_node) { + if (!m_recent_media_node) + { TRACE("nextPhrase: m_recent_media_node==NULL, nowhere to go.\n"); return; } @@ -781,18 +768,22 @@ // Find the nearest ancestor that is a child of a <seq> const ambulant::lib::node *phrase = _curPhrase(m_recent_media_node); const ambulant::lib::node *next; - do { - if (!phrase) { + do + { + if (!phrase) + { TRACE("nextPhrase: no current phrase"); assert(player); player->stop(); return; } next = phrase->next(); - if (!next) { + if (!next) + { // We're apparently at the end of the parent <seq>. Up one level. const ambulant::lib::node *parent = phrase->up(); - if (!parent) { + if (!parent) + { // Need to go to next SMIL document. TRACE("nextPhrase: top-of-tree, stop playback\n"); assert(player); @@ -801,22 +792,26 @@ } phrase = _curPhrase(parent); } - } while(!next); + } + while(!next); TRACE("nextPhrase: goto_node(%s)\n", next->get_sig().c_str()); player->goto_node(next); } void MmView::prevPhrase() { - if (!m_recent_media_node) { + if (!m_recent_media_node) + { TRACE("prevPhrase: m_recent_media_node==NULL, nowhere to go.\n"); return; } // Find the nearest ancestor that is a child of a <seq> const ambulant::lib::node *phrase = _curPhrase(m_recent_media_node); const ambulant::lib::node *prev; - do { - if (!phrase) { + do + { + if (!phrase) + { TRACE("prevPhrase: no current phrase\n"); m_previous_in_progress = true; assert(player); @@ -824,10 +819,12 @@ return; } prev = phrase->previous(); - if (!prev) { + if (!prev) + { // We're apparently at the beginning of the parent <seq>. Up one level. const ambulant::lib::node *parent = phrase->up(); - if (!parent) { + if (!parent) + { // Need to go to previous SMIL document. TRACE("prevPhrase: top-of-tree, stop playback, handle in upper layer\n"); m_previous_in_progress = true; @@ -837,11 +834,13 @@ } phrase = _curPhrase(parent); } - } while(!prev); + } + while(!prev); // Now we need to find the last child of prev. Go down, and find // the phrase for that node. const ambulant::lib::node *ch = prev->get_last_child(); - while (ch) { + while (ch) + { prev = ch; ch = prev->get_last_child(); } @@ -861,7 +860,8 @@ const ambulant::lib::node *ch = root->get_last_child(); const ambulant::lib::node *prev; assert(ch); - while (ch) { + while (ch) + { prev = ch; ch = prev->get_last_child(); } @@ -888,8 +888,7 @@ nextPhrase(); } -ambulant::net::datasource_factory * -MmView::getDatasourceFactory() +ambulant::net::datasource_factory* MmView::getDatasourceFactory() { if (!player) return NULL; return player->get_datasource_factory(); @@ -913,7 +912,8 @@ lib::node *body = root->get_first_child("body"); assert(body); lib::node *s = body->down(); - while (s) { + while (s) + { const char *dur_str = s->get_attribute("dur"); #ifdef AMBULANT_SEEK_WORKAROUND if (dur_str) @@ -927,11 +927,14 @@ // with systemComponent. lib::node::iterator it; lib::node::iterator end = root->end(); - for (it=root->begin(); it!=end; it++) { - if ((*it).first) { // Only do something on inward iteration + for (it=root->begin(); it!=end; it++) + { + if ((*it).first) + { // Only do something on inward iteration lib::node *n = (*it).second; const char *teststr = n->get_attribute("system-required"); - if (teststr) { + if (teststr) + { n->set_attribute("systemComponent", teststr); n->del_attribute("system-required"); } @@ -958,7 +961,7 @@ return; } - CAmisGuiMFC2App* pApp = (CAmisGuiMFC2App *) AfxGetApp(); + CAmisGuiMFC2App* pApp = (CAmisGuiMFC2App*) AfxGetApp(); // pApp->setPlayPauseState(false); if (m_previous_in_progress) { @@ -973,7 +976,7 @@ } } -void MmView::node_started(const ambulant::lib::node *n) +void MmView::node_started(const ambulant::lib::node* n) { // Note by Jack: this routine makes a mess of unicode, mbcs and such. USES_CONVERSION; @@ -1024,10 +1027,3 @@ } - -/*BOOL MmView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) -{ - // TODO: Add your specialized code here and/or call the base class - - return __super::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext); -}*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-17 07:21:45
|
Revision: 2152 http://amis.svn.sourceforge.net/amis/?rev=2152&view=rev Author: marisademeglio Date: 2007-09-17 00:21:46 -0700 (Mon, 17 Sep 2007) Log Message: ----------- New mostly untested, un-hooked-up code to do contrast and font changes entirely with CSS. Did a bit of code cleanup here and there to improve stylistic consistency. Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h branches/amis3/AmisGuiMFC2/include/gui/HtmlView.h branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp Added Paths: ----------- branches/amis3/bin/settings/amis-contrast.css branches/amis3/bin/settings/amis-default.css branches/amis3/bin/settings/font1.css branches/amis3/bin/settings/font2.css branches/amis3/bin/settings/font3.css branches/amis3/bin/settings/font4.css Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-09-15 21:03:11 UTC (rev 2151) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-09-17 07:21:46 UTC (rev 2152) @@ -77,6 +77,9 @@ afx_msg void OnAddBookmark(); afx_msg void OnSelectBookmark(UINT); afx_msg void OnGoToPage(); + afx_msg void OnIncreaseFontSize(); + afx_msg void OnResetFontSize(); + afx_msg void OnToggleContrast(); protected: HMENU m_hMDIMenu; HACCEL m_hMDIAccel; Modified: branches/amis3/AmisGuiMFC2/include/gui/HtmlView.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/HtmlView.h 2007-09-15 21:03:11 UTC (rev 2151) +++ branches/amis3/AmisGuiMFC2/include/gui/HtmlView.h 2007-09-17 07:21:46 UTC (rev 2152) @@ -19,13 +19,9 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#if !defined(AFX_AMISHTMLVIEW_H__8577ADA1_DCD3_499C_AB49_312286B915F4__INCLUDED_) -#define AFX_AMISHTMLVIEW_H__8577ADA1_DCD3_499C_AB49_312286B915F4__INCLUDED_ +#ifndef HTMLVIEW_H +#define HTMLVIEW_H -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - #include <afxhtml.h> #include "HtmlDoc.h" #include "ambulant/gui/dx/html_bridge.h" @@ -47,64 +43,45 @@ { class CAmisHtmlView : public CHtmlView { -protected: // create from serialization only - +protected: CAmisHtmlView(); - DECLARE_DYNCREATE(CAmisHtmlView) public: - CAmisHtmlView(const RECT& rect, CWnd* parent); + CAmisHtmlView(const RECT&, CWnd*); + virtual ~CAmisHtmlView(); -// Attributes -public: CAmisHtmlDoc* GetDocument(); + //returns a pointer to the stylesheet + IHTMLStyleSheet* applyStylesheet(ambulant::net::url*); + void removeStylesheet(IHTMLStyleSheet*); -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAmisHtmlView) - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual void OnDraw(CDC*); // overridden to draw this view + virtual BOOL PreCreateWindow(CREATESTRUCT&); virtual void OnInitialUpdate(); - virtual void OnDocumentComplete(LPCTSTR lpszURL); - virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); - virtual BOOL PreTranslateMessage(MSG* pMsg); - virtual void OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel); - protected: - virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView); - virtual HRESULT OnFilterDataObject(LPDATAOBJECT pDataObject, LPDATAOBJECT* ppDataObject); - virtual HRESULT OnShowContextMenu(DWORD dwID, LPPOINT ppt,LPUNKNOWN pcmdtReserved, LPDISPATCH pdispReserved); + virtual void OnDocumentComplete(LPCTSTR); + virtual BOOL Create(LPCTSTR, LPCTSTR, DWORD, const RECT&, CWnd*, UINT, CCreateContext* pContext = NULL); + virtual BOOL PreTranslateMessage(MSG*); + virtual void OnBeforeNavigate2(LPCTSTR, DWORD, LPCTSTR, CByteArray&, LPCTSTR, BOOL*); + virtual void OnNavigateComplete2(LPCTSTR); + virtual void CAmisHtmlView::OnNavigateError(LPCTSTR, LPCTSTR, DWORD, BOOL*); +protected: + virtual void OnActivateView(BOOL, CView*, CView*); + virtual HRESULT OnFilterDataObject(LPDATAOBJECT, LPDATAOBJECT*); + virtual HRESULT OnShowContextMenu(DWORD, LPPOINT, LPUNKNOWN, LPDISPATCH); virtual void OnEditCopy(); - //}}AFX_VIRTUAL + afx_msg int OnCreate(LPCREATESTRUCT); + DECLARE_MESSAGE_MAP() -// Implementation -public: - virtual ~CAmisHtmlView(); #ifdef _DEBUG virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; + virtual void Dump(CDumpContext&) const; #endif -// Generated message map functions -protected: - //{{AFX_MSG(CAmisHtmlView) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() + public: - virtual void OnNavigateComplete2(LPCTSTR strURL); - virtual void CAmisHtmlView::OnNavigateError( - LPCTSTR lpszURL, - LPCTSTR lpszFrame, - DWORD dwError, - BOOL *pbCancel - ); + //from: http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q241750 //new code // Operations @@ -165,9 +142,4 @@ } } } -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_AMISHTMLVIEW_H__8577ADA1_DCD3_499C_AB49_312286B915F4__INCLUDED_) +#endif Modified: branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2007-09-15 21:03:11 UTC (rev 2151) +++ branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2007-09-17 07:21:46 UTC (rev 2152) @@ -51,15 +51,11 @@ void increaseFontSize(); void toggleContrast(); - void loadBlankDocument(); - void highlightUriTarget(amis::TextNode*); void highlightUriTarget(std::string url); void redoPageColors(bool bDisableContrast=false); - wstring getCurrentText(); - void webDocumentComplete(); @@ -69,26 +65,28 @@ void highlightElementAtId(string); void pageContrastOn(); void pageContrastOff(); - void setPageContrast(string, string); void redoHighlightColors(); bool isElementInView(IHTMLElement*); IHTMLElement* GetElementFromId(string id, const GUID *iid); IHTMLDocument2* GetDoc(); -private: int mFontSize; - bool mb_flagWebDocWait; - bool mb_flagContrast; + bool mbWaitForDocumentLoad; + bool mbContrastOn; ambulant::net::url mCurrentUrl; string mTextElmId; wstring mCurrentElmText; - + vector<ambulant::net::url> mFontSizeCssFiles; IHTMLElement* pLastElm; + VARIANT mUnhighlightedBG; + VARIANT mUnhighlightedFG; + IHTMLStyleSheet* mpFontCss; + IHTMLStyleSheet* mpContrastCss; + IHTMLStyleSheet* mpDefaultCss; + ambulant::net::url mContrastCssUri; + ambulant::net::url mDefaultCssUri; - VARIANT mLastBG; - VARIANT mLastFG; - private: static TextRenderBrain* pinstance; Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-15 21:03:11 UTC (rev 2151) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-17 07:21:46 UTC (rev 2152) @@ -74,6 +74,7 @@ ON_COMMAND(ID_MENU_BMK_ADD, OnAddBookmark) ON_COMMAND_RANGE(BOOKMARKS_BASE_ID, BOOKMARKS_BASE_ID + MAX_ANYTHING, OnSelectBookmark) ON_COMMAND(ID_MENU_NAV_GOTOPAGE, OnGoToPage) + END_MESSAGE_MAP() Modified: branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2007-09-15 21:03:11 UTC (rev 2151) +++ branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2007-09-17 07:21:46 UTC (rev 2152) @@ -528,12 +528,10 @@ LPCTSTR lpszURL, LPCTSTR lpszFrame, DWORD dwError, - BOOL *pbCancel -) + BOOL *pbCancel) { } -//new code CString CAmisHtmlView::GetFullName() const { ASSERT(m_pBrowserApp != NULL); @@ -621,13 +619,56 @@ strResourceURL.Format(_T("res://%s/%s"), lpszModule, lpszResource); Navigate(strResourceURL, 0, 0, 0); } - else - bRetVal = FALSE; + else + bRetVal = FALSE; delete [] lpszModule; return bRetVal; } +IHTMLStyleSheet* CAmisHtmlView::applyStylesheet(ambulant::net::url* stylesheet) +{ + USES_CONVERSION; + + //copied this pDoc-getting code from another function in this file + HRESULT res; + // Check that we are indeed in threading mode +#ifdef _DEBUG + assert(CoInitialize(NULL) == S_FALSE); +#endif + if (stylesheet == NULL) return NULL; + + // First we need to get a pointer to the DOM + IDispatch *pDisp = GetHtmlDocument(); + if (pDisp == NULL) return NULL; + IHTMLDocument2 *pDoc; + res = pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pDoc); + if (!SUCCEEDED(res)) return NULL; + + BSTR css_path_bstr; + CString css_path_cstr = A2T(stylesheet->get_url().c_str()); + css_path_bstr = css_path_cstr.AllocSysString(); + + IHTMLStyleSheet* pStyleSheet; + //i'm really not sure of the best value for the 2nd parameter + //i tried 0 and 1, and neither makes a difference in how the + //stylesheet doesn't override the default styling (i would like it to override this) + res = pDoc->createStyleSheet(css_path_bstr, 0, &pStyleSheet); + SysFreeString(css_path_bstr); + + return pStyleSheet; +} + +void CAmisHtmlView::removeStylesheet(IHTMLStyleSheet* pStyleSheet) +{ + if (!pStyleSheet) return; + pStyleSheet->put_disabled(VARIANT_TRUE); + pStyleSheet->Release(); + pStyleSheet = NULL; +} + + + BOOL CAmisHtmlView::LoadFromResource(UINT nRes) { HINSTANCE hInstance = AfxGetResourceHandle(); @@ -648,9 +689,7 @@ delete [] lpszModule; return bRetVal; } -//end new code -//#ifdef AMIS_WITH_AMBULANT CAmisHtmlView *html_browser_imp::s_browser = NULL; html_browser_imp::html_browser_imp(int left, int top, int width, int height) @@ -662,20 +701,23 @@ rect.bottom = top + height; - if ( ! s_browser) { + if ( ! s_browser) + { // No browser yet. Create one with the right size and position. HtmlView* browser = new HtmlView(rect, topView); assert (browser != NULL); s_browser = browser; - } else { + } else + { // The browser was created earlier. Move and resize it, if needed. s_browser->MoveWindow(&rect, 1); } //AM_DBG lib::logger::get_logger()->debug("html_browser_imp::html_browser_imp(0x%x): LTWH=(%d,%d,%d,%d) m_browser=0x%x", this, left, top, width, height, m_browser); } -html_browser_imp::~html_browser_imp() { +html_browser_imp::~html_browser_imp() +{ //AM_DBG lib::logger::get_logger()->debug("html_browser_imp::~html_browser_imp(0x%x)", this); #if 0 ShowWindow(s_browser->m_hWnd, SW_HIDE); @@ -687,8 +729,8 @@ //KB s_browser = NULL; } -void -html_browser_imp::goto_url(std::string urlstr, ambulant::net::datasource_factory *df) { +void html_browser_imp::goto_url(std::string urlstr, ambulant::net::datasource_factory *df) +{ #ifdef HTML_LOAD_MANUALLY // First get the URL for the document (strip the fragment id) ambulant::net::url url = ambulant::net::url::from_url(urlstr); @@ -697,11 +739,13 @@ // Now check whether we've already loaded this document. If we have not // loaded it yet PrepareNavigateString will also remember the URL for - if (MainWndParts::Instance()->mpHtmlView->PrepareNavigateString(lpUrl)) { + if (MainWndParts::Instance()->mpHtmlView->PrepareNavigateString(lpUrl)) + { // We haven't got this document yet. Load it, and send the data to the widget. char *data = NULL; size_t datasize = 0; - if (!ambulant::net::read_data_from_url(url, df, &data, &datasize)) { + if (!ambulant::net::read_data_from_url(url, df, &data, &datasize)) + { MainWndParts::Instance()->mpHtmlView->PrepareNavigateString("about:blank"); return; } @@ -710,7 +754,8 @@ int titlepos = datastr.find("<title>"); if (titlepos == std::string::npos) titlepos = datastr.find("<TITLE>"); - if (titlepos != std::string::npos) { + if (titlepos != std::string::npos) + { std::string basetag = "<base href=\""; basetag += docurl; basetag += "\">"; @@ -728,8 +773,8 @@ MainWndParts::Instance()->mpHtmlView->PostMessage(WM_MY_HIGHLIGHTURITARGET, 0, (LPARAM)strcopy); } -void -html_browser_imp::hide() { +void html_browser_imp::hide() +{ // AM_DBG lib::logger::get_logger()->debug("html_browser_imp::hide(0x%x)", this); #if 0 // JACK hack was to comment this line out: it causes a deadlock between the main @@ -742,8 +787,8 @@ } -void -html_browser_imp::show() { +void html_browser_imp::show() +{ // AM_DBG lib::logger::get_logger()->debug("html_browser_imp::show(0x%x)", this); #if 0 ShowWindow(s_browser->m_hWnd, SW_SHOW); @@ -752,16 +797,15 @@ #endif } -void -html_browser_imp::redraw() { +void html_browser_imp::redraw() +{ // AM_DBG lib::logger::get_logger()->debug("html_browser_imp::redraw(0x%x)", this); ShowWindow(s_browser->m_hWnd, SW_SHOWNA); } -bool -html_browser_imp::uses_screen_reader() +bool html_browser_imp::uses_screen_reader() { return false; //return !MainWndParts::Instance()->mpMmView->expectingAudio(); } -//#endif + Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-09-15 21:03:11 UTC (rev 2151) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-09-17 07:21:46 UTC (rev 2152) @@ -24,6 +24,9 @@ #include "Preferences.h" #include "gui/TextRenderBrain.h" #include "gui/MainWndParts.h" +#include "util/FilePathTools.h" +#include "gui/AmisGuiMFC2.h" + #include <algorithm> #include <fstream> @@ -51,14 +54,30 @@ TextRenderBrain::TextRenderBrain() { mFontSize = 0; - mb_flagWebDocWait = false; - mb_flagContrast = false; + mbWaitForDocumentLoad = false; + mbContrastOn = false; pLastElm = NULL; - VariantInit(&mLastFG); - VariantInit(&mLastBG); + VariantInit(&mUnhighlightedFG); + VariantInit(&mUnhighlightedBG); mCurrentUrl = ambulant::net::url(); + + //TODO: replace with preferences CSS file list + string app_path = theApp.getAppPath(); + app_path += "/"; + + mFontSizeCssFiles.push_back(ambulant::net::url::from_filename(amis::util::FilePathTools::goRelativePath(app_path, "../settings/font1.css"))); + mFontSizeCssFiles.push_back(ambulant::net::url::from_filename(amis::util::FilePathTools::goRelativePath(app_path, "../settings/font2.css"))); + mFontSizeCssFiles.push_back(ambulant::net::url::from_filename(amis::util::FilePathTools::goRelativePath(app_path, "../settings/font3.css"))); + mFontSizeCssFiles.push_back(ambulant::net::url::from_filename(amis::util::FilePathTools::goRelativePath(app_path, "../settings/font4.css"))); + + mContrastCssUri = ambulant::net::url::from_filename(amis::util::FilePathTools::goRelativePath(app_path, "../settings/amis-contrast.css")); + mDefaultCssUri = ambulant::net::url::from_filename(amis::util::FilePathTools::goRelativePath(app_path, "../settings/amis-default.css")); + + mpFontCss = NULL; + mpContrastCss = NULL; + mpDefaultCss = NULL; } TextRenderBrain::~TextRenderBrain() @@ -70,11 +89,11 @@ highlightUriTarget(pText->getSrc()); } +//TODO: make sure this path comparison works for Japanese too void TextRenderBrain::highlightUriTarget(std::string urlstr) { USES_CONVERSION; ambulant::net::url url = ambulant::net::url::from_url(urlstr); - string text_elm_id = url.get_ref(); //make sure our document still exists; otherwise force a reload by @@ -85,8 +104,7 @@ bool sameDoc = url.same_document(mCurrentUrl); // If it's identical ignore it (the previous call may still be waiting // for the webDocumentComplete callback) - if (sameDoc && url.get_ref() == mCurrentUrl.get_ref()) - return; + if (sameDoc && url.get_ref() == mCurrentUrl.get_ref()) return; // If it's a different document: load it. if (!sameDoc) @@ -97,7 +115,7 @@ CString load_url(url.get_url().c_str()); mCurrentUrl = url; - mb_flagWebDocWait = true; + mbWaitForDocumentLoad = true; MainWndParts::Instance()->mpHtmlView->Navigate2(load_url, NULL, NULL); //now wait for webDocumentComplete @@ -114,41 +132,27 @@ // <audio src="clip1.wav"/> // <audio src="clip2.wav"/> //</seq></par> - if (text_elm_id == mTextElmId) - { -// AmisBrain::Instance()->textRenderDone(); - return; - } + if (text_elm_id == mTextElmId) return; //save the current ID mTextElmId = text_elm_id; - highlightElementAtId(mTextElmId); } - } void TextRenderBrain::webDocumentComplete() { - if (mb_flagWebDocWait == true) + if (mbWaitForDocumentLoad) { + mpDefaultCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&mDefaultCssUri); MainWndParts::Instance()->mpHtmlView->RedrawWindow(); + mbWaitForDocumentLoad = false; - mb_flagWebDocWait = false; - //refresh font size and contrast settings for the newly loaded page + if (mFontSize > 0) setFontSize(mFontSize); + if (mbContrastOn) pageContrastOn(); - if (mFontSize > 0) - { - setFontSize(mFontSize); - } - - if (mb_flagContrast == true) - { - pageContrastOn(); - } - highlightElementAtId(mCurrentUrl.get_ref()); } } @@ -157,12 +161,10 @@ { USES_CONVERSION; - if (pElm == NULL) - return; + if (!pElm) return; BSTR tag_name; pElm->get_tagName(&tag_name); - string str_tag_name = OLE2A(tag_name); //convert the string to lower case before doing a comparison @@ -183,7 +185,6 @@ CString temp_cstr(OLE2CW(attr_val.bstrVal)); LPCTSTR tmp; tmp = (LPCTSTR)temp_cstr; - mCurrentElmText.assign ((LPCTSTR)temp_cstr); } else @@ -192,28 +193,20 @@ BSTR inner_text; pElm->get_innerText(&inner_text); - CString temp_cstr(OLE2CW(inner_text)); LPCTSTR tmp; tmp = (LPCTSTR)temp_cstr; - mCurrentElmText.assign ((LPCTSTR)temp_cstr); } - } void TextRenderBrain::highlightElementAtId(string elm_id) { USES_CONVERSION; - if (elm_id.size() == 0) - { -// AmisBrain::Instance()->textRenderDone(); - return; - } + if (elm_id.size() == 0) return; IHTMLElement* pElm = NULL; - pElm = GetElementFromId(elm_id, 0); //save last-style data since we'll be replacing it before using it @@ -225,17 +218,17 @@ copy_last_bg.vt = VT_BSTR; copy_last_fg.vt = VT_BSTR; - copy_last_bg.bstrVal = mLastBG.bstrVal; - copy_last_fg.bstrVal = mLastFG.bstrVal; + copy_last_bg.bstrVal = mUnhighlightedBG.bstrVal; + copy_last_fg.bstrVal = mUnhighlightedFG.bstrVal; - if (pElm != NULL) + if (pElm) { IHTMLStyle* pStyle = NULL; //save the current style info before changing it pElm->get_style(&pStyle); - pStyle->get_backgroundColor(&mLastBG); - pStyle->get_color(&mLastFG); + pStyle->get_backgroundColor(&mUnhighlightedBG); + pStyle->get_color(&mUnhighlightedFG); //save the element text //this is just a convenient place for this function call, since it @@ -271,14 +264,11 @@ pStyle->put_color(var_fg); //reset the last highlighted element's style - if (pLastElm != NULL) + if (pLastElm) { IHTMLStyle* pLastStyle = NULL; - pLastElm->get_style(&pLastStyle); - //set the properties - //marisa, test removing border entirely pLastStyle->put_backgroundColor(copy_last_bg); pLastStyle->put_color(copy_last_fg); } @@ -291,13 +281,8 @@ pElm->scrollIntoView(v_bool); } - pLastElm = pElm; } - -// AmisBrain::Instance()->textRenderDone(); - - } void TextRenderBrain::toggleContrast() @@ -320,82 +305,41 @@ } */ - if (mb_flagContrast == true) pageContrastOff(); + if (mbContrastOn) pageContrastOff(); else pageContrastOn(); } void TextRenderBrain::pageContrastOn() { - mb_flagContrast = true; +/* mb_flagContrast = true; string fg, bg; fg = amis::Preferences::Instance()->mpPageFG->getAsHtmlColor(); bg = amis::Preferences::Instance()->mpPageBG->getAsHtmlColor(); setPageContrast(fg, bg); - +*/ + mbContrastOn = true; + mpContrastCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&mContrastCssUri); } void TextRenderBrain::pageContrastOff() { - mb_flagContrast = false; +/* mb_flagContrast = false; string fg, bg; fg = ""; bg = ""; setPageContrast(fg, bg); +*/ + mbContrastOn = false; + MainWndParts::Instance()->mpHtmlView->removeStylesheet(mpContrastCss); } -void TextRenderBrain::setPageContrast(string fg, string bg) -{ - //variants - VARIANT var_pagefg_color; - VARIANT var_pagebg_color; - - VariantInit(&var_pagefg_color); - VariantInit(&var_pagebg_color); - - //get the colors as chars - const char* pagefg_color = fg.c_str(); - const char* pagebg_color = bg.c_str(); - - //convert to variants - var_pagefg_color.vt = VT_BSTR; - var_pagefg_color.bstrVal = A2BSTR(pagefg_color); - - var_pagebg_color.vt = VT_BSTR; - var_pagebg_color.bstrVal = A2BSTR(pagebg_color); - - IHTMLElement* pBody = NULL; - IHTMLStyle* pStyle = NULL; - - IHTMLDocument2* doc = GetDoc(); - - if (doc != NULL) - { - //get the body document element - HRESULT hr = doc->get_body(&pBody); - - if (hr == S_OK && pBody != NULL) - { - //get the body's style - pBody->get_style(&pStyle); - - //set properties of style - pStyle->put_backgroundColor(var_pagebg_color); - pStyle->put_color(var_pagefg_color); - } - } -} - void TextRenderBrain::increaseFontSize() { //MainWndParts::Instance()->mpSidebar->m_wndDlg.increaseFontSize(); - - if (mFontSize >= 0 && mFontSize < 4) - { - setFontSize(mFontSize + 1); - } + if (mFontSize >= 0 && mFontSize < 4) setFontSize(mFontSize + 1); } void TextRenderBrain::resetFontSize() @@ -403,152 +347,79 @@ //MainWndParts::Instance()->mpSidebar->m_wndDlg.resetFontSize(); setFontSize(0); } - -//set the font size -//0 = small -//1 = medium -//2 = large -//3 = x-large -//4 = xx-large -/* -@todo -if the document default is not "small", this doesn't behave perfectly -and the reset goes to "small", not "default -*/ -void TextRenderBrain::setFontSize(int fontsz) -{ - IHTMLDocument2 *doc = NULL; - HRESULT hr; - IHTMLElement* pBody = NULL; - IHTMLStyle* pStyle = NULL; - - VARIANT new_font_size; - VariantInit(&new_font_size); - new_font_size.vt = VT_BSTR; - - - if (fontsz == 0) - { - new_font_size.bstrVal = L"small"; - } - else if(fontsz == 1) - { - new_font_size.bstrVal = L"medium"; - } - else if(fontsz == 2) - { - new_font_size.bstrVal = L"large"; - } - else if(fontsz == 3) - { - new_font_size.bstrVal = L"x-large"; - } - else if(fontsz == 4) - { - new_font_size.bstrVal = L"xx-large"; - } - else - { - fontsz = 0; - new_font_size.bstrVal = L"small"; - } - - mFontSize = fontsz; - - doc = GetDoc(); - - if (doc != NULL) - { - hr = doc->get_body(&pBody); - - if (hr == S_OK && pBody != NULL) - { - pBody->get_style(&pStyle); - pStyle->put_fontSize(new_font_size); - } - } +//set the font size +//0 = reset +//1...4 = increasingly bigger +void TextRenderBrain::setFontSize(int fontsz) +{ + if (fontsz > mFontSizeCssFiles.size() || fontsz < 1) fontsz = 0; + mFontSize = fontsz; + + //remove the old stylesheet + MainWndParts::Instance()->mpHtmlView->removeStylesheet(mpFontCss); + + if (fontsz) + MainWndParts::Instance()->mpHtmlView->applyStylesheet(&mFontSizeCssFiles[fontsz-1]); + + if (isElementInView(pLastElm) == false) + { + VARIANT v_bool; + v_bool.vt = VT_BOOL; + v_bool.boolVal = TRUE; + pLastElm->scrollIntoView(v_bool); + } } //taken from http://www.wischik.com/lu/programmer/webform.html IHTMLElement* TextRenderBrain::GetElementFromId(string id_str, const GUID *iid) { - - const char* id; + const char* id = NULL; IHTMLElement *ret=0; IHTMLElementCollection* doc_all = NULL; IHTMLDocument2 *doc = NULL; HRESULT hr; - if (id_str.size() == 0) - { - return 0; - } - + if (id_str.size() == 0) return 0; + id = id_str.c_str(); - doc = GetDoc(); - if (doc==0) - { - return 0; - } - + if (doc==0) return 0; hr = doc->get_all(&doc_all); // this is like doing document.all if (hr == S_OK) { IDispatch* disp = NULL; - VARIANT vid; VARIANT v0; - unsigned int len; wchar_t* ws = NULL; VariantInit(&v0); - len=strlen(id); vid.vt=VT_BSTR; ws = new wchar_t[len+1]; - MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, id, -1, ws, len+1); - - // AfxMessageBox(ws); - vid.bstrVal=ws; hr = doc_all->item(vid,v0,&disp); // this is like doing document.all["messages"] - delete[] ws; if (hr == S_OK && disp != 0) { IHTMLElement* element = NULL; - if (iid == 0) - { - hr = disp->QueryInterface(IID_IHTMLElement,(void **)&element); - } - else - { - hr = disp->QueryInterface(*iid,(void**)&element); - } + if (iid == 0) hr = disp->QueryInterface(IID_IHTMLElement,(void **)&element); + else hr = disp->QueryInterface(*iid,(void**)&element); - if (hr == S_OK) - { - ret = element; // it's the caller's responsibility to release it - } - + if (hr == S_OK) ret = element; // it's the caller's responsibility to release it disp->Release(); } - doc_all->Release(); } - doc->Release(); - return ret; } @@ -556,17 +427,14 @@ IHTMLDocument2* TextRenderBrain::GetDoc() { IDispatch *dispatch = NULL; - dispatch = MainWndParts::Instance()->mpHtmlView->GetHtmlDocument(); - IHTMLDocument2 *doc = NULL; - if (dispatch != NULL) + + if (dispatch) { dispatch->QueryInterface(IID_IHTMLDocument2,(void**)&doc); dispatch->Release(); } - - return doc; } @@ -586,10 +454,7 @@ // MainWndParts::Instance()->mpSidebar->m_wndDlg.repaintContrast(); //repaint the html view contrast if it had been enabled - if (this->mb_flagContrast == true) - { - this->pageContrastOn(); - } + if (mbContrastOn) this->pageContrastOn(); } //otherwise turn the contrast off everywhere else @@ -642,11 +507,12 @@ pStyle->put_backgroundColor(var_bg); pStyle->put_color(var_fg); } - } //this function looks at the element's coordinates and the coordinates of the section of the //document which is being displayed, and decides if the element is visible or not +//however, stupid IE 7 broke it and it doesn't work anymore +//TODO fix this bool TextRenderBrain::isElementInView(IHTMLElement* pElm) { //the IHTMLELEMENT measurements @@ -656,18 +522,11 @@ long elm_left = 0; //if any measurements go wrong, return false - if (pElm->get_offsetWidth(&elm_width) != S_OK) - return false; + if (pElm->get_offsetWidth(&elm_width) != S_OK) return false; + if (pElm->get_offsetHeight(&elm_height) != S_OK) return false; + if (pElm->get_offsetTop(&elm_top) != S_OK) return false; + if (pElm->get_offsetLeft(&elm_left) != S_OK) return false; - if (pElm->get_offsetHeight(&elm_height) != S_OK) - return false; - - if (pElm->get_offsetTop(&elm_top) != S_OK) - return false; - - if (pElm->get_offsetLeft(&elm_left) != S_OK) - return false; - HRESULT hr; // get the document dispatch from browser @@ -695,17 +554,14 @@ pContainer->get_scrollTop(&scroll_pos.y); pContainer->get_scrollLeft(&scroll_pos.x); - pDisp->Release(); //get the html view's width and height long view_width = 0; long view_height = 0; - view_width = MainWndParts::Instance()->mpHtmlView->GetWidth(); view_height = MainWndParts::Instance()->mpHtmlView->GetHeight(); - int top_visible = scroll_pos.y; int bottom_visible = scroll_pos.y + view_height; int left_visible = scroll_pos.x; @@ -722,25 +578,14 @@ screen_data.Format(_T("******\nScreen \ttop = %d \tbottom = %d \tleft = %d \tright = %d \n****\n"), top_visible, bottom_visible, left_visible, right_visible); - TRACE(screen_data); - TRACE(element_data); +// TRACE(screen_data); +// TRACE(element_data); - if (elm_top < top_visible || elm_bottom > bottom_visible) - return false; + if (elm_top < top_visible || elm_bottom > bottom_visible) return false; + if (elm_left < left_visible || elm_right > right_visible) return false; - if (elm_left < left_visible || elm_right > right_visible) - return false; - //otherwise we assume it's in view return true; } -void TextRenderBrain::loadBlankDocument() -{ -#ifdef AMIS_WITH_AMBULANT - return; -#else - MainWndParts::Instance()->mpHtmlView->Navigate2(_T("about:blank"), NULL, NULL); -#endif -} Added: branches/amis3/bin/settings/amis-contrast.css =================================================================== --- branches/amis3/bin/settings/amis-contrast.css (rev 0) +++ branches/amis3/bin/settings/amis-contrast.css 2007-09-17 07:21:46 UTC (rev 2152) @@ -0,0 +1,3 @@ +/*contrast CSS sheet*/ +body{ background-color: blue; color: white;} + Added: branches/amis3/bin/settings/amis-default.css =================================================================== --- branches/amis3/bin/settings/amis-default.css (rev 0) +++ branches/amis3/bin/settings/amis-default.css 2007-09-17 07:21:46 UTC (rev 2152) @@ -0,0 +1,2 @@ +/*default CSS sheet*/ + Added: branches/amis3/bin/settings/font1.css =================================================================== --- branches/amis3/bin/settings/font1.css (rev 0) +++ branches/amis3/bin/settings/font1.css 2007-09-17 07:21:46 UTC (rev 2152) @@ -0,0 +1,9 @@ +/*whole document body*/ +body { + font-size: 150%; + line-spacing: 125% +} + +h1, h2, h3, h4, h5, h6{ + font-size: 150%; +} Added: branches/amis3/bin/settings/font2.css =================================================================== --- branches/amis3/bin/settings/font2.css (rev 0) +++ branches/amis3/bin/settings/font2.css 2007-09-17 07:21:46 UTC (rev 2152) @@ -0,0 +1,9 @@ +/*whole document body*/ +body { + font-size: 175%; + line-spacing: 150% +} + +h1, h2, h3, h4, h5, h6{ + font-size: 175%; +} Added: branches/amis3/bin/settings/font3.css =================================================================== --- branches/amis3/bin/settings/font3.css (rev 0) +++ branches/amis3/bin/settings/font3.css 2007-09-17 07:21:46 UTC (rev 2152) @@ -0,0 +1,9 @@ +/*whole document body*/ +body { + font-size: 200%; + line-spacing: 175% +} + +h1, h2, h3, h4, h5, h6{ + font-size: 200%; +} Added: branches/amis3/bin/settings/font4.css =================================================================== --- branches/amis3/bin/settings/font4.css (rev 0) +++ branches/amis3/bin/settings/font4.css 2007-09-17 07:21:46 UTC (rev 2152) @@ -0,0 +1,9 @@ +/*whole document body*/ +body { + font-size: 225%; + line-spacing: 175% +} + +h1, h2, h3, h4, h5, h6{ + font-size: 225%; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-23 20:14:15
|
Revision: 2155 http://amis.svn.sourceforge.net/amis/?rev=2155&view=rev Author: marisademeglio Date: 2007-09-23 13:14:17 -0700 (Sun, 23 Sep 2007) Log Message: ----------- Hooked up contrast, text size. Contrast works but not on all documents (this is a stylesheet problem). Text size needs debugging. Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/MainWndParts.cpp branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/bin/settings/amis-contrast.css Modified: branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h 2007-09-23 20:14:17 UTC (rev 2155) @@ -40,7 +40,7 @@ void refreshRecentBooksListMenu(); void setupMenusSomethingOpen(amis::dtb::BookmarkSet*); void setupMenusNothingOpen(); - void setSidebarItemCheckmark(bool); + void setViewItemCheckmark(bool, UINT); void addBookmark(amis::dtb::PositionMark*); void loadBookmarks(amis::dtb::BookmarkSet*); private: Modified: branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2007-09-23 20:14:17 UTC (rev 2155) @@ -49,7 +49,8 @@ void resetFontSize(); void increaseFontSize(); - void toggleContrast(); + bool toggleContrast(); + bool isContrastOn(); void highlightUriTarget(amis::TextNode*); void highlightUriTarget(std::string url); @@ -63,8 +64,8 @@ void saveElementText(IHTMLElement*); void setFontSize(int); void highlightElementAtId(string); - void pageContrastOn(); - void pageContrastOff(); + void htmlContrastOn(); + void htmlContrastOff(); void redoHighlightColors(); bool isElementInView(IHTMLElement*); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-23 20:14:17 UTC (rev 2155) @@ -21,28 +21,33 @@ */ #include "stdafx.h" +#include "../resource.h" + +#include "dtb/nav/NavModel.h" + +#include "DtbWithHooks.h" + +#include "io/RecentBooksFileIO.h" + #include "gui/AmisGuiMFC2.h" #include "gui/MainFrm.h" -#include "gui/sidebar/AmisSidebar.h" #include "gui/ChildFrm.h" #include "gui/MainWndParts.h" - -#include "../resource.h" - #include "gui/MmDoc.h" #include "gui/MmView.h" #include "gui/MenuManip.h" +#include "gui/TextRenderBrain.h" + +#include "gui/sidebar/AmisSidebar.h" + #include "gui/dialogs/AmisFileDialog.h" -#include "util/FilePathTools.h" - -#include "DtbWithHooks.h" -#include "io/RecentBooksFileIO.h" #include "gui/dialogs/AboutDialog.h" #include "gui/dialogs/OpenUrlDialog.h" #include "gui/dialogs/SkipDialog.h" #include "gui/dialogs/GoToPageDialog.h" -#include "dtb/nav/NavModel.h" +#include "util/FilePathTools.h" + #ifdef _DEBUG #define new DEBUG_NEW #endif @@ -74,7 +79,9 @@ ON_COMMAND(ID_MENU_BMK_ADD, OnAddBookmark) ON_COMMAND_RANGE(BOOKMARKS_BASE_ID, BOOKMARKS_BASE_ID + MAX_ANYTHING, OnSelectBookmark) ON_COMMAND(ID_MENU_NAV_GOTOPAGE, OnGoToPage) - + ON_COMMAND(ID_MENU_VIEW_CONTRAST, OnToggleContrast) + ON_COMMAND(ID_MENU_VIEW_LARGEFONT, OnIncreaseFontSize) + ON_COMMAND(ID_MENU_VIEW_RESETFONT, OnResetFontSize) END_MESSAGE_MAP() @@ -364,6 +371,7 @@ } else { + //TODO: localize this AfxMessageBox(_T("Error opening book")); } } @@ -407,4 +415,18 @@ if (p_page) amis::dtb::DtbWithHooks::Instance()->loadNavNode(p_page); } } +} + +void CAmisGuiMFC2App::OnToggleContrast() +{ + bool is_contrast_on = amis::gui::TextRenderBrain::Instance()->toggleContrast(); + MenuManip::Instance()->setViewItemCheckmark(is_contrast_on, ID_MENU_VIEW_CONTRAST); +} +void CAmisGuiMFC2App::OnIncreaseFontSize() +{ + TextRenderBrain::Instance()->increaseFontSize(); +} +void CAmisGuiMFC2App::OnResetFontSize() +{ + TextRenderBrain::Instance()->resetFontSize(); } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/MainWndParts.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainWndParts.cpp 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/AmisGuiMFC2/src/gui/MainWndParts.cpp 2007-09-23 20:14:17 UTC (rev 2155) @@ -75,7 +75,7 @@ void MainWndParts::toggleSidebar() { mbSidebarVisible = !mbSidebarVisible; - MenuManip::Instance()->setSidebarItemCheckmark(mbSidebarVisible); + MenuManip::Instance()->setViewItemCheckmark(mbSidebarVisible, ID_MENU_VIEW_SIDEBAR_ONOFF); //if the window is hidden, show it if (!mpSidebar->ShowWindow(SW_SHOWNA)) mpMainFrame->ShowControlBar(mpSidebar, TRUE, TRUE); Modified: branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2007-09-23 20:14:17 UTC (rev 2155) @@ -218,12 +218,16 @@ //info menu p_main_menu->EnableMenuItem(5, MF_BYPOSITION | MF_ENABLED); + //uncheck "high contrast" + bool is_contrast_on = TextRenderBrain::Instance()->isContrastOn(); + setViewItemCheckmark(is_contrast_on, ID_MENU_VIEW_CONTRAST); + setupNavigationOptions(); loadBookmarks(pBookmarks); } -void MenuManip::setSidebarItemCheckmark(bool isChecked) +void MenuManip::setViewItemCheckmark(bool isChecked, UINT itemId) { CMenu* p_menu = NULL; p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); @@ -232,8 +236,8 @@ p_menu = p_menu->GetSubMenu(1); assert(p_menu); - if (isChecked == true) p_menu->CheckMenuItem(ID_MENU_VIEW_SIDEBAR_ONOFF, MF_CHECKED); - else p_menu->CheckMenuItem(ID_MENU_VIEW_SIDEBAR_ONOFF, MF_UNCHECKED); + if (isChecked == true) p_menu->CheckMenuItem(itemId, MF_CHECKED); + else p_menu->CheckMenuItem(itemId, MF_UNCHECKED); } void MenuManip::addBookmark(amis::dtb::PositionMark* pBmk) @@ -245,6 +249,7 @@ CMenu* p_menu = NULL; CString menu_label; p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); + //get "bookmarks" p_menu = p_menu->GetSubMenu(4); amis::TextNode* p_text = NULL; Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-09-23 20:14:17 UTC (rev 2155) @@ -151,7 +151,7 @@ //refresh font size and contrast settings for the newly loaded page if (mFontSize > 0) setFontSize(mFontSize); - if (mbContrastOn) pageContrastOn(); + if (mbContrastOn) htmlContrastOn(); highlightElementAtId(mCurrentUrl.get_ref()); } @@ -285,30 +285,21 @@ } } -void TextRenderBrain::toggleContrast() +bool TextRenderBrain::isContrastOn() { + return mbContrastOn; +} +//turns the contrast on or off. returns the new state of the contrast (true = on) +bool TextRenderBrain::toggleContrast() +{ // MainWndParts::Instance()->mpSidebar->m_wndDlg.toggleContrast(); -// MainWndParts::Instance()->MenuManip()->setContrast(mb_flagContrast); -/* CMenu* p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); - if (mb_flagContrast == true) - { - //uncheck the contrast item - p_menu->CheckMenuItem(ID_VIEW_CONTRAST, MF_UNCHECKED); - pageContrastOff(); - } - else - { - //check the contrast item - p_menu->CheckMenuItem(ID_VIEW_CONTRAST, MF_CHECKED); - pageContrastOn(); - } - */ + if (mbContrastOn) htmlContrastOff(); + else htmlContrastOn(); - if (mbContrastOn) pageContrastOff(); - else pageContrastOn(); + return mbContrastOn; } -void TextRenderBrain::pageContrastOn() +void TextRenderBrain::htmlContrastOn() { /* mb_flagContrast = true; string fg, bg; @@ -323,7 +314,7 @@ } -void TextRenderBrain::pageContrastOff() +void TextRenderBrain::htmlContrastOff() { /* mb_flagContrast = false; string fg, bg; @@ -358,8 +349,7 @@ //remove the old stylesheet MainWndParts::Instance()->mpHtmlView->removeStylesheet(mpFontCss); - if (fontsz) - MainWndParts::Instance()->mpHtmlView->applyStylesheet(&mFontSizeCssFiles[fontsz-1]); + if (fontsz) MainWndParts::Instance()->mpHtmlView->applyStylesheet(&mFontSizeCssFiles[fontsz-1]); if (isElementInView(pLastElm) == false) { @@ -454,7 +444,7 @@ // MainWndParts::Instance()->mpSidebar->m_wndDlg.repaintContrast(); //repaint the html view contrast if it had been enabled - if (mbContrastOn) this->pageContrastOn(); + if (mbContrastOn) htmlContrastOn(); } //otherwise turn the contrast off everywhere else @@ -463,7 +453,7 @@ // MainWndParts::Instance()->mpSidebar->m_wndDlg.turnContrastOff(); //turn off the html view contrast - this->pageContrastOff(); + htmlContrastOff(); } } //this is called to refresh the page colors Modified: branches/amis3/bin/settings/amis-contrast.css =================================================================== --- branches/amis3/bin/settings/amis-contrast.css 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/bin/settings/amis-contrast.css 2007-09-23 20:14:17 UTC (rev 2155) @@ -1,3 +1,6 @@ /*contrast CSS sheet*/ body{ background-color: blue; color: white;} +h1 {color: green;} +a {text-decoration: none;} +a:hover {background-color: red;} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jac...@us...> - 2007-09-24 10:09:57
|
Revision: 2158 http://amis.svn.sourceforge.net/amis/?rev=2158&view=rev Author: jackjansen Date: 2007-09-24 03:10:00 -0700 (Mon, 24 Sep 2007) Log Message: ----------- Checking in svn:ignores Property Changed: ---------------- branches/amis3/AmisCore/ branches/amis3/AmisGuiMFC2/ branches/amis3/Audio/ branches/amis3/DefaultLangpack/AmisLangpack/ branches/amis3/VC7/ branches/amis3/bin/ branches/amis3/bin/settings/lang/ Property changes on: branches/amis3/AmisCore ___________________________________________________________________ Name: svn:ignore + Debug Property changes on: branches/amis3/AmisGuiMFC2 ___________________________________________________________________ Name: svn:ignore + Debug Property changes on: branches/amis3/Audio ___________________________________________________________________ Name: svn:ignore + tmp-Debug Property changes on: branches/amis3/DefaultLangpack/AmisLangpack ___________________________________________________________________ Name: svn:ignore + debug tmp Property changes on: branches/amis3/VC7 ___________________________________________________________________ Name: svn:ignore + *.ncb *.suo Property changes on: branches/amis3/bin ___________________________________________________________________ Name: svn:ignore + *.dll Property changes on: branches/amis3/bin/settings/lang ___________________________________________________________________ Name: svn:ignore + eng-US This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-24 10:13:35
|
Revision: 2160 http://amis.svn.sourceforge.net/amis/?rev=2160&view=rev Author: marisademeglio Date: 2007-09-24 03:13:39 -0700 (Mon, 24 Sep 2007) Log Message: ----------- more ignores Property Changed: ---------------- branches/amis3/AmisCore/ branches/amis3/AmisCore/testAmisCore/ branches/amis3/AmisGuiMFC2/ branches/amis3/AudioOld/ branches/amis3/bin/ branches/amis3/bin/settings/ branches/amis3/bin/settings/bmk/ branches/amis3/lib/ Property changes on: branches/amis3/AmisCore ___________________________________________________________________ Name: svn:ignore - Debug + Debug Release *.ncb *.suo Property changes on: branches/amis3/AmisCore/testAmisCore ___________________________________________________________________ Name: svn:ignore + Release Property changes on: branches/amis3/AmisGuiMFC2 ___________________________________________________________________ Name: svn:ignore - Debug + Debug *.ncb *.suo Property changes on: branches/amis3/AudioOld ___________________________________________________________________ Name: svn:ignore + Debug Property changes on: branches/amis3/bin ___________________________________________________________________ Name: svn:ignore - *.dll + *.dll *.ilk *.pdb amlog.txt AmisGuiMFC2.exe Property changes on: branches/amis3/bin/settings ___________________________________________________________________ Name: svn:ignore + amisPrefs.xml amisRecentBooks.xml Property changes on: branches/amis3/bin/settings/bmk ___________________________________________________________________ Name: svn:ignore + *.bmk Property changes on: branches/amis3/lib ___________________________________________________________________ Name: svn:ignore - AmisAudioD.exp AmisAudioD.lib AmisCoreD.lib + AmisAudioD.exp AmisAudioD.lib AmisCoreD.lib xerces-c_2.lib xerces-c_2D.lib AmisCore.lib This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-24 13:36:52
|
Revision: 2161 http://amis.svn.sourceforge.net/amis/?rev=2161&view=rev Author: marisademeglio Date: 2007-09-24 06:36:52 -0700 (Mon, 24 Sep 2007) Log Message: ----------- fixed a bug in section order playback Modified Paths: -------------- branches/amis3/AmisCore/include/dtb/Spine.h branches/amis3/AmisCore/include/dtb/nav/NavVisitor.h branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp branches/amis3/AmisCore/src/dtb/Spine.cpp branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp Modified: branches/amis3/AmisCore/include/dtb/Spine.h =================================================================== --- branches/amis3/AmisCore/include/dtb/Spine.h 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisCore/include/dtb/Spine.h 2007-09-24 13:36:52 UTC (rev 2161) @@ -43,17 +43,17 @@ ~Spine(); //note: removed forced value on bool (skipCheck = false) for python linking - void addFile(ambulant::net::url*, bool); - void addFile(string, bool); + void addFile(const ambulant::net::url*, bool); + //void addFile(string, bool); - bool isFilePresent(ambulant::net::url*); + bool isFilePresent(const ambulant::net::url*); bool isEmpty(); const ambulant::net::url* getNextFile(); const ambulant::net::url* getPreviousFile(); const ambulant::net::url* getFirstFile(); const ambulant::net::url* getLastFile(); - bool goToFile(ambulant::net::url*); + bool goToFile(const ambulant::net::url*); void print(); int getNumberOfSmilFiles(); const ambulant::net::url* getSmilFilePath(unsigned int); Modified: branches/amis3/AmisCore/include/dtb/nav/NavVisitor.h =================================================================== --- branches/amis3/AmisCore/include/dtb/nav/NavVisitor.h 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisCore/include/dtb/nav/NavVisitor.h 2007-09-24 13:36:52 UTC (rev 2161) @@ -54,11 +54,12 @@ public: BuildSpineVisitor() {mpSpine = NULL;} ~BuildSpineVisitor() {} - amis::dtb::Spine* getSpine(NavModel*); + amis::dtb::Spine* getSpine(NavModel*, const ambulant::net::url*); bool preVisit(NavNode*); private: amis::dtb::Spine* mpSpine; + const ambulant::net::url* mpBookDirectory; }; Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-24 13:36:52 UTC (rev 2161) @@ -208,7 +208,7 @@ mpMetadata = ncc_file_reader.getMetadata(); mpCustomTests = ncc_file_reader.getCustomTests(); - mpSpine = spine_visitor.getSpine(mpNavModel); + mpSpine = spine_visitor.getSpine(mpNavModel, this->getFileSet()->getBookDirectory()); mUid = getUid(); mpFiles->setAdditionalDataAfterInitialParse(this->mUid, NULL, NULL); Modified: branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-09-24 13:36:52 UTC (rev 2161) @@ -130,6 +130,7 @@ return &mBookmarksFilepath; } +//these two functions (setSmilFile, getSmilFile) are not used when Ambulant is hooked up //expected: relative file path void amis::dtb::DtbFileSet::setSmilFile(const ambulant::net::url* file) { @@ -140,6 +141,8 @@ { return &mSmilFilepath; } + + //is this an ncc file? bool amis::dtb::DtbFileSet::isNccFile(const ambulant::net::url* filepath) { Modified: branches/amis3/AmisCore/src/dtb/Spine.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Spine.cpp 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisCore/src/dtb/Spine.cpp 2007-09-24 13:36:52 UTC (rev 2161) @@ -95,7 +95,7 @@ //check to see if a file is present in the spine -bool amis::dtb::Spine::isFilePresent(ambulant::net::url* filePath) +bool amis::dtb::Spine::isFilePresent(const ambulant::net::url* filePath) { for (unsigned int i=0; i<mSpineList.size(); i++) { @@ -108,19 +108,20 @@ } //wrapper -void amis::dtb::Spine::addFile(string filePath, bool skipCheck) +/*void amis::dtb::Spine::addFile(string filePath, bool skipCheck) { ambulant::net::url fileurl = ambulant::net::url::from_url(filePath); addFile(&fileurl, skipCheck); -} +}*/ //if the file doesn't already exist, add it to the spine list //skipCheck allows to skip the isFilePresent check for very long lists -void amis::dtb::Spine::addFile(ambulant::net::url* filePath, bool skipCheck) +//filePath should be a full path. +void amis::dtb::Spine::addFile(const ambulant::net::url* filePath, bool skipCheck) { if (filePath->is_empty_path()) return; - if (skipCheck == true) + if (skipCheck) { mSpineList.push_back(filePath->get_document()); } @@ -133,7 +134,6 @@ } } - //print the spine void amis::dtb::Spine::print() { @@ -158,7 +158,7 @@ } //set the spine at this particular file, if exists -bool amis::dtb::Spine::goToFile(ambulant::net::url* filePath) +bool amis::dtb::Spine::goToFile(const ambulant::net::url* filePath) { bool b_found = false; unsigned int i; @@ -167,6 +167,7 @@ if (mSpineList[i].same_document((*filePath))) { b_found = true; + break; } } Modified: branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp 2007-09-24 13:36:52 UTC (rev 2161) @@ -29,8 +29,9 @@ /**************************************/ /*BUILD SPINE VISITOR /**************************************/ -amis::dtb::Spine* amis::dtb::nav::BuildSpineVisitor::getSpine(amis::dtb::nav::NavModel* model) +amis::dtb::Spine* amis::dtb::nav::BuildSpineVisitor::getSpine(amis::dtb::nav::NavModel* model, const ambulant::net::url* pBookDirectory) { + mpBookDirectory = pBookDirectory; mpSpine = new amis::dtb::Spine(); model->acceptDepthFirst(this); return mpSpine; @@ -39,7 +40,11 @@ //this gets called each time a node is visited bool amis::dtb::nav::BuildSpineVisitor::preVisit(NavNode* n) { - mpSpine->addFile(n->getContent(), false); + //make a full path out of n->getContent() + ambulant::net::url smil_url = ambulant::net::url::from_url(n->getContent()); + ambulant::net::url full_smil_url = smil_url.join_to_base(*mpBookDirectory); + + mpSpine->addFile(&full_smil_url, false); return true; } Modified: branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2007-09-24 13:36:52 UTC (rev 2161) @@ -54,7 +54,7 @@ void updateCustomTestStates(bool playAll = false); amis::dtb::Bookmark* addBookmark(); void loadBookmark(int); - amis::dtb::smil::SmilMediaGroup* loadSmilFromUrl(ambulant::net::url*); + amis::dtb::smil::SmilMediaGroup* loadSmilFromUrl(const ambulant::net::url*); private: void addToRecentBooks(); Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-09-24 13:36:52 UTC (rev 2161) @@ -109,18 +109,12 @@ //if we're not using the lastmark or it is unavailable, just load from the beginning if (loadLastmark == false || getBookmarks() == NULL || getBookmarks()->getLastmark() == NULL) - { smilfile = getSpine()->getFirstFile(); - //why this is necessary I forget ... it might not be - this->getFileSet()->setSmilFile(smilfile); - } else - { smilfile = &getBookmarks()->getLastmark()->mUri; - } - assert(smilfile); - amis::gui::MainWndParts::Instance()->mpMmDoc->OnOpenDocument(A2T(smilfile->get_url().c_str())); + loadSmilFromUrl(smilfile); + return NULL; #else smil::SmilMediaGroup* pData = Dtb::startReading(loadLastmark); @@ -149,22 +143,15 @@ void DtbWithHooks::nextSmilDocument() { const ambulant::net::url* filepath = this->getSpine()->getNextFile(); - if (filepath != NULL) - { - ambulant::net::url full_path_to_file = filepath->join_to_base(*getFileSet()->getBookDirectory()); - amis::gui::MainWndParts::Instance()->mpMmView->ScheduleReplaceDoc(full_path_to_file.get_url()); - } + if (filepath) + amis::gui::MainWndParts::Instance()->mpMmView->ScheduleReplaceDoc(filepath->get_url()); } void DtbWithHooks::previousSmilDocument() { const ambulant::net::url* filepath = this->getSpine()->getPreviousFile(); - if (filepath != NULL) - { - ambulant::net::url full_path_to_file = filepath->join_to_base(*getFileSet()->getBookDirectory()); - amis::gui::MainWndParts::Instance()->mpMmView->ScheduleReplaceDoc(full_path_to_file.get_url()); - - } + if (filepath) + amis::gui::MainWndParts::Instance()->mpMmView->ScheduleReplaceDoc(filepath->get_url()); } void DtbWithHooks::loadNavNode(nav::NavNode* pNav) @@ -333,12 +320,16 @@ loadSmilFromUrl(&p_mark->mpStart->mUri); } -amis::dtb::smil::SmilMediaGroup* DtbWithHooks::loadSmilFromUrl(ambulant::net::url* pUri) +amis::dtb::smil::SmilMediaGroup* DtbWithHooks::loadSmilFromUrl(const ambulant::net::url* pUri) { USES_CONVERSION; - + assert(pUri); ambulant::net::url full_path = pUri->join_to_base(*getFileSet()->getBookDirectory()); - amis::gui::MainWndParts::Instance()->mpMmDoc->OnOpenDocument(A2T(full_path.get_url().c_str())); - + + //set the spine at this file. this also makes sure that we're going to a file that is in the book. + if (getSpine()->goToFile(&full_path)) + { + amis::gui::MainWndParts::Instance()->mpMmDoc->OnOpenDocument(A2T(full_path.get_url().c_str())); + } return NULL; } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2007-09-24 13:36:52 UTC (rev 2161) @@ -20,29 +20,28 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include <algorithm> +#include <string> +#include <cassert> + #include "stdafx.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisGuiMFC2.h" #include "gui/HtmlDoc.h" #include "gui/HtmlView.h" - #include "gui/MainWndParts.h" +#include "gui/MmDoc.h" +#include "gui/TextRenderBrain.h" +#include "DtbWithHooks.h" -#include <algorithm> -#include <string> - #define WITH_HTML_WIDGET #define AM_DBG if (1) -#include <cassert> -#include "gui/MmDoc.h" -#include "gui/TextRenderBrain.h" - typedef amis::gui::CAmisHtmlView HtmlView; using namespace std; using namespace amis::gui; -//#endif // Messages for communicating between worker threads and main (GUI) thread, which // is the only one that should do html-widget calls. @@ -68,29 +67,20 @@ #endif extern CWnd* topView; -///////////////////////////////////////////////////////////////////////////// -// CAmisHtmlView IMPLEMENT_DYNCREATE(CAmisHtmlView, CHtmlView) BEGIN_MESSAGE_MAP(CAmisHtmlView, CHtmlView) - //{{AFX_MSG_MAP(CAmisHtmlView) ON_WM_CREATE() #ifdef HTML_LOAD_MANUALLY ON_MESSAGE(WM_MY_NAVIGATESTRING, OnNavigateString) #endif ON_MESSAGE(WM_MY_HIGHLIGHTURITARGET, OnHighlightUrlTarget) ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - - //}}AFX_MSG_MAP END_MESSAGE_MAP() -///////////////////////////////////////////////////////////////////////////// -// CAmisHtmlView construction/destruction - CAmisHtmlView::CAmisHtmlView() { - //mpBrain = NULL; #ifdef HTML_LOAD_AMBULANT_PDTB mpLoaderBridge = NULL; #endif @@ -98,7 +88,6 @@ CAmisHtmlView::CAmisHtmlView(const RECT& rect, CWnd* parent) { - //mpBrain = NULL; #ifdef HTML_LOAD_AMBULANT_PDTB mpLoaderBridge = NULL; #endif @@ -107,7 +96,8 @@ CAmisHtmlView::~CAmisHtmlView() { - if (mpLoaderBridge) { + if (mpLoaderBridge) + { mpLoaderBridge->Release(); mpLoaderBridge = NULL; } @@ -115,28 +105,15 @@ BOOL CAmisHtmlView::PreCreateWindow(CREATESTRUCT& cs) { - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - - return CHtmlView::PreCreateWindow(cs); } -///////////////////////////////////////////////////////////////////////////// -// CAmisHtmlView drawing - void CAmisHtmlView::OnDraw(CDC* pDC) { CAmisHtmlDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); - - // TODO: add draw code for native data here } -///////////////////////////////////////////////////////////////////////////// -// CAmisHtmlView diagnostics - #ifdef _DEBUG void CAmisHtmlView::AssertValid() const { @@ -157,17 +134,11 @@ #endif //_DEBUG -///////////////////////////////////////////////////////////////////////////// -// CAmisHtmlView message handlers - int CAmisHtmlView::OnCreate(LPCREATESTRUCT lpCreateStruct) { - if (CHtmlView::OnCreate(lpCreateStruct) == -1) - return -1; + if (CHtmlView::OnCreate(lpCreateStruct) == -1) return -1; MainWndParts::Instance()->mpHtmlView = this; - - this->ModifyStyle(0, WS_CLIPCHILDREN); return 0; } @@ -185,37 +156,31 @@ CHtmlView::OnActivateView(bActivate, pActivateView, pDeactiveView); } +//this signals the completion of a URL load request void CAmisHtmlView::OnDocumentComplete(LPCTSTR lpszURL) { TextRenderBrain::Instance()->webDocumentComplete(); - CHtmlView::OnDocumentComplete(lpszURL); - } BOOL CAmisHtmlView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { // create the view window itself m_pCreateContext = pContext; - if (!CView::Create(lpszClassName, lpszWindowName, - dwStyle, rect, pParentWnd, nID, pContext)) - { + if (!CView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext)) return FALSE; - } - RECT rectClient; GetClientRect(&rectClient); // create the control window // AFX_IDW_PANE_FIRST is a safe but arbitrary ID if (!m_wndBrowser.CreateControl(CLSID_WebBrowser, lpszWindowName, - WS_VISIBLE | WS_CHILD , rectClient, this, AFX_IDW_PANE_FIRST)) + WS_VISIBLE | WS_CHILD , rectClient, this, AFX_IDW_PANE_FIRST)) { DestroyWindow(); return FALSE; } - LPUNKNOWN lpUnk = m_wndBrowser.GetControlUnknown(); HRESULT hr = lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp); @@ -244,7 +209,6 @@ p_parent->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam); } - return CHtmlView::PreTranslateMessage(pMsg); } @@ -255,22 +219,27 @@ BOOL* pbCancel) { USES_CONVERSION; - //AfxMessageBox(lpszURL); + // lpszURL can be either a URL or a filename (sigh) // Guess: if there's a : in the string and it is not in second position // this is a URL. string urlOrFile = T2A(lpszURL); ambulant::net::url thisUrl; string::size_type colonPos = urlOrFile.find(':'); - if (colonPos == string::npos || colonPos == 1) { + if (colonPos == string::npos || colonPos == 1) + { thisUrl = ambulant::net::url::from_filename(urlOrFile, true); - } else if (urlOrFile.substr(0, 5) == "file:") { + } + else if (urlOrFile.substr(0, 5) == "file:") + { // Stupid hack: urlOrFile can be mixed-case. Sigh. ambulant::net::url tmpurl = ambulant::net::url::from_url(urlOrFile); assert(tmpurl.is_local_file()); std::string tmpfile = tmpurl.get_file(); thisUrl = ambulant::net::url::from_filename(tmpfile); - } else { + } + else + { thisUrl = ambulant::net::url::from_url(urlOrFile); } //if this URL is not in our current book directory, don't go there @@ -296,7 +265,7 @@ if (thisUrl.guesstype() == "application/smil") { *pbCancel = TRUE; -// AmisBrain::Instance()->loadSmilContent(thisUrl.get_url()); + amis::dtb::DtbWithHooks::Instance()->loadSmilFromUrl(&thisUrl); } //else it's probably a text-file loading request that we sent ourselves else @@ -304,8 +273,6 @@ CHtmlView::OnBeforeNavigate2(lpszURL, nFlags, lpszTargetFrameName, baPostedData, lpszHeaders, pbCancel); } } - - } LPARAM CAmisHtmlView::OnHighlightUrlTarget(WPARAM wParam, LPARAM lParam) @@ -326,18 +293,23 @@ // Also, we need to inform the PdtbPluggableProtocol about // our datasource factory. This is done with the PdtbBridge // object, which remembers the factory until disposed of. - if (mpLoaderBridge == NULL) { + if (mpLoaderBridge == NULL) + { ambulant::net::datasource_factory *df = MainWndParts::Instance()->mpMmView->getDatasourceFactory(); assert(df); HRESULT hr = CoCreateInstance(CLSID_CPdtbBridge, 0, CLSCTX_INPROC_SERVER, IID_PdtbBridge, (void **)&mpLoaderBridge); - if (SUCCEEDED(hr)) { + if (SUCCEEDED(hr)) + { mpLoaderBridge->SetDatasourceFactory((DATASOURCEFACTORYPTR)df); } } - } else { - if (mpLoaderBridge) { + } + else + { + if (mpLoaderBridge) + { mpLoaderBridge->Release(); mpLoaderBridge = NULL; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-24 15:04:21
|
Revision: 2165 http://amis.svn.sourceforge.net/amis/?rev=2165&view=rev Author: marisademeglio Date: 2007-09-24 08:04:19 -0700 (Mon, 24 Sep 2007) Log Message: ----------- removed thai encoding conversion workaround; instead, the installer will add a registry alias that says TIS-620 = windows-874. Added initial installer script (doesn't work) which has a note about the registry key that we need to add. Modified Paths: -------------- branches/amis3/AmisCore/include/io/XercesSaxParseBase.h branches/amis3/AmisCore/src/io/BookmarksFileIO.cpp branches/amis3/AmisCore/src/io/ModuleDescReader.cpp branches/amis3/AmisCore/src/io/NavFileReader.cpp branches/amis3/AmisCore/src/io/OpfFileReader.cpp branches/amis3/AmisCore/src/io/QuickDataSmilFileReader.cpp branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp branches/amis3/AmisCore/src/io/SmilFileReader.cpp branches/amis3/AmisCore/src/io/TextSearch.cpp branches/amis3/AmisCore/src/io/XercesSaxParseBase.cpp branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp branches/amis3/installer/main/setup-amis3.nsi Modified: branches/amis3/AmisCore/include/io/XercesSaxParseBase.h =================================================================== --- branches/amis3/AmisCore/include/io/XercesSaxParseBase.h 2007-09-24 14:38:46 UTC (rev 2164) +++ branches/amis3/AmisCore/include/io/XercesSaxParseBase.h 2007-09-24 15:04:19 UTC (rev 2165) @@ -43,9 +43,7 @@ public: XercesSaxParseBase(); virtual ~XercesSaxParseBase() = 0; - - //removed forcedEncoding = "" for python wrapping (it confused the source-generation parser) - bool parseFile(const ambulant::net::url*, string forcedEncoding); + bool parseFile(const ambulant::net::url*); amis::Error getError(); //SAX METHODS Modified: branches/amis3/AmisCore/src/io/BookmarksFileIO.cpp =================================================================== --- branches/amis3/AmisCore/src/io/BookmarksFileIO.cpp 2007-09-24 14:38:46 UTC (rev 2164) +++ branches/amis3/AmisCore/src/io/BookmarksFileIO.cpp 2007-09-24 15:04:19 UTC (rev 2165) @@ -86,7 +86,7 @@ mElementStack.clear(); - if (!this->parseFile(filepath, "")) + if (!this->parseFile(filepath)) { delete mpBookmarks; return false; Modified: branches/amis3/AmisCore/src/io/ModuleDescReader.cpp =================================================================== --- branches/amis3/AmisCore/src/io/ModuleDescReader.cpp 2007-09-24 14:38:46 UTC (rev 2164) +++ branches/amis3/AmisCore/src/io/ModuleDescReader.cpp 2007-09-24 15:04:19 UTC (rev 2165) @@ -59,7 +59,7 @@ mpData = new amis::ModuleDescData(); mb_flagGetChars = false; - if (!this->parseFile(filepath, "")) + if (!this->parseFile(filepath)) { delete mpData; return false; Modified: branches/amis3/AmisCore/src/io/NavFileReader.cpp =================================================================== --- branches/amis3/AmisCore/src/io/NavFileReader.cpp 2007-09-24 14:38:46 UTC (rev 2164) +++ branches/amis3/AmisCore/src/io/NavFileReader.cpp 2007-09-24 15:04:19 UTC (rev 2165) @@ -84,7 +84,7 @@ //push the root onto the open nodes list mOpenNodes.push_back(mpNavModel->getNavMap()->getRoot()); - if (!this->parseFile(filepath, "")) + if (!this->parseFile(filepath)) { delete mpNavModel; return false; Modified: branches/amis3/AmisCore/src/io/OpfFileReader.cpp =================================================================== --- branches/amis3/AmisCore/src/io/OpfFileReader.cpp 2007-09-24 14:38:46 UTC (rev 2164) +++ branches/amis3/AmisCore/src/io/OpfFileReader.cpp 2007-09-24 15:04:19 UTC (rev 2165) @@ -44,7 +44,7 @@ mpSpine = new amis::dtb::Spine(); mUnsortedSmilFiles.clear(); mItemRefs.clear(); - bool b_return_value = amis::io::XercesSaxParseBase::parseFile(filename, ""); + bool b_return_value = amis::io::XercesSaxParseBase::parseFile(filename); sortSpine(); Modified: branches/amis3/AmisCore/src/io/QuickDataSmilFileReader.cpp =================================================================== --- branches/amis3/AmisCore/src/io/QuickDataSmilFileReader.cpp 2007-09-24 14:38:46 UTC (rev 2164) +++ branches/amis3/AmisCore/src/io/QuickDataSmilFileReader.cpp 2007-09-24 15:04:19 UTC (rev 2165) @@ -66,7 +66,7 @@ mpNodes = pNodes; mbFlag_GetNextAudio = false; - if (!this->parseFile(filepath, "")) + if (!this->parseFile(filepath)) { return false; } Modified: branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp =================================================================== --- branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp 2007-09-24 14:38:46 UTC (rev 2164) +++ branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp 2007-09-24 15:04:19 UTC (rev 2165) @@ -76,7 +76,7 @@ mb_flagGetChars = false; - if (!this->parseFile(filepath, "")) + if (!this->parseFile(filepath)) { delete mpRecentBooks; return false; Modified: branches/amis3/AmisCore/src/io/SmilFileReader.cpp =================================================================== --- branches/amis3/AmisCore/src/io/SmilFileReader.cpp 2007-09-24 14:38:46 UTC (rev 2164) +++ branches/amis3/AmisCore/src/io/SmilFileReader.cpp 2007-09-24 15:04:19 UTC (rev 2165) @@ -96,7 +96,7 @@ clearOpenNodesList(); - if (!this->parseFile(filepath, "")) + if (!this->parseFile(filepath)) { delete mpSmilTree; return false; Modified: branches/amis3/AmisCore/src/io/TextSearch.cpp =================================================================== --- branches/amis3/AmisCore/src/io/TextSearch.cpp 2007-09-24 14:38:46 UTC (rev 2164) +++ branches/amis3/AmisCore/src/io/TextSearch.cpp 2007-09-24 15:04:19 UTC (rev 2165) @@ -80,7 +80,7 @@ std::transform(mSearchString.begin(), mSearchString.end(), mSearchString.begin(), (int(*)(int))tolower); - if (!this->parseFile(filepath, "")) + if (!this->parseFile(filepath)) { return ""; } Modified: branches/amis3/AmisCore/src/io/XercesSaxParseBase.cpp =================================================================== --- branches/amis3/AmisCore/src/io/XercesSaxParseBase.cpp 2007-09-24 14:38:46 UTC (rev 2164) +++ branches/amis3/AmisCore/src/io/XercesSaxParseBase.cpp 2007-09-24 15:04:19 UTC (rev 2165) @@ -47,7 +47,7 @@ { } -bool amis::io::XercesSaxParseBase::parseFile(const ambulant::net::url* filepath, string forcedEncoding) +bool amis::io::XercesSaxParseBase::parseFile(const ambulant::net::url* filepath) { SAX2XMLReader* parser; mFilepath = *filepath; @@ -66,7 +66,6 @@ str.assign(msg); mError.setMessage(str); XMLString::release(&msg); - //cout<<"XML platform utils initialization error"<<endl; return false; } @@ -86,7 +85,6 @@ mError.setMessage(str); delete parser; XMLPlatformUtils::Terminate(); - //cout<<"parsing error."<<endl; return false; } //try-catch block for Xerces parsing @@ -95,24 +93,8 @@ //give the sax parser pointers to our content and error handler object parser->setContentHandler(this); parser->setErrorHandler(this); - - if (forcedEncoding == "") - { - //parser begins parsing; expect SAX Events soon - parser->parse((*p_input_source)); - } - else - { - //reset the error message - mError.clear(); - XMLCh* xmlch_encoding = XMLString::transcode(forcedEncoding.c_str()); - - //todo: flag that we had to set the encoding in case anyone else (like ambulant) needs to be told explicitly - p_input_source->setEncoding(xmlch_encoding); - parser->parse((*p_input_source)); - - XMLString::release(&xmlch_encoding); - } + //parser begins parsing; expect SAX Events soon + parser->parse((*p_input_source)); } catch (const XMLException& toCatch) @@ -125,7 +107,6 @@ XMLString::release(&msg); delete parser; XMLPlatformUtils::Terminate(); - //cout<<"parsing error."<<endl; return false; } @@ -144,16 +125,8 @@ //... } - if (mError.getCode() != amis::OK) - { - //cout<<"parsing error: "<<mError.getMessage()<<endl; - return false; - } - else - { - //cout<<"oh my god, it parsed!"<<endl; - return true; - } + if (mError.getCode() != amis::OK) return false; + else return true; } amis::Error amis::io::XercesSaxParseBase::getError() @@ -172,24 +145,12 @@ } void amis::io::XercesSaxParseBase::fatalError(const SAXParseException& e) -{ - char* verbose_thai_encoding_msg = "An exception occurred! Type:TranscodingException, Message:Could not create a converter for encoding: TIS-620"; - +{ char* xerces_msg = XMLString::transcode(e.getMessage()); mError.setCode (amis::PARSE_ERROR); string msg = "While processing *" + mFilepath.get_url() + "* Xerces signalled: \"" + xerces_msg + "\""; mError.setMessage(msg); - //if the file had problems because it was encoded using TIS-620 - if (!strcmp(xerces_msg, verbose_thai_encoding_msg)) - { - XMLString::release(&xerces_msg); - //reparse with forced encoding - parseFile(&mFilepath, "iso-8859-11"); - } - else - { - XMLString::release(&xerces_msg); - } + XMLString::release(&xerces_msg); } Modified: branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp 2007-09-24 14:38:46 UTC (rev 2164) +++ branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp 2007-09-24 15:04:19 UTC (rev 2165) @@ -72,7 +72,7 @@ { mpPrefs = NULL; ambulant::net::url file = ambulant::net::url::from_filename(filepath); - return this->parseFile(&file, ""); + return this->parseFile(&file); } //-------------- Modified: branches/amis3/installer/main/setup-amis3.nsi =================================================================== --- branches/amis3/installer/main/setup-amis3.nsi 2007-09-24 14:38:46 UTC (rev 2164) +++ branches/amis3/installer/main/setup-amis3.nsi 2007-09-24 15:04:19 UTC (rev 2165) @@ -2,7 +2,7 @@ ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "AMIS" -!define PRODUCT_VERSION "2.6" +!define PRODUCT_VERSION "3.0" !define PRODUCT_PUBLISHER "DAISY for All Project" !define PRODUCT_WEB_SITE "http://amis.sf.net" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\AMIS.exe" @@ -68,9 +68,9 @@ Name "${PRODUCT_NAME} ${PRODUCT_VERSION} (${LANG_NAME})" ;this is the name of the installer that gets created. ;for some reason, i vaguely remember that it shouldn't have spaces in the filename. -OutFile "Setup-amis-26-${DEFAULT_LANGPACK}.exe" +OutFile "Setup-amis-3-${DEFAULT_LANGPACK}.exe" InstallDir "$PROGRAMFILES\AMIS" -;InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" +InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" ShowInstDetails show ShowUnInstDetails show @@ -85,10 +85,9 @@ CreateShortCut "$DESKTOP\AMIS.lnk" "$INSTDIR\AMIS.exe" ;copy the DLLs + File "${BIN_DIR}\libambulant_shwin32.dll" File "${BIN_DIR}\AmisAudio.dll" - File "${BIN_DIR}\AmisCommon.dll" - File "${BIN_DIR}\NavParse.dll" - File "${BIN_DIR}\SmilEngine.dll" + File "${BIN_DIR}\AmisCore.dll" File "${BIN_DIR}\xerces-c_2_7.dll" File "${BIN_DIR}\TransformSample.ax" @@ -97,10 +96,10 @@ File "${BIN_DIR}\settings\bmk\readme.txt" ;copy the default settings - SetOutPath "$INSTDIR\settings\config" - File "${BIN_DIR}\settings\config\amisPrefs.xml" - File "${BIN_DIR}\settings\config\amisRecentBooks.xml" - File "${BIN_DIR}\settings\config\*.css" + SetOutPath "$INSTDIR\settings" + File "${BIN_DIR}\settings\amisPrefs.xml" + File "${BIN_DIR}\settings\amisRecentBooks.xml" + File "${BIN_DIR}\settings\*.css" ;copy the images SetOutPath "$INSTDIR\settings\img" @@ -128,6 +127,10 @@ File "${WIN32_DIR}\MSVCP71.DLL" File "${WIN32_DIR}\MFC71U.DLL" + ;TODO: ask the user if they want to change their registry to support Thai books + ;TODO: if so, add this key in HKLM + ;Software\Classes\MIME\Database\Charset\TIS-620 and set AliasForCharset to windows-874 + SectionEnd ;****************************** @@ -244,7 +247,6 @@ Delete "$INSTDIR\settings\lang\*" Delete "$INSTDIR\settings\img\*" - Delete "$INSTDIR\settings\config\*" Delete "$INSTDIR\settings\bmk\*.txt" Delete "$SMPROGRAMS\AMIS\*" @@ -253,7 +255,6 @@ RMDir "$INSTDIR\settings\lang" RMDir "$INSTDIR\settings\img" - RMDir "$INSTDIR\settings\config" RMDir "$INSTDIR\settings\bmk" RMDir "$INSTDIR" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-24 15:41:06
|
Revision: 2166 http://amis.svn.sourceforge.net/amis/?rev=2166&view=rev Author: marisademeglio Date: 2007-09-24 08:29:30 -0700 (Mon, 24 Sep 2007) Log Message: ----------- fixed CSS problems with contrast and font size Modified Paths: -------------- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/bin/settings/amis-contrast.css branches/amis3/bin/settings/font1.css branches/amis3/bin/settings/font2.css branches/amis3/bin/settings/font3.css branches/amis3/bin/settings/font4.css Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-09-24 15:04:19 UTC (rev 2165) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-09-24 15:29:30 UTC (rev 2166) @@ -349,7 +349,7 @@ //remove the old stylesheet MainWndParts::Instance()->mpHtmlView->removeStylesheet(mpFontCss); - if (fontsz) MainWndParts::Instance()->mpHtmlView->applyStylesheet(&mFontSizeCssFiles[fontsz-1]); + if (fontsz) mpFontCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&mFontSizeCssFiles[fontsz-1]); if (isElementInView(pLastElm) == false) { Modified: branches/amis3/bin/settings/amis-contrast.css =================================================================== --- branches/amis3/bin/settings/amis-contrast.css 2007-09-24 15:04:19 UTC (rev 2165) +++ branches/amis3/bin/settings/amis-contrast.css 2007-09-24 15:29:30 UTC (rev 2166) @@ -1,6 +1,4 @@ /*contrast CSS sheet*/ -body{ background-color: blue; color: white;} -h1 {color: green;} -a {text-decoration: none;} -a:hover {background-color: red;} - +body{ background-color: navy !important; color: white !important;} +a {color: white !important;} +a:hover {color: white !important; font-weight: bolder !important;} Modified: branches/amis3/bin/settings/font1.css =================================================================== --- branches/amis3/bin/settings/font1.css 2007-09-24 15:04:19 UTC (rev 2165) +++ branches/amis3/bin/settings/font1.css 2007-09-24 15:29:30 UTC (rev 2166) @@ -1,9 +1,9 @@ /*whole document body*/ body { - font-size: 150%; - line-spacing: 125% + font-size: 150% !important; + line-spacing: 125% !important; } h1, h2, h3, h4, h5, h6{ - font-size: 150%; + font-size: 150% !important; } Modified: branches/amis3/bin/settings/font2.css =================================================================== --- branches/amis3/bin/settings/font2.css 2007-09-24 15:04:19 UTC (rev 2165) +++ branches/amis3/bin/settings/font2.css 2007-09-24 15:29:30 UTC (rev 2166) @@ -1,9 +1,9 @@ /*whole document body*/ body { - font-size: 175%; - line-spacing: 150% + font-size: 175% !important; + line-spacing: 150% !important; } h1, h2, h3, h4, h5, h6{ - font-size: 175%; + font-size: 175% !important; } Modified: branches/amis3/bin/settings/font3.css =================================================================== --- branches/amis3/bin/settings/font3.css 2007-09-24 15:04:19 UTC (rev 2165) +++ branches/amis3/bin/settings/font3.css 2007-09-24 15:29:30 UTC (rev 2166) @@ -1,9 +1,9 @@ /*whole document body*/ body { - font-size: 200%; - line-spacing: 175% + font-size: 200% !important; + line-spacing: 175% !important; } h1, h2, h3, h4, h5, h6{ - font-size: 200%; + font-size: 200% !important; } Modified: branches/amis3/bin/settings/font4.css =================================================================== --- branches/amis3/bin/settings/font4.css 2007-09-24 15:04:19 UTC (rev 2165) +++ branches/amis3/bin/settings/font4.css 2007-09-24 15:29:30 UTC (rev 2166) @@ -1,9 +1,9 @@ /*whole document body*/ body { - font-size: 225%; - line-spacing: 175% + font-size: 225% !important; + line-spacing: 175% !important; } h1, h2, h3, h4, h5, h6{ - font-size: 225%; + font-size: 225% !important; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-25 12:58:10
|
Revision: 2169 http://amis.svn.sourceforge.net/amis/?rev=2169&view=rev Author: marisademeglio Date: 2007-09-25 05:58:13 -0700 (Tue, 25 Sep 2007) Log Message: ----------- memory leak testing and cleanup Modified Paths: -------------- branches/amis3/AmisCore/testAmisCoreWin32/testAmisCore.cpp branches/amis3/AmisCore/testAmisCoreWin32/testAmisCore.vcproj branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp Modified: branches/amis3/AmisCore/testAmisCoreWin32/testAmisCore.cpp =================================================================== --- branches/amis3/AmisCore/testAmisCoreWin32/testAmisCore.cpp 2007-09-25 12:23:34 UTC (rev 2168) +++ branches/amis3/AmisCore/testAmisCoreWin32/testAmisCore.cpp 2007-09-25 12:58:13 UTC (rev 2169) @@ -1,7 +1,6 @@ // testAmisCore.cpp : Defines the entry point for the console application. // -#include <vld.h> #ifndef TESTAMISCORE #define TESTAMISCORE @@ -18,6 +17,9 @@ #include "ambulant/net/url.h" +#include <vld.h> + + #endif void doPhraseNavInputLoop(amis::dtb::Dtb*); @@ -29,7 +31,7 @@ int _tmain(int argc, _TCHAR* argv[]) { amis::dtb::Dtb* book = new amis::dtb::Dtb(); - if (!book->open("c:\\daisybooks\\Mountains_skip\\ncc.html", "c:\\daisybooks\\bmk\\")) + if (!book->open("file://c:/daisybooks/Mountains_skip/ncc.html", "file://c:/daisybooks/bmk/")) //if (!book->open("c:\\dtb\\ValidZedFromMarkus\\06-speechgen.opf", "c:\\dtb\\bmk\\")) //if (!book->open("d:\\FullPackage.opf", "c:\\dtb\\bmk\\")) cout<<"Error opening book"<<endl; Modified: branches/amis3/AmisCore/testAmisCoreWin32/testAmisCore.vcproj =================================================================== --- branches/amis3/AmisCore/testAmisCoreWin32/testAmisCore.vcproj 2007-09-25 12:23:34 UTC (rev 2168) +++ branches/amis3/AmisCore/testAmisCoreWin32/testAmisCore.vcproj 2007-09-25 12:58:13 UTC (rev 2169) @@ -12,18 +12,18 @@ <Configurations> <Configuration Name="Debug|Win32" - OutputDirectory="../../../bin" + OutputDirectory="../../bin" IntermediateDirectory="Debug" ConfigurationType="1" CharacterSet="1"> <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="C:\devel\ambulant\include;"C:\Program Files\Visual Leak Detector\include";../../include" + AdditionalIncludeDirectories="C:\devel\ambulant\include;"C:\Program Files\Visual Leak Detector";../include" PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" MinimalRebuild="TRUE" BasicRuntimeChecks="3" - RuntimeLibrary="1" + RuntimeLibrary="3" UsePrecompiledHeader="3" WarningLevel="3" Detect64BitPortabilityProblems="TRUE" @@ -35,8 +35,8 @@ AdditionalDependencies="xerces-c_2D.lib libambulant_shwin32_D.lib AmisCoreD.lib" OutputFile="$(OutDir)/testAmisCoreD.exe" LinkIncremental="2" - AdditionalLibraryDirectories=""C:\Program Files\Visual Leak Detector\lib";../../../../../../ambulant/lib/win32;../../../lib" - IgnoreDefaultLibraryNames="uafxcwd.lib;uafxcw.lib;LIBCD.lib;LIBC.lib;msvcrt.lib;libcmt.lib;libcmtd.lib" + AdditionalLibraryDirectories="../../../../../ambulant/lib/win32;../../lib;"C:\Program Files\Visual Leak Detector"" + IgnoreDefaultLibraryNames="" GenerateDebugInformation="TRUE" ProgramDatabaseFile="$(OutDir)/testAmisCore.pdb" SubSystem="1" Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-09-25 12:23:34 UTC (rev 2168) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-09-25 12:58:13 UTC (rev 2169) @@ -20,7 +20,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="include;../../../../ambulant/include/;"../../../../ambulant-private/pdtbplugin";"../../../../ambulant-private/pdtbplugin/PdtbIePlugin";../AmisCore/include;"../../../../xerces-c-src/src";../3rdPartyAudio;../mffmTimeCode;" + AdditionalIncludeDirectories="include;../../../../ambulant/include/;"../../../../ambulant-private/pdtbplugin";"../../../../ambulant-private/pdtbplugin/PdtbIePlugin";../AmisCore/include;"../../../../xerces-c-src/src";../3rdPartyAudio;../mffmTimeCode;"C:\Program Files\Visual Leak Detector"" PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG" MinimalRebuild="TRUE" BasicRuntimeChecks="3" @@ -37,7 +37,7 @@ Name="VCLinkerTool" AdditionalDependencies="AmisCoreD.lib xerces-c_2D.lib libambulant_shwin32_D.lib AmisAudioD.lib vorbisfile_static.lib vorbisenc_static.lib vorbis_static.lib ogg_static.lib libmad.lib stlib.lib fftw3.lib audiere.lib" LinkIncremental="2" - AdditionalLibraryDirectories="../lib;../../../../ambulant/lib/win32;"$(VSInstallDir)\..\Microsoft Speech SDK 5.1\Lib\i386"" + AdditionalLibraryDirectories="../lib;../../../../ambulant/lib/win32;"$(VSInstallDir)\..\Microsoft Speech SDK 5.1\Lib\i386";"C:\Program Files\Visual Leak Detector"" IgnoreDefaultLibraryNames="uafxcwd.lib;uafxcw.lib;LIBCD.lib;LIBC.lib;msvcrt.lib;libcmt.lib" GenerateDebugInformation="TRUE" SubSystem="2" Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-09-25 12:23:34 UTC (rev 2168) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-09-25 12:58:13 UTC (rev 2169) @@ -21,12 +21,13 @@ */ // AmisGuiMFC2.h : main header file for the AmisGuiMFC2 application // + #pragma once - #ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH #endif + #include "resource.h" // main symbols #include <string> Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-25 12:23:34 UTC (rev 2168) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-25 12:58:13 UTC (rev 2169) @@ -23,9 +23,16 @@ #include "stdafx.h" #include "../resource.h" + +//visual leak detector +//http://dmoulding.googlepages.com/vld +#include "vld.h" + + #include "dtb/nav/NavModel.h" #include "DtbWithHooks.h" +#include "Preferences.h" #include "io/RecentBooksFileIO.h" @@ -39,6 +46,7 @@ #include "gui/TextRenderBrain.h" #include "gui/sidebar/AmisSidebar.h" +#include "gui/sidebar/AmisSidebarLoader.h" #include "gui/dialogs/AmisFileDialog.h" #include "gui/dialogs/AboutDialog.h" @@ -179,6 +187,14 @@ if (m_hMDIAccel != NULL)FreeResource(m_hMDIAccel); amis::dtb::DtbWithHooks::Instance()->DestroyInstance(); + amis::Preferences::Instance()->DestroyInstance(); + amis::gui::sidebar::AmisSidebarLoader::Instance()->DestroyInstance(); + amis::gui::TextRenderBrain::Instance()->DestroyInstance(); + amis::gui::MenuManip::Instance()->DestroyInstance(); + amis::gui::MainWndParts::Instance()->DestroyInstance(); + + if (mpRecentBooks) delete mpRecentBooks; + return CWinApp::ExitInstance(); } Modified: branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2007-09-25 12:23:34 UTC (rev 2168) +++ branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2007-09-25 12:58:13 UTC (rev 2169) @@ -251,6 +251,7 @@ { topView = NULL; MainWndParts::Instance()->mpMmView = NULL; + gui::dx::dx_player::cleanup(); } BOOL MmView::PreCreateWindow(CREATESTRUCT& cs) Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-09-25 12:23:34 UTC (rev 2168) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-09-25 12:58:13 UTC (rev 2169) @@ -78,10 +78,20 @@ mpFontCss = NULL; mpContrastCss = NULL; mpDefaultCss = NULL; + } TextRenderBrain::~TextRenderBrain() { + + //these crash.. + + /*if (mpFontCss) delete mpFontCss; + if (mpContrastCss) delete mpContrastCss; + if (mpDefaultCss) delete mpDefaultCss; + */ + + //TODO: should delete variants too } void TextRenderBrain::highlightUriTarget(amis::TextNode* pText) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-25 15:45:36
|
Revision: 2170 http://amis.svn.sourceforge.net/amis/?rev=2170&view=rev Author: marisademeglio Date: 2007-09-25 08:45:36 -0700 (Tue, 25 Sep 2007) Log Message: ----------- Started re-adding protected book support. The compiler gives a nonsense error in Dtb.cpp and I was in the middle of removing all new stuff (only 3 functions) and testing bit by bit. However, it's the end of the day, so this stuff will wait 'til tomorrow. Modified Paths: -------------- branches/amis3/AmisCore/include/dtb/Dtb.h branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp Modified: branches/amis3/AmisCore/include/dtb/Dtb.h =================================================================== --- branches/amis3/AmisCore/include/dtb/Dtb.h 2007-09-25 12:58:13 UTC (rev 2169) +++ branches/amis3/AmisCore/include/dtb/Dtb.h 2007-09-25 15:45:36 UTC (rev 2170) @@ -69,6 +69,7 @@ ambulant::net::url calculateUriOfData(amis::dtb::smil::SmilMediaGroup*); int getDaisyVersion(); + //bool isProtected(); private: bool processNcc(const ambulant::net::url*); @@ -80,6 +81,8 @@ void cleanUpObjects(); void setNewLastmark(amis::dtb::smil::SmilMediaGroup*); string searchFullTextRelative(int); + //bool registerBookKeyFile(const ambulant::net::url*); + //bool checkForCopyProtection(amis::dtb::Metadata*); private: amis::dtb::Metadata* mpMetadata; @@ -97,6 +100,9 @@ string mLastSearchResult; string mLastSearchedTextFile; int mDaisyVersion; + //bool mbIsProtected; + //ambulant::net::url mBookKeyFile; + //ambulant::net::url mNccPdtbFile; }; } Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-25 12:58:13 UTC (rev 2169) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-25 15:45:36 UTC (rev 2170) @@ -28,7 +28,13 @@ #include "io/TextSearch.h" #include "io/OpfFileReader.h" #include "io/NcxFileReader.h" + +#if defined(AMIS_COMPILER_MSVC) +//windows header containing charset conversion macros +#include <afxpriv.h> +#endif +//#include "ambulant/common/plugin_engine.h" //constructor amis::dtb::Dtb::Dtb() @@ -55,6 +61,8 @@ //delete objects void amis::dtb::Dtb::cleanUpObjects() { + mbIsProtected = false; + if (mpFiles != NULL) delete mpFiles; if (mpSmilTree != NULL) @@ -208,6 +216,23 @@ mpMetadata = ncc_file_reader.getMetadata(); mpCustomTests = ncc_file_reader.getCustomTests(); + //if this NCC file turned out to be a protected book, then we need to get custom tests and a nav model + //from an encrypted file + if (1)// (checkForCopyProtection(mpMetadata)) + { + /* mbIsProtected = true; + if (mpNavModel) delete mpNavModel; + if (mpCustomTests) delete mpCustomTests; + + //register key file with ambulant + this->registerBookKeyFile(&mBookKeyFile); + //reparse the ncc.pdtb file + if (!ncc_file_reader.readFromFile(&mNccPdtbFile)) return false; + + mpNavModel = ncc_file_reader.getNavModel(); + mpCustomTests = ncc_file_reader.getCustomTests();*/ + } + mpSpine = spine_visitor.getSpine(mpNavModel, this->getFileSet()->getBookDirectory()); mUid = getUid(); @@ -586,3 +611,57 @@ return p_bmk; } +//set the book key in the ambulant plugin engine +/* +bool amis::dtb::Dtb::registerBookKeyFile(const ambulant::net::url* key) +{ + // Check whether the plugin is available. + /*ambulant::common::plugin_engine *pe = ambulant::common::plugin_engine::get_plugin_engine(); + assert(pe); + pdtb_plugin_interface *pdata = (pdtb_plugin_interface *)pe->get_extra_data("pdtb_plugin"); + if (!pdata) return false; //TODO give error message + return pdata->set_key(mURL, key); + return false; +}*/ + +//this function looks at the metadata and decides if the book is a protected book +//if so, the book key and "real" ncc file path are saved +/* +bool amis::dtb::Dtb::checkForCopyProtection(amis::dtb::Metadata* pMetadata) +{ +#if defined(AMIS_COMPILER_MSVC) + //windows utility for converting wstring to string + USES_CONVERSION; +#endif + + if (!pMetadata) return false; + + //metadata uses wide strings + std::wstring w_version = pMetadata->getMetadata("prod:pdtb-version"); + std::wstring w_key = pMetadata->getMetadata("prod:pdtb-bookKey"); + std::wstring w_ncc = pMetadata->getMetadata("prod:pdtb-nccFile"); + +#if defined(AMIS_COMPILER_MSVC) + std::string s_version = T2A(w_version.c_str()); + std::string s_key = T2A(w_key.c_str()); + std::string s_ncc = T2A(w_ncc.c_str()); +#else + //TODO convert the strings on other platforms +#endif + + if (s_version == "1.0.0" && s_key != "" && s_ncc != "") + { + ambulant::net::url keyfile = ambulant::net::url::from_filename(s_key); + ambulant::net::url ncc = ambulant::net::url::from_filename(s_ncc); + mBookKeyFile = keyfile.join_to_base(*getFileSet()->getBookDirectory()); + mNccPdtbFile = ncc.join_to_base(*getFileSet()->getBookDirectory()); + return true; + } + else return false; +} +*/ +//just in case this info is useful to anyone +/*bool amis::dtb::Dtb::isProtected() +{ + return mbIsProtected; +}*/ \ No newline at end of file Modified: branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-09-25 12:58:13 UTC (rev 2169) +++ branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-09-25 15:45:36 UTC (rev 2170) @@ -150,7 +150,8 @@ //convert the string to lower case before doing a comparison std::transform(file_name.begin(), file_name.end(), file_name.begin(), (int(*)(int))tolower); - if (file_name.compare("ncc.html") == 0) + if (file_name.compare("ncc.html") == 0 || + file_name.compare("ncc.pdtb") == 0) return true; else return false; Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-09-25 12:58:13 UTC (rev 2169) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-09-25 15:45:36 UTC (rev 2170) @@ -20,7 +20,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="include;../../../../ambulant/include/;"../../../../ambulant-private/pdtbplugin";"../../../../ambulant-private/pdtbplugin/PdtbIePlugin";../AmisCore/include;"../../../../xerces-c-src/src";../3rdPartyAudio;../mffmTimeCode;"C:\Program Files\Visual Leak Detector"" + AdditionalIncludeDirectories="include;../../../../ambulant/include/;"../../../../ambulant-private/pdtbplugin";"../../../../ambulant-private/pdtbplugin/PdtbIePlugin";../AmisCore/include;"../../../../xerces-c-src/src";../3rdPartyAudio;../mffmTimeCode" PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG" MinimalRebuild="TRUE" BasicRuntimeChecks="3" @@ -37,7 +37,7 @@ Name="VCLinkerTool" AdditionalDependencies="AmisCoreD.lib xerces-c_2D.lib libambulant_shwin32_D.lib AmisAudioD.lib vorbisfile_static.lib vorbisenc_static.lib vorbis_static.lib ogg_static.lib libmad.lib stlib.lib fftw3.lib audiere.lib" LinkIncremental="2" - AdditionalLibraryDirectories="../lib;../../../../ambulant/lib/win32;"$(VSInstallDir)\..\Microsoft Speech SDK 5.1\Lib\i386";"C:\Program Files\Visual Leak Detector"" + AdditionalLibraryDirectories="../lib;../../../../ambulant/lib/win32;"$(VSInstallDir)\..\Microsoft Speech SDK 5.1\Lib\i386"" IgnoreDefaultLibraryNames="uafxcwd.lib;uafxcw.lib;LIBCD.lib;LIBC.lib;msvcrt.lib;libcmt.lib" GenerateDebugInformation="TRUE" SubSystem="2" @@ -133,6 +133,9 @@ RelativePath=".\include\DtbWithHooks.h"> </File> <File + RelativePath=".\include\pdtb.h"> + </File> + <File RelativePath=".\include\Preferences.h"> </File> <File @@ -268,6 +271,9 @@ </FileConfiguration> </File> <File + RelativePath=".\src\pdtb.cpp"> + </File> + <File RelativePath=".\src\Preferences.cpp"> </File> <File Modified: branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2007-09-25 12:58:13 UTC (rev 2169) +++ branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2007-09-25 15:45:36 UTC (rev 2170) @@ -55,7 +55,7 @@ amis::dtb::Bookmark* addBookmark(); void loadBookmark(int); amis::dtb::smil::SmilMediaGroup* loadSmilFromUrl(const ambulant::net::url*); - + private: void addToRecentBooks(); void makeAllNavContainerLabelsHumanReadable(); Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-09-25 12:58:13 UTC (rev 2169) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-09-25 15:45:36 UTC (rev 2170) @@ -332,4 +332,5 @@ amis::gui::MainWndParts::Instance()->mpMmDoc->OnOpenDocument(A2T(full_path.get_url().c_str())); } return NULL; -} \ No newline at end of file +} + Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-25 12:58:13 UTC (rev 2169) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-25 15:45:36 UTC (rev 2170) @@ -23,12 +23,8 @@ #include "stdafx.h" #include "../resource.h" +#include "pdtb.h" -//visual leak detector -//http://dmoulding.googlepages.com/vld -#include "vld.h" - - #include "dtb/nav/NavModel.h" #include "DtbWithHooks.h" @@ -175,6 +171,9 @@ pFrame->ShowWindow(SW_SHOWMAXIMIZED); pFrame->UpdateWindow(); + //load user keys into the ambulant plugin engine + addUserKeysToAmbulantPluginEngine(); + return TRUE; } @@ -252,19 +251,29 @@ { amis::gui::dialogs::AmisFileDialog* p_dlg = new amis::gui::dialogs::AmisFileDialog(amis::gui::dialogs::AmisFileDialog::getFileOpenFilter()); string filename = p_dlg->showOpen(); - ambulant::net::url filename_url = ambulant::net::url::from_filename(filename); + + //the user is able to open UAK files through AMIS + if (isUakFile(filename)) + { + importUakIntoRegistry(filename); + } - if (!filename_url.is_empty_path()) + //else it's a book + else { - if (amis::dtb::DtbWithHooks::Instance()->open(&filename_url, &very_temporary_bookmarks_dir)) + ambulant::net::url filename_url = ambulant::net::url::from_filename(filename); + if (!filename_url.is_empty_path()) { - mbBookIsOpen = true; - amis::dtb::DtbWithHooks::Instance()->startReading(true); + if (amis::dtb::DtbWithHooks::Instance()->open(&filename_url, &very_temporary_bookmarks_dir)) + { + mbBookIsOpen = true; + amis::dtb::DtbWithHooks::Instance()->startReading(true); + } + else + { + //TODO give an error that book could not be opened + } } - else - { - //TODO give an error that book could not be opened - } } } Modified: branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2007-09-25 12:58:13 UTC (rev 2169) +++ branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2007-09-25 15:45:36 UTC (rev 2170) @@ -251,7 +251,7 @@ { topView = NULL; MainWndParts::Instance()->mpMmView = NULL; - gui::dx::dx_player::cleanup(); + ambulant::gui::dx::dx_player::cleanup(); } BOOL MmView::PreCreateWindow(CREATESTRUCT& cs) Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-09-25 12:58:13 UTC (rev 2169) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-09-25 15:45:36 UTC (rev 2170) @@ -196,6 +196,7 @@ LPCTSTR tmp; tmp = (LPCTSTR)temp_cstr; mCurrentElmText.assign ((LPCTSTR)temp_cstr); + SysFreeString(attr_val.bstrVal); } else { @@ -207,6 +208,7 @@ LPCTSTR tmp; tmp = (LPCTSTR)temp_cstr; mCurrentElmText.assign ((LPCTSTR)temp_cstr); + SysFreeString(inner_text); } } Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp 2007-09-25 12:58:13 UTC (rev 2169) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp 2007-09-25 15:45:36 UTC (rev 2170) @@ -60,9 +60,7 @@ filter += _T("ncc.*; *.opf"); filter += _T(")|"); filter += _T("ncc.*; *.opf"); -#ifdef WITH_DAISY_PDTB filter += _T("|DAISY Pdtb Keys (*.uak)|*.uak"); -#endif filter += _T("||"); return filter; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-26 00:03:50
|
Revision: 2172 http://amis.svn.sourceforge.net/amis/?rev=2172&view=rev Author: marisademeglio Date: 2007-09-25 17:03:54 -0700 (Tue, 25 Sep 2007) Log Message: ----------- Hooked up everything for PDTB support. The last issue is in this function: pdtb.cpp -> registerBookKeyFile the function gets called with the correct parameters, but it feels like ambulant doesn't see the pdtb plugin. (even after i remembered to reroute the pdtbplugin projects' build outputs to the AMIS3 branch.). Modified Paths: -------------- branches/amis3/AmisCore/include/dtb/Dtb.h branches/amis3/AmisCore/include/dtb/DtbFileSet.h branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/VC7/amis.sln Modified: branches/amis3/AmisCore/include/dtb/Dtb.h =================================================================== --- branches/amis3/AmisCore/include/dtb/Dtb.h 2007-09-25 15:58:17 UTC (rev 2171) +++ branches/amis3/AmisCore/include/dtb/Dtb.h 2007-09-26 00:03:54 UTC (rev 2172) @@ -36,6 +36,8 @@ { namespace dtb { +typedef bool (*ProtectedBookKeyHandlerFunctionPtr)(const ambulant::net::url*, const ambulant::net::url*); + class Dtb { public: @@ -69,7 +71,8 @@ ambulant::net::url calculateUriOfData(amis::dtb::smil::SmilMediaGroup*); int getDaisyVersion(); - //bool isProtected(); + bool isProtected(); + void setCallbackForPreprocessingBookKey(ProtectedBookKeyHandlerFunctionPtr); private: bool processNcc(const ambulant::net::url*); @@ -81,8 +84,7 @@ void cleanUpObjects(); void setNewLastmark(amis::dtb::smil::SmilMediaGroup*); string searchFullTextRelative(int); - //bool registerBookKeyFile(const ambulant::net::url*); - //bool checkForCopyProtection(amis::dtb::Metadata*); + bool checkForCopyProtection(amis::dtb::Metadata*); private: amis::dtb::Metadata* mpMetadata; @@ -100,10 +102,8 @@ string mLastSearchResult; string mLastSearchedTextFile; int mDaisyVersion; - //bool mbIsProtected; - //ambulant::net::url mBookKeyFile; - //ambulant::net::url mNccPdtbFile; - + bool mbIsProtected; + ProtectedBookKeyHandlerFunctionPtr mpCallbackForPreprocessingBookKey; }; } } Modified: branches/amis3/AmisCore/include/dtb/DtbFileSet.h =================================================================== --- branches/amis3/AmisCore/include/dtb/DtbFileSet.h 2007-09-25 15:58:17 UTC (rev 2171) +++ branches/amis3/AmisCore/include/dtb/DtbFileSet.h 2007-09-26 00:03:54 UTC (rev 2172) @@ -58,6 +58,11 @@ void setTextFile(const ambulant::net::url*); amis::UrlList* getTextFiles(); + void setProtectedNavFilepath(const ambulant::net::url*); + const ambulant::net::url* getProtectedNavFilepath(); + void setProtectedBookKeyFilepath(const ambulant::net::url*); + const ambulant::net::url* getProtectedBookKeyFilepath(); + private: string calculateSafeBookmarksFilename(wstring); void findTextFiles(); @@ -69,6 +74,8 @@ ambulant::net::url mBookmarksDirectory; ambulant::net::url mBookmarksFilepath; ambulant::net::url mSmilFilepath; + ambulant::net::url mProtectedNavFilepath; + ambulant::net::url mProtectedBookKeyFilepath; UrlList mTextFiles; }; } Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-25 15:58:17 UTC (rev 2171) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-26 00:03:54 UTC (rev 2172) @@ -19,6 +19,11 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "AmisCore.h" +#if defined(AMIS_COMPILER_MSVC) +//windows header containing charset conversion macros +#include <afxpriv.h> +#endif #include "dtb/Dtb.h" #include "io/NccFileReader.h" @@ -28,13 +33,8 @@ #include "io/TextSearch.h" #include "io/OpfFileReader.h" #include "io/NcxFileReader.h" - -#if defined(AMIS_COMPILER_MSVC) -//windows header containing charset conversion macros -#include <afxpriv.h> -#endif -//#include "ambulant/common/plugin_engine.h" +#include "ambulant/common/plugin_engine.h" //constructor amis::dtb::Dtb::Dtb() @@ -51,6 +51,7 @@ mpCustomTests = NULL; mUid.erase(); mDaisyVersion = 0; + mpCallbackForPreprocessingBookKey = NULL; } //destructor amis::dtb::Dtb::~Dtb() @@ -136,8 +137,6 @@ mpFiles->initWithNccOrOpf(fileUrl); mpFiles->setBookmarksDirectory(bookmarksDirectory); - //mpFiles->print(); - if (DtbFileSet::isNccFile(fileUrl)) { mDaisyVersion = 2; @@ -218,19 +217,28 @@ //if this NCC file turned out to be a protected book, then we need to get custom tests and a nav model //from an encrypted file - if (1)// (checkForCopyProtection(mpMetadata)) + if (checkForCopyProtection(mpMetadata)) { - /* mbIsProtected = true; + mbIsProtected = true; if (mpNavModel) delete mpNavModel; if (mpCustomTests) delete mpCustomTests; - //register key file with ambulant - this->registerBookKeyFile(&mBookKeyFile); - //reparse the ncc.pdtb file - if (!ncc_file_reader.readFromFile(&mNccPdtbFile)) return false; + if (mpCallbackForPreprocessingBookKey != NULL) + { + if (mpCallbackForPreprocessingBookKey( + getFileSet()->getProtectedNavFilepath(), + getFileSet()->getProtectedBookKeyFilepath() + ) == true) + { + //reparse the ncc.pdtb file + if (!ncc_file_reader.readFromFile(getFileSet()->getProtectedNavFilepath())) return false; - mpNavModel = ncc_file_reader.getNavModel(); - mpCustomTests = ncc_file_reader.getCustomTests();*/ + mpNavModel = ncc_file_reader.getNavModel(); + mpCustomTests = ncc_file_reader.getCustomTests(); + } + else return false; //TODO error message + } + else return false; //TODO error message } mpSpine = spine_visitor.getSpine(mpNavModel, this->getFileSet()->getBookDirectory()); @@ -238,7 +246,7 @@ mUid = getUid(); mpFiles->setAdditionalDataAfterInitialParse(this->mUid, NULL, NULL); amis::dtb::nav::ResolveSmilDataVisitor resolve_smil_visitor; - resolve_smil_visitor.resolve(mpNavModel, mpSpine, /*mpFiles->getBookDirectory(),*/ true); + resolve_smil_visitor.resolve(mpNavModel, mpSpine, true); this->mpTextSmilMap = resolve_smil_visitor.getSmilTextMap(); } @@ -257,7 +265,7 @@ //note that this step takes a very long time if the book is large, because //it involves walking the nav model and also opening all the SMIL files - resolve_smil_visitor.resolve(mpNavModel, mpSpine, /*mpFiles->getBookDirectory(),*/ false); + resolve_smil_visitor.resolve(mpNavModel, mpSpine, false); this->mpTextSmilMap = resolve_smil_visitor.getSmilTextMap(); } @@ -611,29 +619,24 @@ return p_bmk; } -//set the book key in the ambulant plugin engine -/* -bool amis::dtb::Dtb::registerBookKeyFile(const ambulant::net::url* key) +//set the function that deals with protected books +//in our case (amis-ambulant), the callback will register the key file with the decryption plugin +//I decided to do this instead of linking the plugin to AmisCore directly +//the callback here will get invoked during processNcc +void amis::dtb::Dtb::setCallbackForPreprocessingBookKey(ProtectedBookKeyHandlerFunctionPtr pFunction) { - // Check whether the plugin is available. - /*ambulant::common::plugin_engine *pe = ambulant::common::plugin_engine::get_plugin_engine(); - assert(pe); - pdtb_plugin_interface *pdata = (pdtb_plugin_interface *)pe->get_extra_data("pdtb_plugin"); - if (!pdata) return false; //TODO give error message - return pdata->set_key(mURL, key); - return false; -}*/ + mpCallbackForPreprocessingBookKey = pFunction; +} + //this function looks at the metadata and decides if the book is a protected book //if so, the book key and "real" ncc file path are saved -/* bool amis::dtb::Dtb::checkForCopyProtection(amis::dtb::Metadata* pMetadata) { #if defined(AMIS_COMPILER_MSVC) //windows utility for converting wstring to string USES_CONVERSION; #endif - if (!pMetadata) return false; //metadata uses wide strings @@ -653,15 +656,15 @@ { ambulant::net::url keyfile = ambulant::net::url::from_filename(s_key); ambulant::net::url ncc = ambulant::net::url::from_filename(s_ncc); - mBookKeyFile = keyfile.join_to_base(*getFileSet()->getBookDirectory()); - mNccPdtbFile = ncc.join_to_base(*getFileSet()->getBookDirectory()); + getFileSet()->setProtectedBookKeyFilepath(&keyfile.join_to_base(*getFileSet()->getBookDirectory())); + getFileSet()->setProtectedNavFilepath(&ncc.join_to_base(*getFileSet()->getBookDirectory())); return true; } else return false; } -*/ + //just in case this info is useful to anyone -/*bool amis::dtb::Dtb::isProtected() +bool amis::dtb::Dtb::isProtected() { return mbIsProtected; -}*/ \ No newline at end of file +} \ No newline at end of file Modified: branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-09-25 15:58:17 UTC (rev 2171) +++ branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-09-26 00:03:54 UTC (rev 2172) @@ -274,3 +274,24 @@ { return &mTextFiles; } + +//this should be a full path (inconsistent, I know, but at least documented) +void amis::dtb::DtbFileSet::setProtectedNavFilepath(const ambulant::net::url* file) +{ + mProtectedNavFilepath = *file; +} + +const ambulant::net::url* amis::dtb::DtbFileSet::getProtectedNavFilepath() +{ + return &mProtectedNavFilepath; +} + +//this should be a full path +void amis::dtb::DtbFileSet::setProtectedBookKeyFilepath(const ambulant::net::url* file) +{ + mProtectedBookKeyFilepath = *file; +} +const ambulant::net::url* amis::dtb::DtbFileSet::getProtectedBookKeyFilepath() +{ + return &mProtectedBookKeyFilepath; +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-25 15:58:17 UTC (rev 2171) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-26 00:03:54 UTC (rev 2172) @@ -173,6 +173,8 @@ //load user keys into the ambulant plugin engine addUserKeysToAmbulantPluginEngine(); + //set the callback function to handle book key registration + amis::dtb::DtbWithHooks::Instance()->setCallbackForPreprocessingBookKey(registerBookKeyFile); return TRUE; } @@ -253,9 +255,9 @@ string filename = p_dlg->showOpen(); //the user is able to open UAK files through AMIS - if (isUakFile(filename)) + if (isUserKeyFile(filename)) { - importUakIntoRegistry(filename); + importUserKeysIntoRegistry(filename); } //else it's a book Modified: branches/amis3/VC7/amis.sln =================================================================== --- branches/amis3/VC7/amis.sln 2007-09-25 15:58:17 UTC (rev 2171) +++ branches/amis3/VC7/amis.sln 2007-09-26 00:03:54 UTC (rev 2172) @@ -17,6 +17,14 @@ {E0F81CE5-9C15-4E36-BC71-42BE1C0F2406} = {E0F81CE5-9C15-4E36-BC71-42BE1C0F2406} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pdtbplugin", "..\..\..\..\ambulant-private\pdtbplugin\pdtbplugin.vcproj", "{D909EB3F-6D3E-43D5-ADFF-190F3F9EA840}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PdtbIePlugin", "..\..\..\..\ambulant-private\pdtbplugin\PdtbIePlugin\PdtbIePlugin.vcproj", "{8B8E82A3-277F-4486-8D6A-4BCFB2DE3464}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug @@ -39,6 +47,14 @@ {A7A37247-BAAC-4376-8354-96A8C09F926A}.Debug.Build.0 = Debug|Win32 {A7A37247-BAAC-4376-8354-96A8C09F926A}.Release.ActiveCfg = Release|Win32 {A7A37247-BAAC-4376-8354-96A8C09F926A}.Release.Build.0 = Release|Win32 + {D909EB3F-6D3E-43D5-ADFF-190F3F9EA840}.Debug.ActiveCfg = Debug|Win32 + {D909EB3F-6D3E-43D5-ADFF-190F3F9EA840}.Debug.Build.0 = Debug|Win32 + {D909EB3F-6D3E-43D5-ADFF-190F3F9EA840}.Release.ActiveCfg = Release|Win32 + {D909EB3F-6D3E-43D5-ADFF-190F3F9EA840}.Release.Build.0 = Release|Win32 + {8B8E82A3-277F-4486-8D6A-4BCFB2DE3464}.Debug.ActiveCfg = Debug|Win32 + {8B8E82A3-277F-4486-8D6A-4BCFB2DE3464}.Debug.Build.0 = Debug|Win32 + {8B8E82A3-277F-4486-8D6A-4BCFB2DE3464}.Release.ActiveCfg = Release|Win32 + {8B8E82A3-277F-4486-8D6A-4BCFB2DE3464}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-27 13:51:22
|
Revision: 2179 http://amis.svn.sourceforge.net/amis/?rev=2179&view=rev Author: marisademeglio Date: 2007-09-27 06:51:22 -0700 (Thu, 27 Sep 2007) Log Message: ----------- If the key doesn't work for the protected book, then the book is played as normal. To test: other cases where opening a book fails (see if the last-read book is loaded instead) Also fixed: a bug in ResolveSmilDataVisitor Modified Paths: -------------- branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/pdtb.cpp Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-27 12:15:02 UTC (rev 2178) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-27 13:51:22 UTC (rev 2179) @@ -220,8 +220,6 @@ if (checkForCopyProtection(mpMetadata)) { mbIsProtected = true; - if (mpNavModel) delete mpNavModel; - if (mpCustomTests) delete mpCustomTests; if (mpCallbackForPreprocessingBookKey != NULL) { @@ -233,12 +231,16 @@ //reparse the ncc.pdtb file if (!ncc_file_reader.readFromFile(getFileSet()->getProtectedNavFilepath())) return false; + if (mpNavModel) delete mpNavModel; + if (mpCustomTests) delete mpCustomTests; mpNavModel = ncc_file_reader.getNavModel(); mpCustomTests = ncc_file_reader.getCustomTests(); } - else return false; //TODO error message } - else return false; //TODO error message + /* if: 1. no function registered to handle protected books or + 2. that function failed + then: playback of NCC.html continues and it will say "this book is protected... " + */ } mpSpine = spine_visitor.getSpine(mpNavModel, this->getFileSet()->getBookDirectory()); Modified: branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-09-27 12:15:02 UTC (rev 2178) +++ branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-09-27 13:51:22 UTC (rev 2179) @@ -160,7 +160,7 @@ //is this an opf file? bool amis::dtb::DtbFileSet::isOpfFile(const ambulant::net::url* filepath) { - string file_ext = amis::util::FilePathTools::getFileName(filepath->get_path()); + string file_ext = amis::util::FilePathTools::getExtension(filepath->get_path()); //convert the string to lower case before doing a comparison std::transform(file_ext.begin(), file_ext.end(), file_ext.begin(), (int(*)(int))tolower); @@ -202,6 +202,8 @@ else if(safe_filename[i] == ':') safe_filename.replace(i, 1, "__"); + else if(safe_filename[i] == ' ') + safe_filename.replace(i, 1, "__"); } safe_filename.append(".bmk"); Modified: branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp 2007-09-27 12:15:02 UTC (rev 2178) +++ branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp 2007-09-27 13:51:22 UTC (rev 2179) @@ -66,7 +66,12 @@ return; mpPreviousNavNode = NULL; + //this is the map of NavNodes to smil ids (one id to many nodes) + //an id in section 1.1 is in section 1.1 and not in section 1 + //an id in any section may also be referenced by a page node mpMap = new NodeRefMap; + + //a map of text ids and the smil files they occur in mpTextMap = new StringMap; unsigned int i = 0; @@ -79,12 +84,19 @@ //have their audio data filled in (this data isn't built into the NCC files) if (resolveNavNodeAudioData == true) { + //who = which nav nodes WhoRefersToThisSmilFile who_visitor; p_nav_nodes = who_visitor.findOut(pModel, pSpine->getSmilFilePath(i)); } - const ambulant::net::url* smilfile = pSpine->getSmilFilePath(i);//->join_to_base(*bookDir); + const ambulant::net::url* smilfile = pSpine->getSmilFilePath(i); amis::io::QuickDataSmilFileReader quick_reader; + //get all the ids and text src's from this smil file. also fill in the audio data for the nav nodes. + //big id list is a list of all SMIL element IDs + //text map is a map of the smilfile name and the text src in it + //p_nav_nodes is a list of pointers to nav nodes that refer to this smil file quick_reader.readFromFile(smilfile, &mBigIdList, mpTextMap, p_nav_nodes); + + //this deletes a pointer to a list of pointers, not the nodes themselves if (p_nav_nodes != NULL) delete p_nav_nodes; } @@ -183,7 +195,7 @@ else { //look for the end of the range - for (it_b = it_a + 1; it_b <= mBigIdList.end(); it_b++) + for (it_b = it_a; it_b < mBigIdList.end(); it_b++) { if ((*it_b).compare(b) == 0) { Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-09-27 12:15:02 UTC (rev 2178) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-09-27 13:51:22 UTC (rev 2179) @@ -88,6 +88,8 @@ private: void initPathsAndFiles(); + void openBook(const ambulant::net::url*); + void openLastReadBook(); std::string mAppPath; std::string mLocalizationDll; ambulant::net::url mURL; Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-27 12:15:02 UTC (rev 2178) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-27 13:51:22 UTC (rev 2179) @@ -105,6 +105,9 @@ BOOL CAmisGuiMFC2App::InitInstance() { + //this says "use the registry instead of ini files" (for windows-specific app preferences). we use it for UAKs + SetRegistryKey(_T("Amis")); + // InitCommonControls() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. @@ -248,34 +251,61 @@ return mpRecentBooks; } +void CAmisGuiMFC2App::openBook(const ambulant::net::url* filename) +{ + bool b_a_book_was_open = false; + //close the open book + if (mbBookIsOpen == true) + { + b_a_book_was_open = true; + OnFileClose(); + } + + if (!filename->is_empty_path()) + { + if (amis::dtb::DtbWithHooks::Instance()->open(filename, &very_temporary_bookmarks_dir)) + { + mbBookIsOpen = true; + amis::dtb::DtbWithHooks::Instance()->startReading(true); + } + else + { + //TODO localize these messages + CString message1 = _T("Error opening book"); + CString message2 = _T("Error opening book. Reloading previous book."); + + if (b_a_book_was_open) + { + AfxMessageBox(message2); + openLastReadBook(); + } + else AfxMessageBox(message1); + } + } +} +void CAmisGuiMFC2App::openLastReadBook() +{ + //close any open book + OnFileClose(); + + if (mpRecentBooks->getLastRead()) + openBook(&mpRecentBooks->getLastRead()->mPath); +} + void CAmisGuiMFC2App::OnFileOpen() { amis::gui::dialogs::AmisFileDialog* p_dlg = new amis::gui::dialogs::AmisFileDialog(amis::gui::dialogs::AmisFileDialog::getFileOpenFilter()); string filename = p_dlg->showOpen(); - //the user is able to open UAK files through AMIS if (isUserKeyFile(filename)) { importUserKeysIntoRegistry(filename); } - - //else it's a book else { - ambulant::net::url filename_url = ambulant::net::url::from_filename(filename); - if (!filename_url.is_empty_path()) - { - if (amis::dtb::DtbWithHooks::Instance()->open(&filename_url, &very_temporary_bookmarks_dir)) - { - mbBookIsOpen = true; - amis::dtb::DtbWithHooks::Instance()->startReading(true); - } - else - { - //TODO give an error that book could not be opened - } - } + ambulant::net::url book_path = ambulant::net::url::from_filename(filename); + openBook(&book_path); } } @@ -320,11 +350,7 @@ amis::RecentBookEntry* p_book = NULL; p_book = mpRecentBooks->getEntry(selection); - if (amis::dtb::DtbWithHooks::Instance()->open(&p_book->mPath, &very_temporary_bookmarks_dir)) - { - amis::dtb::DtbWithHooks::Instance()->startReading(true); - } - + openBook(&p_book->mPath); } void CAmisGuiMFC2App::OnNavNextSection() @@ -360,6 +386,7 @@ MainWndParts::Instance()->mpMmView->OnDestroy(); amis::dtb::DtbWithHooks::Instance()->DestroyInstance(); amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.clearAll(); + amis::gui::MenuManip::Instance()->setupMenusNothingOpen(); mbBookIsOpen = false; } } @@ -392,15 +419,7 @@ { str_url = T2A(dlg.getUrl()); ambulant::net::url book_url = ambulant::net::url::from_url(str_url); - if (amis::dtb::DtbWithHooks::Instance()->open(&book_url, &very_temporary_bookmarks_dir)) - { - amis::dtb::DtbWithHooks::Instance()->startReading(true); - } - else - { - //TODO: localize this - AfxMessageBox(_T("Error opening book")); - } + openBook(&book_url); } } @@ -456,4 +475,5 @@ void CAmisGuiMFC2App::OnResetFontSize() { TextRenderBrain::Instance()->resetFontSize(); -} \ No newline at end of file +} + Modified: branches/amis3/AmisGuiMFC2/src/pdtb.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/pdtb.cpp 2007-09-27 12:15:02 UTC (rev 2178) +++ branches/amis3/AmisGuiMFC2/src/pdtb.cpp 2007-09-27 13:51:22 UTC (rev 2179) @@ -1,10 +1,12 @@ #include "pdtb.h" #include "stdafx.h" +//for string transformations +#include <algorithm> //stupid hack .. for now #define WITH_PROTECTED_BOOK_SUPPORT 1 -//#ifdef WITH_PROTECTED_BOOK_SUPPORT +#ifdef WITH_PROTECTED_BOOK_SUPPORT #include "ambulant/common/plugin_engine.h" #include "../../ambulant-private/pdtbplugin/pdtbplugin.h" @@ -64,10 +66,12 @@ return false; } -bool isUserKeyFile(std::string filename) +bool isUserKeyFile(string filename) { - string ext = amis::util::FilePathTools::getExtension(filename); - if (ext == "uak" || ext == "UAK") return true; + string file_ext = amis::util::FilePathTools::getExtension(filename); + //convert the string to lower case before doing a comparison + std::transform(file_ext.begin(), file_ext.end(), file_ext.begin(), (int(*)(int))tolower); + if (file_ext == "uak") return true; else return false; } -//#endif \ No newline at end of file +#endif \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-27 14:37:09
|
Revision: 2181 http://amis.svn.sourceforge.net/amis/?rev=2181&view=rev Author: marisademeglio Date: 2007-09-27 07:37:13 -0700 (Thu, 27 Sep 2007) Log Message: ----------- Trying to fix little stupid bugs related to closing books or opening several in a row Modified Paths: -------------- branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-27 14:21:28 UTC (rev 2180) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-27 14:37:13 UTC (rev 2181) @@ -133,6 +133,7 @@ //cout<<"trying to open: "<<filepath<<endl; + mpFiles = NULL; mpFiles = new amis::dtb::DtbFileSet(); mpFiles->initWithNccOrOpf(fileUrl); mpFiles->setBookmarksDirectory(bookmarksDirectory); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-27 14:21:28 UTC (rev 2180) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-27 14:37:13 UTC (rev 2181) @@ -297,6 +297,8 @@ { amis::gui::dialogs::AmisFileDialog* p_dlg = new amis::gui::dialogs::AmisFileDialog(amis::gui::dialogs::AmisFileDialog::getFileOpenFilter()); string filename = p_dlg->showOpen(); + if (filename == "") return; + //the user is able to open UAK files through AMIS if (isUserKeyFile(filename)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-27 14:59:34
|
Revision: 2183 http://amis.svn.sourceforge.net/amis/?rev=2183&view=rev Author: marisademeglio Date: 2007-09-27 07:59:37 -0700 (Thu, 27 Sep 2007) Log Message: ----------- Resolved tiny conflict Tried some stuff out with closing or deleting a Dtb object instance. Modified Paths: -------------- branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-27 14:57:18 UTC (rev 2182) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-27 14:59:37 UTC (rev 2183) @@ -84,6 +84,20 @@ delete mpTextSmilMap; if (mpCustomTests != NULL) delete mpCustomTests; + + mpFiles = NULL; + mpSmilTree = NULL; + mpNavModel = NULL; + mpAuthor = NULL; + mpBookmarks = NULL; + mpMetadata = NULL; + mpSpine = NULL; + mpTitle = NULL; + mpTextSmilMap = NULL; + mpCustomTests = NULL; + mUid.erase(); + mDaisyVersion = 0; + mpCallbackForPreprocessingBookKey = NULL; } amis::dtb::Spine* amis::dtb::Dtb::getSpine() { Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-27 14:57:18 UTC (rev 2182) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-27 14:59:37 UTC (rev 2183) @@ -384,8 +384,9 @@ void CAmisGuiMFC2App::OnFileClose() { if (mbBookIsOpen) - { - amis::dtb::DtbWithHooks::Instance()->DestroyInstance(); + { + //the order matters here + amis::dtb::DtbWithHooks::Instance()->DestroyInstance(); MainWndParts::Instance()->mpMmView->OnDestroy(); amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.clearAll(); amis::gui::MenuManip::Instance()->setupMenusNothingOpen(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-10-13 09:46:39
|
Revision: 2185 http://amis.svn.sourceforge.net/amis/?rev=2185&view=rev Author: daniel_weck Date: 2007-10-13 02:46:40 -0700 (Sat, 13 Oct 2007) Log Message: ----------- - Daniel WECK First commit in Amis3: * Warning, I have commented MmView.cpp:221 m_prefer_ffmpeg, because of my Ambulant revision which does not have this preference item. (by the way, I use my own todo annotation for easy find: "DanToDo") * The title bar now displays the Amis2.6 content fields (app_name, book_title, view_mode, voicing, play/pause_state). There is some garbage "AMIS1" at the end, I think it needs to be removed from the RC (impossible to remove programmatically) * The play/pause state is updated in the menu and in the title bar Modified Paths: -------------- branches/amis3/AmisCore/include/dtb/Dtb.h branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h branches/amis3/AmisGuiMFC2/include/gui/MainWndParts.h branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/MainWndParts.cpp branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp Modified: branches/amis3/AmisCore/include/dtb/Dtb.h =================================================================== --- branches/amis3/AmisCore/include/dtb/Dtb.h 2007-09-27 17:26:39 UTC (rev 2184) +++ branches/amis3/AmisCore/include/dtb/Dtb.h 2007-10-13 09:46:40 UTC (rev 2185) @@ -53,7 +53,8 @@ amis::dtb::Bookmark* addBookmark(amis::MediaGroup*); //void loadFromBookmark(amis::Bookmark*); - + + amis::MediaGroup* getTitle(); amis::dtb::Metadata* getMetadata(); amis::dtb::Spine* getSpine(); amis::dtb::nav::NavModel* getNavModel(); Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-27 17:26:39 UTC (rev 2184) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-10-13 09:46:40 UTC (rev 2185) @@ -99,6 +99,10 @@ mDaisyVersion = 0; mpCallbackForPreprocessingBookKey = NULL; } +amis::MediaGroup* amis::dtb::Dtb::getTitle() +{ + return mpTitle; +} amis::dtb::Spine* amis::dtb::Dtb::getSpine() { return mpSpine; Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-09-27 17:26:39 UTC (rev 2184) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-10-13 09:46:40 UTC (rev 2185) @@ -57,6 +57,9 @@ std::string getAppPath(); amis::RecentBooks* getRecentBooks(); + + void setPauseState(bool play); + //Menu handlers afx_msg void OnFileOpen(); afx_msg void OnPlayPause(); Modified: branches/amis3/AmisGuiMFC2/include/gui/MainWndParts.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MainWndParts.h 2007-09-27 17:26:39 UTC (rev 2184) +++ branches/amis3/AmisGuiMFC2/include/gui/MainWndParts.h 2007-10-13 09:46:40 UTC (rev 2185) @@ -71,6 +71,24 @@ private: static MainWndParts* pinstance; + +public: + + enum TitleBarFieldID{TITLEBAR_APPNAME, TITLEBAR_BOOKTITLE, TITLEBAR_VIEWMODE, TITLEBAR_SELFVOICING, TITLEBAR_PLAYSTATE}; + void updateTitleBar(TitleBarFieldID field, CString str); + + void updateTitleViewMode(); + void updateTitleSelfVoicing(bool selfVoiced); + void updateTitlePlayState(bool playing); + +private: + + CString mStrTITLEBAR_APPNAME; + CString mStrTITLEBAR_VIEWMODE; + CString mStrTITLEBAR_SELFVOICING; + CString mStrTITLEBAR_PLAYSTATE; + CString mStrTITLEBAR_BOOKTITLE; + }; } } Modified: branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h 2007-09-27 17:26:39 UTC (rev 2184) +++ branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h 2007-10-13 09:46:40 UTC (rev 2185) @@ -40,7 +40,8 @@ void refreshRecentBooksListMenu(); void setupMenusSomethingOpen(amis::dtb::BookmarkSet*); void setupMenusNothingOpen(); - void setViewItemCheckmark(bool, UINT); + void setViewItemCheckmark(bool, UINT); + void setPauseState(bool pauseState); void addBookmark(amis::dtb::PositionMark*); void loadBookmarks(amis::dtb::BookmarkSet*); private: Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-09-27 17:26:39 UTC (rev 2184) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-10-13 09:46:40 UTC (rev 2185) @@ -75,6 +75,19 @@ amis::gui::sidebar::AmisSidebarLoader::Instance()->loadNavigationData (this->getNavModel(), &amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg); + if (this->getTitle() != NULL) + { + amis::TextNode* p_txt = NULL; + p_txt = this->getTitle()->getText(); + if (p_txt != NULL) + { + CString title = p_txt->getTextString().c_str(); + title.Trim(); + //DanToDo: title text seems to be empty with HELP DTB. Not initialized properly in the backend parser ? + amis::gui::MainWndParts::Instance()->updateTitleBar(amis::gui::MainWndParts::TITLEBAR_BOOKTITLE, title); + } + } + addToRecentBooks(); amis::dtb::BookmarkSet* p_bmks = NULL; p_bmks = this->getBookmarks(); @@ -339,6 +352,8 @@ { amis::gui::MainWndParts::Instance()->mpMmDoc->OnOpenDocument(A2T(full_path.get_url().c_str())); } + //DanToDo: Is this the best place to set the PLAY/PAUSE status ? (is the book actually playing at this stage...probably not) + theApp.setPauseState(false); return NULL; } Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-27 17:26:39 UTC (rev 2184) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-10-13 09:46:40 UTC (rev 2185) @@ -253,6 +253,10 @@ void CAmisGuiMFC2App::openBook(const ambulant::net::url* filename) { + MainWndParts::Instance()->updateTitleBar(MainWndParts::TITLEBAR_APPNAME, L"Amis"); + MainWndParts::Instance()->updateTitleViewMode(); + MainWndParts::Instance()->updateTitleSelfVoicing(Preferences::Instance()->mbIsSelfVoicing); + bool b_a_book_was_open = false; //close the open book @@ -311,6 +315,35 @@ } } +/** + * 'pauseState' function parameter: + * - FALSE => state is set to "PLAYING", the "PAUSE" action button is therefore shown + * - TRUE => state is set to "PAUSED", the "PLAY" action button is therefore shown + */ +void CAmisGuiMFC2App::setPauseState(bool pauseState) +{ + //DanToDo: + //AudioSequencePlayer::Instance()->Stop(); + + ////CAmisGuiMFC2App* pApp = (CAmisGuiMFC2App *) AfxGetApp();AfxGetApp()->m_pMainWnd;theApp.xxxx() + + //if (mpMainFrame->m_wndDefaultToolbar) + { + //DanToDo: + //mpMainFrame->m_wndDefaultToolbar.setPauseState(pauseState); + } + + //if (mpMainFrame->m_wndBasicToolbar) + { + //DanToDo: + //mpMainFrame->m_wndBasicToolbar.setPauseState(pauseState); + } + + amis::gui::MenuManip::Instance()->setPauseState(pauseState); + + MainWndParts::Instance()->updateTitlePlayState(!pauseState); +} + void CAmisGuiMFC2App::OnPlayPause() { MmView *view = MainWndParts::Instance()->mpMmView; Modified: branches/amis3/AmisGuiMFC2/src/gui/MainWndParts.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainWndParts.cpp 2007-09-27 17:26:39 UTC (rev 2184) +++ branches/amis3/AmisGuiMFC2/src/gui/MainWndParts.cpp 2007-10-13 09:46:40 UTC (rev 2185) @@ -162,3 +162,73 @@ return this->mbBasicView; } + +void MainWndParts::updateTitleViewMode() +{ + updateTitleBar(TITLEBAR_VIEWMODE, (isBasicView() ? L"Basic view mode" : L"Default view mode")); +} + +void MainWndParts::updateTitleSelfVoicing(bool selfVoiced) +{ + updateTitleBar(TITLEBAR_SELFVOICING, (selfVoiced ? L"Self-voicing" : L"Not self-voicing")); +} + +void MainWndParts::updateTitlePlayState(bool playing) +{ + updateTitleBar(TITLEBAR_PLAYSTATE, (playing ? L"Playing..." : L"Paused.")); +} + +void MainWndParts::updateTitleBar(TitleBarFieldID field, CString str) { + CString title; + switch (field) { + case TITLEBAR_APPNAME: { + mStrTITLEBAR_APPNAME = str; + break; + } + case TITLEBAR_BOOKTITLE: { + mStrTITLEBAR_BOOKTITLE = str; + break; + } + case TITLEBAR_VIEWMODE: { + mStrTITLEBAR_VIEWMODE = str; + break; + } + case TITLEBAR_SELFVOICING: { + mStrTITLEBAR_SELFVOICING = str; + break; + } + case TITLEBAR_PLAYSTATE: { + mStrTITLEBAR_PLAYSTATE = str; + break; + } + } + title.Append(mStrTITLEBAR_APPNAME); + title.Append(L" \""); + if (mStrTITLEBAR_BOOKTITLE.IsEmpty()) + { + title.Append(L"NO TITLE"); + } + else + { + title.Append(mStrTITLEBAR_BOOKTITLE); + } + title.Append(L"\" "); + title.Append(mStrTITLEBAR_VIEWMODE); + title.Append(L" - "); + title.Append(mStrTITLEBAR_SELFVOICING); + title.Append(L" - "); + if (mStrTITLEBAR_PLAYSTATE.IsEmpty()) + { + title.Append(L"Playing?"); + } + else + { + title.Append(mStrTITLEBAR_PLAYSTATE); + } + + mpMainFrame->SetTitle(L""); + AfxGetApp()->m_pMainWnd->SetWindowText(L""); + + mpMainFrame->SetTitle(title); + AfxGetApp()->m_pMainWnd->SetWindowText(title); +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2007-09-27 17:26:39 UTC (rev 2184) +++ branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2007-10-13 09:46:40 UTC (rev 2185) @@ -313,3 +313,28 @@ if (p_mark) addBookmark(p_mark); } } + +void MenuManip::setPauseState(bool pauseState) +{ + + CMenu* p_menu = NULL; + p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); + if (p_menu == NULL) + { + return; + } + + p_menu = p_menu->GetSubMenu(2); + assert(p_menu); + + if (pauseState) + { + // If book is paused, then we display a "play" action + p_menu->ModifyMenu(0, MF_BYPOSITION, ID_MENU_PLAYPAUSE, L"&Play\tSpace"); + } + else + { + // If book is playing, then we display a "pause" action + p_menu->ModifyMenu(0, MF_BYPOSITION, ID_MENU_PLAYPAUSE, L"&Pause\tSpace"); + } +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2007-09-27 17:26:39 UTC (rev 2184) +++ branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2007-10-13 09:46:40 UTC (rev 2185) @@ -216,7 +216,9 @@ prefs->m_parser_id = "xerces"; prefs->m_use_plugins = true; prefs->m_plugin_dir = ""; - prefs->m_prefer_ffmpeg = false; + + //DanToDo: I removed the line below to compile with my revision of Ambulant + //prefs->m_prefer_ffmpeg = false; prefs->m_dynamic_content_control = true; @@ -424,6 +426,7 @@ /*DBG*/in_here++; if(player) { + theApp.setPauseState(false); player->play(); needs_done_redraw = true; InvalidateRect(NULL); @@ -444,7 +447,11 @@ void MmView::OnFilePause() { - if(player) player->pause(); + if(player) + { + theApp.setPauseState(true); + player->pause(); + } } void MmView::OnUpdateFilePause(CCmdUI *pCmdUI) @@ -777,6 +784,7 @@ TRACE("nextPhrase: no current phrase"); assert(player); player->stop(); + theApp.setPauseState(true); return; } next = phrase->next(); @@ -790,6 +798,7 @@ TRACE("nextPhrase: top-of-tree, stop playback\n"); assert(player); player->stop(); + theApp.setPauseState(true); return; } phrase = _curPhrase(parent); @@ -818,6 +827,7 @@ m_previous_in_progress = true; assert(player); player->stop(); + theApp.setPauseState(true); return; } prev = phrase->previous(); @@ -832,6 +842,7 @@ m_previous_in_progress = true; assert(player); player->stop(); + theApp.setPauseState(true); return; } phrase = _curPhrase(parent); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-10-13 23:51:06
|
Revision: 2189 http://amis.svn.sourceforge.net/amis/?rev=2189&view=rev Author: daniel_weck Date: 2007-10-13 16:51:05 -0700 (Sat, 13 Oct 2007) Log Message: ----------- - Daniel WECK * Added new AmisAudio module (the solution will be updated in a minute, to include this new project, and exclude the old "Audio" folder) Added Paths: ----------- branches/amis3/AmisAudio/ branches/amis3/AmisAudio/AmisAudio.cpp branches/amis3/AmisAudio/AmisAudio.dsp branches/amis3/AmisAudio/AmisAudio.dsw branches/amis3/AmisAudio/AmisAudio.h branches/amis3/AmisAudio/AmisAudio.sln branches/amis3/AmisAudio/AmisAudio.vcproj branches/amis3/AmisAudio/ReadMe.txt branches/amis3/AmisAudio/StdAfx.cpp branches/amis3/AmisAudio/StdAfx.h branches/amis3/AmisAudio/TPBReader2/ branches/amis3/AmisAudio/TPBReader2/RegOcx.cpp branches/amis3/AmisAudio/TPBReader2/RegOcx.h branches/amis3/AmisAudio/TPBReader2/dmp/ branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h branches/amis3/AmisAudio/TPBReader2/dmp/DmpPpg.cpp branches/amis3/AmisAudio/TPBReader2/dmp/DmpPpg.h branches/amis3/AmisAudio/TPBReader2/dmp/Resource.h branches/amis3/AmisAudio/TPBReader2/dmp/StdAfx.cpp branches/amis3/AmisAudio/TPBReader2/dmp/StdAfxFIX.h branches/amis3/AmisAudio/TPBReader2/dmp/TransformSample.h branches/amis3/AmisAudio/TPBReader2/dmp/Vupp1.h branches/amis3/AmisAudio/TPBReader2/dmp/VuppInterface.h branches/amis3/AmisAudio/TPBReader2/dmp/VuppSample.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/ branches/amis3/AmisAudio/TPBReader2/dmp/directx/amextra.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/amfilter.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/cache.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/combase.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/cprop.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/ctlutil.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/ddmm.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/dllsetup.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/dsschedule.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/fourcc.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/measure.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/msgthrd.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/mtype.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/outputq.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/pstream.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/pullpin.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/refclock.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/reftime.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/renbase.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/schedule.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/seekpt.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/source.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/streams.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/strmctl.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/sysclock.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/transfrm.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/transip.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/videoctl.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/vtrans.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/winctrl.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/winutil.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/wxdebug.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/wxlist.h branches/amis3/AmisAudio/TPBReader2/dmp/directx/wxutil.h branches/amis3/AmisAudio/TPBReader2/dmp/dmp.cpp branches/amis3/AmisAudio/TPBReader2/dmp/dmp.h branches/amis3/AmisAudio/TPBReader2/dmp/iTPBTS.h branches/amis3/AmisAudio/TPBReader2/dmp/intvec.h Added: branches/amis3/AmisAudio/AmisAudio.cpp =================================================================== --- branches/amis3/AmisAudio/AmisAudio.cpp (rev 0) +++ branches/amis3/AmisAudio/AmisAudio.cpp 2007-10-13 23:51:05 UTC (rev 2189) @@ -0,0 +1,630 @@ +/* +AmisAudio + +Copyright (C) 2005 DAISY for All Project + +Licensing note: This file is released as LGPL; however, its module relies upon GPL code in third party libraries. Any reuse of this library in a closed source environment must contact the GPL license holders to negotiate terms for use with an altered license. GPL code referenced from this module includes, but may not be limited to, libfftw, WSOLA code by Matt Flax, and stlib. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +// AmisAudio.cpp : Defines the entry point for the DLL application. + +//#include "StdAfx.h" +//#include "TPBReader2\dmp\StdAfxFIX.h" + + + +#include <stdlib.h> +#include <iostream> +#include <string> +#include "AmisAudio.h" + +#include <process.h> + +#include "win32Fix.H" + +//#include "../AmisGuiMFC/Brain/Preferences.h" + +/* +BOOL APIENTRY DllMain( HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} +*/ + + +AmisAudio* AmisAudio::pinstance = 0; + +AmisAudio* AmisAudio::Instance() +{ + if (pinstance == 0) // is it the first call? + { + pinstance = new AmisAudio; // create sole instance + } + return pinstance; // address of sole instance +} + + + +/*AmisAudio::AmisAudio(HWND parentWindow) +{ + mState=NOTACTIVE; + mVolume=100; + mWsolaSource=NULL; + + parentWnd=parentWindow; +}*/ + +AmisAudio::AmisAudio() +{ + //pDmpApp = 0; + pDmpCtrl = 0; + mTau=1.0; + mState=NOTACTIVE; + mVolume=100; + + mbAudioPlaybackEnabled = true; + + pDmpCtrl = new CDmpCtrl(); +} + +/****************************************************************** +AmisAudio destructor Function +******************************************************************/ + + +AmisAudio::~AmisAudio() +{ + if (pDmpCtrl) delete pDmpCtrl; + + /*clean up code goes here*/ +} + +void AmisAudio::DestroyInstance() +{ + if (pinstance) delete pinstance; +} + +void AmisAudio::setStatePause() { + mState = PAUSE; + +} + + +/*-------------------------------------------------------------------------------------------------------------------------- +This function enables Audio plugin, initializes rate to 1.0 and volume to 100 +----------------------------------------------------------------------------------------------------------------------------*/ +void AmisAudio::enable() +{ + if (pDmpCtrl) { + mState=PAUSE; //ACTIVE + mTau=1.0; + mVolume = 100; + return; + } + switch(mState) + { + case NOTACTIVE: + { + + mState=PAUSE; //ACTIVE + // mRate = 1.0; + mTau=1.0; + mVolume = 100; + return; + } + default: + return; + //return"Audio Plugin is already enabled"; + } +} + +/*-------------------------------------------------------------------------------------------------------------------------- +This function disables Audio plugin +----------------------------------------------------------------------------------------------------------------------------*/ +void AmisAudio::disable() +{ + switch(mState) + { + //case ACTIVE: + case PLAYING: + case PAUSE: + //if(mState==PLAYING) + { + stop(); + ShowStatePrompt(); + mState=NOTACTIVE; + ShowStatePrompt(); + mState=NOTACTIVE; + return; + //return"Audio plugin has been disabled!!"; + } + case NOTACTIVE: + return; + //return"Audio plugin is not enabled."; + + } + +} + + +/**************************************************************** +play(char *filename,char* clipBegin,char* clipEnd) function +****************************************************************/ + +void AmisAudio::play(const char *filename,char* clipBegin,char* clipEnd){ + + + if (mbAudioPlaybackEnabled == false) + { + + return; + } + + mFileName.assign(filename); + int channel; + + //Format the beg and end from string to timeCode + SmilTimeCode startStop(clipBegin, clipBegin, clipEnd); + + unsigned long begin,end; + + ShowStatePrompt(); + + + + + switch(mState) + { + + case NOTACTIVE: + { + return; + //return "Audio plugin is not enabled.\n"; + break; + } + //case ACTIVE: + case PAUSE: + case PLAYING: + { + if (pDmpCtrl) { + + if (mbAudioPlaybackEnabled == false) + { + return; + } + //stop(); + if (!pDmpCtrl->fileName(filename)) { + + pDmpCtrl->destroyFilterGraph(); + return; + } + pDmpCtrl->insertVupp(); + + begin=startStop.getStart(); + end=startStop.getEnd(); + if (! (begin == 0 && end == 0)) { + + if (begin >= 0 && begin < pDmpCtrl->getDuration()) { + pDmpCtrl->setPosition(begin); + } + + if (end >= 0 && end > begin && end < pDmpCtrl->getDuration()) { + pDmpCtrl->setStopPosition(end); + } + } + + //long volume = mVolume/10; + //pDmpCtrl->setVolume(volume); + pDmpCtrl->play(); + mState = PLAYING; + return; + } + + //return "now playing\n" ; + } + } + +} // end method + + + +/**************************************************************** +stop() function +****************************************************************/ + +void AmisAudio::stop() +{ + switch(mState) + { + + case NOTACTIVE: + { + return; + //return "Audio plugin is not enabled.\n"; + } + + /*case ACTIVE: + { + return; + //return"No file is playing"; + }*/ + + case PLAYING : + { + mState = PAUSE; //ACTIVE + + + if (pDmpCtrl) { + pDmpCtrl->stop(); + //pDmpCtrl->pause(); + return; + } + + + return; + //return"The playing file has been stopped"; + } + + case PAUSE : + { + mState = PAUSE; //ACTIVE + + + + return; + //return"The playing file has been stopped"; + + } + } +} + + + + +/**************************************************************** +pause() function +****************************************************************/ + +void AmisAudio::pause(){ + + + switch(mState) + { + + case NOTACTIVE: + { + return; + //return "Audio plugin is not enabled.\n"; + + } + + /* case ACTIVE : + { + return; + //return "The plugin is already stopped."; + } */ + case PLAYING : + { + mState=PAUSE; + + if (pDmpCtrl) { + //pDmpCtrl->stop(); + pDmpCtrl->pause(); + return; + } + + return; + //return"The plugin is paused"; + } + + + + case PAUSE : + { + return; + //return "The plugin is already paused."; + } + + } +} + + +/**************************************************************** +resume() function +****************************************************************/ + +int AmisAudio::resume(){ + + + switch(mState) + { + + case NOTACTIVE: + { + return -1; + //return "Audio plugin is not enabled.\n"; + + } + + //case ACTIVE : + case PAUSE : + { + + + if (pDmpCtrl) { + + pDmpCtrl->play(); + mState=PLAYING; + return 0; + } + + //return"The plugin is resumed"; + + } + + case PLAYING : + { + return 0; + //return"The plugin is not in paused state"; + } + + + } + +} + +/**************************************************************** +getVolume() function +****************************************************************/ + +unsigned AmisAudio::getVolume() +{ + + return mVolume; +} + + +/**************************************************************** +setVolume(char * value) function +****************************************************************/ +void AmisAudio::setVolume(unsigned int value) +{ + + + switch(mState) + { + + case NOTACTIVE: + { + return; + //return "Audio plugin is not enabled.\n"; + + } + + //case ACTIVE : + case PAUSE : + case PLAYING : + { + if(value>=0 && value<=100) + { + mVolume=value; + + + if (pDmpCtrl) { + + pDmpCtrl->setVolume((long)((double)value/10.0)); + + return ; + } + + return; + //return returnMessage; + } + else + { + return; + //return"Volume out of range"; + } + } + } +} + +//adjustment is positive or negative (louder or softer) +void AmisAudio::adjustVolume(int adjustment) +{ + int value; + + value = mVolume + adjustment; + + setVolume(value); +} + + +void AmisAudio::adjustRate(double adjustment) +{ + if (pDmpCtrl) { + if (adjustment < 0) {adjustment = 2;} else {adjustment = -2;} + double value = mTau + adjustment; + setRate(value); + return; + } + double value = mTau + adjustment; + + setRate(value); +} + + +/**************************************************************** +getRate() function +****************************************************************/ + +double AmisAudio::getRate() +{ + return mTau; +} + +/**************************************************************** +setRate() function +****************************************************************/ + +void AmisAudio::setRate(double value){ + + + switch(mState) + { + + case NOTACTIVE: + { + return; + //return "Audio plugin is not enabled.\n"; + + } + + //case ACTIVE : + case PAUSE : + case PLAYING : + { + if (pDmpCtrl) { + + mTau=value; + + TRACE(_T("\n####################\n")); + TRACE(_T("\n#################### RATE BEFORE %lf\n", mTau)); + + + if (mTau > 1.0) { + double offset = mTau - 1.0; + /* int n = offset / 0.2; + offset *= 6; + offset = n * 0.5; */ + //mTau = 1 - offset; + } + if (mTau < 1.0) { + double offset = 1.0 - mTau; + /* int n = offset / 0.2; + offset *= 6; + offset = n * 0.5; */ + //mTau = 1 + offset; + } + //if (mTau > 3) mTau = 3; + //if (mTau < 1) mTau = 1; + + //mTau=value; + + TRACE(_T("\n#################### RATE AFTER %lf\n", mTau)); + TRACE(_T("\n####################\n")); + pDmpCtrl->setRate(mTau); + return; + } + + + } + + + + } + + +} // end method + + + + +/**************************************************************** + isPlaying() function +****************************************************************/ + +bool AmisAudio::isPlaying() +{ + + if(mState==PLAYING) + { + return true; + } + else + { + return false; + } + + +} + +bool AmisAudio::isActive() +{ + + return (mState==PAUSE || mState==PLAYING); + +} + /**************************************************************** + ShowStatePropmt() function + ****************************************************************/ + + + void AmisAudio::ShowStatePrompt(){ + + switch(mState){ + + case NOTACTIVE: { + std::cout<<"Not Active"<<endl; + break; + } + + /* case ACTIVE: { + std::cout<<" Active"<<endl; + break; + } */ + + case PAUSE: { + std::cout<<" Pause"<<endl; + break; + } + + case PLAYING: { + std::cout<<" Playing"<<endl; + } + + + } + + } + + + void AmisAudio::enableAudioPlayback() + { + mbAudioPlaybackEnabled = true; + } + + void AmisAudio::disableAudioPlayback() + { + mbAudioPlaybackEnabled = false; + } + + bool AmisAudio::isAudioPlaybackEnabled() + { + return mbAudioPlaybackEnabled; + } + Added: branches/amis3/AmisAudio/AmisAudio.dsp =================================================================== --- branches/amis3/AmisAudio/AmisAudio.dsp (rev 0) +++ branches/amis3/AmisAudio/AmisAudio.dsp 2007-10-13 23:51:05 UTC (rev 2189) @@ -0,0 +1,130 @@ +# Microsoft Developer Studio Project File - Name="AmisAudio" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=AmisAudio - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "AmisAudio.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "AmisAudio.mak" CFG="AmisAudio - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "AmisAudio - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "AmisAudio - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/AmisAudio", QAAAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "AmisAudio - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 1 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../bin" +# PROP Intermediate_Dir "tmp" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "AMISAUDIO_EXPORTS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "audiere\audiere-1.9.3-win32\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "AMISAUDIO_EXPORTS" /D "_WINDLL" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 fftw3.lib audiere.lib user32.lib stlib.lib libmad.lib vorbis_static.lib ogg_static.lib vorbisfile_static.lib vorbisenc_static.lib /nologo /dll /machine:I386 /nodefaultlib:"libcd.lib" /libpath:"audiere\audiere-1.9.3-win32\lib" +# SUBTRACT LINK32 /incremental:yes + +!ELSEIF "$(CFG)" == "AmisAudio - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 1 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../bin" +# PROP Intermediate_Dir "tmp" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "AMISAUDIO_EXPORTS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "D:\sdk\audio\audiere\audiere-1.9.3-win32\include" /I ".\timeCode.1.4" /I ".\MFFM_FFTW" /I ".\MFFM_FFTW\MFFM_FFTw_Wrapper-v1.4" /I ".\mffm-libsndfilew-1.2" /I ".\libsndfile-1.0.11\Win32" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "AMISAUDIO_EXPORTS" /D "_WINDLL" /FR /Yu"stdafx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 fftw3.lib audiere.lib kernel32.lib gdi32.lib user32.lib stlib.lib libmad.lib vorbis_static.lib ogg_static.lib vorbisfile_static.lib vorbisenc_static.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libcd.lib" /out:"../bin/AmisAudioD.dll" /pdbtype:sept /libpath:"audiere\audiere-1.9.3-win32\lib" +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "AmisAudio - Win32 Release" +# Name "AmisAudio - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\AmisAudio.cpp +# End Source File +# Begin Source File + +SOURCE=..\3rdPartyAudio\complexFFT.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\AmisAudio.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project Added: branches/amis3/AmisAudio/AmisAudio.dsw =================================================================== --- branches/amis3/AmisAudio/AmisAudio.dsw (rev 0) +++ branches/amis3/AmisAudio/AmisAudio.dsw 2007-10-13 23:51:05 UTC (rev 2189) @@ -0,0 +1,41 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "AmisAudio"=.\AmisAudio.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "AmisAudioTestApp"=.\AmisAudioTest\AmisAudioTestApp\AmisAudioTestApp.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + Added: branches/amis3/AmisAudio/AmisAudio.h =================================================================== --- branches/amis3/AmisAudio/AmisAudio.h (rev 0) +++ branches/amis3/AmisAudio/AmisAudio.h 2007-10-13 23:51:05 UTC (rev 2189) @@ -0,0 +1,142 @@ +/* +AmisAudio + +Copyright (C) 2005 DAISY for All Project + +Licensing note: This file is released as LGPL; however, its module relies upon GPL code in third party libraries. Any reuse of this library in a closed source environment must contact the GPL license holders to negotiate terms for use with an altered license. GPL code referenced from this module includes, but may not be limited to, libfftw, WSOLA code by Matt Flax, and stlib. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef AMISAUDIO_H +#define AMISAUDIO_H +/** The following ifdef block is the standard way of creating macros which make exporting +// from a DLL simpler. All files within this DLL are compiled with the AMISAUDIO_EXPORTS +// symbol defined on the command line. this symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// AMISAUDIO_API functions as being imported from a DLL, wheras this DLL sees symbols +// defined with this macro as being exported. +*/ + +#ifdef AMISAUDIO_EXPORTS +#define AMISAUDIO_API __declspec(dllexport) +#else +#define AMISAUDIO_API __declspec(dllimport) +#endif + +///This gets rid of some warnings +#pragma warning(disable : 4786) + + +#include "TPBReader2\dmp\DmpCtl.h" +#include "TPBReader2\dmp\Dmp.h" + + +//#include "StdAfx.h" +#include <windows.h> + +#include "smilTimeCode.H" + +//for message sending ... +typedef void (*sendMessageCallbackFn)(void *); + +//using namespace std; + +enum State{NOTACTIVE,PAUSE,PLAYING}; //ACTIVE + + +#ifdef _MSC_VER +#pragma warning(disable : 4251) +#endif + +/** This class is exported from the AmisAudio.dll*/ + +class AMISAUDIO_API AmisAudio +{ +protected: + ///Constructor which is used to ensure callbacks are executed once a stream is played + //AmisAudio(HWND parentWindow); + ///Constructor which executes no callback once a stream is played + AmisAudio(); + +public: + + //Two instances are used because AMIS should have two audio tracks - the book and the UI + static AmisAudio* Instance(); + + ///Deconstructor + ~AmisAudio (); + + + static void DestroyInstance(); + + + void setStatePause(); + + + //functions related to enabling/disabling audio + //these were added so that screen readers could ask AMIS to be quiet + void enableAudioPlayback(); + void disableAudioPlayback(); + bool isAudioPlaybackEnabled(); + +private: + + //private member functions + //Look in the cpp source for comments on what these functions do. + +public: + void enable(); + void disable(); + void play(const char *filename,char* clipBegin,char* clipEnd); + + + +public: + void stop(); + void pause(); + int resume(); + unsigned int getVolume(); + void setVolume (unsigned int); + double getRate(); + void setRate(double); + bool isPlaying(); + bool isActive(); + + void adjustVolume(int); + void adjustRate(double); + +private: + void ShowStatePrompt(); + + //member variables + std::string mFileName; //The file name being played + unsigned int mVolume; //The volume of the stream + + State mState; //The state of the player + double mTau; //This is the playback speed + + //is the audio playback enabled? + bool mbAudioPlaybackEnabled; + +private: + static AmisAudio* pinstance; + + + CDmpCtrl* pDmpCtrl; + //CDmpApp* pDmpApp; +}; + + +#endif \ No newline at end of file Added: branches/amis3/AmisAudio/AmisAudio.sln =================================================================== --- branches/amis3/AmisAudio/AmisAudio.sln (rev 0) +++ branches/amis3/AmisAudio/AmisAudio.sln 2007-10-13 23:51:05 UTC (rev 2189) @@ -0,0 +1,30 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AmisAudio", "AmisAudio.vcproj", "{FA42A65E-7A79-431A-A474-0A7B367BFDEB}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AmisAudioTestApp", "testAmisAudio\AmisAudioTestApp.vcproj", "{1BF5F8C6-814F-4607-86EC-6CB93D468F62}" + ProjectSection(ProjectDependencies) = postProject + {FA42A65E-7A79-431A-A474-0A7B367BFDEB} = {FA42A65E-7A79-431A-A474-0A7B367BFDEB} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {FA42A65E-7A79-431A-A474-0A7B367BFDEB}.Debug.ActiveCfg = Debug|Win32 + {FA42A65E-7A79-431A-A474-0A7B367BFDEB}.Debug.Build.0 = Debug|Win32 + {FA42A65E-7A79-431A-A474-0A7B367BFDEB}.Release.ActiveCfg = Release|Win32 + {FA42A65E-7A79-431A-A474-0A7B367BFDEB}.Release.Build.0 = Release|Win32 + {1BF5F8C6-814F-4607-86EC-6CB93D468F62}.Debug.ActiveCfg = Debug|Win32 + {1BF5F8C6-814F-4607-86EC-6CB93D468F62}.Debug.Build.0 = Debug|Win32 + {1BF5F8C6-814F-4607-86EC-6CB93D468F62}.Release.ActiveCfg = Release|Win32 + {1BF5F8C6-814F-4607-86EC-6CB93D468F62}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal Added: branches/amis3/AmisAudio/AmisAudio.vcproj =================================================================== --- branches/amis3/AmisAudio/AmisAudio.vcproj (rev 0) +++ branches/amis3/AmisAudio/AmisAudio.vcproj 2007-10-13 23:51:05 UTC (rev 2189) @@ -0,0 +1,356 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="AmisAudio" + ProjectGUID="{62575239-B3F3-4020-A275-7ADF0EA18799}" + SccProjectName=""$/AmisAudio", QAAAAAAA" + SccLocalPath="." + Keyword="MFCProj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory=".\../bin" + IntermediateDirectory=".\tmp" + ConfigurationType="2" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="1"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories=""../AmisGuiMFC2/include/";"../AmisCore/include/";"../3rdPartyAudio"; "../mffmTimeCode"" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_WINDOWS;_USRDLL;AMISAUDIO_EXPORTS" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + PrecompiledHeaderThrough="StdAfx.h" + PrecompiledHeaderFile=".\tmp/AmisAudio.pch" + AssemblerListingLocation=".\tmp/" + ObjectFile=".\tmp/" + ProgramDataBaseFileName=".\tmp/" + BrowseInformation="1" + WarningLevel="3" + SuppressStartupBanner="TRUE" + DebugInformationFormat="4" + CompileAs="2"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalOptions="/FORCE:MULTIPLE" + AdditionalDependencies="Strmiids.lib TransformSample.lib stlib.lib kernel32.lib gdi32.lib user32.lib ../lib/AmisCoreD.lib" + ShowProgress="2" + OutputFile="../bin/AmisAudioD.dll" + LinkIncremental="1" + SuppressStartupBanner="TRUE" + AdditionalLibraryDirectories="../lib" + IgnoreDefaultLibraryNames="libc.lib" + GenerateDebugInformation="TRUE" + ProgramDatabaseFile="./tmp/AmisAudioD.pdb" + ImportLibrary="../lib/AmisAudioD.lib" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="_DEBUG" + MkTypLibCompatible="TRUE" + SuppressStartupBanner="TRUE" + TargetEnvironment="1" + TypeLibraryName=".\../bin/AmisAudio.tlb" + HeaderFileName=""/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG" + Culture="1033"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory=".\../bin" + IntermediateDirectory=".\tmp" + ConfigurationType="2" + UseOfMFC="2" + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="1"> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories=""../3rdPartyAudio"; "../mffmTimeCode"" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;AMISAUDIO_EXPORTS" + StringPooling="TRUE" + RuntimeLibrary="2" + EnableFunctionLevelLinking="TRUE" + UsePrecompiledHeader="0" + PrecompiledHeaderThrough="stdafx.h" + PrecompiledHeaderFile=".\tmp/AmisAudio.pch" + AssemblerListingLocation=".\tmp/" + ObjectFile=".\tmp/" + ProgramDataBaseFileName=".\tmp/" + WarningLevel="3" + SuppressStartupBanner="TRUE" + CompileAs="0"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="Strmiids.lib stlib.lib kernel32.lib gdi32.lib user32.lib AmisCommon.lib" + OutputFile=".\../bin/AmisAudio.dll" + LinkIncremental="1" + SuppressStartupBanner="TRUE" + AdditionalLibraryDirectories="../lib" + IgnoreDefaultLibraryNames="libc.lib" + ProgramDatabaseFile="./tmp/AmisAudio.pdb" + ImportLibrary="../lib/AmisAudio.lib" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="NDEBUG" + MkTypLibCompatible="TRUE" + SuppressStartupBanner="TRUE" + TargetEnvironment="1" + TypeLibraryName=".\../bin/AmisAudio.tlb" + HeaderFileName=""/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG" + Culture="1033"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"> + <File + RelativePath="AmisAudio.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="" + BasicRuntimeChecks="3" + UsePrecompiledHeader="0" + BrowseInformation="1"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath="..\3rdPartyAudio\complexFFT.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\TPBReader2\dmp\dmp.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\TPBReader2\dmp\DmpCtl.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + PrecompiledHeaderThrough="StdAfxFIX.h"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\TPBReader2\dmp\DmpPpg.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + PrecompiledHeaderThrough="StdAfxFIX.h"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\TPBReader2\RegOcx.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath="StdAfx.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="" + BasicRuntimeChecks="3" + UsePrecompiledHeader="1" + BrowseInformation="1"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="" + UsePrecompiledHeader="1"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl"> + <File + RelativePath="AmisAudio.h"> + </File> + <File + RelativePath="..\mffmTimeCode\counter.H"> + </File> + <File + RelativePath=".\TPBReader2\dmp\dmp.h"> + </File> + <File + RelativePath=".\TPBReader2\dmp\DmpCtl.h"> + </File> + <File + RelativePath=".\TPBReader2\dmp\DmpPpg.h"> + </File> + <File + RelativePath="..\mffmTimeCode\field.H"> + </File> + <File + RelativePath=".\TPBReader2\dmp\iTPBTS.h"> + </File> + <File + RelativePath="..\mffmTimeCode\masterCounter.H"> + </File> + <File + RelativePath="..\mffmTimeCode\masterCounterArray.H"> + </File> + <File + RelativePath=".\TPBReader2\RegOcx.h"> + </File> + <File + RelativePath=".\TPBReader2\dmp\Resource.h"> + </File> + <File + RelativePath="..\mffmTimeCode\SmilTimeCode.H"> + </File> + <File + RelativePath="StdAfx.h"> + </File> + <File + RelativePath=".\TPBReader2\dmp\StdAfxFIX.h"> + </File> + <File + RelativePath="..\mffmTimeCode\timeCode.H"> + </File> + <File + RelativePath=".\TPBReader2\dmp\TransformSample.h"> + </File> + <File + RelativePath=".\TPBReader2\dmp\Vupp1.h"> + </File> + <File + RelativePath=".\TPBReader2\dmp\VuppInterface.h"> + </File> + <File + RelativePath=".\TPBReader2\dmp\VuppSample.h"> + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> + </Filter> + <File + RelativePath="ReadMe.txt"> + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Added: branches/amis3/AmisAudio/ReadMe.txt =================================================================== --- branches/amis3/AmisAudio/ReadMe.txt (rev 0) +++ branches/amis3/AmisAudio/ReadMe.txt 2007-10-13 23:51:05 UTC (rev 2189) @@ -0,0 +1,74 @@ +Amis Audio is an audio library which can play audio files of various formats. Technicly the formats required are specified in +the following document : +http://www.niso.org/standards/resources/Z39-86-2002.html#Audio +Supported formats are implemented by the Audiere library: +http://audiere.sourceforge.net/features.php + +The time scale modification is implemented in the WSOLA algorithm (Author : Matt Flax <flatmax@>) which is available here : +http://sourceforge.net/projects/mffmtimescale/ + +The interpretation of time code signals is implemented using the MFFM TimeCode library which is available here : +http://mffmtimecode.sourceforge.net/ + +Amis audio combines Audiere, WSOLA and the TimeCode library to implement the standard. + +AmisAudio embodies the following commands : + +1. play + plays a file. +2. pause() + pause playback +2. resume() + resume playback +3. stop() + stop playback +4. setRate + set the speed of play (0.5 = double speed, 1.0 = normal speed and 2.0 = half speed) +5. setVolume + set the volume +8. isPlaying + returns whether the audio is playing or not +9. When the playback of an audio clip is done, a signal is raised by posting a message to the windows message queue. + +Commands sent to the player are of the following form and input as text : + +First the audio engine must be enabled : +audio://enable + +Next you may specify one of many commands ... some examples are : + +To play a file starting at a particular point and ending at a particular point; +audio://play?filename=amis3.mp3&clipBegin=0.0s&clipEnd=0:3.5s + +To change the playback speed : +Audio://setRate?value=2 + +To change the volume (%100 =full ): +Audio://setVolume?value=100 + +To pause the play : +Audio://pause + +To stop the play : +Audio://stop + +To get the speed of play : +Audio://getRate + + +Compilation : + +Various libraries and headers are required to complile AmisAudio. They are implemented in C or C++. +These include : +Audiere ... http://audiere.sourceforge.net +WSOLA ... http://sourceforge.net/projects/mffmtimescale/ +TimeCode ... http://mffmtimecode.sourceforge.net/ +FFTW ... http://www.fftw.org +An FFTW wrapper ... http://mffmfftwrapper.sourceforge.net/ + +An example integration environment is given by Marissa D. in the CVS of the module AmisAudio +http://cvs.sourceforge.net/viewcvs.py/amis +http://cvs.sourceforge.net/viewcvs.py/amis/AmisAudio + +This code has been written initally by someone other then me (flatmax) ... I have plug and played +their original source code ... it need a thourough workove to clean it up a bit.... Added: branches/amis3/AmisAudio/StdAfx.cpp =================================================================== --- branches/amis3/AmisAudio/StdAfx.cpp (rev 0) +++ branches/amis3/AmisAudio/StdAfx.cpp 2007-10-13 23:51:05 UTC (rev 2189) @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// AmisAudio.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file Added: branches/amis3/AmisAudio/StdAfx.h =================================================================== --- branches/amis3/AmisAudio/StdAfx.h (rev 0) +++ branches/amis3/AmisAudio/StdAfx.h 2007-10-13 23:51:05 UTC (rev 2189) @@ -0,0 +1,113 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__AE5780CC_1107_4F64_ADC7_F4BACF658CC2__INCLUDED_) +#define AFX_STDAFX_H__AE5780CC_1107_4F64_ADC7_F4BACF658CC2__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +/* +#ifndef _AFX_NOFORCE_LIBS + +///////////////////////////////////////////////////////////////////////////// +// Win32 libraries + +#ifndef _AFXDLL + #ifndef _UNICODE + #ifdef _DEBUG + #pragma comment(lib, "nafxcwd.lib") + #else + #pragma comment(lib, "nafxcw.lib") + #endif + #else + #ifdef _DEBUG + #pragma comment(lib, "uafxcwd.lib") + #else + #pragma comment(lib, "uafxcw.lib") + #endif + #endif +#else + #ifndef _UNICODE + #ifdef _DEBUG + #pragma comment(lib, "mfc71d.lib") + #pragma comment(lib, "mfcs71d.lib") + #else + #pragma comment(lib, "mfc71.lib") + #pragma comment(lib, "mfcs71.lib") + #endif + #else + #ifdef _DEBUG + #pragma comment(lib, "mfc71ud.lib") + #pragma comment(lib, "mfcs71ud.lib") + #else + #pragma comment(lib, "mfc71u.lib") + #pragma comment(lib, "mfcs71u.lib") + #endif + #endif +#endif + +#ifdef _DLL + #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG) + #pragma comment(lib, "msvcrtd.lib") + #else + #pragma comment(lib, "msvcrt.lib") + #endif +#else +#ifdef _MT + #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG) + #pragma comment(lib, "libcmtd.lib") + #else + #pragma comment(lib, "libcmt.lib") + #endif +#else + #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG) + #pragma comment(lib, "libcd.lib") + #else + #pragma comment(lib, "libc.lib") + #endif +#endif +#endif + +#pragma comment(lib, "kernel32.lib") +#pragma comment(lib, "user32.lib") +#pragma comment(lib, "gdi32.lib") +#pragma comment(lib, "msimg32.lib") +#pragma comment(lib, "comdlg32.lib") +#pragma comment(lib, "winspool.lib") +#pragma comment(lib, "advapi32.lib") +#pragma comment(lib, "shell32.lib") +#pragma comment(lib, "comctl32.lib") +#pragma comment(lib, "shlwapi.lib") + +// force inclusion of NOLIB.OBJ for /disallowlib directives +#pragma comment(linker, "/include:__afxForceEXCLUDE") + +// force inclusion of DLLMODUL.OBJ for _USRDLL +#ifdef _USRDLL +#pragma comment(linker, "/include:__afxForceUSRDLL") +#endif + +// force inclusion of STDAFX.OBJ for precompiled types +#ifdef _AFXDLL +#pragma comment(linker, "/include:__afxForceSTDAFX") +#endif + +#endif //!_AFX_NOFORCE_LIBS + +*/ + +// Insert your headers here +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include <windows.h> + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__AE5780CC_1107_4F64_ADC7_F4BACF658CC2__INCLUDED_) Added: branches/amis3/AmisAudio/TPBReader2/RegOcx.cpp =================================================================== --- branches/amis3/AmisAudio/TPBReader2/RegOcx.cpp (rev 0) +++ branches/amis3/AmisAudio/TPBReader2/RegOcx.cpp 2007-10-13 23:51:05 UTC (rev 2189) @@ -0,0 +1,152 @@ +// RegOcx.cpp : Defines the entry point for the DLL application. +// +//#include "../../AmisGuiMFC/Brain/AmisBrain.h" + +//#include "StdAfx.h" + +#include "windows.h" +#include "malloc.h" +#include <string> + +using namespace std; + +typedef HRESULT (*DllRegisterServer) (void); +typedef HRESULT (*DllUnregisterServer) (void); +//typedef long (*DllRegisterServer) (void); + +/* +BOOL APIENTRY DllMain( HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + //LoadLibrary( + return TRUE; +} +*/ + +BOOL RunDllReg(LPTSTR lpFileName) { + LPTSTR lpSysDir = (LPTSTR) malloc(255); + GetSystemDirectory(lpSysDir, 255); + + + + //USES_CONVERSION; + + TCHAR szBuffer[256]; + GetModuleFileName(NULL, szBuffer, 256); + //CString cstr_app_path = szBuffer; + std::wstring strDir(szBuffer); + int pos = strDir.find_last_of('\\'); //ReverseFind + + if (pos >= 0) + { + strDir = strDir.substr(0, pos); //Mid + } + + //strDir = AmisBrain::Instance()->getAppPath(); + + + std::wstring strFullPath = strDir.append(lpFileName); + + /*for (int i=0; i<255; i++) { + if ((char) lpSysDir[i] == 0) { + memcpy((lpSysDir + i), lpFileName, 27); + lpSysDir[i + 27] = 0; + break; + } + }*/ + + bool bResult = false; + HMODULE hModule; + + try { + hModule = LoadLibrary(strFullPath.c_str()); + if (hModule == 0) { + + std::wstring strMessage(L"ActiveX library is missing, DirectX audio will play only at normal speed.\n\n"); + strMessage.append(strFullPath); + + + MessageBox(NULL, strMessage.c_str(), L"ActiveX Library not found", MB_OK); + + throw(1); + } + DllRegisterServer DllReg = (DllRegisterServer) GetProcAddress(hModule, "DllRegisterServer"); + if (DllReg == 0) throw(2); + HRESULT hResult = DllReg(); + if (hResult != S_OK) throw(3); + + bResult = true; + } catch (...) { + } + + FreeLibrary(hModule); + free(lpSysDir); + + return bResult; +} + +BOOL RunDllUnreg(LPTSTR lpFileName) { + LPTSTR lpSysDir = (LPTSTR) malloc(255); + GetSystemDirectory(lpSysDir, 255); + + std::wstring strDir(lpSysDir); + std::wstring strFullPath = strDir.append(lpFileName); + /* + for (int i=0; i<255; i++) { + if ((char) lpSysDir[i] == 0) { + memcpy((lpSysDir + i), lpFileName, 27); + lpSysDir[i + 27] = 0; + break; + } + } + */ + + bool bResult = false; + HMODULE hModule; + + try { + hModule = LoadLibrary(strFullPath.c_str()); + if (hModule == 0) { + + //std::wstring strMessage(L"ActiveX library is missing, DirectX audio will play only at normal speed.\n\n"); + //strMessage.append(strFullPath); + + + //MessageBox(NULL, strMessage.c_str(), L"ActiveX Library not found", MB_OK); + + throw(1); + } + DllRegisterServer DllReg = (DllUnregisterServer) GetProcAddress(hModule, "DllUnregisterServer"); + if (DllReg == 0) throw(2); + HRESULT hResult = DllReg(); + if (hResult != S_OK) throw(3); + + bResult = true; + } catch (...) { + } + + FreeLibrary(hModule); + free(lpSysDir); + + return bResult; +} + +BOOL RegisterOCX() { + //if (!RunDllReg("\\DirectShowAudioHandler.ocx")) return false; + if (!RunDllReg(L"\\TransformSample.ax")) return false; + //if (!RunDllReg("\\IppDecryptor.dll")) return false; + //if (!RunDllReg("\\ComDlg32.ocx")) return false; + + return true; +} + +BOOL UnregisterOCX() { + //if (!RunDllUnreg("\\DirectShowAudioHandler.ocx")) return false; + if (!RunDllUnreg(L"\\TransformSample.ax")) return false; + //if (!RunDllUnreg("\\IppDecryptor.dll")) return false; + //if (!RunDllUnreg("\\ComDlg32.ocx")) return false; + + return true; +} \ No newline at end of file Added: branches/amis3/AmisAudio/TPBReader2/RegOcx.h =================================================================== --- branches/amis3/AmisAudio/TPBReader2/RegOcx.h (rev 0) +++ branches/amis3/AmisAudio/TPBReader2/RegOcx.h 2007-10-13 23:51:05 UTC (rev 2189) @@ -0,0 +1,18 @@ +// RegOcx.cpp : Defines the entry point for the DLL application. +// + +/* +BOOL APIENTRY DllMain( HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + //LoadLibrary( + return TRUE; +} +*/ + +BOOL RunDllReg(LPTSTR lpFileName); +BOOL RunDllUnreg(LPTSTR lpFileName); +BOOL RegisterOCX(); +BOOL UnregisterOCX(); \ No newline at end of file Added: branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp (rev 0) +++ branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2007-10-13 23:51:05 UTC (rev 2189) @@ -0,0 +1,1245 @@ +// DmpCtl.cpp : Implementation of the CDmpCtrl ActiveX Control class. + + +#include "StdAfxFIX.h" + +#include "DmpCtl.h" + +#include "DmpPpg.h" + +#include <string> +using namespace std; + +#include "resource.h" + +#include <assert.h> + +//#include <dshow.h> + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + + +#include "../RegOcx.h" + +/* +const GUID CDECL BASED_CODE _tlid = + { 0xd825129b, 0xb483, 0x46bc, { 0xb9, 0x4f, 0x6, 0xc1, 0xfd, 0x5a, 0xeb, 0xb1 } }; +const WORD _wVerMajor = 1; +const WORD _wVerMinor = 0; +*/ + +//NO_ACTIVEX IMPLEMENT_DYNCREATE(CDmpCtrl, COleControl) + + +///////////////////////////////////////////////////////////////////////////// +// Message map + +//NO_ACTIVEX +/* +zBEGIN_MESSAGE_MAP(CDmpCtrl, COleControl) + //{{zAFX_MSG_MAP(CDmpCtrl) + //}}zAFX_MSG_MAP + zON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties) +zEND_MESSAGE_MAP() +*/ + +///////////////////////////////////////////////////////////////////////////// +// Dispatch map + +//NO_ACTIVEX +/* +zBEGIN_DISPATCH_MAP(CDmpCtrl, COleControl) + //{{zAFX_DISPATCH_MAP(CDmpCtrl) + DISP_PROPERTY_EX(CDmpCtrl, "EndOfStream", GetEndOfStream, SetEndOfStream, VT_BOOL) + DISP_FUNCTION(CDmpCtrl, "fileName", fileName, VT_BOOL, VTS_BSTR) + DISP_FUNCTION(CDmpCtrl, "play", play, VT_BOOL, VTS_NONE) + DISP_FUNCTION(CDmpCtrl, "stop", stop, VT_BOOL, VTS_NONE) + DISP_FUNCTION(CDmpCtrl, "getPosition", getPosition, VT_I4, VTS_NONE) + DISP_FUNCTION(CDmpCtrl, "setPosition", setPosition, VT_BOOL, VTS_I4) + DISP_FUNCTION(CDmpCtrl, "setRate", setRate, VT_BOOL, VTS_R8) + DISP_FUNCTION(CDmpCtrl, "getRate", getRate, VT_R8, VTS_NONE) + DISP_FUNCTION(CDmpCtrl, "getDuration", getDuration, VT_I4, VTS_NONE) + DISP_FUNCTION(CDmpCtrl, "setStopPosition", setStopPosition, VT_BOOL, VTS_I4) + DISP_FUNCTION(CDmpCtrl, "insertVupp", insertVupp, VT_BOOL, VTS_NONE) + DISP_FUNCTION(CDmpCtrl, "getState", getState, VT_I4, VTS_NONE) + DISP_FUNCTION(CDmpCtrl, "pause", pause, VT_BOOL, VTS_NONE) + DISP_FUNCTION(CDmpCtrl, "setVuppProperties", setVuppProperties, VT_BOOL, VTS_R8 VTS_I2 VTS_I2 VTS_I2 VTS_I2 VTS_I2) + DISP_FUNCTION(CDmpCtrl, "setVolume", setVolume, VT_BOOL, VTS_I4) + DISP_FUNCTION(CDmpCtrl, "getVolume", getVolume, VT_I4, VTS_NONE) + DISP_FUNCTION(CDmpCtrl, "stopDmpThread", stopDmpThread, VT_EMPTY, VTS_NONE) + //}}zAFX_DISPATCH_MAP +zEND_DISPATCH_MAP() +*/ + +///////////////////////////////////////////////////////////////////////////// +// Event map + +//NO_ACTIVEX +/* +zBEGIN_EVENT_MAP(CDmpCtrl, COleControl) + //{{zAFX_EVENT_MAP(CDmpCtrl) + zEVENT_CUSTOM("newTime", FireNewTime, VTS_I4) + zEVENT_CUSTOM("endOfStream", FireEndOfStream, VTS_NONE) + zEVENT_CUSTOM_ID("error", DISPID_ERROREVENT, FireError, VTS_I4) + //}}zAFX_EVENT_MAP +zEND_EVENT_MAP() +*/ + +///////////////////////////////////////////////////////////////////////////// +// Property pages + +// TODO: Add more property pages as needed. Remember to increase the count! +//NO_ACTIVEX +/* +BEGIN_PROPPAGEIDS(CDmpCtrl, 1) + PROPPAGEID(CDmpPropPage::guid) +END_PROPPAGEIDS(CDmpCtrl) +*/ + +///////////////////////////////////////////////////////////////////////////// +// Initialize class factory and guid + +//NO_ACTIVEX +/* +IMPLEMENT_OLECREATE_EX(CDmpCtrl, "DMP.DmpCtrl.1", + 0xef821ae, 0x89ee, 0x41c5, 0x87, 0xd0, 0xff, 0xb, 0x33, 0xba, 0x4b, 0xa6) +*/ + +///////////////////////////////////////////////////////////////////////////// +// Type library ID and version + +//NO_ACTIVEX +/* +IMPLEMENT_OLETYPELIB(CDmpCtrl, _tlid, _wVerMajor, _wVerMinor) +*/ + +///////////////////////////////////////////////////////////////////////////// + +// Interface IDs + +//NO_ACTIVEX +/* +const IID BASED_CODE IID_DDmp = + { 0x12d87155, 0xaf68, 0x4b5d, { 0xac, 0x74, 0x72, 0xa1, 0x69, 0x21, 0xc8, 0xbd } }; + +const IID BASED_CODE IID_DDmpEvents = + { 0x2257ed6e, 0xced8, 0x4f21, { 0x95, 0x1c, 0x76, 0x22, 0xec, 0x21, 0x3, 0x16 } }; +*/ + +///////////////////////////////////////////////////////////////////////////// +// Control type information + +//NO_ACTIVEX +/* +static const DWORD BASED_CODE _dwDmpOleMisc = + OLEMISC_INVISIBLEATRUNTIME | + OLEMISC_SETCLIENTSITEFIRST | + OLEMISC_INSIDEOUT | + OLEMISC_CANTLINKINSIDE | + OLEMISC_RECOMPOSEONRESIZE; + +IMPLEMENT_OLECTLTYPE(CDmpCtrl, IDS_DMP, _dwDmpOleMisc) +*/ + +///////////////////////////////////////////////////////////////////////////// +// CDmpCtrl::CDmpCtrlFactory::UpdateRegistry - +// Adds or removes system registry entries for CDmpCtrl + +//NO_ACTIVEX +/* +BOOL CDmpCtrl::CDmpCtrlFactory::UpdateRegistry(BOOL bRegister) +{ + // TODO: Verify that your control follows apartment-model threading rules. + // Refer to MFC TechNote 64 for more information. + // If your control does not conform to the apartment-model rules, then + // you must modify the code below, changing the 6th parameter from + // afxRegApartmentThreading to 0. + + if (bRegister) {} + return AfxOleRegisterControlClass( + AfxGetInstanceHandle(), + m_clsid, + m_lpszProgID, + IDS_DMP, + IDB_DMP, + afxRegApartmentThreading, + _dwDmpOleMisc, + _tlid, + _wVerMajor, + _wVerMinor); + else + return AfxOleUnregisterClass(m_clsid, m_lpszProgID); +} +*/ + +/* + Code starts here. +*/ + +EXTERN_GUID(WMFORMAT_WaveFormatEx, +0x05589f81, 0xc356, 0x11ce, 0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a); + +// Interface and class id declarations, these are IDs of interfaces and classes +// that we use. + +/* +const IID CLSID_MPEG3Decoder = + { 951988224, 56308, 4560, { 134,14,0,160,36,207,239,109 } }; + +const IID IID_IVuppInterface = + { 0xa33e626e, 0xd6c4, 0x4559, { 0xa1, 0xd6, 0x9f, 0x1d, 0x95, 0xf0, 0xd8, 0xe2 } }; + +const IID CLSID_TPBVupp10 = + { 0x66172967, 0x56c5, 0x4b89,{ 0xaa, 0x92, 0xc9, 0xef, 0xec, 0x56, 0x46, 0x7b } }; + +const IID IID_ITPBTS = { + 0x5dd2d89b, 0x6925, 0x4ceb, 0x9c, 0x20, 0xad, 0x79, 0xf, 0x76, 0xe6, 0x38}; + +const IID CLSID_TPBTSFilter = { + 0xb9b0860, 0xf562, 0x43da, 0x8e, 0xd4, 0xfd, 0x3f, 0xdb, 0xcd, 0x99, 0x6}; +*/ + + +///////////////////////////////////////////////////////////////////////////// +// CDmpCtrl::CDmpCtrl - Constructor + +CDmpCtrl::CDmpCtrl() +{ + // Initialize COM engine for use by this thread + //CoInitialize(NULL); + //CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + CoInitializeEx(NULL, COINIT_MULTITHREADED); + + RegisterOCX(); + + //NO_ACTIVEX InitializeIIDs(&IID_DDmp, &IID_DDmpEvents); + + static int instanceCount = 0; + thisInstanceNumber = instanceCount; + instanceCount++; + + + bInitialized = false; + bFileLoaded = false; + bUseVupp = false; + //bEndOfStream = false; + bCatchEvents = false; + + hEventHandler = NULL; +// pITPBTs = NULL; + pIVuppInterface = NULL; + pIGB = NULL; + + startPosition = 0; + stopPosition = 0; + + bProcessEvents = true; + + hThread = GetCurrentThread(); + + logSession("Construct"); + mRate = 1.0; +} + +///////////////////////////////////////////////////////////////////////////// +// CDmpCtrl::~CDmpCtrl - Destructor + +CDmpCtrl::~CDmpCtrl() +{ + destroyFilterGraph(); + bFileLoaded = false; + bInitialized = false; + + logSession("Destruct"); + + CoUninitialize(); + + UnregisterOCX(); +} + +BOOL CDmpCtrl::createFilterGraph() { + + logSession("Create filtergraph"); + + if (pIGB != NULL) { + destroyFilterGraph(); + } + + bInitialized = FALSE; + bFileLoaded = FALSE; + + // Here we start creating a FilterGraph object and derivate several + // interfaces from the object. + + if (CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, + IID_IGraphBuilder, (void **) &pIGB) != S_OK) { + + //NO_ACTIVEX FireError(lError); + destroyFilterGraph(); + return false; + } + + bCatchEvents = true; + //LPDWORD lpdwThreadID; + unsigned long lpdwThreadID; + bProcessEvents = true; + hEventHandler = CreateThread(NULL, 0, eventHandler, this, 0, &lpdwThreadID); + + + + startPosition = 0; + bInitialized = TRUE; + + return true; +} + +BOOL CDmpCtrl::destroyFilterGraph() { + + logSession("Destroy filtergraph"); + stop(); + + if (hEventHandler) { + + bCatchEvents = true; + bProcessEvents = true; + + IMediaEventSink *pIMES = NULL; + pIGB->QueryInterface(IID_IMediaEventSink, (void**) &pIMES); + pIMES->Notify(EC_USER + 4, 0, 0); + pIMES->Release(); + pIMES = NULL; + + +// bCatchEvents = false; +// threadSuspended = true; + + //SuspendThread(hEventHandler); + if (WaitForSingleObject(hEventHandler, INFINITE) != WAIT_OBJECT_0) { + return false; + } + + } + +/* if (pITPBTs != NULL) { + pITPBTs->StopEventEngine(); + pITPBTs->Release(); + pITPBTs = NULL; + } +*/ + + if (pIGB != NULL) { + //pIGB->Release(); + pIGB = NULL; + } + + if (pIVuppInterface != NULL) { + int f =pIVuppInterface->Release(); + pIVuppInterface = NULL; + } + return true; +} + + +// This function inserts a AsyncReader source filter into the FilterGraph filter +// chain and sets the filename property on the source filter. +BOOL CDmpCtrl::insertSource(WCHAR *wFileName) +{ + IBaseFilter *pAsyncFilter = NULL; + IPin *pPin = NULL; + IEnumPins *pEPins = NULL; + + + // Create a AsyncReader object and derivate the BaseFilter interface + if (CoCreateInstance(CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, + IID_IBaseFilter, (void **) &pAsyncFilter) != S_OK) { + if (pAsyncFilter != NULL) pAsyncFilter->Release(); + return false; + } + + // Add the AsyncReader filter to the filtergraph + if (pIGB->AddSourceFilter(wFileName, wFileName, &pAsyncFilter) != S_OK) { + if (pAsyncFilter != NULL) pAsyncFilter->Release(); + return false; + } + + // Enumerate the pins on the AsyncReader object, find the first pin and let + // the FilterGraph render the whole filter chain from the pin. + if (pAsyncFilter->EnumPins(&pEPins) != S_OK) { + if (pAsyncFilter != NULL) pAsyncFilter->Release(); + + if (pEPins != NULL) pEPins->Release(); + return false; + } + if (pEPins->Next(1, &pPin, NULL) != S_OK) { + + if (pPin != NULL) pPin->Release(); + if (pEPins != NULL) pEPins->Release(); + + if (pAsyncFilter != NULL) pAsyncFilter->Release(); + return false; + } + if (pIGB->Render(pPin) != S_OK) { + + if (pPin != NULL) pPin->Release(); + if (pEPins != NULL) pEPins->Release(); + if (pAsyncFilter != NULL) pAsyncFilter->Release(); + + return false; + } + + if (pPin != NULL) pPin->Release(); + if (pEPins != NULL) pEPins->Release(); + if (pAsyncFilter != NULL) pAsyncFilter->Release(); + return true; +} + +BOOL CD... [truncated message content] |
From: <dan...@us...> - 2007-10-14 01:59:18
|
Revision: 2196 http://amis.svn.sourceforge.net/amis/?rev=2196&view=rev Author: daniel_weck Date: 2007-10-13 18:59:13 -0700 (Sat, 13 Oct 2007) Log Message: ----------- - Daniel WECK * TTS tests in place (app startup and play/pause space trigger) Modified Paths: -------------- branches/amis3/AmisAudio/AmisAudio.cpp branches/amis3/AmisAudio/AmisAudio.h branches/amis3/AmisAudio/TPBReader2/RegOcx.cpp branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp branches/amis3/AmisGuiMFC2/src/Preferences.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp Modified: branches/amis3/AmisAudio/AmisAudio.cpp =================================================================== --- branches/amis3/AmisAudio/AmisAudio.cpp 2007-10-14 00:25:39 UTC (rev 2195) +++ branches/amis3/AmisAudio/AmisAudio.cpp 2007-10-14 01:59:13 UTC (rev 2196) @@ -91,6 +91,10 @@ pDmpCtrl = new CDmpCtrl(); } +void AmisAudio::setCallback(sendMessageCallbackFn pFunction) +{ + pDmpCtrl->setCallback(pFunction); +} /****************************************************************** AmisAudio destructor Function ******************************************************************/ Modified: branches/amis3/AmisAudio/AmisAudio.h =================================================================== --- branches/amis3/AmisAudio/AmisAudio.h 2007-10-14 00:25:39 UTC (rev 2195) +++ branches/amis3/AmisAudio/AmisAudio.h 2007-10-14 01:59:13 UTC (rev 2196) @@ -117,6 +117,8 @@ void adjustVolume(int); void adjustRate(double); + typedef void (*sendMessageCallbackFn)(void *); + void setCallback(sendMessageCallbackFn pFunction); private: void ShowStatePrompt(); Modified: branches/amis3/AmisAudio/TPBReader2/RegOcx.cpp =================================================================== --- branches/amis3/AmisAudio/TPBReader2/RegOcx.cpp 2007-10-14 00:25:39 UTC (rev 2195) +++ branches/amis3/AmisAudio/TPBReader2/RegOcx.cpp 2007-10-14 01:59:13 UTC (rev 2196) @@ -1,9 +1,6 @@ // RegOcx.cpp : Defines the entry point for the DLL application. // -//#include "../../AmisGuiMFC/Brain/AmisBrain.h" -//#include "StdAfx.h" - #include "windows.h" #include "malloc.h" #include <string> @@ -44,9 +41,6 @@ strDir = strDir.substr(0, pos); //Mid } - //strDir = AmisBrain::Instance()->getAppPath(); - - std::wstring strFullPath = strDir.append(lpFileName); /*for (int i=0; i<255; i++) { Modified: branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2007-10-14 00:25:39 UTC (rev 2195) +++ branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2007-10-14 01:59:13 UTC (rev 2196) @@ -12,6 +12,9 @@ #include "resource.h" +//#include "../../../AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h" + + #include <assert.h> //#include <dshow.h> @@ -25,6 +28,12 @@ #include "../RegOcx.h" + +void CDmpCtrl::setCallback(sendMessageCallbackFn pFunction) +{ + sendMessageCallback=pFunction; +} + /* const GUID CDECL BASED_CODE _tlid = { 0xd825129b, 0xb483, 0x46bc, { 0xb9, 0x4f, 0x6, 0xc1, 0xfd, 0x5a, 0xeb, 0xb1 } }; @@ -1145,6 +1154,10 @@ */ if (bProcessEvents) { stopPosition = 0; + + //AudioSequencePlayer::Instance()->ClipAudioEndNotify(); + sendMessageCallback(0); + //SetEndOfStream(true); // pause(); } Modified: branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h 2007-10-14 00:25:39 UTC (rev 2195) +++ branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h 2007-10-14 01:59:13 UTC (rev 2196) @@ -56,6 +56,10 @@ public: CDmpCtrl(); + typedef void (*sendMessageCallbackFn)(void *); + sendMessageCallbackFn sendMessageCallback; + void setCallback(sendMessageCallbackFn pFunction); + // Overrides // ClassWizard generated virtual function overrides //{{zAFX_VIRTUAL(CDmpCtrl) Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-10-14 00:25:39 UTC (rev 2195) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-10-14 01:59:13 UTC (rev 2196) @@ -29,6 +29,11 @@ AudioSequencePlayer* AudioSequencePlayer::pinstance = 0; +//The message callback function ... signals end of the clip +static void clipFinishedCallback(void *wind) +{ + AudioSequencePlayer::Instance()->ClipAudioEndNotify(); +} AudioSequencePlayer::AudioSequencePlayer(void) { m_previousAudioSequence = NULL; @@ -44,8 +49,10 @@ unsigned int threadID; - TTSPlayer::Instance()->Play(L""); // To avoid lazy instanciation and load the SAPI module. + AmisAudio::Instance()->setCallback((sendMessageCallbackFn)clipFinishedCallback); + TTSPlayer::Instance(); // To avoid lazy instanciation and load the SAPI module. + InitializeCriticalSection(&m_csSequence); m_hEventWakeup = CreateEvent(NULL, TRUE, FALSE, NULL); @@ -232,6 +239,7 @@ } }*/ } + void AudioSequencePlayer::ClipAudioEndNotify() { TRACE(L"####### END AUDIO"); m_wakeUpOriginator = 3; // AUDIO CLIP END @@ -281,9 +289,9 @@ string tmpStr = amis::Preferences::Instance()->mUiLang; //CAmisGuiMFC2App* pApp = (CAmisGuiMFC2App *) AfxGetApp(); - tmpStr = amis::util::FilePathTools::goRelativePath(theApp.getAppPath(), tmpStr); //AmisBrain::Instance()->getAppPath() + tmpStr = amis::util::FilePathTools::goRelativePath(theApp.getAppPath(), tmpStr); - src = amis::util::FilePathTools::goRelativePath(tmpStr, src); //AudioPromptCol, AmisBrain ::Instance()->mFilePath ... + src = amis::util::FilePathTools::goRelativePath(tmpStr, src); src = amis::util::FilePathTools::getAsLocalFilePath(src); string clipBegin = ""; Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp 2007-10-14 00:25:39 UTC (rev 2195) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp 2007-10-14 01:59:13 UTC (rev 2196) @@ -15,8 +15,6 @@ #define TRACE ATLTRACE #endif -// DanToDo: The following includes did not survive the Amis3 architecture, so I must find equivalent functions/utilities elsewhere now. -//#include "../Brain/AmisBrain.h" #include <gui/MainWndParts.h> @@ -76,6 +74,8 @@ void TTSPlayer::Play(CString str) { + TRACE(L"******"); + TRACE(str); #ifdef COMPILE_WITH_SAPI if (IsSpeaking()) { TRACE("????????"); Modified: branches/amis3/AmisGuiMFC2/src/Preferences.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2007-10-14 00:25:39 UTC (rev 2195) +++ branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2007-10-14 01:59:13 UTC (rev 2196) @@ -50,6 +50,8 @@ mpPageFG = new Color("#ffffff"); mbPauseOnApplicationLostFocus = true; + + this->mbIsSelfVoicing = true; } Preferences::~Preferences() Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-10-14 00:25:39 UTC (rev 2195) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-10-14 01:59:13 UTC (rev 2196) @@ -53,7 +53,10 @@ #include "util/FilePathTools.h" #include "../AmisAudio/AmisAudio.h" +#include "../../AmisSelfVoicing\AudioSequencePlayer.h" +#include "../../AmisSelfVoicing\TTSPlayer.h" + #ifdef _DEBUG #define new DEBUG_NEW #endif @@ -180,9 +183,18 @@ //set the callback function to handle book key registration amis::dtb::DtbWithHooks::Instance()->setCallbackForPreprocessingBookKey(registerBookKeyFile); - //DanTodo: initialize Self-voicing audio backend + if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + { AmisAudio::Instance()->enable(); + + AudioSequence* seq = new AudioSequence; + seq->append(L"AMIS"); + seq->append(L"Text-to-speech engine is ready.Text-to-speech engine is ready.Text-to-speech engine is ready."); + seq->append(L"Is it good ?"); + AudioSequencePlayer::Instance()->Play(seq); + } + return TRUE; } @@ -201,8 +213,14 @@ amis::gui::MenuManip::Instance()->DestroyInstance(); amis::gui::MainWndParts::Instance()->DestroyInstance(); - //DanTodo: destroy Self-voicing audio backend - //AmisAudio::Instance()->DestroyInstance(); + if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + { + AmisAudio::Instance()->DestroyInstance(); + + TTSPlayer::Instance()->DestroyInstance(); + + AudioSequencePlayer::Instance()->DestroyInstance(); + } if (mpRecentBooks) delete mpRecentBooks; @@ -329,9 +347,15 @@ */ void CAmisGuiMFC2App::setPauseState(bool pauseState) { - //DanToDo: add self-voicing - //AudioSequencePlayer::Instance()->Stop(); + + if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + { + AudioSequencePlayer::Instance()->Stop(); + AudioSequence* seq = new AudioSequence; + if (pauseState) seq->append(L"Paused."); else seq->append(L"Playing."); + AudioSequencePlayer::Instance()->Play(seq); + } //DanToDo: I don't think Amis3 has a toolbar, so for now the following code is useless (should be removed definitely ?). //if (mpMainFrame->m_wndDefaultToolbar) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-10-14 13:34:10
|
Revision: 2197 http://amis.svn.sourceforge.net/amis/?rev=2197&view=rev Author: daniel_weck Date: 2007-10-14 06:34:13 -0700 (Sun, 14 Oct 2007) Log Message: ----------- - Daniel Weck Major Commit * Added AccessibleUi backend (it's wired and works fine with the default loaded language pack: eng-US) * Added hooks to the UI, the top menu kinda works (because its contents have changed since 2.6, things are not quite right...but the framework seems to work fine) * I had a hard time with CoInitialize AppartmentThreaded vs Multithreaded, because of the fact that AMIS now runs at least 3 activeX components: IE-HTML view, Vupp, SAPI-TTS. It seems to work though, but of course we'll only know for sure when all the UI self-voicing hooks are in place. * Oh...and the code is a mess, but I need to test stuff before adding new classes and/or projects that will screw the linking of the VC++ solution. Modified Paths: -------------- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h branches/amis3/AmisGuiMFC2/src/Preferences.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp Added Paths: ----------- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUiDataReader.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/LabelList.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/LabelList.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/StdAfx.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/StdAfx.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.h branches/amis3/AmisGuiMFC2/PreTranslateMessageHandler.cpp branches/amis3/AmisGuiMFC2/PreTranslateMessageHandler.h Modified: branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2007-10-14 01:59:13 UTC (rev 2196) +++ branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2007-10-14 13:34:13 UTC (rev 2197) @@ -221,7 +221,7 @@ // Initialize COM engine for use by this thread //CoInitialize(NULL); //CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - CoInitializeEx(NULL, COINIT_MULTITHREADED); + //CoInitializeEx(NULL, COINIT_MULTITHREADED); RegisterOCX(); @@ -265,7 +265,7 @@ logSession("Destruct"); - CoUninitialize(); + //CoUninitialize(); UnregisterOCX(); } @@ -281,6 +281,10 @@ bInitialized = FALSE; bFileLoaded = FALSE; + //CoInitialize(NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + //CoInitializeEx(NULL, COINIT_MULTITHREADED); + // Here we start creating a FilterGraph object and derivate several // interfaces from the object. @@ -292,6 +296,8 @@ return false; } + CoUninitialize(); + bCatchEvents = true; //LPDWORD lpdwThreadID; unsigned long lpdwThreadID; @@ -303,6 +309,7 @@ startPosition = 0; bInitialized = TRUE; + return true; } Modified: branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h 2007-10-14 01:59:13 UTC (rev 2196) +++ branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h 2007-10-14 13:34:13 UTC (rev 2197) @@ -126,8 +126,8 @@ bool bSelfBreak = false; //CoInitialize(NULL); - //CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - CoInitializeEx(NULL, COINIT_MULTITHREADED); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + //CoInitializeEx(NULL, COINIT_MULTITHREADED); CDmpCtrl *pDMP = (CDmpCtrl*)lpParam; IMediaEvent *pIME; Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-10-14 01:59:13 UTC (rev 2196) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-10-14 13:34:13 UTC (rev 2197) @@ -413,6 +413,215 @@ </Filter> </Filter> </Filter> + <Filter + Name="AccessibleUi" + Filter=""> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\AccessibleUIDataReader.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\AccessibleUiDataReader.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\Action.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\Action.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\AudioPrompt.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\AudioPrompt.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\AudioPromptReader.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\AudioPromptReader.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\Container.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\Container.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\DataTree.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\DataTree.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\Dialog.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\Dialog.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\DialogControl.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\DialogControl.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\IniFile.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\IniFile.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\Label.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\Label.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\LabelList.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\LabelList.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\Prompt.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\Prompt.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\PromptResolver.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\PromptResolver.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\StdAfx.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\StdAfx.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\Switch.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\Switch.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\UiItem.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\UiItem.h"> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\UiMediaTypes.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> + <File + RelativePath=".\AmisSelfVoicing\AccessibleUI\UiMediaTypes.h"> + </File> + </Filter> <File RelativePath=".\amis.ico"> </File> @@ -444,6 +653,12 @@ RelativePath=".\flag.ico"> </File> <File + RelativePath=".\PreTranslateMessageHandler.cpp"> + </File> + <File + RelativePath=".\PreTranslateMessageHandler.h"> + </File> + <File RelativePath=".\resource.h"> </File> <File Added: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp 2007-10-14 13:34:13 UTC (rev 2197) @@ -0,0 +1,1222 @@ +//xerces includes + + +#include <xercesc/util/XMLString.hpp> +#include <xercesc/sax2/Attributes.hpp> +#include <xercesc/sax/SAXParseException.hpp> +#include <xercesc/sax/SAXException.hpp> +#include <xercesc/sax/HandlerBase.hpp> + +#include <xercesc/util/PlatformUtils.hpp> +#include <xercesc/util/TransService.hpp> +#include <xercesc/sax2/SAX2XMLReader.hpp> +#include <xercesc/sax2/XMLReaderFactory.hpp> + +#include "./IniFile.h" + +#include <vector> +#include <string> + +#include "AccessibleUiDataReader.h" +#include "Switch.h" + +#include "../AmisGuiMFC2/include/Preferences.h" +#include "../AmisCore/include/util/FilePathTools.h" + +// DanToDo: The following includes did not survive the Amis3 architecture, so I must find equivalent functions/utilities elsewhere now. +//#include "../Brain/AmisBrain.h" +//#include "../Brain/PrefsReader.h" +//#include "../../AmisCommon/AmisCommon.h" +//#include "../Brain/trim.h" + +namespace AccessibleUi +{ +DataReader::DataReader() +{ + mUiItems.empty(); + mpRecentLabel = NULL; + mpRecentTextNode = NULL; + mpData = NULL; + mpRecentSwitch = NULL; + mCollectedText.empty(); +} + +DataReader::~DataReader() +{ + +} + +void DataReader::setAppPath(string appPath) { + mAppPath = appPath; +} + +string DataReader::getIniFilePath() { + if (! mIniFilePath.empty()) return mIniFilePath; + + mIniFilePath = amis::Preferences::Instance()->mUiLang; + mIniFilePath = amis::util::FilePathTools::goRelativePath(mAppPath, mIniFilePath); + mIniFilePath = amis::util::FilePathTools::goRelativePath(mIniFilePath, "resource.h.ini"); + mIniFilePath = amis::util::FilePathTools::getAsLocalFilePath(mIniFilePath); + + return mIniFilePath; +} + +//-------------- +//start parsing the file and filling in the data model (passed in as pData) +amis::Error DataReader::readFile(string inputFilepath, AccessibleUi::DataTree* pData) +{ + amis::Error err; + + SAX2XMLReader* parser = NULL; + + mUiItems.empty(); + mpRecentLabel = NULL; + mpRecentTextNode = NULL; + mpData = NULL; + mpRecentPrompt = NULL; + mbFlag_GetChars = false; + mpRecentLabelList = NULL; + mbFlag_ProcessingGeneralPrompts = false; + mbFlag_ProcessingPromptItemRefs = false; + + mBuildErrorFlag = amis::OK; + mBuildErrorMsg = ""; + + mpData = pData; + mFilepath = amis::util::FilePathTools::getAsLocalFilePath(inputFilepath); + + const char* cp_file = NULL; + cp_file = mFilepath.c_str(); + + try + { + XMLPlatformUtils::Initialize(); + } + + catch (const XMLException& e) + { + + //MEMORY LEAK VERIFIED + char* xerces_msg = NULL; + + xerces_msg = XMLString::transcode(e.getMessage()); + + mBuildErrorFlag = amis::PARSE_ERROR; + mBuildErrorMsg = "Fatal error while processing *" + mFilepath + + "* Xerces signalled: \"" + xerces_msg + "\""; + + XMLString::release(&xerces_msg); + + err.setCode(mBuildErrorFlag); + err.setMessage(mBuildErrorMsg); + + return err; + + } + + //create an XMLReader object + parser = XMLReaderFactory::createXMLReader(); + parser->setContentHandler(this); + parser->setErrorHandler(this); + + parser->setFeature(XMLUni::fgXercesLoadExternalDTD, false); + parser->setFeature(XMLUni::fgSAX2CoreValidation, false); + + + try + { + parser->parse(cp_file); + } + catch (const XMLException& e) + { + //MEMORY LEAK VERIFIED + char* xerces_msg = NULL; + + xerces_msg = XMLString::transcode(e.getMessage()); + + mBuildErrorFlag = amis::PARSE_ERROR; + mBuildErrorMsg = "Fatal error while processing *" + mFilepath + + "* Xerces signalled: \"" + xerces_msg + "\""; + + XMLString::release(&xerces_msg); + + err.setCode(mBuildErrorFlag); + err.setMessage(mBuildErrorMsg); + + return err; + + } + + delete parser; + XMLPlatformUtils::Terminate(); + + err.setCode(mBuildErrorFlag); + err.setMessage(mBuildErrorMsg); + + //resolve prompt items + mpData->resolvePromptItemsWithRefIds(); + + return err; +} + +//-------------- +//xerces' start element function +void DataReader::startElement(const XMLCh* const uri, + const XMLCh* const localname, + const XMLCh* const qname, + const Attributes& attributes) +{ + char* node_name = XMLString::transcode(qname); + + //container element + if (strcmp(node_name, "container") == 0) + { + Container* p_container = new Container(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("id"); + attr = XMLString::transcode(attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_container->setId(attr_tmpstr); + XMLString::release(&attr); + } + + //MEMORY LEAK VERIFIED + attr = NULL; + attr_name = XMLString::transcode("accelerator"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + //p_container->setKeyboardAccelerator(attr_tmpstr); + XMLString::release(&attr); + } + Container* p_parent_container = NULL; + + p_parent_container = (Container*)findMostRecentUiItem(CONTAINER); + + if (p_parent_container != NULL) + { + p_parent_container->addChildItem(p_container); + } + else + { + mpData->addContainer(p_container); + } + + mUiItems.push_back(p_container); + + } + + + + //action element + else if (strcmp(node_name, "action") == 0) + { + Container* p_container = NULL; + p_container = (Container*)findMostRecentUiItem(CONTAINER); + + if (p_container != NULL) + { + Action* p_action = new Action(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("mfcid"); + attr = XMLString::transcode(attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + + int valueInt; + if (attr_tmpstr.compare("IDOK") == 0) { + valueInt = 1; + } else if (attr_tmpstr.compare("IDCANCEL") == 0) { + valueInt = 2; + } else { + string valueStr = CIniFile::GetValue(attr_tmpstr, "resources", getIniFilePath()); + CIniFile::string2int(valueStr.c_str(), valueInt); + } + p_action->setMfcId(valueInt); + + XMLString::release(&attr); + } + + //MEMORY LEAK VERIFIED + attr = NULL; + attr_name = XMLString::transcode("widget"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_action->setWidgetCategories(attr_tmpstr); + XMLString::release(&attr); + } + + //MEMORY LEAK VERIFIED + attr = NULL; + attr_name = XMLString::transcode("accelerator"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + //p_action->setKeyboardAccelerator(attr_tmpstr); + XMLString::release(&attr); + } + + //MEMORY LEAK VERIFIED + attr = NULL; + attr_name = XMLString::transcode("condition"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_action->setCondition(attr_tmpstr); + XMLString::release(&attr); + } + + if (mpRecentSwitch != NULL) + { + mpRecentSwitch->addAction(p_action); + } + else + { + p_container->addChildItem(p_action); + } + + mUiItems.push_back(p_action); + + } + + } + + //caption or description element + else if (strcmp(node_name, "caption") == 0 || + strcmp(node_name, "description") == 0 || + strcmp(node_name, "accelerator") == 0 || + strcmp(node_name, "mnemonic") == 0) + { + UiItem* p_item = NULL; + p_item = mUiItems.back(); + + if (p_item != NULL) + { + Label* p_label = new Label(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("mfcid"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + + int valueInt; + if (attr_tmpstr.compare("IDOK") == 0) { + valueInt = 1; + } else if (attr_tmpstr.compare("IDCANCEL") == 0) { + valueInt = 2; + } else { + string valueStr = CIniFile::GetValue(attr_tmpstr, "resources", getIniFilePath()); + CIniFile::string2int(valueStr.c_str(), valueInt); + } + p_label->setMfcId(valueInt); + + XMLString::release(&attr); + } + + //MEMORY LEAK VERIFIED + attr = NULL; + attr_name = XMLString::transcode("condition"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_label->setCondition(attr_tmpstr); + XMLString::release(&attr); + } + + if (strcmp(node_name, "caption") == 0) + { + p_label->setType(CAPTION); + + if (mpRecentSwitch != NULL && + mpRecentSwitch->getSwitchType() == CAPTIONSWITCH) + { + mpRecentSwitch->addLabel(p_label); + } + else + { + if (mpRecentLabelList != NULL) + { + mpRecentLabelList->addLabel(p_label); + } + else + { + p_item->setCaption(p_label); + } + } + } + else if (strcmp(node_name, "mnemonic") == 0 && p_item->getUiItemType() == ACTION) + { + p_label->setType(MNEMONIC); + if (mpRecentLabelList != NULL) + { + mpRecentLabelList->addLabel(p_label); + } + else + { + ((Action*)p_item)->setMnemonic(p_label); + } + } + else if (strcmp(node_name, "accelerator") == 0 && p_item->getUiItemType() == ACTION) + { + p_label->setType(ACCELERATOR); + if (mpRecentLabelList != NULL) + { + mpRecentLabelList->addLabel(p_label); + } + else + { + ((Action*)p_item)->setKeyboardAccelerator(p_label); + } + } + else if (strcmp(node_name, "accelerator") == 0 && p_item->getUiItemType() == CONTAINER) + { + p_label->setType(ACCELERATOR); + if (mpRecentLabelList != NULL) + { + mpRecentLabelList->addLabel(p_label); + } + else + { + ((Container*)p_item)->setKeyboardAccelerator(p_label); + } + } + else + { + p_label->setType(DESCRIPTION); + + if (mpRecentSwitch != NULL && + mpRecentSwitch->getSwitchType() == DESCRIPTIONSWITCH) + { + mpRecentSwitch->addLabel(p_label); + } + else + { + if (mpRecentLabelList != NULL) + { + mpRecentLabelList->addLabel(p_label); + } + else + { + p_item->setDescription(p_label); + } + } + } + + mpRecentLabel = p_label; + } + } + + //text element + else if (strcmp(node_name, "text") == 0) + { + if (mpRecentLabel != NULL && mpRecentPrompt == NULL) + { + TextNode* p_text = new TextNode(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("mnemonic"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_text->setMnemonic(attr_tmpstr); + XMLString::release(&attr); + } + + mpRecentTextNode = (amis::TextNode*)p_text; + + + TextAudioPair* p_pair = NULL; + p_pair = mpRecentLabel->getContents(); + + //if a text-audio pair hasn't been started for the current label + //then make one + if (p_pair == NULL) + { + p_pair = new TextAudioPair(); + mpRecentLabel->setContents(p_pair); + } + + p_pair->setText(p_text); + + mbFlag_GetChars = true; + } + //if there is no label open but there is a prompt open, then the + //text node should go on its last item, if exists + else if (mpRecentPrompt != NULL) + { + int sz = mpRecentPrompt->getNumberOfItems(); + if (sz > 0) + { + PromptItemBase* p_item = mpRecentPrompt->getItem(sz-1); + + if (p_item->getPromptItemType() == PROMPT_ITEM) + { + TextNode* p_text = new TextNode(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("mnemonic"); + attr = XMLString::transcode(attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_text->setMnemonic(attr_tmpstr); + XMLString::release(&attr); + } + + mpRecentTextNode = (amis::TextNode*)p_text; + + mbFlag_GetChars = true; + p_item->getContents()->setText(p_text); + } + } + } + else if (this->mbFlag_ProcessingPromptItemRefs == true) + { + int last_prompt_item = mpData->getNumPromptItems(); + if (last_prompt_item > 0) + { + PromptItem* p_item = NULL; + p_item = mpData->getPromptItem(last_prompt_item-1); + + if (p_item != NULL) + { + TextNode* p_text = new TextNode(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("mnemonic"); + attr = XMLString::transcode(attributes.getValue(attr_name)); + XMLString::release(&attr_name); + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_text->setMnemonic(attr_tmpstr); + XMLString::release(&attr); + } + + mpRecentTextNode = (amis::TextNode*)p_text; + + mbFlag_GetChars = true; + p_item->getContents()->setText(p_text); + } + } + } + } + + //audio element + else if (strcmp(node_name, "audio") == 0) + { + if (mpRecentLabel != NULL && mpRecentPrompt == NULL) + { + amis::AudioNode* p_audio = new amis::AudioNode(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("src"); + + attr = XMLString::transcode + (attributes.getValue(attr_name)); + + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_audio->setSrc(attr_tmpstr); + XMLString::release(&attr); + } + + TextAudioPair* p_pair = NULL; + p_pair = mpRecentLabel->getContents(); + + //if a text-audio pair hasn't been started for the current label + //then make one + if (p_pair == NULL) + { + p_pair = new TextAudioPair(); + mpRecentLabel->setContents(p_pair); + } + + p_pair->setAudio(p_audio); + } + + //if there is no label open but there is a prompt open, then the + //audio node should go on its last item, if exists + else if (mpRecentPrompt != NULL) + { + int sz = mpRecentPrompt->getNumberOfItems(); + if (sz > 0) + { + PromptItemBase* p_item = mpRecentPrompt->getItem(sz-1); + + if (p_item->getPromptItemType() == PROMPT_ITEM) + { + amis::AudioNode* p_audio = new amis::AudioNode(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("src"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_audio->setSrc(attr_tmpstr); + XMLString::release(&attr); + } + + + p_item->getContents()->setAudio(p_audio); + } + } + } + else if (this->mbFlag_ProcessingPromptItemRefs == true) + { + int last_prompt_item = mpData->getNumPromptItems(); + if (last_prompt_item > 0) + { + PromptItem* p_item = NULL; + p_item = mpData->getPromptItem(last_prompt_item-1); + + if (p_item != NULL) + { + amis::AudioNode* p_audio = new amis::AudioNode(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("src"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_audio->setSrc(attr_tmpstr); + XMLString::release(&attr); + } + + p_item->getContents()->setAudio(p_audio); + } + } + } + } + + //icon element + else if (strcmp(node_name, "icon") == 0) + { + Action* p_action = NULL; + p_action = (Action*)findMostRecentUiItem(ACTION); + + if (p_action != NULL) + { + ImageNode* p_image = new ImageNode(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("type"); + + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + if (strcmp(attr, "smallIcon") == 0) + { + p_image->setImageType(SMALL_ICON); + } + else if(strcmp(attr, "largeIcon") == 0) + { + p_image->setImageType(LARGE_ICON); + } + + XMLString::release(&attr); + } + + //MEMORY LEAK VERIFIED + attr = NULL; + attr_name = XMLString::transcode("src"); + + attr = XMLString::transcode + (attributes.getValue(attr_name)); + + XMLString::release(&attr_name); + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_image->setSrc(attr_tmpstr); + XMLString::release(&attr); + } + + + p_action->addImage(p_image); + } + } + + //dialog element + else if (strcmp(node_name, "dialog") == 0) + { + Dialog* p_dialog = new Dialog(); + + mUiItems.push_back(p_dialog); + + mpData->addDialog(p_dialog); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("mfcid"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + + int valueInt; + if (attr_tmpstr.compare("IDOK") == 0) { + valueInt = 1; + } else if (attr_tmpstr.compare("IDCANCEL") == 0) { + valueInt = 2; + } else { + string valueStr = CIniFile::GetValue(attr_tmpstr, "resources", getIniFilePath()); + CIniFile::string2int(valueStr.c_str(), valueInt); + } + p_dialog->setMfcId(valueInt); + + XMLString::release(&attr); + } + + //MEMORY LEAK VERIFIED + attr = NULL; + attr_name = XMLString::transcode("id"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_dialog->setId(attr_tmpstr); + XMLString::release(&attr); + } + + + } + else if (strcmp(node_name, "control") == 0) + { + + Dialog* p_dialog = NULL; + p_dialog = (Dialog*)findMostRecentUiItem(DIALOG); + + if (p_dialog != NULL) + { + DialogControl* p_dlg_control = new DialogControl(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("mfcid"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + + int valueInt; + if (attr_tmpstr.compare("IDOK") == 0) { + valueInt = 1; + } else if (attr_tmpstr.compare("IDCANCEL") == 0) { + valueInt = 2; + } else { + string valueStr = CIniFile::GetValue(attr_tmpstr, "resources", getIniFilePath()); + CIniFile::string2int(valueStr.c_str(), valueInt); + } + p_dlg_control->setMfcId(valueInt); + + + XMLString::release(&attr); + } + + //MEMORY LEAK VERIFIED + attr = NULL; + attr_name = XMLString::transcode("widget"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_dlg_control->setWidgetCategories(attr_tmpstr); + XMLString::release(&attr); + } + + //MEMORY LEAK VERIFIED + attr = NULL; + attr_name = XMLString::transcode("id"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_dlg_control->setId(attr_tmpstr); + XMLString::release(&attr); + } + + p_dialog->addChildControl(p_dlg_control); + + mUiItems.push_back(p_dlg_control); + } + + + } + else if (strcmp(node_name, "list") == 0) + { + LabelList* p_list = new LabelList(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("repeat"); + + attr = XMLString::transcode + (attributes.getValue(attr_name)); + + XMLString::release(&attr_name); + + if (attr != NULL) + { + if (strcmp(attr, "yes") == 0) + p_list->setRepeat(true); + else + p_list->setRepeat(false); + + XMLString::release(&attr); + } + + mpRecentLabelList = p_list; + + UiItem* p_item = NULL; + p_item = mUiItems.back(); + + if (p_item != NULL) + p_item->setLabelList(p_list); + } + else if (strcmp(node_name, "switch") == 0) + { + if (mUiItems.size() > 0) + { + Switch* p_switch = new Switch(); + mUiItems.back()->setSwitch(p_switch); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("element"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + if (attr != NULL) + { + if (strcmp(attr, "action") == 0) + p_switch->setSwitchType(ACTIONSWITCH); + else if (strcmp(attr, "caption") == 0) + p_switch->setSwitchType(CAPTIONSWITCH); + else if (strcmp(attr, "description") == 0) + p_switch->setSwitchType(DESCRIPTIONSWITCH); + + XMLString::release(&attr); + } + + mpRecentSwitch = p_switch; + } + } + else if (strcmp(node_name, "prompt") == 0) + { + Prompt* p_prompt = new Prompt(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("id"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_prompt->setId(attr_tmpstr); + XMLString::release(&attr); + } + + //MEMORY LEAK VERIFIED + attr = NULL; + attr_name = XMLString::transcode("type"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_prompt->setType(attr_tmpstr); + XMLString::release(&attr); + } + + this->mpRecentPrompt = p_prompt; + + //if we are processing a label, then the prompt belongs to it + if (mpRecentLabel != NULL) + { + mpRecentLabel->setPrompt(mpRecentPrompt); + } + else if (this->mbFlag_ProcessingGeneralPrompts == true) + { + mpData->addPrompt(mpRecentPrompt); + } + + //else it belongs to a dialog + else + { + Dialog* p_dlg = NULL; + p_dlg = (Dialog*)findMostRecentUiItem(DIALOG); + if (p_dlg != NULL) + { + p_dlg->addPrompt(mpRecentPrompt); + } + } + } + else if (strcmp(node_name, "promptVar") == 0) + { + if (mpRecentPrompt == NULL) + { + mpRecentPrompt = new Prompt(); + + //if we are processing a label, then the prompt belongs to it + if (mpRecentLabel != NULL) + { + mpRecentLabel->setPrompt(mpRecentPrompt); + } + } + + PromptVar* p_var = new PromptVar(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("name"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_var->setName(attr_tmpstr); + XMLString::release(&attr); + } + + //MEMORY LEAK VERIFIED + attr = NULL; + attr_name = XMLString::transcode("param"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_var->setParam(attr_tmpstr); + XMLString::release(&attr); + } + + + mpRecentPrompt->addItem(p_var); + } + else if (strcmp(node_name, "promptItem") == 0) + { + if (mpRecentPrompt == NULL && this->mbFlag_ProcessingPromptItemRefs == false) + { + mpRecentPrompt = new Prompt(); + //if we are processing a label, then the prompt belongs to it + if (mpRecentLabel != NULL) + { + mpRecentLabel->setPrompt(mpRecentPrompt); + } + } + + PromptItem* p_item = new PromptItem(); + + //MEMORY LEAK VERIFIED + char* attr = NULL; + XMLCh* attr_name = XMLString::transcode("refid"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_item->setRefId(attr_tmpstr); + XMLString::release(&attr); + + //add this to the temporary list of things that need to be resolved + mpData->addForResolution(p_item); + } + + //if there was no refid, then this promptItem will have child contents + if (attr == NULL) + { + TextAudioPair* p_pair = new TextAudioPair(); + p_item->setContents(p_pair); + } + + attr = NULL; + attr_name = XMLString::transcode("id"); + attr = XMLString::transcode + (attributes.getValue(attr_name)); + XMLString::release(&attr_name); + if (attr != NULL) + { + std::string attr_tmpstr; + attr_tmpstr.assign(attr); + p_item->setId(attr_tmpstr); + XMLString::release(&attr); + } + + //if we are not processing prompt item refs + //then mpRecentPrompt will exist (either from a prior iteration or + //created above in this else-if block + if (this->mbFlag_ProcessingPromptItemRefs == false) + { + mpRecentPrompt->addItem(p_item); + } + //otherwise, if we are processing the promptItemRefs section + //add it to the data tree + else + { + mpData->addPromptItem(p_item); + } + + } + else if (strcmp(node_name, "generalPrompts") == 0) + { + this->mbFlag_ProcessingGeneralPrompts = true; + } + else if (strcmp(node_name, "promptItemRefs") == 0) + { + this->mbFlag_ProcessingPromptItemRefs = true; + } + else + { + //not recognized + } + + + + XMLString::release(&node_name); +} + +//-------------------------------------------------- +//! (SAX Event) close this element +//-------------------------------------------------- +void DataReader::endElement( const XMLCh* const uri, + const XMLCh* const localname, + const XMLCh* const qname) +{ + //local variable + char* element_name = XMLString::transcode(qname); + + //if it's a ui item + if (strcmp (element_name, "container") == 0 || + strcmp(element_name, "action") == 0 || + strcmp(element_name, "dialog") == 0 || + strcmp(element_name, "control") == 0) + { + //pop it off the stack + mUiItems.pop_back(); + } + //if it was a TEXT or NOTE element, get the accumulated text string and put it on the node + else if (strcmp(element_name, "text") == 0 || + strcmp(element_name, "note") == 0) + { + if (mpRecentTextNode != NULL) + mpRecentTextNode->setTextString(mCollectedText); + + mCollectedText.erase(); + mbFlag_GetChars = false; + mpRecentTextNode = NULL; + } + + + else if(strcmp(element_name, "caption") == 0 || + strcmp(element_name, "description") == 0) + { + mpRecentLabel = NULL; + mpRecentPrompt = NULL; + } + + else if (strcmp(element_name, "switch") == 0) + { + mpRecentSwitch = NULL; + } + + else if(strcmp(element_name, "prompt") == 0) + { + mpRecentPrompt = NULL; + + } + else if (strcmp(element_name, "list") == 0) + { + mpRecentLabelList = NULL; + } + else if (strcmp(element_name, "generalPrompts") == 0) + { + this->mbFlag_ProcessingGeneralPrompts = false; + } + else if (strcmp(element_name, "promptItemRefs") == 0) + { + this->mbFlag_ProcessingPromptItemRefs = false; + } + + + XMLString::release(&element_name); + +} + +void DataReader::characters(const XMLCh *const chars, const unsigned int length) +{ + if (mbFlag_GetChars == true) + { + mCollectedText.append((wchar_t*)chars); + } + +} + +//------------------ +//xerces fatal error +void DataReader::fatalError(const SAXParseException& e) +{ + char* xerces_msg = NULL; + + xerces_msg = XMLString::transcode(e.getMessage()); + + mBuildErrorFlag = amis::PARSE_ERROR; + mBuildErrorMsg = "Fatal error while processing *" + mFilepath + + "* Xerces signalled: \"" + xerces_msg + "\""; + + XMLString::release(&xerces_msg); +} + +void DataReader::error(const SAXParseException& e) +{ + char* xerces_msg = NULL; + + xerces_msg = XMLString::transcode(e.getMessage()); + + mBuildErrorFlag = amis::PARSE_ERROR; + mBuildErrorMsg = "Error while processing *" + mFilepath + + "* Xerces signalled: \"" + xerces_msg + "\""; + + XMLString::release(&xerces_msg); +} + +void DataReader::warning(const SAXParseException& e) +{ + char* xerces_msg = NULL; + + xerces_msg = XMLString::transcode(e.getMessage()); + + mBuildErrorFlag = amis::PARSE_ERROR; + mBuildErrorMsg = "Warning while processing *" + mFilepath + + "* Xerces signalled: \"" + xerces_msg + "\""; + + XMLString::release(&xerces_msg); +} + +UiItem* DataReader::findMostRecentUiItem(UiItemType itemType) +{ + UiItem* p_item = NULL; + + for (int i=mUiItems.size()-1; i>=0; i--) + { + if (mUiItems[i]->getUiItemType() == itemType) + { + p_item = mUiItems[i]; + break; + } + } + + return p_item; +} + + +} \ No newline at end of file Added: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUiDataReader.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUiDataReader.h (rev 0) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUiDataReader.h 2007-10-14 13:34:13 UTC (rev 2197) @@ -0,0 +1,113 @@ +/* +AmisGtkGuiExe: AMIS executable module and primary UI +Copyright (C) 2004 DAISY for All Project + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef ACCESSIBLEUIDATAREADER_H +#define ACCESSIBLEUIDATAREADER_H + +//SYSTEM INCLUDES +#include <string> +#include <vector> + +//XERCES INCLUDES +#include <xercesc/sax2/DefaultHandler.hpp> + +#include "DataTree.h" +#include "UiItem.h" + + +#include "../AmisCore/include/Error.h" + +//NAMESPACES +XERCES_CPP_NAMESPACE_USE + +XERCES_CPP_NAMESPACE_BEGIN +class Attributes; +XERCES_CPP_NAMESPACE_END + +using namespace std; + + +namespace AccessibleUi +{ +class DataReader: public DefaultHandler +{ +public: + //!constructor + DataReader(); + + //!destructor + ~DataReader(); + + //MEMBER FUNCTIONS + //!set the file to be processed + amis::Error readFile(string, DataTree*); + + //Xerces SAX methods + //!start tag of an element + void startElement(const XMLCh* const, const XMLCh* const, const XMLCh* const, + const Attributes&); + //!end tag of an element + void endElement(const XMLCh* const, const XMLCh* const, const XMLCh* const); + //!character data + void characters(const XMLCh *const, const unsigned int); + //!parse fatal error + void fatalError(const SAXParseException&); + //!parse warning + void warning(const SAXParseException&); + //!parse error (non-fatal) + void error(const SAXParseException&); + + string getIniFilePath(); + void setAppPath(string appPath); + +private: + UiItem* findMostRecentUiItem(UiItemType); + + //MEMBER VARIABLES + DataTree* mpData; + + vector <UiItem*> mUiItems; + + string mFilepath; + + string mAppPath; + string mIniFilePath; + + Label* mpRecentLabel; + Switch* mpRecentSwitch; + amis::TextNode* mpRecentTextNode; + Prompt* mpRecentPrompt; + + //!build error + amis::ErrorCode mBuildErrorFlag; + //!build error message + string mBuildErrorMsg; + + bool mbFlag_GetChars; + wstring mCollectedText; + + LabelList* mpRecentLabelList; + + bool mbFlag_ProcessingGeneralPrompts; + bool mbFlag_ProcessingPromptItemRefs; + +}; + +}//end namespace AccessibleUi +#endif \ No newline at end of file Added: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.cpp 2007-10-14 13:34:13 UTC (rev 2197) @@ -0,0 +1,154 @@ +#include "Action.h" +#include <fstream> + +namespace AccessibleUi +{ +Action::Action() +{ + this->setUiItemType(ACTION); + mImages.empty(); + mAccelerator = NULL; + mMnemonic = NULL; +} +Action::~Action() +{ + ImageNode* p_image = NULL; + for (int i=mImages.size()-1; i>=0; i--) + { + p_image = mImages[i]; + mImages.pop_back(); + if (p_image != NULL) + delete p_image; + + p_image = NULL; + } + + +} +AccessibleUi::ImageNode* Action::getImage(ImageType type) +{ + ImageNode* p_node = NULL; + + for (int i=0; i<mImages.size(); i++) + { + if (mImages[i]->getImageType() == type) + { + p_node = mImages[i]; + break; + } + } + + return p_node; +} + +std::string Action::getWidgetCategories() +{ + return mWidgetCategories; +} +Label* Action::getKeyboardAccelerator() +{ + return mAccelerator; +} +Label* Action::getMnemonic() +{ + return mMnemonic; +} + +void Action::addImage(AccessibleUi::ImageNode* pNode) +{ + mImages.push_back(pNode); +} + +void Action::setWidgetCategories(std::string widgetCategories) +{ + this->mWidgetCategories.assign(widgetCategories); +} +void Action::setKeyboardAccelerator(Label* accelerator) +{ + this->mAccelerator = accelerator; +} +void Action::setMnemonic(Label* mnemonic) +{ + this->mMnemonic = mnemonic; +} + +void Action::setCondition(std::string rule) +{ + mCondition.assign(rule); +} + +std::string Action::getCondition() +{ + return mCondition; +} + +void Action::testPrint(std::string outfile, int numTabs) +{ + fstream out; + out.open(outfile.c_str(), ios::app | ios::out); + + int i=0; + int j=0; + + for (i=0; i<numTabs; i++){out<<"\t";} + out<<"Action"<<endl; + + for (i=0; i<numTabs+1; i++){out<<"\t";} + out<<"id = "<<this->getId()<<endl; + + for (i=0; i<numTabs+1; i++){out<<"\t";} + out<<"mfc id = "<<this->getMfcId()<<endl; + + for (i=0; i<numTabs+1; i++){out<<"\t";} + out<<"widget = "<<this->mWidgetCategories<<endl; + + for (i=0; i<numTabs+1; i++){out<<"\t";} + out<<"accelerator = "<<this->mAccelerator<<endl; + + for (i=0; i<numTabs+1; i++){out<<"\t";} + out<<"condition = "<<mCondition<<endl; + + for (i=0; i<numTabs+1; i++){out<<"\t";} + out<<"Images"<<endl; + + for (i=0; i<mImages.size(); i++) + { + for (j=0; j<numTabs+2; j++){out<<"\t";} + out<<"src = "<<mImages[i]->getSrc()<<endl; + + for (j=0; j<numTabs+2; j++){out<<"\t";} + out<<"type = "; + + if (mImages[i]->getImageType() == SMALL_ICON) + { + out<<"small icon"<<endl; + } + else + { + out<<"large icon"<<endl; + } + } + out.close(); + + Label* p_label = NULL; + p_label = this->getCaption(); + if (p_label!=NULL) + { + p_label->testPrint(outfile, numTabs+1); + } + + p_label = NULL; + p_label = this->getDescription(); + if (p_label != NULL) + { + p_label->testPrint(outfile, numTabs+1); + } + + LabelList* p_list = NULL; + p_list = this->getLabelList(); + if (p_list != NULL) + p_list->testPrint(outfile, numTabs + 1); + +} + +} //end namespace AccessibleUi \ No newline at end of file Added: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.h (rev 0) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.h 2007-10-14 13:34:13 UTC (rev 2197) @@ -0,0 +1,50 @@ +#ifndef ACTION_H +#define ACTION_H + +#include "UiMediaTypes.h" +#include "UiItem.h" + +namespace AccessibleUi +{ +class Action : public UiItem +{ +public: + Action(); + ~Action(); + AccessibleUi::ImageNode* getImage(ImageType); + + std::string getWidgetCategories(); + + Label* getMnemonic(); + Label* getKeyboardAccelerator(); + + std::string getCondition(); + + + void testPrint(std::string, int); + +protected: + void addImage(AccessibleUi::ImageNode*); + void setWidgetCategories(std::string); + + void setKeyboardAccelerator(Label*); + void setMnemonic(Label*); + + void setCondition(std::string); + +private: + std::vector<AccessibleUi::ImageNode*> mImages; + std::string mWidgetCategories; + + Label* mAccelerator; + Label* mMnemonic; + + std::string mCondition; + + + friend class DataReader; + +}; + +} +#endif \ No newline at end of file Added: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.cpp 2007-10-14 13:34:13 UTC (rev 2197) @@ -0,0 +1,138 @@ +#include "AudioPrompt.h" + + +//************ +// audio prompt component +//************* +AudioPromptComponent::AudioPromptComponent() +{ + mpMedia = NULL; +} + +AudioPromptComponent::~AudioPromptComponent() +{ + if (mpMedia != NULL) + { + delete mpMedia; + } + + this->mRuntimeValue.clear(); + this->mTextAlternative.clear(); + this->mRuntimeValue.clear(); +} + + + +//************ +// audio prompt +//************* +AudioPrompt::AudioPrompt() +{ + mStringResourceID = -1; +} + +AudioPrompt::~AudioPrompt() +{ + int sz_seq = mSequence.size(); + amis::MediaNode* p_media = NULL; + int i; + + AudioPromptComponent* p_pc = NULL; + + for (i = sz_seq -1; i >=0; i--) + { + p_pc = mSequence[i]; + + mSequence.pop_back(); + + delete p_pc; + } + + this->mName.empty(); + this->mSequence.clear(); +} + +//************ +// audio prompt collection +//************* +AudioPromptCol* AudioPromptCol::pinstance = 0; + +AudioPromptCol* AudioPromptCol::Instance() +{ + if (pinstance == 0) + { + pinstance = new AudioPromptCol; + } + + return pinstance; +} + +void AudioPromptCol::DestroyInstance() +{ + delete pinstance; +} + +AudioPromptCol::AudioPromptCol() +{ +} + +AudioPromptCol::~AudioPromptCol() +{ + cleanUpVector(); + +} + +void AudioPromptCol::clearAll() +{ + cleanUpVector(); +} + +void AudioPromptCol::cleanUpVector() +{ + int sz = mPrompts.size(); + + int i; + + AudioPrompt* p_prompt = NULL; + + for (i = sz -1; i >=0; i--) + { + p_prompt = mPrompts[i]; + + mPrompts.pop_back(); + + delete p_prompt; + + } +} + +void AudioPromptCol::addPrompt(AudioPrompt* pPrompt) +{ + mPrompts.push_back(pPrompt); +} + +AudioPrompt* AudioPromptCol::getPrompt(string promptName) +{ + //search for the macro in the collection + unsigned int i; + bool b_found = false; + + for (i=0; i<mPrompts.size(); i++) + { + if (mPrompts[i]->mName.compare(promptName) == 0) + { + b_found = true; + break; + } + } + + if (b_found == false) + { + return NULL; + } + else + { + return mPrompts[i]; + } + +} \ No newline at end of file Added: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.h (rev 0) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.h 2007-10-14 13:34:13 UTC (rev 2197) @@ -0,0 +1,95 @@ +#ifndef AUDIOPROMPT_H +#define AUDIOPROMPT_H + +#include <string> + +#include "../AmisCore/include/Media.h" + +//!prompt variable structure +/*! + A variable has three properties, a name, a source function, and + a runtime value, like "yellow" or "c:\file" +*/ + +class AudioPromptComponent +{ +public: + AudioPromptComponent(); + ~AudioPromptComponent(); + //!is this a variable? + bool mbIsVar; + //!name of the variable + std::string mVarName; + //!value of the variable as given by the source function + std::wstring mRuntimeValue; + //!a media object (if it's not a variable) + amis::MediaNode* mpMedia; + // Text alternative to the audio clip: can be used for TTS or braille. + std::wstring mTextAlternative; + + +}; + +//! prompt structure +/*! + a prompt has a name (like "dialog_intro"), a list of variables (described above), + and a sequence of items to be played. + \n\n + it could also just reference a single audio clip. +*/ +class AudioPrompt +{ +public: + AudioPrompt(); + ~AudioPrompt(); + + //!name of the prompt + std::string mName; + + int mStringResourceID; + + //!list of all actions + vector<AudioPromptComponent*> mSequence; + +}; + +//collection of audio prompts +class AudioPromptCol +{ +protected: + AudioPromptCol(); + +public: + static AudioPromptCol* Instance(); + void DestroyInstance(); + ~AudioPromptCol(); + + //!return a prompt based on its name + AudioPrompt* getPrompt(string); + + //!add a prompt to the collection + void addPrompt(AudioPrompt*); + + //!clear the collection + void clearAll(); + +public: + //!the source file path for the audio prompts XML file + std::string mFilePath; + +private: + //!clean up the collection of prompts + void cleanUpVector(); + + +private: + //!the collection of prompts + vector<AudioPrompt*> mPrompts; + +private: + static AudioPromptCol* pinstance; + + +}; + +#endif \ No newline at end of file Added: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.cpp 2007-10-14 13:34:13 UTC (rev 2197) @@ -0,0 +1,328 @@ +/* +AmisGuiMFC: AMIS executable module and primary UI +Copyright (C) 2004 DAISY for All Project + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/*! +This module was adapted to read audio prompts that are either a single clip +or made up of a sequence of clips and TTS renderings of variables +*/ + +//SYSTEM INCLUDES +#include <string> +#include <vector> + +#include "afxpriv.h" + +//PROJECT INCLUDES +#include <xercesc/util/XMLString.hpp> +#include <xercesc/sax2/Attributes.hpp> +#include <xercesc/sax/SAXParseException.hpp> +#include <xercesc/sax/SAXException.hpp> +#include <xercesc/sax/HandlerBase.hpp> + +#include <xercesc/util/PlatformUtils.hpp> +#include <xercesc/util/TransService.hpp> +#include <xercesc/sax2/SAX2XMLReader.hpp> +#include <xercesc/sax2/XMLReaderFactory.hpp> + +//LOCAL INCLUDES +#include "AudioPromptReader.h" + +using namespace std; + + +AudioPromptReader::AudioPromptReader() +{ + +} + +AudioPromptReader::~AudioPromptReader() +{ + +} + + +void AudioPromptReader::loadFile(string filepath) +{ + const char* cp_file = NULL; + char* xerces_msg = NULL; + SAX2XMLReader* parser = NULL; + + + cp_file = filepath.c_str(); + + //clear any existing data + AudioPromptCol::Instance()->clearAll(); + + AudioPromptCol::Instance()->mFilePath = filepath; + + //try-catch block for Xerces platform utilities + try + { + XMLPlatformUtils::Initialize(); + } + catch (const XMLException& toCatch) + { + xerces_msg = XMLString::transcode(toCatch.getMessage()); //DANIEL MEMORY LEAK VERIFIED + // cout<<"Xerces said: "<<xerces_msg<<endl; + XMLString::release(&xerces_msg); //DANIEL MEMORY LEAK VERIFIED + return; + } + + //assuming we've made it this far, create a new parser + parser = XMLReaderFactory::createXMLReader(); + + //set these parser features to turn off DTD loading and validation + parser->setFeature(XMLUni::fgXercesLoadExternalDTD, false); + parser->setFeature(XMLUni::fgSAX2CoreValidation, false); + + + //try-catch block for Xerces parsing + try + { + parser->setContentHandler(this); + parser->setErrorHandler(this); + //parser begins fileparse. expect SAX Events soon. + parser->parse(cp_file); + } + catch (const XMLException& toCatch) + { + xerces_msg = XMLString::transcode(toCatch.getMessage()); //DANIEL MEMORY LEAK VERIFIED + //cout<<"Xerces said: "<<xerces_msg<<endl; + XMLString::release(&xerces_msg); //DANIEL MEMORY LEAK VERIFIED + //terminate the platform utilities + delete parser; + XMLPlatformUtils::Terminate(); + return; + } + + //we're done with the parser so delete it and terminate the XML platform utilities + delete parser; + XMLPlatformUtils::Terminate(); +} + +//-------------------------------------------------- +//! (SAX Event) analyze the element type and build a gui +//-------------------------------------------------- +void AudioPromptReader::startElement(const XMLCh* const uri, + const XMLCh* const localname, + const XMLCh* const qname, + const Attributes& attributes) +{ + + USES_CONVERSION; + + //local variables + char* element_name = NULL; + string tmp_string; + + //get the element name as a string + element_name = XMLString::transcode(qname); //DANIEL MEMORY LEAK VERIFIED + + if (strcmp(element_name, "prompt") == 0) + { + mpCurrentPrompt = new AudioPrompt(); + + XMLCh* txt_NAME = XMLString::transcode("name"); //DANIEL MEMORY LEAK VERIFIED + char* name = XMLString::transcode(attributes.getValue(txt_NAME)); //DANIEL MEMORY LEAK VERIFIED + XMLString::release(&txt_NAME); //DANIEL MEMORY LEAK VERIFIED + + mpCurrentPrompt->mName.assign(name); + XMLString::release(&name); //DANIEL MEMORY LEAK VERIFIED + } + + else if(strcmp(element_name, "var")==0) + { + AudioPromptComponent* p_prompt_var = NULL; + p_prompt_var = new AudioPromptComponent; + + + XMLCh* txt_NAME = XMLString::transcode("name"); //DANIEL MEMORY LEAK VERIFIED + char* name = XMLString::transcode(attributes.getValue(txt_NAME)); //DANIEL MEMORY LEAK VERIFIED + XMLString::release(&txt_NAME); //DANIEL MEMORY LEAK VERIFIED + + p_prompt_var->mVarName.assign(name); + XMLString::release(&name); //DANIEL MEMORY LEAK VERIFIED + + p_prompt_var->mRuntimeValue = _T(""); + p_prompt_var->mbIsVar = true; + + p_prompt_var->mTextAlternative = _T(""); + + mpCurrentPrompt->mSequence.push_back(p_prompt_var); + } + + + else if (strcmp(element_name, "audio") == 0) + { + amis::AudioNode* p_audio = NULL; + p_audio = new amis::AudioNode(); + + AudioPromptComponent* p_pc = NULL; + p_pc = new AudioPromptComponent; + + char* src = NULL; + XMLCh* txt_SRC = XMLString::transcode("src"); //DANIEL MEMORY LEAK VERIFIED + src = XMLString::transcode(attributes.getValue(txt_SRC)); //DANIEL MEMORY LEAK VERIFIED + XMLString::release(&txt_SRC); //DANIEL MEMORY LEAK VERIFIED + + char* clipBegin = NULL; + XMLCh* txt_CLIPBEGIN = XMLString::transcode("clipBegin"); //DANIEL MEMORY LEAK VERIFIED + clipBegin = XMLString::transcode(a... [truncated message content] |
From: <dan...@us...> - 2007-10-18 15:08:16
|
Revision: 2206 http://amis.svn.sourceforge.net/amis/?rev=2206&view=rev Author: daniel_weck Date: 2007-10-18 08:08:14 -0700 (Thu, 18 Oct 2007) Log Message: ----------- - Daniel WECK * Removed unused codec (ThirdPartyAudio) * Moved mffmTimeCode inside AmisAudio Modified Paths: -------------- branches/amis3/AmisAudio/AmisAudio.cpp branches/amis3/AmisAudio/AmisAudio.h branches/amis3/AmisAudio/AmisAudio.vcproj Added Paths: ----------- branches/amis3/AmisAudio/mffmTimeCode/ branches/amis3/AmisAudio/mffmTimeCode/SmilTimeCode.H branches/amis3/AmisAudio/mffmTimeCode/counter.H branches/amis3/AmisAudio/mffmTimeCode/field.H branches/amis3/AmisAudio/mffmTimeCode/masterCounter.H branches/amis3/AmisAudio/mffmTimeCode/masterCounterArray.H branches/amis3/AmisAudio/mffmTimeCode/timeCode.H branches/amis3/AmisAudio/mffmTimeCode/win32fix.H Removed Paths: ------------- branches/amis3/3rdPartyAudio/ branches/amis3/mffmTimeCode/ Modified: branches/amis3/AmisAudio/AmisAudio.cpp =================================================================== --- branches/amis3/AmisAudio/AmisAudio.cpp 2007-10-18 15:02:10 UTC (rev 2205) +++ branches/amis3/AmisAudio/AmisAudio.cpp 2007-10-18 15:08:14 UTC (rev 2206) @@ -33,7 +33,7 @@ #include <process.h> -#include "win32Fix.H" +//#include "win32Fix.H" //#include "../AmisGuiMFC/Brain/Preferences.h" Modified: branches/amis3/AmisAudio/AmisAudio.h =================================================================== --- branches/amis3/AmisAudio/AmisAudio.h 2007-10-18 15:02:10 UTC (rev 2205) +++ branches/amis3/AmisAudio/AmisAudio.h 2007-10-18 15:08:14 UTC (rev 2206) @@ -46,7 +46,7 @@ //#include "StdAfx.h" #include <windows.h> -#include "smilTimeCode.H" +#include "./mffmTimeCode/smilTimeCode.H" //for message sending ... typedef void (*sendMessageCallbackFn)(void *); Modified: branches/amis3/AmisAudio/AmisAudio.vcproj =================================================================== --- branches/amis3/AmisAudio/AmisAudio.vcproj 2007-10-18 15:02:10 UTC (rev 2205) +++ branches/amis3/AmisAudio/AmisAudio.vcproj 2007-10-18 15:08:14 UTC (rev 2206) @@ -23,7 +23,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories=""../AmisGuiMFC2/include/";"../AmisCore/include/";"../3rdPartyAudio"; "../mffmTimeCode"" + AdditionalIncludeDirectories=""../AmisGuiMFC2/include/";"../AmisCore/include/"" PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_WINDOWS;_USRDLL;AMISAUDIO_EXPORTS" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -274,6 +274,9 @@ RelativePath="AmisAudio.h"> </File> <File + RelativePath=".\mffmTimeCode\counter.H"> + </File> + <File RelativePath=".\TPBReader2\dmp\dmp.h"> </File> <File @@ -283,21 +286,36 @@ RelativePath=".\TPBReader2\dmp\DmpPpg.h"> </File> <File + RelativePath=".\mffmTimeCode\field.H"> + </File> + <File RelativePath=".\TPBReader2\dmp\iTPBTS.h"> </File> <File + RelativePath=".\mffmTimeCode\masterCounter.H"> + </File> + <File + RelativePath=".\mffmTimeCode\masterCounterArray.H"> + </File> + <File RelativePath=".\TPBReader2\RegOcx.h"> </File> <File RelativePath=".\TPBReader2\dmp\Resource.h"> </File> <File + RelativePath=".\mffmTimeCode\SmilTimeCode.H"> + </File> + <File RelativePath="StdAfx.h"> </File> <File RelativePath=".\TPBReader2\dmp\StdAfxFIX.h"> </File> <File + RelativePath=".\mffmTimeCode\timeCode.H"> + </File> + <File RelativePath=".\TPBReader2\dmp\TransformSample.h"> </File> <File @@ -309,6 +327,9 @@ <File RelativePath=".\TPBReader2\dmp\VuppSample.h"> </File> + <File + RelativePath=".\mffmTimeCode\win32fix.H"> + </File> </Filter> <Filter Name="Resource Files" Added: branches/amis3/AmisAudio/mffmTimeCode/SmilTimeCode.H =================================================================== --- branches/amis3/AmisAudio/mffmTimeCode/SmilTimeCode.H (rev 0) +++ branches/amis3/AmisAudio/mffmTimeCode/SmilTimeCode.H 2007-10-18 15:08:14 UTC (rev 2206) @@ -0,0 +1,209 @@ +/* + mffm Time Code + Time Code for multimedia systems + + Copyright (C) 2000-2005 Matt R. Flax <fl...@ie...> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You have received a copy of the GNU Lesser General Public License + along with this library. +*/ +#ifndef SMILTIMECODE_H_ +#define SMILTIMECODE_H_ + +#define SMILTIMECODE_VERSION 0.0 + +#include "timeCode.H" +#include <strstream> +//#include "win32fix.H" + +//Begins the implementation of SMIL timing : +// http://www.w3.org/TR/2005/REC-SMIL2-20050107/smil-timing.html#Timing-LanguageDefinition + +//The array type is char so that it can contain a smil mark up of a time reference +#define ARRAYTYPE char +//There are four fields in smil ... hours, minutes, seconds and milliseconds +#define FIELDCOUNT 4 +//The master counter will not work with X under win32 so for portability, use no GUI - field +#define MASTERCOUNTERTYPE MasterCounter<field, FIELDCOUNT> +//The maximum field counts +#define MAX_HOURS 300 +#define MAX_MINUTES 60 +#define MAX_SECONDS 60 +#define MAX_MILLISECONDS 1000 + +#define DEFAULTBUFLEN 512 + +/** This class loads a TimeCode structure with the correct + beginning and end. A SMIL type of string is used as input for + both times + +*/ +class SmilTimeCode : public TimeCode<MASTERCOUNTERTYPE, ARRAYTYPE> { + + //This function performs the raw string to milliseconds conversion + //Input is a SMIL compliant string + //Output is a millisecond count. + int convertStrToTimeCode(char *strSMIL){ + //Step for conversion : + // Work out the time metric : this correcponds to the maximum specified time field + // Work out whether the last field is a fractional part and remember that info. + // Hold fields in an array 'counts' + // Load a master counter with appropriate millisecond count + // Return the master counter millisecond count + + //Find the metric and thus the end of the stream + //Form an array to hold the metric digit values + int startMetric=0; + + char * tempI; + if ((tempI=strstr(strSMIL,"ms"))!=NULL){ + //we are receiving milliseconds + tempI[0]='\0'; //Mark a new end to the string + startMetric=0; //Indicate the start metric + } else if ((tempI=strstr(strSMIL,"s"))!=NULL){ + //we are receiving seconds + tempI[0]='\0'; //Mark a new end to the string + startMetric=1; //Indicate the start metric + } else if ((tempI=strstr(strSMIL,"min"))!=NULL){ + //we are receiving minutes + tempI[0]='\0'; //Mark a new end to the string + startMetric=2; //Indicate the start metric + } else if ((tempI=strstr(strSMIL,"h"))!=NULL){ + //we are receiving hours + tempI[0]='\0'; //Mark a new end to the string + startMetric=3; //Indicate the start metric + } else { + //No specification of metric. + // Check number of ':' in the string + int cnt=0; + for (int i=0;i<strlen(strSMIL);i++){ + if (strSMIL[i]==':') + cnt++; + } + if (cnt==3)//We are using hours minutes seconds milliseconds + startMetric=3; + else if (cnt==2)//We are using hours minutes seconds + startMetric=3; + else if (cnt==1)//We are using minutes seconds + startMetric=2; + else //We are using seconds + startMetric=1; + } + + cout<<"startMetric="<<startMetric<<endl; + + //Make sure '.' is translated to ':' + float convertLastField=0; //Use this to force fractional conversion of the smallest field + if ((tempI=strstr(strSMIL,"."))!=NULL){ + convertLastField=atof(tempI); + tempI[0]=':'; + cout<<convertLastField<<endl; + } + //if (convertLastField) + // cout<<"Last field needs conversion"<<endl; + + //Form an array to hold values counts[4]={milliseconds, sec, min, hours} + int counts[4]={-1,-1,-1,-1}; + + //Fill up to the start metric with zeros + for (int i=FIELDCOUNT-1;i>startMetric;i--) + counts[i]=0; + + /* for (i=0;i<FIELDCOUNT;i++) + cout<<counts[i]<<'\t'; + cout<<endl; + */ + + int howMany, howManyNot, origStartMetric; //Indicates how many tokens (and non tokens) + parseTok:{ + howMany=howManyNot=0; + origStartMetric=startMetric; + + //Work out how many tokens to parse + istrstream buf(strSMIL); + char tempS[DEFAULTBUFLEN]; + while (buf.getline(tempS,DEFAULTBUFLEN,':')){//Fill the array from the end + if (strlen(tempS)){ //Guard against no first token e.g. .25 (meaning 0.25 seconds) + howMany++; + if (startMetric>=0) + counts[startMetric]=atoi(tempS); + //cout<<tempS<<'\t'<<counts[startMetric]<<endl;; + } else { + howManyNot++; + if (startMetric>=0) + counts[startMetric]=0; + } + startMetric--; + } + cout<<howMany<<" Fields"<<endl; + } + + if (origStartMetric+1<howMany){ + cout<<"metric (h,min,s or ms) doesn't match the number of fields, autocorrecting"<<endl; + startMetric=howMany-1; + goto parseTok; + } + + for (i=0;i<FIELDCOUNT;i++) + cout<<counts[i]<<'\t'; + cout<<endl; + + //Now load up the masterCounter + MASTERCOUNTERTYPE tempTime (128,MAX_HOURS,MAX_MINUTES,MAX_SECONDS,MAX_MILLISECONDS); + tempTime=0; + int factor=1,fractionalFactor=1;//Factor to multiply by + //tempTime.dump(); + for (i=0;i<FIELDCOUNT;i++){ + switch (i) { + case 0: factor=1; fractionalFactor*=MAX_MILLISECONDS; + break; + case 1: factor*=MAX_MILLISECONDS; fractionalFactor*=MAX_SECONDS; + break; + case 2: factor*=MAX_SECONDS; fractionalFactor*=MAX_MINUTES; + break; + case 3: factor*=MAX_MINUTES; break; + default: cout<<"SmilTimeCode::convertStrToTimeCode field count exceeded : Error 2"<<endl; break; + } + if (counts[i]>=0){ //Check that a token exists + if (convertLastField>0){ //We must use a fractional concept + //cout<<"fractional i="<<i<<" counts[i]="<<counts[i]<<" fractionalFactor = "<<fractionalFactor<<endl; + //char tempS[DEFAULTBUFLEN]; + //sprintf(tempS,"0.%d\0",counts[i]); + //tempTime+=atof(tempS)*fractionalFactor; + //cout<<"fractional i="<<i<<" convertLastField="<<convertLastField<<" fractionalFactor = "<<fractionalFactor<<endl; + tempTime+=convertLastField*(fractionalFactor+1); //Check this +1 : introduced to remove 1ms error e.g. 0.120 goes to 0.119 without this +1 + convertLastField=0; //Ensure it doesn't happen again. + } else //Regular update + tempTime+=counts[i]*factor; + } + } + + // tempTime.dump(); + + return tempTime.getCount(); + } + +public: + //The time code is restricted to MAX_INT hours, 60 minutes, 60 seconds and 1000 milliseconds + SmilTimeCode(char *SMILBegin, char *SMILCurrent, char *SMILEnd) : TimeCode<MASTERCOUNTERTYPE, ARRAYTYPE>(DEFAULTBUFLEN,MAX_HOURS,MAX_MINUTES,MAX_SECONDS,MAX_MILLISECONDS){ + //This constructor will fill in the time code for beginning, current time and end time + + //Set the end of time + //setFinish(convertStrToTimeCode(SMILEnd)); + this->end=convertStrToTimeCode(SMILEnd); + //Set the beginning of time + //setBeginning(convertStrToTimeCode(SMILBegin)); + this->start=convertStrToTimeCode(SMILBegin); + } +}; +#endif //SMILTIMECODE_H_ Added: branches/amis3/AmisAudio/mffmTimeCode/counter.H =================================================================== --- branches/amis3/AmisAudio/mffmTimeCode/counter.H (rev 0) +++ branches/amis3/AmisAudio/mffmTimeCode/counter.H 2007-10-18 15:08:14 UTC (rev 2206) @@ -0,0 +1,172 @@ +/* + mffm Time Code + Time Code for multimedia systems + + Copyright (C) 2000, 2001 Matt R. Flax <fl...@ie...> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You have received a copy of the GNU Lesser General Public License + along with this library. +*/ +#ifndef COUNTER_H_ +#define COUNTER_H_ + +//#include <iomanip.h> +#include <iostream> + +#ifndef MAXINT +#include "./win32fix.h" +#endif + +//#define C_DEBUG + +//#define CTYPE int +class counter { +protected: + inline void cond(void){ +#ifdef C_DEBUG + std::cout<<"counter::cond enter"<<std::endl; +#endif + if (minCount<(int)0.0) + std::cerr<<"Warning: min Count < 0 and may cause problems"<<std::endl; + if (maxCount<=minCount) + std::cerr<<"Warning: max Count <= min Count and may cause problems"<<std::endl; + if (maxCount==(int)0.0) + std::cerr<<"Warning: max Count = 0 and may cause problems"<<std::endl; + int temp=(int)0.0; + if (--temp>0){ + std::cerr<<"counter: You are using an unsigned type ... error ... exiting"<<std::endl; + exit(-1); + } +#ifdef C_DEBUG + std::cout<<"counter::cond exit"<<std::endl; +#endif + } + + inline void clean(void){ +#ifdef C_DEBUG + std::cout<<"counter::clean count = "<<count<<std::endl; +#endif + int tempCount=count-minCount, tempMaxCount=maxCount-minCount; + // std::cout<<tempCount<<'\t'<<tempMaxCount<<std::endl; + // if (count<0.0){ + // carry=count/maxCount-(int)1.0; + //count+=maxCount; + if (tempCount<0.0){ + carry=tempCount/tempMaxCount-(int)1.0; + tempCount+=tempMaxCount; + // std::cout<<carry<<'\t'<<count<<std::endl; + } + if (tempCount>=tempMaxCount){ + carry=tempCount/tempMaxCount; + tempCount%=tempMaxCount; + } + count=tempCount+minCount; + //std::cout<<"clean exit"<<std::endl; +#ifdef C_DEBUG + std::cout<<"counter::clean exit "<<count<<std::endl; +#endif + } + + int count, maxCount, minCount; + int carry; +public: + counter (){ +#ifdef C_DEBUG + std::cout<<"counter::counter()"<<std::endl; +#endif + maxCount=MAXINT; minCount=0; count=(int)0;carry=0; cond(); + + } + counter (int minc, int maxc){ +#ifdef C_DEBUG + std::cout<<"counter::counter(minc, maxc)"<<std::endl; +#endif + maxCount=maxc; minCount=minc; count=(int)0;carry=0; cond(); + } + counter (int minc, int c, int maxc){ +#ifdef C_DEBUG + std::cout<<"counter::counter(minc="<<minc<<", c="<<c<<", maxc="<<maxc<<")"<<std::endl; +#endif + // if (c<0.0) std::cout <<"counter: init vals must be >=0 ... this may cause a problem"<<std::endl; + count=c; maxCount=maxc; minCount=minc; carry=0; cond(); clean(); + } + + /// returns the current count + int getCount(void){return count;} + /// returns the maximum count + int getMaxCount(void){return maxCount;} + /// Sets the maximum count + int setMaxCount(counter mc){return setMaxCount(mc.count);} + int setMaxCount(int mc){ + if (count>mc) count=mc-1; + return maxCount=mc; + } + /// returns the minimum count + int getMinCount(void){return minCount;} + /// Sets the minimum count + int setMinCount(counter mc){return setMinCount(mc.count);} + int setMinCount(int mc){ +#ifdef C_DEBUG + std::cout<<"counter::setMinCount(mc="<<mc<<")"<<std::endl; +#endif + if (count<mc) count=mc; + return minCount=mc; + } + /// returns the carry + int getCarry(void){return carry;} + /// resets the carry to zero + void resetCarry(void){carry=0;} + + // Logic operators + char operator!=(counter& c) {return count != c.count;} + char operator!=(int& c) {return count != c;} + char operator==(counter& c) {return count == c.count;} + char operator==(int& c) {return count == c;} + char operator> (counter& c) {return count > c.count;} + char operator> (int& c) {return count > c;} + char operator>=(counter& c) {return count >= c.count;} + char operator>=(int& c) {return count >= c;} + char operator< (counter& c) {return count < c.count;} + char operator< (int& c) {return count < c;} + char operator<=(counter& c) {return count <= c.count;} + char operator<=(int& c) {return count <= c;} + + // Evaluational operators + counter& operator =(counter c){ + //std::cout<<"count::yoyo"<<std::endl; + count = c.count; clean(); return *this;} + counter& operator =(int c){ + //std::cout<<"count::yo "<<count<<std::endl; + count = c;clean(); return *this;} + counter& operator+=(counter c){count += c.count; clean(); return *this;} + counter& operator+=(int c){count += c; clean(); return *this;} + counter& operator-=(counter c){count -= c.count; clean(); return *this;} + counter& operator-=(int c){count -= c; clean(); return *this;} + counter& operator*=(counter c){count *= c.count; clean(); return *this;} + counter& operator*=(int c){count *= c; clean(); return *this;} + counter& operator/=(counter c){count /= c.count; clean(); return *this;} + counter& operator/=(int c){count /= c; clean(); return *this;} + + int operator+(counter& c){return count+c.count;} + int operator+(int c){return count+c;} + int operator-(counter& c){return count-c.count;} + int operator-(int c){return count-c;} + double operator*(counter& c){return (double)count*(double)c.count;} + double operator*(int c){return (double)count*(double)c;} + double operator/(counter& c){return (double)count/(double)c.count;} + double operator/(int c){return (double)count/(double)c;} + + friend std::ostream& operator <<(std::ostream& o, counter c) {o << c.count<<"\tcarry="<<c.carry<<"\tMinCount="<<c.minCount<<"\tMaxCount="<<c.maxCount; return o;} +}; +#endif //COUNTER_H_ + Added: branches/amis3/AmisAudio/mffmTimeCode/field.H =================================================================== --- branches/amis3/AmisAudio/mffmTimeCode/field.H (rev 0) +++ branches/amis3/AmisAudio/mffmTimeCode/field.H 2007-10-18 15:08:14 UTC (rev 2206) @@ -0,0 +1,108 @@ +/* + mffm Time Code + Time Code for multimedia systems + + Copyright (C) 2000, 2001 Matt R. Flax <fl...@ie...> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You have received a copy of the GNU Lesser General Public License + along with this library. +*/ +#ifndef FIELD_H_ +#define FIELD_H_ + +#include <math.h> + +#include "counter.H" + +//template <class FTYPE> +//#define FTYPE int +class field : public counter { + unsigned int digitCount; + + /// Sets the digit count and display array + void countDigits(void){ + // Work out the required digit count ... + double mVal=maxCount; + digitCount=0; + while (mVal>pow(10.0,(int) ++digitCount)-1.0); + // Set up the digit array ... + digits=NULL; + if (!(digits=new unsigned char[digitCount])){ + std::cerr <<"field: digit malloc error"<<std::endl; + exit(-1); + } + } + + /// Sets the digits array to the digit value of the counter + void syncDigits(void){ + //std::cout<<"syncdigits :: "<<std::endl; + if (count==maxCount) count=0; + int cnt = count; + register double temp; + for (int i=digitCount-1;i>=0;i--){ + temp=pow(10.0, i); + digits[i]=(char)((double)cnt/temp); + //std::cout<<(int)digits[i]<<std::endl; + cnt-=digits[i]*(int)temp; + } + } + +public: + unsigned char *digits; + + field(int minimumVal, int startVal, int maximumVal) : counter(minimumVal, startVal, maximumVal){ +//#if DEBUG > 1 +// std::cout<<"field::field(minimumVal, startVal, maximumVal)"<<std::endl; +//#endif + digits=NULL; + // Set up the digit array and count + countDigits(); + // Sync the digits with the counter value + syncDigits(); + } + + ~field(void){ +//#if DEBUG > 1 +// std::cout<<"field::~field"<<std::endl; +//#endif + // std::cout<<"~field: in"<<std::endl; + if (digits) delete [] digits; + // std::cout<<"~field: out"<<std::endl; + } + + // The following alter the counter and must be overloaded + field& operator =(const counter& f){counter::operator =(f); syncDigits(); return *this;} + field& operator =(const int f){ + // std::cout<<"equate"<<std::endl; +counter::operator =(f); +//std::cout<<"about to sync"<<std::endl; + syncDigits(); return *this;} + field& operator+=(const counter& f){counter::operator+=(f); syncDigits(); return *this;} + field& operator+=(const int& f){counter::operator+=(f); syncDigits(); return *this;} + field& operator-=(const counter& f){counter::operator-=(f); syncDigits(); return *this;} + field& operator-=(const int& f){counter::operator-=(f); syncDigits(); return *this;} + field& operator*=(const counter& f){counter::operator*=(f); syncDigits(); return *this;} + field& operator*=(const int& f){counter::operator*=(f); syncDigits(); return *this;} + field& operator/=(const counter& f){counter::operator/=(f); syncDigits(); return *this;} + field& operator/=(const int& f){counter::operator/=(f); syncDigits(); return *this;} + + friend std::ostream& operator <<(std::ostream& o, field& f) { + std::cout<<(counter)f<<":\t"; + for (int i=f.digitCount-1; i>=0; i--) + o << (long)f.digits[i]; + return o; + } + + int digitCnt(void){return digitCount;} +}; +#endif //FIELD_H_ Added: branches/amis3/AmisAudio/mffmTimeCode/masterCounter.H =================================================================== --- branches/amis3/AmisAudio/mffmTimeCode/masterCounter.H (rev 0) +++ branches/amis3/AmisAudio/mffmTimeCode/masterCounter.H 2007-10-18 15:08:14 UTC (rev 2206) @@ -0,0 +1,194 @@ +/* + mffm Time Code + Time Code for multimedia systems + + Copyright (C) 2000, 2001 Matt R. Flax <fl...@ie...> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You have received a copy of the GNU Lesser General Public License + along with this library. +*/ +#ifndef MASTERCOUNTER_H_ +#define MASTERCOUNTER_H_ + +#include <stdarg.h> +#include "field.H" + +//#define DEBUG_MC + +template <class FIELDTYPE, int FIELDCOUNT> +class MasterCounter : public counter { +protected: + FIELDTYPE **fields; +public: + int fieldCount(void){return FIELDCOUNT;} + + MasterCounter(int startVal, ...) : counter(0, startVal, 1){ +#ifdef DEBUG_MC + std::cout<<"MasterCounter::MasterCounter(startVal, ...)"<<std::endl; +#endif + int maxC=1; + + if (FIELDCOUNT){ + if (!(fields=new FIELDTYPE*[FIELDCOUNT])){ + std::cerr<<"MasterCounter: Out of memory error"<<std::endl; + exit(-1); + } + for (int i=0;i<FIELDCOUNT;i++) + fields[i]=NULL; + + va_list ap; + va_start(ap, startVal); + for (i=0;i<FIELDCOUNT;i++){ + int temp=va_arg(ap, int); + if (i==0) + maxC*=temp; + maxC*=temp; + if (!(fields[i]=new FIELDTYPE(0, 0,temp))){ + std::cerr<<"MasterCounter: Out of memory error 1"<<std::endl; + exit(-1); + } + } + va_end(ap); + setMaxCount(maxC); + updateFields(); + } +#ifdef DEBUG_MC + std::cout<<"MasterCounter::MasterCounter(startVal, ...) EXIT"<<std::endl; +#endif + } + + MasterCounter(void) : counter(0, 0, 1){ +#ifdef DEBUG_MC + std::cout<<"MasterCounter::MasterCounter()"<<std::endl; +#endif + if (FIELDCOUNT){ + fields=new FIELDTYPE*[FIELDCOUNT]; + if (!fields){ + std::cerr<<"MasterCounter: Out of memory error"<<std::endl; + exit(-1); + } + for (int i=0;i<FIELDCOUNT;i++) + fields[i]=NULL; + } + } + + void init(int c, ...){ +#ifdef DEBUG_MC + std::cout<<"MasterCount: init "<<c<<" ..."<<std::endl; +#endif + va_list ap; + va_start(ap, c); + init(c, ap); + va_end(ap); + } + + void init(int c, va_list& ap){ +#ifdef DEBUG_MC + std::cout<<"MasterCount: init "<<c<<std::endl; +#endif + count=c; + int maxC=1; + for (int i=0;i<FIELDCOUNT;i++){ + int temp=va_arg(ap, int); + maxC*=temp; + //std::cout<<i<<" after "<<temp<<'\t'<<maxC<<std::endl; + fields[i]=new FIELDTYPE(0,0,temp); + if (!fields[i]){ + std::cerr<<"MasterCounter: Out of memory error 1"<<std::endl; + exit(-1); + } + // std::cout<<FIELDCOUNT<< " looping"<<std::endl; + } + setMaxCount(maxC); + updateFields(); + } + + ~MasterCounter(void){ +#ifdef DEBUG_MC + std::cout<<"MasterCounter::~MasterCounter"<<std::endl; +#endif + if (fields) { + for (int i=0;i<FIELDCOUNT;i++){ + if (fields[i]) delete fields[i]; + fields[i]=NULL; + } + delete [] fields; + fields=NULL; + } + // std::cout<<"~MasterCounter: out"<<std::endl; + } + + /// Sets the minimum count + int setMinCount(counter mc){return setMinCount(mc.getCount());} + int setMinCount(int mc){ +#ifdef DEBUG_MC + std::cout<<"MasterCounter::setMinCount(mc="<<mc<<")"<<std::endl; +#endif + int temp=counter::setMinCount(mc); + updateFields(); + return temp; + } + + /// Sets the minimum count + int setMaxCount(counter mc){return setMaxCount(mc.getCount());} + int setMaxCount(int mc){ +#ifdef DEBUG_MC + std::cout<<"MasterCounter::setMaxCount(mc="<<mc<<")"<<std::endl; +#endif + int temp=counter::setMaxCount(mc); + updateFields(); + return temp; + } + + // syncs the field with the new counter value + void updateFields(void){ + //std::cout<<"masterCounter: updateFields"<<std::endl; + int temp=count, tempCarry; + for (int i=0;i<FIELDCOUNT;i++){ + //std::cout<<i<<std::endl; + int which =FIELDCOUNT-i-1; + tempCarry=temp%fields[which]->getMaxCount(); + temp=temp/fields[which]->getMaxCount(); + *fields[which]=(int)tempCarry; + } + //std::cout<<"masterCounter: updateFields EXIT"<<std::endl; + } + + // Logic operators + /* char operator==(counter& m) {return count == m.getCount();} + char operator!=(counter& m) {return count != m.getCount();} + char operator> (counter& m) {return count > m.getCount();} + char operator>=(counter& m) {return count >= m.getCount();} + char operator< (counter& m) {return count < m.getCount();} + char operator<=(counter& m) {return count <= m.getCount();} + */ + + // Evaluational operators + MasterCounter& operator =(counter c){counter::operator=(c); updateFields();return *this;} + MasterCounter& operator =(int c){counter::operator=(c);updateFields();return *this;} + MasterCounter& operator+=(counter c){counter::operator+=(c); updateFields();return *this;} + MasterCounter& operator+=(int c){counter::operator+=(c);updateFields();return *this;} + MasterCounter& operator-=(counter c){counter::operator-=(c); updateFields();return *this;} + MasterCounter& operator-=(int c){counter::operator-=(c); updateFields();return *this;} + MasterCounter& operator*=(counter c){counter::operator*=(c); updateFields();return *this;} + MasterCounter& operator*=(int c){counter::operator*=(c); updateFields();return *this;} + MasterCounter& operator/=(counter c){counter::operator/=(c); updateFields();return *this;} + MasterCounter& operator/=(int c){counter::operator/=(c); updateFields();return *this;} + + friend std::ostream& operator <<(std::ostream& o, MasterCounter<FIELDTYPE, FIELDCOUNT>& c) { + o << c.count<<"\tMinCount="<<c.minCount<<"\tcarry="<<c.carry<<"\tMaxCount="<<c.maxCount<<'\t'; + return o; + } +}; +#endif //MASTERCOUNTER_H_ + Added: branches/amis3/AmisAudio/mffmTimeCode/masterCounterArray.H =================================================================== --- branches/amis3/AmisAudio/mffmTimeCode/masterCounterArray.H (rev 0) +++ branches/amis3/AmisAudio/mffmTimeCode/masterCounterArray.H 2007-10-18 15:08:14 UTC (rev 2206) @@ -0,0 +1,163 @@ +/* + mffm Time Code + Time Code for multimedia systems + + Copyright (C) 2000, 2001 Matt R. Flax <fl...@ie...> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You have received a copy of the GNU Lesser General Public License + along with this library. +*/ +#ifndef MASTERCOUNTERARRAY_H_ +#define MASTERCOUNTERARRAY_H_ + +#include <stdarg.h> +//#include <sys/resource.h> +#include "field.H" + +//#define MCA_DEBUG + +template <class MASTERCOUNTERTYPE, class ARRAYTYPE> +class MasterCounterArray : public MASTERCOUNTERTYPE { + + /// The size in bytes of a single sample (multichannel size). i.e. 16 bit stereo => 4 bytes + int frameSize; + // double countToFrames, framesToCount; + +protected: + ARRAYTYPE *array; +public: + // double getFramesToCount(){return framesToCount;} + //double getCountToFrames(){return countToFrames;} + + int getFrameSize(){return frameSize;} + int setFrameSize(int fsz){ +#ifdef MCA_DEBUG + std::cout<<"MasterCounterArray::setFrameSize"<<std::endl; +#endif + //// Find the conversion from frames to count + // framesToCount=(double)frameCount/(double)rate; + //countToFrames=(double)rate/(double)frameCount; + + if (frameSize!=fsz){ + frameSize=fsz; + updateArray(); + } + return frameSize; + } + + /** Constructor, specifying a startValue for the array index and a + list of time code fields. + */ + MasterCounterArray(int startVal, ...) : MASTERCOUNTERTYPE(){ +#ifdef MCA_DEBUG + + std::cout<<"MasterCounterArray::MasterCounterArray(startVal="<<startVal<<", ...)"<<std::endl; +#endif + array=NULL; + frameSize=1; + va_list ap; + va_start(ap, startVal); + init(startVal, ap); + va_end(ap); + } + + /** Empty constructor, must use init to complete valid construction + */ + MasterCounterArray(void) : MASTERCOUNTERTYPE(){ +#ifdef MCA_DEBUG + std::cout<<"MasterCounterArray::MasterCounterArray()"<<std::endl; +#endif + array=NULL; + frameSize=1; + } + + /** Initialiser for the empty constructor + */ + void init(int c, ...){ +#ifdef MCA_DEBUG + std::cout<<"MasterCounterArray::init(startVal="<<c<<", ...)"<<std::endl; +#endif + va_list ap; + va_start(ap, c); + init(c, ap); + va_end(ap); + } + + /** second stage init, called by 'other' init function + */ + void init(int c, va_list& ap){ +#ifdef MCA_DEBUG + std::cout<<"MasterCounterArray::init(startVal="<<c<<", va_list)"<<std::endl; +#endif + //cout<<"c "<<c<<endl; + MASTERCOUNTERTYPE::init(c,ap); + //std::cout<<*this<<std::endl; + updateArray(); + } + + /** Deconstructor */ + ~MasterCounterArray(void){ +#ifdef MCA_DEBUG + std::cout<<"MasterCounterArray::~MasterCounterArray"<<std::endl; +#endif + if (array) delete [] array; + array=NULL; + // std::cout<<"MasterCounterArray::~MasterCounterArray exit"<<std::endl; + } + + void updateArray(){ +#ifdef MCA_DEBUG + std::cout<<"MasterCounterArray::updateArray - new size "<<getCount()*frameSize<<std::endl; +#endif + //std::cout<<"count "<<getCount()<<std::endl; + //std::cout<<"frameSize "<<frameSize<<std::endl; + if (array) delete [] array; + array=NULL; + // std::cout<<getCount()<<std::endl; + //Should limit the possible allocatable space here ... + /* struct rlimit limit; + getrlimit(RLIMIT_MEMLOCK , &limit); + std::cout<<"rlim_cur "<<limit.rlim_cur<<std::endl; + std::cout<<"rlim_max "<<limit.rlim_max<<std::endl; + */ + //cout<<"making array of size "<<this->getCount()*frameSize<<endl; + if (!(array=new ARRAYTYPE[this->getCount()*frameSize])){ + std::cout<<"MasterCounterArray: Out of memory"<<std::endl; + exit(-1); + } + //std::cout<<"MasterCounterArray::updateArray : array="<<array<<std::endl; + } + + void zeroArray(void){ + //Check whether this needs frameSize multiplier. + bzero(array, this->getCount()*sizeof(ARRAYTYPE)); + } + + // Evaluational operators + MasterCounterArray& operator =(counter c){counter::operator=(c); updateArray();return *this;} + MasterCounterArray& operator =(int c){counter::operator=(c);updateArray();return *this;} + MasterCounterArray& operator+=(counter c){counter::operator+=(c); updateArray();return *this;} + MasterCounterArray& operator+=(int c){counter::operator+=(c); updateArray();return *this;} + MasterCounterArray& operator-=(counter c){counter::operator-=(c); updateArray();return *this;} + MasterCounterArray& operator-=(int c){counter::operator-=(c); updateArray();return *this;} + MasterCounterArray& operator*=(counter c){counter::operator*=(c); updateArray();return *this;} + MasterCounterArray& operator*=(int c){counter::operator*=(c); updateArray();return *this;} + MasterCounterArray& operator/=(counter c){counter::operator/=(c); updateArray();return *this;} + MasterCounterArray& operator/=(int c){counter::operator/=(c); updateArray();return *this;} + + // ARRAYTYPE& operator[](int i){return array[i];} + ARRAYTYPE* getDataPtr(void){return array;} + ARRAYTYPE& operator[](int i){return array[i];} + // ARRAYTYPE& operator[]=(int i, ARRAYTYPE val){return array[i]=val;} +}; +#endif //MASTERCOUNTERARRAY_H_ Added: branches/amis3/AmisAudio/mffmTimeCode/timeCode.H =================================================================== --- branches/amis3/AmisAudio/mffmTimeCode/timeCode.H (rev 0) +++ branches/amis3/AmisAudio/mffmTimeCode/timeCode.H 2007-10-18 15:08:14 UTC (rev 2206) @@ -0,0 +1,220 @@ +/* + mffm Time Code + Time Code for multimedia systems + + Copyright (C) 2000, 2001 Matt R. Flax <fl...@ie...> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You have received a copy of the GNU Lesser General Public License + along with this library. +*/ +#ifndef TIMECODE_H_ +#define TIMECODE_H_ + +#include <stdarg.h> +#include "masterCounter.H" +#include "masterCounterArray.H" + +/** Time Code, inherits the current code + */ +template <class MASTERCOUNTERTYPE, class ARRAYTYPE> +class TimeCode : public MASTERCOUNTERTYPE { + int beginning, finish; +protected: + MASTERCOUNTERTYPE start, end; +public: + // The window count + MasterCounterArray<MASTERCOUNTERTYPE, ARRAYTYPE> *window; + //void zeroArray(void) {window->zeroArray();} + //ARRAYTYPE* getDataPtr(void){return window->getDataPtr();} + // ARRAYTYPE& operator[](int i){return window[i];} + + TimeCode(int startVal, ...) : MASTERCOUNTERTYPE (){ +//#if DEBUG > 1 +// std::cout<<"TimeCode::TimeCode(startVal, ...)"<<std::endl; +//#endif + window=NULL; + va_list ap, ap1, ap2, ap3; + va_start(ap, startVal); + va_start(ap1, startVal); + va_start(ap2, startVal); + va_start(ap3, startVal); + init(startVal, ap, ap1, ap2, ap3); + va_end(ap); + va_end(ap1); + va_end(ap2); + va_end(ap3); + } + + TimeCode(void) : MASTERCOUNTERTYPE (){ +//#if DEBUG > 1 +// std::cout<<"TimeCode::TimeCode()"<<std::endl; +//#endif + window=NULL; + } + + void init(int startVal, ...) { + va_list ap, ap1, ap2, ap3; + va_start(ap, startVal); + va_start(ap1, startVal); + va_start(ap2, startVal); + va_start(ap3, startVal); + init(startVal, ap, ap1, ap2, ap3); + va_end(ap); + va_end(ap1); + va_end(ap2); + va_end(ap3); + } + + void init(int c, va_list& ap, va_list& apStart, va_list& apEnd, va_list& apWindow){ +//#if DEBUG > 1 +// std::cout<<"TimeCode::init"<<std::endl; +//#endif + beginning=0; + start.init(beginning, apStart); + + MASTERCOUNTERTYPE::init(c, ap); + finish=this->getMaxCount(); + + // Ensure end points to the last window + end.init(finish-1, apEnd); + + if (window) delete window; + if (!(window=new MasterCounterArray<MASTERCOUNTERTYPE, ARRAYTYPE>)) std::cerr <<"TimeCode::init : window malloc error"<<std::endl; + window->init(this->fields[this->fieldCount()-1]->getMaxCount(), apWindow); + } + + ~TimeCode(void){ +//#if DEBUG > 1 +// std::cout<<"TimeCode::~TimeCode"<<std::endl; +//#endif + if (window) delete window; + } + + int getBeginning(void){return beginning;} + void setBeginning(counter c){setBeginning(c.getCount());} + void setBeginning(int c){ + if (c>=finish) + c=finish-1; + beginning=c; + setStart(beginning); + } + + void nothing(){} + + int getStart(){return start.getCount();}; + void setStart(counter c){setStart(c.getCount());} + void setStart(int c){ +//#if DEBUG > 1 +// std::cout<<"TimeCode::setStart "<<c<<std::endl; +//#endif + //Check that the beginning is not underrun + // the end minimum is not before the start + // the end minimum matches the start point + if (c<beginning) c=beginning; + if (c>end.getCount()) c=end.getCount(); + // if (c<end->getMinCount()) end->setMinCount(c); + end.setMinCount(c); + nothing(); + start.MASTERCOUNTERTYPE::operator=(c);// set the start point + //start=c;// set the start point + // std::cout<<start<<std::endl; + setMinCount(start); // reset the minimum of the current time + } + + int getEnd(){return end.getCount();}; + void setEnd(counter c){setEnd(c.getCount());} + void setEnd(int c){ +//#if DEBUG > 1 +// std::cout<<"TimeCode::setEnd "<<c<<std::endl; +//#endif + + //Check that the finish is not overrun + // the start maximum is not after the end + // the start maximum matches the end point + if (c>finish) c=finish; + if (c<start.getCount()) c=start.getCount(); + + start.setMaxCount(c); + // set the end point + end.MASTERCOUNTERTYPE::operator=(c); + setMaxCount(end); // reset the maximum of the current time + } + + int getFinish(void){return finish;} + void setFinish(counter c){setEnd(c.getCount());} + void setFinish(int c){ + finish=c; + end.setMaxCount(c); + window->setMaxCount(c); + } + + /** this function will apply a type II filter using the masterArray as the + output. + Filter coefficients are specified by the arrays a and b, with their + coefficient counts represented by aCnt and bCnt. + The input is pointed to by 'input'. The current location must be pointed + to and there must be at least 'aCnt' elements in the array preceeding + the pointer. + This function will only process one output at a time. + Coefficient notes : + a[0]=1.0; + input : + input The current value of the input signal + aCnt the number of denomiator coefficients + a the denominator (pole polynomial) coefficients + bCnt the number of numerator coefficients + b the numerator (zero polynomial) coefficients + memory the filter memory of dimension max(aCnt,bCnt) + */ + inline void filter(ARRAYTYPE input, const int aCnt, const double *a, const int bCnt, const double *b, double *memory){ + int j, loc=this->getCount(); + + //cout<<a<<'\t'<<b<<'\t'<<memory<<'\n'; + //cout<<aCnt<<'\t'<<bCnt<<'\n'; + + // Firstly calculate the output + (*window)[loc]=input*b[0]+memory[0]; + //cout<<(*window)[loc]<<'\t'<<input<<'\t'<<b[0]<<'\t'<<memory[0]<<'\n'; + // Manipulate the filter memory + for (j=1;j<aCnt & j<bCnt; j++){ + memory[j-1]=memory[j]+input*b[j]-(*window)[loc]*a[j]; + //cout<<memory[j-1]<<'\t'<<memory[j]<<'\t'<<input<<'\t'<<b[j]<<'\t'<<(*window)[loc]<<'\t'<<a[j]<<'\n'; + } + + //if (bCnt>aCnt) + for (j;j<bCnt;j++){ + memory[j-1]=memory[j]+input*b[j]; + //cout<<"take 2 b: "<<memory[j-1]<<'\t'<<memory[j]<<'\t'<<input<<'\t'<<b[j]<<'\n'; + } + //else + for (j;j<aCnt;j++){ + memory[j-1]=memory[j]-(*window)[loc]*a[j]; + //cout<<"take 2 a "<<memory[j-1]<<'\t'<<memory[j]<<'\t'<<(*window)[loc]<<'\t'<<a[j]<<'\n'; + } + //cout<<'\n'; + } + + TimeCode& operator =(TimeCode& c){counter::operator=(c);return *this;} + TimeCode& operator =(counter c){counter::operator=(c);return *this;} + TimeCode& operator =(int c){counter::operator=(c);return *this;} + + friend std::ostream& operator <<(std::ostream& o, TimeCode& tc) { + o<<"TimeCode: Beginning: "<<tc.beginning<<" Finish: "<<tc.finish<<'\n'; + o<<"Start: "<<tc.start<<'\n'; + o<<"Current: "<<(MASTERCOUNTERTYPE&)tc<<'\n'; + o<<"End: "<<tc.end<<'\n'; + o<<"Window Count: "<<*tc.window<<'\n'; + return o; + } +}; +#endif //TIMECODE_H_ Added: branches/amis3/AmisAudio/mffmTimeCode/win32fix.H =================================================================== --- branches/amis3/AmisAudio/mffmTimeCode/win32fix.H (rev 0) +++ branches/amis3/AmisAudio/mffmTimeCode/win32fix.H 2007-10-18 15:08:14 UTC (rev 2206) @@ -0,0 +1,74 @@ +/* Copyright 2001 Matt Flax <fl...@ie...> + This file is part of MFFM Time Scale Modification for Audio. + + MFFM Time Scale Modification for Audio is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + MFFM Time Scale Modification for Audio is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You have received a copy of the GNU General Public License + along with MFFM Time Scale Modification for Audio + */ +#ifndef WIN32FIX_H_ +#define WIN32FIX_H_ + +// DLLs in Windows should use the standard calling convention +#ifndef ADR_CALL + #if defined(WIN32) || defined(_WIN32) + #define ADR_CALL __stdcall + #else + #define ADR_CALL + #endif +#endif + +// Export functions from the DLL +#ifndef ADR_DECL +# if defined(WIN32) || defined(_WIN32) +# ifdef LIBFFT_EXPORTS +# define ADR_DECL __declspec(dllexport) +# else +# define ADR_DECL __declspec(dllimport) +# endif +# else +# define ADR_DECL +# endif +#endif + +#define ADR_FUNCTION(ret) extern "C" ADR_DECL ret ADR_CALL + +#ifndef round +#define round(a) roundD(a) +#endif + +#ifndef bzero +#define bzero(a,c) memset(a,0,c) +#endif + +#ifndef remainder +#define remainder(a,b) fmod(a,b) +#endif + +#ifndef MAXDOUBLE +//#include <limits> +//#define MAXDOUBLE (numeric_limits<double>::max()) +//#define MAXDOUBLE DBL_MAX +#define MAXDOUBLE 1e308 +#endif + +#ifndef MAXINT +//#include <limits> +//#define MAXINT (numeric_limits<int>::max()) +#define MAXINT INT_MAX +#endif + +#ifndef cerr +#include <iostream> +using namespace std; +//#define cerr std:cout +#endif +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-10-18 18:33:03
|
Revision: 2211 http://amis.svn.sourceforge.net/amis/?rev=2211&view=rev Author: daniel_weck Date: 2007-10-18 11:33:06 -0700 (Thu, 18 Oct 2007) Log Message: ----------- - Daniel WECK * Added new namespaces: amis::gui::spoken amis::audio amis::tts * Harmonized callback functions for TTS and AmisAudio Modified Paths: -------------- branches/amis3/AmisAudio/AmisAudio.cpp branches/amis3/AmisAudio/AmisAudio.h branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUiDataReader.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/LabelList.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/LabelList.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.h branches/amis3/AmisGuiMFC2/PreTranslateMessageHandler.h branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp Modified: branches/amis3/AmisAudio/AmisAudio.cpp =================================================================== --- branches/amis3/AmisAudio/AmisAudio.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisAudio/AmisAudio.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -32,6 +32,8 @@ #include "AmisAudio.h" #include <process.h> + +using namespace amis::audio; //#include "win32Fix.H" Modified: branches/amis3/AmisAudio/AmisAudio.h =================================================================== --- branches/amis3/AmisAudio/AmisAudio.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisAudio/AmisAudio.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -49,7 +49,7 @@ #include "./mffmTimeCode/smilTimeCode.H" //for message sending ... -typedef void (*sendMessageCallbackFn)(void *); +typedef void (*sendMessageCallbackFn)(); //using namespace std; @@ -62,6 +62,10 @@ /** This class is exported from the AmisAudio.dll*/ +namespace amis +{ +namespace audio +{ class AMISAUDIO_API AmisAudio { protected: @@ -117,8 +121,9 @@ void adjustVolume(int); void adjustRate(double); - typedef void (*sendMessageCallbackFn)(void *); + typedef void (*sendMessageCallbackFn)(void); void setCallback(sendMessageCallbackFn pFunction); + private: void ShowStatePrompt(); @@ -140,5 +145,7 @@ //CDmpApp* pDmpApp; }; +} +} #endif \ No newline at end of file Modified: branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -1163,7 +1163,7 @@ stopPosition = 0; //AudioSequencePlayer::Instance()->ClipAudioEndNotify(); - sendMessageCallback(0); + sendMessageCallback(); //SetEndOfStream(true); // pause(); Modified: branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -56,7 +56,7 @@ public: CDmpCtrl(); - typedef void (*sendMessageCallbackFn)(void *); + typedef void (*sendMessageCallbackFn)(void); sendMessageCallbackFn sendMessageCallback; void setCallback(sendMessageCallbackFn pFunction); Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -29,8 +29,8 @@ //#include "../../AmisCommon/AmisCommon.h" //#include "../Brain/trim.h" -namespace AccessibleUi -{ +using namespace amis::gui::spoken; + DataReader::DataReader() { mUiItems.empty(); @@ -63,7 +63,7 @@ //-------------- //start parsing the file and filling in the data model (passed in as pData) -amis::Error DataReader::readFile(string inputFilepath, AccessibleUi::DataTree* pData) +amis::Error DataReader::readFile(string inputFilepath, DataTree* pData) { amis::Error err; @@ -1218,5 +1218,3 @@ return p_item; } - -} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUiDataReader.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUiDataReader.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUiDataReader.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -43,8 +43,13 @@ using namespace std; -namespace AccessibleUi + +namespace amis { +namespace gui +{ +namespace spoken +{ class DataReader: public DefaultHandler { public: @@ -109,5 +114,6 @@ }; -}//end namespace AccessibleUi +}}} + #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -1,8 +1,8 @@ #include "Action.h" #include <fstream> -namespace AccessibleUi -{ +using namespace amis::gui::spoken; + Action::Action() { this->setUiItemType(ACTION); @@ -25,7 +25,7 @@ } -AccessibleUi::ImageNode* Action::getImage(ImageType type) +ImageNode* Action::getImage(ImageType type) { ImageNode* p_node = NULL; @@ -54,7 +54,7 @@ return mMnemonic; } -void Action::addImage(AccessibleUi::ImageNode* pNode) +void Action::addImage(ImageNode* pNode) { mImages.push_back(pNode); } @@ -150,5 +150,3 @@ p_list->testPrint(outfile, numTabs + 1); } - -} //end namespace AccessibleUi \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -4,14 +4,19 @@ #include "UiMediaTypes.h" #include "UiItem.h" -namespace AccessibleUi + +namespace amis { +namespace gui +{ +namespace spoken +{ class Action : public UiItem { public: Action(); ~Action(); - AccessibleUi::ImageNode* getImage(ImageType); + ImageNode* getImage(ImageType); std::string getWidgetCategories(); @@ -24,7 +29,7 @@ void testPrint(std::string, int); protected: - void addImage(AccessibleUi::ImageNode*); + void addImage(ImageNode*); void setWidgetCategories(std::string); void setKeyboardAccelerator(Label*); @@ -33,7 +38,7 @@ void setCondition(std::string); private: - std::vector<AccessibleUi::ImageNode*> mImages; + std::vector<ImageNode*> mImages; std::string mWidgetCategories; Label* mAccelerator; @@ -46,5 +51,5 @@ }; -} +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -1,5 +1,6 @@ #include "AudioPrompt.h" +using namespace amis::gui::spoken; //************ // audio prompt component Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -11,6 +11,13 @@ a runtime value, like "yellow" or "c:\file" */ +namespace amis +{ +namespace gui +{ +namespace spoken +{ + class AudioPromptComponent { public: @@ -91,5 +98,6 @@ }; +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -44,8 +44,8 @@ #include "AudioPromptReader.h" using namespace std; +using namespace amis::gui::spoken; - AudioPromptReader::AudioPromptReader() { Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -41,6 +41,12 @@ using namespace std; +namespace amis +{ +namespace gui +{ +namespace spoken +{ //!Get an action list from a prompts XML file @@ -86,5 +92,5 @@ }; - +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -7,8 +7,7 @@ #include "Switch.h" #include <fstream> -namespace AccessibleUi -{ +using namespace amis::gui::spoken; Container::Container() { @@ -191,5 +190,3 @@ } } - -} //end namespace AccessibleUi \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -5,9 +5,13 @@ #include "UiItem.h" #include "Action.h" -namespace AccessibleUi + +namespace amis { - +namespace gui +{ +namespace spoken +{ class Container : public UiItem { public: @@ -34,5 +38,5 @@ friend class DataReader; }; -} +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -1,8 +1,7 @@ #include "DataTree.h" #include <fstream> -namespace AccessibleUi -{ +using namespace amis::gui::spoken; DataTree* DataTree::pinstance = 0; @@ -330,5 +329,3 @@ } } - -} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -5,8 +5,13 @@ #include "Dialog.h" #include "Switch.h" -namespace AccessibleUi + +namespace amis { +namespace gui +{ +namespace spoken +{ class DataTree { protected: @@ -63,5 +68,5 @@ friend class DataReader; }; -} +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -2,8 +2,8 @@ #include "Dialog.h" #include <fstream> -namespace AccessibleUi -{ +using namespace amis::gui::spoken; + Dialog::Dialog() { mChildControls.empty(); @@ -159,5 +159,3 @@ { mPrompts.push_back(pPrompt); } - -} Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -5,9 +5,13 @@ #include "Prompt.h" #include "DialogControl.h" -namespace AccessibleUi + +namespace amis { - +namespace gui +{ +namespace spoken +{ class Dialog : public UiItem { public: @@ -34,5 +38,5 @@ friend class DataReader; }; -} +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -2,8 +2,8 @@ #include "Switch.h" #include <fstream> -namespace AccessibleUi -{ +using namespace amis::gui::spoken; + DialogControl::DialogControl() { setUiItemType(CONTROL); @@ -68,4 +68,3 @@ mWidgetCategories.assign(widgetCategories); } -} Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -6,8 +6,13 @@ #include "UiItem.h" #include "LabelList.h" -namespace AccessibleUi + +namespace amis { +namespace gui +{ +namespace spoken +{ class DialogControl : public UiItem { public: @@ -27,5 +32,5 @@ friend class DataReader; }; -} +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -5,6 +5,8 @@ #include ".\inifile.h" +using namespace amis::gui::spoken; + CIniFile::CIniFile(void) // Default constructor { } Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -7,6 +7,14 @@ #include <functional> using namespace std; + +namespace amis +{ +namespace gui +{ +namespace spoken +{ + class CIniFile { public: @@ -112,4 +120,5 @@ return Start.Key > End.Key; } }; -}; \ No newline at end of file +}; +}}} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -1,8 +1,7 @@ #include "Label.h" #include <fstream> -namespace AccessibleUi -{ +using namespace amis::gui::spoken; Label::Label() { @@ -131,6 +130,4 @@ return p_new; } - - -} \ No newline at end of file + \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -3,8 +3,13 @@ #include "Prompt.h" -namespace AccessibleUi + +namespace amis { +namespace gui +{ +namespace spoken +{ enum LabelType {CAPTION, DESCRIPTION, ACCELERATOR, MNEMONIC}; class Label @@ -46,5 +51,5 @@ friend class DataReader; }; -} +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/LabelList.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/LabelList.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/LabelList.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -1,8 +1,7 @@ #include "LabelList.h" #include <fstream> -namespace AccessibleUi -{ +using namespace amis::gui::spoken; LabelList::LabelList() { @@ -79,5 +78,3 @@ { mLabels.push_back(pLabel); } - -} Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/LabelList.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/LabelList.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/LabelList.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -3,8 +3,13 @@ #include "Label.h" -namespace AccessibleUi + +namespace amis { +namespace gui +{ +namespace spoken +{ class LabelList { public: @@ -26,6 +31,6 @@ friend class DataReader; }; -} +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -2,10 +2,8 @@ #include "Prompt.h" #include <fstream> +using namespace amis::gui::spoken; -namespace AccessibleUi -{ - //** //PromptItemBase PromptItemBase::PromptItemBase() @@ -427,5 +425,3 @@ mItems[j]->testPrint(outfile, numTabs + 1); } } - -}//end namespace AccessibleUi \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -5,9 +5,13 @@ #include "UiMediaTypes.h" -namespace AccessibleUi + +namespace amis { - +namespace gui +{ +namespace spoken +{ enum PromptItemType {PROMPT_VARIABLE, PROMPT_ITEM}; class PromptItemBase @@ -117,5 +121,5 @@ }; -} +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -1,8 +1,8 @@ //#include "stdafx.h" #include ".\promptresolver.h" -namespace AccessibleUi -{ +using namespace amis::gui::spoken; + /* PromptResolver::PromptResolver(void) { @@ -11,4 +11,3 @@ PromptResolver::~PromptResolver(void) { }*/ -} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -5,15 +5,20 @@ #ifndef PROMPTRESOLVER_H #define PROMPTRESOLVER_H -namespace AccessibleUi + +namespace amis { -class PromptResolver +namespace gui { +namespace spoken +{ + class PromptResolver +{ public: //PromptResolver(void); //virtual ~PromptResolver = 0; - virtual void resolvePromptVariables(AccessibleUi::Prompt*) = 0; + virtual void resolvePromptVariables(Prompt*) = 0; }; -} +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -5,8 +5,7 @@ #include <fstream> -namespace AccessibleUi -{ +using namespace amis::gui::spoken; Switch::Switch() { @@ -181,5 +180,3 @@ } } } - -} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -4,8 +4,13 @@ #include "Action.h" #include "Label.h" -namespace AccessibleUi + +namespace amis { +namespace gui +{ +namespace spoken +{ enum SwitchType {ACTIONSWITCH, CAPTIONSWITCH, DESCRIPTIONSWITCH}; class Switch @@ -38,6 +43,6 @@ friend class DataReader; }; -} +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -1,8 +1,8 @@ #include "UiItem.h" #include "Switch.h" -namespace AccessibleUi -{ +using namespace amis::gui::spoken; + UiItem::UiItem() { mpDescription = NULL; @@ -101,6 +101,3 @@ mpLabelList = pList; } - -}//end namespace AccessibleUi - Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -5,9 +5,13 @@ #include "Label.h" #include "LabelList.h" -namespace AccessibleUi + +namespace amis { - +namespace gui +{ +namespace spoken +{ enum UiItemType {NONE, CONTAINER, ACTION, DIALOG, CONTROL}; class Switch; @@ -62,5 +66,5 @@ friend class DataReader; }; -} +}}} #endif Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -2,8 +2,7 @@ #include "UiMediaTypes.h" #include <fstream> -namespace AccessibleUi -{ +using namespace amis::gui::spoken; //*********** //TextNode @@ -158,6 +157,3 @@ out.close(); } - - -}//end namespace AccessibleUi Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -6,9 +6,13 @@ #include "../AmisCore/include/Media.h" -namespace AccessibleUi + +namespace amis { - +namespace gui +{ +namespace spoken +{ class TextNode : public amis::TextNode { public: @@ -66,5 +70,5 @@ }; -} +}}} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -23,14 +23,50 @@ #endif +using namespace amis::audio; +using namespace amis::tts; +AudioSequencePlayer* AudioSequencePlayer::pinstance = 0; -AudioSequencePlayer* AudioSequencePlayer::pinstance = 0; +void AudioSequencePlayer::TTSAudioEndNotify() { + TRACE(L"####### END TTS"); + m_wakeUpOriginator = 2; // TTS END + SetEvent(m_hEventWakeup); + /* + if (m_wakeUpAction != 0) { + SetEvent(m_hEventWakeup); + } else { + m_nEndEventsToExpect--; + if (m_nEndEventsToExpect <= 0) { + SetEvent(m_hEventWakeup); + } + }*/ +} +void AudioSequencePlayer::ClipAudioEndNotify() { + TRACE(L"####### END AUDIO"); + m_wakeUpOriginator = 3; // AUDIO CLIP END + SetEvent(m_hEventWakeup); + /* + if (m_wakeUpAction != 0) { + SetEvent(m_hEventWakeup); + } else { + m_nEndEventsToExpect--; + if (m_nEndEventsToExpect <= 0) { + SetEvent(m_hEventWakeup); + } + }*/ +} + +//The message callback function ... signals end of the tts +static void ttsFinishedCallback() +{ + AudioSequencePlayer::Instance()->ClipAudioEndNotify(); +} //The message callback function ... signals end of the clip -static void clipFinishedCallback(void *wind) +static void clipFinishedCallback() { AudioSequencePlayer::Instance()->ClipAudioEndNotify(); } @@ -57,6 +93,7 @@ unsigned int threadID; AmisAudio::Instance()->setCallback((sendMessageCallbackFn)clipFinishedCallback); + TTSPlayer::Instance()->setCallback((sendMessageCallbackFn)ttsFinishedCallback); InitializeCriticalSection(&m_csSequence); @@ -218,35 +255,7 @@ } } -void AudioSequencePlayer::TTSAudioEndNotify() { - TRACE(L"####### END TTS"); - m_wakeUpOriginator = 2; // TTS END - SetEvent(m_hEventWakeup); - /* - if (m_wakeUpAction != 0) { - SetEvent(m_hEventWakeup); - } else { - m_nEndEventsToExpect--; - if (m_nEndEventsToExpect <= 0) { - SetEvent(m_hEventWakeup); - } - }*/ -} -void AudioSequencePlayer::ClipAudioEndNotify() { - TRACE(L"####### END AUDIO"); - m_wakeUpOriginator = 3; // AUDIO CLIP END - SetEvent(m_hEventWakeup); - /* - if (m_wakeUpAction != 0) { - SetEvent(m_hEventWakeup); - } else { - m_nEndEventsToExpect--; - if (m_nEndEventsToExpect <= 0) { - SetEvent(m_hEventWakeup); - } - }*/ -} // DanToDo: this string function should move to utilities. string AudioSequencePlayer::stringReplaceAll(string sourceStr, string searchStr, string replaceStr) Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -11,6 +11,14 @@ #include "../AmisCore/include/Media.h" + +namespace amis +{ +namespace gui +{ +namespace spoken +{ + // -------------------------------- class AudioSequenceComponent { @@ -173,4 +181,7 @@ } }; +} +} +} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -9,8 +9,6 @@ #include <spuihelp.h> #include <sphelper.h> -#include "AudioSequencePlayer.h" - #ifndef TRACE #define TRACE ATLTRACE #endif @@ -21,6 +19,14 @@ #include "../AmisGuiMFC2/include/Preferences.h" #include "../AmisGuiMFC2/resource.h" +using namespace amis::tts; + + +void TTSPlayer::setCallback(sendMessageCallbackFn pFunction) +{ + sendMessageCallback = pFunction; +} + TTSPlayer* TTSPlayer::pinstance = 0; TTSPlayer* TTSPlayer::Instance() @@ -36,7 +42,6 @@ // Error value is LONG_MAX. long TTSPlayer::GetSpeechRate() { -#ifdef COMPILE_WITH_SAPI long pRate; HRESULT hr = 0; hr = m_iV->GetRate(&pRate); @@ -48,15 +53,12 @@ _ASSERT(0); return LONG_MAX; // Should never happen ! } -#else - return LONG_MAX; -#endif } // between -10 and 10. 0 is default rate (engine dependant). BOOL TTSPlayer::SetSpeechRate(long newRate) { -#ifdef COMPILE_WITH_SAPI + HRESULT hr = 0; hr = m_iV->SetRate(newRate); if (SUCCEEDED(hr)) { @@ -67,43 +69,37 @@ _ASSERT(0); return FALSE; // Should never happen ! } -#else - return FALSE; -#endif } void TTSPlayer::Play(CString str) { TRACE(L"******"); TRACE(str); -#ifdef COMPILE_WITH_SAPI if (IsSpeaking()) { TRACE("????????"); } m_iV->Speak(str, SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL); -#endif } void TTSPlayer::Stop() { -#ifdef COMPILE_WITH_SAPI m_iV->Speak(NULL, SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL); m_isSpeaking = FALSE; //m_iV->Speak(L"", SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL); -#endif + } void TTSPlayer::WaitUntilDone() { -#ifdef COMPILE_WITH_SAPI + m_iV->WaitUntilDone(INFINITE); -#endif + } -#ifdef COMPILE_WITH_SAPI + void __stdcall TTSPlayer::SpkCallback(WPARAM wParam, LPARAM lParam) { @@ -133,7 +129,8 @@ ((TTSPlayer *)lParam)->m_isSpeaking = FALSE; - AudioSequencePlayer::Instance()->TTSAudioEndNotify(); + ((TTSPlayer *)lParam)->sendMessageCallback(); + break; case SPEI_VOICE_CHANGE: @@ -194,16 +191,15 @@ CoUninitialize(); } -#endif int TTSPlayer::initVoiceList(HWND hWnd) { -#ifdef COMPILE_WITH_SAPI + HRESULT hr = SpInitTokenComboBox( GetDlgItem( hWnd, IDC_TTSVOICE ), SPCAT_VOICES ); //HRESULT hr = SpInitTokenComboBox( GetDlgItem( IDC_TTSVOICE )->GetSafeHwnd(), SPCAT_VOICES ); if ( SUCCEEDED( hr ) ) {return m_currentVoiceNumber;} else {return -1;} -#endif + } void TTSPlayer::ChangeVoice(int index) { @@ -214,7 +210,6 @@ void TTSPlayer::ChangeVoice(bool speakNotify) { - #ifdef COMPILE_WITH_SAPI HRESULT hr = S_OK; CComPtr<ISpObjectToken> cpVoiceToken; @@ -254,7 +249,4 @@ if(SUCCEEDED(hr) && speakNotify) Play( L"This is my new voice !"); -#else - return; -#endif } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -3,17 +3,11 @@ #pragma once -#ifndef COMPILE_WITH_SAPI -#define COMPILE_WITH_SAPI // Comment this line if you want to compile AMIS without SAPI support -#endif // ! COMPILE_WITH_SAPI - #include <afxwin.h> #include <afxext.h> -#ifdef COMPILE_WITH_SAPI #include <sapi.h> #include <sphelper.h> -#endif //COMPILE_WITH_SAPI @@ -21,9 +15,20 @@ //#include "../AmisCore/include/Media.h" +namespace amis +{ +namespace tts +{ + class TTSPlayer { public: + + typedef void (*sendMessageCallbackFn)(void); + + sendMessageCallbackFn sendMessageCallback; + void setCallback(sendMessageCallbackFn pFunction); + static void DestroyInstance(); static TTSPlayer* Instance(); @@ -46,7 +51,6 @@ static TTSPlayer* pinstance; -#ifdef COMPILE_WITH_SAPI private: static void __stdcall SpkCallback(WPARAM wParam, LPARAM lParam); @@ -58,7 +62,7 @@ ISpVoice* m_iV; // Voice Interface -#endif //COMPILE_WITH_SAPI }; - +} +} #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/PreTranslateMessageHandler.h =================================================================== --- branches/amis3/AmisGuiMFC2/PreTranslateMessageHandler.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/PreTranslateMessageHandler.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -2,6 +2,14 @@ #include "../AmisSelfVoicing/AudioSequencePlayer.h" + +namespace amis +{ +namespace gui +{ +namespace spoken +{ + class PreTranslateMessageHandler { public: @@ -35,3 +43,6 @@ //bool processGeneralDialogFeedback(bool playNow, AudioSequence*, MSG* pMsg, int idUiFocus, bool ignoreSpaceKey, bool ignoreArrowKeys, CString strTextField); //void processGeneralKeyPressFeedback(bool playNow, AudioSequence* ,MSG* pMsg, bool ignoreSpaceKey, bool ignoreArrowKeys); }; +} +} +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -103,19 +103,19 @@ AudioSequence* playPromptFromUiId(int nItemID, bool playImmediately = true, AudioSequence* seq = NULL); AudioSequence* playContainerPromptFromId(string id, bool playImmediately, AudioSequence* seq = NULL); - AudioSequence* playPromptFromStringId(string, bool playImmediately = true, AudioSequence* seq = NULL, AccessibleUi::PromptResolver* pResolver = NULL); - AudioSequence* playPromptItemFromStringId(string, bool playImmediately = true, AudioSequence* seq = NULL, AccessibleUi::PromptResolver* pResolver = NULL); + AudioSequence* playPromptFromStringId(string, bool playImmediately = true, AudioSequence* seq = NULL, PromptResolver* pResolver = NULL); + AudioSequence* playPromptItemFromStringId(string, bool playImmediately = true, AudioSequence* seq = NULL, PromptResolver* pResolver = NULL); AudioSequence* playDialogInstructionsFromUiId(int nItemID, bool playImmediately = true, AudioSequence* seq = NULL); AudioSequence* playDialogTextControlsFromUiId(int nItemID, bool playImmediately = true, AudioSequence* seq = NULL, string switchCondition = ""); AudioSequence* playDialogControlFromUiIds(int dlgID, int ctrlId, bool playImmediately = true, AudioSequence* seq = NULL, string switchCondition = ""); - void fillSequencePrompt(AudioSequence* seq, AccessibleUi::Prompt* prompt, AccessibleUi::PromptResolver* pResolver = NULL); - void fillSequenceCaptionAndDescription(AudioSequence* seq, AccessibleUi::UiItem* uiItem); - void fillSequenceSwitch(AudioSequence* seq, AccessibleUi::UiItem* uiItem, string switchCondition = ""); - void fillSequenceContentAndPrompt(AudioSequence* seq, AccessibleUi::Label* label); - void fillSequenceContents(AudioSequence* seq, AccessibleUi::PromptItemBase* pi); + void fillSequencePrompt(AudioSequence* seq, Prompt* prompt, PromptResolver* pResolver = NULL); + void fillSequenceCaptionAndDescription(AudioSequence* seq, UiItem* uiItem); + void fillSequenceSwitch(AudioSequence* seq, UiItem* uiItem, string switchCondition = ""); + void fillSequenceContentAndPrompt(AudioSequence* seq, Label* label); + void fillSequenceContents(AudioSequence* seq, PromptItemBase* pi); - void resolvePromptVariables(AccessibleUi::Prompt*); + void resolvePromptVariables(Prompt*); private: void initPathsAndFiles(); Modified: branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2007-10-18 18:33:06 UTC (rev 2211) @@ -27,6 +27,10 @@ #include "../../PreTranslateMessageHandler.h" #pragma once + +using namespace amis::gui::spoken; + + namespace amis { namespace gui Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -63,6 +63,8 @@ #define MAX_ANYTHING 49 using namespace amis::gui; +using namespace amis::audio; +using namespace amis::tts; // CAmisGuiMFC2App @@ -186,9 +188,9 @@ if (amis::Preferences::Instance()->mbIsSelfVoicing == true) { //read in the new self-voicing/accessible UI data - AccessibleUi::DataReader new_data_reader; - AccessibleUi::DataTree* p_new_data_tree; - p_new_data_tree = AccessibleUi::DataTree::Instance(); + DataReader new_data_reader; + DataTree* p_new_data_tree; + p_new_data_tree = DataTree::Instance(); string tmpStr = amis::Preferences::Instance()->mUiLang; @@ -266,7 +268,7 @@ TTSPlayer::Instance()->DestroyInstance(); AudioSequencePlayer::Instance()->DestroyInstance(); - AccessibleUi::DataTree::Instance()->DestroyInstance(); + DataTree::Instance()->DestroyInstance(); } if (mpRecentBooks) delete mpRecentBooks; @@ -631,23 +633,23 @@ } //AppendAudioSequenceStringResource(seq, nItemID); - AccessibleUi::UiItem* p_uiItem = AccessibleUi::DataTree::Instance()->findUiItemInContainers(nItemID, strCondition); + UiItem* p_uiItem = DataTree::Instance()->findUiItemInContainers(nItemID, strCondition); if (p_uiItem != NULL) { - AccessibleUi::Label* keyboardShortcutAccelerator = NULL; - AccessibleUi::Label* mnemonic = NULL; - if (p_uiItem->getUiItemType() == AccessibleUi::ACTION) { - AccessibleUi::Action* action = (AccessibleUi::Action*)p_uiItem; + Label* keyboardShortcutAccelerator = NULL; + Label* mnemonic = NULL; + if (p_uiItem->getUiItemType() == ACTION) { + Action* action = (Action*)p_uiItem; keyboardShortcutAccelerator = action->getKeyboardAccelerator(); mnemonic = action->getMnemonic(); } - else if (p_uiItem->getUiItemType() == AccessibleUi::CONTAINER) { - AccessibleUi::Container* container = (AccessibleUi::Container*)p_uiItem; + else if (p_uiItem->getUiItemType() == CONTAINER) { + Container* container = (Container*)p_uiItem; keyboardShortcutAccelerator = container->getKeyboardAccelerator(); } //fillSequenceCaptionAndDescription(seq, p_uiItem); - AccessibleUi::Label* label = p_uiItem->getCaption(); + Label* label = p_uiItem->getCaption(); if (label != NULL) { fillSequenceContentAndPrompt(seq, label); } @@ -767,13 +769,13 @@ if (!id.empty()) { - AccessibleUi::Container* p_container = AccessibleUi::DataTree::Instance()->findContainer(id); + Container* p_container = DataTree::Instance()->findContainer(id); if (p_container != NULL) { if (seq == NULL) { seq = new AudioSequence; } - AccessibleUi::Label* keyboardShortcutAccelerator = p_container->getKeyboardAccelerator(); + Label* keyboardShortcutAccelerator = p_container->getKeyboardAccelerator(); fillSequenceCaptionAndDescription(seq, p_container); @@ -791,7 +793,7 @@ //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // This works for Prompts. -AudioSequence* CAmisGuiMFC2App::playPromptFromStringId(string promptId, bool playImmediately, AudioSequence* seq, AccessibleUi::PromptResolver* pResolver) +AudioSequence* CAmisGuiMFC2App::playPromptFromStringId(string promptId, bool playImmediately, AudioSequence* seq, PromptResolver* pResolver) { @@ -801,7 +803,7 @@ //AppendAudioSequenceStringID(seq, promptId); - AccessibleUi::Prompt* p_prompt_ = AccessibleUi::DataTree::Instance()->findPrompt(promptId); + Prompt* p_prompt_ = DataTree::Instance()->findPrompt(promptId); if (p_prompt_ != NULL) { @@ -816,7 +818,7 @@ //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // This works for Prompts. -AudioSequence* CAmisGuiMFC2App::playPromptItemFromStringId(string promptId, bool playImmediately, AudioSequence* seq, AccessibleUi::PromptResolver* pResolver) +AudioSequence* CAmisGuiMFC2App::playPromptItemFromStringId(string promptId, bool playImmediately, AudioSequence* seq, PromptResolver* pResolver) { @@ -825,7 +827,7 @@ seq = new AudioSequence; } - AccessibleUi::PromptItem* p_prompt_ = AccessibleUi::DataTree::Instance()->findPromptItem(promptId); + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem(promptId); if (p_prompt_ != NULL) { @@ -848,9 +850,9 @@ } //AppendAudioSequenceStringResource(seq, nItemID); - AccessibleUi::Dialog* p_dialog = AccessibleUi::DataTree::Instance()->findDialog(nItemID); + Dialog* p_dialog = DataTree::Instance()->findDialog(nItemID); if (p_dialog != NULL) { - AccessibleUi::Prompt* prompt = p_dialog->getPrompt("instructions"); + Prompt* prompt = p_dialog->getPrompt("instructions"); if (prompt != NULL) { fillSequencePrompt(seq, prompt); } @@ -874,14 +876,14 @@ } //AppendAudioSequenceStringResource(seq, nItemID); - AccessibleUi::Dialog* p_dialog = AccessibleUi::DataTree::Instance()->findDialog(nItemID); + Dialog* p_dialog = DataTree::Instance()->findDialog(nItemID); if (p_dialog != NULL) { fillSequenceCaptionAndDescription(seq, p_dialog); fillSequenceSwitch(seq, p_dialog, switchCondition); int count = p_dialog->getNumChildControls(); for (int i = 0 ; i < count; i++) { - AccessibleUi::DialogControl* control = p_dialog->getChildControl(i); + DialogControl* control = p_dialog->getChildControl(i); string strCat = control->getWidgetCategories(); int find = strCat.find("button"); if (-1 == find) { @@ -913,14 +915,14 @@ if (dlgID == -1) { if (ctrlId == IDCANCEL) { - AccessibleUi::PromptItem* p_prompt = AccessibleUi::DataTree::Instance()->findPromptItem("cancel_button_caption"); + 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 = AccessibleUi::DataTree::Instance()->findPromptItem("cancel_button_description"); + p_prompt = DataTree::Instance()->findPromptItem("cancel_button_description"); if (p_prompt != NULL) { fillSequenceContents(seq, p_prompt); @@ -929,14 +931,14 @@ } } else if (ctrlId == IDOK) { - AccessibleUi::PromptItem* p_prompt = AccessibleUi::DataTree::Instance()->findPromptItem("ok_button_caption"); + 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 = AccessibleUi::DataTree::Instance()->findPromptItem("ok_button_description"); + p_prompt = DataTree::Instance()->findPromptItem("ok_button_description"); if (p_prompt != NULL) { fillSequenceContents(seq, p_prompt); @@ -945,9 +947,9 @@ } - /* AccessibleUi::Dialog* p_dialog = AccessibleUi::DataTree::Instance()->findDialog(IDD_ABOUTBOX); + /* Dialog* p_dialog = DataTree::Instance()->findDialog(IDD_ABOUTBOX); if (p_dialog != NULL) { - AccessibleUi::DialogControl* control = p_dialog->findControl(IDOK); + DialogControl* control = p_dialog->findControl(IDOK); if (control != NULL) { fillSequenceCaptionAndDescription(seq, control); @@ -961,9 +963,9 @@ } else { - AccessibleUi::Dialog* p_dialog = AccessibleUi::DataTree::Instance()->findDialog(dlgID); + Dialog* p_dialog = DataTree::Instance()->findDialog(dlgID); if (p_dialog != NULL) { - AccessibleUi::DialogControl* control = p_dialog->findControl(ctrlId); + DialogControl* control = p_dialog->findControl(ctrlId); if (control != NULL) { fillSequenceCaptionAndDescription(seq, control); @@ -979,7 +981,7 @@ //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// -void CAmisGuiMFC2App::fillSequencePrompt(AudioSequence* seq, AccessibleUi::Prompt* prompt, AccessibleUi::PromptResolver* pResolver) { +void CAmisGuiMFC2App::fillSequencePrompt(AudioSequence* seq, Prompt* prompt, PromptResolver* pResolver) { resolvePromptVariables(prompt); if (pResolver != NULL) { @@ -989,15 +991,15 @@ int sz = prompt->getNumberOfItems(); for (int i=0; i<sz; i++) { - AccessibleUi::PromptItemBase* pib = prompt->getItem(i); + PromptItemBase* pib = prompt->getItem(i); switch(pib->getPromptItemType()) { - case AccessibleUi::PROMPT_ITEM: { - AccessibleUi::PromptItem* pi = (AccessibleUi::PromptItem*) pib; + case PROMPT_ITEM: { + PromptItem* pi = (PromptItem*) pib; fillSequenceContents(seq, pi); break; } - case AccessibleUi::PROMPT_VARIABLE: { - AccessibleUi::PromptVar* pv = (AccessibleUi::PromptVar*) pib; + case PROMPT_VARIABLE: { + PromptVar* pv = (PromptVar*) pib; //seq->append(pv->getName().c_str()); fillSequenceContents(seq, pv); break; @@ -1009,9 +1011,9 @@ //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// -void CAmisGuiMFC2App::fillSequenceCaptionAndDescription(AudioSequence* seq, AccessibleUi::UiItem* uiItem) { +void CAmisGuiMFC2App::fillSequenceCaptionAndDescription(AudioSequence* seq, UiItem* uiItem) { - AccessibleUi::Label* label = uiItem->getCaption(); + Label* label = uiItem->getCaption(); if (label != NULL) { fillSequenceContentAndPrompt(seq, label); } @@ -1024,22 +1026,22 @@ //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// -void CAmisGuiMFC2App::fillSequenceSwitch(AudioSequence* seq, AccessibleUi::UiItem* uiItem, string switchCondition) { +void CAmisGuiMFC2App::fillSequenceSwitch(AudioSequence* seq, UiItem* uiItem, string switchCondition) { - AccessibleUi::Switch* zwitch; + Switch* zwitch; if ((zwitch = uiItem->getSwitch()) != NULL) { switch(zwitch->getSwitchType()) { - case AccessibleUi::ACTIONSWITCH: { - AccessibleUi::Action* action = zwitch->getAction(switchCondition); + case ACTIONSWITCH: { + Action* action = zwitch->getAction(switchCondition); if (action != NULL) { fillSequenceCaptionAndDescription(seq, action); } break; } - case AccessibleUi::CAPTIONSWITCH: {} - case AccessibleUi::DESCRIPTIONSWITCH: { - AccessibleUi::Label* label = zwitch->getLabel(switchCondition); + case CAPTIONSWITCH: {} + case DESCRIPTIONSWITCH: { + Label* label = zwitch->getLabel(switchCondition); if (label != NULL) { fillSequenceContentAndPrompt(seq, label); } @@ -1051,33 +1053,33 @@ //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// -void CAmisGuiMFC2App::fillSequenceContentAndPrompt(AudioSequence* seq, AccessibleUi::Label* label) +void CAmisGuiMFC2App::fillSequenceContentAndPrompt(AudioSequence* seq, Label* label) { - AccessibleUi::TextAudioPair* pair = label->getContents(); + TextAudioPair* pair = label->getContents(); if (pair != NULL) { amis::AudioNode* audio = pair->getAudio(); if (!Preferences::Instance()->mbUseTTSNotAudio && audio != NULL) { seq->append(audio); } else { - AccessibleUi::TextNode* textN = pair->getText(); + TextNode* textN = pair->getText(); if (textN != NULL) { seq->append(textN->getTextString().c_str()); } } } - AccessibleUi::Prompt* prompt = label->getPrompt(); + Prompt* prompt = label->getPrompt(); if (prompt != NULL) { int count = prompt->getNumberOfItems(); for (int i=0; i<count; i++) { - AccessibleUi::PromptItemBase* pib = prompt->getItem(i); + PromptItemBase* pib = prompt->getItem(i); switch(pib->getPromptItemType()) { - case AccessibleUi::PROMPT_ITEM: + case PROMPT_ITEM: { - AccessibleUi::PromptItem* pi = (AccessibleUi::PromptItem*) pib; + PromptItem* pi = (PromptItem*) pib; pair = pi->getContents(); if (pair != NULL) @@ -1088,7 +1090,7 @@ seq->append(audio); } else { - AccessibleUi::TextNode * textN = pair->getText(); + TextNode * textN = pair->getText(); if (textN != NULL) { seq->append(textN->getTextString().c_str()); @@ -1097,8 +1099,8 @@ } break; } - case AccessibleUi::PROMPT_VARIABLE: { - AccessibleUi::PromptVar* pv = (AccessibleUi::PromptVar*) pib; + case PROMPT_VARIABLE: { + PromptVar* pv = (PromptVar*) pib; //We assume variable value resolution happened before. @@ -1111,7 +1113,7 @@ seq->append(audio); } else { - AccessibleUi::TextNode * textN = pair->getText(); + TextNode * textN = pair->getText(); if (textN != NULL) { seq->append(textN->getTextString().c_str()); @@ -1127,15 +1129,15 @@ //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// -void CAmisGuiMFC2App::fillSequenceContents(AudioSequence* seq, AccessibleUi::PromptItemBase* pi) { +void CAmisGuiMFC2App::fillSequenceContents(AudioSequence* seq, PromptItemBase* pi) { - AccessibleUi::TextAudioPair* pair = pi->getContents(); + TextAudioPair* pair = pi->getContents(); if (pair != NULL) { amis::AudioNode* audio = pair->getAudio(); if (!Preferences::Instance()->mbUseTTSNotAudio && audio != NULL) { seq->append(audio); } else { - AccessibleUi::TextNode * textN = pair->getText(); + TextNode * textN = pair->getText(); if (textN != NULL) { seq->append(textN->getTextString().c_str()); } @@ -1146,17 +1148,17 @@ //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// //the new one -void CAmisGuiMFC2App::resolvePromptVariables(AccessibleUi::Prompt* pPrompt) +void CAmisGuiMFC2App::resolvePromptVariables(Prompt* pPrompt) { USES_CONVERSION; - AccessibleUi::PromptVar* p_var = NULL; + PromptVar* p_var = NULL; for (int i=0; i<pPrompt->getNumberOfItems(); i++) { - if (pPrompt->getItem(i)->getPromptItemType() == AccessibleUi::PROMPT_VARIABLE) + if (pPrompt->getItem(i)->getPromptItemType() == PROMPT_VARIABLE) { - p_var = (AccessibleUi::PromptVar*)pPrompt->getItem(i); + p_var = (PromptVar*)pPrompt->getItem(i); if (p_var->getName() == "BOOK_PATH") { Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -34,7 +34,7 @@ static char THIS_FILE[] = __FILE__; #endif - +using namespace amis::audio; using namespace amis::gui; // CMainFrame @@ -218,7 +218,7 @@ if ( nFlags & MF_GRAYED ) { - AccessibleUi::PromptItem* promptNotAvailable = AccessibleUi::DataTree::Instance()->findPromptItem("not_available"); + PromptItem* promptNotAvailable = DataTree::Instance()->findPromptItem("not_available"); if (promptNotAvailable != NULL) { @@ -248,7 +248,7 @@ if (prompt.compare("file") == 0 || prompt.compare("recentBooksList") == 0) { seq = theApp.playContainerPromptFromId("recentBooksList", false, seq); - AccessibleUi::PromptItem* p_prompt_ = AccessibleUi::DataTree::Instance()->findPromptItem("menu"); + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); if (p_prompt_ != NULL) { @@ -262,7 +262,7 @@ } else if (prompt.compare("navigate") == 0 || prompt.compare("sectiondepth") == 0) { seq = theApp.playContainerPromptFromId("sectiondepth", false, seq); - AccessibleUi::PromptItem* p_prompt_ = AccessibleUi::DataTree::Instance()->findPromptItem("menu"); + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); if (p_prompt_ != NULL) { @@ -299,7 +299,7 @@ break; //default: seq = new AudioSequence(); } - AccessibleUi::PromptItem* p_prompt_ = AccessibleUi::DataTree::Instance()->findPromptItem("menu"); + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); if (p_prompt_ != NULL) { @@ -644,7 +644,7 @@ } //todo: replace this by something like: -// Container* container = AccessibleUi::DataTree::Instance()->findContainerWhichHasFirstItem(id) +// Container* container = DataTree::Instance()->findContainerWhichHasFirstItem(id) // container.id std::string CMainFrame::computeRootMenuFromFirstChildID(unsigned int firstItemId, bool playPrompt) { @@ -703,7 +703,7 @@ if (playPrompt) { AudioSequence* seq = theApp.playContainerPromptFromId(str_id, false); - AccessibleUi::PromptItem* p_prompt_ = AccessibleUi::DataTree::Instance()->findPromptItem("menu"); + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); if (p_prompt_ != NULL) { Modified: branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2007-10-18 16:39:59 UTC (rev 2210) +++ branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2007-10-18 18:33:06 UTC (rev 2211) @@ -329,28 +329,28 @@ bool b_BookIsPlaying = MainWndParts::Instance()->mpMainFrame->mbWasPlayingWhenLostFocus || !pauseState; - AccessibleUi::UiItem* p_uiItem = AccessibleUi::DataTree::Instance()->findUiItemInContainers(ID_MENU_PLAYPAUSE, (b_BookIsPlaying ? "canPause" : "canPlay")); + UiItem* p_uiItem = DataTree::Instance()->findUiItemInContainers(ID_MENU_PLAYPAUSE, (b_BookIsPlaying ? "canPause" : "canPlay")); if (p_uiItem != NULL) { - AccessibleUi::Label* accelerator = NULL; - if (p_uiItem->getUiItemType() == AccessibleUi::ACTION) { - accelerator = ((AccessibleUi::Action*)p_uiItem)->getKeyboardAccelerator(); + Label* accelerator = NULL; + if (p_uiItem->getUiItemType() == ACTION) { + accelerator = ((Action*)p_uiItem)->getKeyboardAccelerator(); } - AccessibleUi::Label* mnemonic = NULL; - if (p_uiItem->getUiItemType() == AccessibleUi::ACTION) { - mnemonic = ((AccessibleUi::Action*)p_uiItem)->getMnemonic(); + Label* mnemonic = NULL; + if (p_uiItem->getUiItemType() == ACTION) { + mnemonic = ((Action*)p_uiItem)->getMnemonic(); } - AccessibleUi::Label* p_caption = p_uiItem->getCaption(); + Label* p_caption = p_uiItem->getCaption(); if (p_caption != NULL) { - AccessibleUi::TextAudioPair* pair = p_caption->getContents(); + TextAudioPair* pair = p_caption->getContents(); if (pair != NULL) { amis::TextNode* textNode = pair->getText(); if (textNode != NULL) { wstring str = textNode->getTextString(); if (mnemonic != NULL) { - AccessibleUi::TextAudioPair* pair = mnemonic->getContents(); + TextAudioPair* pair = mnemonic->getContents(); if (pair != NULL) { - AccessibleUi::TextNode* node = pair->getText(); + TextNode* node = pair->getText(); if (node != NULL) { wstring strMnemonic = node->getTextString(); int index = str.find_first_of(strMnemonic, 0); @@ -365,9 +365,9 @@ str.append(_T("\t")); //char* text = accelerator.c_str(); //str.append(accelerator.c_str()); - AccessibleUi::TextAudioPair* pair = accelerator->getContents(); + TextAudioPair* pair = accelerator->getContents(); if (pair != NULL) { - AccessibleUi::TextNode* node = pair->getText(); + TextNode* node = pair->getText(); if (node != NULL) { str.append(node->getTextString()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-10-18 22:27:14
|
Revision: 2212 http://amis.svn.sourceforge.net/amis/?rev=2212&view=rev Author: daniel_weck Date: 2007-10-18 15:27:17 -0700 (Thu, 18 Oct 2007) Log Message: ----------- - Daniel WECK * Re-organization of code (took lots of time to fix the windows.h versus afxwin.h includes !) Modified Paths: -------------- branches/amis3/AmisAudio/AmisAudio.cpp branches/amis3/AmisAudio/AmisAudio.h branches/amis3/AmisAudio/TPBReader2/dmp/DmpPpg.h branches/amis3/AmisAudio/TPBReader2/dmp/dmp.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.h branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h branches/amis3/AmisGuiMFC2/include/gui/MainWndParts.h branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp Added Paths: ----------- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequence.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequence.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequenceComponent.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequenceComponent.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/Prompt.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/Prompt.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PromptResolver.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PromptResolver.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/UiMediaTypes.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/UiMediaTypes.h Removed Paths: ------------- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/StdAfx.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/StdAfx.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.h branches/amis3/AmisGuiMFC2/PreTranslateMessageHandler.cpp branches/amis3/AmisGuiMFC2/PreTranslateMessageHandler.h Modified: branches/amis3/AmisAudio/AmisAudio.cpp =================================================================== --- branches/amis3/AmisAudio/AmisAudio.cpp 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisAudio/AmisAudio.cpp 2007-10-18 22:27:17 UTC (rev 2212) @@ -21,11 +21,7 @@ */ // AmisAudio.cpp : Defines the entry point for the DLL application. -//#include "StdAfx.h" -//#include "TPBReader2\dmp\StdAfxFIX.h" - - #include <stdlib.h> #include <iostream> #include <string> Modified: branches/amis3/AmisAudio/AmisAudio.h =================================================================== --- branches/amis3/AmisAudio/AmisAudio.h 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisAudio/AmisAudio.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -42,10 +42,8 @@ #include "TPBReader2\dmp\DmpCtl.h" #include "TPBReader2\dmp\Dmp.h" +//#include <windows.h> -//#include "StdAfx.h" -#include <windows.h> - #include "./mffmTimeCode/smilTimeCode.H" //for message sending ... Modified: branches/amis3/AmisAudio/TPBReader2/dmp/DmpPpg.h =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/DmpPpg.h 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisAudio/TPBReader2/dmp/DmpPpg.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -5,7 +5,6 @@ #pragma once #endif // _MSC_VER > 1000 -//#include "stdafx.h" #include "resource.h" // main symbols Modified: branches/amis3/AmisAudio/TPBReader2/dmp/dmp.cpp =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/dmp.cpp 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisAudio/TPBReader2/dmp/dmp.cpp 2007-10-18 22:27:17 UTC (rev 2212) @@ -3,8 +3,6 @@ #include "StdAfxFIX.h" -//#include "stdafx.h" - //#include <dshow.h> #include "dmp.h" Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.h 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Action.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,7 +1,7 @@ #ifndef ACTION_H #define ACTION_H -#include "UiMediaTypes.h" +#include "../UiMediaTypes.h" #include "UiItem.h" Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.cpp 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Container.cpp 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,7 +1,5 @@ //amis menu data -// DanToDo: The following includes did not survive the Amis3 architecture, so I must find equivalent functions/utilities elsewhere now. -//#include "../stdafx.h" #include "Container.h" #include "Switch.h" Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.h 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Dialog.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -2,7 +2,7 @@ #define DIALOG_H #include "UiItem.h" -#include "Prompt.h" +#include "../Prompt.h" #include "DialogControl.h" Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.h 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DialogControl.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,8 +1,8 @@ #ifndef DIALOGCONTROL_H #define DIALOGCONTROL_H -#include "UiMediaTypes.h" -#include "Prompt.h" +#include "../UiMediaTypes.h" +#include "../Prompt.h" #include "UiItem.h" #include "LabelList.h" Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.cpp 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/IniFile.cpp 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,7 +1,5 @@ -// DanToDo: The following includes did not survive the Amis3 architecture, so I must find equivalent functions/utilities elsewhere now. -//#include "StdAfx.h" #include ".\inifile.h" Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.h 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Label.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,7 +1,7 @@ #ifndef LABEL_H #define LABEL_H -#include "Prompt.h" +#include "../Prompt.h" namespace amis Deleted: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.cpp 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.cpp 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,427 +0,0 @@ - -#include "Prompt.h" -#include <fstream> - -using namespace amis::gui::spoken; - -//** -//PromptItemBase -PromptItemBase::PromptItemBase() -{ - mpContents = NULL; -} -PromptItemBase::~PromptItemBase() -{ - if (mpContents != NULL) { - delete mpContents; - } -} -TextAudioPair* PromptItemBase::getContents() -{ - return mpContents; -} - -PromptItemType PromptItemBase::getPromptItemType() -{ - return mType; -} -void PromptItemBase::setPromptItemType(PromptItemType type) -{ - mType = type; -} - -void PromptItemBase::setContents(TextAudioPair* pContents) -{ - mpContents = pContents; -} - -void PromptItemBase::setContents(std::wstring textString, amis::AudioNode* p_audio) -{ - if (mpContents != NULL) - delete mpContents; - - TextAudioPair* p_pair = new TextAudioPair(); - - TextNode* p_text = NULL; - if (!textString.empty()) { - p_text = new TextNode(); - p_text->setTextString(textString); - p_pair->setText(p_text); - } - - p_pair->setAudio(p_audio); - - this->mpContents = p_pair; - -} -void PromptItemBase::setContents(std::wstring textString, std::string audioSrc) -{ - if (mpContents != NULL) - delete mpContents; - - TextAudioPair* p_pair = new TextAudioPair(); - - TextNode* p_text = NULL; - if (!textString.empty()) { - p_text = new TextNode(); - p_text->setTextString(textString); - p_pair->setText(p_text); - } - - amis::AudioNode* p_audio = new amis::AudioNode(); - if (!audioSrc.empty()) { - p_audio = new amis::AudioNode(); - p_audio->setSrc(audioSrc); - p_pair->setAudio(p_audio); - } - - this->mpContents = p_pair; - -} - -void PromptItemBase::setContents(amis::MediaGroup* pMediaGroup) -{ - if (mpContents != NULL) - delete mpContents; - - mpContents = new TextAudioPair(); - - if (pMediaGroup->hasText() == true) - { - TextNode* p_text = new TextNode(); - p_text->setTextString(pMediaGroup->getText()->getTextString()); - mpContents->setText(p_text); - } - - if (pMediaGroup->hasAudio() == true) - { - amis::AudioNode* p_audio = new amis::AudioNode(); - p_audio->setSrc(pMediaGroup->getAudio(0)->getSrc()); - p_audio->setClipBegin(pMediaGroup->getAudio(0)->getClipBegin()); - p_audio->setClipEnd(pMediaGroup->getAudio(0)->getClipEnd()); - - mpContents->setAudio(p_audio); - } - - -} - -//** -//PromptItem -PromptItem::PromptItem() -{ - mRefId=""; - mId = ""; - setPromptItemType(PROMPT_ITEM); -} -PromptItem::~PromptItem() -{ -} - -std::string PromptItem::getRefId() -{ - return mRefId; -} -std::string PromptItem::getId() -{ - return mId; -} -void PromptItem::setRefId(std::string refId) -{ - mRefId.assign(refId); -} -void PromptItem::setId(std::string id) -{ - mId.assign(id); -} - -//make a hardcopy of the contents pointed to by refid -void PromptItem::setReferenceContents(PromptItem* pItem) -{ - if (pItem != NULL) - { - TextAudioPair* p_pair = NULL; - p_pair = pItem->getContents(); - if (p_pair != NULL) - { - - TextAudioPair* p_these_contents = new TextAudioPair(); - - if (p_pair->getText() != NULL) - { - p_these_contents->setText(p_pair->getText()->clone()); - } - if (p_pair->getAudio() != NULL) - { - p_these_contents->setAudio((amis::AudioNode*)p_pair->getAudio()->clone()); - } - - this->setContents(p_these_contents); - - } - } - -} -PromptItem* PromptItem::clone() -{ - PromptItem* p_new = new PromptItem(); - p_new->setPromptItemType(this->getPromptItemType()); - p_new->setRefId(this->mRefId); - - TextAudioPair* p_pair = this->getContents()->clone(); - - p_new->setContents(p_pair); - - return p_new; - -} -void PromptItem::testPrint(std::string outfile, int numTabs) -{ - fstream out; - out.open(outfile.c_str(), ios::app | ios::out); - - int i=0; - - for (i=0; i<numTabs; i++){out<<"\t";} - out<<"Prompt Item"<<endl; - - if (mRefId.size() > 0) - { - for (i=0; i<numTabs + 1; i++){out<<"\t";} - out<<"ref id = "<<mRefId<<endl; - } - out.close(); - this->getContents()->testPrint(outfile, numTabs + 1); - -} - -//** -//PromptVar -PromptVar::PromptVar() -{ - mParam = ""; - mName = ""; - - setPromptItemType(PROMPT_VARIABLE); -} -PromptVar::~PromptVar() -{ -} - -std::string PromptVar::getParam() -{ - return mParam; -} - -std::string PromptVar::getName() -{ - return mName; -} -void PromptVar::setParam(std::string param) -{ - mParam.assign(param); -} -void PromptVar::setName(std::string name) -{ - mName.assign(name); -} - -//prompt variables don't copy their contents -//since that changes so often -PromptVar* PromptVar::clone() -{ - PromptVar* p_new = new PromptVar(); - p_new->setName (this->mName); - p_new->setParam (this->mParam); - p_new->setPromptItemType(this->getPromptItemType()); - - return p_new; - -} -void PromptVar::testPrint(std::string outfile, int numTabs) -{ - fstream out; - out.open(outfile.c_str(), ios::app | ios::out); - - int i=0; - - for (i=0; i<numTabs; i++){out<<"\t";} - out<<"Prompt Variable"<<endl; - - if (mName.size() > 0) - { - for (i=0; i<numTabs + 1; i++){out<<"\t";} - out<<"Name = "<<mName<<endl; - } - - if (mParam.size() > 0) - { - for (i=0; i<numTabs + 1; i++){out<<"\t";} - out<<"Param = "<<mParam<<endl; - } - - if (this->getContents() != NULL) - { - this->getContents()->testPrint(outfile, numTabs + 1); - } - - out.close(); - - -} - -//** -//Prompt -Prompt::Prompt() -{ - mItems.empty(); -} -Prompt::~Prompt() -{ - PromptItemBase* p_item = NULL; - - for (int i=0; i<mItems.size()-1; i--) - { - p_item = mItems[i]; - mItems.pop_back(); - if (p_item != NULL) - delete p_item; - - p_item = NULL; - } -} -int Prompt::getNumberOfItems() -{ - return mItems.size(); -} -PromptItemBase* Prompt::getItem(int idx) -{ - if (idx >=0 && idx < mItems.size()) - { - return mItems[idx]; - } - else - { - return NULL; - } -} - -void Prompt::addItem(PromptItemBase* pItem) -{ - mItems.push_back(pItem); -} -std::string Prompt::getType() -{ - return mType; -} -void Prompt::setType(std::string type) -{ - mType.assign(type); -} - -std::string Prompt::getId() -{ - return mId; -} -void Prompt::setId(std::string id) -{ - mId.assign(id); -} - -//return a string containing all the promptItem texts -//if the prompt has unresolved variables, insert them as the variable name -//(good for testing) -std::wstring Prompt::concatAllText() -{ - std::wstring ret_string; - ret_string.erase(); - - PromptVar* p_var = NULL; - TextAudioPair* p_contents = NULL; - PromptItemBase* p_base = NULL; - - int sz = mItems.size(); - for (int i=0; i<sz; i++) - { - p_base = mItems[i]; - - if (p_base->getPromptItemType() == PROMPT_VARIABLE && - p_base->getContents() == NULL) - { - p_var = (PromptVar*)p_base; - //@todo - //this variable was not resolved, so append its name to the list - //convert std::string to std::wstring: can we do this here with no MFC dependencies? - //ret_string.append(p_var->getName()); - } - else - { - p_contents = p_base->getContents(); - if (p_contents != NULL) - { - if (p_contents->getText() != NULL) - { - ret_string.append(p_contents->getText()->getTextString()); - } - } - else - { - std::string sz_err = " #ERROR# "; - //@todo - //convert std::string to std::wstring: can we do this here with no MFC dependencies? - //ret_string.append(sz_err.c_str()); - } - } - } - - return ret_string; -} - -Prompt* Prompt::clone() -{ - Prompt* p_new = new Prompt(); - p_new->setId(this->mId); - p_new->setType(this->mType); - - PromptItem* p_item; - PromptVar* p_var; - - for (int i=0; i<this->mItems.size(); i++) - { - if (mItems[i]->getPromptItemType() == PROMPT_ITEM) - { - p_item = (PromptItem*)mItems[i]; - p_new->addItem(p_item->clone()); - } - else if (mItems[i]->getPromptItemType() == PROMPT_VARIABLE) - { - p_var = (PromptVar*)mItems[i]; - p_new->addItem(p_var->clone()); - } - } - - return p_new; -} -void Prompt::testPrint(std::string outfile, int numTabs) -{ - fstream out; - out.open(outfile.c_str(), ios::app | ios::out); - - int i=0; - - for (i=0; i<numTabs; i++){out<<"\t";} - out<<"Prompt"<<endl; - - for (i=0; i<numTabs + 1; i++){out<<"\t";} - out<<"id = "<<mId<<endl; - - for (i=0; i<numTabs + 1; i++){out<<"\t";} - out<<"type = "<<mType<<endl; - - out.close(); - - for(int j=0; j<mItems.size(); j++) - { - mItems[j]->testPrint(outfile, numTabs + 1); - } -} Deleted: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.h 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Prompt.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,125 +0,0 @@ -#ifndef PROMPT_H -#define PROMPT_H - - -#include "UiMediaTypes.h" - - - -namespace amis -{ -namespace gui -{ -namespace spoken -{ -enum PromptItemType {PROMPT_VARIABLE, PROMPT_ITEM}; - -class PromptItemBase -{ -public: - PromptItemBase(); - ~PromptItemBase(); - - PromptItemType getPromptItemType(); - TextAudioPair* getContents(); - - virtual void testPrint(std::string, int) = 0; - void setContents(std::wstring, std::string); - void setContents(std::wstring textString, amis::AudioNode* p_audio); - - void setPromptItemType(PromptItemType); - void setContents(TextAudioPair*); - void setContents(amis::MediaGroup*); - -private: - PromptItemType mType; - TextAudioPair* mpContents; - -}; - -//both promptItems and promptVars should resolve to a PromptItemBase -class PromptItem : public PromptItemBase -{ -public: - PromptItem(); - ~PromptItem(); - - std::string getRefId(); - std::string getId(); - void testPrint(std::string, int); - PromptItem* clone(); - void setReferenceContents(PromptItem*); - -protected: - void setRefId(std::string); - void setId(std::string); - -private: - std::string mRefId; - std::string mId; - - friend class DataReader; -}; - -class PromptVar : public PromptItemBase -{ -public: - PromptVar(); - ~PromptVar(); - - //the variable parameter - std::string getParam(); - - //the variable name - std::string getName(); - - void testPrint(std::string, int); - - PromptVar* clone(); - -protected: - void setParam(std::string); - void setName(std::string); - -private: - std::string mParam; - std::string mName; - - friend class DataReader; -}; - - - -class Prompt -{ -public: - Prompt(); - ~Prompt(); - - int getNumberOfItems(); - PromptItemBase* getItem(int); - - std::string getType(); - std::string getId(); - - void testPrint(std::string, int); - std::wstring concatAllText(); - Prompt* clone(); - - -protected: - void addItem(PromptItemBase*); - void setType(std::string); - void setId(std::string); - -private: - vector <PromptItemBase*> mItems; - std::string mType; - std::string mId; - - friend class DataReader; -}; - - -}}} -#endif \ No newline at end of file Deleted: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.cpp 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.cpp 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,13 +0,0 @@ -//#include "stdafx.h" -#include ".\promptresolver.h" - -using namespace amis::gui::spoken; - - /* -PromptResolver::PromptResolver(void) -{ -} - -PromptResolver::~PromptResolver(void) -{ -}*/ Deleted: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.h 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/PromptResolver.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,24 +0,0 @@ -#pragma once - -#include "Prompt.h" - -#ifndef PROMPTRESOLVER_H -#define PROMPTRESOLVER_H - - -namespace amis -{ -namespace gui -{ -namespace spoken -{ - class PromptResolver -{ -public: - //PromptResolver(void); - //virtual ~PromptResolver = 0; - - virtual void resolvePromptVariables(Prompt*) = 0; -}; -}}} -#endif \ No newline at end of file Deleted: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/StdAfx.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/StdAfx.cpp 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/StdAfx.cpp 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// AmisGuiMFC.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - Deleted: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/StdAfx.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/StdAfx.h 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/StdAfx.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,33 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__DE447A84_1CA9_4A55_9A4A_D91FCE1DB1CB__INCLUDED_) -#define AFX_STDAFX_H__DE447A84_1CA9_4A55_9A4A_D91FCE1DB1CB__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#pragma warning(disable : 4786) -#pragma warning(disable : 4251) - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -#include <afxwin.h> // MFC core and standard components -#include <afxext.h> // MFC extensions -#include <afxdisp.h> // MFC Automation classes -#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include <afxcmn.h> // MFC support for Windows Common Controls -#include <afxctl.h> //for CPictureHolder support -#endif // _AFX_NO_AFXCMN_SUPPORT -//#include <afxhtml.h> - - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. -#define _SCB_REPLACE_MINIFRAME - -#endif // !defined(AFX_STDAFX_H__DE447A84_1CA9_4A55_9A4A_D91FCE1DB1CB__INCLUDED_) Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.h 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiItem.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,7 +1,7 @@ #ifndef UIITEM_H #define UIITEM_H -#include "UiMediaTypes.h" +#include "../UiMediaTypes.h" #include "Label.h" #include "LabelList.h" Deleted: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.cpp 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.cpp 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,159 +0,0 @@ - -#include "UiMediaTypes.h" -#include <fstream> - -using namespace amis::gui::spoken; - -//*********** -//TextNode -TextNode::TextNode() -{ - mMnemonic = ""; -} - -TextNode::~TextNode() -{ -} - -std::string TextNode::getMnemonic() -{ - return mMnemonic; -} -void TextNode::setMnemonic(std::string mnemonic) -{ - mMnemonic.assign(mnemonic); -} - -//just copy over the text string and the mnemonic -//not complete but will do for now -TextNode* TextNode::clone() -{ - TextNode* p_new = new TextNode(); - p_new->setTextString(this->getTextString()); - p_new->setMnemonic(this->getMnemonic()); - - return p_new; - -} - -//*********** -//ImageNode -ImageNode::ImageNode() -{ - mImageType = SMALL_ICON; -} -ImageNode::~ImageNode() -{ -} -ImageType ImageNode::getImageType() -{ - return mImageType; -} -void ImageNode::setImageType(ImageType imgType) -{ - mImageType = imgType; -} - -//****************** -//TextAudioPair - -TextAudioPair::TextAudioPair() -{ - mpText = NULL; - mpAudio = NULL; - mpMediaGroupVersion = NULL; -} -TextAudioPair::~TextAudioPair() -{ - if (mpMediaGroupVersion != NULL) - delete mpMediaGroupVersion; - if (mpText != NULL) - delete mpText; - if (mpAudio != NULL) - delete mpAudio; - -} - -TextNode* TextAudioPair::getText() -{ - return mpText; -} - -amis::AudioNode* TextAudioPair::getAudio() -{ - return mpAudio; -} - -void TextAudioPair::setText(TextNode* pNode) -{ - this->mpText = pNode; -} -void TextAudioPair::setAudio(amis::AudioNode* pNode) -{ - this->mpAudio = pNode; -} -TextAudioPair* TextAudioPair::clone() -{ - TextAudioPair* p_new = new TextAudioPair(); - - amis::AudioNode* p_audio = (amis::AudioNode*)this->getAudio()->clone(); - TextNode* p_text = this->getText()->clone(); - - p_new->setAudio(p_audio); - p_new->setText(p_text); - - return p_new; -} -amis::MediaGroup* TextAudioPair::getAsAmisMediaGroup() -{ - if (mpMediaGroupVersion != NULL) - delete mpMediaGroupVersion; - - mpMediaGroupVersion = new amis::MediaGroup(); - - mpMediaGroupVersion->setText(this->mpText); - mpMediaGroupVersion->addAudioClip(this->mpAudio); - - return mpMediaGroupVersion; -} -void TextAudioPair::testPrint(std::string outfile, int numTabs) -{ - fstream out; - out.open(outfile.c_str(), ios::app | ios::out); - - int i=0; - - for (i=0; i<numTabs; i++){out<<"\t";} - out<<"text = "; - - out.close(); - - //reopen in widechar mode to write the text string - wfstream wout; - wout.open(outfile.c_str(), ios::app | ios::out); - - if (mpText != NULL) - { - wout.write(this->mpText->getTextString().c_str(), - this->mpText->getTextString().size()); - } - - wout.close(); - //done with widechar mode - - out.open(outfile.c_str(), ios::app | ios::out); - - out<<endl; - - if (mpAudio != NULL) - { - for (i=0; i<numTabs; i++){out<<"\t";} - std::string audio_src = mpAudio->getSrc(); - - out<<"audio src = "; - out<<audio_src<<endl; - } - - out.close(); - -} Deleted: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.h 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/UiMediaTypes.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,74 +0,0 @@ - -#ifndef UIMEDIATYPES_H -#define UIMEDIATYPES_H - - -#include "../AmisCore/include/Media.h" - - - -namespace amis -{ -namespace gui -{ -namespace spoken -{ -class TextNode : public amis::TextNode -{ -public: - TextNode(); - ~TextNode(); - - std::string getMnemonic(); - void setMnemonic(std::string); - - TextNode* clone(); - -private: - std::string mMnemonic; - -}; - -enum ImageType {SMALL_ICON, LARGE_ICON}; - -class ImageNode : public amis::ImageNode -{ -public: - ImageNode(); - ~ImageNode(); - - ImageType getImageType(); - - void setImageType(ImageType); - -private: - ImageType mImageType; - -}; - -class TextAudioPair -{ -public: - TextAudioPair(); - ~TextAudioPair(); - - TextNode* getText(); - amis::AudioNode* getAudio(); - - void testPrint(std::string, int); - - void setText(TextNode*); - void setAudio(amis::AudioNode*); - TextAudioPair* clone(); - amis::MediaGroup* getAsAmisMediaGroup(); - - -private: - TextNode* mpText; - amis::AudioNode* mpAudio; - amis::MediaGroup* mpMediaGroupVersion; - - -}; -}}} -#endif \ No newline at end of file Added: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequence.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequence.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequence.cpp 2007-10-18 22:27:17 UTC (rev 2212) @@ -0,0 +1,73 @@ +#include "AudioSequence.h" + +using namespace amis::gui::spoken; + +AudioSequence::AudioSequence(){} + +AudioSequence::~AudioSequence(){ + if (m_AudioSequence.GetCount() > 0) + { + for (size_t i = 0; i < m_AudioSequence.GetCount(); i++) { + AudioSequenceComponent* comp = m_AudioSequence.GetAt(m_AudioSequence.FindIndex(i)); + delete comp; + } + + m_AudioSequence.RemoveAll(); + } + } + +UINT AudioSequence::GetCount() { + return m_AudioSequence.GetCount(); + } +bool AudioSequence::IsEmpty() { + return m_AudioSequence.GetCount() == 0; + } +AudioSequenceComponent* AudioSequence::RemoveTail() { + return m_AudioSequence.RemoveTail(); + }; +void AudioSequence::AddTail(AudioSequenceComponent* comp) { + m_AudioSequence.AddTail(comp); + } + void AudioSequence::append(CString strTTS) { + if (strTTS.IsEmpty()) { + TRACE(L"???????????????????????????"); + } + AudioSequenceComponent* comp = new AudioSequenceComponent; + comp->m_isAudioClip = false; + comp->m_AudioClip = 0; + comp->m_String = strTTS; + m_AudioSequence.AddHead(comp); + } +void AudioSequence::append(amis::AudioNode* audioClip) { + AudioSequenceComponent* comp = new AudioSequenceComponent; + comp->m_isAudioClip = TRUE; + comp->m_AudioClip = audioClip; + comp->m_String = L""; + m_AudioSequence.AddHead(comp); + } + void AudioSequence::prepend(CString strTTS) { + if (strTTS.IsEmpty()) { + TRACE(L"???????????????????????????"); + } + AudioSequenceComponent* comp = new AudioSequenceComponent; + comp->m_isAudioClip = false; + comp->m_AudioClip = 0; + comp->m_String = strTTS; + m_AudioSequence.AddTail(comp); + } + void AudioSequence::prepend(amis::AudioNode* audioClip) { + AudioSequenceComponent* comp = new AudioSequenceComponent; + comp->m_isAudioClip = TRUE; + comp->m_AudioClip = audioClip; + comp->m_String = L""; + m_AudioSequence.AddTail(comp); + } + AudioSequence* AudioSequence::clone() { + AudioSequence* seq = new AudioSequence; + for (size_t i = 0; i < m_AudioSequence.GetCount(); i++) { + AudioSequenceComponent* comp = m_AudioSequence.GetAt(m_AudioSequence.FindIndex(i))->clone(); + seq->AddTail(comp); + } + + return seq; + } \ No newline at end of file Added: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequence.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequence.h (rev 0) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequence.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -0,0 +1,45 @@ +#ifndef AudioSequence_H +#define AudioSequence_H + +#pragma once + +#include "AudioSequenceComponent.h" + + +//#include <atlstr.h> +#include <atlcoll.h> + + +#include "../AmisCore/include/Media.h" + + +namespace amis +{ +namespace gui +{ +namespace spoken +{ + +class AudioSequence +{ +public: + AudioSequence(); + ~AudioSequence(); + UINT GetCount(); + bool IsEmpty(); + AudioSequenceComponent* RemoveTail(); + void AddTail(AudioSequenceComponent* comp); + void append(CString strTTS); + void append(amis::AudioNode* audioClip); + void prepend(CString strTTS); + void prepend(amis::AudioNode* audioClip); + AudioSequence* clone(); +private: + CAtlList<AudioSequenceComponent*> m_AudioSequence; +}; + + +} +} +} +#endif \ No newline at end of file Added: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequenceComponent.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequenceComponent.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequenceComponent.cpp 2007-10-18 22:27:17 UTC (rev 2212) @@ -0,0 +1,29 @@ +#include "AudioSequenceComponent.h" + +using namespace amis::gui::spoken; + +AudioSequenceComponent::AudioSequenceComponent(){ + mWasCloned = false; + } +AudioSequenceComponent::~AudioSequenceComponent(){ +#ifdef XUSE_WSTRING + m_String = ""; +#else + m_String.Empty(); +#endif + + if (mWasCloned) { + delete m_AudioClip; + } + m_AudioClip = NULL; + } + +AudioSequenceComponent* AudioSequenceComponent::clone() { + AudioSequenceComponent* comp = new AudioSequenceComponent; + comp->m_AudioClip = (m_AudioClip ? (amis::AudioNode*)m_AudioClip->clone() : NULL); + comp->m_String = m_String; + comp->m_isAudioClip = m_isAudioClip; + comp->mWasCloned = true; + + return comp; +} \ No newline at end of file Added: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequenceComponent.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequenceComponent.h (rev 0) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequenceComponent.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -0,0 +1,48 @@ +#ifndef AudioSequenceComponent_H +#define AudioSequenceComponent_H + +#pragma once + +//#define XUSE_WSTRING + +#ifdef XUSE_WSTRING +#include <string> +#else +#ifndef __AFXWIN_H__ +#include <afxwin.h> +#endif +#endif + +#include "../AmisCore/include/Media.h" + + +namespace amis +{ +namespace gui +{ +namespace spoken +{ + +// -------------------------------- +class AudioSequenceComponent +{ +public: + AudioSequenceComponent(); + ~AudioSequenceComponent(); + AudioSequenceComponent* clone(); + BOOL m_isAudioClip; + bool mWasCloned; + +#ifdef XUSE_WSTRING + std::wstring m_String; +#else + CString m_String; +#endif + amis::AudioNode* m_AudioClip; +}; + + +} +} +} +#endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-10-18 22:27:17 UTC (rev 2212) @@ -1,5 +1,6 @@ +#include "AudioSequencePlayer.h" #include "TTSPlayer.h" @@ -9,23 +10,20 @@ #include "../AmisAudio/AmisAudio.h" + #include "../AmisGuiMFC2/include/Preferences.h" + #include <gui/MainWndParts.h> +#include "../AmisCore/include/Media.h" -#include <process.h> -#include <stdlib.h> +#include "gui/MmView.h" -#include "AudioSequencePlayer.h" - -#ifndef TRACE -#define TRACE ATLTRACE -#endif - - using namespace amis::audio; using namespace amis::tts; +using namespace amis::gui::spoken; + AudioSequencePlayer* AudioSequencePlayer::pinstance = 0; @@ -92,6 +90,7 @@ unsigned int threadID; + AmisAudio::Instance()->enable(); AmisAudio::Instance()->setCallback((sendMessageCallbackFn)clipFinishedCallback); TTSPlayer::Instance()->setCallback((sendMessageCallbackFn)ttsFinishedCallback); @@ -111,6 +110,9 @@ { Stop(); delete pinstance; + + AmisAudio::Instance()->DestroyInstance(); + TTSPlayer::Instance()->DestroyInstance(); } AudioSequencePlayer::~AudioSequencePlayer(void) @@ -497,3 +499,575 @@ return 0; } + + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +// This works for Containers (menus). +AudioSequence* AudioSequencePlayer::playPromptFromUiId(int nItemID, bool playImmediately, AudioSequence* seq) +{ +//amis::Preferences::Instance()->mbUseTTSNotAudio == true) + if (nItemID != -1) + { + amis::RecentBooks* books = theApp.getRecentBooks(); + + int nRecentBooks = (books ? books->getNumberOfEntries() : 0); + string strCondition; + + if (ID_MENU_PLAYPAUSE == nItemID) { + + MmView *view = MainWndParts::Instance()->mpMmView; + bool b_BookIsPlaying = MainWndParts::Instance()->mpMainFrame->mbWasPlayingWhenLostFocus || view->isPlaying(); // BOOK Audio Player + + strCondition = (b_BookIsPlaying ? "canPause" : "canPlay"); + + } else if (ID_FILE_RECENT_EMPTY == nItemID || (nItemID >= BOOK_BASE_ID && nItemID < BOOK_BASE_ID + nRecentBooks)) { + if (nRecentBooks > 0) { + strCondition = "BOOK_BASE_ID"; + } else { + strCondition = "ID_FILE_RECENT_EMPTY"; + } + } + + if (seq == NULL) { + seq = new AudioSequence; + } + //AppendAudioSequenceStringResource(seq, nItemID); + + UiItem* p_uiItem = DataTree::Instance()->findUiItemInContainers(nItemID, strCondition); + if (p_uiItem != NULL) { + + Label* keyboardShortcutAccelerator = NULL; + Label* mnemonic = NULL; + if (p_uiItem->getUiItemType() == ACTION) { + Action* action = (Action*)p_uiItem; + keyboardShortcutAccelerator = action->getKeyboardAccelerator(); + mnemonic = action->getMnemonic(); + } + else if (p_uiItem->getUiItemType() == CONTAINER) { + Container* container = (Container*)p_uiItem; + keyboardShortcutAccelerator = container->getKeyboardAccelerator(); + } + //fillSequenceCaptionAndDescription(seq, p_uiItem); + + Label* label = p_uiItem->getCaption(); + if (label != NULL) { + fillSequenceContentAndPrompt(seq, label); + } + if (mnemonic != NULL) { + fillSequenceContentAndPrompt(seq, mnemonic); + } + if (keyboardShortcutAccelerator != NULL) { + fillSequenceContentAndPrompt(seq, keyboardShortcutAccelerator); + } + label = p_uiItem->getDescription(); + if (label != NULL) { + fillSequenceContentAndPrompt(seq, label); + } + + } + 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 = playPromptItemFromStringId(strPrompt, false, NULL); + } + + } else { + + // Called for Show Section Depth (1, 2, 3, etc.) + // and for Recent-Files "Empty". + HWND hWnd = MainWndParts::Instance()->mpMainFrame->GetSafeHwnd(); + HMENU hMenu = ::GetMenu(hWnd); + + int nLen = ::GetMenuString(hMenu, nItemID, NULL, 0, MF_BYCOMMAND); + + if (nLen > 0) { + + LPTSTR lpszText = (LPTSTR)_alloca((nLen + 1) * sizeof(TCHAR)); + if (::GetMenuString(hMenu, nItemID, lpszText, nLen + 1, MF_BYCOMMAND) == nLen) { + + CString str; + str.Append(lpszText); + str.Replace(L"&", L""); + + CString strDebug; + strDebug.Format(_T("+++ 1 --%s--\n"), str); //DAN_MENU_DEBUG + TRACE(strDebug); + + if (! str.IsEmpty()) { + seq->append(str); + } + + //str.Empty(); + } + } + CString strText; + strText.LoadString( nItemID ); + + CString strDebug; + strDebug.Format(_T("+++ 2 --%s--\n"), strText); //DAN_MENU_DEBUG + TRACE(strDebug); + + if (! strText.IsEmpty()) { + seq->append(strText); + } + //strText.Empty(); + } + if (playImmediately) AudioSequencePlayer::Instance()->Play(seq); + return seq; + } + + return NULL; +} + + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +// This works for Containers (menus). +AudioSequence* AudioSequencePlayer::playContainerPromptFromId(string id, bool playImmediately, AudioSequence* seq) { + + + if (!id.empty()) { + Container* p_container = DataTree::Instance()->findContainer(id); + if (p_container != NULL) { + if (seq == NULL) { + seq = new AudioSequence; + } + + Label* keyboardShortcutAccelerator = p_container->getKeyboardAccelerator(); + + fillSequenceCaptionAndDescription(seq, p_container); + + if (keyboardShortcutAccelerator != NULL) { + fillSequenceContentAndPrompt(seq, keyboardShortcutAccelerator); + } + + if (playImmediately) AudioSequencePlayer::Instance()->Play(seq); + return seq; + } + } + return NULL; +} + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +// This works for Prompts. +AudioSequence* AudioSequencePlayer::playPromptFromStringId(string promptId, bool playImmediately, AudioSequence* seq, PromptResolver* pResolver) +{ + + + if (seq == NULL) { + seq = new AudioSequence; + } + //AppendAudioSequenceStringID(seq, promptId); + + + Prompt* p_prompt_ = DataTree::Instance()->findPrompt(promptId); + + if (p_prompt_ != NULL) + { + fillSequencePrompt(seq, p_prompt_, pResolver); + } + + + if (playImmediately) AudioSequencePlayer::Instance()->Play(seq); + return seq; +} + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +// This works for Prompts. +AudioSequence* AudioSequencePlayer::playPromptItemFromStringId(string promptId, bool playImmediately, AudioSequence* seq, PromptResolver* pResolver) +{ + + + + if (seq == NULL) { + seq = new AudioSequence; + } + + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem(promptId); + + if (p_prompt_ != NULL) + { + fillSequenceContents(seq, p_prompt_); + } + if (playImmediately) AudioSequencePlayer::Instance()->Play(seq); + return seq; +} + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +// This works for Dialogs, plays the instructions. +AudioSequence* AudioSequencePlayer::playDialogInstructionsFromUiId(int nItemID, bool playImmediately, AudioSequence* seq) { + + if (nItemID != -1) { + + + if (seq == NULL) { + seq = new AudioSequence; + } + //AppendAudioSequenceStringResource(seq, nItemID); + + Dialog* p_dialog = DataTree::Instance()->findDialog(nItemID); + if (p_dialog != NULL) { + Prompt* prompt = p_dialog->getPrompt("instructions"); + if (prompt != NULL) { + fillSequencePrompt(seq, prompt); + } + } + if (playImmediately) AudioSequencePlayer::Instance()->Play(seq, true); + return seq; + } + return NULL; +} + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +// This works for Dialogs +AudioSequence* AudioSequencePlayer::playDialogTextControlsFromUiId(int nItemID, bool playImmediately, AudioSequence* seq, string switchCondition) { + + if (nItemID != -1) { + + + if (seq == NULL) { + seq = new AudioSequence; + } + //AppendAudioSequenceStringResource(seq, nItemID); + + Dialog* p_dialog = DataTree::Instance()->findDialog(nItemID); + if (p_dialog != NULL) { + fillSequenceCaptionAndDescription(seq, p_dialog); + fillSequenceSwitch(seq, p_dialog, switchCondition); + + int count = p_dialog->getNumChildControls(); + for (int i = 0 ; i < count; i++) { + DialogControl* control = p_dialog->getChildControl(i); + string strCat = control->getWidgetCategories(); + int find = strCat.find("button"); + if (-1 == find) { + fillSequenceCaptionAndDescription(seq, control); + } + } + } + + if (playImmediately) AudioSequencePlayer::Instance()->Play(seq); + return seq; + } + return NULL; +} + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +// This works for Dialogs +AudioSequence* AudioSequencePlayer::playDialogControlFromUiIds(int dlgID, int ctrlId, bool playImmediately, AudioSequence* seq, string switchCondition) { + + if ( + (dlgID != -1 && ctrlId != -1) + || (dlgID == -1 && (ctrlId == IDOK || ctrlId == IDCANCEL)) + ) { + + + if (seq == NULL) { + 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); + } + }*/ + } + + + + + + + } else { + Dialog* p_dialog = DataTree::Instance()->findDialog(dlgID); + if (p_dialog != NULL) { + DialogControl* control = p_dialog->findControl(ctrlId); + + if (control != NULL) { + fillSequenceCaptionAndDescription(seq, control); + } + } + } + + if (playImmediately) AudioSequencePlayer::Instance()->Play(seq); + return seq; + } + return NULL; +} + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +void AudioSequencePlayer::fillSequencePrompt(AudioSequence* seq, Prompt* prompt, PromptResolver* pResolver) { + + resolvePromptVariables(prompt); + if (pResolver != NULL) { + pResolver->resolvePromptVariables(prompt); + } + + int sz = prompt->getNumberOfItems(); + for (int i=0; i<sz; i++) + { + PromptItemBase* pib = prompt->getItem(i); + switch(pib->getPromptItemType()) { + case PROMPT_ITEM: { + PromptItem* pi = (PromptItem*) pib; + fillSequenceContents(seq, pi); + break; + } + case PROMPT_VARIABLE: { + PromptVar* pv = (PromptVar*) pib; + //seq->append(pv->getName().c_str()); + fillSequenceContents(seq, pv); + break; + } + } + } +} + + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +void AudioSequencePlayer::fillSequenceCaptionAndDescription(AudioSequence* seq, UiItem* uiItem) { + + Label* label = uiItem->getCaption(); + if (label != NULL) { + fillSequenceContentAndPrompt(seq, label); + } + + label = uiItem->getDescription(); + if (label != NULL) { + fillSequenceContentAndPrompt(seq, label); + } +} + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +void AudioSequencePlayer::fillSequenceSwitch(AudioSequence* seq, UiItem* uiItem, string switchCondition) { + + Switch* zwitch; + if ((zwitch = uiItem->getSwitch()) != NULL) { + + switch(zwitch->getSwitchType()) { + case ACTIONSWITCH: { + Action* action = zwitch->getAction(switchCondition); + if (action != NULL) { + fillSequenceCaptionAndDescription(seq, action); + } + break; + } + case CAPTIONSWITCH: {} + case DESCRIPTIONSWITCH: { + Label* label = zwitch->getLabel(switchCondition); + if (label != NULL) { + fillSequenceContentAndPrompt(seq, label); + } + break; + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +void AudioSequencePlayer::fillSequenceContentAndPrompt(AudioSequence* seq, Label* label) +{ + TextAudioPair* pair = label->getContents(); + if (pair != NULL) { + amis::AudioNode* audio = pair->getAudio(); + if (!Preferences::Instance()->mbUseTTSNotAudio && audio != NULL) { + seq->append(audio); + } else { + TextNode* textN = pair->getText(); + if (textN != NULL) { + seq->append(textN->getTextString().c_str()); + } + } + } + + Prompt* prompt = label->getPrompt(); + if (prompt != NULL) + { + int count = prompt->getNumberOfItems(); + for (int i=0; i<count; i++) + { + PromptItemBase* pib = prompt->getItem(i); + switch(pib->getPromptItemType()) + { + case PROMPT_ITEM: + { + PromptItem* pi = (PromptItem*) pib; + + pair = pi->getContents(); + if (pair != NULL) + { + amis::AudioNode* audio = pair->getAudio(); + if (!Preferences::Instance()->mbUseTTSNotAudio && audio != NULL) + { + seq->append(audio); + } else + { + TextNode * textN = pair->getText(); + if (textN != NULL) + { + seq->append(textN->getTextString().c_str()); + } + } + } + break; + } + case PROMPT_VARIABLE: { + PromptVar* pv = (PromptVar*) pib; + + //We assume variable value resolution happened before. + + pair = pv->getContents(); + if (pair != NULL) + { + amis::AudioNode* audio = pair->getAudio(); + if (!Preferences::Instance()->mbUseTTSNotAudio && audio != NULL) + { + seq->append(audio); + } else + { + TextNode * textN = pair->getText(); + if (textN != NULL) + { + seq->append(textN->getTextString().c_str()); + } + } + } + break; + } + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +void AudioSequencePlayer::fillSequenceContents(AudioSequence* seq, PromptItemBase* pi) { + + TextAudioPair* pair = pi->getContents(); + if (pair != NULL) { + amis::AudioNode* audio = pair->getAudio(); + if (!Preferences::Instance()->mbUseTTSNotAudio && audio != NULL) { + seq->append(audio); + } else { + TextNode * textN = pair->getText(); + if (textN != NULL) { + seq->append(textN->getTextString().c_str()); + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////// +//the new one +void AudioSequencePlayer::resolvePromptVariables(Prompt* pPrompt) +{ + USES_CONVERSION; + + PromptVar* p_var = NULL; + + for (int i=0; i<pPrompt->getNumberOfItems(); i++) + { + if (pPrompt->getItem(i)->getPromptItemType() == PROMPT_VARIABLE) + { + p_var = (PromptVar*)pPrompt->getItem(i); + + if (p_var->getName() == "BOOK_PATH") + { + //CString file_path = A2CW(mFilePath.c_str()); + //p_var->setContents(LPCTSTR(file_path), ""); + //DanToDo: is this variable actually used anywhere ? If yes, where do I get the current book path from ? + //amis::dtb::DtbWithHooks::Instance()-> + } + } + } +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h 2007-10-18 18:33:06 UTC (rev 2211) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h 2007-10-18 22:27:17 UTC (rev 2212) @@ -3,14 +3,19 @@ #pragma once -#include <atlstr.h> -#include <atlcoll.h> +#include <process.h> +#include <stdlib.h> -#include <afxwin.h> -#include <afxext.h> +#ifndef TRACE +#define TRACE ATLTRACE +#endif -#include "../AmisCore/include/Media.h" +#include "./AccessibleUI/UiItem.h" +#include "./promptresolver.h" +//#include "AudioSequenceComponent.h" +#include "AudioSequence.h" +using namespace amis::gui::spoken; namespace amis { @@ -20,111 +25,27 @@ { // -------------------------------- -class AudioSequenceComponent +class CCS { +private: + LPCRITICAL_SECTION m_lpCS; + public: - __inline AudioSequenceComponent(){ - mWasCloned = false; - }; - __inline ~AudioSequenceComponent(){ - m_String.Empty(); - if (mWasCloned) { - delete m_AudioClip; - } - m_AudioClip = NULL; - }; + __inline CCS(LPCRITICAL_SECTION lpCS): m_lpCS(NULL) + { + _ASSERT(lpCS != NULL); - __inline AudioSequenceComponent* clone() { - AudioSequenceComponent* comp = new AudioSequenceComponent; - comp->m_AudioClip = (m_AudioClip ? (amis::AudioNode*)m_AudioClip->clone() : NULL); - comp->m_String = m_String; - comp->m_isAudioClip = m_isAudioClip; - comp->mWasCloned = true; - - return comp; - }; - BOOL m_isAudioClip; - bool mWasCloned; - CString m_String; - amis::AudioNode* m_AudioClip; -}; + m_lpCS = lpCS; // Save + EnterCriticalSection(lpCS); + } -// -------------------------------- -class AudioSequence -{ -public: - __inline AudioSequence(){}; - __inline ~AudioSequence(){ - if (m_AudioSequence.GetCount() > 0) - { - for (size_t i = 0; i < m_AudioSequence.GetCount(); i++) { - AudioSequenceComponent* comp = m_AudioSequence.GetAt(m_AudioSequence.FindIndex(i)); - delete comp; - } - - m_AudioSequence.RemoveAll(); - } - }; - __inline UINT GetCount() { - return m_AudioSequence.GetCount(); - }; - __inline bool IsEmpty() { - return m_AudioSequence.GetCount() == 0; - }; - __inline AudioSequenceComponent* RemoveTail() { - return m_AudioSequence.RemoveTail(); - }; - __inline void AddTail(AudioSequenceComponent* comp) { - m_AudioSequence.AddTail(comp); - }; - __inline void append(CString strTTS) { - if (strTTS.IsEmpty()) { - TRACE(L"???????????????????????????"); - } - AudioSequenceComponent* comp = new AudioSequenceComponent; - comp->m_isAudioClip = false; - comp->m_AudioClip = 0; - comp->m_String = strTTS; - m_AudioSequence.AddHead(comp); - }; - __inline void append(amis::AudioNode* audioClip) { - AudioSequenceComponent* comp = new AudioSequenceComponent; - comp->m_isAudioClip = TRUE; - comp->m_AudioClip = audioClip; - comp->m_String = L""; - m_AudioSequence.AddHead(comp); - }; - __inline void prepend(CString strTTS) { - if (strTTS.IsEmpty()) { - TRACE(L"???????????????????????????"); - } - AudioSequenceComponent* comp = new AudioSequenceComponent; - comp->m_isAudioClip = false; - comp->m_AudioClip = 0; - comp->m_String = strTTS; - m_AudioSequence.AddTail(comp); - }; - __inline void prepend(amis::AudioNode* audioClip) { - AudioSequenceComponent* comp = new AudioSequenceComponent; - comp->m_isAudioClip = TRUE; - comp->m_AudioClip = audioClip; - comp->m_String = L""; - m_AudioSequence.AddTail(comp); - }; - __inline AudioSequence* clone() { - AudioSequence* seq = new AudioSequence; - for (size_t i = 0; i < m_AudioSequence.GetCount(); i++) { - AudioSequenceComponent* comp = m_AudioSequence.GetAt(m_AudioSequence.FindIndex(i))->clone(); - seq->AddTail(comp); - } - - return seq; - }; -private: - CAtlList<AudioSequenceComponent*> m_AudioSequence; + __inline ~CCS() + { + if (m_lpCS != NULL) + LeaveCriticalSection(m_lpCS); + } }; -// -------------------------------- class AudioSequencePlayer { @@ -157,28 +78,27 @@ HANDLE m_hEventWakeup; CRITICAL_SECTION m_csSequence; bool m_bAbort; -}; -// -------------------------------- -class CCS -{ -private: - LPCRITICAL_SECTION m_lpCS; - public: - __inline CCS(LPCRITICAL_SECTION lpCS): m_lpCS(NULL) - { - _ASSERT(lpCS != NULL); - m_lpCS = lpCS; // Save - EnterCriticalSection(lpCS); - } + //static void AppendAudioSequenceStringResource(AudioSequence* seq, int nItemID); + //static void AppendAudioSequenceStringID(AudioSequence* seq, string); - __inline ~CCS() - { - if (m_lpCS != NULL) - LeaveCriticalSection(m_lpCS); - } + static AudioSequence* playPromptFromUiId(int nItemID, bool playImmediately = true, AudioSequence* seq = NULL); + static AudioSequence* playContainerPromptFromId(string id, bool playImmediately, AudioSequence* seq = NULL); + static AudioSequence* playPromptFromStringId(string, bool playImmediately = true, AudioSequence* seq = NULL, PromptResolver* pResolver = NULL); + static AudioSequence* playPromptItemFromStringId(string, bool playImmediately = true, AudioSequence* seq = NULL, PromptResolver* pResolver = NULL); + static AudioSequence* playDialogInstructionsFromUiId(int nItemID, bool playImmediately = true, AudioSequence* seq = NULL); + static AudioSequence* playDialogTextControlsFromUiId(int nItemID, bool playImmediately = true, AudioSequence* seq = NULL, string switchCondition = ""); + static AudioSequence* playDialogControlFromUiIds(int dlgID, int ctrlId, bool playImmediately = true, AudioSequence* seq = NULL, string switchCondition = ""); + + static void fillSequencePrompt(AudioSequence* seq, Prompt* prompt, PromptResolver* pResolver = NULL); + static void fillSequenceCaptionAndDescription(AudioSequence* seq, UiItem* uiItem); + static void fillSequenceSwitch(AudioSequence* seq, UiItem* uiItem, string switchCondition = ""); + static void fillSequenceContentAndPrompt(AudioSequence* seq, Label* label); + static void fillSequenceContents(AudioSequence* seq, PromptItemBase* pi); + + static void resolvePromptVariables(Prompt*); }; } Added: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.cpp 2007-10-18 22:27:17 UTC (rev 2212) @@ -0,0 +1,409 @@ + +#include ".\pretranslatemessagehandler.h" +//#include "gui/AmisGuiMFC2.h" + +PreTranslateMessageHandler::PreTranslateMessageHandler(int idUiDialog) +{ + m_instructionsDialogID = idUiDialog; + mbKeyControl = false; + mLastKeyDown = -1; + mSeq = NULL; +} + +PreTranslateMessageHandler::~PreTranslateMessageHandler(void) +{ +} + +bool PreTranslateMessageHandler::isControlPressed() { + return mbKeyControl; +} + +CString PreTranslateMessageHandler::normalizeTextEntry(CString str, int nStartChar, int nEndChar) { + + CString strNew = str; + if (nStartChar == nEndChar && nStartChar != -1) { + if (nStartChar >= str.GetLength()) { + //str = L""; + } else { + strNew = str.Mid(nStartChar, 1); + } + } else if (nStartChar != -1 && nEndChar != -1) { + strNew = str.Mid(nStartChar, nEndChar-nStartChar); + } + return strNew; +} + +CString PreTranslateMessageHandler::convertKeystrokeToSpeakableString(WPARAM ch, bool ignoreSpaceKey, bool ignoreArrowKeys, bool ignoreCharKeys) +{ + + CString cstr; + if (!ignoreCharKeys) + { + switch (ch) + { + case 0x08: + + // Process a backspace. + + break; + + case 0x0A: + + // Process a linefeed. + + break; + + case 0x1B: + + // Process an escape. + + break; + + case 0x09: + + // Process a tab. + + break; + + case 0x0D: + + // Process a carriage return. + + break; + + default: + + // Process displayable characters. + + //echo keystrokes + cstr.AppendChar(ch); + /*if (cstr == L".") { + cstr = L"dot"; + } else if (cstr == L"-") { + cstr = L"minus"; +... [truncated message content] |
From: <dan...@us...> - 2007-10-19 06:00:02
|
Revision: 2218 http://amis.svn.sourceforge.net/amis/?rev=2218&view=rev Author: daniel_weck Date: 2007-10-18 23:00:03 -0700 (Thu, 18 Oct 2007) Log Message: ----------- - Daniel WECK * Attempt to compile+link Amis3 in Release mode...no success so far. Modified Paths: -------------- branches/amis3/AmisAudio/AmisAudio.cpp branches/amis3/AmisAudio/AmisAudio.vcproj branches/amis3/AmisCore/AmisCore.vcproj branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUiDataReader.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequence.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequenceComponent.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/UiMediaTypes.h branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/GoToPageDialog.cpp branches/amis3/VC7/amis.sln Modified: branches/amis3/AmisAudio/AmisAudio.cpp =================================================================== --- branches/amis3/AmisAudio/AmisAudio.cpp 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisAudio/AmisAudio.cpp 2007-10-19 06:00:03 UTC (rev 2218) @@ -54,6 +54,10 @@ */ +namespace amis +{ +namespace audio +{ AmisAudio* AmisAudio::pinstance = 0; AmisAudio* AmisAudio::Instance() @@ -630,3 +634,4 @@ return mbAudioPlaybackEnabled; } +}} \ No newline at end of file Modified: branches/amis3/AmisAudio/AmisAudio.vcproj =================================================================== --- branches/amis3/AmisAudio/AmisAudio.vcproj 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisAudio/AmisAudio.vcproj 2007-10-19 06:00:03 UTC (rev 2218) @@ -43,7 +43,7 @@ <Tool Name="VCLinkerTool" AdditionalOptions="/FORCE:MULTIPLE" - AdditionalDependencies="Strmiids.lib TransformSample.lib stlib.lib kernel32.lib gdi32.lib user32.lib ../lib/AmisCoreD.lib" + AdditionalDependencies="Strmiids.lib TransformSample.lib stlib.lib kernel32.lib gdi32.lib user32.lib AmisCoreD.lib" ShowProgress="2" OutputFile="../bin/AmisAudioD.dll" LinkIncremental="1" @@ -85,20 +85,20 @@ </Configuration> <Configuration Name="Release|Win32" - OutputDirectory=".\../bin" - IntermediateDirectory=".\tmp" - ConfigurationType="2" - UseOfMFC="2" + OutputDirectory="../lib" + IntermediateDirectory="Release" + ConfigurationType="4" + UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="1"> <Tool Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories=""../3rdPartyAudio"; "../mffmTimeCode"" + AdditionalIncludeDirectories=""../AmisGuiMFC2/include/";"../AmisCore/include/"" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;AMISAUDIO_EXPORTS" StringPooling="TRUE" - RuntimeLibrary="2" + RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" UsePrecompiledHeader="0" PrecompiledHeaderThrough="stdafx.h" @@ -108,20 +108,11 @@ ProgramDataBaseFileName=".\tmp/" WarningLevel="3" SuppressStartupBanner="TRUE" - CompileAs="0"/> + CompileAs="2"/> <Tool Name="VCCustomBuildTool"/> <Tool - Name="VCLinkerTool" - AdditionalDependencies="Strmiids.lib stlib.lib kernel32.lib gdi32.lib user32.lib AmisCommon.lib" - OutputFile=".\../bin/AmisAudio.dll" - LinkIncremental="1" - SuppressStartupBanner="TRUE" - AdditionalLibraryDirectories="../lib" - IgnoreDefaultLibraryNames="libc.lib" - ProgramDatabaseFile="./tmp/AmisAudio.pdb" - ImportLibrary="../lib/AmisAudio.lib" - TargetMachine="1"/> + Name="VCLibrarianTool"/> <Tool Name="VCMIDLTool" PreprocessorDefinitions="NDEBUG" @@ -145,8 +136,6 @@ <Tool Name="VCXMLDataGeneratorTool"/> <Tool - Name="VCWebDeploymentTool"/> - <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Modified: branches/amis3/AmisCore/AmisCore.vcproj =================================================================== --- branches/amis3/AmisCore/AmisCore.vcproj 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisCore/AmisCore.vcproj 2007-10-19 06:00:03 UTC (rev 2218) @@ -66,10 +66,11 @@ AdditionalIncludeDirectories="./include; ../../../../xerces-c-src/src;../../../../ambulant/include" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" RuntimeLibrary="0" + EnableFunctionLevelLinking="TRUE" UsePrecompiledHeader="0" WarningLevel="3" - Detect64BitPortabilityProblems="TRUE" - DebugInformationFormat="3"/> + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="0"/> <Tool Name="VCCustomBuildTool"/> <Tool Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-10-19 06:00:03 UTC (rev 2218) @@ -20,7 +20,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="include;../../../../ambulant/include/;"../../../../ambulant-private/pdtbplugin";"../../../../ambulant-private/pdtbplugin/PdtbIePlugin";../AmisCore/include;"../../../../xerces-c-src/src";../3rdPartyAudio;../mffmTimeCode;"$(VSInstallDir)\..\Microsoft Speech SDK 5.1\Include"" + AdditionalIncludeDirectories="include;../../../../ambulant/include/;"../../../../ambulant-private/pdtbplugin";"../../../../ambulant-private/pdtbplugin/PdtbIePlugin";../AmisCore/include;"../../../../xerces-c-src/src";"$(VSInstallDir)\..\Microsoft Speech SDK 5.1\Include"" PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG" MinimalRebuild="TRUE" BasicRuntimeChecks="3" @@ -35,7 +35,7 @@ Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" - AdditionalDependencies="AmisCoreD.lib xerces-c_2D.lib libambulant_shwin32_D.lib AmisAudioD.lib vorbisfile_static.lib vorbisenc_static.lib vorbis_static.lib ogg_static.lib libmad.lib stlib.lib fftw3.lib audiere.lib" + AdditionalDependencies="AmisCoreD.lib xerces-c_2D.lib libambulant_shwin32_D.lib AmisAudioD.lib" LinkIncremental="2" AdditionalLibraryDirectories="../lib;../../../../ambulant/lib/win32;"$(VSInstallDir)\..\Microsoft Speech SDK 5.1\Lib\i386"" IgnoreDefaultLibraryNames="uafxcwd.lib;uafxcw.lib;LIBCD.lib;LIBC.lib;msvcrt.lib;libcmt.lib" @@ -75,13 +75,14 @@ IntermediateDirectory="Release" ConfigurationType="1" UseOfMFC="2" - CharacterSet="2"> + CharacterSet="1"> <Tool Name="VCCLCompilerTool" + AdditionalIncludeDirectories="include;../../../../ambulant/include/;"../../../../ambulant-private/pdtbplugin";"../../../../ambulant-private/pdtbplugin/PdtbIePlugin";../AmisCore/include;"../../../../xerces-c-src/src";"$(VSInstallDir)\..\Microsoft Speech SDK 5.1\Include"" PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG" MinimalRebuild="FALSE" RuntimeLibrary="2" - TreatWChar_tAsBuiltInType="TRUE" + TreatWChar_tAsBuiltInType="FALSE" UsePrecompiledHeader="3" WarningLevel="3" Detect64BitPortabilityProblems="TRUE" @@ -90,7 +91,11 @@ Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" + AdditionalDependencies="Strmiids.lib UAFXCW.LIB msvcrt.lib AmisCore.lib AmisAudio.lib xerces-c_2.lib libambulant_shwin32.lib " LinkIncremental="1" + AdditionalLibraryDirectories="../lib;../../../../ambulant/lib/win32;"$(VSInstallDir)\..\Microsoft Speech SDK 5.1\Lib\i386"" + IgnoreAllDefaultLibraries="FALSE" + IgnoreDefaultLibraryNames="UAFXCW.LIB;libcpmt.lib;msvcprt.lib;libcmt.lib;msvcrt.lib" GenerateDebugInformation="TRUE" SubSystem="2" OptimizeReferences="2" @@ -269,12 +274,30 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\pdtb.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\Preferences.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\stdafx.cpp"> @@ -284,6 +307,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="1"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <Filter Name="io" @@ -296,6 +325,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> </Filter> <Filter @@ -303,18 +338,48 @@ Filter=""> <File RelativePath=".\src\gui\AmisGuiMFC2.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\ChildFrm.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\HtmlDoc.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\HtmlView.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\MainFrm.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\MainWndParts.cpp"> @@ -324,24 +389,60 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\MenuManip.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\MmDoc.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\MmView.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\TextRenderBrain.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <Filter Name="dialogs" Filter=""> <File RelativePath=".\src\gui\dialogs\AboutDialog.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\dialogs\AmisDialogBase.cpp"> @@ -351,18 +452,48 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\dialogs\AmisFileDialog.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\dialogs\GoToPageDialog.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\dialogs\OpenUrlDialog.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\dialogs\SkipDialog.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> </Filter> <Filter @@ -370,6 +501,12 @@ Filter=""> <File RelativePath=".\src\gui\sidebar\AmisSidebar.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\sidebar\AmisSidebarLoader.cpp"> @@ -379,36 +516,102 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\sidebar\cdxCDynamicBar.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\sidebar\cdxCDynamicControlsManager.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\sidebar\cdxCDynamicDialog.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\sidebar\cdxCDynamicWnd.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\sidebar\cdxCDynamicWndEx.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\sidebar\cdxCSizeIconCtrl.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\sidebar\NavListControl.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\sidebar\scbarcf.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\sidebar\scbarg.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\src\gui\sidebar\SizeCBar.cpp"> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> </Filter> </Filter> @@ -424,6 +627,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AudioSequence.h"> @@ -436,6 +645,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AudioSequenceComponent.h"> @@ -448,6 +663,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AudioSequencePlayer.h"> @@ -460,6 +681,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\PreTranslateMessageHandler.h"> @@ -472,6 +699,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\Prompt.h"> @@ -484,6 +717,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\PromptResolver.h"> @@ -496,6 +735,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\TTSPlayer.h"> @@ -508,6 +753,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\UiMediaTypes.h"> @@ -523,6 +774,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\AccessibleUiDataReader.h"> @@ -535,6 +792,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\Action.h"> @@ -547,6 +810,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\AudioPrompt.h"> @@ -559,6 +828,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\AudioPromptReader.h"> @@ -571,6 +846,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\Container.h"> @@ -583,6 +864,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\DataTree.h"> @@ -595,6 +882,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\Dialog.h"> @@ -607,6 +900,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\DialogControl.h"> @@ -619,6 +918,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\IniFile.h"> @@ -631,6 +936,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\Label.h"> @@ -643,6 +954,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\LabelList.h"> @@ -655,6 +972,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\Switch.h"> @@ -667,6 +990,12 @@ Name="VCCLCompilerTool" UsePrecompiledHeader="0"/> </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> </File> <File RelativePath=".\AmisSelfVoicing\AccessibleUI\UiItem.h"> Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp 2007-10-19 06:00:03 UTC (rev 2218) @@ -20,8 +20,8 @@ #include "AccessibleUiDataReader.h" #include "Switch.h" -#include "../AmisGuiMFC2/include/Preferences.h" -#include "../AmisCore/include/util/FilePathTools.h" +#include "Preferences.h" +#include "util/FilePathTools.h" #include "util/xercesutils.h" Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUiDataReader.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUiDataReader.h 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUiDataReader.h 2007-10-19 06:00:03 UTC (rev 2218) @@ -30,7 +30,7 @@ #include "UiItem.h" -#include "../AmisCore/include/Error.h" +#include "Error.h" //NAMESPACES XERCES_CPP_NAMESPACE_USE Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.h 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPrompt.h 2007-10-19 06:00:03 UTC (rev 2218) @@ -3,7 +3,7 @@ #include <string> -#include "../AmisCore/include/Media.h" +#include "Media.h" //!prompt variable structure /*! Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.cpp 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.cpp 2007-10-19 06:00:03 UTC (rev 2218) @@ -159,10 +159,10 @@ p_prompt_var->mVarName.assign(name); XMLString::release(&name); //DANIEL MEMORY LEAK VERIFIED - p_prompt_var->mRuntimeValue = _T(""); + p_prompt_var->mRuntimeValue = L""; p_prompt_var->mbIsVar = true; - p_prompt_var->mTextAlternative = _T(""); + p_prompt_var->mTextAlternative = L""; mpCurrentPrompt->mSequence.push_back(p_prompt_var); } @@ -211,7 +211,7 @@ } p_pc->mbIsVar = false; - p_pc->mRuntimeValue = _T(""); + p_pc->mRuntimeValue = L""; p_pc->mVarName = ""; p_pc->mpMedia = p_audio; Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.h 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AudioPromptReader.h 2007-10-19 06:00:03 UTC (rev 2218) @@ -27,7 +27,7 @@ //XERCES INCLUDES #include <xercesc/sax2/DefaultHandler.hpp> -#include "../AmisCore/include/Media.h" +#include "Media.h" #include "AudioPrompt.h" Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.cpp 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/Switch.cpp 2007-10-19 06:00:03 UTC (rev 2218) @@ -1,6 +1,6 @@ #include "Switch.h" -#include "../AmisGuiMFC2/resource.h" +#include "../../AmisGuiMFC2/resource.h" //#include "../AudioAudio/AmisAudio.h" #include <fstream> Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequence.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequence.h 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequence.h 2007-10-19 06:00:03 UTC (rev 2218) @@ -10,7 +10,7 @@ #include <atlcoll.h> -#include "../AmisCore/include/Media.h" +#include "Media.h" namespace amis Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequenceComponent.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequenceComponent.h 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequenceComponent.h 2007-10-19 06:00:03 UTC (rev 2218) @@ -13,7 +13,7 @@ #endif #endif -#include "../AmisCore/include/Media.h" +#include "Media.h" namespace amis Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-10-19 06:00:03 UTC (rev 2218) @@ -8,13 +8,13 @@ #include "util/FilePathTools.h" -#include "../AmisAudio/AmisAudio.h" +#include "../../AmisAudio/AmisAudio.h" -#include "../AmisGuiMFC2/include/Preferences.h" +#include "Preferences.h" #include <gui/MainWndParts.h> -#include "../AmisCore/include/Media.h" +#include "Media.h" #include "gui/MmView.h" @@ -315,6 +315,7 @@ } unsigned __stdcall AudioSequencePlayer::ThreadProc(void* Arg) { + USES_CONVERSION; _ASSERT(Arg != NULL); @@ -476,6 +477,10 @@ strDebug.Format(_T("============ PLAY AUDIO TTS: --%s--\n"), comp->m_String); TRACE(strDebug); if (!TTSPlayer::Instance()->IsSpeaking()) { + + //LPCWSTR str = T2W(comp->m_String); + //std::wstring str = (LPCTSTR)comp->m_String.GetBuffer(); + //comp->m_String.ReleaseBuffer(); TTSPlayer::Instance()->Play(comp->m_String); delete comp; } else { @@ -630,7 +635,7 @@ CString str; str.Append(lpszText); - str.Replace(L"&", L""); + str.Replace(CString("&"), CString("")); CString strDebug; strDebug.Format(_T("+++ 1 --%s--\n"), str); //DAN_MENU_DEBUG Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.h 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.h 2007-10-19 06:00:03 UTC (rev 2218) @@ -25,8 +25,8 @@ int idUiFocus, bool ignoreSpaceKey = false, bool ignoreArrowKeys = false, - CString strTextField = L"", - CString strTextFieldFULL = L"", + CString strTextField = CString(L""), + CString strTextFieldFULL = CString(L""), bool ignoreCharKeys = false); private: Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp 2007-10-19 06:00:03 UTC (rev 2218) @@ -20,8 +20,8 @@ //#include <gui/MainWndParts.h> -#include "../AmisGuiMFC2/include/Preferences.h" -#include "../AmisGuiMFC2/resource.h" +#include "Preferences.h" +#include "../../AmisGuiMFC2/resource.h" using namespace amis::tts; @@ -63,32 +63,43 @@ } // between -10 and 10. 0 is default rate (engine dependant). -BOOL TTSPlayer::SetSpeechRate(long newRate) +bool TTSPlayer::SetSpeechRate(long newRate) { HRESULT hr = 0; hr = m_iV->SetRate(newRate); if (SUCCEEDED(hr)) { - return TRUE; + return true; } else if (hr == E_INVALIDARG) { - return FALSE; + return false; } else { _ASSERT(0); - return FALSE; // Should never happen ! + return false; // Should never happen ! } } #ifdef USE_WSTRING void TTSPlayer::Play(std::wstring str) +{ #else void TTSPlayer::Play(CString str) +{ + USES_CONVERSION; #endif -{ + TRACE(L"******"); TRACE(str); if (IsSpeaking()) { TRACE("????????"); } + + +#ifdef USE_WSTRING m_iV->Speak(str, SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL); + #else + + //LPCWSTR str_ = T2W(str); +m_iV->Speak(str, SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL); +#endif } void TTSPlayer::Stop() @@ -156,7 +167,7 @@ } } -BOOL TTSPlayer::IsSpeaking(void) {return m_isSpeaking;} +bool TTSPlayer::IsSpeaking(void) {return m_isSpeaking;} TTSPlayer::TTSPlayer(void) : m_currentVoiceNumber(-1) Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.h 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.h 2007-10-19 06:00:03 UTC (rev 2218) @@ -39,16 +39,16 @@ void WaitUntilDone(); long GetSpeechRate(); - BOOL SetSpeechRate(long newRate); + bool SetSpeechRate(long newRate); void ChangeVoice(bool speakNotify); void ChangeVoice(int index); int initVoiceList(HWND); -BOOL IsSpeaking(void); +bool IsSpeaking(void); - BOOL m_isSpeaking; + bool m_isSpeaking; static TTSPlayer* pinstance; Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/UiMediaTypes.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/UiMediaTypes.h 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/UiMediaTypes.h 2007-10-19 06:00:03 UTC (rev 2218) @@ -3,7 +3,7 @@ #define UIMEDIATYPES_H -#include "../AmisCore/include/Media.h" +#include "Media.h" Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-10-19 06:00:03 UTC (rev 2218) @@ -27,6 +27,8 @@ #error include 'stdafx.h' before including this file for PCH #endif +///This gets rid of some warnings +#pragma warning(disable : 4049) #include "resource.h" // main symbols #include <string> Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-10-19 06:00:03 UTC (rev 2218) @@ -219,7 +219,7 @@ { amis::MediaGroup* p_media = new amis::MediaGroup(); amis::TextNode* p_text = new amis::TextNode(); - p_text->setTextString(_T("sections")); + p_text->setTextString(L"sections"); p_media->setText(p_text); p_map->setLabel(p_media); } @@ -235,7 +235,7 @@ { amis::MediaGroup* p_media = new amis::MediaGroup(); amis::TextNode* p_text = new amis::TextNode(); - p_text->setTextString(_T("pages")); + p_text->setTextString(L"pages"); p_media->setText(p_text); p_pages->setLabel(p_media); } @@ -254,7 +254,7 @@ { amis::MediaGroup* p_media = new amis::MediaGroup(); amis::TextNode* p_text = new amis::TextNode(); - p_text->setTextString(_T("")); + p_text->setTextString(L""); p_media->setText(p_text); ((*p_lists)[i])->setLabel(p_media); } @@ -273,38 +273,38 @@ if (id.compare("sidebar") == 0 || id.compare("sidebars") == 0) { - search_for.assign(_T("sidebars")); + search_for.assign(L"sidebars"); } else if (id.compare("optional-prodnote") == 0 || id.compare("optional-prodnotes") == 0 || id.compare("prodnote") == 0 || id.compare("prodnotes") == 0) { - search_for.assign(_T("prodnotes")); + search_for.assign(L"prodnotes"); } else if (id.compare("noteref") == 0 || id.compare("noterefs") == 0 || id.compare("footnote") == 0 || id.compare("footnotes") == 0) { - search_for.assign(_T("noterefs")); + search_for.assign(L"noterefs"); } else if (id.compare("group") == 0 || id.compare("groups") == 0) { - search_for.assign(_T("groups")); + search_for.assign(L"groups"); } else if (id.compare("page") == 0 || id.compare("pages") == 0 || id.compare("pagenumber") == 0 || id.compare("pagenumbers") == 0) { - search_for.assign(_T("pages")); + search_for.assign(L"pages"); } else if (id.compare("section") == 0 || id.compare("sections") == 0) { - search_for.assign(_T("sections")); + search_for.assign(L"sections"); } //TODO: match the item in the accessible UI data set @@ -352,7 +352,9 @@ //set the spine at this file. this also makes sure that we're going to a file that is in the book. if (getSpine()->goToFile(&full_path)) { - amis::gui::MainWndParts::Instance()->mpMmDoc->OnOpenDocument(A2T(full_path.get_url().c_str())); + + LPCTSTR str_ = A2T(full_path.get_url().c_str()); //(LPSTR) + amis::gui::MainWndParts::Instance()->mpMmDoc->OnOpenDocument(str_); } //DanToDo: Is this the best place to set the PLAY/PAUSE status ? (is the book actually playing at this stage...probably not) theApp.setPauseState(false); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-10-19 06:00:03 UTC (rev 2218) @@ -315,7 +315,7 @@ void CAmisGuiMFC2App::openBook(const ambulant::net::url* filename) { - MainWndParts::Instance()->updateTitleBar(MainWndParts::TITLEBAR_APPNAME, L"Amis"); + MainWndParts::Instance()->updateTitleBar(MainWndParts::TITLEBAR_APPNAME, CString(L"Amis")); MainWndParts::Instance()->updateTitleViewMode(); MainWndParts::Instance()->updateTitleSelfVoicing(Preferences::Instance()->mbIsSelfVoicing); Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/GoToPageDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/GoToPageDialog.cpp 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/GoToPageDialog.cpp 2007-10-19 06:00:03 UTC (rev 2218) @@ -62,7 +62,7 @@ std::wstring GoToPageDialog::getPageNumber() { - return m_PageNumber.Trim(); + return m_PageNumber.Trim().GetBuffer(); } Modified: branches/amis3/VC7/amis.sln =================================================================== --- branches/amis3/VC7/amis.sln 2007-10-19 01:24:52 UTC (rev 2217) +++ branches/amis3/VC7/amis.sln 2007-10-19 06:00:03 UTC (rev 2218) @@ -38,7 +38,6 @@ {E0F81CE5-9C15-4E36-BC71-42BE1C0F2406}.Debug.ActiveCfg = Debug|Win32 {E0F81CE5-9C15-4E36-BC71-42BE1C0F2406}.Debug.Build.0 = Debug|Win32 {E0F81CE5-9C15-4E36-BC71-42BE1C0F2406}.Release.ActiveCfg = Release|Win32 - {E0F81CE5-9C15-4E36-BC71-42BE1C0F2406}.Release.Build.0 = Release|Win32 {A7A37247-BAAC-4376-8354-96A8C09F926A}.Debug.ActiveCfg = Debug|Win32 {A7A37247-BAAC-4376-8354-96A8C09F926A}.Debug.Build.0 = Debug|Win32 {A7A37247-BAAC-4376-8354-96A8C09F926A}.Release.ActiveCfg = Release|Win32 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-11-05 16:19:46
|
Revision: 2220 http://amis.svn.sourceforge.net/amis/?rev=2220&view=rev Author: marisademeglio Date: 2007-11-05 08:19:49 -0800 (Mon, 05 Nov 2007) Log Message: ----------- Added open URL menu item and dialog to amisAccessibleUi.xml Added generic and MFC-specific search text functions. Need to replace annoying pop-up command window with this instead. Modified Paths: -------------- branches/amis3/AmisCore/AmisCore.vcproj branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/src/Preferences.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/DefaultLangpack/amisAccessibleUi.xml Added Paths: ----------- branches/amis3/AmisCore/include/util/SearchForFiles.h branches/amis3/AmisCore/src/util/SearchForFiles.cpp branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp Modified: branches/amis3/AmisCore/AmisCore.vcproj =================================================================== --- branches/amis3/AmisCore/AmisCore.vcproj 2007-10-22 00:36:38 UTC (rev 2219) +++ branches/amis3/AmisCore/AmisCore.vcproj 2007-11-05 16:19:49 UTC (rev 2220) @@ -478,6 +478,9 @@ UsePrecompiledHeader="0"/> </FileConfiguration> </File> + <File + RelativePath=".\src\util\SearchForFiles.cpp"> + </File> </Filter> </Filter> <Filter @@ -635,6 +638,9 @@ RelativePath=".\include\util\findfilecontainer.h"> </File> <File + RelativePath=".\include\util\SearchForFiles.h"> + </File> + <File RelativePath=".\include\util\xercesutils.h"> </File> </Filter> Added: branches/amis3/AmisCore/include/util/SearchForFiles.h =================================================================== --- branches/amis3/AmisCore/include/util/SearchForFiles.h (rev 0) +++ branches/amis3/AmisCore/include/util/SearchForFiles.h 2007-11-05 16:19:49 UTC (rev 2220) @@ -0,0 +1,54 @@ +#ifndef SEARCHFORFILES_H +#define SEARCHFORFILES_H + +#include <string> +#include <vector> +#include "AmisCore.h" +#include "Media.h" +#include "ambulant/net/url.h" + +namespace amis +{ +namespace util +{ + +//will we need this struct? it is leftover. +//if so, does it belong here? +struct BookInfo +{ + amis::MediaGroup* mpTitle; + string mFilePath; +}; + +//this class is mostly virtual +//it needs platform-specific implementations +//one example is the MFC implementation in AMIS for Windows +class SearchForFiles +{ +public: + SearchForFiles(); + virtual ~SearchForFiles()=0; + + virtual int startSearch(std::string)=0; + + void setRecursiveSearch(bool); + bool isRecursiveSearch(); + + void addSearchCriteria(std::string); + amis::StdStringList getSearchCriteria(); + void clearSearchCriteria(); + bool matchesCriteria(std::string); + + //this function should be called by implementations of SearchForFiles + void addSearchResult(const ambulant::net::url*); + amis::UrlList getSearchResults(); + void clearSearchResults(); + +private: + bool mbIsRecursive; + amis::StdStringList mCriteria; + amis::UrlList mResults; +}; +} +} +#endif \ No newline at end of file Added: branches/amis3/AmisCore/src/util/SearchForFiles.cpp =================================================================== --- branches/amis3/AmisCore/src/util/SearchForFiles.cpp (rev 0) +++ branches/amis3/AmisCore/src/util/SearchForFiles.cpp 2007-11-05 16:19:49 UTC (rev 2220) @@ -0,0 +1,96 @@ +/* +AMIS: Adaptive Multimedia Information System +Software for playing DAISY books +Homepage: http://amis.sf.net + +Copyright (C) 2004-2007 DAISY for All Project + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +//for string transformations +#include <algorithm> + +#include "util/SearchForFiles.h" + +amis::util::SearchForFiles::SearchForFiles() +{ + mbIsRecursive = true; +} +amis::util::SearchForFiles::~SearchForFiles() +{ +} + +void amis::util::SearchForFiles::setRecursiveSearch(bool isRecursive) +{ + mbIsRecursive = isRecursive; +} + +bool amis::util::SearchForFiles::isRecursiveSearch() +{ + return mbIsRecursive; +} + +/*! + search criteria is defined as a desired substring of a filename + so to find all the opf files, just ask for .opf. not *.opf. +*/ +void amis::util::SearchForFiles::addSearchCriteria(std::string criterion) +{ + std::string criterion_lower = criterion; + //make lower case + std::transform(criterion_lower.begin(), criterion_lower.end(), criterion_lower.begin(), (int(*)(int))tolower); + mCriteria.push_back(criterion_lower); +} + +amis::StdStringList amis::util::SearchForFiles::getSearchCriteria() +{ + return mCriteria; +} +bool amis::util::SearchForFiles::matchesCriteria(std::string data) +{ + std::string data_lower = data; + //make lower case + std::transform(data_lower.begin(), data_lower.end(), data_lower.begin(), (int(*)(int))tolower); + + for (int i=0; i<mCriteria.size(); i++) + { + if (data_lower.find(mCriteria[i]) != std::string::npos) return true; + } + if (mCriteria.size() > 0) return false; + //if there are no criteria, everything is always a match + else return true; +} + +void amis::util::SearchForFiles::clearSearchCriteria() +{ + mCriteria.clear(); +} + +//this function should ONLY be called by implementations of SearchForFiles +void amis::util::SearchForFiles::addSearchResult(const ambulant::net::url* searchResult) +{ + mResults.push_back(*searchResult); +} + +amis::UrlList amis::util::SearchForFiles::getSearchResults() +{ + return mResults; +} + +void amis::util::SearchForFiles::clearSearchResults() +{ + mResults.clear(); +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-10-22 00:36:38 UTC (rev 2219) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-11-05 16:19:49 UTC (rev 2220) @@ -144,6 +144,9 @@ RelativePath=".\include\Preferences.h"> </File> <File + RelativePath=".\include\SearchForFilesMFC.h"> + </File> + <File RelativePath=".\include\stdafx.h"> </File> <File @@ -300,6 +303,9 @@ </FileConfiguration> </File> <File + RelativePath=".\src\SearchForFilesMFC.cpp"> + </File> + <File RelativePath=".\src\stdafx.cpp"> <FileConfiguration Name="Debug|Win32"> Added: branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h (rev 0) +++ branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h 2007-11-05 16:19:49 UTC (rev 2220) @@ -0,0 +1,30 @@ +#ifndef SEARCHFORFILESMFC_H +#define SEARCHFORFILESMFC_H + +#include <string> +#include <vector> +#include "stdafx.h" +#include "util/SearchForFiles.h" + +using namespace std; +namespace amis +{ +namespace util +{ +class SearchForFilesMFC : public amis::util::SearchForFiles +{ +public: + SearchForFilesMFC(); + ~SearchForFilesMFC(); + + int startSearch(std::string); + void stopSearch(); + +private: + int recursiveSearch(LPCTSTR); + void doEvents(); + bool mbShouldStop; +}; +} +} +#endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/Preferences.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2007-10-22 00:36:38 UTC (rev 2219) +++ branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2007-11-05 16:19:49 UTC (rev 2220) @@ -51,7 +51,7 @@ mbPauseOnApplicationLostFocus = true; - this->mbIsSelfVoicing = true; + this->mbIsSelfVoicing = false; this->mUiLang = "./settings/lang/eng-US/"; this->mbUseTTSNotAudio = false; } Added: branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp 2007-11-05 16:19:49 UTC (rev 2220) @@ -0,0 +1,119 @@ +/* +AMIS: Adaptive Multimedia Information System +Software for playing DAISY books +Homepage: http://amis.sf.net + +Copyright (C) 2004-2007 DAISY for All Project + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#include "stdafx.h" +#include "util/SearchForFiles.h" +#include "SearchForFilesMFC.h" +#include "ambulant/net/url.h" + +using namespace amis::util; + +SearchForFilesMFC::SearchForFilesMFC() +{ + mbShouldStop = false; +} + +SearchForFilesMFC::~SearchForFilesMFC() +{ + clearSearchResults(); +} + +int SearchForFilesMFC::startSearch(std::string searchPath) +{ + USES_CONVERSION; + mbShouldStop = false; + + clearSearchResults(); + + //call the search routine, which returns the number of files found + return recursiveSearch(A2T(searchPath.c_str())); +} + +void SearchForFilesMFC::stopSearch() +{ + mbShouldStop = true; +} + +int SearchForFilesMFC::recursiveSearch(LPCTSTR path) +{ + USES_CONVERSION; + + CFileFind finder; + CString filename; + int files_found = 0; + + BOOL b_is_working = finder.FindFile(path); + while (b_is_working) + { + b_is_working = finder.FindNextFile(); + + // handle messages + doEvents(); + + // received a stop signal + if (mbShouldStop == true) break; + + if (finder.IsDots()) continue; + + // if it's a directory, recursively search it + if (finder.IsDirectory() && isRecursiveSearch()) + { + CString str = finder.GetFilePath(); + files_found += recursiveSearch(str + _T("\\*.*")); + } + else + { + filename = finder.GetFileName(); + + if (matchesCriteria(T2A(filename))) + { + files_found++; + //save the file path + CString file_path = finder.GetFilePath(); + std::string file_path_string = T2A(file_path); + ambulant::net::url file_path_url = ambulant::net::url::from_url(file_path_string); + addSearchResult(&file_path_url); + } + } + } + + amis::UrlList results = getSearchResults(); + return results.size(); +} + +//peek at the message queue +void SearchForFilesMFC::doEvents() +{ + MSG msg; + + while ( ::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE ) ) + { + if ( ::GetMessage(&msg, NULL, 0, 0)) + { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + else + { + break; + } + } +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-10-22 00:36:38 UTC (rev 2219) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-11-05 16:19:49 UTC (rev 2220) @@ -186,8 +186,12 @@ amis::dtb::DtbWithHooks::Instance()->setCallbackForPreprocessingBookKey(registerBookKeyFile); - if (amis::Preferences::Instance()->mbIsSelfVoicing == true) - { + //marisa removed this if-statement + //the self-voicing data should be ready to go whether or not self-voicing is turned on at the start + //the self-voicing data is also the dynamic localization data, so it is used all over the place + //maybe this needs to be changed someday and all strings must be duplicated in the RC file .. ? for now it's ok. + //if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + //{ //read in the new self-voicing/accessible UI data DataReader new_data_reader; DataTree* p_new_data_tree; @@ -231,7 +235,7 @@ { amis::Preferences::Instance()->mbIsSelfVoicing = false; } - } + //} Modified: branches/amis3/DefaultLangpack/amisAccessibleUi.xml =================================================================== --- branches/amis3/DefaultLangpack/amisAccessibleUi.xml 2007-10-22 00:36:38 UTC (rev 2219) +++ branches/amis3/DefaultLangpack/amisAccessibleUi.xml 2007-11-05 16:19:49 UTC (rev 2220) @@ -32,6 +32,23 @@ <audio src="./audio/006_O.mp3" from="file:///c:/devel/amis/Defaultlangpack/prompts/prom0007.smil#text_0007" /> </mnemonic> </action> + <!--new action--> + <action mfcid="ID_MENU_FILE_OPENURL" widget="menuItem"> + <note>This is going to be a menu item</note> + <icon src="./open.png" type="smallIcon" /> + <caption> + <text>Open URL...</text> + <originalText>Open URL...</originalText> + </caption> + <description> + <text>Open a Daisy book from a URL</text> + <originalText>Open a Daisy book from a URL</originalText> + </description> + <accelerator> + <text>Ctrl+U</text> + <originalText>Ctrl+U</originalText> + </accelerator> + </action> <action mfcid="ID_MENU_FILE_LOADCD" widget="menuItem toolbarItem"> <note>This is going to be a menu item and a toolbar item</note> <icon src="./settings/img/cd3.ico" type="smallIcon" /> @@ -1906,6 +1923,55 @@ </list> </control> </dialog> + <!--new dialog--> + <dialog mfcid="IDD_OPENURL"> + <note>This is the open URL dialog</note> + <caption> + <text>Open URL</text> + <originalText>Open URL</originalText> + </caption> + <description mfcid="IDC_DESC"> + <text>Enter the URL of the book you want to open:</text> + <originalText>Enter the URL of the book you want to open:</originalText> + </description> + <prompt type="instructions"> + <promptItem refid="tabAround" /> + <promptItem> + <text>After typing in the URL, press enter.</text> + <originalText>After typing in the URL, press enter.</originalText> + </promptItem> + <promptItem refid="altC_to_cancel" /> + <promptItem refid="repeatLastPromptInstr" /> + <promptItem refid="hearDlgInstructions" /> + </prompt> + <control mfcid="IDOK" widget="button"> + <caption> + <promptItem refid="ok_button_caption" /> + </caption> + <description> + <text>Press to load the URL.</text> + <originalText>Press to load the URL.</originalText> + </description> + </control> + <control mfcid="IDCANCEL" widget="button"> + <caption> + <promptItem refid="cancel_button_caption" /> + </caption> + <description> + <promptItem refid="cancel_button_description" /> + </description> + <mnemonic> + <text>C</text> + <originalText>C</originalText> + </mnemonic> + </control> + <control mfcid="IDC_URL" widget="textfield"> + <description> + <text>Type the URL in this field.</text> + <originalText>Type the URL in this field.</originalText> + </description> + </control> + </dialog> </dialogs> <prompts> <promptItemRefs> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-11-05 20:22:51
|
Revision: 2221 http://amis.svn.sourceforge.net/amis/?rev=2221&view=rev Author: marisademeglio Date: 2007-11-05 12:22:52 -0800 (Mon, 05 Nov 2007) Log Message: ----------- Started using new file searcher. No more annoying command prompt! Modified Paths: -------------- branches/amis3/AmisCore/include/dtb/Dtb.h branches/amis3/AmisCore/include/dtb/DtbFileSet.h branches/amis3/AmisCore/include/util/SearchForFiles.h branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp branches/amis3/AmisCore/src/util/SearchForFiles.cpp branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp Modified: branches/amis3/AmisCore/include/dtb/Dtb.h =================================================================== --- branches/amis3/AmisCore/include/dtb/Dtb.h 2007-11-05 16:19:49 UTC (rev 2220) +++ branches/amis3/AmisCore/include/dtb/Dtb.h 2007-11-05 20:22:52 UTC (rev 2221) @@ -31,6 +31,7 @@ #include "dtb/smil/SmilMediaGroup.h" #include "dtb/DtbFileSet.h" #include "ambulant/net/url.h" +#include "util/SearchForFiles.h" namespace amis { @@ -62,7 +63,8 @@ wstring getUid(); amis::dtb::BookmarkSet* getBookmarks(); amis::dtb::CustomTestSet* getCustomTestSet(); - + void setFileSearcher(amis::util::SearchForFiles*); + amis::util::SearchForFiles* getFileSearcher(); string searchFullText(wstring); amis::dtb::smil::SmilTree* getSmilTree(); string searchFullTextNext(); @@ -102,6 +104,7 @@ wstring mLastSearchString; string mLastSearchResult; string mLastSearchedTextFile; + amis::util::SearchForFiles* mpFileSearcher; int mDaisyVersion; bool mbIsProtected; ProtectedBookKeyHandlerFunctionPtr mpCallbackForPreprocessingBookKey; Modified: branches/amis3/AmisCore/include/dtb/DtbFileSet.h =================================================================== --- branches/amis3/AmisCore/include/dtb/DtbFileSet.h 2007-11-05 16:19:49 UTC (rev 2220) +++ branches/amis3/AmisCore/include/dtb/DtbFileSet.h 2007-11-05 20:22:52 UTC (rev 2221) @@ -26,6 +26,7 @@ #include <string> #include "AmisCore.h" #include "ambulant/net/url.h" +#include "util/SearchForFiles.h" using namespace std; @@ -39,7 +40,7 @@ DtbFileSet(); ~DtbFileSet(); //!initialize with NCC or OPF filepath - void initWithNccOrOpf(const ambulant::net::url*); + void initWithNccOrOpf(const ambulant::net::url*, amis::util::SearchForFiles*); //utility functions static bool isNccFile(const ambulant::net::url*); static bool isOpfFile(const ambulant::net::url*); @@ -65,7 +66,7 @@ private: string calculateSafeBookmarksFilename(wstring); - void findTextFiles(); + void findTextFiles(amis::util::SearchForFiles*); ambulant::net::url mNavFilepath; ambulant::net::url mBookDirectory; @@ -76,6 +77,7 @@ ambulant::net::url mSmilFilepath; ambulant::net::url mProtectedNavFilepath; ambulant::net::url mProtectedBookKeyFilepath; + amis::util::SearchForFiles* mpFileSearcher; UrlList mTextFiles; }; } Modified: branches/amis3/AmisCore/include/util/SearchForFiles.h =================================================================== --- branches/amis3/AmisCore/include/util/SearchForFiles.h 2007-11-05 16:19:49 UTC (rev 2220) +++ branches/amis3/AmisCore/include/util/SearchForFiles.h 2007-11-05 20:22:52 UTC (rev 2221) @@ -37,16 +37,24 @@ void addSearchCriteria(std::string); amis::StdStringList getSearchCriteria(); void clearSearchCriteria(); - bool matchesCriteria(std::string); + bool matchesSearchCriteria(std::string); - //this function should be called by implementations of SearchForFiles + void addSearchExclusionCriteria(std::string); + amis::StdStringList getSearchExclusionCriteria(); + void clearSearchExclusionCriteria(); + bool matchesSearchExclusionCriteria(std::string); + + //this function should ONLY be called by implementations of SearchForFiles void addSearchResult(const ambulant::net::url*); + amis::UrlList getSearchResults(); void clearSearchResults(); private: + bool matchesList(std::string, amis::StdStringList); bool mbIsRecursive; amis::StdStringList mCriteria; + amis::StdStringList mExclusions; amis::UrlList mResults; }; } Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-11-05 16:19:49 UTC (rev 2220) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-11-05 20:22:52 UTC (rev 2221) @@ -49,6 +49,7 @@ mpTitle = NULL; mpTextSmilMap = NULL; mpCustomTests = NULL; + mpFileSearcher = NULL; mUid.erase(); mDaisyVersion = 0; mpCallbackForPreprocessingBookKey = NULL; @@ -60,6 +61,7 @@ } //delete objects +//we are purposely not deleting mpFileSearcher void amis::dtb::Dtb::cleanUpObjects() { mbIsProtected = false; @@ -131,6 +133,14 @@ { return mpCustomTests; } +void amis::dtb::Dtb::setFileSearcher(amis::util::SearchForFiles* fileSearcher) +{ + mpFileSearcher = fileSearcher; +} +amis::util::SearchForFiles* amis::dtb::Dtb::getFileSearcher() +{ + return mpFileSearcher; +} //-------------------------------------------------- //wrapper for opening files @@ -153,7 +163,7 @@ mpFiles = NULL; mpFiles = new amis::dtb::DtbFileSet(); - mpFiles->initWithNccOrOpf(fileUrl); + mpFiles->initWithNccOrOpf(fileUrl, mpFileSearcher); mpFiles->setBookmarksDirectory(bookmarksDirectory); if (DtbFileSet::isNccFile(fileUrl)) Modified: branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-11-05 16:19:49 UTC (rev 2220) +++ branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-11-05 20:22:52 UTC (rev 2221) @@ -45,7 +45,7 @@ mTextFiles.clear(); } -void amis::dtb::DtbFileSet::initWithNccOrOpf(const ambulant::net::url* filepath) +void amis::dtb::DtbFileSet::initWithNccOrOpf(const ambulant::net::url* filepath, amis::util::SearchForFiles* fileSearcher) { /* this shows off a bug in the url code...but when it's fixed, this is an easier way to calculate the book directory @@ -57,6 +57,7 @@ std::string book_dir = temp_url.get_url(); book_dir += "/"; mBookDirectory = ambulant::net::url::from_url(book_dir); + mpFileSearcher = fileSearcher; if (isNccFile(filepath)) { @@ -64,9 +65,7 @@ //these should be set to "" .. however you do that with ambulant::net::url objects //this->mOpfFilepath; //this->mResourceFilepath; - - //this brings up the annoying command terminal - findTextFiles(); + findTextFiles(fileSearcher); } else if (isOpfFile(filepath)) { @@ -230,8 +229,8 @@ stored in the order it was created, and i don't know how to get at the key (text-src) by itself (maybe map_iter.first)? -another note: the process called by this function which searches the directory spawns an annoying (temporary) pop-up command line window*/ -void amis::dtb::DtbFileSet::findTextFiles() +*/ +void amis::dtb::DtbFileSet::findTextFiles(amis::util::SearchForFiles* fileSearcher) { //searching won't work on network-based books yet if (mBookDirectory.is_local_file() == false) return; @@ -241,27 +240,16 @@ //if we are not dealing with an OPF, then we have to look for the text files ourself if (this->mOpfFilepath.is_empty_path()) { - FindFilesInPath file_searcher(mBookDirectory.get_file(), "*.html"); - - StdStringList::const_iterator it; - bool b_check_ncc = true; - for(it = file_searcher.c_FileList.begin(); it != file_searcher.c_FileList.end();++it) - { - if (b_check_ncc) - { - string tmp = amis::util::FilePathTools::getFileName(*it); - if (tmp.compare("ncc.html") == 0) - { - b_check_ncc = false; - //if there is more than one file, skip the rest of the loop - //we don't need to copy the ncc file if there are other text files present - if (file_searcher.c_FileList.size() > 1) continue; - } - } + //we want to find the HTML files that are not NCC files + mpFileSearcher->addSearchCriteria(".html"); + mpFileSearcher->addSearchExclusionCriteria("ncc.html"); + mpFileSearcher->setRecursiveSearch(true); + mpFileSearcher->startSearch(mBookDirectory.get_file()); + + mTextFiles = mpFileSearcher->getSearchResults(); - ambulant::net::url fileurl = ambulant::net::url::from_filename((*it)); - mTextFiles.push_back(fileurl); - } + //if we didn't find any text files, then use the nav file as our text file + if (mTextFiles.size() == 0) mTextFiles.push_back(this->mNavFilepath); } } Modified: branches/amis3/AmisCore/src/util/SearchForFiles.cpp =================================================================== --- branches/amis3/AmisCore/src/util/SearchForFiles.cpp 2007-11-05 16:19:49 UTC (rev 2220) +++ branches/amis3/AmisCore/src/util/SearchForFiles.cpp 2007-11-05 20:22:52 UTC (rev 2221) @@ -28,6 +28,8 @@ amis::util::SearchForFiles::SearchForFiles() { mbIsRecursive = true; + mCriteria.clear(); + mExclusions.clear(); } amis::util::SearchForFiles::~SearchForFiles() { @@ -59,21 +61,45 @@ { return mCriteria; } -bool amis::util::SearchForFiles::matchesCriteria(std::string data) +void amis::util::SearchForFiles::addSearchExclusionCriteria(std::string criterion) { + std::string criterion_lower = criterion; + //make lower case + std::transform(criterion_lower.begin(), criterion_lower.end(), criterion_lower.begin(), (int(*)(int))tolower); + mExclusions.push_back(criterion_lower); +} + +amis::StdStringList amis::util::SearchForFiles::getSearchExclusionCriteria() +{ + return mExclusions; +} +void amis::util::SearchForFiles::clearSearchExclusionCriteria() +{ + mExclusions.clear(); +} +bool amis::util::SearchForFiles::matchesSearchCriteria(std::string data) +{ + return matchesList(data, mCriteria); +} +bool amis::util::SearchForFiles::matchesSearchExclusionCriteria(std::string data) +{ + return matchesList(data, mExclusions); +} + +bool amis::util::SearchForFiles::matchesList(std::string data, StdStringList list) +{ std::string data_lower = data; //make lower case std::transform(data_lower.begin(), data_lower.end(), data_lower.begin(), (int(*)(int))tolower); - for (int i=0; i<mCriteria.size(); i++) + for (int i=0; i<list.size(); i++) { - if (data_lower.find(mCriteria[i]) != std::string::npos) return true; + if (data_lower.find(list[i]) != std::string::npos) return true; } - if (mCriteria.size() > 0) return false; + if (list.size() > 0) return false; //if there are no criteria, everything is always a match else return true; } - void amis::util::SearchForFiles::clearSearchCriteria() { mCriteria.clear(); Modified: branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2007-11-05 16:19:49 UTC (rev 2220) +++ branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2007-11-05 20:22:52 UTC (rev 2221) @@ -25,6 +25,7 @@ #include "dtb/Dtb.h" +#include "SearchForFilesMFC.h" namespace amis { @@ -61,6 +62,9 @@ void addToRecentBooks(); void makeAllNavContainerLabelsHumanReadable(); void makeNavContainerLabelHumanReadable(nav::NavContainer*); + + //this object is instantiated and destroyed by this class, but otherwise is managed by the base class + amis::util::SearchForFilesMFC* mpFileSearcherTmp; private: static DtbWithHooks* pinstance; }; Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-11-05 16:19:49 UTC (rev 2220) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-11-05 20:22:52 UTC (rev 2221) @@ -31,6 +31,7 @@ #include "ambulant/net/url.h" #include "ambulant/smil2/test_attrs.h" + using namespace amis::dtb; DtbWithHooks* DtbWithHooks::pinstance = 0; @@ -56,14 +57,20 @@ DtbWithHooks::DtbWithHooks() { + mpFileSearcherTmp = NULL; + mpFileSearcherTmp = new amis::util::SearchForFilesMFC(); + setFileSearcher(mpFileSearcherTmp); } DtbWithHooks::~DtbWithHooks() { + if (mpFileSearcherTmp != NULL) delete mpFileSearcherTmp; } bool DtbWithHooks::open(const ambulant::net::url* filename, const ambulant::net::url* bookmarksPath) { + getFileSearcher()->clearSearchResults(); + //call the base class if (!Dtb::open(filename, bookmarksPath)) return false; Modified: branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp 2007-11-05 16:19:49 UTC (rev 2220) +++ branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp 2007-11-05 20:22:52 UTC (rev 2221) @@ -60,7 +60,9 @@ CString filename; int files_found = 0; - BOOL b_is_working = finder.FindFile(path); + CString cstr_path = path; + cstr_path.Append(_T("*.*")); + BOOL b_is_working = finder.FindFile(cstr_path); while (b_is_working) { b_is_working = finder.FindNextFile(); @@ -82,14 +84,16 @@ else { filename = finder.GetFileName(); - - if (matchesCriteria(T2A(filename))) + std::string str_filename = T2A(filename); + if (matchesSearchCriteria(str_filename) && !matchesSearchExclusionCriteria(str_filename)) { files_found++; //save the file path CString file_path = finder.GetFilePath(); std::string file_path_string = T2A(file_path); - ambulant::net::url file_path_url = ambulant::net::url::from_url(file_path_string); + //TODO + //we assume that the search returns local files + ambulant::net::url file_path_url = ambulant::net::url::from_filename(file_path_string); addSearchResult(&file_path_url); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-11-05 22:19:50
|
Revision: 2222 http://amis.svn.sourceforge.net/amis/?rev=2222&view=rev Author: marisademeglio Date: 2007-11-05 14:19:49 -0800 (Mon, 05 Nov 2007) Log Message: ----------- Added (untested) code to retrieve the text (but not the audio yet) title and author. Added "close" menu item to accessible UI XML file. Added new dialog (not being used yet) for publication information. Removed unused dialogs: current position, navigation options, colors page Modified Paths: -------------- branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/resource.h branches/amis3/DefaultLangpack/amisAccessibleUi.xml Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-11-05 20:22:52 UTC (rev 2221) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-11-05 22:19:49 UTC (rev 2222) @@ -275,7 +275,20 @@ //the spine visitor also makes the smil file paths absolute mpSpine = spine_visitor.getSpine(mpNavModel, this->getFileSet()->getBookDirectory()); + //fill in the text for the title and the author mUid = getUid(); + mpTitle = new amis::MediaGroup(); + amis::TextNode* p_title_text = new amis::TextNode(); + p_title_text->setTextString(mpMetadata->getMetadata("dc:title")); + mpTitle->setText(p_title_text); + + mpAuthor = new amis::MediaGroup(); + amis::TextNode p_author_text = new amis::TextNode(); + p_author_text->setTextString(mpMetadata->getMetadata("dc:creator")); + mpAuthor->setText(p_author_text); + + //TODO: get the audio for the title and author + mpFiles->setAdditionalDataAfterInitialParse(this->mUid, NULL, NULL); amis::dtb::nav::ResolveSmilDataVisitor resolve_smil_visitor; resolve_smil_visitor.resolve(mpNavModel, mpSpine, true); Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2007-11-05 20:22:52 UTC (rev 2221) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2007-11-05 22:19:49 UTC (rev 2222) @@ -88,7 +88,7 @@ BOTTOMMARGIN, 280 END - IDD_PROPPAGE4, DIALOG + IDD_LANGUAGES, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 222 @@ -96,7 +96,7 @@ BOTTOMMARGIN, 215 END - IDD_PROPPAGE1, DIALOG + IDD_PREFERENCES, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 249 @@ -120,14 +120,6 @@ BOTTOMMARGIN, 48 END - IDD_CURRENTPOSITION, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 232 - TOPMARGIN, 7 - BOTTOMMARGIN, 165 - END - IDD_CDSEARCH, DIALOG BEGIN LEFTMARGIN, 7 @@ -144,30 +136,14 @@ BOTTOMMARGIN, 90 END - IDD_NAVIGATIONOPTIONS, DIALOG + IDD_PUBLICATIONINFO, DIALOG BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 240 - TOPMARGIN, 7 - BOTTOMMARGIN, 168 - END - - IDD_FULLSUMMARY, DIALOG - BEGIN LEFTMARGIN, 6 - RIGHTMARGIN, 248 + RIGHTMARGIN, 393 TOPMARGIN, 7 - BOTTOMMARGIN, 171 + BOTTOMMARGIN, 270 END - IDD_PROPPAGE2, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 203 - TOPMARGIN, 7 - BOTTOMMARGIN, 200 - END - IDD_OPENURL, DIALOG BEGIN LEFTMARGIN, 7 @@ -319,7 +295,7 @@ CONTROL 186,IDC_PICTURE,"Static",SS_BITMAP,7,7,86,79 END -IDD_PROPPAGE4 DIALOGEX 0, 0, 229, 223 +IDD_LANGUAGES DIALOGEX 0, 0, 229, 223 STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Language" FONT 8, "MS Sans Serif", 0, 0, 0x0 @@ -335,7 +311,7 @@ LTEXT "Your language choices are:",IDC_STATIC,7,57,56,8 END -IDD_PROPPAGE1 DIALOGEX 0, 0, 256, 236 +IDD_PREFERENCES DIALOGEX 0, 0, 256, 236 STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "General Preferences" FONT 8, "MS Sans Serif", 0, 0, 0x0 @@ -383,18 +359,6 @@ EDITTEXT IDC_SEARCHSTRING,7,7,106,13,ES_AUTOHSCROLL END -IDD_CURRENTPOSITION DIALOGEX 0, 0, 239, 172 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Current Position" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "OK",IDOK,95,151,50,14 - LTEXT "This is a list of data about your current position.", - IDC_LISTCAPTION,7,7,225,17 - CONTROL "",IDC_SUMMARY,"SysListView32",LVS_LIST | LVS_ALIGNLEFT | - WS_BORDER | WS_TABSTOP,7,23,225,119,WS_EX_LEFTSCROLLBAR -END - IDD_CDSEARCH DIALOGEX 0, 0, 253, 180 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Multiple books found" @@ -414,66 +378,36 @@ CAPTION "About AMIS" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - ICON IDI_AMIS,IDC_STATIC,11,17,21,20 + ICON IDI_AMIS,IDC_STATIC,11,17,20,20 LTEXT "AMIS: \nAdaptive Multimedia Information System", IDC_AMISNAME,40,10,132,31,SS_NOPREFIX - LTEXT "Copyright \xA9 2006 DAISY for All",IDC_COPYRIGHT,40,82,119, + LTEXT "Copyright \xA9 2008 DAISY for All",IDC_COPYRIGHT,40,82,119, 8 DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP - LTEXT "Version 2.0",IDC_VERSION,39,44,128,8 - LTEXT "Release Date: 23 Oct 2005",IDC_VERSIONNOTE,40,59,124,11 + LTEXT "Version 3.0 beta",IDC_VERSION,39,44,128,8 + LTEXT "Release Date: 01 January 2008",IDC_VERSIONNOTE,40,59, + 124,11 END -IDD_NAVIGATIONOPTIONS DIALOGEX 0, 0, 247, 175 +IDD_PUBLICATIONINFO DIALOGEX 0, 0, 400, 278 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Navigation Options" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "OK",IDOK,100,154,50,14 - LTEXT "This is a list of items to which you may navigate directly.", - IDC_LISTCAPTION,7,7,225,17 - CONTROL "",IDC_SUMMARY,"SysListView32",LVS_LIST | LVS_ALIGNLEFT | - WS_BORDER | WS_TABSTOP,7,31,233,119,WS_EX_LEFTSCROLLBAR -END - -IDD_FULLSUMMARY DIALOGEX 0, 0, 255, 178 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Publication Summary" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - DEFPUSHBUTTON "OK",IDOK,107,157,50,14 - LTEXT "This is a list of publication metadata.", - IDC_LISTCAPTION,6,7,242,17 - CONTROL "",IDC_SUMMARY,"SysListView32",LVS_LIST | LVS_ALIGNLEFT | - WS_BORDER | WS_TABSTOP,6,31,242,119,WS_EX_LEFTSCROLLBAR + DEFPUSHBUTTON "OK",IDOK,176,256,50,14 + LTEXT "About: TITLE by CREATOR",IDC_DIALOGCAPTION,6,7,387,17 + CONTROL "",IDC_PUBLICATIONINFO,"SysListView32",LVS_LIST | + LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,6,126,387,119, + WS_EX_LEFTSCROLLBAR + LTEXT "About your current position:", + IDC_CURRENTPOSITIONCAPTION,6,27,387,17 + CONTROL "",IDC_CURRENTPOSITION2,"SysListView32",LVS_LIST | + LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7, + 46,386,47,WS_EX_LEFTSCROLLBAR + LTEXT "About this publication:",IDC_PUBLICATIONINFOCAPTION,6, + 107,387,16 END -IDD_PROPPAGE2 DIALOGEX 0, 0, 210, 207 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Set Colors" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - GROUPBOX "Phrase Highlighting",IDC_PHRASES,7,7,196,73 - LTEXT "Text Foreground:",IDC_TEXTFG,15,21,58,9 - PUSHBUTTON "",IDC_BTN_TEXTFG,79,17,19,14,BS_FLAT - LTEXT "Text Background:",IDC_TEXTBG,13,42,58,9 - PUSHBUTTON "",IDC_BTN_TEXTBG,79,38,19,14,BS_FLAT - LTEXT "Selection Border:",IDC_BORDER,15,64,55,9,NOT WS_VISIBLE - PUSHBUTTON "",IDC_BTN_BORDER,79,61,19,14,BS_FLAT | NOT WS_VISIBLE - GROUPBOX "High Contrast Settings",IDC_CONTRAST,7,87,196,75 - LTEXT "Page Foreground:",IDC_PAGEFG,14,112,58,9 - PUSHBUTTON "",IDC_BTN_PAGEFG,80,109,19,14,BS_FLAT - LTEXT "Page Background:",IDC_PAGEBG,14,133,61,9 - PUSHBUTTON "",IDC_BTN_PAGEBG,80,130,19,14,BS_FLAT - PUSHBUTTON "Reset Colors",IDC_BTN_RESETCOLORS,146,185,57,15 - CONTROL "Preview of phrase highlight colors.",IDC_PHRASEPREVIEW, - "RichEdit20A",ES_MULTILINE | ES_AUTOHSCROLL | WS_BORDER | - WS_TABSTOP,113,14,90,63 - CONTROL "Preview of page contrast colors.",IDC_CONTRASTPREVIEW, - "RichEdit20A",ES_MULTILINE | ES_AUTOHSCROLL | WS_BORDER | - WS_TABSTOP,113,95,90,63 -END - IDD_OPENURL DIALOGEX 0, 0, 265, 70 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU @@ -582,13 +516,14 @@ VK_UP, ID_MENU_PLAY_VOLUP, VIRTKEY, CONTROL, NOINVERT VK_SPACE, ID_MENU_PLAYPAUSE, VIRTKEY, NOINVERT VK_F11, ID_MENU_VIEW_BASIC, VIRTKEY, NOINVERT - "S", ID_VIEW_CONTRAST, VIRTKEY, CONTROL, NOINVERT "E", ID_RESET_HIGHLIGHT_COLORS, VIRTKEY, SHIFT, CONTROL, NOINVERT "F", ID_TOGGLE_AUDIO_CONTENT_PLAYBACK, VIRTKEY, SHIFT, CONTROL, NOINVERT "G", ID_TOGGLE_AUDIO_SELFVOICING_PLAYBACK, VIRTKEY, SHIFT, CONTROL, NOINVERT + "S", ID_VIEW_CONTRAST, VIRTKEY, CONTROL, NOINVERT + "U", ID_MENU_FILE_OPENFROMURL, VIRTKEY, CONTROL, NOINVERT END @@ -720,6 +655,7 @@ STRINGTABLE BEGIN ID_MENU_PLAYPAUSE "Start synchronized playback." + ID_MENU_FILE_CLOSE "Close the publication." END #endif // English (U.S.) resources Modified: branches/amis3/AmisGuiMFC2/resource.h =================================================================== --- branches/amis3/AmisGuiMFC2/resource.h 2007-11-05 20:22:52 UTC (rev 2221) +++ branches/amis3/AmisGuiMFC2/resource.h 2007-11-05 22:19:49 UTC (rev 2222) @@ -5,9 +5,10 @@ #define IDD_ABOUTBOX 100 #define IDS_PROPSHT_CAPTION 102 #define IDD_SIDEBAR 103 -#define IDD_PROPPAGE2 106 #define IDD_PROPPAGE1 110 +#define IDD_PREFERENCES 110 #define IDD_PROPPAGE4 112 +#define IDD_LANGUAGES 112 #define ID_FOCUS_ON_SIDEBAR 123 #define ID_HEAR_LAST_PROMPT 124 #define ID_HEAR_INSTRUCTIONS 125 @@ -28,8 +29,7 @@ #define IDD_GOTOPAGE 180 #define IDD_CDSEARCH 181 #define IDD_FULLSUMMARY 182 -#define IDD_CURRENTPOSITION 183 -#define IDD_NAVIGATIONOPTIONS 184 +#define IDD_PUBLICATIONINFO 182 #define IDI_LANGICON 185 #define IDD_PROPPAGE3 185 #define IDB_BOOKSHELFMAG 186 @@ -89,7 +89,12 @@ #define IDC_TEXTFG 1079 #define IDC_URL 1079 #define IDC_TEXTBG 1080 +#define IDC_DIALOGCAPTION 1080 #define IDC_BORDER 1081 +#define IDC_PUBLICATIONINFO 1081 +#define IDC_CURRENTPOSITIONCAPTION 1082 +#define IDC_CURRENTPOSITION2 1083 +#define IDC_PUBLICATIONINFOCAPTION 1084 #define ID_MENU_FIND_IN_TEXT_NEXT 9000 #define IDC_LANGLIST 9001 #define ID_MENU_FIND_IN_TEXT_PREV 9001 @@ -135,8 +140,8 @@ #define ID_MENU_NAV_FINDINTEXT 32859 #define ID_MENU_NAV_GOTOPAGE 32860 #define ID_MENU_PLAYPAUSE 32865 -#define ID_MENU_FILE_CLOSE 32867 #define ID_MENU_FILE_OPENFROMURL 32870 +#define ID_MENU_FILE_CLOSE 32871 #define IDS_NOSKIP 61245 #define IDS_SELFOLDER_TITLE 61258 #define IDS_SELFOLDER_INSTR 61259 @@ -151,8 +156,8 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 191 -#define _APS_NEXT_COMMAND_VALUE 32871 -#define _APS_NEXT_CONTROL_VALUE 1080 +#define _APS_NEXT_COMMAND_VALUE 32873 +#define _APS_NEXT_CONTROL_VALUE 1083 #define _APS_NEXT_SYMED_VALUE 141 #endif #endif Modified: branches/amis3/DefaultLangpack/amisAccessibleUi.xml =================================================================== --- branches/amis3/DefaultLangpack/amisAccessibleUi.xml 2007-11-05 20:22:52 UTC (rev 2221) +++ branches/amis3/DefaultLangpack/amisAccessibleUi.xml 2007-11-05 22:19:49 UTC (rev 2222) @@ -17,7 +17,7 @@ <audio src="./audio/003_Open.mp3" from="file:///c:/devel/amis/Defaultlangpack/prompts/prom0004.smil#text_0004" /> </caption> <description> - <text>Open a Daisy book from the local file system</text> + <text>Open a DAISY book from the local file system</text> <originalText>Open a Daisy book from the local file system</originalText> <audio src="./audio/004_Open_a_Daisy_book_from_the_loc.mp3" from="file:///c:/devel/amis/Defaultlangpack/prompts/prom0005.smil#text_0005" /> </description> @@ -33,6 +33,23 @@ </mnemonic> </action> <!--new action--> + <action mfcid="ID_MENU_FILE_CLOSE" widget="menuItem"> + <note>This is going to be a menu item</note> + <icon src="./close.png" type="smallIcon" /> + <caption> + <text>Close</text> + <originalText>Close</originalText> + </caption> + <description> + <text>Close the DAISY publication.</text> + <originalText>Close the DAISY publication.</originalText> + </description> + <mnemonic> + <text>C</text> + <originalText>C</originalText> + </mnemonic> + </action> + <!--new action--> <action mfcid="ID_MENU_FILE_OPENURL" widget="menuItem"> <note>This is going to be a menu item</note> <icon src="./open.png" type="smallIcon" /> @@ -41,13 +58,17 @@ <originalText>Open URL...</originalText> </caption> <description> - <text>Open a Daisy book from a URL</text> + <text>Open a DAISY publication from a URL</text> <originalText>Open a Daisy book from a URL</originalText> </description> <accelerator> <text>Ctrl+U</text> <originalText>Ctrl+U</originalText> </accelerator> + <mnemonic> + <text>U</text> + <originalText>U</originalText> + </mnemonic> </action> <action mfcid="ID_MENU_FILE_LOADCD" widget="menuItem toolbarItem"> <note>This is going to be a menu item and a toolbar item</note> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |