amis-cvs Mailing List for AMIS (Page 3)
Brought to you by:
julienq,
marisademeglio
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(184) |
Sep
(89) |
Oct
(185) |
Nov
(71) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(45) |
Feb
(125) |
Mar
(138) |
Apr
(135) |
May
(72) |
Jun
(68) |
Jul
(23) |
Aug
(14) |
Sep
(39) |
Oct
(131) |
Nov
(43) |
Dec
(5) |
2007 |
Jan
(13) |
Feb
(16) |
Mar
(5) |
Apr
(28) |
May
(44) |
Jun
(63) |
Jul
(109) |
Aug
(19) |
Sep
(48) |
Oct
(35) |
Nov
(16) |
Dec
(27) |
2008 |
Jan
(40) |
Feb
(56) |
Mar
(97) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <mar...@us...> - 2008-03-12 03:45:08
|
Revision: 2404 http://amis.svn.sourceforge.net/amis/?rev=2404&view=rev Author: marisademeglio Date: 2008-03-11 20:45:11 -0700 (Tue, 11 Mar 2008) Log Message: ----------- Added text style dialog; not hooked up and not working yet. Modified Paths: -------------- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/include/Preferences.h branches/amis3/AmisGuiMFC2/include/gui/dialogs/SkipDialog.h branches/amis3/AmisGuiMFC2/include/util/Color.h branches/amis3/AmisGuiMFC2/resource.h branches/amis3/AmisGuiMFC2/src/Preferences.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/AmisGuiMFC2/src/util/Color.cpp Added Paths: ----------- branches/amis3/AmisGuiMFC2/include/gui/dialogs/TextStyleDialog.h branches/amis3/AmisGuiMFC2/src/gui/dialogs/TextStyleDialog.cpp Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-11 05:40:01 UTC (rev 2403) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-12 03:45:11 UTC (rev 2404) @@ -143,6 +143,14 @@ TOPMARGIN, 7 BOTTOMMARGIN, 216 END + + IDD_TEXTSTYLE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 386 + TOPMARGIN, 7 + BOTTOMMARGIN, 142 + END END #endif // APSTUDIO_INVOKED @@ -185,6 +193,7 @@ END MENUITEM "Bi&gger Font", ID_AMIS_BIGGER_FONT MENUITEM "S&maller Font", ID_AMIS_SMALLER_FONT + MENUITEM "&Text style...", ID_AMIS_SHOW_TEXTSTYLE END POPUP "&Play" BEGIN @@ -402,7 +411,29 @@ PUSHBUTTON "Cancel",IDCANCEL,112,202,50,14 END +IDD_TEXTSTYLE DIALOGEX 0, 0, 393, 149 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | + WS_SYSMENU +CAPTION "Text Style" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "Font:",IDC_FONTLABEL,7,7,155,12 + COMBOBOX IDC_FONT,7,20,155,30,CBS_DROPDOWN | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + LTEXT "Highlighted text color:",IDC_HIGHLIGHTFOREGROUNDLABEL,7, + 45,155,11 + COMBOBOX IDC_HIGHLIGHTFOREGROUND,7,57,155,30,CBS_DROPDOWN | + CBS_SORT | WS_VSCROLL | WS_TABSTOP + LTEXT "Highlight background color:", + IDC_HIGHLIGHTBACKGROUNDLABEL,7,83,156,8 + COMBOBOX IDC_HIGHLIGHTBACKGROUND,7,98,156,12,CBS_DROPDOWN | + CBS_SORT | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_TEXTSTYLEPREVIEW,211,7,175,135,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",IDOK,39,128,50,14 + PUSHBUTTON "Cancel",IDCANCEL,101,128,50,14 +END + ///////////////////////////////////////////////////////////////////////////// // // Bitmap Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2008-03-11 05:40:01 UTC (rev 2403) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2008-03-12 03:45:11 UTC (rev 2404) @@ -237,6 +237,9 @@ <File RelativePath=".\include\gui\dialogs\SkipDialog.h"> </File> + <File + RelativePath=".\include\gui\dialogs\TextStyleDialog.h"> + </File> </Filter> <Filter Name="sidebar" @@ -660,6 +663,9 @@ UsePrecompiledHeader="0"/> </FileConfiguration> </File> + <File + RelativePath=".\src\gui\dialogs\TextStyleDialog.cpp"> + </File> </Filter> <Filter Name="sidebar" Modified: branches/amis3/AmisGuiMFC2/include/Preferences.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/Preferences.h 2008-03-11 05:40:01 UTC (rev 2403) +++ branches/amis3/AmisGuiMFC2/include/Preferences.h 2008-03-12 03:45:11 UTC (rev 2404) @@ -38,13 +38,13 @@ public: //these should be private some day - //these values (should) come from parsing default.css + //these values come from TextRenderBrain after it parses amis.css util::Color mHighlightFG; util::Color mHighlightBG; std::string mFontName; - int mFontSize; util::Color mPageFG; util::Color mPageBG; + int mFontSize; public: static Preferences* Instance(); Modified: branches/amis3/AmisGuiMFC2/include/gui/dialogs/SkipDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/SkipDialog.h 2008-03-11 05:40:01 UTC (rev 2403) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/SkipDialog.h 2008-03-12 03:45:11 UTC (rev 2404) @@ -34,7 +34,6 @@ { namespace dialogs { - class SkipDialog : public AmisDialogBase { //friend class amis::gui::spoken::SkipDialogVoicing; @@ -55,9 +54,7 @@ virtual BOOL PreTranslateMessage(MSG* pMsg); protected: - //{{AFX_MSG(SkipDialog) afx_msg void OnPaint(); - //}}AFX_MSG DECLARE_MESSAGE_MAP() CCheckListBox m_ListSkips; private: Added: branches/amis3/AmisGuiMFC2/include/gui/dialogs/TextStyleDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/TextStyleDialog.h (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/TextStyleDialog.h 2008-03-12 03:45:11 UTC (rev 2404) @@ -0,0 +1,61 @@ +/* +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 +*/ +#ifndef TEXTSTYLEDIALOG_H +#define TEXTSTYLEDIALOG_H + +#include "gui/dialogs/AmisDialogBase.h" +#include "../resource.h" + +BOOL CALLBACK EnumFontCallback (LPLOGFONT, LPTEXTMETRIC, DWORD, LPARAM); + +namespace amis +{ +namespace gui +{ +namespace dialogs +{ + +class TextStyleDialog : public AmisDialogBase +{ +public: + TextStyleDialog(CWnd* pParent = NULL); + ~TextStyleDialog(); + enum { IDD = IDD_TEXTSTYLE }; + +protected: + void initializeCombos(); + virtual BOOL OnInitDialog(); + virtual BOOL PreTranslateMessage(MSG* pMsg); + afx_msg void OnCbnSelchangeFont(); + afx_msg void OnCbnSetfocusFont(); + afx_msg void OnCbnSelchangeHighlightForeground(); + afx_msg void OnCbnSetfocusHighlightForeground(); + afx_msg void OnCbnSelchangeHighlightBackground(); + afx_msg void OnCbnSetfocusHighlightBackground(); +protected: + afx_msg void OnPaint(); + DECLARE_MESSAGE_MAP() +}; +} +} +} +#endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/include/util/Color.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/util/Color.h 2008-03-11 05:40:01 UTC (rev 2403) +++ branches/amis3/AmisGuiMFC2/include/util/Color.h 2008-03-12 03:45:11 UTC (rev 2404) @@ -30,7 +30,6 @@ { namespace util { - class Color { private: @@ -44,11 +43,13 @@ void set(COLORREF); COLORREF getAsColorRef(); std::string getAsHtmlHexColor(); - static std::string getHexValueForNamedColor(std::string); + std::string getHexValueForNamedColor(std::string); + amis::StringMap* getColorHexMap(); private: static COLORREF htmlToRgb(std::string); static int _httoi(const TCHAR *value); static std::string getColorAsHtmlValue(COLORREF); + amis::StringMap mColorHexMap; }; } Modified: branches/amis3/AmisGuiMFC2/resource.h =================================================================== --- branches/amis3/AmisGuiMFC2/resource.h 2008-03-11 05:40:01 UTC (rev 2403) +++ branches/amis3/AmisGuiMFC2/resource.h 2008-03-12 03:45:11 UTC (rev 2404) @@ -2,9 +2,6 @@ // Microsoft Visual C++ generated include file. // Used by AmisGuiMFC2.rc // - -#define SELF_VOICING_PLAY_NEXT 6969 - #define IDD_ABOUTBOX 100 #define IDS_PROPSHT_CAPTION 102 #define IDD_SIDEBAR 103 @@ -29,6 +26,7 @@ #define IDB_BOOKSHELFMAG 186 #define IDD_OPENURL 190 #define IDD_PREFERENCES 191 +#define IDD_TEXTSTYLE 192 #define AMIS_RECENT_BOOK_BASE_ID 200 #define AMIS_SECTION_DEPTH_BASE_ID 250 #define AMIS_NAVLIST_BASE_ID 300 @@ -74,6 +72,14 @@ #define IDC_MULTIVOLCD_INSTRUCTIONS 1103 #define IDC_GOTOPAGE_CAPTION 1104 #define IDC_OPENURL_CAPTION 1105 +#define IDC_FONT 1106 +#define IDC_HIGHLIGHTFOREGROUND 1107 +#define IDC_HIGHLIGHTBACKGROUND 1108 +#define IDC_FONTLABEL 1109 +#define IDC_HIGHLIGHTFOREGROUNDLABEL 1110 +#define IDC_HIGHLIGHTBACKGROUNDLABEL 1111 +#define IDC_TEXTSTYLEPREVIEW 1112 +#define SELF_VOICING_PLAY_NEXT 6969 #define IDC_CURRLANG 9002 #define IDC_VERSION 9006 #define IDC_VERSIONNOTE 9007 @@ -111,6 +117,7 @@ #define ID_AMIS_SHOW_PUBLICATION_SUMMARY 32949 #define ID_AMIS_SHOW_HELP_CONTENTS 32950 #define ID_AMIS_ABOUT 32951 +#define ID_AMIS_SHOW_TEXTSTYLE 32953 #define IDS_SELFOLDER_TITLE 61258 #define IDS_SELFOLDER_INSTR 61259 #define IDS_FOLDERDOESNOTEXIST 61279 @@ -123,9 +130,9 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 192 -#define _APS_NEXT_COMMAND_VALUE 32952 -#define _APS_NEXT_CONTROL_VALUE 1106 +#define _APS_NEXT_RESOURCE_VALUE 193 +#define _APS_NEXT_COMMAND_VALUE 32954 +#define _APS_NEXT_CONTROL_VALUE 1113 #define _APS_NEXT_SYMED_VALUE 143 #endif #endif Modified: branches/amis3/AmisGuiMFC2/src/Preferences.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2008-03-11 05:40:01 UTC (rev 2403) +++ branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2008-03-12 03:45:11 UTC (rev 2404) @@ -425,7 +425,7 @@ p_log->writeMessage("\tLangpacks dir = ", &mLangpacksDir); p_log->writeMessage("\tFontsize css dir = ", &mFontsizeCssDir); p_log->writeMessage("\tContrast css dir = ", &mCustomCssDir); - p_log->writeMessage("\tUser css file = ", &mAmisCssFile); + p_log->writeMessage("\tAmis css file = ", &mAmisCssFile); p_log->writeMessage("\tZed2005 css file = ", &mZed2005CssFile); p_log->writeMessage("\tInstalled language packs:"); Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-03-11 05:40:01 UTC (rev 2403) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-03-12 03:45:11 UTC (rev 2404) @@ -654,8 +654,9 @@ VariantInit(&highlight_fg); p_rule_style->get_backgroundColor(&highlight_bg); p_rule_style->get_color(&highlight_fg); - string fg_color = amis::util::Color::getHexValueForNamedColor(OLE2A(highlight_fg.bstrVal)); - string bg_color = amis::util::Color::getHexValueForNamedColor(OLE2A(highlight_bg.bstrVal)); + util::Color dummy_color; + string fg_color = dummy_color.getHexValueForNamedColor(OLE2A(highlight_fg.bstrVal)); + string bg_color = dummy_color.getHexValueForNamedColor(OLE2A(highlight_bg.bstrVal)); Preferences::Instance()->mHighlightBG.set(bg_color); Preferences::Instance()->mHighlightFG.set(fg_color); p_rule_style->Release(); @@ -676,8 +677,9 @@ p_rule_style->get_fontFamily(&font_family); p_rule_style->get_fontSize(&font_size); - string fg_color = amis::util::Color::getHexValueForNamedColor(OLE2A(page_fg.bstrVal)); - string bg_color = amis::util::Color::getHexValueForNamedColor(OLE2A(page_bg.bstrVal)); + util::Color dummy_color; + string fg_color = dummy_color.getHexValueForNamedColor(OLE2A(page_fg.bstrVal)); + string bg_color = dummy_color.getHexValueForNamedColor(OLE2A(page_bg.bstrVal)); string font_name = OLE2A(font_family); //font names could look like "arial, verdana, sans-serif;" //just grab the first one Added: branches/amis3/AmisGuiMFC2/src/gui/dialogs/TextStyleDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/TextStyleDialog.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/TextStyleDialog.cpp 2008-03-12 03:45:11 UTC (rev 2404) @@ -0,0 +1,145 @@ +/* +AMIS: Adaptive Multimedia Information System +Software for playing DAISY books +Homepage: http://amis.sf.net + +Copyright (C) 2004-2008 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 "gui/dialogs/TextStyleDialog.h" +#include "../resource.h" +#include "AmisCore.h" +#include "util/Color.h" +#include "Preferences.h" + +using namespace amis::gui::dialogs; + +BEGIN_MESSAGE_MAP(TextStyleDialog, CDialog) + ON_WM_KEYUP() + ON_WM_KEYDOWN() + ON_CBN_SELCHANGE(IDC_FONT, OnCbnSelchangeFont) + ON_CBN_SETFOCUS(IDC_FONT, OnCbnSetfocusFont) + ON_CBN_SELCHANGE(IDC_HIGHLIGHTFOREGROUND, OnCbnSelchangeHighlightForeground) + ON_CBN_SETFOCUS(IDC_HIGHLIGHTFOREGROUND, OnCbnSetfocusHighlightForeground) + ON_CBN_SELCHANGE(IDC_HIGHLIGHTBACKGROUND, OnCbnSelchangeHighlightBackground) + ON_CBN_SETFOCUS(IDC_HIGHLIGHTBACKGROUND, OnCbnSetfocusHighlightBackground) + ON_WM_PAINT() +END_MESSAGE_MAP() + +BOOL CALLBACK EnumFontCallback (LPLOGFONT lplf, LPTEXTMETRIC lptm, DWORD dwType, LPARAM lpData) +{ + CComboBox* p_font_list = (CComboBox*)lpData; + int index = p_font_list->AddString(lplf->lfFaceName); + return TRUE; +} + +TextStyleDialog::TextStyleDialog(CWnd* pParent /*=NULL*/) + : AmisDialogBase(TextStyleDialog::IDD) +{ +} +TextStyleDialog::~TextStyleDialog() +{ +} +BOOL TextStyleDialog::OnInitDialog() +{ + initializeCombos(); + return CDialog::OnInitDialog(); +} +void TextStyleDialog::initializeCombos() +{ + USES_CONVERSION; + + CComboBox* p_foreground_list = (CComboBox*)GetDlgItem(IDC_HIGHLIGHTFOREGROUND); + CComboBox* p_background_list = (CComboBox*)GetDlgItem(IDC_HIGHLIGHTBACKGROUND); + + //workaround: color map is not static + util::Color dummy_color; + amis::StringMap* p_all_colors = dummy_color.getColorHexMap(); + + //the current values all come from Preferences + //TODO: save them to file + int foreground_sel = -1; + int background_sel = -1; + int i = 0; + amis::StringMap::iterator it = p_all_colors->begin(); + while (it != p_all_colors->end()) + { + CString label = A2T(it->first.c_str()); + p_foreground_list->AddString(label); + p_background_list->AddString(label); + if (it->second == Preferences::Instance()->mHighlightBG.getAsHtmlHexColor()) + background_sel = i; + if (it->second == Preferences::Instance()->mHighlightFG.getAsHtmlHexColor()) + foreground_sel = i; + i++; + it++; + } + p_foreground_list->SetCurSel(foreground_sel); + p_background_list->SetCurSel(background_sel); + + CClientDC dc(this); + EnumFonts (dc, 0,(FONTENUMPROC)EnumFontCallback,(LPARAM)this); +} +void TextStyleDialog::OnPaint() +{ + CPaintDC dc(this); // device context for painting + // Let the window do its default painting... + CWnd::DefWindowProc( WM_PAINT, (WPARAM)dc.m_hDC, 0 ); + //call the base class on_paint function + on_paint(); +} + + +BOOL TextStyleDialog::PreTranslateMessage(MSG* pMsg) +{ + if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) + { + CWnd* p_wnd = this->GetFocus(); + if (p_wnd) + { + int id = p_wnd->GetDlgCtrlID(); + //inexplicably, the default behavior for pressing enter in a dialog is to close it. + //we're overriding this here. + if (pMsg->wParam == VK_RETURN) + { + //do nothing + } + } + } + return AmisDialogBase::PreTranslateMessage(pMsg); +} + +//widget event handlers +void TextStyleDialog::OnCbnSelchangeFont() +{ +} +void TextStyleDialog::OnCbnSetfocusFont() +{ +} +void TextStyleDialog::OnCbnSelchangeHighlightForeground() +{ +} +void TextStyleDialog::OnCbnSetfocusHighlightForeground() +{ +} +void TextStyleDialog::OnCbnSelchangeHighlightBackground() +{ +} +void TextStyleDialog::OnCbnSetfocusHighlightBackground() +{ +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/util/Color.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/util/Color.cpp 2008-03-11 05:40:01 UTC (rev 2403) +++ branches/amis3/AmisGuiMFC2/src/util/Color.cpp 2008-03-12 03:45:11 UTC (rev 2404) @@ -27,6 +27,153 @@ Color::Color() { + //this should be the list of color names supported by IE + mColorHexMap["antiquewhite"]="#FAEBD7"; + mColorHexMap["aqua"]= "#00FFFF"; + mColorHexMap["aquamarine"]="#7FFFD4"; + mColorHexMap["azure"]="#F0FFFF"; + mColorHexMap["beige"]="#F5F5DC"; + mColorHexMap["bisque"]="#FFE4C4"; + mColorHexMap["black"]="#000000"; + mColorHexMap["blanchedalmond"]="#FFEBCD"; + mColorHexMap["blue"]="#0000FF"; + mColorHexMap["blueviolet"]="#8A2BE2"; + mColorHexMap["brown"]="#A52A2A"; + mColorHexMap["burlywood"]="#DEB887"; + mColorHexMap["cadetblue"]="#5F9EA0"; + mColorHexMap["chartreuse"]="#7FFF00"; + mColorHexMap["chocolate"]="#D2691E"; + mColorHexMap["coral"]="#FF7F50"; + mColorHexMap["cornflowerblue"]="#6495ED"; + mColorHexMap["cornsilk"]="#FFF8DC"; + mColorHexMap["crimson"]="#DC143C"; + mColorHexMap["cyan"]="#00FFFF"; + mColorHexMap["darkblue"]="#00008B"; + mColorHexMap["darkcyan"]="#008B8B"; + mColorHexMap["darkgoldenrod"]="#B8860B"; + mColorHexMap["darkgray"]="#A9A9A9"; + mColorHexMap["darkgrey"]="#A9A9A9"; + mColorHexMap["darkgreen"]="#006400"; + mColorHexMap["darkkhaki"]="#BDB76B"; + mColorHexMap["darkmagenta"]="#8B008B"; + mColorHexMap["darkolivegreen"]="#556B2F"; + mColorHexMap["darkorange"]="#FF8C00"; + mColorHexMap["darkorchid"]="#9932CC"; + mColorHexMap["darkred"]="#8B0000"; + mColorHexMap["darksalmon"]="#E9967A"; + mColorHexMap["darkseagreen"]="#8FBC8F"; + mColorHexMap["darkslateblue"]="#483D8B"; + mColorHexMap["darkslategray"]="#2F4F4F"; + mColorHexMap["darkslategrey"]="#2F4F4F"; + mColorHexMap["darkturquoise"]="#00CED1"; + mColorHexMap["darkviolet"]="#9400D3"; + mColorHexMap["deeppink"]="#FF1493"; + mColorHexMap["deepskyblue"]="#00BFFF"; + mColorHexMap["dimgray"]="#696969"; + mColorHexMap["dimgrey"]="#696969"; + mColorHexMap["dodgerblue"]="#1E90FF"; + mColorHexMap["firebrick"]="#B22222"; + mColorHexMap["floralwhite"]="#FFFAF0"; + mColorHexMap["forestgreen"]="#228B22"; + mColorHexMap["fuchsia"]="#FF00FF"; + mColorHexMap["gainsboro"]="#DCDCDC"; + mColorHexMap["ghostwhite"]="#F8F8FF"; + mColorHexMap["gold"]="#FFD700"; + mColorHexMap["goldenrod"]="#DAA520"; + mColorHexMap["gray"]="#808080"; + mColorHexMap["grey"]="#808080"; + mColorHexMap["green"]="#008000"; + mColorHexMap["greenyellow"]="#ADFF2F"; + mColorHexMap["honeydew"]="#F0FFF0"; + mColorHexMap["hotpink"]="#FF69B4"; + mColorHexMap["indianred"]="#CD5C5C"; + mColorHexMap["indigo"]="#4B0082"; + mColorHexMap["ivory"]="#FFFFF0"; + mColorHexMap["khaki"]="#F0E68C"; + mColorHexMap["lavender"]="#E6E6FA"; + mColorHexMap["lavenderblush"]="#FFF0F5"; + mColorHexMap["lawngreen"]="#7CFC00"; + mColorHexMap["lemonchiffon"]="#FFFACD"; + mColorHexMap["lightblue"]="#ADD8E6"; + mColorHexMap["lightcoral"]="#F08080"; + mColorHexMap["lightcyan"]="#E0FFFF"; + mColorHexMap["lightgoldenrodyellow"]="#FAFAD2"; + mColorHexMap["lightgray"]="#D3D3D3"; + mColorHexMap["lightgrey"]="#D3D3D3"; + mColorHexMap["lightgreen"]="#90EE90"; + mColorHexMap["lightpink"]="#FFB6C1"; + mColorHexMap["lightsalmon"]="#FFA07A"; + mColorHexMap["lightseagreen"]="#20B2AA"; + mColorHexMap["lightskyblue"]="#87CEFA"; + mColorHexMap["lightslategray"]="#778899"; + mColorHexMap["lightslategrey"]="#778899"; + mColorHexMap["lightsteelblue"]="#B0C4DE"; + mColorHexMap["lightYellow"]="#FFFFE0"; + mColorHexMap["lime"]="#00FF00"; + mColorHexMap["limegreen"]="#32CD32"; + mColorHexMap["linen"]="#FAF0E6"; + mColorHexMap["magenta"]="#FF00FF"; + mColorHexMap["maroon"]="#800000"; + mColorHexMap["mediumaquamarine"]="#66CDAA"; + mColorHexMap["mediumblue"]="#0000CD"; + mColorHexMap["mediumorchid"]="#BA55D3"; + mColorHexMap["mediumpurple"]="#9370D8"; + mColorHexMap["mediumseagreen"]="#3CB371"; + mColorHexMap["mediumslateblue"]="#7B68EE"; + mColorHexMap["mediumspringgreen"]="#00FA9A"; + mColorHexMap["mediumturquoise"]="#48D1CC"; + mColorHexMap["mediumvioletred"]="#C71585"; + mColorHexMap["midnightblue"]="#191970"; + mColorHexMap["mintcream"]="#F5FFFA"; + mColorHexMap["mistyrose"]="#FFE4E1"; + mColorHexMap["moccasin"]="#FFE4B5"; + mColorHexMap["navajowhite"]="#FFDEAD"; + mColorHexMap["navy"]="#000080"; + mColorHexMap["oldlace"]="#FDF5E6"; + mColorHexMap["olive"]="#808000"; + mColorHexMap["olivedrab"]="#6B8E23"; + mColorHexMap["orange"]="#FFA500"; + mColorHexMap["orangered"]="#FF4500"; + mColorHexMap["orchid"]="#DA70D6"; + mColorHexMap["palegoldenrod"]="#EEE8AA"; + mColorHexMap["palegreen"]="#98FB98"; + mColorHexMap["paleturquoise"]="#AFEEEE"; + mColorHexMap["palevioletred"]="#D87093"; + mColorHexMap["papayawhip"]="#FFEFD5"; + mColorHexMap["peachpuff"]="#FFDAB9"; + mColorHexMap["peru"]="#CD853F"; + mColorHexMap["pink"]="#FFC0CB"; + mColorHexMap["plum"]="#DDA0DD"; + mColorHexMap["powderblue"]="#B0E0E6"; + mColorHexMap["purple"]="#800080"; + mColorHexMap["red"]="#FF0000"; + mColorHexMap["rosybrown"]="#BC8F8F"; + mColorHexMap["royalblue"]="#4169E1"; + mColorHexMap["saddlebrown"]="#8B4513"; + mColorHexMap["salmon"]="#FA8072"; + mColorHexMap["sandybrown"]="#F4A460"; + mColorHexMap["seagreen"]="#2E8B57"; + mColorHexMap["seashell"]="#FFF5EE"; + mColorHexMap["sienna"]="#A0522D"; + mColorHexMap["silver"]="#C0C0C0"; + mColorHexMap["skyblue"]="#87CEEB"; + mColorHexMap["slateblue"]="#6A5ACD"; + mColorHexMap["slategray"]="#708090"; + mColorHexMap["slategrey"]="#708090"; + mColorHexMap["snow"]="#FFFAFA"; + mColorHexMap["springgreen"]="#00FF7F"; + mColorHexMap["steelblue"]="#4682B4"; + mColorHexMap["tan"]="#D2B48C"; + mColorHexMap["teal"]="#008080"; + mColorHexMap["thistle"]="#D8BFD8"; + mColorHexMap["tomato"]="#FF6347"; + mColorHexMap["turquoise"]="#40E0D0"; + mColorHexMap["violet"]="#EE82EE"; + mColorHexMap["wheat"]="#F5DEB3"; + mColorHexMap["white"]="#FFFFFF"; + mColorHexMap["whitesmoke"]="#F5F5F5"; + mColorHexMap["yellow"]="#FFFF00"; + mColorHexMap["yellowgreen"]="#9ACD32"; } //this expects a HEX value Color::Color(std::string value) @@ -148,9 +295,7 @@ std::string Color::getColorAsHtmlValue(COLORREF color_ref) { USES_CONVERSION; - std::string ret_val; - //wstring tmp_ret_val; BYTE rVal = GetRValue(color_ref); BYTE gVal = GetGValue(color_ref); @@ -165,159 +310,15 @@ //input: a color name //output: #RRGGBB -//if no match is found, the input parameter is returned as-is std::string Color::getHexValueForNamedColor(std::string colorName) { std::string color = colorName; //make lower case std::transform(color.begin(), color.end(), color.begin(), (int(*)(int))tolower); - //this should be the list of color names supported by IE + return mColorHexMap[color]; +} - if (!color.compare("antiquewhite")) return "#FAEBD7"; - if (!color.compare("aqua")) return "#00FFFF"; - if (!color.compare("aquamarine")) return "#7FFFD4"; - if (!color.compare("azure")) return "#F0FFFF"; - if (!color.compare("beige")) return "#F5F5DC"; - if (!color.compare("bisque")) return "#FFE4C4"; - if (!color.compare("black")) return "#000000"; - if (!color.compare("blanchedalmond")) return "#FFEBCD"; - if (!color.compare("blue")) return "#0000FF"; - if (!color.compare("blueviolet")) return "#8A2BE2"; - if (!color.compare("brown")) return "#A52A2A"; - if (!color.compare("burlywood")) return "#DEB887"; - if (!color.compare("cadetblue")) return "#5F9EA0"; - if (!color.compare("chartreuse")) return "#7FFF00"; - if (!color.compare("chocolate")) return "#D2691E"; - if (!color.compare("coral")) return "#FF7F50"; - if (!color.compare("cornflowerblue")) return "#6495ED"; - if (!color.compare("cornsilk")) return "#FFF8DC"; - if (!color.compare("crimson")) return "#DC143C"; - if (!color.compare("cyan")) return "#00FFFF"; - if (!color.compare("darkblue")) return "#00008B"; - if (!color.compare("darkcyan")) return "#008B8B"; - if (!color.compare("darkgoldenrod")) return "#B8860B"; - if (!color.compare("darkgray")) return "#A9A9A9"; - if (!color.compare("darkgrey")) return "#A9A9A9"; - if (!color.compare("darkgreen")) return "#006400"; - if (!color.compare("darkkhaki")) return "#BDB76B"; - if (!color.compare("darkmagenta")) return "#8B008B"; - if (!color.compare("darkolivegreen")) return "#556B2F"; - if (!color.compare("darkorange")) return "#FF8C00"; - if (!color.compare("darkorchid")) return "#9932CC"; - if (!color.compare("darkred")) return "#8B0000"; - if (!color.compare("darksalmon")) return "#E9967A"; - if (!color.compare("darkseagreen")) return "#8FBC8F"; - if (!color.compare("darkslateblue")) return "#483D8B"; - if (!color.compare("darkslategray")) return "#2F4F4F"; - if (!color.compare("darkslategrey")) return "#2F4F4F"; - if (!color.compare("darkturquoise")) return "#00CED1"; - if (!color.compare("darkviolet")) return "#9400D3"; - if (!color.compare("deeppink")) return "#FF1493"; - if (!color.compare("deepskyblue")) return "#00BFFF"; - if (!color.compare("dimgray")) return "#696969"; - if (!color.compare("dimgrey")) return "#696969"; - if (!color.compare("dodgerblue")) return "#1E90FF"; - if (!color.compare("firebrick")) return "#B22222"; - if (!color.compare("floralwhite")) return "#FFFAF0"; - if (!color.compare("forestgreen")) return "#228B22"; - if (!color.compare("fuchsia")) return "#FF00FF"; - if (!color.compare("gainsboro")) return "#DCDCDC"; - if (!color.compare("ghostwhite")) return "#F8F8FF"; - if (!color.compare("gold")) return "#FFD700"; - if (!color.compare("goldenrod")) return "#DAA520"; - if (!color.compare("gray")) return "#808080"; - if (!color.compare("grey")) return "#808080"; - if (!color.compare("green")) return "#008000"; - if (!color.compare("greenyellow")) return "#ADFF2F"; - if (!color.compare("honeydew")) return "#F0FFF0"; - if (!color.compare("hotpink")) return "#FF69B4"; - if (!color.compare("indianred")) return "#CD5C5C"; - if (!color.compare("indigo")) return "#4B0082"; - if (!color.compare("ivory")) return "#FFFFF0"; - if (!color.compare("khaki")) return "#F0E68C"; - if (!color.compare("lavender")) return "#E6E6FA"; - if (!color.compare("lavenderblush")) return "#FFF0F5"; - if (!color.compare("lawngreen")) return "#7CFC00"; - if (!color.compare("lemonchiffon")) return "#FFFACD"; - if (!color.compare("lightblue")) return "#ADD8E6"; - if (!color.compare("lightcoral")) return "#F08080"; - if (!color.compare("lightcyan")) return "#E0FFFF"; - if (!color.compare("lightgoldenrodyellow")) return "#FAFAD2"; - if (!color.compare("lightgray")) return "#D3D3D3"; - if (!color.compare("lightgrey")) return "#D3D3D3"; - if (!color.compare("lightgreen")) return "#90EE90"; - if (!color.compare("lightpink")) return "#FFB6C1"; - if (!color.compare("lightsalmon")) return "#FFA07A"; - if (!color.compare("lightseagreen")) return "#20B2AA"; - if (!color.compare("lightskyblue")) return "#87CEFA"; - if (!color.compare("lightslategray")) return "#778899"; - if (!color.compare("lightslategrey")) return "#778899"; - if (!color.compare("lightsteelblue")) return "#B0C4DE"; - if (!color.compare("lightYellow")) return "#FFFFE0"; - if (!color.compare("lime")) return "#00FF00"; - if (!color.compare("limegreen")) return "#32CD32"; - if (!color.compare("linen")) return "#FAF0E6"; - if (!color.compare("magenta")) return "#FF00FF"; - if (!color.compare("maroon")) return "#800000"; - if (!color.compare("mediumaquamarine")) return "#66CDAA"; - if (!color.compare("mediumblue")) return "#0000CD"; - if (!color.compare("mediumorchid")) return "#BA55D3"; - if (!color.compare("mediumpurple")) return "#9370D8"; - if (!color.compare("mediumseagreen")) return "#3CB371"; - if (!color.compare("mediumslateblue")) return "#7B68EE"; - if (!color.compare("mediumspringgreen")) return "#00FA9A"; - if (!color.compare("mediumturquoise")) return "#48D1CC"; - if (!color.compare("mediumvioletred")) return "#C71585"; - if (!color.compare("midnightblue")) return "#191970"; - if (!color.compare("mintcream")) return "#F5FFFA"; - if (!color.compare("mistyrose")) return "#FFE4E1"; - if (!color.compare("moccasin")) return "#FFE4B5"; - if (!color.compare("navajowhite")) return "#FFDEAD"; - if (!color.compare("navy")) return "#000080"; - if (!color.compare("oldlace")) return "#FDF5E6"; - if (!color.compare("olive")) return "#808000"; - if (!color.compare("olivedrab")) return "#6B8E23"; - if (!color.compare("orange")) return "#FFA500"; - if (!color.compare("orangered")) return "#FF4500"; - if (!color.compare("orchid")) return "#DA70D6"; - if (!color.compare("palegoldenrod")) return "#EEE8AA"; - if (!color.compare("palegreen")) return "#98FB98"; - if (!color.compare("paleturquoise")) return "#AFEEEE"; - if (!color.compare("palevioletred")) return "#D87093"; - if (!color.compare("papayawhip")) return "#FFEFD5"; - if (!color.compare("peachpuff")) return "#FFDAB9"; - if (!color.compare("peru")) return "#CD853F"; - if (!color.compare("pink")) return "#FFC0CB"; - if (!color.compare("plum")) return "#DDA0DD"; - if (!color.compare("powderblue")) return "#B0E0E6"; - if (!color.compare("purple")) return "#800080"; - if (!color.compare("red")) return "#FF0000"; - if (!color.compare("rosybrown")) return "#BC8F8F"; - if (!color.compare("royalblue")) return "#4169E1"; - if (!color.compare("saddlebrown")) return "#8B4513"; - if (!color.compare("salmon")) return "#FA8072"; - if (!color.compare("sandybrown")) return "#F4A460"; - if (!color.compare("seagreen")) return "#2E8B57"; - if (!color.compare("seashell")) return "#FFF5EE"; - if (!color.compare("sienna")) return "#A0522D"; - if (!color.compare("silver")) return "#C0C0C0"; - if (!color.compare("skyblue")) return "#87CEEB"; - if (!color.compare("slateblue")) return "#6A5ACD"; - if (!color.compare("slategray")) return "#708090"; - if (!color.compare("slategrey")) return "#708090"; - if (!color.compare("snow")) return "#FFFAFA"; - if (!color.compare("springgreen")) return "#00FF7F"; - if (!color.compare("steelblue")) return "#4682B4"; - if (!color.compare("tan")) return "#D2B48C"; - if (!color.compare("teal")) return "#008080"; - if (!color.compare("thistle")) return "#D8BFD8"; - if (!color.compare("tomato")) return "#FF6347"; - if (!color.compare("turquoise")) return "#40E0D0"; - if (!color.compare("violet")) return "#EE82EE"; - if (!color.compare("wheat")) return "#F5DEB3"; - if (!color.compare("white")) return "#FFFFFF"; - if (!color.compare("whitesmoke")) return "#F5F5F5"; - if (!color.compare("yellow")) return "#FFFF00"; - if (!color.compare("yellowgreen")) return "#9ACD32"; - return colorName; +amis::StringMap* Color::getColorHexMap() +{ + return &mColorHexMap; } \ 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...> - 2008-03-11 05:39:59
|
Revision: 2403 http://amis.svn.sourceforge.net/amis/?rev=2403&view=rev Author: marisademeglio Date: 2008-03-10 22:40:01 -0700 (Mon, 10 Mar 2008) Log Message: ----------- updated to reflect latest code Modified Paths: -------------- branches/amis3/amis_issues.txt Modified: branches/amis3/amis_issues.txt =================================================================== --- branches/amis3/amis_issues.txt 2008-03-11 05:33:02 UTC (rev 2402) +++ branches/amis3/amis_issues.txt 2008-03-11 05:40:01 UTC (rev 2403) @@ -26,7 +26,6 @@ * Listviews have more than one column, cutting off text * Sidebar intercepts shift+arrow even when I tell it not to. * window resizing problems with HTML view -* bookmarking for non-ascii dc:identifiers BUG REPORTS --- @@ -113,4 +112,5 @@ * Supports an unlimited number of font size CSS files. The default is still 4. * If no dc:identifier or the bookmark file can't be created, it no longer crashes * publication summary dialog not getting current section for zed books -* "previous section" works as it should \ No newline at end of file +* "previous section" works as it should +* bookmarking for books with non-ascii dc:identifiers \ 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...> - 2008-03-11 05:32:57
|
Revision: 2402 http://amis.svn.sourceforge.net/amis/?rev=2402&view=rev Author: marisademeglio Date: 2008-03-10 22:33:02 -0700 (Mon, 10 Mar 2008) Log Message: ----------- history file renamed Added Paths: ----------- branches/amis3/bin/settings/amisHistory.xml.default Removed Paths: ------------- branches/amis3/bin/settings/amisRecentBooks.xml.default Copied: branches/amis3/bin/settings/amisHistory.xml.default (from rev 2401, branches/amis3/bin/settings/amisRecentBooks.xml.default) =================================================================== --- branches/amis3/bin/settings/amisHistory.xml.default (rev 0) +++ branches/amis3/bin/settings/amisHistory.xml.default 2008-03-11 05:33:02 UTC (rev 2402) @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no" ?><bookList xmlns="http://amisproject.org" name="History"></bookList> \ No newline at end of file Deleted: branches/amis3/bin/settings/amisRecentBooks.xml.default =================================================================== --- branches/amis3/bin/settings/amisRecentBooks.xml.default 2008-03-11 05:32:16 UTC (rev 2401) +++ branches/amis3/bin/settings/amisRecentBooks.xml.default 2008-03-11 05:33:02 UTC (rev 2402) @@ -1 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no" ?><bookList xmlns="http://amisproject.org" name="History"></bookList> \ 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...> - 2008-03-11 05:32:09
|
Revision: 2401 http://amis.svn.sourceforge.net/amis/?rev=2401&view=rev Author: marisademeglio Date: 2008-03-10 22:32:16 -0700 (Mon, 10 Mar 2008) Log Message: ----------- bookmarking now supported for books with non-ascii dc:identifier values the recent books list has changed and is now a general history list. it keeps track of the book path, the uid, and the bookmark file path. this way, a bookmark file can be found by matching the uid of the book. this is also faster than searching the bookmark directory for a filename that looks like a match. bookmark files are mangled programatically and so they should be consistently found even if the history list gets corrupted or disappears. Modified Paths: -------------- branches/amis3/AmisCore/AmisCore.vcproj 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/AmisCore/src/io/BookmarksFileIO.cpp branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp branches/amis3/bin/settings/amisRecentBooks.xml.default branches/amis3/bin/settings/makeLocalCopiesOfDefaults.bat Added Paths: ----------- branches/amis3/AmisCore/include/BookList.h branches/amis3/AmisCore/include/io/BookListFileIO.h branches/amis3/AmisCore/src/BookList.cpp branches/amis3/AmisCore/src/io/BookListFileIO.cpp Removed Paths: ------------- branches/amis3/AmisCore/include/RecentBooks.h branches/amis3/AmisCore/include/io/RecentBooksFileIO.h branches/amis3/AmisCore/src/RecentBooks.cpp branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp Modified: branches/amis3/AmisCore/AmisCore.vcproj =================================================================== --- branches/amis3/AmisCore/AmisCore.vcproj 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisCore/AmisCore.vcproj 2008-03-11 05:32:16 UTC (rev 2401) @@ -112,6 +112,9 @@ </FileConfiguration> </File> <File + RelativePath=".\src\BookList.cpp"> + </File> + <File RelativePath=".\src\Error.cpp"> <FileConfiguration Name="Debug|Win32"> @@ -138,19 +141,13 @@ UsePrecompiledHeader="0"/> </FileConfiguration> </File> - <File - RelativePath=".\src\RecentBooks.cpp"> - <FileConfiguration - Name="Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0"/> - </FileConfiguration> - </File> <Filter Name="io" Filter=""> <File + RelativePath=".\src\io\BookListFileIO.cpp"> + </File> + <File RelativePath=".\src\io\BookmarksFileIO.cpp"> <FileConfiguration Name="Debug|Win32"> @@ -196,15 +193,6 @@ RelativePath=".\src\io\QuickDataSmilFileReader.cpp"> </File> <File - RelativePath=".\src\io\RecentBooksFileIO.cpp"> - <FileConfiguration - Name="Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0"/> - </FileConfiguration> - </File> - <File RelativePath=".\src\io\SmilFileReader.cpp"> <FileConfiguration Name="Debug|Win32"> @@ -493,6 +481,9 @@ RelativePath=".\include\AmisCore.h"> </File> <File + RelativePath=".\include\BookList.h"> + </File> + <File RelativePath=".\include\Error.h"> </File> <File @@ -501,13 +492,13 @@ <File RelativePath=".\include\ModuleDescData.h"> </File> - <File - RelativePath=".\include\RecentBooks.h"> - </File> <Filter Name="io" Filter=""> <File + RelativePath=".\include\io\BookListFileIO.h"> + </File> + <File RelativePath=".\include\io\BookmarksFileIO.h"> </File> <File @@ -529,9 +520,6 @@ RelativePath=".\include\io\QuickDataSmilFileReader.h"> </File> <File - RelativePath=".\include\io\RecentBooksFileIO.h"> - </File> - <File RelativePath=".\include\io\SmilFileReader.h"> </File> <File Copied: branches/amis3/AmisCore/include/BookList.h (from rev 2399, branches/amis3/AmisCore/include/RecentBooks.h) =================================================================== --- branches/amis3/AmisCore/include/BookList.h (rev 0) +++ branches/amis3/AmisCore/include/BookList.h 2008-03-11 05:32:16 UTC (rev 2401) @@ -0,0 +1,66 @@ +/* +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 +*/ +#ifndef BOOKLIST_H +#define BOOKLIST_H + +#include <string> +#include <vector> +#include "ambulant/net/url.h" + +using namespace std; + +namespace amis +{ +class BookEntry +{ +public: + BookEntry(); + ~BookEntry(); + + std::wstring mUid; + ambulant::net::url mPath; + ambulant::net::url mBmkPath; + bool mbIsLastRead; +}; +class BookList +{ +public: + BookList(); + ~BookList(); + int getNumberOfEntries(); + amis::BookEntry* getEntry(unsigned int); + void addEntry(amis::BookEntry*); + void deleteEntry(unsigned int); + amis::BookEntry* getLastRead(); + const ambulant::net::url* getFilepath(); + void setFilepath(const ambulant::net::url*); + void setName(std::wstring); + std::wstring getName(); + amis::BookEntry* findByUid(wstring); +private: + void cleanUpVector(); + ambulant::net::url mFilepath; + vector<amis::BookEntry*> mItems; + std::wstring mName; +}; +} +#endif Deleted: branches/amis3/AmisCore/include/RecentBooks.h =================================================================== --- branches/amis3/AmisCore/include/RecentBooks.h 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisCore/include/RecentBooks.h 2008-03-11 05:32:16 UTC (rev 2401) @@ -1,68 +0,0 @@ -/* -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 -*/ -#ifndef BOOKLIST_H -#define BOOKLIST_H - -#include <string> -#include <vector> -#include "ambulant/net/url.h" - -using namespace std; - -namespace amis -{ -class BookEntry -{ -public: - BookEntry(); - ~BookEntry(); - - std::wstring mUid; - ambulant::net::url mPath; - ambulant::net::url mBmkPath; - bool mbIsLastRead; -}; -class BookList -{ -public: - BookList(); - ~BookList(); - int getNumberOfEntries(); - amis::BookEntry* getEntry(unsigned int); - void addEntry(amis::BookEntry*); - void deleteEntry(unsigned int); - int getMaxItemsAllowed(); - void setMaxItemsAllowed(unsigned int); - amis::BookEntry* getLastRead(); - const ambulant::net::url* getFilepath(); - void setFilepath(const ambulant::net::url*); - void setName(std::wstring); - std::wstring getName(); -private: - void cleanUpVector(); - unsigned int mMax; - ambulant::net::url mFilepath; - vector<amis::BookEntry*> mItems; - std::wstring mName; -}; -} -#endif Modified: branches/amis3/AmisCore/include/dtb/Dtb.h =================================================================== --- branches/amis3/AmisCore/include/dtb/Dtb.h 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisCore/include/dtb/Dtb.h 2008-03-11 05:32:16 UTC (rev 2401) @@ -45,8 +45,8 @@ Dtb(); ~Dtb(); - bool open(const ambulant::net::url*, const ambulant::net::url*); - bool open(string, string); + bool open(const ambulant::net::url*, const ambulant::net::url*, amis::BookList*); + bool open(string, string, amis::BookList*); amis::dtb::smil::SmilMediaGroup* startReading(bool); amis::dtb::smil::SmilMediaGroup* nextPhrase(); amis::dtb::smil::SmilMediaGroup* previousPhrase(); @@ -96,6 +96,7 @@ amis::dtb::BookmarkSet* mpBookmarks; amis::dtb::CustomTestSet* mpCustomTests; DtbFileSet* mpFiles; + amis::BookList* mpHistory; std::wstring mUid; amis::StringMap* mpTextSmilMap; wstring mLastSearchString; Modified: branches/amis3/AmisCore/include/dtb/DtbFileSet.h =================================================================== --- branches/amis3/AmisCore/include/dtb/DtbFileSet.h 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisCore/include/dtb/DtbFileSet.h 2008-03-11 05:32:16 UTC (rev 2401) @@ -27,6 +27,7 @@ #include "AmisCore.h" #include "ambulant/net/url.h" #include "util/SearchForFiles.h" +#include "BookList.h" using namespace std; @@ -46,7 +47,10 @@ static bool isOpfFile(const ambulant::net::url*); //set additional information void setBookmarksDirectory(const ambulant::net::url*); - void setAdditionalDataAfterInitialParse(wstring, const ambulant::net::url*, const ambulant::net::url*); + void setAdditionalDataAfterInitialParse(wstring, + const ambulant::net::url*, + const ambulant::net::url*, + amis::BookList*); //get data const ambulant::net::url* getBookDirectory(); const ambulant::net::url* getNavFilepath(); Copied: branches/amis3/AmisCore/include/io/BookListFileIO.h (from rev 2399, branches/amis3/AmisCore/include/io/RecentBooksFileIO.h) =================================================================== --- branches/amis3/AmisCore/include/io/BookListFileIO.h (rev 0) +++ branches/amis3/AmisCore/include/io/BookListFileIO.h 2008-03-11 05:32:16 UTC (rev 2401) @@ -0,0 +1,79 @@ +/* +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 +*/ +#ifndef BOOKLISTFILEIO_H +#define BOOKLISTFILEIO_H + +#include "BookList.h" +#include "io/XercesSaxParseBase.h" + +#include <string> +#include <vector> + +#include <xercesc/sax2/DefaultHandler.hpp> +#include <xercesc/dom/DOM.hpp> +#include <xercesc/parsers/XercesDOMParser.hpp> + +XERCES_CPP_NAMESPACE_USE + +XERCES_CPP_NAMESPACE_BEGIN +class Attributes; +XERCES_CPP_NAMESPACE_END + +namespace amis +{ +namespace io +{ +class BookListFileIO : public XercesSaxParseBase +{ +public: + BookListFileIO(); + ~BookListFileIO(); + + bool readFromFile(const ambulant::net::url*); + amis::BookList* getBookList(); + //write the file to disk + bool writeToFile(const ambulant::net::url*, amis::BookList*); + + void startElement(const XMLCh* const uri, + const XMLCh* const localname, + const XMLCh* const qname, + const Attributes& attributes); + void endElement(const XMLCh* const uri, + const XMLCh* const localname, + const XMLCh* const qname) + {/*we don't need this method*/} + void characters(const XMLCh *const, const unsigned int) + {/*we don't need this method*/} + +private: + void writeBookEntry(amis::BookEntry*); + ambulant::net::url mFilePath; + //the books list file object model + amis::BookList* mpBookList; + amis::BookEntry* mpCurrentEntry; + //The DOM document pointer + xercesc_2_7::DOMDocument* mpDoc; +}; +} +} + +#endif Deleted: branches/amis3/AmisCore/include/io/RecentBooksFileIO.h =================================================================== --- branches/amis3/AmisCore/include/io/RecentBooksFileIO.h 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisCore/include/io/RecentBooksFileIO.h 2008-03-11 05:32:16 UTC (rev 2401) @@ -1,79 +0,0 @@ -/* -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 -*/ -#ifndef BOOKLISTFILEIO_H -#define BOOKLISTFILEIO_H - -#include "RecentBooks.h" -#include "io/XercesSaxParseBase.h" - -#include <string> -#include <vector> - -#include <xercesc/sax2/DefaultHandler.hpp> -#include <xercesc/dom/DOM.hpp> -#include <xercesc/parsers/XercesDOMParser.hpp> - -XERCES_CPP_NAMESPACE_USE - -XERCES_CPP_NAMESPACE_BEGIN -class Attributes; -XERCES_CPP_NAMESPACE_END - -namespace amis -{ -namespace io -{ -class BookListFileIO : public XercesSaxParseBase -{ -public: - BookListFileIO(); - ~BookListFileIO(); - - bool readFromFile(const ambulant::net::url*); - amis::BookList* getBookList(); - //write the file to disk - bool writeToFile(const ambulant::net::url*, amis::BookList*); - - void startElement(const XMLCh* const uri, - const XMLCh* const localname, - const XMLCh* const qname, - const Attributes& attributes); - void endElement(const XMLCh* const uri, - const XMLCh* const localname, - const XMLCh* const qname) - {/*we don't need this method*/} - void characters(const XMLCh *const, const unsigned int) - {/*we don't need this method*/} - -private: - void writeBookEntry(amis::BookEntry*); - ambulant::net::url mFilePath; - //the books list file object model - amis::BookList* mpBookList; - amis::BookEntry* mpCurrentEntry; - //The DOM document pointer - xercesc_2_7::DOMDocument* mpDoc; -}; -} -} - -#endif Copied: branches/amis3/AmisCore/src/BookList.cpp (from rev 2399, branches/amis3/AmisCore/src/RecentBooks.cpp) =================================================================== --- branches/amis3/AmisCore/src/BookList.cpp (rev 0) +++ branches/amis3/AmisCore/src/BookList.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -0,0 +1,152 @@ +/* +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 "BookList.h" +#include "util/FilePathTools.h" +#include <iostream> +using namespace std; + +amis::BookEntry::BookEntry() +{ + this->mbIsLastRead= false; +} + +amis::BookEntry::~BookEntry() +{ +} +amis::BookList::BookList() +{ + mItems.clear(); +} + +amis::BookList::~BookList() +{ + cleanUpVector(); +} +void amis::BookList::cleanUpVector() +{ + int sz = mItems.size(); + amis::BookEntry* p_tmp; + for (int i = sz-1; i>=0; i--) + { + p_tmp = mItems[i]; + mItems.pop_back(); + if (p_tmp != NULL) delete p_tmp; + } +} +int amis::BookList::getNumberOfEntries() +{ + return mItems.size(); +} +void amis::BookList::setName(std::wstring name) +{ + mName = name; +} +std::wstring amis::BookList::getName() +{ + return mName; +} +amis::BookEntry* amis::BookList::getEntry(unsigned int idx) +{ + if (idx >= 0 && idx < mItems.size()) + return mItems[idx]; + else + return NULL; +} + +void amis::BookList::addEntry(amis::BookEntry* pEntry) +{ + int n_duplicate = -1; + //first check for duplicates + if (mItems.size() > 0) + { + for (int i=0; i<mItems.size(); i++) + { + if (mItems[i]->mUid.compare(pEntry->mUid) == 0 && mItems[i]->mUid.size() > 0) + { + n_duplicate = i; + break; + } + } + + //if we found a duplicate, delete it from its original position + //and add our new (identical) entry at the end of the list + if (n_duplicate > -1) + deleteEntry(n_duplicate); + } + + //add the new entry + mItems.push_back(pEntry); + + //only one book can be the last read book! + if (pEntry->mbIsLastRead == true) + { + amis::BookEntry* p_tmp = NULL; + for (unsigned int i = 0; i<mItems.size() - 1; i++) + { + p_tmp = mItems[i]; + p_tmp->mbIsLastRead = false; + } + } +} +void amis::BookList::deleteEntry(unsigned int idx) +{ + std::vector<amis::BookEntry*>::iterator it; + + if (idx < mItems.size() && idx >= 0) + { + it = mItems.begin() + idx; + mItems.erase(it); + } +} + +amis::BookEntry* amis::BookList::getLastRead() +{ + amis::BookEntry* p_tmp = NULL; + for (unsigned int i = 0; i<mItems.size(); i++) + { + p_tmp = mItems[i]; + if (p_tmp->mbIsLastRead == true) break; + } + return p_tmp; +} + +void amis::BookList::setFilepath(const ambulant::net::url* pFilepath) +{ + mFilepath = *pFilepath; +} + +const ambulant::net::url* amis::BookList::getFilepath() +{ + return &mFilepath; +} + +amis::BookEntry* amis::BookList::findByUid(wstring uid) +{ + for (int i=0; i<mItems.size(); i++) + { + if (mItems[i]->mUid.compare(uid) == 0 && uid.size() > 0) + { + return mItems[i]; + } + } + return NULL; +} \ No newline at end of file Deleted: branches/amis3/AmisCore/src/RecentBooks.cpp =================================================================== --- branches/amis3/AmisCore/src/RecentBooks.cpp 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisCore/src/RecentBooks.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -1,158 +0,0 @@ -/* -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 "RecentBooks.h" -#include "util/FilePathTools.h" -#include <iostream> -using namespace std; - -amis::BookEntry::BookEntry() -{ - this->mbIsLastRead= false; -} - -amis::BookEntry::~BookEntry() -{ -} -amis::BookList::BookList() -{ - mMax = 0; - mItems.clear(); -} - -amis::BookList::~BookList() -{ - cleanUpVector(); -} -void amis::BookList::cleanUpVector() -{ - int sz = mItems.size(); - amis::BookEntry* p_tmp; - for (int i = sz-1; i>=0; i--) - { - p_tmp = mItems[i]; - mItems.pop_back(); - if (p_tmp != NULL) delete p_tmp; - } -} - -void amis::BookList::setMaxItemsAllowed(unsigned int max) -{ - mMax = max; -} - -int amis::BookList::getMaxItemsAllowed() -{ - return mMax; -} - -int amis::BookList::getNumberOfEntries() -{ - return mItems.size(); -} -void amis::BookList::setName(std::wstring name) -{ - mName = name; -} -std::wstring amis::BookList::getName() -{ - return mName; -} -amis::BookEntry* amis::BookList::getEntry(unsigned int idx) -{ - if (idx >= 0 && idx < mItems.size()) - return mItems[idx]; - else - return NULL; -} - -//TODO: check for duplicates via UID; replace old with new -void amis::BookList::addEntry(amis::BookEntry* pEntry) -{ - int n_duplicate = -1; - //first check for duplicates - if (mItems.size() > 0) - { - for (int i=0; i<mItems.size(); i++) - { - if (mItems[i]->mUid.compare(pEntry->mUid) == 0) - { - n_duplicate = i; - break; - } - } - - //if we found a duplicate, delete it from its original position - //and add our new (identical) entry at the end of the list - if (n_duplicate > -1) - deleteEntry(n_duplicate); - } - - //add the new entry - mItems.push_back(pEntry); - - //make sure we are not over the max - //if so, remove the first (presumably oldest) entry - if (mItems.size() > mMax && mMax != 0) - deleteEntry(0); - - //only one book can be the last read book! - if (pEntry->mbIsLastRead == true) - { - amis::BookEntry* p_tmp = NULL; - for (unsigned int i = 0; i<mItems.size() - 1; i++) - { - p_tmp = mItems[i]; - p_tmp->mbIsLastRead = false; - } - } -} -void amis::BookList::deleteEntry(unsigned int idx) -{ - std::vector<amis::BookEntry*>::iterator it; - - if (idx < mItems.size() && idx >= 0) - { - it = mItems.begin() + idx; - mItems.erase(it); - } -} - -amis::BookEntry* amis::BookList::getLastRead() -{ - amis::BookEntry* p_tmp = NULL; - for (unsigned int i = 0; i<mItems.size(); i++) - { - p_tmp = mItems[i]; - if (p_tmp->mbIsLastRead == true) break; - } - return p_tmp; -} - -void amis::BookList::setFilepath(const ambulant::net::url* pFilepath) -{ - mFilepath = *pFilepath; -} - -const ambulant::net::url* amis::BookList::getFilepath() -{ - return &mFilepath; -} Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -105,6 +105,7 @@ mpTitle = NULL; mpTextSmilMap = NULL; mpCustomTests = NULL; + mpHistory = NULL; mUid.erase(); mDaisyVersion = UNSUPPORTED; @@ -153,19 +154,21 @@ //-------------------------------------------------- //wrapper for opening files //-------------------------------------------------- -bool amis::dtb::Dtb::open(string filepath, string bookmarksDirectory) +bool amis::dtb::Dtb::open(string filepath, string bookmarksDirectory, amis::BookList* history) { ambulant::net::url fileUrl = ambulant::net::url::from_url(filepath); ambulant::net::url bookmarksDirUrl = ambulant::net::url::from_url(bookmarksDirectory); - - return open(&fileUrl, &bookmarksDirUrl); + return open(&fileUrl, &bookmarksDirUrl, history); } //-------------------------------------------------- //open an NCC or OPF file //-------------------------------------------------- -bool amis::dtb::Dtb::open(const ambulant::net::url* fileUrl, const ambulant::net::url* bookmarksDirectory) +bool amis::dtb::Dtb::open(const ambulant::net::url* fileUrl, + const ambulant::net::url* bookmarksDirectory, + amis::BookList* history) { cleanUpObjects(); + mpHistory = history; string log_msg = "Opening book: " + fileUrl->get_url(); amis::util::Log::Instance()->writeMessage(log_msg, "Dtb::open", "AmisCore"); @@ -314,7 +317,7 @@ //TODO: get the audio for the title (author audio not available in Daisy 202) - mpFiles->setAdditionalDataAfterInitialParse(this->mUid, NULL, NULL); + mpFiles->setAdditionalDataAfterInitialParse(mUid, NULL, NULL, mpHistory); amis::dtb::nav::ResolveSmilDataVisitor resolve_smil_visitor; resolve_smil_visitor.resolve(mpNavModel, mpSpine, true); this->mpTextSmilMap = resolve_smil_visitor.getSmilTextMap(); @@ -392,7 +395,7 @@ const ambulant::net::url* txtfile = opf_file_reader.getTextFilename(); mUid = getUid(); - mpFiles->setAdditionalDataAfterInitialParse(mUid, navfile, resfile); + mpFiles->setAdditionalDataAfterInitialParse(mUid, navfile, resfile, mpHistory); mpFiles->setTextFile(txtfile); return true; } Modified: branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -73,13 +73,29 @@ } //after the caller has parsed the ncc or opf file, additional data is available -void amis::dtb::DtbFileSet::setAdditionalDataAfterInitialParse(wstring uid, const ambulant::net::url* navfile, const ambulant::net::url* resourcefile) +void amis::dtb::DtbFileSet::setAdditionalDataAfterInitialParse(wstring uid, + const ambulant::net::url* navfile, + const ambulant::net::url* resourcefile, + amis::BookList* bookmarkHistory) { if (uid.size() > 0) { - std::string thefilename = calculateSafeBookmarksFilename(uid); - mBookmarksFilepath = ambulant::net::url::from_filename(thefilename);//calculateSafeBookmarksFilename(uid)); - mBookmarksFilepath = mBookmarksFilepath.join_to_base(mBookmarksDirectory); + amis::BookEntry* p_entry = NULL; + //try to find the book in the history and grab its bookmarks filepath + if (bookmarkHistory != NULL) + { + p_entry = bookmarkHistory->findByUid(uid); + if (p_entry != NULL && p_entry->mBmkPath.is_empty_path() == false) + mBookmarksFilepath = p_entry->mBmkPath; + } + //if the bookmarks filepath wasn't found, then calculate it + //it will be recorded in the history list by the main application + if (mBookmarksFilepath.is_empty_path() == true) + { + std::string thefilename = calculateSafeBookmarksFilename(uid); + mBookmarksFilepath = ambulant::net::url::from_filename(thefilename); + mBookmarksFilepath = mBookmarksFilepath.join_to_base(mBookmarksDirectory); + } } else { @@ -170,44 +186,51 @@ return false; } -//TODO: make up a safe name if the book has no UID string amis::dtb::DtbFileSet::calculateSafeBookmarksFilename(wstring uid) { #if defined(AMIS_COMPILER_MSVC) //windows utility for converting wstring to string USES_CONVERSION; #endif - string safe_filename; + string proposed_filename; #if defined(AMIS_COMPILER_MSVC) - safe_filename.assign(T2A(uid.c_str())); + proposed_filename.assign(T2A(uid.c_str())); #elif defined(AMIS_COMPILER_GCC) -//medtest safe_filename.assign(uid.c_str()); -safe_filename.assign("the_bookmark_filename"); + //TODO: something for other platforms + proposed_filename.assign("the_bookmark_file"); #endif - - //replace all / \ , ; : (special chars) with '__' (double underscore) - for (unsigned int i=0; i<safe_filename.length(); i++) + + string safe_filename; + //make sure the bookmark filename contains only ASCII A-Z, 1-9 characters and hyphens + for (unsigned int i=0; i<proposed_filename.length(); i++) { - if (safe_filename[i] == '\\') - safe_filename.replace(i, 1, "__"); - - else if(safe_filename[i] == '/') - safe_filename.replace(i, 1, "__"); + int c = proposed_filename[i]; + /*the safe values of ASCII characters are: + 32 (space) + 45 (hyphen) + 46 (period) + 95 (underscore) + 48 through 57 (0 through 9) + 65 through 90 (A through Z) + 97 through 122 (a through z) + */ + if (c == 32 || c == 45 || c == 46 || c == 95 + || (c >= 48 && c <= 57) + || (c >= 65 && c <= 90) + || (c >=97 && c<=122)) + { + safe_filename += proposed_filename[i]; + } + else + { + //use the character code directly (or an underscore) + char ch[3]; + itoa(c, ch, 10); + safe_filename.append(ch); + } + } - else if(safe_filename[i] == ',') - safe_filename.replace(i, 1, "__"); - - else if(safe_filename[i] == ';') - safe_filename.replace(i, 1, "__"); - - else if(safe_filename[i] == ':') - safe_filename.replace(i, 1, "__"); - else if(safe_filename[i] == ' ') - safe_filename.replace(i, 1, "__"); - } - safe_filename.append(".bmk"); - return safe_filename; } Copied: branches/amis3/AmisCore/src/io/BookListFileIO.cpp (from rev 2399, branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp) =================================================================== --- branches/amis3/AmisCore/src/io/BookListFileIO.cpp (rev 0) +++ branches/amis3/AmisCore/src/io/BookListFileIO.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -0,0 +1,264 @@ +/* +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 "io/BookListFileIO.h" +#include "util/FilePathTools.h" +#include "util/xercesutils.h" +#include <iostream> + +#if defined(AMIS_COMPILER_MSVC) +//for creating directories on windows +#include "io.h" +#include "direct.h" +//todo: something for linux +#endif + +//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 <xercesc/dom/DOM.hpp> +#include <xercesc/dom/DOMWriter.hpp> +#include <xercesc/framework/LocalFileFormatTarget.hpp> +#include <xercesc/parsers/XercesDOMParser.hpp> +#include <xercesc/sax2/Attributes.hpp> +#include <xercesc/framework/StdOutFormatTarget.hpp> + +using namespace std; + + +amis::io::BookListFileIO::BookListFileIO() +{ + mpBookList = NULL; +} + +amis::io::BookListFileIO::~BookListFileIO() +{ +} + +amis::BookList* amis::io::BookListFileIO::getBookList() +{ + return mpBookList; +} + +bool amis::io::BookListFileIO::readFromFile(const ambulant::net::url* filepath) +{ + mpCurrentEntry = NULL; + if (!this->parseFile(filepath)) + { + delete mpBookList; + return false; + } + return true; +} + +void amis::io::BookListFileIO::startElement(const XMLCh* const uri, + const XMLCh* const localname, + const XMLCh* const qname, + const Attributes& attributes) +{ + char* element_name; + element_name = XMLString::transcode(qname); + + if (strcmp(element_name, "bookList") == 0) + { + mpBookList = new amis::BookList(); + mpBookList->setFilepath(this->getFilepath()); + wstring tmp_wstr; + tmp_wstr.assign(SimpleAttrs::getw("name", &attributes)); + mpBookList->setName(tmp_wstr); + } + else if (strcmp(element_name, "bookEntry") == 0) + { + mpCurrentEntry = new amis::BookEntry(); + mpBookList->addEntry(mpCurrentEntry); + + string tmpstr; + tmpstr.assign(SimpleAttrs::get("isLastRead", &attributes)); + if (tmpstr.compare("yes") == 0) + mpCurrentEntry->mbIsLastRead = true; + else + mpCurrentEntry->mbIsLastRead = false; + + wstring tmp_wstr; + tmp_wstr.assign(SimpleAttrs::getw("uid", &attributes)); + mpCurrentEntry->mUid = tmp_wstr; + + tmpstr.assign(SimpleAttrs::get("href", &attributes)); + mpCurrentEntry->mPath = ambulant::net::url::from_url(tmpstr); + } + else if(strcmp(element_name, "bookmarks") == 0) + { + if (mpCurrentEntry != NULL) + { + string tmpstr; + tmpstr.assign(SimpleAttrs::get("href", &attributes)); + mpCurrentEntry->mBmkPath = ambulant::net::url::from_url(tmpstr); + } + } + XMLString::release(&element_name); +} +bool amis::io::BookListFileIO::writeToFile(const ambulant::net::url* filepath, amis::BookList* pFile) +{ + if (filepath != NULL && filepath->is_local_file() == false) return false; + + // Initialize the XML4C2 system. + try + { + XMLPlatformUtils::Initialize(); + } + catch(...)//const XMLException& toCatch) + { + return false; + } + + if (pFile == NULL) return false; + if (!pFile->getFilepath()->is_local_file()) return false; + + std::string local_file_name; + //use the specified filepath unless it is unavailable + if (filepath != NULL) + local_file_name = amis::util::FilePathTools::getAsLocalFilePath(filepath->get_file()); + else + local_file_name = amis::util::FilePathTools::getAsLocalFilePath(pFile->getFilepath()->get_file()); + + mpBookList = pFile; + + int i; + //the DOM implementation pointer (this is part of how Xerces does things) + DOMImplementation* pImpl; + //a pointer to the Document Writer. This will save the document to file. + DOMWriter* pWriter; + + //a DOMNode pointer - need this later for writing output + DOMNode* pDocNode; + + //document output + XMLFormatTarget* pFormTarget; + + //You have to use the DOM Implementation class to get a pointer to the DOM object. It's part of how Xerces works. + pImpl = DOMImplementationRegistry::getDOMImplementation(X("Core")); + + //Now create a document using the DOM implementation's createDocument method + mpDoc = pImpl->createDocument( + X("http://amisproject.org"), // root element namespace URI. + X("bookList"), // root element name + 0); // document type object (DTD). + + + DOMElement* p_root = mpDoc->getDocumentElement(); + //add the root element attributes + if (mpBookList->getName().size() > 0) + p_root->setAttribute(X("name"), mpBookList->getName().c_str()); + + //start adding data to the DOM + amis::BookEntry* p_entry; + for (i=0; i<mpBookList->getNumberOfEntries(); i++) + { + p_entry = mpBookList->getEntry(i); + writeBookEntry(p_entry); + } + + + //initialize the DOM Writer + pWriter = ((DOMImplementationLS*)pImpl)->createDOMWriter(); + + //initialize the output stream and give it the name of our output file + //if no filepath was specified, use the one associated with the book list object + if (filepath->is_empty_path()) + { + //make sure the path to the file exists + string dir = amis::util::FilePathTools::getParentDirectory(local_file_name); + if (access(dir.c_str(), 0) == -1) + { +#if defined(AMIS_COMPILER_MSVC) + _mkdir(dir.c_str()); +#elif defined(AMIS_COMPILER_GCC) + //todo: something that creates directories on other platforms +#endif + } + pFormTarget = new LocalFileFormatTarget(local_file_name.c_str()); + } + //otherwise save to the specified location + else + { + //make sure the path to the file exists + string dir = amis::util::FilePathTools::getParentDirectory(local_file_name); + if (access(dir.c_str(), 0) == -1) + { +#if defined(AMIS_COMPILER_MSVC) + _mkdir(dir.c_str()); +#elif defined(AMIS_COMPILER_GCC) + //todo: something to make directories on other platforms +#endif + } + pFormTarget = new LocalFileFormatTarget(local_file_name.c_str()); + } + + //get the document as a node pointer + pDocNode = (DOMNode*)mpDoc; + + //process the document through the writer + //the writer sends output to the form target (which was configured to use our output file) + pWriter->writeNode(pFormTarget, *pDocNode); + + //delete some pointers + delete pFormTarget; + delete pWriter; + delete mpDoc; + + //terminate the XML platform utilities + XMLPlatformUtils::Terminate(); + return true; +} + +void amis::io::BookListFileIO::writeBookEntry(amis::BookEntry* pEntry) +{ + if (pEntry == NULL) return; + + //create the title + DOMElement* p_book_elm = mpDoc->createElement(X("bookEntry")); + DOMElement* p_bmk_elm = NULL; + if (pEntry->mBmkPath.is_empty_path() == false) + { + p_bmk_elm = mpDoc->createElement(X("bookmarks")); + p_bmk_elm->setAttribute(X("href"), X(pEntry->mBmkPath.get_url().c_str())); + } + if (pEntry->mbIsLastRead == true) + p_book_elm->setAttribute(X("isLastRead"), X("yes")); + + p_book_elm->setAttribute(X("uid"), pEntry->mUid.c_str()); + p_book_elm->setAttribute(X("href"), X(pEntry->mPath.get_url().c_str())); + + if (p_bmk_elm != NULL) p_book_elm->appendChild(p_bmk_elm); + + DOMElement* p_root = mpDoc->getDocumentElement(); + p_root->appendChild(p_book_elm); +} Modified: branches/amis3/AmisCore/src/io/BookmarksFileIO.cpp =================================================================== --- branches/amis3/AmisCore/src/io/BookmarksFileIO.cpp 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisCore/src/io/BookmarksFileIO.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -381,9 +381,9 @@ //Now create a document using the DOM implementation's createDocument method mpDoc = pImpl->createDocument( - 0, // root element namespace URI. - X("bookmarkSet"), // root element name - 0); // document type object (DTD). + X("http://amisproject.org"), // root element namespace URI. + X("bookmarkSet"), // root element name + 0); // document type object (DTD). //start adding data to the DOM writeTitle(mpBookmarks->getTitle()); Deleted: branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp =================================================================== --- branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -1,271 +0,0 @@ -/* -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 "io/RecentBooksFileIO.h" -#include "util/FilePathTools.h" -#include "util/xercesutils.h" -#include <iostream> - -#if defined(AMIS_COMPILER_MSVC) -//for creating directories on windows -#include "io.h" -#include "direct.h" -//todo: something for linux -#endif - -//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 <xercesc/dom/DOM.hpp> -#include <xercesc/dom/DOMWriter.hpp> -#include <xercesc/framework/LocalFileFormatTarget.hpp> -#include <xercesc/parsers/XercesDOMParser.hpp> -#include <xercesc/sax2/Attributes.hpp> -#include <xercesc/framework/StdOutFormatTarget.hpp> - -using namespace std; - - -amis::io::BookListFileIO::BookListFileIO() -{ - mpBookList = NULL; -} - -amis::io::BookListFileIO::~BookListFileIO() -{ -} - -amis::BookList* amis::io::BookListFileIO::getBookList() -{ - return mpBookList; -} - -bool amis::io::BookListFileIO::readFromFile(const ambulant::net::url* filepath) -{ - mpCurrentEntry = NULL; - mpBookList->setFilepath(filepath); - if (!this->parseFile(filepath)) - { - delete mpBookList; - return false; - } - return true; -} - -void amis::io::BookListFileIO::startElement(const XMLCh* const uri, - const XMLCh* const localname, - const XMLCh* const qname, - const Attributes& attributes) -{ - char* element_name; - element_name = XMLString::transcode(qname); - - if (strcmp(element_name, "bookList") == 0) - { - mpBookList = new amis::BookList(); - wstring tmp_wstr; - tmp_wstr.assign(SimpleAttrs::getw("name", &attributes)); - mpBookList->setName(tmp_wstr); - int max; - string tmpstr; - tmpstr.assign(SimpleAttrs::get("maxLength", &attributes)); - if (tmpstr.size() > 0) max = atoi(tmpstr.c_str()); - else max = 0; - mpBookList->setMaxItemsAllowed(max); - } - else if (strcmp(element_name, "book") == 0) - { - mpCurrentEntry = new amis::BookEntry(); - mpBookList->addEntry(mpCurrentEntry); - - string tmpstr; - tmpstr.assign(SimpleAttrs::get("isLastRead", &attributes)); - if (tmpstr.compare("yes") == 0) - mpCurrentEntry->mbIsLastRead = true; - else - mpCurrentEntry->mbIsLastRead = false; - - wstring tmp_wstr; - tmp_wstr.assign(SimpleAttrs::getw("uid", &attributes)); - mpCurrentEntry->mUid = tmp_wstr; - - tmpstr.assign(SimpleAttrs::get("href", &attributes)); - mpCurrentEntry->mPath = ambulant::net::url::from_url(tmpstr); - } - else if(strcmp(element_name, "bookmarks") == 0) - { - string tmpstr; - tmpstr.assign(SimpleAttrs::get("href", &attributes)); - mpCurrentEntry->mBmkPath = ambulant::net::url::from_url(tmpstr); - } - XMLString::release(&element_name); -} -bool amis::io::BookListFileIO::writeToFile(const ambulant::net::url* filepath, amis::BookList* pFile) -{ - if (filepath != NULL && filepath->is_local_file() == false) return false; - - // Initialize the XML4C2 system. - try - { - XMLPlatformUtils::Initialize(); - } - catch(...)//const XMLException& toCatch) - { - return false; - } - - if (pFile == NULL) return false; - if (!pFile->getFilepath()->is_local_file()) return false; - - std::string local_file_name; - //use the specified filepath unless it is unavailable - if (filepath != NULL) - local_file_name = amis::util::FilePathTools::getAsLocalFilePath(filepath->get_file()); - else - local_file_name = amis::util::FilePathTools::getAsLocalFilePath(pFile->getFilepath()->get_file()); - - mpBookList = pFile; - - int i; - //the DOM implementation pointer (this is part of how Xerces does things) - DOMImplementation* pImpl; - //a pointer to the Document Writer. This will save the document to file. - DOMWriter* pWriter; - - //a DOMNode pointer - need this later for writing output - DOMNode* pDocNode; - - //document output - XMLFormatTarget* pFormTarget; - - //You have to use the DOM Implementation class to get a pointer to the DOM object. It's part of how Xerces works. - pImpl = DOMImplementationRegistry::getDOMImplementation(X("Core")); - - //Now create a document using the DOM implementation's createDocument method - mpDoc = pImpl->createDocument( - 0, // root element namespace URI. - X("bookList"), // root element name - 0); // document type object (DTD). - - - DOMElement* p_root = mpDoc->getDocumentElement(); - //add the root element attributes - if (mpBookList->getName().size() > 0) - p_root->setAttribute(X("name"), mpBookList->getName().c_str()); - int max = mpBookList->getMaxItemsAllowed(); - char temp[5]; - itoa(max, temp, 5); - p_root->setAttribute(X("maxLength"), X(temp)); - - //start adding data to the DOM - amis::BookEntry* p_entry; - for (i=0; i<mpBookList->getNumberOfEntries(); i++) - { - p_entry = mpBookList->getEntry(i); - writeBookEntry(p_entry); - } - - - //initialize the DOM Writer - pWriter = ((DOMImplementationLS*)pImpl)->createDOMWriter(); - - //initialize the output stream and give it the name of our output file - //if no filepath was specified, use the one associated with the RecentBooks object - if (filepath->is_empty_path()) - { - //make sure the path to the file exists - string dir = amis::util::FilePathTools::getParentDirectory(local_file_name); - if (access(dir.c_str(), 0) == -1) - { -#if defined(AMIS_COMPILER_MSVC) - _mkdir(dir.c_str()); -#elif defined(AMIS_COMPILER_GCC) - //todo: something that creates directories on other platforms -#endif - } - pFormTarget = new LocalFileFormatTarget(local_file_name.c_str()); - } - //otherwise save to the specified location - else - { - //make sure the path to the file exists - string dir = amis::util::FilePathTools::getParentDirectory(local_file_name); - if (access(dir.c_str(), 0) == -1) - { -#if defined(AMIS_COMPILER_MSVC) - _mkdir(dir.c_str()); -#elif defined(AMIS_COMPILER_GCC) - //todo: something to make directories on other platforms -#endif - } - pFormTarget = new LocalFileFormatTarget(local_file_name.c_str()); - } - - //get the document as a node pointer - pDocNode = (DOMNode*)mpDoc; - - //process the document through the writer - //the writer sends output to the form target (which was configured to use our output file) - pWriter->writeNode(pFormTarget, *pDocNode); - - //delete some pointers - delete pFormTarget; - delete pWriter; - delete mpDoc; - - //terminate the XML platform utilities - XMLPlatformUtils::Terminate(); - return true; -} - -void amis::io::BookListFileIO::writeBookEntry(amis::BookEntry* pEntry) -{ - if (pEntry == NULL) return; - - //create the title - DOMElement* p_book_elm = mpDoc->createElement(X("bookEntry")); - DOMElement* p_bmk_elm = NULL; - if (pEntry->mBmkPath.is_empty_path() == false) - { - p_bmk_elm = mpDoc->createElement(X("bookmarks")); - p_bmk_elm->setAttribute(X("href"), X(pEntry->mBmkPath.get_url().c_str())); - } - if (pEntry->mbIsLastRead == true) - p_book_elm->setAttribute(X("isLastRead"), X("yes")); - - p_book_elm->setAttribute(X("uid"), pEntry->mUid.c_str()); - p_book_elm->setAttribute(X("href"), X(pEntry->mPath.get_url().c_str())); - - if (p_bmk_elm != NULL) p_book_elm->appendChild(p_bmk_elm); - - DOMElement* p_root = mpDoc->getDocumentElement(); - p_root->appendChild(p_book_elm); -} Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-11 05:32:16 UTC (rev 2401) @@ -255,9 +255,9 @@ END IDD_SIDEBAR DIALOGEX 0, 0, 175, 183 -STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | - WS_BORDER -FONT 8, "MS Sans Serif", 0, 0, 0x0 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE | + WS_CLIPCHILDREN | WS_BORDER +FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN CONTROL "Tab1",IDC_TAB,"SysTabControl32",TCS_BOTTOM,0,163,175,18 CONTROL "Tree1",IDC_TREE,"SysTreeView32",TVS_HASLINES | Modified: branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2008-03-11 05:32:16 UTC (rev 2401) @@ -59,7 +59,7 @@ amis::dtb::smil::SmilMediaGroup* loadSmilFromUrl(const ambulant::net::url*); private: - void addToRecentBooks(); + void addToHistory(); void makeAllNavContainerLabelsHumanReadable(); void makeNavContainerLabelHumanReadable(nav::NavContainer*); Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-11 05:32:16 UTC (rev 2401) @@ -37,7 +37,7 @@ #include "ambulant/net/url.h" #include "gui/MainFrm.h" -#include "RecentBooks.h" +#include "BookList.h" #include "gui/self-voicing/AudioSequencePlayer.h" #include "gui/self-voicing/datamodel/AccessibleUIDataReader.h" @@ -45,6 +45,7 @@ #define WITH_DAISY_PDTB #define AMIS_MAX_ANYTHING 49 #define AMIS_MAX_AUDIO_RATE 4.0 +#define AMIS_MAX_RECENT_BOOKS 5 namespace amis { @@ -62,7 +63,7 @@ virtual int ExitInstance(); const ambulant::net::url& getBookURL() const; std::string getAppPath(); - amis::BookList* getRecentBooks(); + amis::BookList* getHistory(); bool isBookOpen(); void setPauseState(bool play); bool shouldIgnoreOpenDocEvent(); @@ -119,7 +120,7 @@ std::string mAppPath; std::string mLocalizationDll; ambulant::net::url mURL; - amis::BookList* mpRecentBooks; + amis::BookList* mpHistory; bool mbBookIsOpen; bool mbShouldIgnoreOpenDocEvent; bool mbWasLastExitClean; Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -23,8 +23,8 @@ #include "gui/MainWndParts.h" #include "util/FilePathTools.h" #include "gui/sidebar/AmisSidebarLoader.h" -#include "RecentBooks.h" -#include "io/RecentBooksFileIO.h" +#include "BookList.h" +#include "io/BookListFileIO.h" #include "gui/AmisApp.h" #include "gui/MenuManip.h" #include "gui/TextRenderBrain.h" @@ -72,7 +72,7 @@ getFileSearcher()->clearSearchResults(); //call the base class - if (!Dtb::open(filename, bookmarksPath)) return false; + if (!Dtb::open(filename, bookmarksPath, theApp.getHistory())) return false; //turn on all skippable options to start with updateCustomTestStates(true); @@ -93,7 +93,7 @@ } } - addToRecentBooks(); + addToHistory(); amis::dtb::BookmarkSet* p_bmks = NULL; p_bmks = this->getBookmarks(); amis::gui::MenuManip::Instance()->setupNavigationOptions(); @@ -194,26 +194,26 @@ loadSmilFromUrl(&rel_path); } -void DtbWithHooks::addToRecentBooks() +void DtbWithHooks::addToHistory() { - amis::BookList* p_recent_books = NULL; - p_recent_books = theApp.getRecentBooks(); + amis::BookList* p_history = NULL; + p_history = theApp.getHistory(); - if (p_recent_books != NULL) + if (p_history != NULL) { amis::BookEntry* p_entry = new amis::BookEntry(); p_entry->mbIsLastRead = true; p_entry->mBmkPath = *this->getFileSet()->getBookmarksFilepath(); - + p_entry->mUid.assign(this->getUid()); if (getDaisyVersion() == DAISY_202) p_entry->mPath = *this->getFileSet()->getNavFilepath(); else if (getDaisyVersion() == DAISY_2005) p_entry->mPath = *this->getFileSet()->getOpfFilepath(); - p_recent_books->addEntry(p_entry); + p_history->addEntry(p_entry); amis::io::BookListFileIO io; - io.writeToFile(p_recent_books->getFilepath(), p_recent_books); + io.writeToFile(p_history->getFilepath(), p_history); amis::gui::MenuManip::Instance()->refreshRecentBooksListMenu(); } Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -27,7 +27,7 @@ #include "AmisCore.h" #include "util/FilePathTools.h" #include "Preferences.h" -#include "io/RecentBooksFileIO.h" +#include "io/BookListFileIO.h" #include "io/PreferencesFileIO.h" #include "util/SearchForFilesMFC.h" #include "util/Log.h" @@ -117,7 +117,7 @@ CAmisApp::CAmisApp() { - mpRecentBooks = NULL; + mpHistory = NULL; } //THE APPLICATION! @@ -234,7 +234,7 @@ if (b_open_from_cmdline == false && Preferences::Instance()->getLoadLastBook() == true && mbWasLastExitClean == true) - book_to_open = mpRecentBooks->getLastRead()->mPath; + book_to_open = mpHistory->getLastRead()->mPath; //open a book if we decided to either open the command line parameter or last-read book if (!book_to_open.is_empty_path()) openBook(&book_to_open); @@ -262,7 +262,7 @@ amis::gui::MainWndParts::Instance()->DestroyInstance(); AudioSequencePlayer::Instance()->DestroyInstance(); DataTree::Instance()->DestroyInstance(); - if (mpRecentBooks != NULL) delete mpRecentBooks; + if (mpHistory != NULL) delete mpHistory; CoUninitialize(); @@ -301,12 +301,12 @@ prefs_io.writeToFile(prefs_path, Preferences::Instance()); //read the recent books list - string recent_books_path = "./settings/amisRecentBooks.xml"; - recent_books_path = amis::util::FilePathTools::goRelativePath(theApp.getAppPath(), recent_books_path); - ambulant::net::url the_book_path = ambulant::net::url::from_filename(recent_books_path); - amis::io::BookListFileIO recent_books_io; - if (recent_books_io.readFromFile(&the_book_path)) mpRecentBooks = recent_books_io.getBookList(); - else mpRecentBooks = NULL; + string history_path = "./settings/amisHistory.xml"; + history_path = amis::util::FilePathTools::goRelativePath(theApp.getAppPath(), history_path); + ambulant::net::url the_path = ambulant::net::url::from_filename(history_path); + amis::io::BookListFileIO history_io; + if (history_io.readFromFile(&the_path)) mpHistory = history_io.getBookList(); + else mpHistory = NULL; } void CAmisApp::initializeSelfVoicing() @@ -355,9 +355,9 @@ return this->mURL; } -amis::BookList* CAmisApp::getRecentBooks() +amis::BookList* CAmisApp::getHistory() { - return mpRecentBooks; + return mpHistory; } bool CAmisApp::isBookOpen() { @@ -418,8 +418,8 @@ //close any open book OnFileClose(); - if (mpRecentBooks->getLastRead()) - openBook(&mpRecentBooks->getLastRead()->mPath); + if (mpHistory->getLastRead()) + openBook(&mpHistory->getLastRead()->mPath); } /******************************* @@ -492,13 +492,13 @@ } void CAmisApp::OnFileRecentBook(UINT id) { - if (mpRecentBooks == NULL) return; + if (mpHistory == NULL) return; UINT selection = id - AMIS_RECENT_BOOK_BASE_ID; string filename = ""; amis::BookEntry* p_book = NULL; - p_book = mpRecentBooks->getEntry(selection); + p_book = mpHistory->getEntry(selection); string log_msg = "Loading recent book " + p_book->mPath.get_url(); amis::util::Log::Instance()->writeMessage("Loading recent book", &p_book->mPath, "CAmisApp::OnFileRecentBook", "AmisGuiMFC2"); openBook(&p_book->mPath); Modified: branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -26,7 +26,7 @@ #include "gui/MainWndParts.h" #include "gui/AmisApp.h" #include "DtbWithHooks.h" -#include "RecentBooks.h" +#include "BookList.h" #include "dtb/nav/NavModel.h" #include "gui/TextRenderBrain.h" #include "util/FilePathTools.h" @@ -61,8 +61,8 @@ void MenuManip::refreshRecentBooksListMenu() { USES_CONVERSION; - if (theApp.getRecentBooks() == NULL) return; - int num_entries = theApp.getRecentBooks()->getNumberOfEntries(); + if (theApp.getHistory() == NULL) return; + int num_entries = theApp.getHistory()->getNumberOfEntries(); CMenu* p_main_menu = NULL; p_main_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); @@ -87,9 +87,12 @@ //re-add all entries amis::BookEntry* p_entry = NULL; - for (i=0; i<num_entries; i++) + int max = AMIS_MAX_RECENT_BOOKS; + if (num_entries < max) max = num_entries; + //get the last X entries + for (i=max-1; i>=0; i--) { - p_entry = theApp.getRecentBooks()->getEntry(i); + p_entry = theApp.getHistory()->getEntry(i); string filepath = p_entry->mPath.get_url(); CString cstr_filepath = A2T(filepath.c_str()); BOOL ret = p_menu->AppendMenu(MF_STRING, AMIS_RECENT_BOOK_BASE_ID + i, cstr_filepath); Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -823,7 +823,7 @@ seq = new AudioSequence; } - amis::BookList* books = theApp.getRecentBooks(); + amis::BookList* books = theApp.getHistory(); int nRecentBooks = (books ? books->getNumberOfEntries() : 0); string strCondition; Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -5,7 +5,7 @@ #include "gui/self-voicing/datamodel/Label.h" #include "gui/self-voicing/Prompt.h" #include "gui/self-voicing/UiMediaTypes.h" -#include "RecentBooks.h" +#include "BookList.h" #include "gui/self-voicing/dialogs/menuvoicing.h" #include "gui/self-voicing/audiosequenceplayer.h" #include "DtbWithHooks.h" @@ -322,7 +322,7 @@ TRACE(s); - amis::BookList* books = theApp.getRecentBooks(); + amis::BookList* books = theApp.getHistory(); int nRecentBooks = (books ? books->getNumberOfEntries() : 0); if (nRecentBooks > 0 && (nItemID >= AMIS_RECENT_BOOK_BASE_ID && @@ -330,7 +330,7 @@ { int idx = nItemID - AMIS_RECENT_BOOK_BASE_ID; - amis::BookEntry* p_entry = theApp.getRecentBooks()->getEntry(idx); + amis::BookEntry* p_entry = theApp.getHistory()->getEntry(idx); //DanTodo: surely, there must be a way to get a title instead of rendering the URL with TTS ??! (see bookmark methd commented below) string str = p_entry->mPath.get_url(); Modified: branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp 2008-03-11 05:32:16 UTC (rev 2401) @@ -230,7 +230,7 @@ } pImpl = DOMImplementationRegistry::getDOMImplementation(X("Core")); pDoc = pImpl->createDocument( - X("http://amis.sf.net"), + X("http://amisproject.org"), X("preferences"), (xercesc_2_7::DOMDocumentType*)0); Modified: branches/amis3/bin/settings/amisRecentBooks.xml.default =================================================================== --- branches/amis3/bin/settings/amisRecentBooks.xml.default 2008-03-11 04:47:18 UTC (rev 2400) +++ branches/amis3/bin/settings/amisRecentBooks.xml.default 200... [truncated message content] |
From: <mar...@us...> - 2008-03-11 04:47:12
|
Revision: 2400 http://amis.svn.sourceforge.net/amis/?rev=2400&view=rev Author: marisademeglio Date: 2008-03-10 21:47:18 -0700 (Mon, 10 Mar 2008) Log Message: ----------- added new bugs Modified Paths: -------------- branches/amis3/amis_issues.txt Modified: branches/amis3/amis_issues.txt =================================================================== --- branches/amis3/amis_issues.txt 2008-03-11 01:58:12 UTC (rev 2399) +++ branches/amis3/amis_issues.txt 2008-03-11 04:47:18 UTC (rev 2400) @@ -5,7 +5,7 @@ * code cleanup to follow conventions/style of existing code regarding folder locations, indentation, variables * use meaningful trace messages and delete old ones * review TODOs, remove if resolved, address if needed -* remove commented-out code +* remove commented-out code unless there is a good reason to keep it in (say why) NEW FEATURES --- @@ -16,7 +16,6 @@ * add dialog to adjust highlight colors and font type * fontsize in the sidebar * highlight current section (in sidebar) in same color as page highlight -* bookmarking for non-ascii dc:identifiers * opening URLs from the command line ISSUES @@ -26,23 +25,32 @@ * zed books need a stylesheet * Listviews have more than one column, cutting off text * Sidebar intercepts shift+arrow even when I tell it not to. -* publication summary dialog not getting current section for zed books * window resizing problems with HTML view -* "previous section" command results not previous enough +* bookmarking for non-ascii dc:identifiers BUG REPORTS --- * play/pause state doesn't toggle correctly on startup * navigation not highlighted until you click on it * japanese characters not shown in sidebar in win2k +* speed buttons reset when you open a new book + 1. open a book + 2. play + 3. select "faster" + 4. make sure that the button for "faster" is not active + 5. close the book + 6. open the same book + 7. see the buttons for speed +* phrase arrow keys don't work when the focus is in the sidebar +* audio does not change speed +* book in a japanese folder can't be opened - AMBULANT ISSUES -- * How to stop ambulant when closing a book * review skippability across document boundaries (need reading options dialog to work) +* memory leaks - BETA (APRIL 1) ================= NEW FEATURES @@ -103,4 +111,6 @@ * Loads last book on startup * Loads from command line * Supports an unlimited number of font size CSS files. The default is still 4. -* If no dc:identifier or the bookmark file can't be created, it crashes \ No newline at end of file +* If no dc:identifier or the bookmark file can't be created, it no longer crashes +* publication summary dialog not getting current section for zed books +* "previous section" works as it should \ 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...> - 2008-03-11 01:58:17
|
Revision: 2399 http://amis.svn.sourceforge.net/amis/?rev=2399&view=rev Author: marisademeglio Date: 2008-03-10 18:58:12 -0700 (Mon, 10 Mar 2008) Log Message: ----------- changing recentbooks format to something more generic Modified Paths: -------------- branches/amis3/AmisCore/include/AmisCore.h branches/amis3/AmisCore/include/RecentBooks.h branches/amis3/AmisCore/include/io/RecentBooksFileIO.h branches/amis3/AmisCore/src/RecentBooks.cpp branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp branches/amis3/bin/settings/amisRecentBooks.xml.default Modified: branches/amis3/AmisCore/include/AmisCore.h =================================================================== --- branches/amis3/AmisCore/include/AmisCore.h 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/AmisCore/include/AmisCore.h 2008-03-11 01:58:12 UTC (rev 2399) @@ -57,8 +57,8 @@ class AudioNode; class MediaGroup; class Error; - class RecentBookEntry; - class RecentBooks; + class BookEntry; + class BookList; class ModuleDescData; class SearchDTBText; class SearchDTBParser; @@ -125,16 +125,18 @@ } namespace io { - class RecentBooksFileIO; + class BookListFileIO; + class BookmarksFileIO; class ModuleDescReader; - class BookmarksFileIO; class NccFileReader; class NavFileReader; class NcxFileReader; + class OpfFileReader; class QuickDataSmilFileReader; class SmilFileReader; class TextSearch; class XercesSaxParseBase; + class UrlInputSource; } namespace util { Modified: branches/amis3/AmisCore/include/RecentBooks.h =================================================================== --- branches/amis3/AmisCore/include/RecentBooks.h 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/AmisCore/include/RecentBooks.h 2008-03-11 01:58:12 UTC (rev 2399) @@ -19,8 +19,8 @@ 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 RECENTBOOKS_H -#define RECENTBOOKS_H +#ifndef BOOKLIST_H +#define BOOKLIST_H #include <string> #include <vector> @@ -30,40 +30,39 @@ namespace amis { -//!RecentBookEntry class -class RecentBookEntry +class BookEntry { - public: - RecentBookEntry(); - ~RecentBookEntry(); - - ambulant::net::url mPath; - ambulant::net::url mBmkPath; - bool mbIsLastRead; +public: + BookEntry(); + ~BookEntry(); + + std::wstring mUid; + ambulant::net::url mPath; + ambulant::net::url mBmkPath; + bool mbIsLastRead; }; - -//!RecentBooks class -class RecentBooks +class BookList { - public: - RecentBooks(); - ~RecentBooks(); + BookList(); + ~BookList(); int getNumberOfEntries(); - amis::RecentBookEntry* getEntry(unsigned int); - void addEntry(amis::RecentBookEntry*); + amis::BookEntry* getEntry(unsigned int); + void addEntry(amis::BookEntry*); void deleteEntry(unsigned int); int getMaxItemsAllowed(); void setMaxItemsAllowed(unsigned int); - amis::RecentBookEntry* getLastRead(); + amis::BookEntry* getLastRead(); const ambulant::net::url* getFilepath(); void setFilepath(const ambulant::net::url*); + void setName(std::wstring); + std::wstring getName(); private: void cleanUpVector(); unsigned int mMax; ambulant::net::url mFilepath; - vector<amis::RecentBookEntry*> mItems; + vector<amis::BookEntry*> mItems; + std::wstring mName; }; - } #endif Modified: branches/amis3/AmisCore/include/io/RecentBooksFileIO.h =================================================================== --- branches/amis3/AmisCore/include/io/RecentBooksFileIO.h 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/AmisCore/include/io/RecentBooksFileIO.h 2008-03-11 01:58:12 UTC (rev 2399) @@ -19,8 +19,8 @@ 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 RECENTBOOKSFILEIO_H -#define RECENTBOOKSFILEIO_H +#ifndef BOOKLISTFILEIO_H +#define BOOKLISTFILEIO_H #include "RecentBooks.h" #include "io/XercesSaxParseBase.h" @@ -42,44 +42,34 @@ { namespace io { -class RecentBooksFileIO : public XercesSaxParseBase +class BookListFileIO : public XercesSaxParseBase { public: - RecentBooksFileIO(); - ~RecentBooksFileIO(); + BookListFileIO(); + ~BookListFileIO(); bool readFromFile(const ambulant::net::url*); - amis::RecentBooks* getRecentBooks(); + amis::BookList* getBookList(); //write the file to disk - bool writeToFile(const ambulant::net::url*, amis::RecentBooks*); + bool writeToFile(const ambulant::net::url*, amis::BookList*); - //SAX METHODS void startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attributes); void endElement(const XMLCh* const uri, const XMLCh* const localname, - const XMLCh* const qname); - void characters(const XMLCh *const, const unsigned int); - /*end of sax methods*/ + const XMLCh* const qname) + {/*we don't need this method*/} + void characters(const XMLCh *const, const unsigned int) + {/*we don't need this method*/} private: - void writeRecentBookEntry(amis::RecentBookEntry*); - + void writeBookEntry(amis::BookEntry*); ambulant::net::url mFilePath; - - //!retrieve character data - bool mb_flagGetChars; - - //!temp char data - std::string mTempChars; - - //the recent books file object model - amis::RecentBooks* mpRecentBooks; - - amis::RecentBookEntry* mpCurrentEntry; - + //the books list file object model + amis::BookList* mpBookList; + amis::BookEntry* mpCurrentEntry; //The DOM document pointer xercesc_2_7::DOMDocument* mpDoc; }; Modified: branches/amis3/AmisCore/src/RecentBooks.cpp =================================================================== --- branches/amis3/AmisCore/src/RecentBooks.cpp 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/AmisCore/src/RecentBooks.cpp 2008-03-11 01:58:12 UTC (rev 2399) @@ -24,31 +24,28 @@ #include <iostream> using namespace std; -amis::RecentBookEntry::RecentBookEntry() +amis::BookEntry::BookEntry() { this->mbIsLastRead= false; } -amis::RecentBookEntry::~RecentBookEntry() +amis::BookEntry::~BookEntry() { } -amis::RecentBooks::RecentBooks() +amis::BookList::BookList() { - mMax = 5; + mMax = 0; mItems.clear(); } -amis::RecentBooks::~RecentBooks() +amis::BookList::~BookList() { cleanUpVector(); } - -//TODO: this doesn't seem to be cleaning things up very well .. I think that's why -//RecentBooksFileIO (where objects are created) has memory leaks -void amis::RecentBooks::cleanUpVector() +void amis::BookList::cleanUpVector() { int sz = mItems.size(); - amis::RecentBookEntry* p_tmp; + amis::BookEntry* p_tmp; for (int i = sz-1; i>=0; i--) { p_tmp = mItems[i]; @@ -57,47 +54,46 @@ } } -void amis::RecentBooks::setMaxItemsAllowed(unsigned int max) +void amis::BookList::setMaxItemsAllowed(unsigned int max) { mMax = max; } -int amis::RecentBooks::getMaxItemsAllowed() +int amis::BookList::getMaxItemsAllowed() { return mMax; } -int amis::RecentBooks::getNumberOfEntries() +int amis::BookList::getNumberOfEntries() { return mItems.size(); } - -amis::RecentBookEntry* amis::RecentBooks::getEntry(unsigned int idx) +void amis::BookList::setName(std::wstring name) { + mName = name; +} +std::wstring amis::BookList::getName() +{ + return mName; +} +amis::BookEntry* amis::BookList::getEntry(unsigned int idx) +{ if (idx >= 0 && idx < mItems.size()) - { return mItems[idx]; - } else - { return NULL; - } } -void amis::RecentBooks::addEntry(amis::RecentBookEntry* pEntry) +//TODO: check for duplicates via UID; replace old with new +void amis::BookList::addEntry(amis::BookEntry* pEntry) { - amis::RecentBookEntry* p_tmp; int n_duplicate = -1; - //first check for duplicates if (mItems.size() > 0) { for (int i=0; i<mItems.size(); i++) { - p_tmp = mItems[i]; - - if (p_tmp->mPath.same_document(pEntry->mPath) && - p_tmp->mBmkPath.same_document(pEntry->mBmkPath)) + if (mItems[i]->mUid.compare(pEntry->mUid) == 0) { n_duplicate = i; break; @@ -107,9 +103,7 @@ //if we found a duplicate, delete it from its original position //and add our new (identical) entry at the end of the list if (n_duplicate > -1) - { deleteEntry(n_duplicate); - } } //add the new entry @@ -117,68 +111,48 @@ //make sure we are not over the max //if so, remove the first (presumably oldest) entry - if (mItems.size() > mMax) - { + if (mItems.size() > mMax && mMax != 0) deleteEntry(0); - } //only one book can be the last read book! if (pEntry->mbIsLastRead == true) { - amis::RecentBookEntry* p_tmp = NULL; - + amis::BookEntry* p_tmp = NULL; for (unsigned int i = 0; i<mItems.size() - 1; i++) { p_tmp = mItems[i]; p_tmp->mbIsLastRead = false; } } - } -void amis::RecentBooks::deleteEntry(unsigned int idx) +void amis::BookList::deleteEntry(unsigned int idx) { - std::vector<amis::RecentBookEntry*>::iterator it; + std::vector<amis::BookEntry*>::iterator it; if (idx < mItems.size() && idx >= 0) { it = mItems.begin() + idx; - mItems.erase(it); } } -amis::RecentBookEntry* amis::RecentBooks::getLastRead() +amis::BookEntry* amis::BookList::getLastRead() { - amis::RecentBookEntry* p_tmp = NULL; - + amis::BookEntry* p_tmp = NULL; for (unsigned int i = 0; i<mItems.size(); i++) { p_tmp = mItems[i]; - if (p_tmp->mbIsLastRead == true) - { - break; - } + if (p_tmp->mbIsLastRead == true) break; } - - //if for some reason no book matched the criteria, just return the last one in the list - if (p_tmp == NULL) - { - if (mItems.size() > 0) - { - p_tmp = mItems[mItems.size() - 1]; - } - } - return p_tmp; - } -void amis::RecentBooks::setFilepath(const ambulant::net::url* pFilepath) +void amis::BookList::setFilepath(const ambulant::net::url* pFilepath) { mFilepath = *pFilepath; } -const ambulant::net::url* amis::RecentBooks::getFilepath() +const ambulant::net::url* amis::BookList::getFilepath() { return &mFilepath; } Modified: branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp =================================================================== --- branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp 2008-03-11 01:58:12 UTC (rev 2399) @@ -54,40 +54,33 @@ using namespace std; -amis::io::RecentBooksFileIO::RecentBooksFileIO() +amis::io::BookListFileIO::BookListFileIO() { - mpRecentBooks = NULL; + mpBookList = NULL; } -amis::io::RecentBooksFileIO::~RecentBooksFileIO() +amis::io::BookListFileIO::~BookListFileIO() { } -amis::RecentBooks* amis::io::RecentBooksFileIO::getRecentBooks() +amis::BookList* amis::io::BookListFileIO::getBookList() { - return mpRecentBooks; + return mpBookList; } -bool amis::io::RecentBooksFileIO::readFromFile(const ambulant::net::url* filepath) +bool amis::io::BookListFileIO::readFromFile(const ambulant::net::url* filepath) { mpCurrentEntry = NULL; - mpRecentBooks = new amis::RecentBooks(); - mb_flagGetChars = false; - mpRecentBooks->setFilepath(filepath); + mpBookList->setFilepath(filepath); if (!this->parseFile(filepath)) { - delete mpRecentBooks; + delete mpBookList; return false; } - return true; } - -//-------------------------------------------------- -//xerces start element event -//-------------------------------------------------- -void amis::io::RecentBooksFileIO::startElement(const XMLCh* const uri, +void amis::io::BookListFileIO::startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attributes) @@ -95,74 +88,48 @@ char* element_name; element_name = XMLString::transcode(qname); - if (strcmp(element_name, "book") == 0) + if (strcmp(element_name, "bookList") == 0) { - //this gets reported as a leak, but recent book objects get deleted in RecentBooks::~RecentBooks - //the caller (AmisApp.cpp in our case) is responsible for this - mpCurrentEntry = new amis::RecentBookEntry(); + mpBookList = new amis::BookList(); + wstring tmp_wstr; + tmp_wstr.assign(SimpleAttrs::getw("name", &attributes)); + mpBookList->setName(tmp_wstr); + int max; string tmpstr; + tmpstr.assign(SimpleAttrs::get("maxLength", &attributes)); + if (tmpstr.size() > 0) max = atoi(tmpstr.c_str()); + else max = 0; + mpBookList->setMaxItemsAllowed(max); + } + else if (strcmp(element_name, "book") == 0) + { + mpCurrentEntry = new amis::BookEntry(); + mpBookList->addEntry(mpCurrentEntry); + + string tmpstr; tmpstr.assign(SimpleAttrs::get("isLastRead", &attributes)); if (tmpstr.compare("yes") == 0) mpCurrentEntry->mbIsLastRead = true; else mpCurrentEntry->mbIsLastRead = false; - } - else if(strcmp(element_name, "path") == 0) - mb_flagGetChars = true; - else if(strcmp(element_name, "bmkPath") == 0) - mb_flagGetChars = true; - XMLString::release(&element_name); -} + wstring tmp_wstr; + tmp_wstr.assign(SimpleAttrs::getw("uid", &attributes)); + mpCurrentEntry->mUid = tmp_wstr; -//-------------------------------------------------- -//(SAX Event) close this element -//-------------------------------------------------- -void amis::io::RecentBooksFileIO::endElement( const XMLCh* const uri, - const XMLCh* const localname, - const XMLCh* const qname) -{ - char* element_name = XMLString::transcode(qname); - - if (strcmp(element_name, "book") == 0) - { - mpRecentBooks->addEntry(mpCurrentEntry); + tmpstr.assign(SimpleAttrs::get("href", &attributes)); + mpCurrentEntry->mPath = ambulant::net::url::from_url(tmpstr); } - else if (strcmp(element_name, "path") == 0) + else if(strcmp(element_name, "bookmarks") == 0) { - //TODO: this gets reported as a leak -- unresolved - mpCurrentEntry->mPath = ambulant::net::url::from_url(mTempChars); - mb_flagGetChars = false; + string tmpstr; + tmpstr.assign(SimpleAttrs::get("href", &attributes)); + mpCurrentEntry->mBmkPath = ambulant::net::url::from_url(tmpstr); } - else if(strcmp(element_name, "bmkPath") == 0) - { - //TODO: this gets reported as a leak -- unresolved - mpCurrentEntry->mBmkPath = ambulant::net::url::from_url(mTempChars); - mb_flagGetChars = false; - } - - mTempChars.erase(); XMLString::release(&element_name); } - -//-------------------------------------------------- -//xerces character data event -//-------------------------------------------------- -void amis::io::RecentBooksFileIO::characters(const XMLCh *const chars, const unsigned int length) +bool amis::io::BookListFileIO::writeToFile(const ambulant::net::url* filepath, amis::BookList* pFile) { - if (mb_flagGetChars == true) - { - if (mTempChars == "") - { - char* chardata = XMLString::transcode(chars); - mTempChars.assign(chardata); - XMLString::release(&chardata); - } - } -} - -bool amis::io::RecentBooksFileIO::writeToFile(const ambulant::net::url* filepath, amis::RecentBooks* pFile) -{ if (filepath != NULL && filepath->is_local_file() == false) return false; // Initialize the XML4C2 system. @@ -185,7 +152,7 @@ else local_file_name = amis::util::FilePathTools::getAsLocalFilePath(pFile->getFilepath()->get_file()); - mpRecentBooks = pFile; + mpBookList = pFile; int i; //the DOM implementation pointer (this is part of how Xerces does things) @@ -205,17 +172,25 @@ //Now create a document using the DOM implementation's createDocument method mpDoc = pImpl->createDocument( 0, // root element namespace URI. - X("recentBooks"), // root element name + X("bookList"), // root element name 0); // document type object (DTD). + DOMElement* p_root = mpDoc->getDocumentElement(); + //add the root element attributes + if (mpBookList->getName().size() > 0) + p_root->setAttribute(X("name"), mpBookList->getName().c_str()); + int max = mpBookList->getMaxItemsAllowed(); + char temp[5]; + itoa(max, temp, 5); + p_root->setAttribute(X("maxLength"), X(temp)); + //start adding data to the DOM - amis::RecentBookEntry* p_entry; - - for (i=0; i<mpRecentBooks->getNumberOfEntries(); i++) + amis::BookEntry* p_entry; + for (i=0; i<mpBookList->getNumberOfEntries(); i++) { - p_entry = mpRecentBooks->getEntry(i); - writeRecentBookEntry(p_entry); + p_entry = mpBookList->getEntry(i); + writeBookEntry(p_entry); } @@ -271,30 +246,26 @@ return true; } -void amis::io::RecentBooksFileIO::writeRecentBookEntry(amis::RecentBookEntry* pEntry) +void amis::io::BookListFileIO::writeBookEntry(amis::BookEntry* pEntry) { - if (pEntry == NULL) - return; + if (pEntry == NULL) return; //create the title - DOMElement* p_book_elm = mpDoc->createElement(X("book")); - DOMElement* p_book_path_elm = mpDoc->createElement(X("path")); - DOMElement* p_bmk_path_elm = mpDoc->createElement(X("bmkPath")); - - DOMText* p_path_text = mpDoc->createTextNode(X(pEntry->mPath.get_url().c_str())); - DOMText* p_bmk_path_text = mpDoc->createTextNode(X(pEntry->mBmkPath.get_url().c_str())); - + DOMElement* p_book_elm = mpDoc->createElement(X("bookEntry")); + DOMElement* p_bmk_elm = NULL; + if (pEntry->mBmkPath.is_empty_path() == false) + { + p_bmk_elm = mpDoc->createElement(X("bookmarks")); + p_bmk_elm->setAttribute(X("href"), X(pEntry->mBmkPath.get_url().c_str())); + } if (pEntry->mbIsLastRead == true) p_book_elm->setAttribute(X("isLastRead"), X("yes")); - else - p_book_elm->setAttribute(X("isLastRead"), X("no")); + + p_book_elm->setAttribute(X("uid"), pEntry->mUid.c_str()); + p_book_elm->setAttribute(X("href"), X(pEntry->mPath.get_url().c_str())); - p_book_path_elm->appendChild(p_path_text); - p_bmk_path_elm->appendChild(p_bmk_path_text); + if (p_bmk_elm != NULL) p_book_elm->appendChild(p_bmk_elm); - p_book_elm->appendChild(p_book_path_elm); - p_book_elm->appendChild(p_bmk_path_elm); - DOMElement* p_root = mpDoc->getDocumentElement(); p_root->appendChild(p_book_elm); } Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-11 01:58:12 UTC (rev 2399) @@ -62,7 +62,7 @@ virtual int ExitInstance(); const ambulant::net::url& getBookURL() const; std::string getAppPath(); - amis::RecentBooks* getRecentBooks(); + amis::BookList* getRecentBooks(); bool isBookOpen(); void setPauseState(bool play); bool shouldIgnoreOpenDocEvent(); @@ -119,7 +119,7 @@ std::string mAppPath; std::string mLocalizationDll; ambulant::net::url mURL; - amis::RecentBooks* mpRecentBooks; + amis::BookList* mpRecentBooks; bool mbBookIsOpen; bool mbShouldIgnoreOpenDocEvent; bool mbWasLastExitClean; Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2008-03-11 01:58:12 UTC (rev 2399) @@ -196,12 +196,12 @@ void DtbWithHooks::addToRecentBooks() { - amis::RecentBooks* p_recent_books = NULL; + amis::BookList* p_recent_books = NULL; p_recent_books = theApp.getRecentBooks(); if (p_recent_books != NULL) { - amis::RecentBookEntry* p_entry = new amis::RecentBookEntry(); + amis::BookEntry* p_entry = new amis::BookEntry(); p_entry->mbIsLastRead = true; p_entry->mBmkPath = *this->getFileSet()->getBookmarksFilepath(); @@ -212,7 +212,7 @@ p_recent_books->addEntry(p_entry); - amis::io::RecentBooksFileIO io; + amis::io::BookListFileIO io; io.writeToFile(p_recent_books->getFilepath(), p_recent_books); amis::gui::MenuManip::Instance()->refreshRecentBooksListMenu(); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-11 01:58:12 UTC (rev 2399) @@ -304,8 +304,8 @@ string recent_books_path = "./settings/amisRecentBooks.xml"; recent_books_path = amis::util::FilePathTools::goRelativePath(theApp.getAppPath(), recent_books_path); ambulant::net::url the_book_path = ambulant::net::url::from_filename(recent_books_path); - amis::io::RecentBooksFileIO recent_books_io; - if (recent_books_io.readFromFile(&the_book_path)) mpRecentBooks = recent_books_io.getRecentBooks(); + amis::io::BookListFileIO recent_books_io; + if (recent_books_io.readFromFile(&the_book_path)) mpRecentBooks = recent_books_io.getBookList(); else mpRecentBooks = NULL; } @@ -355,7 +355,7 @@ return this->mURL; } -amis::RecentBooks* CAmisApp::getRecentBooks() +amis::BookList* CAmisApp::getRecentBooks() { return mpRecentBooks; } @@ -497,7 +497,7 @@ UINT selection = id - AMIS_RECENT_BOOK_BASE_ID; string filename = ""; - amis::RecentBookEntry* p_book = NULL; + amis::BookEntry* p_book = NULL; p_book = mpRecentBooks->getEntry(selection); string log_msg = "Loading recent book " + p_book->mPath.get_url(); amis::util::Log::Instance()->writeMessage("Loading recent book", &p_book->mPath, "CAmisApp::OnFileRecentBook", "AmisGuiMFC2"); @@ -541,11 +541,11 @@ amis::util::Log::Instance()->writeMessage("Closing book", "CAmisApp::OnFileClose", "AmisGuiMFC2"); if (mbBookIsOpen) { + mbBookIsOpen = false; //the order matters here amis::dtb::DtbWithHooks::Instance()->DestroyInstance(); MainWndParts::Instance()->mpMmView->OnDestroy(); amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.clearAll(); - mbBookIsOpen = false; } } Modified: branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2008-03-11 01:58:12 UTC (rev 2399) @@ -86,7 +86,7 @@ for (int i=num_menu_items-1; i>=0; i--) p_menu->RemoveMenu(i, MF_BYPOSITION); //re-add all entries - amis::RecentBookEntry* p_entry = NULL; + amis::BookEntry* p_entry = NULL; for (i=0; i<num_entries; i++) { p_entry = theApp.getRecentBooks()->getEntry(i); Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-11 01:58:12 UTC (rev 2399) @@ -823,7 +823,7 @@ seq = new AudioSequence; } - amis::RecentBooks* books = theApp.getRecentBooks(); + amis::BookList* books = theApp.getRecentBooks(); int nRecentBooks = (books ? books->getNumberOfEntries() : 0); string strCondition; Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp 2008-03-11 01:58:12 UTC (rev 2399) @@ -322,7 +322,7 @@ TRACE(s); - amis::RecentBooks* books = theApp.getRecentBooks(); + amis::BookList* books = theApp.getRecentBooks(); int nRecentBooks = (books ? books->getNumberOfEntries() : 0); if (nRecentBooks > 0 && (nItemID >= AMIS_RECENT_BOOK_BASE_ID && @@ -330,7 +330,7 @@ { int idx = nItemID - AMIS_RECENT_BOOK_BASE_ID; - amis::RecentBookEntry* p_entry = theApp.getRecentBooks()->getEntry(idx); + amis::BookEntry* p_entry = theApp.getRecentBooks()->getEntry(idx); //DanTodo: surely, there must be a way to get a title instead of rendering the URL with TTS ??! (see bookmark methd commented below) string str = p_entry->mPath.get_url(); Modified: branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp 2008-03-11 01:58:12 UTC (rev 2399) @@ -116,6 +116,7 @@ void CAmisSidebar::OnSelchangeTree(NMHDR* pNMHDR, LRESULT* pResult) { + if (theApp.isBookOpen() == false) return; amis::dtb::nav::NavPoint* p_nav = NULL; HTREEITEM item; item = m_wndTree.GetSelectedItem(); @@ -127,11 +128,13 @@ //this function is triggered by CNavListControl objects void CAmisSidebar::OnNavListSelect(NMHDR* pNMHDR, LRESULT* pResult, amis::dtb::nav::NavTarget* pData) { + if (theApp.isBookOpen() == false) return; if (pData != NULL) amis::dtb::DtbWithHooks::Instance()->loadNavNode(pData); } void CAmisSidebar::OnPageListClick(NMHDR* pNMHDR, LRESULT* pResult) { + if (theApp.isBookOpen() == false) return; amis::dtb::nav::PageTarget* p_page = NULL; int curr_sel; curr_sel = m_wndPageList.GetSelectionMark(); Modified: branches/amis3/bin/settings/amisRecentBooks.xml.default =================================================================== --- branches/amis3/bin/settings/amisRecentBooks.xml.default 2008-03-10 18:44:53 UTC (rev 2398) +++ branches/amis3/bin/settings/amisRecentBooks.xml.default 2008-03-11 01:58:12 UTC (rev 2399) @@ -1 +1 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no" ?><recentBooks xmlns="http://amisproject.org"></recentBooks> \ No newline at end of file +<?xml version="1.0" encoding="UTF-8" standalone="no" ?><bookList xmlns="http://amisproject.org" name="Recent Books"></bookList> \ 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...> - 2008-03-10 18:44:50
|
Revision: 2398 http://amis.svn.sourceforge.net/amis/?rev=2398&view=rev Author: marisademeglio Date: 2008-03-10 11:44:53 -0700 (Mon, 10 Mar 2008) Log Message: ----------- previous section works Modified Paths: -------------- branches/amis3/AmisCore/src/dtb/nav/NavModel.cpp Modified: branches/amis3/AmisCore/src/dtb/nav/NavModel.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/nav/NavModel.cpp 2008-03-10 18:22:58 UTC (rev 2397) +++ branches/amis3/AmisCore/src/dtb/nav/NavModel.cpp 2008-03-10 18:44:53 UTC (rev 2398) @@ -274,7 +274,10 @@ amis::dtb::nav::NavPoint* amis::dtb::nav::NavModel::previousSection(int currentPlayOrder) { - int idx = currentPlayOrder - 1; + //minus 2 because: play order is 1-based while our list is 0-based + //so a node with a play order of 10 will be in position 9 + //and we want to start looking backwards from position 8 + int idx = currentPlayOrder - 2; if (idx >= mPlayOrderList.size() || idx <= 0) return NULL; for (int i = idx; i >=0; i--) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-03-10 18:23:00
|
Revision: 2397 http://amis.svn.sourceforge.net/amis/?rev=2397&view=rev Author: marisademeglio Date: 2008-03-10 11:22:58 -0700 (Mon, 10 Mar 2008) Log Message: ----------- Fixed bug where section name was not retrieved for zed books Modified Paths: -------------- branches/amis3/AmisCore/src/dtb/nav/NavPoint.cpp branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp branches/amis3/AmisCore/src/io/NccFileReader.cpp Modified: branches/amis3/AmisCore/src/dtb/nav/NavPoint.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/nav/NavPoint.cpp 2008-03-07 05:55:43 UTC (rev 2396) +++ branches/amis3/AmisCore/src/dtb/nav/NavPoint.cpp 2008-03-10 18:22:58 UTC (rev 2397) @@ -167,11 +167,11 @@ void amis::dtb::nav::NavPoint::addChild(NavPoint* pNode) { pNode->setNavModel(mpNavModel); - NavMap* p_map = mpNavModel->getNavMap(); if (p_map != NULL) { + pNode->setNavContainer(p_map); p_map->recordNewDepth(pNode->getLevel()); } Modified: branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp 2008-03-07 05:55:43 UTC (rev 2396) +++ branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp 2008-03-10 18:22:58 UTC (rev 2397) @@ -130,7 +130,7 @@ pModel->setSmilIdNodeMap(mpMap); - printMap(true); + //printMap(true); } //then assign each NavNode a list of file#id values @@ -241,6 +241,7 @@ std::ofstream fileout; if (toFile == true) { + //TODO: take the path out fileout.open("map_printout.txt"); std::streambuf * filebuf = fileout.rdbuf(); cout.rdbuf(filebuf); @@ -255,7 +256,7 @@ { cout<<"Key: "<<mBigIdList[i]<<":"<<endl; NavNodeList* node_list = (*mpMap)[mBigIdList[i]]; - + if (node_list == NULL) continue; for (int j = 0; j<node_list->size(); j++) { cout<<"\t"; Modified: branches/amis3/AmisCore/src/io/NccFileReader.cpp =================================================================== --- branches/amis3/AmisCore/src/io/NccFileReader.cpp 2008-03-07 05:55:43 UTC (rev 2396) +++ branches/amis3/AmisCore/src/io/NccFileReader.cpp 2008-03-10 18:22:58 UTC (rev 2397) @@ -187,9 +187,7 @@ mListType = 0; - //allocate memory for the new node mpCurrentNavPoint = new amis::dtb::nav::NavPoint(); - mpCurrentNavPoint->setNavContainer(this->mpNavModel->getNavMap()); string classname; string id; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-03-07 05:55:39
|
Revision: 2396 http://amis.svn.sourceforge.net/amis/?rev=2396&view=rev Author: marisademeglio Date: 2008-03-06 21:55:43 -0800 (Thu, 06 Mar 2008) Log Message: ----------- added issues from new bug reports Modified Paths: -------------- branches/amis3/amis_issues.txt Modified: branches/amis3/amis_issues.txt =================================================================== --- branches/amis3/amis_issues.txt 2008-03-07 05:55:29 UTC (rev 2395) +++ branches/amis3/amis_issues.txt 2008-03-07 05:55:43 UTC (rev 2396) @@ -24,13 +24,19 @@ * stabilize self-voicing for menus * new audio backend makes reading options dialog crash * zed books need a stylesheet -* make highight colors override the book's built-in colors * Listviews have more than one column, cutting off text * Sidebar intercepts shift+arrow even when I tell it not to. * publication summary dialog not getting current section for zed books * window resizing problems with HTML view * "previous section" command results not previous enough +BUG REPORTS +--- +* play/pause state doesn't toggle correctly on startup +* navigation not highlighted until you click on it +* japanese characters not shown in sidebar in win2k + + AMBULANT ISSUES -- * How to stop ambulant when closing a book @@ -96,4 +102,5 @@ =================== * Loads last book on startup * Loads from command line -* Supports an unlimited number of font size CSS files. The default is still 4. \ No newline at end of file +* Supports an unlimited number of font size CSS files. The default is still 4. +* If no dc:identifier or the bookmark file can't be created, it crashes \ 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...> - 2008-03-07 05:55:25
|
Revision: 2395 http://amis.svn.sourceforge.net/amis/?rev=2395&view=rev Author: marisademeglio Date: 2008-03-06 21:55:29 -0800 (Thu, 06 Mar 2008) Log Message: ----------- No longer crashes if the book has no UID and bookmarking is unavailable. Bookmarking commands disabled if bookmarking not available. 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/MainFrm.h branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp branches/amis3/bin/settings/makeLocalCopiesOfDefaults.bat Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2008-03-06 00:12:19 UTC (rev 2394) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2008-03-07 05:55:29 UTC (rev 2395) @@ -436,7 +436,7 @@ //-------------------------------------------------- void amis::dtb::Dtb::loadBookmarks(const ambulant::net::url* filepath) { - if (filepath == NULL) + if (filepath == NULL || filepath->is_empty_path()) { mpBookmarks = NULL; return; @@ -553,6 +553,8 @@ //it turns out that this method signature is friendlier for ambulant than the other setNewLastmark function void amis::dtb::Dtb::setNewLastmark(ambulant::net::url positionUri) { + if (mpBookmarks == NULL) return; + amis::dtb::PositionData* p_pos_data = new amis::dtb::PositionData(); p_pos_data->mUri = positionUri; Modified: branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2008-03-06 00:12:19 UTC (rev 2394) +++ branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2008-03-07 05:55:29 UTC (rev 2395) @@ -35,6 +35,7 @@ #include "dtb/DtbFileSet.h" #include "util/FilePathTools.h" #include "util/findfilecontainer.h" +#include "util/Log.h" //DTB fileset utility class amis::dtb::DtbFileSet::DtbFileSet() @@ -80,7 +81,10 @@ mBookmarksFilepath = ambulant::net::url::from_filename(thefilename);//calculateSafeBookmarksFilename(uid)); mBookmarksFilepath = mBookmarksFilepath.join_to_base(mBookmarksDirectory); } - + else + { + amis::util::Log::Instance()->writeError("No UID found. Bookmarking unavailable.", "DtbFileSet::setAdditionalDataAfterInitialParse", "AmisCore"); + } if (navfile != NULL) { mNavFilepath = navfile->join_to_base(mBookDirectory); Modified: branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp 2008-03-06 00:12:19 UTC (rev 2394) +++ branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp 2008-03-07 05:55:29 UTC (rev 2395) @@ -130,7 +130,7 @@ pModel->setSmilIdNodeMap(mpMap); -// printMap(true); + printMap(true); } //then assign each NavNode a list of file#id values Modified: branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-03-06 00:12:19 UTC (rev 2394) +++ branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-03-07 05:55:29 UTC (rev 2395) @@ -83,6 +83,7 @@ afx_msg void OnUpdateCmdUiPageStyle(CCmdUI*); afx_msg void OnUpdateCmdUiBiggerFont(CCmdUI*); afx_msg void OnUpdateCmdUiSmallerFont(CCmdUI*); + afx_msg void OnUpdateCmdUiBookmarks(CCmdUI*); DECLARE_MESSAGE_MAP() public: void updateToolbarState(toolbar::Toolbar*); Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-06 00:12:19 UTC (rev 2394) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-07 05:55:29 UTC (rev 2395) @@ -67,7 +67,7 @@ ON_UPDATE_COMMAND_UI(ID_AMIS_NEXT_PAGE, OnUpdateCmdUiPageCommands) ON_UPDATE_COMMAND_UI(ID_AMIS_PREVIOUS_PAGE, OnUpdateCmdUiPageCommands) ON_UPDATE_COMMAND_UI(ID_AMIS_GOTO_PAGE, OnUpdateCmdUiPageCommands) - ON_UPDATE_COMMAND_UI(ID_AMIS_ADD_BOOKMARK, OnUpdateCmdUiGeneral) + ON_UPDATE_COMMAND_UI(ID_AMIS_ADD_BOOKMARK, OnUpdateCmdUiBookmarks) ON_UPDATE_COMMAND_UI(ID_AMIS_FASTER, OnUpdateCmdUiPlayFaster) ON_UPDATE_COMMAND_UI(ID_AMIS_CLOSE_BOOK, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_SHOW_READING_OPTIONS, OnUpdateCmdUiInfoSkip) @@ -557,6 +557,13 @@ else updateUiCommandState(pCmdUi, false); } +void amis::gui::CMainFrame::OnUpdateCmdUiBookmarks(CCmdUI* pCmdUi) +{ + if (theApp.isBookOpen() && amis::dtb::DtbWithHooks::Instance()->getBookmarks() != NULL) + updateUiCommandState(pCmdUi, true); + else + updateUiCommandState(pCmdUi, false); +} //the ON_UPDATE_COMMAND_UI messages end up here because it takes care of the toolbars too void amis::gui::CMainFrame::updateUiCommandState(CCmdUI* pCmdUi, bool value) @@ -617,8 +624,12 @@ else pToolbar->enable(ID_AMIS_SHOW_READING_OPTIONS, false); + if (b_is_book_open && amis::dtb::DtbWithHooks::Instance()->getBookmarks() != NULL) + pToolbar->enable(ID_AMIS_ADD_BOOKMARK, true); + else + pToolbar->enable(ID_AMIS_ADD_BOOKMARK, false); + //general stuff - pToolbar->enable(ID_AMIS_ADD_BOOKMARK, b_is_book_open); pToolbar->enable(ID_AMIS_CLOSE_BOOK, b_is_book_open); pToolbar->enable(ID_AMIS_FOCUS_ON_TEXT, b_is_book_open); pToolbar->enable(ID_AMIS_TOGGLE_AUDIO_CONTENT_PLAYBACK, b_is_book_open); Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp 2008-03-06 00:12:19 UTC (rev 2394) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp 2008-03-07 05:55:29 UTC (rev 2395) @@ -139,18 +139,22 @@ mNarrator = p_meta->getMetadataContent("dc:Narrator"); } - //TODO: get the full mutimedia data (should be available directly from the nav data model) - mNavigableItems = p_nav->getNavMap()->getLabel()->getText()->getTextString(); - if (p_nav->hasPages()) - { - mNavigableItems.append(L", "); - mNavigableItems.append(p_nav->getPageList()->getLabel()->getText()->getTextString()); + //TODO: get the full multimedia data (should be available directly from the nav data model) + if (p_nav->getNavMap()->getLabel() != NULL) + { + mNavigableItems = p_nav->getNavMap()->getLabel()->getText()->getTextString(); + if (p_nav->hasPages()) + { + mNavigableItems.append(L", "); + mNavigableItems.append(p_nav->getPageList()->getLabel()->getText()->getTextString()); + } } int sz = p_nav->getNumberOfNavLists(); for (int i=0; i<sz; i++) { mNavigableItems.append(L", "); - mNavigableItems.append(p_nav->getNavList(i)->getLabel()->getText()->getTextString()); + if (p_nav->getNavList(i)->getLabel() != NULL) + mNavigableItems.append(p_nav->getNavList(i)->getLabel()->getText()->getTextString()); } mPublisher = p_meta->getMetadataContent("dc:Publisher"); mDescription = p_meta->getMetadataContent("dc:Description"); Modified: branches/amis3/bin/settings/makeLocalCopiesOfDefaults.bat =================================================================== --- branches/amis3/bin/settings/makeLocalCopiesOfDefaults.bat 2008-03-06 00:12:19 UTC (rev 2394) +++ branches/amis3/bin/settings/makeLocalCopiesOfDefaults.bat 2008-03-07 05:55:29 UTC (rev 2395) @@ -1,4 +1,5 @@ rem this batch file copies two default config files and renames them so they work with amis -copy amisRecentBooks.xml.default amisRecentBooks.xml -copy amisPrefs.xml.default amisPrefs.xml \ No newline at end of file +copy amisRecentBooks.xml.default amisRecentBooks.xml /y +copy amisPrefs.xml.default amisPrefs.xml /y +copy bmk\amisExtraBookmarksInfo.xml.default bmk\amisExtraBookmarksInfo.xml /y \ 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...> - 2008-03-06 00:12:15
|
Revision: 2394 http://amis.svn.sourceforge.net/amis/?rev=2394&view=rev Author: marisademeglio Date: 2008-03-05 16:12:19 -0800 (Wed, 05 Mar 2008) Log Message: ----------- new feature marked done Modified Paths: -------------- branches/amis3/amis_issues.txt Modified: branches/amis3/amis_issues.txt =================================================================== --- branches/amis3/amis_issues.txt 2008-03-06 00:11:49 UTC (rev 2393) +++ branches/amis3/amis_issues.txt 2008-03-06 00:12:19 UTC (rev 2394) @@ -13,7 +13,6 @@ * add navlists to view menu * re-add tooltips * next/previous page/phrase/section should be enabled or disabled according to the book state -* suport unlimited font sizes * add dialog to adjust highlight colors and font type * fontsize in the sidebar * highlight current section (in sidebar) in same color as page highlight @@ -97,3 +96,4 @@ =================== * Loads last book on startup * Loads from command line +* Supports an unlimited number of font size CSS files. The default is still 4. \ 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...> - 2008-03-06 00:11:43
|
Revision: 2393 http://amis.svn.sourceforge.net/amis/?rev=2393&view=rev Author: marisademeglio Date: 2008-03-05 16:11:49 -0800 (Wed, 05 Mar 2008) Log Message: ----------- Supports an unlimited number of files in the css/font directory Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-05 22:20:43 UTC (rev 2392) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-06 00:11:49 UTC (rev 2393) @@ -44,6 +44,7 @@ #define WITH_DAISY_PDTB #define AMIS_MAX_ANYTHING 49 +#define AMIS_MAX_AUDIO_RATE 4.0 namespace amis { @@ -65,7 +66,8 @@ bool isBookOpen(); void setPauseState(bool play); bool shouldIgnoreOpenDocEvent(); - + bool canIncreasePlaybackSpeed(); + bool canDecreasePlaybackSpeed(); //Menu handlers afx_msg void OnFileOpen(); afx_msg void OnPlayPause(); Modified: branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2008-03-05 22:20:43 UTC (rev 2392) +++ branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2008-03-06 00:11:49 UTC (rev 2393) @@ -47,11 +47,11 @@ void DestroyInstance(); ~TextRenderBrain(); + bool canIncreaseFontSize(); + bool canDecreaseFontSize(); void resetFontSize(); void increaseFontSize(); void decreaseFontSize(); - int getFontLevel(); - int getMaxFontLevel(); void gotoUriTarget(amis::TextNode*); void gotoUriTarget(std::string url); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-05 22:20:43 UTC (rev 2392) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-06 00:11:49 UTC (rev 2393) @@ -139,9 +139,7 @@ // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. InitCommonControls(); - CWinApp::InitInstance(); - mbBookIsOpen = false; mAppPath = ""; @@ -246,7 +244,7 @@ int CAmisApp::ExitInstance() { - TRACE("\nEXITING...\n\n"); + TRACE("\nStarting to EXIT\n\n"); Preferences::Instance()->setWasExitClean(true); PreferencesFileIO prefs_io; @@ -262,31 +260,23 @@ amis::gui::TextRenderBrain::Instance()->DestroyInstance(); amis::gui::MenuManip::Instance()->DestroyInstance(); amis::gui::MainWndParts::Instance()->DestroyInstance(); - - AudioSequencePlayer::Instance()->DestroyInstance(); - - + AudioSequencePlayer::Instance()->DestroyInstance(); DataTree::Instance()->DestroyInstance(); - if (mpRecentBooks != NULL) delete mpRecentBooks; CoUninitialize(); amis::util::Log::Instance()->writeMessage("AMIS EXIT."); - amis::util::Log::Instance()->endLog(); amis::util::Log::Instance()->DestroyInstance(); - TRACE("\nEXIT.\n\n"); - return CWinApp::ExitInstance(); } std::string CAmisApp::getAppPath() { USES_CONVERSION; - if (mAppPath == "") { TCHAR szBuffer[256]; @@ -296,7 +286,6 @@ if (pos >= 0) cstr_app_path = cstr_app_path.Mid(0, pos + 1); mAppPath = W2CA(cstr_app_path); } - return mAppPath; } @@ -495,16 +484,12 @@ amis::util::Log::Instance()->writeMessage("Next phrase", "CAmisApp::OnNavNextPhrase", "AmisGuiMFC2"); amis::dtb::DtbWithHooks::Instance()->nextPhrase(); } - - void CAmisApp::OnFileExit() { amis::util::Log::Instance()->writeMessage("Exiting", "CAmisApp::OnFileExit", "AmisGuiMFC2"); CWnd * ptr = AfxGetMainWnd(); ptr->SendMessage(WM_CLOSE); } - - void CAmisApp::OnFileRecentBook(UINT id) { if (mpRecentBooks == NULL) return; @@ -901,21 +886,9 @@ } void CAmisApp::updateFontSizeButtons() -{ - int font_level = TextRenderBrain::Instance()->getFontLevel(); - int max = TextRenderBrain::Instance()->getMaxFontLevel(); - bool can_increase = true; - bool can_decrease = true; - if (font_level == 0) - { - can_decrease = false; - can_increase = true; - } - else if (font_level == max) - { - can_decrease = true; - can_increase = false; - } +{ + bool can_increase = TextRenderBrain::Instance()->canIncreaseFontSize(); + bool can_decrease = TextRenderBrain::Instance()->canDecreaseFontSize(); MainWndParts::Instance()->mpDefaultToolbar->enable(ID_AMIS_BIGGER_FONT, can_increase); MainWndParts::Instance()->mpBasicToolbar->enable(ID_AMIS_BIGGER_FONT, can_increase); MainWndParts::Instance()->mpDefaultToolbar->enable(ID_AMIS_SMALLER_FONT, can_decrease); @@ -924,25 +897,23 @@ void CAmisApp::updateSpeedButtons() { - double rate = ambulantX::gui::dx::audio_playerX::Instance()->get_rate(); - - //TODO: unhardcode the max rate - double max = 2.0; - bool can_increase = true; - bool can_decrease = true; - if (rate == 1) - { - can_decrease = false; - can_increase = true; - } - else if (rate == max) - { - can_decrease = true; - can_increase = false; - } + bool can_increase = canIncreasePlaybackSpeed(); + bool can_decrease = canDecreasePlaybackSpeed(); MainWndParts::Instance()->mpDefaultToolbar->enable(ID_AMIS_FASTER, can_increase); MainWndParts::Instance()->mpBasicToolbar->enable(ID_AMIS_FASTER, can_increase); MainWndParts::Instance()->mpDefaultToolbar->enable(ID_AMIS_SLOWER, can_decrease); MainWndParts::Instance()->mpBasicToolbar->enable(ID_AMIS_SLOWER, can_decrease); +} +bool CAmisApp::canIncreasePlaybackSpeed() +{ + double rate = ambulantX::gui::dx::audio_playerX::Instance()->get_rate(); + if (rate < AMIS_MAX_AUDIO_RATE) return true; + else return false; +} +bool CAmisApp::canDecreasePlaybackSpeed() +{ + double rate = ambulantX::gui::dx::audio_playerX::Instance()->get_rate(); + if (rate <= 1) return false; + else return true; } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-05 22:20:43 UTC (rev 2392) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-06 00:11:49 UTC (rev 2393) @@ -459,6 +459,9 @@ } CMDIFrameWnd::OnSysCommand(nID, lParam); } +//--------------------------------------------- +//beginning of menu command updater functions +//--------------------------------------------- void CMainFrame::OnUpdateCmdUiPageCommands(CCmdUI* pCmdUi) { if (theApp.isBookOpen() && amis::dtb::DtbWithHooks::Instance()->getNavModel()->hasPages()) @@ -473,27 +476,22 @@ } void CMainFrame::OnUpdateCmdUiInfoSkip(CCmdUI* pCmdUi) { - //TODO: re-enable when the reading options dialog works - updateUiCommandState(pCmdUi, false); - /* if (theApp.isBookOpen() && amis::dtb::DtbWithHooks::Instance()->getCustomTestSet() != NULL && amis::dtb::DtbWithHooks::Instance()->getCustomTestSet()->getLength() > 0) updateUiCommandState(pCmdUi, true); else updateUiCommandState(pCmdUi, false); - */ } void CMainFrame::OnUpdateCmdUiPlaySlower(CCmdUI* pCmdUi) { - if (theApp.isBookOpen() && ambulantX::gui::dx::audio_playerX::Instance()->get_rate() > 1) + if (theApp.isBookOpen() && theApp.canDecreasePlaybackSpeed()) updateUiCommandState(pCmdUi, true); else updateUiCommandState(pCmdUi, false); } void CMainFrame::OnUpdateCmdUiPlayFaster(CCmdUI* pCmdUi) { - //TODO: unhardcode the max rate - if (theApp.isBookOpen() && ambulantX::gui::dx::audio_playerX::Instance()->get_rate() < 2.0) + if (theApp.isBookOpen() && theApp.canIncreasePlaybackSpeed()) updateUiCommandState(pCmdUi, true); else updateUiCommandState(pCmdUi, false); @@ -515,7 +513,6 @@ { if (theApp.isBookOpen()) { - //should it say "play" or "pause"? MmView *p_view = MainWndParts::Instance()->mpMmView; if (p_view == NULL) return; bool b_is_playing = p_view->isPlaying(); @@ -530,8 +527,7 @@ { if (theApp.isBookOpen()) { - int curr = TextRenderBrain::Instance()->getCurrentCustomStyleIndex(); - + int curr = TextRenderBrain::Instance()->getCurrentCustomStyleIndex(); if (curr == -1) { if (pCmdUi->m_nID == ID_AMIS_NO_PAGE_STYLES) pCmdUi->SetCheck(1); @@ -549,14 +545,14 @@ } void amis::gui::CMainFrame::OnUpdateCmdUiSmallerFont(CCmdUI* pCmdUi) { - if (theApp.isBookOpen() && TextRenderBrain::Instance()->getFontLevel() > 0) + if (theApp.isBookOpen() && TextRenderBrain::Instance()->canDecreaseFontSize()) updateUiCommandState(pCmdUi, true); else updateUiCommandState(pCmdUi, false); } void amis::gui::CMainFrame::OnUpdateCmdUiBiggerFont(CCmdUI* pCmdUi) { - if (theApp.isBookOpen() && TextRenderBrain::Instance()->getFontLevel() < TextRenderBrain::Instance()->getMaxFontLevel()) + if (theApp.isBookOpen() && TextRenderBrain::Instance()->canIncreaseFontSize()) updateUiCommandState(pCmdUi, true); else updateUiCommandState(pCmdUi, false); @@ -575,49 +571,74 @@ //we need it anyway. i suspect that our custom toolbars bypass the effect of OnUpdateCommandUi void amis::gui::CMainFrame::updateToolbarState(toolbar::Toolbar* pToolbar) { - if (theApp.isBookOpen() && Preferences::Instance()->getIsSelfVoicing() && ambulantX::gui::dx::audio_playerX::Instance()->get_rate() > 1) - pToolbar->enable(ID_AMIS_SLOWER, true); + bool b_is_book_open = theApp.isBookOpen(); + //audio rate + if (b_is_book_open) + { + pToolbar->enable(ID_AMIS_SLOWER, theApp.canDecreasePlaybackSpeed()); + pToolbar->enable(ID_AMIS_FASTER, theApp.canIncreasePlaybackSpeed()); + } else + { pToolbar->enable(ID_AMIS_SLOWER, false); - - bool enable_page_cmds = false; - if (theApp.isBookOpen() && amis::dtb::DtbWithHooks::Instance()->getNavModel()->hasPages()) - enable_page_cmds = true; + pToolbar->enable(ID_AMIS_FASTER, false); + } + //page navigation + if (b_is_book_open) + { + pToolbar->enable(ID_AMIS_NEXT_PAGE, amis::dtb::DtbWithHooks::Instance()->getNavModel()->hasPages()); + pToolbar->enable(ID_AMIS_PREVIOUS_PAGE, amis::dtb::DtbWithHooks::Instance()->getNavModel()->hasPages()); + pToolbar->enable(ID_AMIS_GOTO_PAGE, amis::dtb::DtbWithHooks::Instance()->getNavModel()->hasPages()); + } + else + { + pToolbar->enable(ID_AMIS_NEXT_PAGE, false); + pToolbar->enable(ID_AMIS_PREVIOUS_PAGE, false); + pToolbar->enable(ID_AMIS_GOTO_PAGE, false); + } - pToolbar->enable(ID_AMIS_NEXT_PAGE, enable_page_cmds); - pToolbar->enable(ID_AMIS_PREVIOUS_PAGE, enable_page_cmds); - pToolbar->enable(ID_AMIS_GOTO_PAGE, enable_page_cmds); + //font sizes + if (b_is_book_open) + { + pToolbar->enable(ID_AMIS_BIGGER_FONT, TextRenderBrain::Instance()->canIncreaseFontSize()); + pToolbar->enable(ID_AMIS_SMALLER_FONT, TextRenderBrain::Instance()->canDecreaseFontSize()); + } + else + { + pToolbar->enable(ID_AMIS_BIGGER_FONT, false); + pToolbar->enable(ID_AMIS_SMALLER_FONT, false); + } - pToolbar->enable(ID_AMIS_BIGGER_FONT, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_SMALLER_FONT, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_ADD_BOOKMARK, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_FASTER, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_CLOSE_BOOK, theApp.isBookOpen()); - - if (theApp.isBookOpen() && amis::dtb::DtbWithHooks::Instance()->getCustomTestSet() != NULL + //reading options (aka "skippability") + if (b_is_book_open + && amis::dtb::DtbWithHooks::Instance()->getCustomTestSet() != NULL && amis::dtb::DtbWithHooks::Instance()->getCustomTestSet()->getLength() > 0) pToolbar->enable(ID_AMIS_SHOW_READING_OPTIONS, true); else pToolbar->enable(ID_AMIS_SHOW_READING_OPTIONS, false); - pToolbar->enable(ID_AMIS_FOCUS_ON_TEXT, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_TOGGLE_AUDIO_CONTENT_PLAYBACK, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_NO_PAGE_STYLES, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_PLAYPAUSE, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_ESCAPE, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_RESET_SPEED, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_PREVIOUS_SECTION, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_NEXT_SECTION, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_PREVIOUS_PHRASE, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_NEXT_PHRASE, theApp.isBookOpen()); + //general stuff + pToolbar->enable(ID_AMIS_ADD_BOOKMARK, b_is_book_open); + pToolbar->enable(ID_AMIS_CLOSE_BOOK, b_is_book_open); + pToolbar->enable(ID_AMIS_FOCUS_ON_TEXT, b_is_book_open); + pToolbar->enable(ID_AMIS_TOGGLE_AUDIO_CONTENT_PLAYBACK, b_is_book_open); + pToolbar->enable(ID_AMIS_NO_PAGE_STYLES, b_is_book_open); + pToolbar->enable(ID_AMIS_PLAYPAUSE, b_is_book_open); + pToolbar->enable(ID_AMIS_ESCAPE, b_is_book_open); + pToolbar->enable(ID_AMIS_RESET_SPEED, b_is_book_open); + pToolbar->enable(ID_AMIS_PREVIOUS_SECTION, b_is_book_open); + pToolbar->enable(ID_AMIS_NEXT_SECTION, b_is_book_open); + pToolbar->enable(ID_AMIS_PREVIOUS_PHRASE, b_is_book_open); + pToolbar->enable(ID_AMIS_NEXT_PHRASE, b_is_book_open); + pToolbar->enable(ID_AMIS_SHOW_PUBLICATION_SUMMARY, b_is_book_open); + pToolbar->enable(ID_AMIS_NEXT_PAGE_STYLE, b_is_book_open); + pToolbar->enable(ID_AMIS_INCREASE_SECTION_DEPTH, b_is_book_open); + pToolbar->enable(ID_AMIS_DECREASE_SECTION_DEPTH, b_is_book_open); + pToolbar->enable(ID_AMIS_INCREASE_VOLUME, b_is_book_open); + pToolbar->enable(ID_AMIS_DECREASE_VOLUME, b_is_book_open); + //TODO: re-enable when the find in text feature works pToolbar->enable(ID_AMIS_FIND_IN_TEXT, false); - pToolbar->enable(ID_AMIS_SHOW_PUBLICATION_SUMMARY, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_NEXT_PAGE_STYLE, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_INCREASE_SECTION_DEPTH, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_DECREASE_SECTION_DEPTH, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_INCREASE_VOLUME, theApp.isBookOpen()); - pToolbar->enable(ID_AMIS_DECREASE_VOLUME, theApp.isBookOpen()); } void amis::gui::CMainFrame::RecalcLayout(BOOL bNotify) { @@ -626,9 +647,7 @@ CRect rect; GetClientRect(&rect); mBasicToolbar.SetIndent ( - (rect.Width() - - (mBasicToolbar.GetButtonCount() * LOWORD(mBasicToolbar.GetButtonSize())) - ) + (rect.Width() - (mBasicToolbar.GetButtonCount() * LOWORD(mBasicToolbar.GetButtonSize()))) / 2); CMDIFrameWnd::RecalcLayout(bNotify); Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-03-05 22:20:43 UTC (rev 2392) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-03-06 00:11:49 UTC (rev 2393) @@ -284,14 +284,6 @@ p_style->put_backgroundColor(var_bg); p_style->put_color(var_fg); } -int TextRenderBrain::getFontLevel() -{ - return mFontSize; -} -int TextRenderBrain::getMaxFontLevel() -{ - return 4; -} int TextRenderBrain::getCurrentCustomStyleIndex() { return mCurrentStyleIdx; @@ -336,14 +328,34 @@ void TextRenderBrain::increaseFontSize() { - amis::util::Log::Instance()->writeMessage("Font size increased", "TextRenderBrain::increaseFontSize", "AmisGuiMFC2"); - if (mFontSize >= 0 && mFontSize < 4) setFontSize(mFontSize + 1); + if (canIncreaseFontSize()) + { + amis::util::Log::Instance()->writeMessage("Font size increased", "TextRenderBrain::increaseFontSize", "AmisGuiMFC2"); + setFontSize(mFontSize + 1); + } } void TextRenderBrain::decreaseFontSize() { - amis::util::Log::Instance()->writeMessage("Font size decreased", "TextRenderBrain::decreaseFontSize", "AmisGuiMFC2"); - if (mFontSize > 0 && mFontSize <=4) setFontSize(mFontSize - 1); + if (canDecreaseFontSize()) + { + amis::util::Log::Instance()->writeMessage("Font size decreased", "TextRenderBrain::decreaseFontSize", "AmisGuiMFC2"); + setFontSize(mFontSize - 1); + } } +bool TextRenderBrain::canIncreaseFontSize() +{ + if (mFontSize < Preferences::Instance()->getFontsizeCssFiles()->size()) + return true; + else + return false; +} +bool TextRenderBrain::canDecreaseFontSize() +{ + if (mFontSize > 0) + return true; + else + return false; +} void TextRenderBrain::resetFontSize() { amis::util::Log::Instance()->writeMessage("Font size reset", "TextRenderBrain::resetFontSize", "AmisGuiMFC2"); @@ -351,7 +363,8 @@ } //set the font size //0 = reset -//1...4 = increasingly bigger +//1...n = index into a file in the css/font directory (presumably the files are in alpha order and each +//represents a larger size) void TextRenderBrain::setFontSize(int fontsz) { if (fontsz > Preferences::Instance()->getFontsizeCssFiles()->size() || fontsz < 1) fontsz = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-03-05 22:20:42
|
Revision: 2392 http://amis.svn.sourceforge.net/amis/?rev=2392&view=rev Author: marisademeglio Date: 2008-03-05 14:20:43 -0800 (Wed, 05 Mar 2008) Log Message: ----------- added features and issues files Added Paths: ----------- branches/amis3/amis_features.txt branches/amis3/amis_issues.txt Added: branches/amis3/amis_features.txt =================================================================== --- branches/amis3/amis_features.txt (rev 0) +++ branches/amis3/amis_features.txt 2008-03-05 22:20:43 UTC (rev 2392) @@ -0,0 +1,79 @@ +AMIS +==== +ABOUT + Open source DAISY player + Free of charge + Actively developed and supported + Can be localized + Previous versions already in-use worldwide + +BOOKS SUPPORTED + DAISY 2.02 full text + full audio + DAISY 2.02 ncc + audio + + DAISY/NISO 2005 full text + full audio + DAISY/NISO 2005 ncx + audio + + Experimental books with Ncc/Ncx + full SMIL 2.0 (e.g. video + captions) + +REQUIREMENTS + Windows XP + Windows 2000 + Windows Vista + DirectX 9 + SAPI 5.1 + +FEATURES +-------- +Navigation shortcuts + Previous/Next phrase + Previous/Next page + Previous/Next section + Go to page + +Browsing the structure in the navigation sidebar + Hierarchical view of sections + List of pages + Lists for each special type of item in the book + +Bookmarking + Add bookmark (named automatically based on what you are bookmarking) + Go to bookmark + Bookmarks for a particular book automatically load when you open that book + +Open a recently-read book +Automatically open your last-read book on startup +Open a local book from the command line +Open the contents of a CD-ROM containing a single book or containing multiple books +Open a book from your local file system +Open a book from a remote URL + +Speed-up audio playback X times +Play and pause the book + +See publication summary information for the book +Find out basic information about AMIS + +Use basic or default view mode +Show/hide the navigation sidebar +Move the navigation sidebar around the screen +Change the style of the page +Make the font bigger up to X times (and go back and forth between sizes) + +Customization + Toolbars + - defined externally in settings\defaultToolbar.xml and settings\basicToolbar.xml + - try making one, following the existing format + - icons go in the img directory + + Fontsize + - font size is defined using css files in settings\css\font\*.css + - You can put anything in here up to X files. + + Page styles + - page styles are defined using css files in settings\css\customStyles\*.css + - You can put anything in here and it will show up in the Page Styles submenu. + - Each will be applied in turn when the user presses the Page Style button. + + AMIS own highlight settings are defined in settings\css\amis.css . See the notes there about how the file is set up. + \ No newline at end of file Added: branches/amis3/amis_issues.txt =================================================================== --- branches/amis3/amis_issues.txt (rev 0) +++ branches/amis3/amis_issues.txt 2008-03-05 22:20:43 UTC (rev 2392) @@ -0,0 +1,99 @@ +ALPHA 2 (MARCH 17) +========== +CODE ORGANIZATION +--- +* code cleanup to follow conventions/style of existing code regarding folder locations, indentation, variables +* use meaningful trace messages and delete old ones +* review TODOs, remove if resolved, address if needed +* remove commented-out code + +NEW FEATURES +--- +* finish self-voicing for all dialogs +* add navlists to view menu +* re-add tooltips +* next/previous page/phrase/section should be enabled or disabled according to the book state +* suport unlimited font sizes +* add dialog to adjust highlight colors and font type +* fontsize in the sidebar +* highlight current section (in sidebar) in same color as page highlight +* bookmarking for non-ascii dc:identifiers +* opening URLs from the command line + +ISSUES +--- +* stabilize self-voicing for menus +* new audio backend makes reading options dialog crash +* zed books need a stylesheet +* make highight colors override the book's built-in colors +* Listviews have more than one column, cutting off text +* Sidebar intercepts shift+arrow even when I tell it not to. +* publication summary dialog not getting current section for zed books +* window resizing problems with HTML view +* "previous section" command results not previous enough + +AMBULANT ISSUES +-- +* How to stop ambulant when closing a book +* review skippability across document boundaries (need reading options dialog to work) + + +BETA (APRIL 1) +================= +NEW FEATURES +--- +* Parse CSS for font info, contrast info +* Don't start reading when browsing the TOC - just announce the label for the item +* AmisCore's "Find in text" needs a faster algorithm +* find in text dialog +* AMIS should remember its last window size and reuse it on startup +* implement (these commands are always available) + ID_AMIS_FOCUS_ON_SIDEBAR + ID_AMIS_TOGGLE_AUDIO_SELFVOICING_PLAYBACK +* implement (available when a book is open) + ID_AMIS_FOCUS_ON_TEXT + ID_AMIS_RESET_HIGHLIGHT_COLORS + ID_AMIS_TOGGLE_AUDIO_CONTENT_PLAYBACK +* add commands to increase/decrease specific volumes + +ISSUES +--- +* disable IE7 right-click menu + +OTHER +--- +* select TTS based on language of book/UI. or take an educated guess. +* Right/left arrow means something different (conceptually) in nav window +* how do we count pages? does the page number appear at the bottom or top of the page? +* resource.h.ini needs to be kept in-sync with a post-build batch process +* memory leaks in ambulant::logger, UrlInputSource, plugin_engine +* installer prompts about Thai encoding support + +LANGUAGE PACKS +--- +* update RC template +* Re-add Language pack support +* review widget types in AmisAccessibleUI (we can't say which will be toolbar items) +* harmonize icon refs with toolbar xml + + +POSTPONED FOR CANDIDATE RELEASE (MAY 1) +=============================== +* One installer per language +* update web scripts to reflect new or changed items +* Update help contents + + +POSTPONED TO BEYOND AMIS 3's FIRST STABLE RELEASE +================================================= +* Dist/disc info +* Handle multiple volumes +* audio slow-down +* Support DAISY resource files (need an example!) +* Bookshare books are slow and don't load if a bookmark file exists for them; eventually this error appears 12:35:27 TRACE dx_html_renderer: programmer error: attempt to start() again. + + +ADDED AFTER ALPHA 1 +=================== +* Loads last book on startup +* Loads from command line This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2008-03-05 05:37:51
|
Revision: 2391 http://amis.svn.sourceforge.net/amis/?rev=2391&view=rev Author: daniel_weck Date: 2008-03-04 21:37:51 -0800 (Tue, 04 Mar 2008) Log Message: ----------- * added a DEFINE flag to compile using a special single-thread mode for the DirectShow backend. It works well so far, but I have not tested as much as the previous design (one-thread-per-audio). Simply un/comment the flag to switch between the 2 different architectures. The single-thread should be (in theory) safer, as it means less overhead and less data to synchronize. It should definitely be cheaper at runtime, as there's only one thread allocated at startup. Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h 2008-03-05 04:09:10 UTC (rev 2390) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h 2008-03-05 05:37:51 UTC (rev 2391) @@ -134,6 +134,8 @@ static double s_current_playback_rate = 1.0; +#define SINGLE_THREAD_HACK + namespace ambulantX { namespace gui { @@ -151,7 +153,9 @@ static audio_playerX* Instance(); static void DestroyInstance(); - +#ifdef SINGLE_THREAD_HACK +HANDLE m_hEventWakeup; +#endif ~audio_playerX(); void start(double t); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-05 04:09:10 UTC (rev 2390) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-05 05:37:51 UTC (rev 2391) @@ -270,9 +270,13 @@ if (mpRecentBooks != NULL) delete mpRecentBooks; + CoUninitialize(); + + amis::util::Log::Instance()->writeMessage("AMIS EXIT."); + amis::util::Log::Instance()->endLog(); amis::util::Log::Instance()->DestroyInstance(); - CoUninitialize(); + TRACE("\nEXIT.\n\n"); Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp 2008-03-05 04:09:10 UTC (rev 2390) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp 2008-03-05 05:37:51 UTC (rev 2391) @@ -73,9 +73,18 @@ while(!bSelfBreak) { hResult = E_FAIL; +#ifdef SINGLE_THREAD_HACK + if (pPlayer->m_media_event == NULL) { + Sleep(100); + continue; + } +#endif + + TRACE(L"\n== THREAD BEFORE EVENT %d\n", nn); hResult = pPlayer->m_media_event->GetEvent(&lEventCode, &lParam1, &lParam2, INFINITE); - pPlayer->m_media_event->FreeEventParams(lEventCode, lParam1, lParam2); + TRACE(L"\n== THREAD AFTER EVENT %d\n", nn); + if (hResult == S_OK) { switch(lEventCode) { case EC_COMPLETE: @@ -83,12 +92,11 @@ TRACE(L"\n== THREAD EVENT COMPLETE %d\n", nn); pPlayer->stop(false, true); - - TRACE(L"\n== THREAD BEFORE CALLBACK %d\n", nn); pPlayer->sendMessageCallback(); - +#ifndef SINGLE_THREAD_HACK bSelfBreak = true; +#endif break; } case EC_USER + 4: { @@ -99,6 +107,39 @@ bSelfBreak = true; break; } + +#ifdef SINGLE_THREAD_HACK +case EC_USER + 5: { +TRACE(L"\n== THREAD BEFORE WAIT TOGGLE %d\n", nn); + DWORD hr = WaitForSingleObject(pPlayer->m_hEventWakeup, INFINITE); + switch (hr) { + case WAIT_FAILED: { + int i = 0; + break; + } + + case WAIT_ABANDONED + : { + int i = 0; + break;} + + case WAIT_OBJECT_0 + : { + int i = 0; + break;} + + case WAIT_TIMEOUT: + { + int i = 0; + break; + } + + } + TRACE(L"\n== THREAD AFTER WAIT TOGGLE %d\n", nn); + break; + } +#endif + default: TRACE(L"\n== THREAD EVENT OTHER %d (%d)\n", nn, lEventCode); } @@ -125,6 +166,9 @@ hEventHandler(0) { set_rate(1.0); + m_hEventWakeup = CreateEvent(NULL, TRUE, FALSE, NULL); + _ASSERT(m_hEventWakeup); + ResetEvent(m_hEventWakeup); InitializeCriticalSection(&m_csSequence); } @@ -230,8 +274,15 @@ void gui::dx::audio_playerX::stop(bool fromPlay, bool fromThread) { +#ifdef SINGLE_THREAD_HACK + ResetEvent(m_hEventWakeup); +#endif + if (fromThread) { + +#ifndef SINGLE_THREAD_HACK hEventHandler = NULL; +#endif return; } @@ -249,9 +300,19 @@ EnterCriticalSection(&m_csSequence); } +#ifndef SINGLE_THREAD_HACK TRACE(L"\n####### -- STOP DX || BEFORE END THREAD\n"); end_thread(); +#else + IMediaEventSink *pIMES = NULL; + m_graph_builder->QueryInterface(IID_IMediaEventSink, (void**) &pIMES); + pIMES->Notify(EC_USER + 5, 0, 0); + pIMES->Release(); + pIMES = NULL; +#endif +Sleep(100); + TRACE(L"\n####### -- STOP DX || AFTER END THREAD\n"); HRESULT hr = m_media_control->Stop(); @@ -725,6 +786,9 @@ //hEventHandler = (HANDLE) _beginthreadex(NULL, 0, eventHandler, (void*) this, 0, &lpdwThreadID); hEventHandler = CreateThread(NULL, 0, &eventHandler, this, 0, &lpdwThreadID); } +#ifdef SINGLE_THREAD_HACK + SetEvent(m_hEventWakeup); +#endif hr = m_media_control->Run(); if(FAILED(hr)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2008-03-05 04:09:06
|
Revision: 2390 http://amis.svn.sourceforge.net/amis/?rev=2390&view=rev Author: daniel_weck Date: 2008-03-04 20:09:10 -0800 (Tue, 04 Mar 2008) Log Message: ----------- -- Very important update -- * the self-voicing backend is now very robust, and has been tested in Release as well as Debug mode. There has been major architectural changes, but the code still contains obsolete parts that will be removed in a later commit. * fixed many memory leaks, by simplifying the design wherever possible and double-checking every possible scenario (interrupted playback threads, interlocking situations due to mixed critical sections, etc.). Please note that the self-voicing UI has been tested with and without a book open (which is important because there are potential COM conflicts with Ambulant's own DirectShow renderer and the IE browser widget). Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h branches/amis3/AmisGuiMFC2/include/gui/dialogs/SkipDialog.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequenceComponent.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/PreTranslateMessageHandler.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/dialogs/MenuVoicing.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h branches/amis3/AmisGuiMFC2/resource.h branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequenceComponent.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/PreTranslateMessageHandler.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp Modified: branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-03-05 04:09:10 UTC (rev 2390) @@ -60,6 +60,7 @@ CReBar mBasicRebar; CMenu mSavedMenu; + virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu); afx_msg void OnMenuSelect( UINT nItemID, UINT nFlags, HMENU hSysMenu ); Modified: branches/amis3/AmisGuiMFC2/include/gui/dialogs/SkipDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/SkipDialog.h 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/SkipDialog.h 2008-03-05 04:09:10 UTC (rev 2390) @@ -27,7 +27,6 @@ #include "gui/dialogs/AmisDialogBase.h" #include "../resource.h" -//#define TESTING namespace amis { @@ -36,13 +35,7 @@ namespace dialogs { -class SkipDialog : -#ifdef TESTING -public CDialog -#else -public AmisDialogBase -#endif - +class SkipDialog : public AmisDialogBase { //friend class amis::gui::spoken::SkipDialogVoicing; friend class SkipDialogVoicing; Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequenceComponent.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequenceComponent.h 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequenceComponent.h 2008-03-05 04:09:10 UTC (rev 2390) @@ -26,7 +26,6 @@ ~AudioSequenceComponent(); AudioSequenceComponent* clone(); BOOL m_isAudioClip; - bool mWasCloned; CString m_String; amis::AudioNode* m_AudioClip; Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h 2008-03-05 04:09:10 UTC (rev 2390) @@ -3,7 +3,7 @@ #pragma once -#include <process.h> +//#include <process.h> #include <stdlib.h> #ifndef TRACE @@ -35,7 +35,10 @@ static bool InstanceExists(); static AudioSequencePlayer* Instance(); void Play(AudioSequence* audioSequence, bool doNotRegisterInHistory = false); - void Stop(); + + void Stop(bool fromPlay = false); + void playNext(bool fromEndEvent); + void RepeatLast(); void TTSAudioEndNotify(); void ClipAudioEndNotify(); @@ -56,21 +59,25 @@ HANDLE m_hEventEnd; CRITICAL_SECTION m_csSequence; bool m_bAbort; + bool bIgnoreTTSEnd; +void checkEndSeq(); +void WaitForEndSeqAndRestartBook(); void waitForSequenceEnd(); //static void AppendAudioSequenceStringResource(AudioSequence* seq, int nItemID); //static void AppendAudioSequenceStringID(AudioSequence* seq, string); - 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 playPromptFromUiId(int nItemID, AudioSequence* seq = NULL); + static void playPromptFromStringId(string); + static void playPromptItemFromStringId(string); + static void playDialogInstructionsFromUiId(int nItemID); + static void playDialogTextControlsFromUiId(int nItemID); + static void playDialogControlFromUiIds(int dlgID, int ctrlId); + + static void fillSequenceContainerPromptFromId(AudioSequence* seq, string id); 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 = ""); Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/PreTranslateMessageHandler.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/PreTranslateMessageHandler.h 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/PreTranslateMessageHandler.h 2008-03-05 04:09:10 UTC (rev 2390) @@ -19,8 +19,7 @@ ~PreTranslateMessageHandler(void); CString normalizeTextEntry(CString str, int nStartChar, int nEndChar); - AudioSequence* handle(bool playNow, - AudioSequence*, + void handle( MSG* pMsg, int idUiFocus, bool ignoreSpaceKey = false, @@ -28,6 +27,8 @@ CString strTextField = CString(L""), CString strTextFieldFULL = CString(L""), bool ignoreCharKeys = false); + +void handleCommand(WPARAM cmdid); private: @@ -37,7 +38,6 @@ int m_instructionsDialogID; bool mbKeyControl; - AudioSequence* mSeq; WPARAM mLastKeyDown; //bool processGeneralDialogFeedback(bool playNow, AudioSequence*, MSG* pMsg, int idUiFocus, bool ignoreSpaceKey, bool ignoreArrowKeys, CString strTextField); Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/dialogs/MenuVoicing.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/dialogs/MenuVoicing.h 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/dialogs/MenuVoicing.h 2008-03-05 04:09:10 UTC (rev 2390) @@ -16,6 +16,8 @@ MenuVoicing(CMainFrame * frm); ~MenuVoicing(void); + AudioSequence* createSeqPrepend(UINT nFlags); + std::string computeRootMenuFromFirstChildID(unsigned int firstItemId, bool playPrompt); void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu); }; Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h 2008-03-05 04:09:10 UTC (rev 2390) @@ -37,6 +37,7 @@ #include <initguid.h> + //#include "ambulant/common/playable.h" //#include "ambulant/lib/win32/win32_error.h" //#include "ambulant/lib/logger.h" Modified: branches/amis3/AmisGuiMFC2/resource.h =================================================================== --- branches/amis3/AmisGuiMFC2/resource.h 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/resource.h 2008-03-05 04:09:10 UTC (rev 2390) @@ -2,6 +2,9 @@ // Microsoft Visual C++ generated include file. // Used by AmisGuiMFC2.rc // + +#define SELF_VOICING_PLAY_NEXT 6969 + #define IDD_ABOUTBOX 100 #define IDS_PROPSHT_CAPTION 102 #define IDD_SIDEBAR 103 Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-05 04:09:10 UTC (rev 2390) @@ -21,6 +21,8 @@ */ #include "stdafx.h" +#include <winbase.h> + #include "../resource.h" #include "AmisCore.h" #include "util/FilePathTools.h" @@ -69,7 +71,7 @@ #if _DEBUG //get Visual Leak Detector version 1.0 here: http://dmoulding.googlepages.com/downloads -//#include <vld.h> +#include <vld.h> #endif using namespace amis::gui; @@ -244,6 +246,8 @@ int CAmisApp::ExitInstance() { + TRACE("\nEXITING...\n\n"); + Preferences::Instance()->setWasExitClean(true); PreferencesFileIO prefs_io; prefs_io.writeToFile(Preferences::Instance()->getSourceUrl()->get_file(), Preferences::Instance()); @@ -259,9 +263,8 @@ amis::gui::MenuManip::Instance()->DestroyInstance(); amis::gui::MainWndParts::Instance()->DestroyInstance(); - if (AudioSequencePlayer::InstanceExists()) { AudioSequencePlayer::Instance()->DestroyInstance(); - } + DataTree::Instance()->DestroyInstance(); @@ -270,6 +273,8 @@ amis::util::Log::Instance()->endLog(); amis::util::Log::Instance()->DestroyInstance(); CoUninitialize(); + + TRACE("\nEXIT.\n\n"); return CWinApp::ExitInstance(); } @@ -326,15 +331,16 @@ new_data_reader.setAppPath(mAppPath); amis::ErrorCode did_it_work = new_data_reader.readFile(lang_xml_file.get_file(), p_new_data_tree); - if (false && did_it_work == amis::OK) + if (did_it_work == amis::OK) { //test print to an output file //p_new_data_tree->testPrint("c:\\devel\\amis\\Langpacks\\sandbox\\dataout.txt"); - /*AudioSequence* seq = new AudioSequence; - seq->append(L"AMIS"); - seq = AudioSequencePlayer::playPromptFromStringId("canceled", false, seq); - AudioSequencePlayer::Instance()->Play(seq);*/ + //AudioSequence* seq = new AudioSequence; + //seq->append(L"A"); + //seq = AudioSequencePlayer::playPromptFromStringId("canceled", false, seq); + //seq->append(CString('1')); + //AudioSequencePlayer::Instance()->Play(seq); } //if the UI file could not be read, then disable self-voicing @@ -346,6 +352,9 @@ { amis::Preferences::Instance()->setIsSelfVoicing(false); } + +//TODO: this is for testing until the alpha 2 (in alpha 1, Self-Voicing is totally disabled) +amis::Preferences::Instance()->setIsSelfVoicing(true); } const ambulant::net::url& CAmisApp::getBookURL() const @@ -651,8 +660,7 @@ amis::util::Log::Instance()->writeMessage("Showing reading options dialog (skippability)", "CAmisApp::OnSkipInfo", "AmisGuiMFC2"); amis::gui::dialogs::SkipDialog skip_dialog; skip_dialog.initializeData(amis::dtb::DtbWithHooks::Instance()->getCustomTestSet()); - //skip_dialog.do_modal(); - skip_dialog.DoModal(); + skip_dialog.do_modal(); amis::dtb::DtbWithHooks::Instance()->updateCustomTestStates(); } @@ -792,7 +800,7 @@ dialogs::PublicationSummaryDialog summary; amis::util::Log::Instance()->writeMessage("Showing publication summary dialog", "CAmisApp::OnPublicationSummary", "AmisGuiMFC2"); summary.setBook(amis::dtb::DtbWithHooks::Instance()); - summary.DoModal(); + summary.do_modal(); } void CAmisApp::OnToggleView() { @@ -845,29 +853,45 @@ return b_was_playing; } + void CAmisApp::afterModalBox(bool b_was_playing) { if (amis::Preferences::Instance()->getIsSelfVoicing() == true) { - AudioSequencePlayer::Instance()->Stop(); + //AudioSequencePlayer::Instance()->Stop(); AudioSequencePlayer::playPromptFromStringId("dialogClosed"); - AudioSequencePlayer::Instance()->waitForSequenceEnd(); + + if (b_was_playing == true) + { + + AudioSequencePlayer::Instance()->WaitForEndSeqAndRestartBook(); + } + + } else { + //resume playback if (b_was_playing == true) { - MmView *view = MainWndParts::Instance()->mpMmView; + + //MainWndParts::Instance()->mpMainFrame->PostMessage(WM_COMMAND, ID_AMBULANT_PLAY); + + MmView *view = MainWndParts::Instance()->mpMmView; view->OnFilePlay(); + } + } } void CAmisApp::generalBookErrorMsgBox(CString str) { bool b = beforeModalBox(); - AudioSequencePlayer::Instance()->Stop(); - AudioSequencePlayer::playPromptFromStringId("generalBookError"); + //AudioSequencePlayer::Instance()->Stop(); + if (amis::Preferences::Instance()->getIsSelfVoicing() == true) { + AudioSequencePlayer::playPromptFromStringId("generalBookError"); + } AfxMessageBox(str); afterModalBox(b); } Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-05 04:09:10 UTC (rev 2390) @@ -122,6 +122,15 @@ delete mCommonPreTranslateMessageHandler; delete mMenuVoicing; } +BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam) +{ + if (amis::Preferences::Instance()->getIsSelfVoicing() == true) + { + mCommonPreTranslateMessageHandler->handleCommand(wParam); + } + + return CMDIFrameWnd::OnCommand(wParam, lParam); +} int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; @@ -366,7 +375,7 @@ if (m_lastOpenPopupMenu != NULL) { m_lastOpenPopupMenu = NULL; } - TRACE("\n---------------DANOUL\n\n"); + TRACE("\n---------------DANOUL1\n\n"); TRACE(L"%d", cwnd); } } @@ -374,18 +383,18 @@ (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP)) { CWnd* cwnd = this->GetFocus(); - if (cwnd) mCommonPreTranslateMessageHandler->handle(true, NULL, pMsg, (cwnd == NULL ? -1 : cwnd->GetDlgCtrlID())); + if (cwnd) mCommonPreTranslateMessageHandler->handle(pMsg, (cwnd == NULL ? -1 : cwnd->GetDlgCtrlID())); } if (pMsg->message == WM_CANCELMODE) { - TRACE("\n---------------DANOUL\n\n"); + TRACE("\n---------------DANOUL2\n\n"); TRACE(L"%d", pMsg->message); } if (pMsg->wParam == WM_CANCELMODE) { - TRACE("\n---------------DANOUL\n\n"); + TRACE("\n---------------DANOUL3\n\n"); TRACE(L"%d", pMsg->wParam); } if (pMsg->lParam == WM_CANCELMODE) { - TRACE("\n---------------DANOUL\n\n"); + TRACE("\n---------------DANOUL4\n\n"); TRACE(L"%d", pMsg->lParam); } return CFrameWnd::PreTranslateMessage(pMsg); Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp 2008-03-05 04:09:10 UTC (rev 2390) @@ -42,7 +42,7 @@ if (cwnd) { mCommonPreTranslateMessageHandler->handle - (true, NULL, pMsg, (cwnd == NULL ? -1 : cwnd->GetDlgCtrlID())); + (pMsg, (cwnd == NULL ? -1 : cwnd->GetDlgCtrlID())); } } @@ -51,41 +51,12 @@ INT_PTR AmisDialogBase::do_modal() { - /* - if (amis::Preferences::Instance()->getIsSelfVoicing() == true) - { - AudioSequencePlayer::Instance()->Stop(); - } - - MmView *view = MainWndParts::Instance()->mpMmView; - bool b_was_playing = view->isPlaying(); - if (b_was_playing == true) - { - view->OnFilePause(); - }*/ - bool b = amis::gui::CAmisApp::beforeModalBox(); INT_PTR ret = DoModal(); theApp.afterModalBox(b); - /* - if (amis::Preferences::Instance()->getIsSelfVoicing() == true) - { - AudioSequencePlayer::Instance()->Stop(); - // DanToDo: make blocking...so that there is no overlap with the book playback. - AudioSequencePlayer::playPromptFromStringId("dialogClosed"); - - AudioSequencePlayer::Instance()->waitForSequenceEnd(); - } - - //resume playback - if (b_was_playing == true) - { - view->OnFilePlay(); - }*/ - return ret; } Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp 2008-03-05 04:09:10 UTC (rev 2390) @@ -38,12 +38,7 @@ amis::gui::dialogs::SkipDialogVoicing * mpSkipDialogVoicing = NULL; SkipDialog::SkipDialog(CWnd* pParent /*=NULL*/) - -#ifdef TESTING - : CDialog(SkipDialog::IDD) -#else : AmisDialogBase(SkipDialog::IDD) -#endif { if (Preferences::Instance()->getIsSelfVoicing() == true) @@ -68,14 +63,14 @@ { return CDialog::PreTranslateMessage(pMsg); } -#ifndef TESTING + if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) { CWnd* cwnd = this->GetFocus(); if (cwnd) { int id = cwnd->GetDlgCtrlID(); - mCommonPreTranslateMessageHandler->handle(true, NULL, pMsg, (cwnd == NULL ? -1 : id), (id == IDC_SKIPS ? true : false), (id == IDC_SKIPS ? true : false), L"", L"", (id == IDC_SKIPS ? true : false)); + mCommonPreTranslateMessageHandler->handle(pMsg, (cwnd == NULL ? -1 : id), (id == IDC_SKIPS ? true : false), (id == IDC_SKIPS ? true : false), L"", L"", (id == IDC_SKIPS ? true : false)); if (pMsg->message == WM_KEYUP) { @@ -86,7 +81,7 @@ } } } -#endif + return CDialog::PreTranslateMessage(pMsg); } @@ -178,16 +173,12 @@ void SkipDialog::OnPaint() { -#ifdef TESTING - CDialog::OnPaint(); - return; -#endif CPaintDC dc(this); // device context for painting // Let the window do its default painting... CWnd::DefWindowProc( WM_PAINT, (WPARAM)dc.m_hDC, 0 ); //call the base class on_paint function -#ifndef TESTING + on_paint(); -#endif + } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequenceComponent.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequenceComponent.cpp 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequenceComponent.cpp 2008-03-05 04:09:10 UTC (rev 2390) @@ -3,15 +3,14 @@ using namespace amis::gui::spoken; AudioSequenceComponent::AudioSequenceComponent(){ - mWasCloned = false; + } AudioSequenceComponent::~AudioSequenceComponent(){ m_String.Empty(); - if (mWasCloned) { delete m_AudioClip; - } + m_AudioClip = NULL; } @@ -20,7 +19,6 @@ 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 Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-05 04:09:10 UTC (rev 2390) @@ -19,6 +19,7 @@ #include "gui/MmView.h" //#include "ambulant/net/url.h" +#include "../../AmisGuiMFC2/resource.h" using namespace amis::tts; @@ -303,14 +304,14 @@ return; } #ifdef CCS_ACTIVE - //EnterCriticalSection(&m_csSequence); + EnterCriticalSection(&m_csSequence); #endif m_wakeUpOriginator = 3; // AUDIO CLIP END TRACE(L"\n ---- m_hEventWakeup AUDIO end\n"); SetEvent(m_hEventWakeup); #ifdef CCS_ACTIVE - //LeaveCriticalSection(&m_csSequence); + LeaveCriticalSection(&m_csSequence); #endif /* if (m_wakeUpAction != 0) { @@ -326,12 +327,27 @@ //The message callback function ... signals end of the tts static void ttsFinishedCallback() { - AudioSequencePlayer::Instance()->TTSAudioEndNotify(); + if (AudioSequencePlayer::Instance()->bIgnoreTTSEnd) { + AudioSequencePlayer::Instance()->bIgnoreTTSEnd = false; + return; + } + AudioSequencePlayer::Instance()->checkEndSeq(); + //AudioSequencePlayer::Instance()->playNext(true); + + //HWND hWnd = MainWndParts::Instance()->mpMainFrame->GetSafeHwnd(); + MainWndParts::Instance()->mpMainFrame->PostMessage(WM_COMMAND, (WPARAM)SELF_VOICING_PLAY_NEXT, (LPARAM)0); } +void AudioSequencePlayer::checkEndSeq() { + if (m_currentAudioSequence != NULL && m_currentAudioSequence->GetCount() == 0) {SetEvent(m_hEventEnd);} +} //The message callback function ... signals end of the clip static void clipFinishedCallback() { - AudioSequencePlayer::Instance()->ClipAudioEndNotify(); + //AudioSequencePlayer::Instance()->playNext(true); + AudioSequencePlayer::Instance()->checkEndSeq(); + + //HWND hWnd = MainWndParts::Instance()->mpMainFrame->GetSafeHwnd(); + MainWndParts::Instance()->mpMainFrame->PostMessage(WM_COMMAND, (WPARAM)SELF_VOICING_PLAY_NEXT, (LPARAM)0); } bool AudioSequencePlayer::InstanceExists() { @@ -355,6 +371,8 @@ m_hThread = NULL; m_bAbort = false; + bIgnoreTTSEnd = false; + m_wakeUpAction = 3; m_wakeUpOriginator = -1; m_nEndEventsToExpect = 0; @@ -365,9 +383,9 @@ InitializeCriticalSection(&m_csSequence); - m_hEventWakeup = CreateEvent(NULL, TRUE, FALSE, NULL); + /* m_hEventWakeup = CreateEvent(NULL, TRUE, FALSE, NULL); _ASSERT(m_hEventWakeup); - ResetEvent(m_hEventWakeup); + ResetEvent(m_hEventWakeup); */ m_hEventEnd = CreateEvent(NULL, TRUE, FALSE, NULL); _ASSERT(m_hEventEnd); @@ -378,15 +396,18 @@ if (m_hThread == NULL) { /* - m_hThread = (HANDLE) _beginthreadex(NULL, 0, ThreadProc, (void*) this, 0, &threadID); */ + m_hThread = (HANDLE) _beginthreadex(NULL, 0, ThreadProc, (void*) this, 0, &threadID); unsigned long threadID; m_hThread = CreateThread(NULL, 0, ThreadProc, this, 0, &threadID); _ASSERT(m_hThread != NULL); + */ } } void AudioSequencePlayer::waitForSequenceEnd() { + +TRACE("\nWAIT for SEQ end.\n"); DWORD hr = WaitForSingleObject(m_hEventEnd, 3000); switch (hr) { case WAIT_FAILED: { @@ -408,6 +429,8 @@ break;} } + +TRACE("\nWAIT for SEQ end DONE.\n"); } void AudioSequencePlayer::DestroyInstance() { @@ -424,7 +447,7 @@ AudioSequencePlayer::~AudioSequencePlayer(void) { BOOL rc; - _ASSERT(m_hThread != NULL); + //_ASSERT(m_hThread != NULL); #ifdef CCS_ACTIVE EnterCriticalSection(&m_csSequence); @@ -440,13 +463,13 @@ #endif m_wakeUpOriginator = 0; // DESTRUCTOR - rc = SetEvent(m_hEventWakeup); - _ASSERT(rc); + /* rc = SetEvent(m_hEventWakeup); + _ASSERT(rc); */ rc = SetEvent(m_hEventEnd); _ASSERT(rc); - +/* DWORD hr = WaitForSingleObject(m_hThread, 2000); switch (hr) { case WAIT_FAILED: { @@ -467,11 +490,11 @@ int i = 0; break;} - } + }*/ - CloseHandle(m_hThread); + //CloseHandle(m_hThread); - CloseHandle(m_hEventWakeup); + //CloseHandle(m_hEventWakeup); CloseHandle(m_hEventEnd); @@ -481,26 +504,41 @@ void AudioSequencePlayer::RepeatLast() { -#ifdef CCS_ACTIVE - EnterCriticalSection(&m_csSequence); -#endif //AudioSequence* audioSequence = new AudioSequence(); if (m_previousAudioSequence) { Play(m_previousAudioSequence); } -#ifdef CCS_ACTIVE - LeaveCriticalSection(&m_csSequence); -#endif } -void AudioSequencePlayer::Stop() +//unsigned __stdcall eventHandler(void* lpParam) { +DWORD __stdcall eventHandlerY(LPVOID lpParam) { +//UINT __cdecl eventHandlerX( LPVOID pParam ) { + + AudioSequencePlayer::Instance()->waitForSequenceEnd(); + //MmView *view = MainWndParts::Instance()->mpMmView; + //view->OnFilePlay(); + MainWndParts::Instance()->mpMainFrame->PostMessage(WM_COMMAND, ID_AMBULANT_PLAY); + + //_endthreadex( 0 ); + return 0; +} +void AudioSequencePlayer::WaitForEndSeqAndRestartBook() { + + unsigned long lpdwThreadID; + //hEventHandler = (HANDLE) _beginthreadex(NULL, 0, eventHandler, (void*) this, 0, &lpdwThreadID); + HANDLE xeventHandler = CreateThread(NULL, 0, &eventHandlerY, 0, 0, &lpdwThreadID); + //AfxBeginThread(eventHandlerX,0); +} + +void AudioSequencePlayer::Stop(bool fromPlay) { +SetEvent(m_hEventEnd); { #ifdef CCS_ACTIVE + if (!fromPlay) EnterCriticalSection(&m_csSequence); #endif - m_wakeUpAction = 0; m_nEndEventsToExpect = 0; @@ -513,12 +551,12 @@ bool bExpectEndEventForWakeUp = false; if (TTSPlayer::Instance()->IsSpeaking()) { - bExpectEndEventForWakeUp = true; + bIgnoreTTSEnd = true; m_nEndEventsToExpect++; //ResetEvent(pThis->m_hEventWakeup); TTSPlayer::Instance()->Stop(); //TTSPlayer::Instance()->WaitUntilDone(); - TRACE(L"####### -- STOP TTS"); + TRACE(L"\n####### ++++ STOP TTS\n"); } if (ambulantX::gui::dx::audio_playerX::Instance()->is_playing()) { @@ -528,7 +566,7 @@ ambulantX::gui::dx::audio_playerX::Instance()->stop(false); //m_wakeUpOriginator = 3; // AUDIO CLIP END //SetEvent(m_hEventWakeup); - TRACE(L"####### -- STOP AUDIO"); + TRACE(L"\n####### ++++ STOP AUDIO\n"); } if (!bExpectEndEventForWakeUp) { @@ -538,17 +576,121 @@ } #ifdef CCS_ACTIVE + if (!fromPlay) LeaveCriticalSection(&m_csSequence); #endif } } +void AudioSequencePlayer::playNext(bool fromEndEvent) { + + if (m_currentAudioSequence == NULL) return; + +#ifdef CCS_ACTIVE + if (fromEndEvent) EnterCriticalSection(&m_csSequence); +#endif + + TRACE(L"\n*** PLAY NEXT\n"); + +if (m_currentAudioSequence->GetCount() == 0) { + + delete m_currentAudioSequence; + m_currentAudioSequence = NULL; + return; + } + + AudioSequenceComponent* comp = m_currentAudioSequence->RemoveTail(); + + +if (comp->m_isAudioClip) { + + if (fromEndEvent) { + HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + if (hr == S_FALSE) CoUninitialize(); + _ASSERT(hr == S_FALSE); + } + + TRACE(L"\n============ PLAY AUDIO CLIP\n"); + playAudioPrompt(comp->m_AudioClip); + +//if (fromEndEvent) {CoUninitialize();} + + delete comp; + comp=NULL; + + } else { + CString strDebug; + strDebug.Format(_T("============ PLAY AUDIO TTS: --%s--\n"), comp->m_String); + TRACE(strDebug); + bIgnoreTTSEnd = false; + TTSPlayer::Instance()->Play(comp->m_String); + delete comp; + comp=NULL; + } +#ifdef CCS_ACTIVE + if (fromEndEvent) LeaveCriticalSection(&m_csSequence); +#endif +} + +//unsigned __stdcall eventHandler(void* lpParam) { +DWORD __stdcall eventHandlerX(LPVOID lpParam) { + + AudioSequencePlayer *pPlayer = (AudioSequencePlayer*)lpParam; + + TRACE(L"\n/// THREAD PLAY BEGIN\n"); + + pPlayer->playNext(true); + + TRACE(L"\n/// THREAD PLAY END\n"); + + //_endthreadex( 0 ); + return 0; +} + + void AudioSequencePlayer::Play(AudioSequence* audioSequence, bool doNotRegisterInHistory) { - Stop(); + if (audioSequence == NULL || audioSequence->GetCount() == 0) { + int debugHere = 0; + } { #ifdef CCS_ACTIVE EnterCriticalSection(&m_csSequence); #endif + + TRACE(L"\n####### -- PLAY SEQ\n"); + + Stop(true); + +if (!doNotRegisterInHistory) { + if (m_previousAudioSequence) { + if (audioSequence != m_previousAudioSequence) { // Not replaying + delete m_previousAudioSequence; + } + } + m_previousAudioSequence = audioSequence->clone(); + } + + + m_currentAudioSequence = audioSequence; + ResetEvent(m_hEventEnd); + + +#ifdef CCS_ACTIVE + LeaveCriticalSection(&m_csSequence); +#endif + + //HWND hWnd = MainWndParts::Instance()->mpMainFrame->GetSafeHwnd(); + MainWndParts::Instance()->mpMainFrame->PostMessage(WM_COMMAND, (WPARAM)SELF_VOICING_PLAY_NEXT, (LPARAM)0); + //playNext(false); + + /* + unsigned long lpdwThreadID; + //hEventHandler = (HANDLE) _beginthreadex(NULL, 0, eventHandler, (void*) this, 0, &lpdwThreadID); + HANDLE xeventHandler = CreateThread(NULL, 0, &eventHandlerX, this, 0, &lpdwThreadID); + */ + + return; + if (!m_bAbort) { m_wakeUpAction = 0; @@ -576,7 +718,7 @@ //ResetEvent(pThis->m_hEventWakeup); TTSPlayer::Instance()->Stop(); //TTSPlayer::Instance()->WaitUntilDone(); - TRACE(L"####### STOP TTS"); + TRACE(L"\n#######--- STOP TTS\n"); } if (ambulantX::gui::dx::audio_playerX::Instance()->is_playing()) { bExpectEndEventForWakeUp = true; @@ -585,7 +727,7 @@ ambulantX::gui::dx::audio_playerX::Instance()->stop(false); //m_wakeUpOriginator = 3; // AUDIO CLIP END //SetEvent(m_hEventWakeup); - TRACE(L"####### STOP AUDIO"); + TRACE(L"\n#######--- STOP AUDIO\n"); } ResetEvent(m_hEventEnd); @@ -672,11 +814,15 @@ //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // This works for Containers (menus). -AudioSequence* AudioSequencePlayer::playPromptFromUiId(int nItemID, bool playImmediately, AudioSequence* seq) +void AudioSequencePlayer::playPromptFromUiId(int nItemID, AudioSequence* seq) { //amis::Preferences::Instance()->mbUseTTSNotAudio == true) if (nItemID != -1) { + if (seq == NULL) { + seq = new AudioSequence; + } + amis::RecentBooks* books = theApp.getRecentBooks(); int nRecentBooks = (books ? books->getNumberOfEntries() : 0); @@ -697,9 +843,7 @@ } } - if (seq == NULL) { - seq = new AudioSequence; - } + //AppendAudioSequenceStringResource(seq, nItemID); UiItem* p_uiItem = DataTree::Instance()->findUiItemInContainers(nItemID, strCondition); @@ -777,78 +921,71 @@ } //strText.Empty(); } - if (playImmediately) AudioSequencePlayer::Instance()->Play(seq); - return seq; + + if (seq->GetCount() == 0) { + delete seq; + + } else { + + AudioSequencePlayer::Instance()->Play(seq); + } } - - return NULL; } //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // This works for Containers (menus). -AudioSequence* AudioSequencePlayer::playContainerPromptFromId(string id, bool playImmediately, AudioSequence* seq) { +void AudioSequencePlayer::fillSequenceContainerPromptFromId(AudioSequence* seq, string id) { - 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); + Label* keyboardShortcutAccelerator = p_container->getKeyboardAccelerator(); 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) +void AudioSequencePlayer::playPromptFromStringId(string promptId) { + - 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); + AudioSequence * seq = new AudioSequence; + fillSequencePrompt(seq, p_prompt_, NULL); + if (seq->GetCount() == 0) { + delete seq; + } else { + AudioSequencePlayer::Instance()->Play(seq); + } } - - if (playImmediately) AudioSequencePlayer::Instance()->Play(seq); - return seq; } //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // This works for Prompts. -AudioSequence* AudioSequencePlayer::playPromptItemFromStringId(string promptId, bool playImmediately, AudioSequence* seq, PromptResolver* pResolver) +void AudioSequencePlayer::playPromptItemFromStringId(string promptId) { - if (seq == NULL) { - seq = new AudioSequence; - } + + AudioSequence * seq = new AudioSequence; + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem(promptId); @@ -856,22 +993,17 @@ { fillSequenceContents(seq, p_prompt_); } - if (playImmediately) AudioSequencePlayer::Instance()->Play(seq); - return seq; + AudioSequencePlayer::Instance()->Play(seq); } //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // This works for Dialogs, plays the instructions. -AudioSequence* AudioSequencePlayer::playDialogInstructionsFromUiId(int nItemID, bool playImmediately, AudioSequence* seq) { +void AudioSequencePlayer::playDialogInstructionsFromUiId(int nItemID) { if (nItemID != -1) { - - if (seq == NULL) { - seq = new AudioSequence; - } - //AppendAudioSequenceStringResource(seq, nItemID); + AudioSequence * seq = new AudioSequence; Dialog* p_dialog = DataTree::Instance()->findDialog(nItemID); if (p_dialog != NULL) { @@ -880,29 +1012,29 @@ fillSequencePrompt(seq, prompt); } } - if (playImmediately) AudioSequencePlayer::Instance()->Play(seq, true); - return seq; + if (seq->GetCount() == 0) { + delete seq; + } + else { + AudioSequencePlayer::Instance()->Play(seq, true); + } } - return NULL; + } //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // This works for Dialogs -AudioSequence* AudioSequencePlayer::playDialogTextControlsFromUiId(int nItemID, bool playImmediately, AudioSequence* seq, string switchCondition) { +void AudioSequencePlayer::playDialogTextControlsFromUiId(int nItemID) { if (nItemID != -1) { - - if (seq == NULL) { - seq = new AudioSequence; - } - //AppendAudioSequenceStringResource(seq, nItemID); - + AudioSequence * seq = new AudioSequence; + Dialog* p_dialog = DataTree::Instance()->findDialog(nItemID); if (p_dialog != NULL) { fillSequenceCaptionAndDescription(seq, p_dialog); - fillSequenceSwitch(seq, p_dialog, switchCondition); + fillSequenceSwitch(seq, p_dialog); int count = p_dialog->getNumChildControls(); for (int i = 0 ; i < count; i++) { @@ -915,16 +1047,15 @@ } } - if (playImmediately) AudioSequencePlayer::Instance()->Play(seq); - return seq; + if (seq->GetCount()==0){delete seq;return;}else{ AudioSequencePlayer::Instance()->Play(seq);} + } - return NULL; } //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // This works for Dialogs -AudioSequence* AudioSequencePlayer::playDialogControlFromUiIds(int dlgID, int ctrlId, bool playImmediately, AudioSequence* seq, string switchCondition) { +void AudioSequencePlayer::playDialogControlFromUiIds(int dlgID, int ctrlId) { if ( (dlgID != -1 && ctrlId != -1) @@ -932,9 +1063,8 @@ ) { - if (seq == NULL) { - seq = new AudioSequence; - } + AudioSequence * seq = new AudioSequence; + if (dlgID == -1) { if (ctrlId == IDCANCEL) { @@ -996,10 +1126,15 @@ } } - if (playImmediately) AudioSequencePlayer::Instance()->Play(seq); - return seq; + if (seq != NULL && seq->GetCount() == 0) { + delete seq; + + } else { + + AudioSequencePlayer::Instance()->Play(seq); + } + } - return NULL; } //////////////////////////////////////////////////////////////////////////////////// @@ -1083,7 +1218,7 @@ amis::AudioNode* audio = pair->getAudio(); if (!Preferences::Instance()->getUseTTSNotAudio() && audio != NULL && audio->getSrc().length() != 0) { - seq->append(audio); + seq->append(audio->clone()); } else { @@ -1114,7 +1249,7 @@ amis::AudioNode* audio = pair->getAudio(); if (!Preferences::Instance()->getUseTTSNotAudio() && audio != NULL && audio->getSrc().length() != 0) { - seq->append(audio); + seq->append(audio->clone()); } else { @@ -1138,7 +1273,7 @@ amis::AudioNode* audio = pair->getAudio(); if (!Preferences::Instance()->getUseTTSNotAudio() && audio != NULL && audio->getSrc().length() != 0) { - seq->append(audio); + seq->append(audio->clone()); } else { @@ -1165,7 +1300,7 @@ amis::AudioNode* audio = pair->getAudio(); if (!Preferences::Instance()->getUseTTSNotAudio() && audio != NULL && audio->getSrc().length() != 0) { - seq->append(audio); + seq->append(audio->clone()); } else { Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/PreTranslateMessageHandler.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/PreTranslateMessageHandler.cpp 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/PreTranslateMessageHandler.cpp 2008-03-05 04:09:10 UTC (rev 2390) @@ -1,5 +1,7 @@ #include "gui/self-voicing/pretranslatemessagehandler.h" + +#include "../../AmisGuiMFC2/resource.h" //#include "gui/AmisApp.h" PreTranslateMessageHandler::PreTranslateMessageHandler(int idUiDialog) @@ -7,7 +9,6 @@ m_instructionsDialogID = idUiDialog; mbKeyControl = false; mLastKeyDown = -1; - mSeq = NULL; } PreTranslateMessageHandler::~PreTranslateMessageHandler(void) @@ -20,230 +21,223 @@ 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 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"; - } else if (!ignoreSpaceKey && cstr == L" ") { - cstr = L"space"; - }*/ - } - } - return 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 + return CString((char)ch); + /*if (cstr == L".") { + cstr = L"dot"; + } else if (cstr == L"-") { + cstr = L"minus"; + } else if (!ignoreSpaceKey && cstr == L" ") { + cstr = L"space"; + }*/ + } + } + return L""; } CString PreTranslateMessageHandler::convertKeystrokeToSpeakableString(MSG* pMsg, bool ignoreSpaceKey, bool ignoreArrowKeys, bool ignoreCharKeys) { - - CString cstr; - WPARAM ch = pMsg->wParam; /*if (pMsg->message == WM_CHAR) { - cstr = convertKeystrokeToSpeakableString(ch, ignoreSpaceKey, ignoreArrowKeys, ignoreCharKeys); + cstr = convertKeystrokeToSpeakableString(ch, ignoreSpaceKey, ignoreArrowKeys, ignoreCharKeys); } else*/ if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) { - if (ch == VK_BACK) - { - cstr = L"backspace"; - } else if (ch == VK_CONTROL) - { - cstr = L"control"; - } else if (ch == VK_SHIFT) - { - cstr = L"shift"; - } else if (ch == VK_LEFT) - { - if (!ignoreArrowKeys) cstr = L"left"; - } else if (ch == VK_UP) - { - if (!ignoreArrowKeys) cstr = L"up"; - } else if (ch == VK_RIGHT) - { - if (!ignoreArrowKeys) cstr = L"right"; - } else if (ch == VK_DOWN) - { - if (!ignoreArrowKeys) cstr = L"down"; - } else if (ch == VK_ESCAPE) - { - cstr = L"escape"; - } else if (ch == VK_HOME) - { - if (!ignoreArrowKeys) cstr = L"home"; - } else if (ch == VK_END) - { - if (!ignoreArrowKeys) cstr = L"end"; - } else if (ch == VK_RETURN) - { - cstr = L"return"; - } - else if (ch == VK_TAB) - { - cstr = L"tab"; - } - else if (ch == VK_SPACE) - { - if (!ignoreSpaceKey) cstr = L"space"; - } - else if (ch == VK_DELETE) - { - cstr = L"delete"; - } - else if (ch == VK_F1) - { - cstr = L"f one"; - } - else if (ch == VK_F2) - { - cstr = L"f two"; - } - else if (ch == VK_F3) - { - cstr = L"f three"; - } - else if (ch == VK_F4) - { - cstr = L"f four"; - } - else if (ch == VK_F5) - { - cstr = L"f five"; - } - else if (ch == VK_F6) - { - cstr = L"f six"; - } - else if (ch == VK_F7) - { - cstr = L"f seven"; - } - else if (ch == VK_F8) - { - cstr = L"f eight"; - } - else if (ch == VK_F9) - { - cstr = L"f nine"; - } - else if (ch == VK_F10) - { - cstr = L"f ten"; - } - else if (ch == VK_F11) - { - cstr = L"f eleven"; - } - else if (ch == VK_F12) - { - cstr = L"f twelve"; - } else { - cstr = convertKeystrokeToSpeakableString(ch, ignoreSpaceKey, ignoreArrowKeys, ignoreCharKeys); - } + if (ch == VK_BACK) + { + return L"backspace"; + } else if (ch == VK_CONTROL) + { + return L"control"; + } else if (ch == VK_SHIFT) + { + return L"shift"; + } else if (ch == VK_LEFT) + { + if (!ignoreArrowKeys) return L"left"; + } else if (ch == VK_UP) + { + if (!ignoreArrowKeys) return L"up"; + } else if (ch == VK_RIGHT) + { + if (!ignoreArrowKeys) return L"right"; + } else if (ch == VK_DOWN) + { + if (!ignoreArrowKeys) return L"down"; + } else if (ch == VK_ESCAPE) + { + return L"escape"; + } else if (ch == VK_HOME) + { + if (!ignoreArrowKeys) return L"home"; + } else if (ch == VK_END) + { + if (!ignoreArrowKeys) return L"end"; + } else if (ch == VK_RETURN) + { + return L"return"; + } + else if (ch == VK_TAB) + { + return L"tab"; + } + else if (ch == VK_SPACE) + { + if (!ignoreSpaceKey) return L"space"; + } + else if (ch == VK_DELETE) + { + return L"delete"; + } + else if (ch == VK_F1) + { + return L"f one"; + } + else if (ch == VK_F2) + { + return L"f two"; + } + else if (ch == VK_F3) + { + return L"f three"; + } + else if (ch == VK_F4) + { + return L"f four"; + } + else if (ch == VK_F5) + { + return L"f five"; + } + else if (ch == VK_F6) + { + return L"f six"; + } + else if (ch == VK_F7) + { + return L"f seven"; + } + else if (ch == VK_F8) + { + return L"f eight"; + } + else if (ch == VK_F9) + { + return L"f nine"; + } + else if (ch == VK_F10) + { + return L"f ten"; + } + else if (ch == VK_F11) + { + return L"f eleven"; + } + else if (ch == VK_F12) + { + return L"f twelve"; + } else { + return convertKeystrokeToSpeakableString(ch, ignoreSpaceKey, ignoreArrowKeys, ignoreCharKeys); + } } - return cstr; + return L""; } -AudioSequence* PreTranslateMessageHandler::handle(bool playNow, AudioSequence* seq, MSG* pMsg, int idUiFocus, bool ignoreSpaceKey, bool ignoreArrowKeys, CString strTextField, CString strTextFieldFULL, bool ignoreCharKeys) { -//NOTE: playNow usually true and seq usually NULL +void PreTranslateMessageHandler::handleCommand(WPARAM cmdid) { + if (SELF_VOICING_PLAY_NEXT == cmdid) { + AudioSequencePlayer::Instance()->playNext(true); + } +} +void PreTranslateMessageHandler::handle(MSG* pMsg, int idUiFocus, bool ignoreSpaceKey, bool ignoreArrowKeys, CString strTextField, CString strTextFieldFULL, bool ignoreCharKeys) { if (pMsg->message == WM_KEYDOWN) { if (mLastKeyDown == pMsg->wParam) { //Prevents repeat - if (seq == NULL) { - seq = new AudioSequence(); - } - return seq; + return; } mLastKeyDown = pMsg->wParam; - TRACE(L"PreTranslateMessageHandler::handle KEY DOWN"); - if (seq == NULL) { - if (mSeq == NULL) { - seq = new AudioSequence(); - mSeq = seq; - } else { - seq = mSeq; - } - } if (pMsg->wParam == VK_CONTROL) { mbKeyControl = true; } - - CString cstr = convertKeystrokeToSpeakableString(pMsg, ignoreSpaceKey, ignoreArrowKeys, ignoreCharKeys); - + + /* + CString cstr = convertKeystrokeToSpeakableString(pMsg, ignoreSpaceKey, ignoreArrowKeys, ignoreCharKeys); + if (!cstr.IsEmpty()) { - + TRACE(cstr); - seq->append(cstr); - if (playNow) { - //mSeq = NULL; - //AudioSequencePlayer::Instance()->Play(seq, true); - } + if (mSeq == NULL) { + mSeq = new AudioSequence(); + mSeq->append(cstr); } + */ + return; + + //mSeq = NULL; + //AudioSequencePlayer::Instance()->Play(seq, true); + + } else if (pMsg->message == WM_KEYUP) { @@ -252,158 +246,131 @@ mLastKeyDown = -1; wasSameKey = true; } - if (pMsg->wParam == VK_CONTROL) { - if (mSeq != NULL) { - delete mSeq; - mSeq = NULL; - } if (mbKeyControl && wasSameKey) { //if (seq != NULL && !(seq->IsEmpty()) && playNow) AudioSequencePlayer::Instance()->Play(seq, true); //else AudioSequencePlayer::Instance()->Stop(); AudioSequencePlayer::Instance()->Stop(); } mbKeyControl = false; + return; } else if(pMsg->wParam == 'I' && mbKeyControl == true) { - if (mSeq != NULL) { - delete mSeq; - mSeq = NULL; - } - if (seq == NULL) { - seq = new AudioSequence(); - } - mbKeyControl = false; //repeat the instructions - AudioSequencePlayer::Instance()->playDialogInstructionsFromUiId(m_instructionsDialogID, playNow, seq); + AudioSequencePlayer::Instance()->playDialogInstructionsFromUiId(m_instructionsDialogID); + return; } else if(pMsg->wParam == 'R' && mbKeyControl == true) { - if (mSeq != NULL) { - delete mSeq; - mSeq = NULL; - } mbKeyControl = false; AudioSequencePlayer::Instance()->RepeatLast(); + return; } else if(pMsg->wParam == 'T' && mbKeyControl == true && !strTextFieldFULL.IsEmpty()) { - if (mSeq != NULL) { - delete mSeq; - mSeq = NULL; + AudioSequence * mSeq = new AudioSequence(); + + mbKeyControl = false; + if (strTextFieldFULL.GetLength() == 1) { + strTextFieldFULL = convertKeystrokeToSpeakableString(strTextFieldFULL.GetAt(0)); } - if (seq == NULL) { - seq = new AudioSequence(); - } - mbKeyControl = false; - if (strTextFieldFULL.GetLength() == 1) { - strTextFieldFULL = convertKeystrokeToSpeakableString(strTextFieldFULL.GetAt(0)); - } - seq->append(strTextFieldFULL); - if (playNow) AudioSequencePlayer::Instance()->Play(seq); + mSeq->append(strTextFieldFULL); + AudioSequencePlayer::Instance()->Play(mSeq); + return; } else { - - if (seq == NULL) { - if (mSeq == NULL) { - seq = new AudioSequence(); - //mSeq = seq; - } else { - seq = mSeq; - mSeq = NULL; - } - } else { - if (mSeq != NULL) { - delete mSeq; - mSeq = NULL; - } - } - - if (pMsg->wParam == VK_TAB || (!ignoreArrowKeys && (pMsg->wParam == VK_HOME || pMsg->wParam == VK_END || pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN || pMsg->wParam == VK_LEFT || pMsg->wParam == VK_RIGHT))) - { - /* - if (pMsg->wParam == VK_TAB) { - seq->append(L"tab"); - } else if (pMsg->wParam == VK_UP) { - seq->append(L"up"); - } else if (pMsg->wParam == VK_DOWN) { - seq->append(L"down"); - } else if (pMsg->wParam == VK_LEFT) { - seq->append(L"left"); - } else if (pMsg->wParam == VK_RIGHT) { - seq->append(L"right"); - } - */ - if (idUiFocus == IDOK) + if (pMsg->wParam == VK_TAB || (!ignoreArrowKeys && (pMsg->wParam == VK_HOME || pMsg->wParam == VK_END || pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN || pMsg->wParam == VK_LEFT || pMsg->wParam == VK_RIGHT))) { - AudioSequencePlayer::Instance()->playDialogControlFromUiIds(m_instructionsDialogID, IDOK, playNow, seq); - } - else if (idUiFocus == IDCANCEL) - { - AudioSequencePlayer::Instance()->playDialogControlFromUiIds(m_instructionsDialogID, IDCANCEL, playNow, seq); - } else if (idUiFocus >= 0) { + if (idUiFocus == IDOK) + { + AudioSequencePlayer::Instance()->playDialogControlFromUiIds(m_instructionsDialogID, IDOK); + return; + } + else if (idUiFocus == IDCANCEL) + { + AudioSequencePlayer::Instance()->playDialogControlFromUiIds(m_instructionsDialogID, IDCANCEL); + return; + + } else if (idUiFocus >= 0) { + + /* + AudioSequence * mSeq = new AudioSequence(); + if (! strTextField.IsEmpty()) { + if (strTextField.GetLength() == 1) { + strTextField = convertKeystrokeToSpeakableString(strTextField.GetAt(0)); + } + mSeq->append(strTextField); + //if (playNow) AudioSequencePlayer::Instance()->Play(seq); + }*/ + AudioSequencePlayer::Instance()->playDialogControlFromUiIds(m_instructionsDialogID, idUiFocus); + return; + } + + } else { + + AudioSequence * mSeq = new AudioSequence(); + if (! strTextField.IsEmpty()) { if (strTextField.GetLength() == 1) { strTextField = convertKeystrokeToSpeakableString(strTextField.GetAt(0)); } - seq->append(strTextField); + mSeq->append(strTextField); //if (playNow) AudioSequencePlayer::Instance()->Play(seq); } - AudioSequencePlayer::Instance()->playDialogControlFromUiIds(m_instructionsDialogID, idUiFocus, playNow, seq); - } - } else { - if (! strTextField.IsEmpty()) { - if (strTextField.GetLength() == 1) { - strTextField = convertKeystrokeToSpeakableString(strTextField.GetAt(0)); + if (!(mSeq->IsEmpty()) && wasSameKey) { + AudioSequencePlayer::Instance()->Play(mSeq, true); + + return; + } else { + delete mSeq; } - seq->append(strTextField); - //if (playNow) AudioSequencePlayer::Instance()->Play(seq); } - if (seq != NULL && !(seq->IsEmpty()) && playNow && wasSameKey) { - AudioSequencePlayer::Instance()->Play(seq, true); - } } - } } //bool doProcessKeyFeedback = processGeneralDialogFeedback(playNow, seq ,pMsg, idUiFocus, ignoreSpaceKey, ignoreArrowKeys, strTextField); //if (doProcessKeyFeedback) processGeneralKeyPressFeedback(playNow, seq, pMsg, ignoreSpaceKey, ignoreArrowKeys); - return seq; + /* + if (mSeq != NULL && mSeq->GetCount() == 0) + delete mSeq; + mSeq=NULL; + } + */ } /* bool PreTranslateMessageHandler::processGeneralDialogFeedback(bool playNow, AudioSequence* seq, MSG* pMsg, int idUiFocus, bool ignoreSpaceKey, bool ignoreArrowKeys, CString strTextField) { - - if (seq == NULL) { - seq = new AudioSequence(); - } - if (pMsg->message == WM_KEYDOWN) - { - } - else if (pMsg->message == WM_KEYUP) - { +if (seq == NULL) { +seq = new AudioSequence(); +} - } +if (pMsg->message == WM_KEYDOWN) +{ +} +else if (pMsg->message == WM_KEYUP) +{ - return true; } +return true; +} + void PreTranslateMessageHandler::processGeneralKeyPressFeedback(bool playNow, AudioSequence* seq, MSG* pMsg, bool ignoreSpaceKey, bool ignoreArrowKeys) { - - if (seq == NULL) { - seq = new AudioSequence(); - } - if (pMsg->message == WM_KEYDOWN) - { - } + +if (seq == NULL) { +seq = new AudioSequence(); } +if (pMsg->message == WM_KEYDOWN) +{ +} +} */ \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp 2008-03-05 00:00:57 UTC (rev 2389) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp 2008-03-05 04:09:10 UTC (rev 2390) @@ -84,8 +84,10 @@ if (!str_id.empty()) { if (playPrompt) { - AudioSequence* seq = AudioSequencePlayer::playContainerPromptFromId(str_id, false); + AudioSequence* seq = new AudioSequence(); + AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, str_id); + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); if (p_prompt_ != NULL) @@ -96,13 +98,32 @@ seq->append(_T("menu")); } - AudioSequencePlayer::Instance()->Play(seq); + if (seq->GetCount() == 0) { + delete seq; + } else { + AudioSequencePlayer::Instance()->Play(seq); + } } } return str_id; } + AudioSequence* MenuVoicing::createSeqPrepend(UINT nFlags) { + + AudioSequence* seq = new AudioSequence(); + + if ( nFlags & MF_GRAYED ) + { + PromptItem* promptNotAvailable = DataTree::Instance()->findPromptItem("not_available"); + if (promptNotAvailable != NULL) + { + + AudioSequencePlayer::fillSequenceContents(seq, promptNotAvailable); + } + } + return seq; + } void MenuVoicing::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu) { @@ -167,11 +188,6 @@ } - if (nItemID) { - // - - CString s; - } //don't read separators if (nFlags & MF_SEPARATOR) { @@ -183,18 +199,6 @@ string prompt; - AudioSequence* seq = NULL; - seq = new AudioSequence(); - - if ( nFlags & MF_GRAYED ) - { - PromptItem* promptNotAvailable = DataTree::Instance()->findPromptItem("not_available"); - if (promptNotAvailable != NULL) - { - - AudioSequencePlayer::fillSequenceContents(seq, promptNotAvailable); - } - } if ( nFlags & MF_POPUP ) { if ( nFlags & MF_BYPOSITION ) @@ -215,8 +219,11 @@ TRACE(s); TRACE(prompt.c_str()); + + AudioSequence* seq = createSeqPrepend(nFlags); + if (prompt.compare("file") == 0 || prompt.compare("recentBooksList") == 0) { - seq = AudioSequencePlayer::playContainerPromptFromId("recentBooksList", false, seq); + AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "recentBooksList"); PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); @@ -228,10 +235,16 @@ seq->append(_T("menu")); } - AudioSequencePlayer::Instance()->Play(seq); + if (seq->GetCount() == 0) { + delete seq; + } else { + AudioSequencePlayer::Instance()->Play(seq); + } + return; } else if (prompt.compare("navigate") == 0 || prompt.compare("sectiondepth") == 0) { - seq = AudioSequencePlayer::playContainerPromptFromId("sectiondepth", false, seq); + AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "sectiondepth"); + PromptItem* p_prompt_ = DataTree::Instance()->findPromptItem("menu"); if (p_prompt_ != NULL) @@ -241,9 +254,15 @@ else { seq->append(_T("menu")); } - AudioSequencePlayer::Instance()->Play(seq); + + if (seq->GetCount() == 0) { + delete seq; + } else { + AudioSequencePlayer::Instance()->Play(seq); + } + return; } else { - int i = 0; // NOP, for breakpoint + delete seq; } } else if ((nItemID >=0 && nItemID <=6) && (mFrm->m_lastOpenPopupMenu == NULL)) { //TODO: Yuuk ! UGLY ! This is only a temporary workaround ! //(nFlags & MF_GRAYED) @@ -251,27 +270,29 @@ TRACE(s); + AudioSequence* seq = createSeqPrepend(nFlags); + switch (nItemID) { case 0: - seq = AudioSequencePlayer::playContainerPromptFromId("file", false, seq); + AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "file"); break; case 1: - seq = AudioSequencePlayer::playContainerPromptFromId("view", false, seq); + AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "view"); break; case 2: - seq = AudioSequencePlayer::playContainerPromptFromId("play", false, seq); + AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "play"); break; case 3: - seq = AudioSequencePlayer::playContainerPromptFromId("navigate", false, seq); + AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "navigate"); break; case 4: - seq = AudioSequencePlayer::playContainerPromptFromId("bookmarks", false, seq); + AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "bookmarks"); break; case 5: - seq = AudioSequencePlayer::playContainerPromptFromId("info", false, seq); + AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "info"); break; case 6: - seq = AudioSequencePlayer::playContainerPromptFromId("help", false, seq); + AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "help"); break; //default: seq = new AudioSequence(); } @@ -282,14 +303,17 @@ AudioSequencePlayer::fillSequenceContents(seq, p_prompt_); } else { - if (seq != NULL) { - seq->append(_T("menu")); - } + seq->append(_T("menu")); + } - if (seq != NULL) { + if (seq->GetCount() == 0) { + delete seq; + } else { AudioSequencePlayer::Instance()->Play(seq); } + return; + } } else @@ -310,9 +334,15 @@ //DanTodo: surely, there must be a way to get a title instead of rendering the URL with TTS ??! (see bookmark methd commented below) string str = p_entry->mPath.get_url(); + + AudioSequence* seq = createSeqPrepend(nFlags); + seq->append(A2T(str.c_str())); + AudioSequencePlayer::Instance()->Play(seq); + return; + //CString cstr_f... [truncated message content] |
From: <mar...@us...> - 2008-03-05 00:00:59
|
Revision: 2389 http://amis.svn.sourceforge.net/amis/?rev=2389&view=rev Author: marisademeglio Date: 2008-03-04 16:00:57 -0800 (Tue, 04 Mar 2008) Log Message: ----------- HTML view resizing a little better but not much. MmView::OnSize isn't getting called! Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h branches/amis3/AmisGuiMFC2/include/gui/MmView.h branches/amis3/AmisGuiMFC2/src/gui/ChildFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp Modified: branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-03-04 05:15:06 UTC (rev 2388) +++ branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-03-05 00:00:57 UTC (rev 2389) @@ -84,10 +84,11 @@ afx_msg void OnUpdateCmdUiSmallerFont(CCmdUI*); DECLARE_MESSAGE_MAP() public: - afx_msg void OnSize(UINT nType, int cx, int cy); void updateToolbarState(toolbar::Toolbar*); private: void updateUiCommandState(CCmdUI*, bool); +public: + virtual void RecalcLayout(BOOL bNotify = TRUE); }; } } Modified: branches/amis3/AmisGuiMFC2/include/gui/MmView.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MmView.h 2008-03-04 05:15:06 UTC (rev 2388) +++ branches/amis3/AmisGuiMFC2/include/gui/MmView.h 2008-03-05 00:00:57 UTC (rev 2389) @@ -50,7 +50,6 @@ void SetMMDocument(LPCTSTR lpszPathName, bool autostart); void skipOptionsChanged(); void ScheduleReplaceDoc(std::string& url); - //bool LocateWelcomeDoc(LPCTSTR rpath); ambulant::net::datasource_factory *getDatasourceFactory(); bool expectingAudio() const { return m_expecting_audio; } UINT_PTR m_timer_id; @@ -100,26 +99,12 @@ 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 LRESULT OnSetClientRect(WPARAM wParam, LPARAM lParam); - //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); -#if 0 - afx_msg void OnViewAutoplay(); - void OnUpdateViewAutoplay(CCmdUI *pCmdUI); -#endif 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 LRESULT OnReplaceDoc(WPARAM wParam, LPARAM lParam); + afx_msg void OnSize(UINT nType, int cx, int cy); // Daisy local navigation support void prevPhrase(); Modified: branches/amis3/AmisGuiMFC2/src/gui/ChildFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/ChildFrm.cpp 2008-03-04 05:15:06 UTC (rev 2388) +++ branches/amis3/AmisGuiMFC2/src/gui/ChildFrm.cpp 2008-03-05 00:00:57 UTC (rev 2389) @@ -73,12 +73,12 @@ int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1) return -1; - this->ShowWindow(SW_SHOWMAXIMIZED); + ShowWindow(SW_SHOWMAXIMIZED); return 0; } void CChildFrame::OnClose() { - this->ShowWindow(SW_MINIMIZE); - // CMDIChildWnd::OnClose(); + ShowWindow(SW_MINIMIZE); + //CMDIChildWnd::OnClose(); } Modified: branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2008-03-04 05:15:06 UTC (rev 2388) +++ branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2008-03-05 00:00:57 UTC (rev 2389) @@ -151,9 +151,6 @@ void CAmisHtmlView::OnInitialUpdate() { this->SetSilent(TRUE); - - //code to load 'amis.html' page was deleted because - //the app loads a book on startup } void CAmisHtmlView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) @@ -334,7 +331,8 @@ CAmisHtmlView::smilPlayerDeleted() { #ifdef HTML_LOAD_AMBULANT_PDTB - if (mpLoaderBridge) { + if (mpLoaderBridge) + { mpLoaderBridge->Release(); mpLoaderBridge = NULL; } @@ -357,8 +355,7 @@ { // If we are already displaying this document return false. CString urlstr(url); - if (mNavStringUrl.Compare(urlstr) == 0) - return false; + if (mNavStringUrl.Compare(urlstr) == 0) return false; HRESULT res; // Check that we are indeed in threading mode #ifdef _DEBUG @@ -368,11 +365,11 @@ #endif // First we need to get a pointer to the DOM IDispatch *pDisp = GetHtmlDocument(); - if (pDisp == NULL) - return false; + if (pDisp == NULL) return false; IHTMLDocument2 *pDoc; res = pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pDoc); - if (!SUCCEEDED(res)) { + if (!SUCCEEDED(res)) + { // XXXJack leaks? return false; } @@ -386,17 +383,17 @@ HRESULT res; // Check that we are indeed in threading mode #ifdef _DEBUG - HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if (hr == S_FALSE) CoUninitialize(); assert(hr == S_FALSE); #endif // First we need to get a pointer to the DOM IDispatch *pDisp = GetHtmlDocument(); - if (pDisp == NULL) - return false; + if (pDisp == NULL) return false; IHTMLDocument2 *pDoc; res = pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pDoc); - if (!SUCCEEDED(res)) { + if (!SUCCEEDED(res)) + { // XXXJack leaks? return false; } @@ -406,35 +403,20 @@ CComBSTR bUrl2(""); IHTMLLocation *pLocation; res = pDoc->get_location(&pLocation); - if (!SUCCEEDED(res)) { - return false; - } -#if 0 - res = pDoc->put_URL(bUrl); - if (!SUCCEEDED(res)) { - return false; - } -#endif + if (!SUCCEEDED(res)) return false; res = pLocation->get_href(&bUrl2); - if (!SUCCEEDED(res)) { - return false; - } + if (!SUCCEEDED(res)) return false; + // Now we open the document for writing, passing in the URL CComVariant dummy; -// res = pDoc->open(bUrl, CComVariant("_self"), dummy, dummy, NULL); res = pDoc->open((BSTR)"", dummy, dummy, dummy, NULL); - if (!SUCCEEDED(res)) { + if (!SUCCEEDED(res)) + { // XXXJack leaks return false; } -// res = pLocation->put_href(bUrl); -// if (!SUCCEEDED(res)) { -// return false; -// } res = pLocation->get_href(&bUrl2); - if (!SUCCEEDED(res)) { - return false; - } + if (!SUCCEEDED(res)) return false; // Now store the HTML data in some funky data structure size_t doclen = strlen(document); @@ -443,14 +425,16 @@ SAFEARRAYBOUND bounds = {1, 0}; SAFEARRAY *pDataArray = SafeArrayCreate(VT_VARIANT, 1, &bounds); - if (!pDataArray) { + if (!pDataArray) + { // XXXJack leaks return false; } VARIANT *vDataArrayAccess; res = SafeArrayAccessData(pDataArray, (void**)&vDataArrayAccess); - if (!SUCCEEDED(res)) { + if (!SUCCEEDED(res)) + { // XXXJack leaks return false; } @@ -459,12 +443,14 @@ // And finally push the data into the DOM and render it res = pDoc->write(pDataArray); - if (!SUCCEEDED(res)) { + if (!SUCCEEDED(res)) + { // XXXJack leaks return false; } res = pDoc->close(); - if (!SUCCEEDED(res)) { + if (!SUCCEEDED(res)) + { // XXXJack leaks return false; } Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-04 05:15:06 UTC (rev 2388) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-05 00:00:57 UTC (rev 2389) @@ -553,18 +553,6 @@ updateUiCommandState(pCmdUi, false); } -//TODO: this doesn't work -void amis::gui::CMainFrame::OnSize(UINT nType, int cx, int cy) -{ - CMDIFrameWnd::OnSize(nType, cx, cy); - if (MainWndParts::Instance()->mpHtmlView != NULL) - { - CRect rect; - GetWindowRect(rect); - MainWndParts::Instance()->mpHtmlView->RedrawWindow(rect); - } -} - //the ON_UPDATE_COMMAND_UI messages end up here because it takes care of the toolbars too void amis::gui::CMainFrame::updateUiCommandState(CCmdUI* pCmdUi, bool value) { @@ -621,4 +609,18 @@ pToolbar->enable(ID_AMIS_DECREASE_SECTION_DEPTH, theApp.isBookOpen()); pToolbar->enable(ID_AMIS_INCREASE_VOLUME, theApp.isBookOpen()); pToolbar->enable(ID_AMIS_DECREASE_VOLUME, theApp.isBookOpen()); -} \ No newline at end of file +} +void amis::gui::CMainFrame::RecalcLayout(BOOL bNotify) +{ + if (MainWndParts::Instance()->mpBasicToolbar == NULL) return; + //center the buttons on a basic toolbar + CRect rect; + GetClientRect(&rect); + mBasicToolbar.SetIndent ( + (rect.Width() + - (mBasicToolbar.GetButtonCount() * LOWORD(mBasicToolbar.GetButtonSize())) + ) + / 2); + + CMDIFrameWnd::RecalcLayout(bNotify); +} Modified: branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2008-03-04 05:15:06 UTC (rev 2388) +++ branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2008-03-05 00:00:57 UTC (rev 2389) @@ -160,8 +160,12 @@ SIZE my_player_callbacks::get_default_size() { SIZE size; - size.cx = 800; - size.cy = 600; + //size.cx = 800; + //size.cy = 600; + CRect rect; + MainWndParts::Instance()->mpMmView->GetClientRect(&rect); + size.cx = rect.Width(); + size.cy = rect.Height(); return size; } @@ -516,56 +520,7 @@ { if (player) player->on_focus_activate(); } -/* -void MmView::OnViewSource() -{ - USES_CONVERSION; - CString cmd = TEXT("Notepad.exe "); - std::string ustr = T2CA(LPCTSTR(m_curDocFilename)); - net::url u = net::url::from_url(ustr); - assert(0); // XXXX Need to find out ustr format (url or filename) - assert(u.is_local_file()); - // XXXX Also check OnUpdateViewSource - cmd += u.get_file().c_str(); // XXXX Incorrect - WinExec(T2CA(cmd), SW_SHOW); -} -*/ -/* -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() -{ -#ifdef WITHOUT_LOG_WINDOW - // Logging to file: open the file in notepad. - TCHAR buf[_MAX_PATH]; - GetModuleFileName(NULL, buf, _MAX_PATH); - TCHAR *p1 = text_strrchr(buf,TCHAR('\\')); - if(p1 != NULL) *p1= TCHAR('\0'); - text_strcat(buf, TEXT("\\")); - text_strcat(buf, log_name); - CString cmd = TEXT("Notepad.exe "); - cmd += buf; - WinExec((LPCSTR)(LPCTSTR)cmd, SW_SHOW); -#else - // Logging to a window: show the window. - if (m_logwindow == NULL) m_logwindow = CLogWindow::GetLogWindowSingleton(); - - m_logwindow->ShowWindow(SW_SHOW); -#endif -} -*/ -/* -void MmView::OnUpdateViewLog(CCmdUI *pCmdUI) -{ - pCmdUI->Enable(TRUE); -} -*/ + LPARAM MmView::OnSetClientRect(WPARAM wParam, LPARAM lParam) { CFrameWnd *mainWnd = (CFrameWnd*) AfxGetMainWnd(); @@ -586,7 +541,27 @@ mainWnd->SetWindowPos(&wndTop, 0, 0, size.cx, size.cy, flags); return 0; } - +//TODO: why does this code never get called?? +void MmView::OnSize(UINT nType, int cx, int cy) +{ + CView::OnSize(nType, cx, cy); + // On resize, if we have a single child, we assume it is the + // HTML View and we resize it to our complete size. + // NOTE: This only works for true Daisy books, where the HTML + // view occupies the complete SMIL layout. If ever more complicated + // layout is used this code will break. + long childCount = GetWindowedChildCount(); + if (childCount == 1) { + CWnd *child = GetWindow(GW_CHILD); + assert(child); + RECT rect; + rect.top = 0; + rect.left = 0; + rect.right = cx; + rect.bottom = cy; + child->MoveWindow(&rect); + } +} LPARAM MmView::OnReplaceDoc(WPARAM wParam, LPARAM lParam) { USES_CONVERSION; @@ -596,71 +571,7 @@ delete purlstr; return 0; } -/* -void MmView::OnOpenFilter() -{ - USES_CONVERSION; - BOOL bOpenFileDialog = TRUE; - TCHAR lpszDefExt[] = TEXT("*.xml"); - LPCTSTR lpszFileName = NULL; // no initial fn - DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - TCHAR lpszFilter[] = TEXT("Settings Files (*.xml)|*.xml|All Files (*.*)|*.*||"); - CWnd* pParentWnd = this; - CFileDialog dlg(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd); - dlg.m_ofn.lpstrTitle = TEXT("Select settings file"); - if(!m_curDocFilename.IsEmpty()) { - // XXXX Is this correct? (URL vs. filename) - net::url u = net::url::from_url( T2CA((LPCTSTR) m_curDocFilename)); - if(u.is_local_file()) - dlg.m_ofn.lpstrInitialDir = get_directory(A2CT(u.get_file().c_str())); - } - if(dlg.DoModal()==IDOK) { - CString str = dlg.GetPathName(); - m_curFilter = str; - smil2::test_attrs::load_test_attrs(lib::textptr(LPCTSTR(str)).c_str()); -#ifndef AM_PLAYER_DG - if(player) player->restart(); -#endif - } -} -*/ -/* -void MmView::OnUpdateOpenFilter(CCmdUI *pCmdUI) -{ - pCmdUI->Enable(TRUE); -} -*/ -/* -void MmView::OnViewFilter() -{ - USES_CONVERSION; - if(!m_curFilter.IsEmpty()) { - CString cmd = TEXT("Notepad.exe "); - cmd += m_curFilter; - WinExec(T2CA((LPCTSTR)cmd), SW_SHOW); - } -} -*/ -/* -void MmView::OnUpdateViewFilter(CCmdUI *pCmdUI) -{ - pCmdUI->Enable(!m_curFilter.IsEmpty()); -} -*/ -#if 0 -void MmView::OnViewAutoplay() -{ - m_autoplay = !m_autoplay; -} - -void MmView::OnUpdateViewAutoplay(CCmdUI *pCmdUI) -{ - pCmdUI->Enable(TRUE); - pCmdUI->SetCheck(m_autoplay?1:0); -} -#endif - BOOL MmView::OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult) { if(!player) return false; @@ -705,42 +616,7 @@ } return -1; // not found } -/* -bool MmView::LocateWelcomeDoc(LPCTSTR rpath) -{ - TCHAR buf[_MAX_PATH]; - GetModuleFileName(NULL, buf, _MAX_PATH); - TCHAR *p1 = text_strrchr(buf,'\\'); - if(p1) *++p1='\0'; - text_strcat(buf, rpath); - TCHAR path[_MAX_PATH]; - TCHAR *pFilePart = 0; - GetFullPathName(buf, MAX_PATH, path, &pFilePart); - WIN32_FIND_DATA fd; - memset(&fd, 0, sizeof(WIN32_FIND_DATA)); - HANDLE hFind = FindFirstFile(path, &fd); - 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) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-03-04 05:15:00
|
Revision: 2388 http://amis.svn.sourceforge.net/amis/?rev=2388&view=rev Author: marisademeglio Date: 2008-03-03 21:15:06 -0800 (Mon, 03 Mar 2008) Log Message: ----------- Added support for opening local books from the command line. Added reopening of the last-read book (although it is still off by default in the preferences) Removed audiere and fftw DLLs since they shouldn't be needed anymore. Modified Paths: -------------- branches/amis3/AmisCore/src/util/Log.cpp branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/MmDoc.cpp Removed Paths: ------------- branches/amis3/bin/audiere.dll branches/amis3/bin/fftw3.dll Modified: branches/amis3/AmisCore/src/util/Log.cpp =================================================================== --- branches/amis3/AmisCore/src/util/Log.cpp 2008-03-03 06:30:45 UTC (rev 2387) +++ branches/amis3/AmisCore/src/util/Log.cpp 2008-03-04 05:15:06 UTC (rev 2388) @@ -66,6 +66,16 @@ void amis::util::Log::endLog() { +#ifdef AMIS_PLATFORM_WINDOWS + char datestr[10]; + char timestr[10]; + _strdate(datestr); + _strtime(timestr); + mFile<<"End of log\n"<<datestr<<"\n"<<timestr<<endl; +#else + mFile<<"End of log"<<endl; + //TODO: timestamp for other platforms +#endif mFile.close(); mbIsFileOpen = false; } Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-03 06:30:45 UTC (rev 2387) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-04 05:15:06 UTC (rev 2388) @@ -383,8 +383,8 @@ CONTROL "Highlight text as it is read aloud",IDC_HIGHLIGHTTEXT, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,59,242,10 CONTROL "Load the most recently read book on startup", - IDC_LOADLASTBOOK,"Button",BS_AUTOCHECKBOX | WS_DISABLED | - WS_TABSTOP,7,76,242,10 + IDC_LOADLASTBOOK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, + 76,242,10 CONTROL "Start in basic view mode",IDC_STARTINBASICVIEW,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,94,242,10 CONTROL "Pause audio when switching applications", Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2008-03-03 06:30:45 UTC (rev 2387) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2008-03-04 05:15:06 UTC (rev 2388) @@ -36,7 +36,7 @@ <Tool Name="VCLinkerTool" AdditionalDependencies="AmisCoreD.lib xerces-c_2D.lib libambulant_shwin32_D.lib strmiids.lib uuid.lib" - OutputFile="$(OutDir)/AMIS.exe" + OutputFile="$(OutDir)/AMISD.exe" LinkIncremental="2" AdditionalLibraryDirectories="../lib;../../../../ambulant/lib/win32;"$(VSInstallDir)\..\Microsoft Speech SDK 5.1\Lib\i386";"$(VSInstallDir)\..\Visual Leak Detector"" IgnoreDefaultLibraryNames="uafxcwd.lib" Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-03 06:30:45 UTC (rev 2387) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-04 05:15:06 UTC (rev 2388) @@ -64,6 +64,7 @@ amis::RecentBooks* getRecentBooks(); bool isBookOpen(); void setPauseState(bool play); + bool shouldIgnoreOpenDocEvent(); //Menu handlers afx_msg void OnFileOpen(); @@ -118,6 +119,9 @@ ambulant::net::url mURL; amis::RecentBooks* mpRecentBooks; bool mbBookIsOpen; + bool mbShouldIgnoreOpenDocEvent; + bool mbWasLastExitClean; + public: //afx_msg void OnAppAbout(); DECLARE_MESSAGE_MAP() Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 06:30:45 UTC (rev 2387) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-04 05:15:06 UTC (rev 2388) @@ -124,6 +124,7 @@ BOOL CAmisApp::InitInstance() { + USES_CONVERSION; HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if (hr == S_FALSE) CoUninitialize(); @@ -173,14 +174,12 @@ // To create the main window, this code creates a new frame window // object and then sets it as the application's main window object CMDIFrameWnd* pFrame = new CMainFrame; - if (!pFrame->LoadFrame(IDR_AMISTYPE)) { amis::util::Log::Instance()->writeError("Could not load MFC frame IDR_AMISTYPE", "CMainFrame::InitInstance", "AmisGuiMFC2"); return FALSE; } - m_pMainWnd = pFrame; // Parse command line for standard shell commands, DDE, file open @@ -190,11 +189,29 @@ // Dispatch commands specified on the command line //it turns out that this step is rather important even if you're not really interested in //the command line because mfc processes dynamic view creation somewhere in here. + //also: + //this will stupidly invoke seemingly any available OnOpenDocument handler if it thinks your + //command parameters want to open a document. + //our workaround is the mbShouldIgnoreOpenDoc event flag + mbShouldIgnoreOpenDocEvent = true; if (!ProcessShellCommand(cmdInfo)) { amis::util::Log::Instance()->writeError("Error processing shell command info", "CAmisApp::InitInstance", "AmisGuiMFC2"); return FALSE; } + mbShouldIgnoreOpenDocEvent = false; + bool b_open_from_cmdline = false; + ambulant::net::url book_to_open; + if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileOpen) + { + //we have to assume that command line parameters are local files + //TODO: introduce a command line parameter to identify URLs + //if we get the two mixed up, then the path gets mangled + b_open_from_cmdline = true; + book_to_open = ambulant::net::url::from_filename(T2A(cmdInfo.m_strFileName)); + amis::util::Log::Instance()->writeMessage("Command line parameter: ", &book_to_open, "CAmisApp::InitInstance", "AmisGuiMFC2"); + } + // try to load shared MDI menus and accelerator table HINSTANCE hInst = AfxGetResourceHandle(); @@ -213,11 +230,24 @@ //set the callback function to handle book key registration amis::dtb::DtbWithHooks::Instance()->setCallbackForPreprocessingBookKey(registerBookKeyFile); + //if we're not opening from the command line, try loading the last-read book + if (b_open_from_cmdline == false + && Preferences::Instance()->getLoadLastBook() == true + && mbWasLastExitClean == true) + book_to_open = mpRecentBooks->getLastRead()->mPath; + + //open a book if we decided to either open the command line parameter or last-read book + if (!book_to_open.is_empty_path()) openBook(&book_to_open); + return TRUE; } int CAmisApp::ExitInstance() { + Preferences::Instance()->setWasExitClean(true); + PreferencesFileIO prefs_io; + prefs_io.writeToFile(Preferences::Instance()->getSourceUrl()->get_file(), Preferences::Instance()); + amis::util::Log::Instance()->writeMessage("Exiting", "CAmisApp::ExitInstance", "AmisGuiMFC2"); if (m_hMDIMenu != NULL) FreeResource(m_hMDIMenu); if (m_hMDIAccel != NULL)FreeResource(m_hMDIAccel); @@ -235,8 +265,7 @@ DataTree::Instance()->DestroyInstance(); - if (mpRecentBooks) - delete mpRecentBooks; + if (mpRecentBooks != NULL) delete mpRecentBooks; amis::util::Log::Instance()->endLog(); amis::util::Log::Instance()->DestroyInstance(); @@ -264,11 +293,15 @@ void CAmisApp::initializePathsAndFiles() { - //read the preferences + //read the preferences and mark the was-exit-clean flag as false amis::io::PreferencesFileIO prefs_io; string prefs_path = "./settings/amisPrefs.xml"; prefs_path = amis::util::FilePathTools::goRelativePath(theApp.getAppPath(), prefs_path); prefs_io.readFromFile(prefs_path); + mbWasLastExitClean = Preferences::Instance()->getWasExitClean(); + Preferences::Instance()->setWasExitClean(false); + prefs_io.writeToFile(prefs_path, Preferences::Instance()); + //read the recent books list string recent_books_path = "./settings/amisRecentBooks.xml"; recent_books_path = amis::util::FilePathTools::goRelativePath(theApp.getAppPath(), recent_books_path); @@ -328,6 +361,10 @@ { return mbBookIsOpen; } +bool CAmisApp::shouldIgnoreOpenDocEvent() +{ + return mbShouldIgnoreOpenDocEvent; +} //this function is used by all functions here that lead to a book being opened void CAmisApp::openBook(const ambulant::net::url* filename) { @@ -337,7 +374,6 @@ MainWndParts::Instance()->updateTitleSelfVoicing(Preferences::Instance()->getIsSelfVoicing()); bool b_a_book_was_open = false; - //close the open book if (mbBookIsOpen == true) { Modified: branches/amis3/AmisGuiMFC2/src/gui/MmDoc.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MmDoc.cpp 2008-03-03 06:30:45 UTC (rev 2387) +++ branches/amis3/AmisGuiMFC2/src/gui/MmDoc.cpp 2008-03-04 05:15:06 UTC (rev 2388) @@ -53,8 +53,8 @@ #include "gui/MmDoc.h" #include "gui/MmView.h" - #include "gui/MainWndParts.h" +#include "gui/AmisApp.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -126,6 +126,11 @@ BOOL MmDoc::OnOpenDocument(LPCTSTR lpszPathName) { + //med 21 June 07 + //this is a hack to get around the fact that windows will automatically invoke this + //OnOpenDocument handler when it does command line processing (even though I wish it wouldn't) + if (theApp.shouldIgnoreOpenDocEvent() == true) return TRUE; + POSITION pos = GetFirstViewPosition(); if(pos != NULL) { Deleted: branches/amis3/bin/audiere.dll =================================================================== (Binary files differ) Deleted: branches/amis3/bin/fftw3.dll =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-03-03 06:30:40
|
Revision: 2387 http://amis.svn.sourceforge.net/amis/?rev=2387&view=rev Author: marisademeglio Date: 2008-03-02 22:30:45 -0800 (Sun, 02 Mar 2008) Log Message: ----------- First alpha of AMIS 3 Modified Paths: -------------- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/DefaultLangpack/amisAccessibleUi.xml branches/amis3/bin/settings/amisPrefs.xml.default branches/amis3/bin/settings/lang/releasedate.mp3 branches/amis3/bin/settings/lang/version.mp3 branches/amis3/installer/main/setup-amis3.nsi Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-03 05:54:57 UTC (rev 2386) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-03 06:30:45 UTC (rev 2387) @@ -374,15 +374,17 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN CONTROL "Use self-voicing",IDC_ISSELFVOICING,"Button", - BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,7,7,241,10 - LTEXT "Select TTS voice:",IDC_SELTTSLABEL,7,22,242,8 + BS_AUTOCHECKBOX | BS_NOTIFY | WS_DISABLED | WS_TABSTOP,7, + 7,241,10 + LTEXT "Select TTS voice:",IDC_SELTTSLABEL,7,22,242,8, + WS_DISABLED COMBOBOX IDC_TTSVOICES,7,35,108,88,CBS_DROPDOWNLIST | CBS_SORT | - WS_VSCROLL | WS_TABSTOP + WS_DISABLED | WS_VSCROLL | WS_TABSTOP CONTROL "Highlight text as it is read aloud",IDC_HIGHLIGHTTEXT, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,59,242,10 CONTROL "Load the most recently read book on startup", - IDC_LOADLASTBOOK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, - 76,242,10 + IDC_LOADLASTBOOK,"Button",BS_AUTOCHECKBOX | WS_DISABLED | + WS_TABSTOP,7,76,242,10 CONTROL "Start in basic view mode",IDC_STARTINBASICVIEW,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,94,242,10 CONTROL "Pause audio when switching applications", Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 05:54:57 UTC (rev 2386) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 06:30:45 UTC (rev 2387) @@ -863,7 +863,7 @@ double rate = ambulantX::gui::dx::audio_playerX::Instance()->get_rate(); //TODO: unhardcode the max rate - double max = 4.0; + double max = 2.0; bool can_increase = true; bool can_decrease = true; if (rate == 1) Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-03 05:54:57 UTC (rev 2386) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-03 06:30:45 UTC (rev 2387) @@ -92,6 +92,8 @@ ON_UPDATE_COMMAND_UI_RANGE(AMIS_PAGE_STYLE_BASE_ID, AMIS_PAGE_STYLE_BASE_ID + AMIS_MAX_ANYTHING, OnUpdateCmdUiPageStyle) ON_UPDATE_COMMAND_UI(ID_AMIS_SMALLER_FONT, OnUpdateCmdUiSmallerFont) ON_UPDATE_COMMAND_UI(ID_AMIS_BIGGER_FONT, OnUpdateCmdUiBiggerFont) + ON_UPDATE_COMMAND_UI(ID_AMIS_INCREASE_VOLUME, OnUpdateCmdUiGeneral) + ON_UPDATE_COMMAND_UI(ID_AMIS_DECREASE_VOLUME, OnUpdateCmdUiGeneral) //}}AFX_MSG_MAP ON_WM_SIZE() END_MESSAGE_MAP() @@ -482,7 +484,7 @@ void CMainFrame::OnUpdateCmdUiPlayFaster(CCmdUI* pCmdUi) { //TODO: unhardcode the max rate - if (theApp.isBookOpen() && ambulantX::gui::dx::audio_playerX::Instance()->get_rate() < 4.0) + if (theApp.isBookOpen() && ambulantX::gui::dx::audio_playerX::Instance()->get_rate() < 2.0) updateUiCommandState(pCmdUi, true); else updateUiCommandState(pCmdUi, false); @@ -617,4 +619,6 @@ pToolbar->enable(ID_AMIS_NEXT_PAGE_STYLE, theApp.isBookOpen()); pToolbar->enable(ID_AMIS_INCREASE_SECTION_DEPTH, theApp.isBookOpen()); pToolbar->enable(ID_AMIS_DECREASE_SECTION_DEPTH, theApp.isBookOpen()); + pToolbar->enable(ID_AMIS_INCREASE_VOLUME, theApp.isBookOpen()); + pToolbar->enable(ID_AMIS_DECREASE_VOLUME, theApp.isBookOpen()); } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-03-03 05:54:57 UTC (rev 2386) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-03-03 06:30:45 UTC (rev 2387) @@ -29,7 +29,8 @@ #include "util/Color.h" #include "util/Log.h" #include <algorithm> - +#include "DtbWithHooks.h" +#include "dtb\Dtb.h" #include <fstream> #include "resource.h" @@ -135,6 +136,10 @@ mpUserCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet (Preferences::Instance()->getAmisCssFile()); scanStylesheetForAdditionalData(mpUserCss); + //TODO: does this ever work? need to test more books. + if (amis::dtb::DtbWithHooks::Instance()->getDaisyVersion() == amis::dtb::DAISY_2005) + MainWndParts::Instance()->mpHtmlView->applyStylesheet(Preferences::Instance()->getZed2005CssFile()); + MainWndParts::Instance()->mpHtmlView->RedrawWindow(); mbWaitForDocumentLoad = false; Modified: branches/amis3/DefaultLangpack/amisAccessibleUi.xml =================================================================== --- branches/amis3/DefaultLangpack/amisAccessibleUi.xml 2008-03-03 05:54:57 UTC (rev 2386) +++ branches/amis3/DefaultLangpack/amisAccessibleUi.xml 2008-03-03 06:30:45 UTC (rev 2387) @@ -34,19 +34,19 @@ <icon src="./open.png" type="smallIcon"/> <caption> <text id="xx">Open URL...</text> - <audio src=""/> + <audio src="./audio/openurl.mp3"/> </caption> <description> <text id="xx">Open a DAISY publication from a URL</text> - <audio src=""/> + <audio src="./audio/openurl_desc.mp3"/> </description> <accelerator> <text id="xx">Ctrl+U</text> - <audio src=""/> + <audio src="./audio/openurl_ctrlu.mp3"/> </accelerator> <mnemonic> <text id="xx">U</text> - <audio src=""/> + <audio src="./audio/openurl_u.mp3"/> </mnemonic> </action> <!--new action--> @@ -55,15 +55,15 @@ <icon src="./close.png" type="smallIcon"/> <caption> <text id="xx">Close</text> - <audio src=""/> + <audio src="./audio/close.mp3"/> </caption> <description> <text id="xx">Close the DAISY publication.</text> - <audio src=""/> + <audio src="./audio/close_desc.mp3"/> </description> <mnemonic> <text id="xx">C</text> - <audio src=""/> + <audio src="./audio/close_c.mp3"/> </mnemonic> </action> <action mfcid="ID_AMIS_LOAD_CD" widget="menuItem toolbarItem"> Modified: branches/amis3/bin/settings/amisPrefs.xml.default =================================================================== --- branches/amis3/bin/settings/amisPrefs.xml.default 2008-03-03 05:54:57 UTC (rev 2386) +++ branches/amis3/bin/settings/amisPrefs.xml.default 2008-03-03 06:30:45 UTC (rev 2387) @@ -4,8 +4,8 @@ <section name="general"> <entry id="ui-lang-id" value="eng-US"/> <entry id="start-in-basic-view" value="no"/> -<entry id="load-last-book" value="yes"/> -<entry id="is-self-voicing" value="yes"/> +<entry id="load-last-book" value="no"/> +<entry id="is-self-voicing" value="no"/> <entry id="tts-voice-index" value="0"/> <entry id="pause-on-lost-focus" value="no"/> <entry id="use-tts-not-audio" value="no"/> Modified: branches/amis3/bin/settings/lang/releasedate.mp3 =================================================================== (Binary files differ) Modified: branches/amis3/bin/settings/lang/version.mp3 =================================================================== (Binary files differ) Modified: branches/amis3/installer/main/setup-amis3.nsi =================================================================== --- branches/amis3/installer/main/setup-amis3.nsi 2008-03-03 05:54:57 UTC (rev 2386) +++ branches/amis3/installer/main/setup-amis3.nsi 2008-03-03 06:30:45 UTC (rev 2387) @@ -86,7 +86,6 @@ ;copy the DLLs File "${BIN_DIR}\libambulant_shwin32.dll" - File "${BIN_DIR}\AmisAudio.dll" File "${BIN_DIR}\xerces-c_2_7.dll" File "${BIN_DIR}\libamplugin_pdtb.dll" File "${BIN_DIR}\PdtbIePlugin.dll" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2008-03-03 05:54:56
|
Revision: 2386 http://amis.svn.sourceforge.net/amis/?rev=2386&view=rev Author: daniel_weck Date: 2008-03-02 21:54:57 -0800 (Sun, 02 Mar 2008) Log Message: ----------- - CreateThread instead of _beginthreadex, in order to match Ambulant's configuration Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h 2008-03-03 05:50:56 UTC (rev 2385) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h 2008-03-03 05:54:57 UTC (rev 2386) @@ -27,11 +27,10 @@ class AudioSequencePlayer { -private: +public: string stringReplaceAll(string sourceStr, string searchStr, string replaceStr); void playAudioPrompt(amis::AudioNode* pAudio); -public: static bool InstanceExists(); static AudioSequencePlayer* Instance(); @@ -41,7 +40,7 @@ void TTSAudioEndNotify(); void ClipAudioEndNotify(); void DestroyInstance(); -private: + int m_wakeUpAction; int m_wakeUpOriginator; int m_nEndEventsToExpect; @@ -52,15 +51,12 @@ AudioSequencePlayer(void); ~AudioSequencePlayer(void); - - static unsigned __stdcall ThreadProc( void* pArguments ); HANDLE m_hThread; HANDLE m_hEventWakeup; HANDLE m_hEventEnd; CRITICAL_SECTION m_csSequence; bool m_bAbort; -public: void waitForSequenceEnd(); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 05:50:56 UTC (rev 2385) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 05:54:57 UTC (rev 2386) @@ -69,7 +69,7 @@ #if _DEBUG //get Visual Leak Detector version 1.0 here: http://dmoulding.googlepages.com/downloads -#include <vld.h> +//#include <vld.h> #endif using namespace amis::gui; @@ -293,7 +293,7 @@ new_data_reader.setAppPath(mAppPath); amis::ErrorCode did_it_work = new_data_reader.readFile(lang_xml_file.get_file(), p_new_data_tree); - if (did_it_work == amis::OK) + if (false && did_it_work == amis::OK) { //test print to an output file //p_new_data_tree->testPrint("c:\\devel\\amis\\Langpacks\\sandbox\\dataout.txt"); Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-03 05:50:56 UTC (rev 2385) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-03 05:54:57 UTC (rev 2386) @@ -28,6 +28,246 @@ #define CCS_ACTIVE + + +/* +unsigned __stdcall AudioSequencePlayer::ThreadProc(void* Arg) { +*/ + +DWORD WINAPI ThreadProc(LPVOID Arg) { + USES_CONVERSION; + + _ASSERT(Arg != NULL); + + ULONG nStream; + AudioSequencePlayer* pThis = (AudioSequencePlayer*) Arg; + + AudioSequenceComponent* comp = NULL; + BOOL bEmptyQueue; + + HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + if (hr == S_FALSE) CoUninitialize(); + _ASSERT(hr == S_OK); + + while (! pThis->m_bAbort) + { + + DWORD hr = WaitForSingleObject(pThis->m_hEventWakeup, INFINITE); + switch (hr) { + case WAIT_FAILED: { + int i = 0; + break; + } + + case WAIT_ABANDONED + : { + int i = 0; + break;} + + case WAIT_OBJECT_0 + : { + int i = 0; + break;} + + case WAIT_TIMEOUT: + { + int i = 0; + break; + } + + } + + /* + if (pThis->m_wakeUpOriginator == 0) { + break; + } else if (pThis->m_wakeUpOriginator == 1) { + + if (AmisBrain::Instance()->isAudioClipPlaying()) { + TRACE(L"### STOP AUDIO CLIP"); + ResetEvent(pThis->m_hEventWakeup); + AmisBrain::Instance()->stopAudioClip(); + continue; + } else + if (TTSPlayer::Instance()->IsSpeaking()) { + TRACE(L"### STOP TTS CLIP"); + ResetEvent(pThis->m_hEventWakeup); + TTSPlayer::Instance()->Stop(); + //TTSPlayer::Instance()->WaitUntilDone(); + continue; + } else { + pThis->m_wakeUpOriginator = -1; + } + + } + */ + + /* + if (pThis->m_wakeUpAction == 0) // INTERRUPT PROCESS BEGIN + { + if (pThis->m_wakeUpOriginator != 1) { + TRACE(L"------------ ZZ_1"); + } + + pThis->m_wakeUpAction = 1; // TTS SHUTDOWN + + if (TTSPlayer::Instance()->IsSpeaking()) { + ResetEvent(pThis->m_hEventWakeup); + TTSPlayer::Instance()->Stop(); + TTSPlayer::Instance()->WaitUntilDone(); + } + + //continue; + } + else if (pThis->m_wakeUpAction == 1) // TTS SHUTDOWN + { + + if (pThis->m_wakeUpOriginator != 2) { + TRACE(L"------------ ZZ_2"); + } + + pThis->m_wakeUpAction = 2; // AUDIO CLIP SHUTDOWN + + if (AmisBrain::Instance()->isAudioClipPlaying()) { + ResetEvent(pThis->m_hEventWakeup); + AmisBrain::Instance()->stopAudioClip(); + } + + //continue; + } + else if (pThis->m_wakeUpAction == 2) // AUDIO CLIP SHUTDOWN + { + + if (pThis->m_wakeUpOriginator != 3) { + TRACE(L"------------ ZZ_3"); + } + pThis->m_wakeUpAction = 3; // Nothing to do. Just play normally. + }*/ + + + if (pThis->m_wakeUpOriginator == 0) { + pThis->m_bAbort = true; + continue; + } + + if (pThis->m_currentAudioSequence == NULL && pThis->m_nextAudioSequence == NULL) {continue;} + + bEmptyQueue = FALSE; + { +#ifdef CCS_ACTIVE + EnterCriticalSection(&pThis->m_csSequence); +#endif + + + if (!pThis->m_bAbort && pThis->m_currentAudioSequence != NULL && pThis->m_currentAudioSequence->GetCount() > 0) + { + comp = pThis->m_currentAudioSequence->RemoveTail(); + + /*if (comp!=NULL) + { + + if (comp->m_isAudioClip) { + if (AmisBrain::Instance()->isAudioClipPlaying()) { + pThis->m_currentAudioSequence->AddTail(comp); + } + } else { + if (TTSPlayer::Instance()->IsSpeaking()) { + pThis->m_currentAudioSequence->AddTail(comp); + } + } + }*/ + + if (pThis->m_currentAudioSequence->GetCount() == 0) { + delete pThis->m_currentAudioSequence; + pThis->m_currentAudioSequence = NULL; + } + } + else + { + bEmptyQueue = TRUE; + } + + if (!pThis->m_bAbort && !bEmptyQueue) + { + if (!pThis->m_bAbort && comp!=NULL) + { + + if (!pThis->m_bAbort && comp->m_isAudioClip) { + pThis->m_wakeUpAction = 3; // Nothing to do. Just play normally. + /*if (TTSPlayer::Instance()->IsSpeaking()) { + ResetEvent(pThis->m_hEventWakeup); + TTSPlayer::Instance()->Stop(); + TTSPlayer::Instance()->WaitUntilDone(); + }*/ + + ResetEvent(pThis->m_hEventWakeup); + TRACE(L"\n============ PLAY AUDIO CLIP\n"); + if (!pThis->m_bAbort) { + /* while (ambulantX::gui::dx::audio_playerX::Instance()->isPlaying()) { + TRACE(L"\nIS PLAYING..."); + Sleep(500); + } */ + pThis->playAudioPrompt(comp->m_AudioClip); + } + delete comp; + comp=NULL; + /* + if (!AmisBrain::Instance()->isAudioClipPlaying()) { + AmisBrain::Instance()->playAudioPrompt(comp->m_AudioClip); + } else { + TRACE(L"THIS SHOULD NEVER HAPPEN ! 1"); + }*/ + + } else if (!pThis->m_bAbort) { + pThis->m_wakeUpAction = 3; // Nothing to do. Just play normally. + + /*if (AmisBrain::Instance()->isAudioClipPlaying()) { + ResetEvent(pThis->m_hEventWakeup); + AmisBrain::Instance()->stopAudioClip(); + }*/ + + + ResetEvent(pThis->m_hEventWakeup); + CString strDebug; + 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; + comp=NULL; + } else { + TRACE(L"THIS SHOULD NEVER HAPPEN ! 2"); + } + } + } + } else if (!pThis->m_bAbort) { + + if (pThis->m_nextAudioSequence != NULL) { + pThis->m_currentAudioSequence = pThis->m_nextAudioSequence; + pThis->m_nextAudioSequence = NULL; + SetEvent(pThis->m_hEventWakeup); + } else { + pThis->m_wakeUpAction = 3; // Nothing to do. Just play normally. + ResetEvent(pThis->m_hEventWakeup); + SetEvent(pThis->m_hEventEnd); + } + } + +#ifdef CCS_ACTIVE + LeaveCriticalSection(&pThis->m_csSequence); +#endif + } + } // while ... + + CoUninitialize(); + + //_endthreadex( 0 ); + return 0; +} + void AudioSequencePlayer::TTSAudioEndNotify() { if (m_bAbort) { @@ -137,8 +377,10 @@ if (m_hThread == NULL) { - unsigned int threadID; - m_hThread = (HANDLE) _beginthreadex(NULL, 0, ThreadProc, (void*) this, 0, &threadID); + /* + m_hThread = (HANDLE) _beginthreadex(NULL, 0, ThreadProc, (void*) this, 0, &threadID); */ + unsigned long threadID; + m_hThread = CreateThread(NULL, 0, ThreadProc, this, 0, &threadID); _ASSERT(m_hThread != NULL); } @@ -976,239 +1218,3 @@ - - -unsigned __stdcall AudioSequencePlayer::ThreadProc(void* Arg) -{ - USES_CONVERSION; - - _ASSERT(Arg != NULL); - - ULONG nStream; - AudioSequencePlayer* pThis = (AudioSequencePlayer*) Arg; - - AudioSequenceComponent* comp = NULL; - BOOL bEmptyQueue; - - HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - if (hr == S_FALSE) CoUninitialize(); - _ASSERT(hr == S_OK); - - while (! pThis->m_bAbort) - { - - DWORD hr = WaitForSingleObject(pThis->m_hEventWakeup, INFINITE); - switch (hr) { - case WAIT_FAILED: { - int i = 0; - break; - } - - case WAIT_ABANDONED - : { - int i = 0; - break;} - - case WAIT_OBJECT_0 - : { - int i = 0; - break;} - - case WAIT_TIMEOUT: - { - int i = 0; - break; - } - - } - - /* - if (pThis->m_wakeUpOriginator == 0) { - break; - } else if (pThis->m_wakeUpOriginator == 1) { - - if (AmisBrain::Instance()->isAudioClipPlaying()) { - TRACE(L"### STOP AUDIO CLIP"); - ResetEvent(pThis->m_hEventWakeup); - AmisBrain::Instance()->stopAudioClip(); - continue; - } else - if (TTSPlayer::Instance()->IsSpeaking()) { - TRACE(L"### STOP TTS CLIP"); - ResetEvent(pThis->m_hEventWakeup); - TTSPlayer::Instance()->Stop(); - //TTSPlayer::Instance()->WaitUntilDone(); - continue; - } else { - pThis->m_wakeUpOriginator = -1; - } - - } - */ - - /* - if (pThis->m_wakeUpAction == 0) // INTERRUPT PROCESS BEGIN - { - if (pThis->m_wakeUpOriginator != 1) { - TRACE(L"------------ ZZ_1"); - } - - pThis->m_wakeUpAction = 1; // TTS SHUTDOWN - - if (TTSPlayer::Instance()->IsSpeaking()) { - ResetEvent(pThis->m_hEventWakeup); - TTSPlayer::Instance()->Stop(); - TTSPlayer::Instance()->WaitUntilDone(); - } - - //continue; - } - else if (pThis->m_wakeUpAction == 1) // TTS SHUTDOWN - { - - if (pThis->m_wakeUpOriginator != 2) { - TRACE(L"------------ ZZ_2"); - } - - pThis->m_wakeUpAction = 2; // AUDIO CLIP SHUTDOWN - - if (AmisBrain::Instance()->isAudioClipPlaying()) { - ResetEvent(pThis->m_hEventWakeup); - AmisBrain::Instance()->stopAudioClip(); - } - - //continue; - } - else if (pThis->m_wakeUpAction == 2) // AUDIO CLIP SHUTDOWN - { - - if (pThis->m_wakeUpOriginator != 3) { - TRACE(L"------------ ZZ_3"); - } - pThis->m_wakeUpAction = 3; // Nothing to do. Just play normally. - }*/ - - - if (pThis->m_wakeUpOriginator == 0) { - pThis->m_bAbort = true; - continue; - } - - if (pThis->m_currentAudioSequence == NULL && pThis->m_nextAudioSequence == NULL) {continue;} - - bEmptyQueue = FALSE; - { -#ifdef CCS_ACTIVE - EnterCriticalSection(&pThis->m_csSequence); -#endif - - - if (!pThis->m_bAbort && pThis->m_currentAudioSequence != NULL && pThis->m_currentAudioSequence->GetCount() > 0) - { - comp = pThis->m_currentAudioSequence->RemoveTail(); - - /*if (comp!=NULL) - { - - if (comp->m_isAudioClip) { - if (AmisBrain::Instance()->isAudioClipPlaying()) { - pThis->m_currentAudioSequence->AddTail(comp); - } - } else { - if (TTSPlayer::Instance()->IsSpeaking()) { - pThis->m_currentAudioSequence->AddTail(comp); - } - } - }*/ - - if (pThis->m_currentAudioSequence->GetCount() == 0) { - delete pThis->m_currentAudioSequence; - pThis->m_currentAudioSequence = NULL; - } - } - else - { - bEmptyQueue = TRUE; - } - - if (!pThis->m_bAbort && !bEmptyQueue) - { - if (!pThis->m_bAbort && comp!=NULL) - { - - if (!pThis->m_bAbort && comp->m_isAudioClip) { - pThis->m_wakeUpAction = 3; // Nothing to do. Just play normally. - /*if (TTSPlayer::Instance()->IsSpeaking()) { - ResetEvent(pThis->m_hEventWakeup); - TTSPlayer::Instance()->Stop(); - TTSPlayer::Instance()->WaitUntilDone(); - }*/ - - ResetEvent(pThis->m_hEventWakeup); - TRACE(L"\n============ PLAY AUDIO CLIP\n"); - if (!pThis->m_bAbort) { - /* while (ambulantX::gui::dx::audio_playerX::Instance()->isPlaying()) { - TRACE(L"\nIS PLAYING..."); - Sleep(500); - } */ - pThis->playAudioPrompt(comp->m_AudioClip); - } - delete comp; - comp=NULL; - /* - if (!AmisBrain::Instance()->isAudioClipPlaying()) { - AmisBrain::Instance()->playAudioPrompt(comp->m_AudioClip); - } else { - TRACE(L"THIS SHOULD NEVER HAPPEN ! 1"); - }*/ - - } else if (!pThis->m_bAbort) { - pThis->m_wakeUpAction = 3; // Nothing to do. Just play normally. - - /*if (AmisBrain::Instance()->isAudioClipPlaying()) { - ResetEvent(pThis->m_hEventWakeup); - AmisBrain::Instance()->stopAudioClip(); - }*/ - - - ResetEvent(pThis->m_hEventWakeup); - CString strDebug; - 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; - comp=NULL; - } else { - TRACE(L"THIS SHOULD NEVER HAPPEN ! 2"); - } - } - } - } else if (!pThis->m_bAbort) { - - if (pThis->m_nextAudioSequence != NULL) { - pThis->m_currentAudioSequence = pThis->m_nextAudioSequence; - pThis->m_nextAudioSequence = NULL; - SetEvent(pThis->m_hEventWakeup); - } else { - pThis->m_wakeUpAction = 3; // Nothing to do. Just play normally. - ResetEvent(pThis->m_hEventWakeup); - SetEvent(pThis->m_hEventEnd); - } - } - -#ifdef CCS_ACTIVE - LeaveCriticalSection(&pThis->m_csSequence); -#endif - } - } // while ... - - CoUninitialize(); - - _endthreadex( 0 ); - return 0; -} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp 2008-03-03 05:50:56 UTC (rev 2385) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp 2008-03-03 05:54:57 UTC (rev 2386) @@ -58,8 +58,9 @@ #define traceX -unsigned __stdcall eventHandler(void* lpParam) { -//static DWORD WINAPI eventHandler(LPVOID lpParam) { +//unsigned __stdcall eventHandler(void* lpParam) { +DWORD __stdcall eventHandler(LPVOID lpParam) { + long lEventCode, lParam1, lParam2; HRESULT hResult = E_FAIL; bool bSelfBreak = false; @@ -85,7 +86,7 @@ } } } - _endthreadex( 0 ); + //_endthreadex( 0 ); return 0; } @@ -678,10 +679,9 @@ } if (hEventHandler == NULL) { - unsigned int lpdwThreadID; - - hEventHandler = (HANDLE) _beginthreadex(NULL, 0, eventHandler, (void*) this, 0, &lpdwThreadID); - //hEventHandler = CreateThread(NULL, 0, eventHandler, this, 0, &lpdwThreadID); + unsigned long lpdwThreadID; + //hEventHandler = (HANDLE) _beginthreadex(NULL, 0, eventHandler, (void*) this, 0, &lpdwThreadID); + hEventHandler = CreateThread(NULL, 0, &eventHandler, this, 0, &lpdwThreadID); } hr = m_media_control->Run(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-03-03 05:50:50
|
Revision: 2385 http://amis.svn.sourceforge.net/amis/?rev=2385&view=rev Author: marisademeglio Date: 2008-03-02 21:50:56 -0800 (Sun, 02 Mar 2008) Log Message: ----------- speed buttons enable/disable correctly Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-03 05:25:23 UTC (rev 2384) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-03 05:50:56 UTC (rev 2385) @@ -112,6 +112,7 @@ void openBook(const ambulant::net::url*); void openLastReadBook(); void updateFontSizeButtons(); + void updateSpeedButtons(); std::string mAppPath; std::string mLocalizationDll; ambulant::net::url mURL; Modified: branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-03-03 05:25:23 UTC (rev 2384) +++ branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-03-03 05:50:56 UTC (rev 2385) @@ -75,6 +75,7 @@ afx_msg void OnUpdateCmdUiGeneral(CCmdUI*); afx_msg void OnUpdateCmdUiInfoSkip(CCmdUI*); afx_msg void OnUpdateCmdUiPlaySlower(CCmdUI*); + afx_msg void OnUpdateCmdUiPlayFaster(CCmdUI*); afx_msg void OnUpdateCmdUiCheckSidebar(CCmdUI*); afx_msg void OnUpdateCmdUiFindInText(CCmdUI*); afx_msg void OnUpdateCmdUiPlayPause(CCmdUI*); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 05:25:23 UTC (rev 2384) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 05:50:56 UTC (rev 2385) @@ -540,7 +540,7 @@ double rate = ambulant::gui::dx::change_global_rate(0.5); ambulantX::gui::dx::audio_playerX::Instance()->set_rate(rate); - + updateSpeedButtons(); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_FASTER, true, NULL); } @@ -554,7 +554,7 @@ //TODO: Doesn't seem to affect the playback speed at all double rate = ambulant::gui::dx::change_global_rate(-0.5); ambulantX::gui::dx::audio_playerX::Instance()->set_rate(rate); - + updateSpeedButtons(); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_SLOWER, true, NULL); } @@ -566,7 +566,7 @@ ambulant::gui::dx::set_global_rate(1.0); ambulantX::gui::dx::audio_playerX::Instance()->set_rate(1.0); - + updateSpeedButtons(); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_NORMALSPEED, true, NULL); } @@ -856,4 +856,29 @@ MainWndParts::Instance()->mpBasicToolbar->enable(ID_AMIS_BIGGER_FONT, can_increase); MainWndParts::Instance()->mpDefaultToolbar->enable(ID_AMIS_SMALLER_FONT, can_decrease); MainWndParts::Instance()->mpBasicToolbar->enable(ID_AMIS_SMALLER_FONT, can_decrease); +} + +void CAmisApp::updateSpeedButtons() +{ + double rate = ambulantX::gui::dx::audio_playerX::Instance()->get_rate(); + + //TODO: unhardcode the max rate + double max = 4.0; + bool can_increase = true; + bool can_decrease = true; + if (rate == 1) + { + can_decrease = false; + can_increase = true; + } + else if (rate == max) + { + can_decrease = true; + can_increase = false; + } + MainWndParts::Instance()->mpDefaultToolbar->enable(ID_AMIS_FASTER, can_increase); + MainWndParts::Instance()->mpBasicToolbar->enable(ID_AMIS_FASTER, can_increase); + MainWndParts::Instance()->mpDefaultToolbar->enable(ID_AMIS_SLOWER, can_decrease); + MainWndParts::Instance()->mpBasicToolbar->enable(ID_AMIS_SLOWER, can_decrease); + } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2008-03-03 05:25:23 UTC (rev 2384) +++ branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2008-03-03 05:50:56 UTC (rev 2385) @@ -648,10 +648,18 @@ void CAmisHtmlView::removeStylesheet(IHTMLStyleSheet* pStyleSheet) { if (!pStyleSheet) return; - amis::util::Log::Instance()->writeMessage("Removing stylesheet", "CAmisHtmlView::removeStylesheet","AmisGuiMFC2"); - pStyleSheet->put_disabled(VARIANT_TRUE); - pStyleSheet->Release(); - pStyleSheet = NULL; + //i don't know if an exception is even raised, but i've seen it crash here, though not consistently + try + { + amis::util::Log::Instance()->writeMessage("Removing stylesheet", "CAmisHtmlView::removeStylesheet","AmisGuiMFC2"); + pStyleSheet->put_disabled(VARIANT_TRUE); + pStyleSheet->Release(); + pStyleSheet = NULL; + } + catch (...) + { + return; + } } Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-03 05:25:23 UTC (rev 2384) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-03 05:50:56 UTC (rev 2385) @@ -68,7 +68,7 @@ ON_UPDATE_COMMAND_UI(ID_AMIS_PREVIOUS_PAGE, OnUpdateCmdUiPageCommands) ON_UPDATE_COMMAND_UI(ID_AMIS_GOTO_PAGE, OnUpdateCmdUiPageCommands) ON_UPDATE_COMMAND_UI(ID_AMIS_ADD_BOOKMARK, OnUpdateCmdUiGeneral) - ON_UPDATE_COMMAND_UI(ID_AMIS_FASTER, OnUpdateCmdUiGeneral) + ON_UPDATE_COMMAND_UI(ID_AMIS_FASTER, OnUpdateCmdUiPlayFaster) ON_UPDATE_COMMAND_UI(ID_AMIS_CLOSE_BOOK, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_SHOW_READING_OPTIONS, OnUpdateCmdUiInfoSkip) ON_UPDATE_COMMAND_UI(ID_AMIS_SLOWER, OnUpdateCmdUiPlaySlower) @@ -262,7 +262,7 @@ if (amis::Preferences::Instance()->getIsSelfVoicing() == true) { - mMenuVoicing->OnMenuSelect(nItemID, nFlags, hSysMenu); + mMenuVoicing->OnMenuSelect(nItemID, nFlags, hSysMenu); } } @@ -462,19 +462,32 @@ } void CMainFrame::OnUpdateCmdUiInfoSkip(CCmdUI* pCmdUi) { + //TODO: re-enable when the reading options dialog works + updateUiCommandState(pCmdUi, false); + /* if (theApp.isBookOpen() && amis::dtb::DtbWithHooks::Instance()->getCustomTestSet() != NULL && amis::dtb::DtbWithHooks::Instance()->getCustomTestSet()->getLength() > 0) updateUiCommandState(pCmdUi, true); else updateUiCommandState(pCmdUi, false); + */ } void CMainFrame::OnUpdateCmdUiPlaySlower(CCmdUI* pCmdUi) { - if (theApp.isBookOpen() && Preferences::Instance()->getIsSelfVoicing() && ambulantX::gui::dx::audio_playerX::Instance()->get_rate() > 1) + if (theApp.isBookOpen() && ambulantX::gui::dx::audio_playerX::Instance()->get_rate() > 1) updateUiCommandState(pCmdUi, true); else updateUiCommandState(pCmdUi, false); } +void CMainFrame::OnUpdateCmdUiPlayFaster(CCmdUI* pCmdUi) +{ + //TODO: unhardcode the max rate + if (theApp.isBookOpen() && ambulantX::gui::dx::audio_playerX::Instance()->get_rate() < 4.0) + updateUiCommandState(pCmdUi, true); + else + updateUiCommandState(pCmdUi, false); + +} void CMainFrame::OnUpdateCmdUiCheckSidebar(CCmdUI* pCmdUi) { if (MainWndParts::Instance()->mpSidebar->IsVisible() == TRUE) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-03-03 05:25:19
|
Revision: 2384 http://amis.svn.sourceforge.net/amis/?rev=2384&view=rev Author: marisademeglio Date: 2008-03-02 21:25:23 -0800 (Sun, 02 Mar 2008) Log Message: ----------- Fontsize buttons now enable/disable like they should Page styles work too Modified Paths: -------------- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h branches/amis3/AmisGuiMFC2/resource.h branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/bin/settings/basicToolbar.xml branches/amis3/bin/settings/css/amis.css branches/amis3/bin/settings/resource.h.ini Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-03 05:25:23 UTC (rev 2384) @@ -182,8 +182,6 @@ BEGIN MENUITEM "None", ID_AMIS_NO_PAGE_STYLES , CHECKED - MENUITEM "sample 1", 351 - MENUITEM "sample 2", 352 END MENUITEM "Bi&gger Font", ID_AMIS_BIGGER_FONT MENUITEM "S&maller Font", ID_AMIS_SMALLER_FONT Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-03 05:25:23 UTC (rev 2384) @@ -99,6 +99,9 @@ afx_msg void OnPreferences(); afx_msg void OnPublicationSummary(); afx_msg void OnToggleView(); + afx_msg void OnClearPageStyle(); + afx_msg void OnApplyPageStyle(UINT); + afx_msg void OnNextPageStyle(); protected: HMENU m_hMDIMenu; HACCEL m_hMDIAccel; @@ -108,6 +111,7 @@ void initializeSelfVoicing(); void openBook(const ambulant::net::url*); void openLastReadBook(); + void updateFontSizeButtons(); std::string mAppPath; std::string mLocalizationDll; ambulant::net::url mURL; Modified: branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-03-03 05:25:23 UTC (rev 2384) @@ -78,6 +78,9 @@ afx_msg void OnUpdateCmdUiCheckSidebar(CCmdUI*); afx_msg void OnUpdateCmdUiFindInText(CCmdUI*); afx_msg void OnUpdateCmdUiPlayPause(CCmdUI*); + afx_msg void OnUpdateCmdUiPageStyle(CCmdUI*); + afx_msg void OnUpdateCmdUiBiggerFont(CCmdUI*); + afx_msg void OnUpdateCmdUiSmallerFont(CCmdUI*); DECLARE_MESSAGE_MAP() public: afx_msg void OnSize(UINT nType, int cx, int cy); Modified: branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h 2008-03-03 05:25:23 UTC (rev 2384) @@ -43,6 +43,7 @@ void addBookmark(amis::dtb::PositionMark*); void loadBookmarks(amis::dtb::BookmarkSet*); void setupNavigationOptions(); + void addPageStyles(); private: static MenuManip* pinstance; }; Modified: branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2008-03-03 05:25:23 UTC (rev 2384) @@ -49,13 +49,19 @@ void resetFontSize(); void increaseFontSize(); - bool toggleContrast(); - bool isContrastOn(); + void decreaseFontSize(); + int getFontLevel(); + int getMaxFontLevel(); void gotoUriTarget(amis::TextNode*); void gotoUriTarget(std::string url); - void redoPageColors(bool bDisableContrast=false); + void applyPageStyle(int); + void clearPageStyle(); + void applyNextPageStyle(); + int getCurrentCustomStyleIndex(); + + void redoPageColors(); wstring getCurrentText(); void webDocumentComplete(); @@ -63,8 +69,6 @@ void saveElementText(IHTMLElement*); void setFontSize(int); void showElementAtId(string); - void htmlContrastOn(); - void htmlContrastOff(); void unHighlightPreviousElement(); void setHighlightColors(IHTMLElement*); void redoHighlightColors(); @@ -75,7 +79,6 @@ int mFontSize; bool mbWaitForDocumentLoad; - bool mbContrastOn; ambulant::net::url mCurrentUrl; string mTextElmId; wstring mCurrentElmText; @@ -83,9 +86,10 @@ VARIANT mUnhighlightedBG; VARIANT mUnhighlightedFG; IHTMLStyleSheet* mpFontCss; - IHTMLStyleSheet* mpContrastCss; + IHTMLStyleSheet* mpStyleCss; IHTMLStyleSheet* mpUserCss; - + int mCurrentStyleIdx; + bool mbStyleOn; private: static TextRenderBrain* pinstance; Modified: branches/amis3/AmisGuiMFC2/resource.h =================================================================== --- branches/amis3/AmisGuiMFC2/resource.h 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/resource.h 2008-03-03 05:25:23 UTC (rev 2384) @@ -14,7 +14,6 @@ #define ID_AMIS_RESET_HIGHLIGHT_COLORS 132 #define ID_AMIS_TOGGLE_AUDIO_CONTENT_PLAYBACK 133 #define ID_AMIS_TOGGLE_AUDIO_SELFVOICING_PLAYBACK 134 -#define ID_AMIS_NEXT_PAGE_STYLE 142 #define IDD_FIND 147 #define AMIS_VIEW_MENU_BASE_ID 150 #define IDD_SKIP 153 @@ -32,6 +31,7 @@ #define AMIS_NAVLIST_BASE_ID 300 #define AMIS_PAGE_STYLE_BASE_ID 350 #define AMIS_BOOKMARKS_BASE_ID 400 +#define ID_AMIS_NEXT_PAGE_STYLE 450 #define ID_AMBULANT_PLAY 700 #define IDC_TREE 1000 #define IDC_TAB 1001 Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 05:25:23 UTC (rev 2384) @@ -108,6 +108,9 @@ ON_COMMAND(ID_AMIS_SHOW_PREFERENCES, OnPreferences) ON_COMMAND(ID_AMIS_SHOW_PUBLICATION_SUMMARY, OnPublicationSummary) ON_COMMAND(ID_AMIS_TOGGLE_VIEW, OnToggleView) + ON_COMMAND(ID_AMIS_NO_PAGE_STYLES, OnClearPageStyle) + ON_COMMAND_RANGE(AMIS_PAGE_STYLE_BASE_ID, AMIS_PAGE_STYLE_BASE_ID + AMIS_MAX_ANYTHING, OnApplyPageStyle) + ON_COMMAND(ID_AMIS_NEXT_PAGE_STYLE, OnNextPageStyle) END_MESSAGE_MAP() CAmisApp::CAmisApp() @@ -200,7 +203,7 @@ MainWndParts::Instance()->mpMainFrame->SetIcon(AfxGetApp()->LoadIcon(IDI_AMIS), TRUE); amis::gui::MenuManip::Instance()->refreshRecentBooksListMenu(); - + amis::gui::MenuManip::Instance()->addPageStyles(); // The main window has been initialized, so show and update it pFrame->ShowWindow(SW_SHOWMAXIMIZED); pFrame->UpdateWindow(); @@ -656,11 +659,13 @@ { amis::util::Log::Instance()->writeMessage("Increase font size", "CAmisApp::OnIncreaseFontSize", "AmisGuiMFC2"); TextRenderBrain::Instance()->increaseFontSize(); + updateFontSizeButtons(); } void CAmisApp::OnDecreaseFontSize() { amis::util::Log::Instance()->writeMessage("Reset font size", "CAmisApp::OnResetFontSize", "AmisGuiMFC2"); - TextRenderBrain::Instance()->resetFontSize(); + TextRenderBrain::Instance()->decreaseFontSize(); + updateFontSizeButtons(); } void CAmisApp::OnSearchForBooks() { @@ -746,7 +751,6 @@ else amis::util::Log::Instance()->writeMessage("Dialog cancelled", "CAmisApp::OnPreferences", "AmisGuiMFC2"); } - void CAmisApp::OnPublicationSummary() { dialogs::PublicationSummaryDialog summary; @@ -754,11 +758,24 @@ summary.setBook(amis::dtb::DtbWithHooks::Instance()); summary.DoModal(); } - void CAmisApp::OnToggleView() { MainWndParts::Instance()->toggleViewMode(); } +void CAmisApp::OnClearPageStyle() +{ + TextRenderBrain::Instance()->clearPageStyle(); +} +void CAmisApp::OnApplyPageStyle(UINT id) +{ + int idx; + idx = id - AMIS_PAGE_STYLE_BASE_ID; + TextRenderBrain::Instance()->applyPageStyle(idx); +} +void CAmisApp::OnNextPageStyle() +{ + TextRenderBrain::Instance()->applyNextPageStyle(); +} /*************************************************** * (MED) I moved these functions out of the menu handler area *****************************************************/ @@ -770,20 +787,7 @@ */ void CAmisApp::setPauseState(bool pauseState) { - - //TODO: re-add toolbar - //if (MainWndParts::Instance()->mpMainFrame->m_wndDefaultToolbar) - { - //MainWndParts::Instance()->mpMainFrame->m_wndDefaultToolbar.setPauseState(pauseState); - } - - //if (MainWndParts::Instance()->mpMainFrame->m_wndBasicToolbar) - { - //MainWndParts::Instance()->mpMainFrame->m_wndBasicToolbar.setPauseState(pauseState); - } - amis::gui::MenuManip::Instance()->setPauseState(pauseState); - MainWndParts::Instance()->updateTitlePlayState(!pauseState); } @@ -832,3 +836,24 @@ afterModalBox(b); } +void CAmisApp::updateFontSizeButtons() +{ + int font_level = TextRenderBrain::Instance()->getFontLevel(); + int max = TextRenderBrain::Instance()->getMaxFontLevel(); + bool can_increase = true; + bool can_decrease = true; + if (font_level == 0) + { + can_decrease = false; + can_increase = true; + } + else if (font_level == max) + { + can_decrease = true; + can_increase = false; + } + MainWndParts::Instance()->mpDefaultToolbar->enable(ID_AMIS_BIGGER_FONT, can_increase); + MainWndParts::Instance()->mpBasicToolbar->enable(ID_AMIS_BIGGER_FONT, can_increase); + MainWndParts::Instance()->mpDefaultToolbar->enable(ID_AMIS_SMALLER_FONT, can_decrease); + MainWndParts::Instance()->mpBasicToolbar->enable(ID_AMIS_SMALLER_FONT, can_decrease); +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-03 05:25:23 UTC (rev 2384) @@ -27,6 +27,7 @@ #include "Preferences.h" #include "DtbWithHooks.h" #include "gui/MenuManip.h" +#include "gui/TextRenderBrain.h" #include "gui/self-voicing/directshow/dx_audio_player.h" @@ -66,8 +67,6 @@ ON_UPDATE_COMMAND_UI(ID_AMIS_NEXT_PAGE, OnUpdateCmdUiPageCommands) ON_UPDATE_COMMAND_UI(ID_AMIS_PREVIOUS_PAGE, OnUpdateCmdUiPageCommands) ON_UPDATE_COMMAND_UI(ID_AMIS_GOTO_PAGE, OnUpdateCmdUiPageCommands) - ON_UPDATE_COMMAND_UI(ID_AMIS_BIGGER_FONT, OnUpdateCmdUiGeneral) - ON_UPDATE_COMMAND_UI(ID_AMIS_SMALLER_FONT, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_ADD_BOOKMARK, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_FASTER, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_CLOSE_BOOK, OnUpdateCmdUiGeneral) @@ -75,7 +74,7 @@ ON_UPDATE_COMMAND_UI(ID_AMIS_SLOWER, OnUpdateCmdUiPlaySlower) ON_UPDATE_COMMAND_UI(ID_AMIS_FOCUS_ON_TEXT, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_TOGGLE_AUDIO_CONTENT_PLAYBACK, OnUpdateCmdUiGeneral) - ON_UPDATE_COMMAND_UI(ID_AMIS_NO_PAGE_STYLES, OnUpdateCmdUiGeneral) + ON_UPDATE_COMMAND_UI(ID_AMIS_NO_PAGE_STYLES, OnUpdateCmdUiPageStyle) ON_UPDATE_COMMAND_UI(ID_AMIS_PLAYPAUSE, OnUpdateCmdUiPlayPause) ON_UPDATE_COMMAND_UI(ID_AMIS_ESCAPE, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_RESET_SPEED, OnUpdateCmdUiGeneral) @@ -86,10 +85,13 @@ ON_UPDATE_COMMAND_UI(ID_AMIS_FIND_IN_TEXT, OnUpdateCmdUiFindInText) ON_UPDATE_COMMAND_UI(ID_AMIS_SHOW_PUBLICATION_SUMMARY, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_NEXT_PAGE_STYLE, OnUpdateCmdUiGeneral) - //TODO: make these more intelligent + //TODO: make these two more intelligent ON_UPDATE_COMMAND_UI(ID_AMIS_INCREASE_SECTION_DEPTH, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_DECREASE_SECTION_DEPTH, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_TOGGLE_SIDEBAR, OnUpdateCmdUiCheckSidebar) + ON_UPDATE_COMMAND_UI_RANGE(AMIS_PAGE_STYLE_BASE_ID, AMIS_PAGE_STYLE_BASE_ID + AMIS_MAX_ANYTHING, OnUpdateCmdUiPageStyle) + ON_UPDATE_COMMAND_UI(ID_AMIS_SMALLER_FONT, OnUpdateCmdUiSmallerFont) + ON_UPDATE_COMMAND_UI(ID_AMIS_BIGGER_FONT, OnUpdateCmdUiBiggerFont) //}}AFX_MSG_MAP ON_WM_SIZE() END_MESSAGE_MAP() @@ -500,7 +502,43 @@ else updateUiCommandState(pCmdUi, false); } +void amis::gui::CMainFrame::OnUpdateCmdUiPageStyle(CCmdUI* pCmdUi) +{ + if (theApp.isBookOpen()) + { + int curr = TextRenderBrain::Instance()->getCurrentCustomStyleIndex(); + + if (curr == -1) + { + if (pCmdUi->m_nID == ID_AMIS_NO_PAGE_STYLES) pCmdUi->SetCheck(1); + else pCmdUi->SetCheck(0); + } + else + { + if (curr == pCmdUi->m_nID - AMIS_PAGE_STYLE_BASE_ID) pCmdUi->SetCheck(1); + else pCmdUi->SetCheck(0); + } + updateUiCommandState(pCmdUi, true); + } + else + updateUiCommandState(pCmdUi, false); +} +void amis::gui::CMainFrame::OnUpdateCmdUiSmallerFont(CCmdUI* pCmdUi) +{ + if (theApp.isBookOpen() && TextRenderBrain::Instance()->getFontLevel() > 0) + updateUiCommandState(pCmdUi, true); + else + updateUiCommandState(pCmdUi, false); +} +void amis::gui::CMainFrame::OnUpdateCmdUiBiggerFont(CCmdUI* pCmdUi) +{ + if (theApp.isBookOpen() && TextRenderBrain::Instance()->getFontLevel() < TextRenderBrain::Instance()->getMaxFontLevel()) + updateUiCommandState(pCmdUi, true); + else + updateUiCommandState(pCmdUi, false); +} +//TODO: this doesn't work void amis::gui::CMainFrame::OnSize(UINT nType, int cx, int cy) { CMDIFrameWnd::OnSize(nType, cx, cy); Modified: branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2008-03-03 05:25:23 UTC (rev 2384) @@ -29,7 +29,8 @@ #include "RecentBooks.h" #include "dtb/nav/NavModel.h" #include "gui/TextRenderBrain.h" - +#include "util/FilePathTools.h" +#include "Preferences.h" using namespace amis::gui; MenuManip* MenuManip::pinstance = 0; @@ -221,18 +222,15 @@ void MenuManip::setPauseState(bool pauseState) { - CMenu* p_menu = NULL; p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); - if (p_menu == NULL) - { - return; - } - + if (p_menu == NULL) return; + p_menu = p_menu->GetSubMenu(2); assert(p_menu); - bool b_BookIsPlaying = MainWndParts::Instance()->mpMainFrame->mbWasPlayingWhenLostFocus || !pauseState; + bool b_BookIsPlaying = MainWndParts::Instance()->mpMainFrame->mbWasPlayingWhenLostFocus + || !pauseState; UiItem* p_uiItem = DataTree::Instance()->findUiItemInContainers(ID_AMIS_PLAYPAUSE, (b_BookIsPlaying ? "canPause" : "canPlay")); if (p_uiItem != NULL) { @@ -251,7 +249,6 @@ TextNodeSV* textNode = pair->getText(); if (textNode != NULL) { wstring str = textNode->getTextString(); - if (mnemonic != NULL) { TextAudioPair* pair = mnemonic->getContents(); if (pair != NULL) { @@ -268,8 +265,6 @@ if (accelerator != NULL) { str.append(_T("\t")); - //char* text = accelerator.c_str(); - //str.append(accelerator.c_str()); TextAudioPair* pair = accelerator->getContents(); if (pair != NULL) { TextNodeSV* node = pair->getText(); @@ -277,25 +272,39 @@ str.append(node->getTextString()); } } - - //str2.append(info.dwTypeData); } p_menu->ModifyMenu(0, MF_BYPOSITION, ID_AMIS_PLAYPAUSE, str.c_str()); } } } } +} - /*if (pauseState) +void MenuManip::addPageStyles() +{ + USES_CONVERSION; + + CMenu* p_menu = NULL; + p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); + //exit if no menu is present..this could mean we are in basic view mode + if (p_menu == NULL) return; + //get to "view" + p_menu = p_menu->GetSubMenu(1); + //get to "page styles" + p_menu = p_menu->GetSubMenu(3); + int num_entries = p_menu->GetMenuItemCount(); + int i; + //remove all but the first one ("None") + for (i=num_entries-1; i>=1; i--) + p_menu->RemoveMenu(i, MF_BYPOSITION); + + //add all the page styles in the settings/css/customStyles folder + amis::UrlList custom_styles = *Preferences::Instance()->getCustomCssFiles(); + for (i=0; i<custom_styles.size(); i++) { - // If book is paused, then we display a "play" action - p_menu->ModifyMenu(0, MF_BYPOSITION, ID_MENU_PLAYPAUSE, L"&Play\tSpace"); + CString menu_label; + string file_name = amis::util::FilePathTools::getFileName(custom_styles[i].get_file()); + menu_label = A2T(file_name.c_str()); + p_menu->AppendMenu(MF_STRING, AMIS_PAGE_STYLE_BASE_ID + i, menu_label); } - 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/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-03-03 05:25:23 UTC (rev 2384) @@ -52,30 +52,22 @@ { mFontSize = 0; mbWaitForDocumentLoad = false; - mbContrastOn = false; mpPreviousElm = NULL; - + mbStyleOn = false; + mCurrentStyleIdx = -1; VariantInit(&mUnhighlightedFG); VariantInit(&mUnhighlightedBG); mCurrentUrl = ambulant::net::url(); mpFontCss = NULL; - mpContrastCss = NULL; + mpStyleCss = NULL; mpUserCss = NULL; } TextRenderBrain::~TextRenderBrain() { - - //these crash.. - - /*if (mpFontCss) delete mpFontCss; - if (mpContrastCss) delete mpContrastCss; - if (mpUserCss) delete mpUserCss; - */ - - //TODO: should delete variants too + //TODO: should delete variants } void TextRenderBrain::gotoUriTarget(amis::TextNode* pText) @@ -148,7 +140,7 @@ //refresh font size and contrast settings for the newly loaded page if (mFontSize > 0) setFontSize(mFontSize); - if (mbContrastOn) htmlContrastOn(); + if (mbStyleOn) applyPageStyle(mCurrentStyleIdx); showElementAtId(mTextElmId); } @@ -287,50 +279,69 @@ p_style->put_backgroundColor(var_bg); p_style->put_color(var_fg); } - -bool TextRenderBrain::isContrastOn() +int TextRenderBrain::getFontLevel() { - return mbContrastOn; + return mFontSize; } -//turns the contrast on or off. returns the new state of the contrast (true = on) -bool TextRenderBrain::toggleContrast() +int TextRenderBrain::getMaxFontLevel() { - //MainWndParts::Instance()->mpSidebar->m_wndDlg.toggleContrast(); - - if (mbContrastOn) htmlContrastOff(); - else htmlContrastOn(); - - return mbContrastOn; + return 4; } -void TextRenderBrain::htmlContrastOn() +int TextRenderBrain::getCurrentCustomStyleIndex() { - amis::util::Log::Instance()->writeMessage("HTML contrast turned on", "TextRenderBrain::htmlContrastOn", "AmisGuiMFC2"); - mbContrastOn = true; + return mCurrentStyleIdx; +} +void TextRenderBrain::applyPageStyle(int idx) +{ + clearPageStyle(); + amis::util::Log::Instance()->writeMessage("Applying custom style", "TextRenderBrain::applyPageStyle", "AmisGuiMFC2"); + mbStyleOn = true; amis::UrlList* list = Preferences::Instance()->getCustomCssFiles(); - ambulant::net::url url = (*list)[0]; - mpContrastCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&url); - scanStylesheetForAdditionalData(mpContrastCss); + ambulant::net::url url = (*list)[idx]; + mCurrentStyleIdx = idx; + mpStyleCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&url); + scanStylesheetForAdditionalData(mpStyleCss); } +void TextRenderBrain::applyNextPageStyle() +{ + amis::UrlList* p_list = Preferences::Instance()->getCustomCssFiles(); + int sz = p_list->size(); + if (mCurrentStyleIdx >= -1 && + mCurrentStyleIdx < sz-1) + { + int tmp = mCurrentStyleIdx; + clearPageStyle(); + mCurrentStyleIdx = tmp + 1; + applyPageStyle(mCurrentStyleIdx); + } + else + { + clearPageStyle(); + } +} -void TextRenderBrain::htmlContrastOff() +void TextRenderBrain::clearPageStyle() { - amis::util::Log::Instance()->writeMessage("HTML contrast turned off", "TextRenderBrain::htmlContrastOff", "AmisGuiMFC2"); - mbContrastOn = false; - MainWndParts::Instance()->mpHtmlView->removeStylesheet(mpContrastCss); + amis::util::Log::Instance()->writeMessage("Clearing page style", "TextRenderBrain::clearPageStyle", "AmisGuiMFC2"); + mbStyleOn = false; + mCurrentStyleIdx = -1; + MainWndParts::Instance()->mpHtmlView->removeStylesheet(mpStyleCss); } void TextRenderBrain::increaseFontSize() { amis::util::Log::Instance()->writeMessage("Font size increased", "TextRenderBrain::increaseFontSize", "AmisGuiMFC2"); - //MainWndParts::Instance()->mpSidebar->m_wndDlg.increaseFontSize(); if (mFontSize >= 0 && mFontSize < 4) setFontSize(mFontSize + 1); } - +void TextRenderBrain::decreaseFontSize() +{ + amis::util::Log::Instance()->writeMessage("Font size decreased", "TextRenderBrain::decreaseFontSize", "AmisGuiMFC2"); + if (mFontSize > 0 && mFontSize <=4) setFontSize(mFontSize - 1); +} void TextRenderBrain::resetFontSize() { amis::util::Log::Instance()->writeMessage("Font size reset", "TextRenderBrain::resetFontSize", "AmisGuiMFC2"); - //MainWndParts::Instance()->mpSidebar->m_wndDlg.resetFontSize(); setFontSize(0); } //set the font size @@ -351,6 +362,10 @@ mpFontCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(css_url); scanStylesheetForAdditionalData(mpFontCss); } + else + { + mpFontCss = NULL; + } if (isElementInView(mpPreviousElm) == false) { VARIANT v_bool; @@ -433,31 +448,12 @@ return mCurrentElmText; } -void TextRenderBrain::redoPageColors(bool disableContrast) +void TextRenderBrain::redoPageColors() { if (Preferences::Instance()->getHighlightText() == true) redoHighlightColors(); else unHighlightPreviousElement(); - - //maintain the contrast settings (on/off) but use the new colors - if (disableContrast == false) - { - //TODO repaint the sidebar contrast - //MainWndParts::Instance()->mpSidebar->m_wndDlg.repaintContrast(); - - //repaint the html view contrast if it had been enabled - if (mbContrastOn) htmlContrastOn(); - } - //otherwise turn the contrast off everywhere - else - { - //TODO turn off the sidebar contrast - //MainWndParts::Instance()->mpSidebar->m_wndDlg.turnContrastOff(); - - //turn off the html view contrast - htmlContrastOff(); - } } //this is called to refresh the page colors //the colors might have changed but the element cursor hasn't moved yet @@ -465,9 +461,7 @@ void TextRenderBrain::redoHighlightColors() { USES_CONVERSION; - IHTMLStyle* pStyle = NULL; - if (mpPreviousElm != NULL) { //get a pointer to the style @@ -477,8 +471,6 @@ string str_text_fg, str_text_bg; VARIANT var_bg; VARIANT var_fg; - - VariantInit(&var_bg); VariantInit(&var_fg); Modified: branches/amis3/bin/settings/basicToolbar.xml =================================================================== --- branches/amis3/bin/settings/basicToolbar.xml 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/bin/settings/basicToolbar.xml 2008-03-03 05:25:23 UTC (rev 2384) @@ -7,7 +7,7 @@ </toggle> <button src="./img/basicToolbar/media_seek_forward.ico" mfcid="ID_AMIS_NEXT_PHRASE"/> <separator/> - <button src="./img/basicToolbar/style.ico" mfcid="ID_AMIS_SLOWER"/> + <button src="./img/basicToolbar/style.ico" mfcid="ID_AMIS_NEXT_PAGE_STYLE"/> <separator/> <button src="./img/basicToolbar/display.ico" mfcid="ID_AMIS_TOGGLE_VIEW"/> </toolbar> Modified: branches/amis3/bin/settings/css/amis.css =================================================================== --- branches/amis3/bin/settings/css/amis.css 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/bin/settings/css/amis.css 2008-03-03 05:25:23 UTC (rev 2384) @@ -1,5 +1,5 @@ /*default CSS sheet*/ /*"amis-highlight" is a reserved word that AMIS will look for to find the highlight colors*/ /*use the body element selector to specify what font you want, etc. AMIS will pick up the font family for the body element and use it in the sidebar*/ -.amis-highlight {color: white; background-color: green} +.amis-highlight {color: black; background-color: yellow} body {font-family: arial, verdana, sans-serif;} \ No newline at end of file Modified: branches/amis3/bin/settings/resource.h.ini =================================================================== --- branches/amis3/bin/settings/resource.h.ini 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/bin/settings/resource.h.ini 2008-03-03 05:25:23 UTC (rev 2384) @@ -33,6 +33,7 @@ AMIS_NAVLIST_BASE_ID=300 AMIS_PAGE_STYLE_BASE_ID=350 AMIS_BOOKMARKS_BASE_ID=400 +ID_AMIS_NEXT_PAGE_STYLE=450 ID_AMBULANT_PLAY=700 IDC_TREE=1000 IDC_TAB=1001 @@ -124,7 +125,6 @@ _APS_NEXT_RESOURCE_VALUE=192 _APS_NEXT_COMMAND_VALUE=32952 _APS_NEXT_CONTROL_VALUE=1106 -_APS_NEXT_SYMED_VALUE=142 +_APS_NEXT_SYMED_VALUE=143 - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2008-03-03 05:17:25
|
Revision: 2383 http://amis.svn.sourceforge.net/amis/?rev=2383&view=rev Author: daniel_weck Date: 2008-03-02 21:17:32 -0800 (Sun, 02 Mar 2008) Log Message: ----------- - fixed issues with speed up/down Modified Paths: -------------- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 04:45:01 UTC (rev 2382) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 05:17:32 UTC (rev 2383) @@ -535,8 +535,8 @@ long currentRate = amis::tts::TTSPlayer::Instance()->GetSpeechRate(); amis::tts::TTSPlayer::Instance()->SetSpeechRate(currentRate+2); - //TODO: Doesn't seem to affect the playback speed at all - double rate = ambulant::gui::dx::change_global_rate(1.12); + double rate = ambulant::gui::dx::change_global_rate(0.5); + ambulantX::gui::dx::audio_playerX::Instance()->set_rate(rate); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_FASTER, true, NULL); } @@ -549,7 +549,8 @@ amis::tts::TTSPlayer::Instance()->SetSpeechRate(currentRate-2); //TODO: Doesn't seem to affect the playback speed at all - double rate = ambulant::gui::dx::change_global_rate(-1.12); + double rate = ambulant::gui::dx::change_global_rate(-0.5); + ambulantX::gui::dx::audio_playerX::Instance()->set_rate(rate); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_SLOWER, true, NULL); } @@ -561,6 +562,7 @@ amis::tts::TTSPlayer::Instance()->SetSpeechRate(0); ambulant::gui::dx::set_global_rate(1.0); + ambulantX::gui::dx::audio_playerX::Instance()->set_rate(1.0); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_NORMALSPEED, true, NULL); } Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-03 04:45:01 UTC (rev 2382) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-03 05:17:32 UTC (rev 2383) @@ -134,6 +134,13 @@ ResetEvent(m_hEventEnd); m_hThread = NULL; + + if (m_hThread == NULL) { + + unsigned int threadID; + m_hThread = (HANDLE) _beginthreadex(NULL, 0, ThreadProc, (void*) this, 0, &threadID); + _ASSERT(m_hThread != NULL); + } } void AudioSequencePlayer::waitForSequenceEnd() @@ -295,21 +302,13 @@ } void AudioSequencePlayer::Play(AudioSequence* audioSequence, bool doNotRegisterInHistory) { - //Stop(); + Stop(); { #ifdef CCS_ACTIVE EnterCriticalSection(&m_csSequence); #endif if (!m_bAbort) { - if (m_hThread == NULL) { - - unsigned int threadID; - m_hThread = (HANDLE) _beginthreadex(NULL, 0, ThreadProc, (void*) this, 0, &threadID); - _ASSERT(m_hThread != NULL); - } - - m_wakeUpAction = 0; m_nEndEventsToExpect = 0; @@ -338,8 +337,8 @@ TRACE(L"####### STOP TTS"); } if (ambulantX::gui::dx::audio_playerX::Instance()->is_playing()) { - //bExpectEndEventForWakeUp = true; - //m_nEndEventsToExpect++; + bExpectEndEventForWakeUp = true; + m_nEndEventsToExpect++; //ResetEvent(pThis->m_hEventWakeup); ambulantX::gui::dx::audio_playerX::Instance()->stop(false); //m_wakeUpOriginator = 3; // AUDIO CLIP END @@ -347,9 +346,11 @@ TRACE(L"####### STOP AUDIO"); } + ResetEvent(m_hEventEnd); + if (!bExpectEndEventForWakeUp) { m_wakeUpOriginator = 1; // PLAY - ResetEvent(m_hEventEnd); + TRACE(L"\n ---- m_hEventWakeup PLAY\n"); SetEvent(m_hEventWakeup); @@ -1090,9 +1091,11 @@ if (pThis->m_wakeUpOriginator == 0) { pThis->m_bAbort = true; + continue; } - + if (pThis->m_currentAudioSequence == NULL && pThis->m_nextAudioSequence == NULL) {continue;} + bEmptyQueue = FALSE; { #ifdef CCS_ACTIVE Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp 2008-03-03 04:45:01 UTC (rev 2382) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp 2008-03-03 05:17:32 UTC (rev 2383) @@ -103,7 +103,7 @@ m_basic_audio(0), hEventHandler(0) { - set_rate(1.7); + set_rate(1.0); InitializeCriticalSection(&m_csSequence); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2008-03-03 04:44:55
|
Revision: 2382 http://amis.svn.sourceforge.net/amis/?rev=2382&view=rev Author: daniel_weck Date: 2008-03-02 20:45:01 -0800 (Sun, 02 Mar 2008) Log Message: ----------- missing files !!! Modified Paths: -------------- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp Added Paths: ----------- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/SmilTimeCode.H branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/counter.H branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/field.H branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/masterCounter.H branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/masterCounterArray.H branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/timeCode.H branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/win32fix.H branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp Added: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h 2008-03-03 04:45:01 UTC (rev 2382) @@ -0,0 +1,223 @@ +/* + * This file is part of Ambulant Player, www.ambulantplayer.org. + * + * Copyright (C) 2003-2008 Stichting CWI, + * Kruislaan 413, 1098 SJ Amsterdam, The Netherlands. + * + * Ambulant Player 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. + * + * Ambulant Player 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 Ambulant Player; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * @$Id: dx_audio_player.h,v 1.21 2008/01/15 10:54:48 jackjansen Exp $ + */ + +#ifndef AMBULANT_GUI_DX_AUDIO_PLAYERX_H +#define AMBULANT_GUI_DX_AUDIO_PLAYERX_H + +//#include "ambulant/config/config.h" + +#include <string> +#include <cmath> + +#include <objbase.h> +#include <strmif.h> +#include <control.h> + +#include <initguid.h> + +//#include "ambulant/common/playable.h" +//#include "ambulant/lib/win32/win32_error.h" +//#include "ambulant/lib/logger.h" + +/* +#ifdef _DEBUG +#pragma comment(lib, "msvcrtd.lib") +#else +#pragma comment(lib, "msvcrt.lib") +#endif +*/ + +/* +#ifndef AMBULANT_PLATFORM_WIN32_WCE +#pragma comment (lib,"winmm.lib") +#pragma comment (lib,"amstrmid.lib") +#endif +#pragma comment (lib,"strmiids.lib") +#pragma comment (lib,"uuid.lib") +*/ + +#ifndef AMBULANT_PLATFORM_WIN32_WCE +#define WITH_TPB_AUDIO_SPEEDUP +#endif + +#ifdef WITH_TPB_AUDIO_SPEEDUP +// If this option is active during build (which is true when building +// for AmisAmbulant) we try to insert the TPB Audio Speedup/Slowdown +// filter into our filtergraph. This allows for changing audio playback +// speed without altering pitch. +// If the TPB DirectShow filter is not available we do nothing. +#include <set> + +DEFINE_GUID(CLSID_TPBVupp69, + 0x66172967, 0x56c5, 0x4b89, 0xaa, 0x92, 0xc9, 0xef, 0xec, 0x56, 0x46, 0x7b); + + +#ifdef __cplusplus +extern "C" { +#endif + +// {A33E626E-D6C4-4559-A1D6-9F1D95F0D8E2} +DEFINE_GUID(IID_IVuppInterface, +0xa33e626e, 0xd6c4, 0x4559, 0xa1, 0xd6, 0x9f, 0x1d, 0x95, 0xf0, 0xd8, 0xe2); + +DECLARE_INTERFACE_(IVuppInterface, IUnknown) { + + //Deklarera metoder: + STDMETHOD(setCrossFadeSpeed) + ( THIS_ + double speed + ) PURE; + + STDMETHOD(setWindowLength) + ( THIS_ + int length + ) PURE; + + STDMETHOD(setCycleSpeed) + ( THIS_ + short speed + ) PURE; + + STDMETHOD(setSilenceLoudnessThreshold) + ( THIS_ + short threshold + ) PURE; + + STDMETHOD(setSilenceRemainderLength) + ( THIS_ + short length + ) PURE; + + STDMETHOD(setSilenceSpeed) + ( THIS_ + short speed + ) PURE; + + STDMETHOD(getPosition) + ( THIS_ + LONGLONG &position + ) PURE; +}; + +#ifdef __cplusplus +} +#endif + + + +#endif // WITH_TPB_AUDIO_SPEEDUP + +typedef void (*sendMessageCallbackFn)(void); + +static double s_current_playback_rate = 1.0; + +namespace ambulantX { + +namespace gui { + +namespace dx { + +class audio_playerX { + + typedef std::pair<bool, double> duration; + + public: + + audio_playerX(); + void setCallback(sendMessageCallbackFn pFunction); + + static audio_playerX* Instance(); + static void DestroyInstance(); + + ~audio_playerX(); + + void start(double t); + void stop(bool fromPlay, bool fromThread=false); + //void pause(common::pause_display d=common::display_show); + void pause(void); + void resume(); + void seek(double t); + void endseek(double t); + duration get_dur(); + void wantclicks(bool want) {} + void preroll(double when, double where, double how_much) {} + + bool can_play(); + bool is_playing(); + double get_position(); + + // -val is the attenuation in decibels + // can be 0 to 100 + void set_volume(long val); + + // can be -100 to 100 + // 0 sets a neutral balance + // and 10 sets -10 db to right and -90 db to left + void set_balance(long val); + bool play(const char * url); + + private: + + void end_thread(); + + void release_player(); + + std::string m_url; + + IGraphBuilder *m_graph_builder; + IMediaControl *m_media_control; + IMediaPosition *m_media_position; + IBasicAudio *m_basic_audio; + + HANDLE hEventHandler; + +public: + IMediaEvent *m_media_event; + sendMessageCallbackFn sendMessageCallback; + +private: + + CRITICAL_SECTION m_csSequence; + static audio_playerX* pinstance; + +#ifdef WITH_TPB_AUDIO_SPEEDUP + public: + void set_rate(double rate); + double get_rate(); + + private: + IVuppInterface *m_audio_speedup; + void initialize_speedup_filter(); +#endif +}; + +} // namespace dx + +} // namespace gui + +} // namespace ambulantX + +#endif // AMBULANT_GUI_DX_AUDIO_PLAYERX_H + Added: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/SmilTimeCode.H =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/SmilTimeCode.H (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/SmilTimeCode.H 2008-03-03 04:45:01 UTC (rev 2382) @@ -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/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/counter.H =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/counter.H (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/counter.H 2008-03-03 04:45:01 UTC (rev 2382) @@ -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/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/field.H =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/field.H (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/field.H 2008-03-03 04:45:01 UTC (rev 2382) @@ -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/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/masterCounter.H =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/masterCounter.H (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/masterCounter.H 2008-03-03 04:45:01 UTC (rev 2382) @@ -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/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/masterCounterArray.H =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/masterCounterArray.H (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/masterCounterArray.H 2008-03-03 04:45:01 UTC (rev 2382) @@ -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/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/timeCode.H =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/timeCode.H (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/timeCode.H 2008-03-03 04:45:01 UTC (rev 2382) @@ -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/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/win32fix.H =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/win32fix.H (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/mffmTimeCode/win32fix.H 2008-03-03 04:45:01 UTC (rev 2382) @@ -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 Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-03 04:23:41 UTC (rev 2381) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-03 04:45:01 UTC (rev 2382) @@ -295,6 +295,7 @@ } void AudioSequencePlayer::Play(AudioSequence* audioSequence, bool doNotRegisterInHistory) { + //Stop(); { #ifdef CCS_ACTIVE EnterCriticalSection(&m_csSequence); Added: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp 2008-03-03 04:45:01 UTC (rev 2382) @@ -0,0 +1,696 @@ +// This file is part of Ambulant Player, www.ambulantplayer.org. +// +// Copyright (C) 2003-2008 Stichting CWI, +// Kruislaan 413, 1098 SJ Amsterdam, The Netherlands. +// +// Ambulant Player 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. +// +// Ambulant Player 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 Ambulant Player; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +/* +* @$Id: dx_audio_player.cpp,v 1.22 2008/01/15 10:55:59 jackjansen Exp $ +*/ + +#ifndef __AFXWIN_H__ +#include <afxwin.h> +#endif + +#include "gui/self-voicing/directshow/dx_audio_player.h" + +//#include "ambulant/lib/logger.h" +//#include "ambulant/lib/textptr.h" +#include <math.h> +#include <vfwmsgs.h> +// CLSID_FilterGraph +//#include <uuids.h> +#include <dshow.h> +#ifndef AM_DBG +#define AM_DBG if(0) +#endif + +#include <process.h> + +using namespace ambulantX; + +//using ambulant::lib::win32::win_report_error; +//using ambulant::lib::win32::win_trace_error; +//using ambulant::lib::logger; + +#ifdef WITH_TPB_AUDIO_SPEEDUP +bool speedup_filter_available; +bool speedup_filter_available_valid; +#endif + +#define win_report_error +#define win_trace_error +#define debugX +#define errorX +#define traceX + + +unsigned __stdcall eventHandler(void* lpParam) { +//static DWORD WINAPI eventHandler(LPVOID lpParam) { + long lEventCode, lParam1, lParam2; + HRESULT hResult = E_FAIL; + bool bSelfBreak = false; + + gui::dx::audio_playerX *pPlayer = (gui::dx::audio_playerX*)lpParam; + + while(!bSelfBreak) { + hResult = E_FAIL; + hResult = pPlayer->m_media_event->GetEvent(&lEventCode, &lParam1, &lParam2, INFINITE); + pPlayer->m_media_event->FreeEventParams(lEventCode, lParam1, lParam2); + if (hResult == S_OK) { + switch(lEventCode) { + case EC_COMPLETE: + pPlayer->stop(false, true); + pPlayer->sendMessageCallback(); + bSelfBreak = true; + break; + case EC_USER + 4: + //pPlayer->stop(false, true); + pPlayer->sendMessageCallback(); + bSelfBreak = true; + break; + } + } + } + _endthreadex( 0 ); + return 0; +} + + +gui::dx::audio_playerX::audio_playerX() +: +//m_url(url), +m_graph_builder(0), +m_media_control(0), +m_media_position(0), +m_media_event(0), +#ifdef WITH_TPB_AUDIO_SPEEDUP +m_audio_speedup(0), +#endif +m_basic_audio(0), +hEventHandler(0) +{ + set_rate(1.7); + InitializeCriticalSection(&m_csSequence); +} + +gui::dx::audio_playerX::~audio_playerX() +{ + stop(false); + DeleteCriticalSection(&m_csSequence); +} + +gui::dx::audio_playerX* gui::dx::audio_playerX::pinstance = 0; + +gui::dx::audio_playerX* gui::dx::audio_playerX::Instance() +{ + if (pinstance == 0) // is it the first call? + { + pinstance = new gui::dx::audio_playerX(); // create sole instance + } + return pinstance; // address of sole instance +} +void gui::dx::audio_playerX::DestroyInstance() +{ + if (pinstance) delete pinstance; +} + + +void gui::dx::audio_playerX::start(double t) { + if(is_playing()) pause(); + seek(t); + resume(); +} + +void gui::dx::audio_playerX::end_thread() { + if (hEventHandler==NULL) return; + + IMediaEventSink *pIMES = NULL; + m_graph_builder->QueryInterface(IID_IMediaEventSink, (void**) &pIMES); + pIMES->Notify(EC_USER + 4, 0, 0); + pIMES->Release(); + pIMES = NULL; + + DWORD hr = WaitForSingleObject(hEventHandler, 1000); + switch (hr) { + case WAIT_FAILED: { + int i = 0; + break; + } + + case WAIT_ABANDONED + : { + int i = 0; + break;} + + case WAIT_OBJECT_0 + : { + int i = 0; + break;} + + case WAIT_TIMEOUT: { + int i = 0; + break;} + + } + hEventHandler = NULL; +} + +void gui::dx::audio_playerX::release_player() { + + if(m_graph_builder) { + + if(m_media_event) { + m_media_event->Release(); + m_media_event = 0; + } + if(m_media_position) { + m_media_position->Release(); + m_media_position = 0; + } + if(m_media_control) { + m_media_control->Release(); + m_media_control = 0; + } + if(m_basic_audio) { + m_basic_audio->Release(); + m_basic_audio = 0; + } +#ifdef WITH_TPB_AUDIO_SPEEDUP + if(m_audio_speedup) { + m_audio_speedup->Release(); + m_audio_speedup = 0; + } +#endif + m_graph_builder->Release(); + m_graph_builder = 0; + } +} + +void gui::dx::audio_playerX::stop(bool fromPlay, bool fromThread) { + + + { + if (!fromPlay) { + EnterCriticalSection(&m_csSequence); + } + if(m_media_control == 0) { + LeaveCriticalSection(&m_csSequence); + return; + } + + if (!fromThread) { + end_thread(); + } else { + hEventHandler = NULL; + } + + if (!fromThread) { + HRESULT hr = m_media_control->Stop(); + if(FAILED(hr)) { + win_report_error("IMediaControl::stop()", hr); + } + + if (m_media_control->StopWhenReady() != S_OK) { + long state, i; + + for (i = 0; i < 100; i++) { + m_media_control->GetState(10, &state); + if (state == State_Stopped) break; + } + + if (i == 100) { + int debug = 0; + } + } + } + release_player(); + if (!fromPlay) { + LeaveCriticalSection(&m_csSequence); + } + } +} + +void gui::dx::audio_playerX::pause(void) { + if(m_media_control == 0) return; + HRESULT hr = m_media_control->Pause(); + if(FAILED(hr)) { + win_report_error("IMediaControl::pause()", hr); + } +} + +void gui::dx::audio_playerX::resume() { + if(m_media_control == 0) { + debugX("Invalid call to audio_playerX::run"); + return; + } + HRESULT hr = m_media_control->Run(); + if(FAILED(hr)) { + win_report_error("IMediaControl::run()", hr); + } +} + +void gui::dx::audio_playerX::seek(double t) { + if(m_media_position == 0) return; + HRESULT hr = m_media_position->put_CurrentPosition(REFTIME(t)); + if(FAILED(hr)) + win_report_error("IMediaPosition::put_CurrentPosition()", hr); +} + +void gui::dx::audio_playerX::endseek(double t) { + if(m_media_position == 0) return; + HRESULT hr = m_media_position->put_StopTime(REFTIME(t)); + if(FAILED(hr)) + win_report_error("IMediaPosition::put_StopTime()", hr); +} + +std::pair<bool, double> gui::dx::audio_playerX::get_dur() { + if(m_media_position == 0) { + debugX("Invalid call to audio_playerX::get_duration"); + return std::pair<bool, double>(false, 0); + } + REFTIME dur = 0.0; + HRESULT hr = m_media_position->get_Duration(&dur); + if(FAILED(hr)) { + win_report_error("IMediaPosition::get_Duration()", hr); + return std::pair<bool, double>(false, 0); + } + return std::pair<bool, double>(dur>0, dur); +} + +bool gui::dx::audio_playerX::can_play() { + return m_graph_builder && + m_media_event && + m_media_position && + m_media_control && + m_media_event; +} + +bool gui::dx::audio_playerX::is_playing() { + + EnterCriticalSection(&m_csSequence); + + if(m_media_control == 0) { + LeaveCriticalSection(&m_csSequence);return false;} + + long msTimeout = 0; + long state; + m_media_control->GetState(msTimeout, &state); + + LeaveCriticalSection(&m_csSequence); + + return (state == State_Running); + + /* + + if(m_media_event == 0) { + LeaveCriticalSection(&m_csSequence);return false;} + + long evCode = 0; + HRESULT hr = m_media_event->WaitForCompletion(msTimeout, &evCode); + if(hr == E_ABORT) return true; + else if(hr == S_OK) return false; + else if(FAILED(hr)) { + // XXXJack: this error occurs all the time... + if (hr == 0x80040227) return false; + win_trace_error("IMediaEvent::WaitForCompletion()", hr); + return false; + } + + LeaveCriticalSection(&m_csSequence); + return evCode == 0; + */ +} + +#if 0 +double gui::dx::audio_playerX::get_position() { + if(m_media_position == 0) { + debugX("Invalid call to audio_playerX::get_current_position"); + return 0.0; + } + REFTIME pos = 0.0; + HRESULT hr = m_media_position->get_CurrentPosition(&pos); + if(FAILED(hr)) { + win_report_error("IMediaPosition::get_CurrentPosition()", hr); + return 0.0; + } + return pos; +} +#endif + + +#ifdef WITH_TPB_AUDIO_SPEEDUP +void gui::dx::audio_playerX::initialize_speedup_filter() { + if (speedup_filter_available_valid && !speedup_filter_available) { + // We don't seem to have the filter. Too bad. + return; + } + // Either the filter exists or we haven't tried yet. Let's try to create + // it and remember whether it worked. + IBaseFilter *pNewFilter = NULL; + + + +#ifdef _DEBUG + HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + if (hr == S_FALSE) CoUninitialize(); + _ASSERT(hr == S_FALSE); +#endif + HRESULT res; + res = CoCreateInstance(CLSID_TPBVupp69, NULL, CLSCTX_INPROC_SERVER, + IID_IBaseFilter, (void**)&pNewFilter); + + if (res != S_OK) { + traceX("dx_audio_player: Speedup filter not available, error 0x%x", res); + speedup_filter_available = false; + speedup_filter_available_valid = true; + return; + } + res = m_graph_builder->AddFilter(pNewFilter, NULL); + if (res != S_OK) { + traceX("dx_audio_player: AddFilter(Speedup filter): error 0x%x", res); + pNewFilter->Release(); + return; + } + speedup_filter_available = true; + speedup_filter_available_valid = true; + // AM_DBG lib::debugX("dx_audio_player: added speedup filter to graph"); + + // Next step: find out where we want to add the filter to the graph. + // We iterate over the filter graph, then for each item in the graph + // we iterate over the connected output pins util we find one we like. + IPin *pOutputPin = NULL; + IPin *pInputPin = NULL; + IEnumFilters *pEnumFilters = NULL; + res = m_graph_builder->EnumFilters(&pEnumFilters); + if (res != S_OK) { + traceX("dx_audio_filter: EnumFilters: error 0x%x", res); + return; + } + + IBaseFilter *pCurFilter; + while (pOutputPin == NULL && (res=pEnumFilters->Next(1, &pCurFilter, NULL)) == S_OK) { + AM_DBG { + FILTER_INFO info; + LPWSTR vendorInfo; + res = pCurFilter->QueryFilterInfo(&info); + if (res != S_OK) info.achName[0] = 0; + res = pCurFilter->QueryVendorInfo(&vendorInfo); + if (res != S_OK) vendorInfo = L""; + //ambulant::lib::textptr tInfo(info.achName); + //ambulant::lib::textptr tVendorInfo(vendorInfo); + //lib::debugX("dx_audio_filter: filter found: '%s' vendor '%s'", tInfo.c_str(), tVendorInfo.c_str()); + } + IEnumPins *pEnumPins; + res = pCurFilter->EnumPins(&pEnumPins); + IPin *pCurPin; + while (pOutputPin == NULL && (res=pEnumPins->Next(1, &pCurPin, NULL)) == S_OK) { + AM_MEDIA_TYPE mediaType; + PIN_DIRECTION curPinDir; + res = pCurPin->QueryDirection(&curPinDir); + HRESULT res2 = pCurPin->ConnectionMediaType(&mediaType); + if (res == S_OK && + res2 == S_OK && + curPinDir == PINDIR_OUTPUT && + mediaType.majortype == MEDIATYPE_Audio&& + mediaType.subtype == MEDIASUBTYPE_PCM){ + pOutputPin = pCurPin; + res = pOutputPin->ConnectedTo(&pInputPin); + if (res != S_OK) { + // This output pin was the correct type, but not connected. + // So it cannot be the one we're looking for. + pOutputPin = pInputPin = NULL; + } else { + // Found it! + pOutputPin->AddRef(); + pInputPin->AddRef(); + } + } + if (res2 == S_OK) { + if (mediaType.cbFormat != 0) { + CoTaskMemFree((PVOID)mediaType.pbFormat); + } + } + pCurPin->Release(); + } + if (res != S_FALSE && res != S_OK) + traceX("dx_audio_filter: enumerating pins: error 0x%x", res); + pEnumPins->Release(); + pCurFilter->Release(); + } + if (res != S_... [truncated message content] |
From: <dan...@us...> - 2008-03-03 04:23:35
|
Revision: 2381 http://amis.svn.sourceforge.net/amis/?rev=2381&view=rev Author: daniel_weck Date: 2008-03-02 20:23:41 -0800 (Sun, 02 Mar 2008) Log Message: ----------- some improvements in threading sync, but not robust enough yet (fast moving with mouse over menu usually generates a crash at application exit) Modified Paths: -------------- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 03:41:28 UTC (rev 2380) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 04:23:41 UTC (rev 2381) @@ -69,7 +69,7 @@ #if _DEBUG //get Visual Leak Detector version 1.0 here: http://dmoulding.googlepages.com/downloads -//#include <vld.h> +#include <vld.h> #endif using namespace amis::gui; Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-03 03:41:28 UTC (rev 2380) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-03 04:23:41 UTC (rev 2381) @@ -30,6 +30,10 @@ void AudioSequencePlayer::TTSAudioEndNotify() { + if (m_bAbort) { + return; + } + #ifdef CCS_ACTIVE //EnterCriticalSection(&m_csSequence); #endif @@ -54,7 +58,10 @@ void AudioSequencePlayer::ClipAudioEndNotify() { - + + if (m_bAbort) { + return; + } #ifdef CCS_ACTIVE //EnterCriticalSection(&m_csSequence); #endif @@ -157,6 +164,7 @@ { if (pinstance != NULL) { + m_bAbort = TRUE; Stop(); ambulantX::gui::dx::audio_playerX::Instance()->DestroyInstance(); TTSPlayer::Instance()->DestroyInstance(); @@ -168,14 +176,20 @@ { BOOL rc; _ASSERT(m_hThread != NULL); - _ASSERT(!m_bAbort); - m_bAbort = TRUE; +#ifdef CCS_ACTIVE + EnterCriticalSection(&m_csSequence); +#endif + if (m_previousAudioSequence) delete m_previousAudioSequence; if (m_currentAudioSequence) delete m_currentAudioSequence; if (m_nextAudioSequence) delete m_nextAudioSequence; +#ifdef CCS_ACTIVE + LeaveCriticalSection(&m_csSequence); +#endif + m_wakeUpOriginator = 0; // DESTRUCTOR rc = SetEvent(m_hEventWakeup); _ASSERT(rc); @@ -339,6 +353,8 @@ TRACE(L"\n ---- m_hEventWakeup PLAY\n"); SetEvent(m_hEventWakeup); } + } else { + delete audioSequence; } #ifdef CCS_ACTIVE LeaveCriticalSection(&m_csSequence); @@ -1071,9 +1087,8 @@ }*/ - if (pThis->m_wakeUpOriginator == 3) { - //Sleep(500); - //TRACE(L"AUDIERE SLEEP-"); + if (pThis->m_wakeUpOriginator == 0) { + pThis->m_bAbort = true; } @@ -1084,7 +1099,7 @@ #endif - if (pThis->m_currentAudioSequence != NULL && pThis->m_currentAudioSequence->GetCount() > 0) + if (!pThis->m_bAbort && pThis->m_currentAudioSequence != NULL && pThis->m_currentAudioSequence->GetCount() > 0) { comp = pThis->m_currentAudioSequence->RemoveTail(); @@ -1189,5 +1204,7 @@ } // while ... CoUninitialize(); - return 0; + + _endthreadex( 0 ); + return 0; } \ 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: <dan...@us...> - 2008-03-03 03:41:22
|
Revision: 2380 http://amis.svn.sourceforge.net/amis/?rev=2380&view=rev Author: daniel_weck Date: 2008-03-02 19:41:28 -0800 (Sun, 02 Mar 2008) Log Message: ----------- a few minor fixes, removed the hard-coded self-voicing flag Modified Paths: -------------- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 03:31:51 UTC (rev 2379) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 03:41:28 UTC (rev 2380) @@ -292,9 +292,6 @@ if (did_it_work == amis::OK) { - - amis::Preferences::Instance()->setIsSelfVoicing(false); - //test print to an output file //p_new_data_tree->testPrint("c:\\devel\\amis\\Langpacks\\sandbox\\dataout.txt"); Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-03 03:31:51 UTC (rev 2379) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-03 03:41:28 UTC (rev 2380) @@ -31,14 +31,14 @@ void AudioSequencePlayer::TTSAudioEndNotify() { #ifdef CCS_ACTIVE - EnterCriticalSection(&m_csSequence); + //EnterCriticalSection(&m_csSequence); #endif m_wakeUpOriginator = 2; // TTS END TRACE(L"\n ---- m_hEventWakeup TTS end\n"); SetEvent(m_hEventWakeup); #ifdef CCS_ACTIVE - LeaveCriticalSection(&m_csSequence); + //LeaveCriticalSection(&m_csSequence); #endif /* @@ -56,14 +56,14 @@ void AudioSequencePlayer::ClipAudioEndNotify() { #ifdef CCS_ACTIVE - EnterCriticalSection(&m_csSequence); + //EnterCriticalSection(&m_csSequence); #endif m_wakeUpOriginator = 3; // AUDIO CLIP END TRACE(L"\n ---- m_hEventWakeup AUDIO end\n"); SetEvent(m_hEventWakeup); #ifdef CCS_ACTIVE - LeaveCriticalSection(&m_csSequence); + //LeaveCriticalSection(&m_csSequence); #endif /* if (m_wakeUpAction != 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |