Thread: [Amis-vcs] SF.net SVN: amis: [2223] branches/amis3 (Page 2)
Brought to you by:
julienq,
marisademeglio
From: <mar...@us...> - 2007-11-08 19:33:29
|
Revision: 2223 http://amis.svn.sourceforge.net/amis/?rev=2223&view=rev Author: marisademeglio Date: 2007-11-08 11:33:31 -0800 (Thu, 08 Nov 2007) Log Message: ----------- Debugging skippability (aka "Reading options") problems. Looking at an easy way to store prompt variables (formerly we did this by using a prompt variable resolver, but this is ugly) Modified Paths: -------------- branches/amis3/AmisCore/include/AmisCore.h branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/resource.h branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp branches/amis3/DefaultLangpack/AmisLangpack/AmisLangpack.rc branches/amis3/DefaultLangpack/amisAccessibleUi.xml Added Paths: ----------- branches/amis3/AmisGuiMFC2/include/UiVariables.h branches/amis3/AmisGuiMFC2/src/UiVariables.cpp Modified: branches/amis3/AmisCore/include/AmisCore.h =================================================================== --- branches/amis3/AmisCore/include/AmisCore.h 2007-11-05 22:19:49 UTC (rev 2222) +++ branches/amis3/AmisCore/include/AmisCore.h 2007-11-08 19:33:31 UTC (rev 2223) @@ -76,9 +76,11 @@ //putting hash_map in stdext:: is MSVC-specific typedef stdext::hash_map<std::string, std::string> StringMap; typedef stdext::hash_map<std::string, ambulant::net::url> UrlMap; + typedef stdext::hash_map<std::string, bool> BooleanMap; #elif defined(AMIS_COMPILER_GCC) typedef __gnu_cxx::hash_map<std::string, std::string> StringMap; typedef __gnu_cxx::hash_map<std::string, ambulant::net::url> UrlMap; + typedef __gnu_cxx::hash_map<std::string, bool> BooleanMap; #endif class MediaNode; Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-11-05 22:19:49 UTC (rev 2222) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-11-08 19:33:31 UTC (rev 2223) @@ -283,11 +283,11 @@ mpTitle->setText(p_title_text); mpAuthor = new amis::MediaGroup(); - amis::TextNode p_author_text = new amis::TextNode(); + amis::TextNode* p_author_text = new amis::TextNode(); p_author_text->setTextString(mpMetadata->getMetadata("dc:creator")); mpAuthor->setText(p_author_text); - //TODO: get the audio for the title and author + //TODO: get the audio for the title (author audio not available in Daisy 202) mpFiles->setAdditionalDataAfterInitialParse(this->mUid, NULL, NULL); amis::dtb::nav::ResolveSmilDataVisitor resolve_smil_visitor; Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2007-11-05 22:19:49 UTC (rev 2222) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2007-11-08 19:33:31 UTC (rev 2223) @@ -229,7 +229,7 @@ END POPUP "&Info" BEGIN - MENUITEM "&Skippable Items...", ID_MENU_INFO_SKIP + MENUITEM "&Reading Options...", ID_MENU_INFO_SKIP MENUITEM SEPARATOR MENUITEM "&Full Summary", ID_MENU_INFO_SUMMARY MENUITEM "&Current Position", ID_MENU_INFO_CURRENTPOSITION @@ -250,15 +250,15 @@ IDD_SKIP DIALOGEX 0, 0, 238, 186 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Skippable Items" +CAPTION "Reading options" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - LTEXT "This book contains the following special structures. Check the ones you want skipped.", + LTEXT "This book contains the following special types of items. Checked items will be played. Unchecked items will be skipped.", IDC_STATIC,7,7,224,21 - DEFPUSHBUTTON "OK",IDOK,94,165,50,14 LISTBOX IDC_SKIPS,7,32,224,123,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + DEFPUSHBUTTON "OK",IDOK,94,165,50,14 END IDD_SIDEBAR DIALOGEX 0, 0, 175, 183 @@ -280,19 +280,18 @@ CAPTION "Search for DAISY Books" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN + CONTROL 186,IDC_PICTURE,"Static",SS_BITMAP,7,7,85,79 LTEXT "You can search your computer for DAISY books. Enter a path or browse for a folder to search, then press Search to begin searching.", - IDC_STATIC,105,15,149,9 + IDC_SEARCHINSTRUCTIONS,105,15,149,9 EDITTEXT IDC_SEARCHPATH,108,32,144,14,ES_AUTOHSCROLL PUSHBUTTON "Browse...",IDC_BROWSE,260,34,45,13 PUSHBUTTON "&Search",IDC_STARTSEARCH,141,56,50,15 PUSHBUTTON "S&top",IDC_STOPSEARCH,201,56,50,14 CTEXT "Ready",IDC_SEARCHING,7,92,298,13,NOT WS_VISIBLE - CONTROL "List1",IDC_FILESFOUND,"SysListView32",LVS_LIST | - LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7, - 109,298,152 - PUSHBUTTON "&Open",IDC_OPENBOOK,79,266,50,14 - PUSHBUTTON "Cancel",IDC_CANCELBUTTON,160,266,50,14 - CONTROL 186,IDC_PICTURE,"Static",SS_BITMAP,7,7,86,79 + LISTBOX IDC_FILESFOUND,7,105,298,156,LBS_SORT | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "&Open",IDC_OPENBOOK,103,266,50,14 + PUSHBUTTON "Cancel",IDC_CANCELBUTTON,158,266,50,14 END IDD_LANGUAGES DIALOGEX 0, 0, 229, 223 @@ -302,13 +301,13 @@ BEGIN LTEXT "Here you can change the language of the software. New language packs are detected automatically.", IDC_STATIC,7,7,215,20 - PUSHBUTTON "Select Language",IDC_BTN_SELECTLANG,165,200,57,15 - CONTROL "List1",IDC_LANGLIST,"SysListView32",LVS_SINGLESEL | - LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,77,215,111 + ICON IDI_LANGICON,IDC_LANGICON,7,31,20,20 LTEXT "You are currently using AMIS in",IDC_CURRLANG,34,35,142, 8 - ICON IDI_LANGICON,IDC_LANGICON,7,31,20,20 LTEXT "Your language choices are:",IDC_STATIC,7,57,56,8 + CONTROL "List1",IDC_LANGLIST,"SysListView32",LVS_SINGLESEL | + LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,77,215,111 + PUSHBUTTON "Select Language",IDC_BTN_SELECTLANG,165,200,57,15 END IDD_PREFERENCES DIALOGEX 0, 0, 256, 236 @@ -316,12 +315,11 @@ CAPTION "General Preferences" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - PUSHBUTTON "Browse...",IDC_BMKDIRBROWSE,128,180,43,14,BS_NOTIFY CONTROL "Use self-voicing",IDC_SELFVOICING,"Button", BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,8,8,75,10 + LTEXT "Select TTS voice:",IDC_SELTTSLABEL,7,32,59,8 COMBOBOX IDC_TTSVOICE,7,47,108,88,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - LTEXT "Select TTS voice:",IDC_SELTTSLABEL,7,32,59,8 CONTROL "Start AMIS in the basic view mode.",IDC_BASIC,"Button", BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,7,90,125,10 CONTROL "Upon switching to basic view, tell the user how to go back to the default view.", @@ -330,8 +328,9 @@ CONTROL "Load the most recently read book when the software starts.", IDC_LOADLASTDTB,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,7,147,188,10 - EDITTEXT IDC_BMKDIR,7,180,111,13,ES_AUTOHSCROLL LTEXT "Bookmarks directory:",IDC_BMKDIRLABEL,7,170,67,8 + EDITTEXT IDC_BMKDIR,7,180,111,13,ES_AUTOHSCROLL + PUSHBUTTON "Browse...",IDC_BMKDIRBROWSE,128,180,43,14,BS_NOTIFY END IDD_GOTOPAGE DIALOGEX 0, 0, 138, 66 @@ -350,13 +349,13 @@ CAPTION "Find in Text" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - DEFPUSHBUTTON "OK",IDOK,124,7,50,14 - PUSHBUTTON "&Cancel",IDCANCEL,124,21,50,14 + EDITTEXT IDC_SEARCHSTRING,7,7,106,13,ES_AUTOHSCROLL CONTROL "Find Next",IDC_FINDNEXT,"Button",BS_AUTORADIOBUTTON,19, 27,46,10 CONTROL "Find Previous",IDC_FINDPREV,"Button",BS_AUTORADIOBUTTON, 19,38,59,10 - EDITTEXT IDC_SEARCHSTRING,7,7,106,13,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",IDOK,124,7,50,14 + PUSHBUTTON "&Cancel",IDCANCEL,124,21,50,14 END IDD_CDSEARCH DIALOGEX 0, 0, 253, 180 @@ -366,11 +365,10 @@ BEGIN LTEXT "More than one book was found on this CD. Please select a book from the list below and press Alt + O to open.", IDC_STATIC,7,7,239,18 - CONTROL "List1",IDC_BOOKLIST,"SysListView32",LVS_LIST | - LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7, - 30,239,124 + LISTBOX IDC_BOOKLIST,7,27,239,124,LBS_SORT | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "&Open",IDC_OPENBOOK,71,159,50,14 - PUSHBUTTON "&Cancel",IDC_CANCEL,150,159,50,14 + PUSHBUTTON "&Cancel",IDC_CANCEL,129,159,50,14 END IDD_ABOUTBOX DIALOGEX 0, 0, 235, 97 @@ -381,12 +379,12 @@ ICON IDI_AMIS,IDC_STATIC,11,17,20,20 LTEXT "AMIS: \nAdaptive Multimedia Information System", IDC_AMISNAME,40,10,132,31,SS_NOPREFIX - LTEXT "Copyright \xA9 2008 DAISY for All",IDC_COPYRIGHT,40,82,119, - 8 - DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP LTEXT "Version 3.0 beta",IDC_VERSION,39,44,128,8 LTEXT "Release Date: 01 January 2008",IDC_VERSIONNOTE,40,59, 124,11 + LTEXT "Copyright \xA9 2008 DAISY for All",IDC_COPYRIGHT,40,82,119, + 8 + DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP END IDD_PUBLICATIONINFO DIALOGEX 0, 0, 400, 278 @@ -394,18 +392,16 @@ CAPTION "Publication Summary" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - DEFPUSHBUTTON "OK",IDOK,176,256,50,14 LTEXT "About: TITLE by CREATOR",IDC_DIALOGCAPTION,6,7,387,17 - CONTROL "",IDC_PUBLICATIONINFO,"SysListView32",LVS_LIST | - LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,6,126,387,119, - WS_EX_LEFTSCROLLBAR LTEXT "About your current position:", IDC_CURRENTPOSITIONCAPTION,6,27,387,17 - CONTROL "",IDC_CURRENTPOSITION2,"SysListView32",LVS_LIST | - LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7, - 46,386,47,WS_EX_LEFTSCROLLBAR + LISTBOX IDC_CURRENTPOSITION,6,47,387,49,LBS_SORT | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP LTEXT "About this publication:",IDC_PUBLICATIONINFOCAPTION,6, 107,387,16 + LISTBOX IDC_PUBLICATIONINFO,6,125,387,123,LBS_SORT | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + DEFPUSHBUTTON "OK",IDOK,176,256,50,14 END IDD_OPENURL DIALOGEX 0, 0, 265, 70 @@ -414,11 +410,11 @@ CAPTION "Open URL" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "OK",IDOK,73,49,50,14 - PUSHBUTTON "Cancel",IDCANCEL,127,49,50,14 LTEXT "Enter the URL of the book you want to open:",IDC_STATIC, 7,7,146,8 EDITTEXT IDC_URL,7,26,251,12,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",IDOK,73,49,50,14 + PUSHBUTTON "Cancel",IDCANCEL,127,49,50,14 END Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-11-05 22:19:49 UTC (rev 2222) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-11-08 19:33:31 UTC (rev 2223) @@ -150,6 +150,9 @@ RelativePath=".\include\stdafx.h"> </File> <File + RelativePath=".\include\UiVariables.h"> + </File> + <File RelativePath=".\include\UrlInputSource.h"> <FileConfiguration Name="Debug|Win32"> @@ -320,6 +323,15 @@ UsePrecompiledHeader="0"/> </FileConfiguration> </File> + <File + RelativePath=".\src\UiVariables.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0"/> + </FileConfiguration> + </File> <Filter Name="io" Filter=""> Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.cpp 2007-11-05 22:19:49 UTC (rev 2222) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/DataTree.cpp 2007-11-08 19:33:31 UTC (rev 2223) @@ -17,7 +17,7 @@ void DataTree::DestroyInstance() { - delete pinstance; + if (pinstance != NULL) delete pinstance; } DataTree::DataTree() Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-11-05 22:19:49 UTC (rev 2222) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-11-08 19:33:31 UTC (rev 2223) @@ -109,7 +109,7 @@ void AudioSequencePlayer::DestroyInstance() { Stop(); - delete pinstance; + if (pinstance != NULL) delete pinstance; AmisAudio::Instance()->DestroyInstance(); TTSPlayer::Instance()->DestroyInstance(); Added: branches/amis3/AmisGuiMFC2/include/UiVariables.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/UiVariables.h (rev 0) +++ branches/amis3/AmisGuiMFC2/include/UiVariables.h 2007-11-08 19:33:31 UTC (rev 2223) @@ -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 UIVARIABLES_H +#define UIVARIABLES_H + +#include "AmisCore.h" + +namespace amis +{ +namespace uiVariables +{ +class Conditions +{ +protected: + Conditions(); +public: + static Conditions* Instance(); + DestroyInstance(); + ~Conditions(); + + bool lookupValue(std::string); + void setValue(std::string, bool); + amis::BooleanMap* getValues(); +private: + static Conditions* pinstance(); + amis::BooleanMap mValues; +}; + +class PromptVars +{ +protected: + PromptVars(); +public: + static PromptVars* Instance(); + DestroyInstance(); + ~PromptVars(); +private: + static PromptVars* pinstance(); +}; +} +} +#endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/resource.h =================================================================== --- branches/amis3/AmisGuiMFC2/resource.h 2007-11-05 22:19:49 UTC (rev 2222) +++ branches/amis3/AmisGuiMFC2/resource.h 2007-11-08 19:33:31 UTC (rev 2223) @@ -93,8 +93,9 @@ #define IDC_BORDER 1081 #define IDC_PUBLICATIONINFO 1081 #define IDC_CURRENTPOSITIONCAPTION 1082 -#define IDC_CURRENTPOSITION2 1083 #define IDC_PUBLICATIONINFOCAPTION 1084 +#define IDC_CURRENTPOSITION 1085 +#define IDC_SEARCHINSTRUCTIONS 1088 #define ID_MENU_FIND_IN_TEXT_NEXT 9000 #define IDC_LANGLIST 9001 #define ID_MENU_FIND_IN_TEXT_PREV 9001 @@ -156,8 +157,8 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 191 -#define _APS_NEXT_COMMAND_VALUE 32873 -#define _APS_NEXT_CONTROL_VALUE 1083 +#define _APS_NEXT_COMMAND_VALUE 32875 +#define _APS_NEXT_CONTROL_VALUE 1089 #define _APS_NEXT_SYMED_VALUE 141 #endif #endif Added: branches/amis3/AmisGuiMFC2/src/UiVariables.cpp =================================================================== Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-11-05 22:19:49 UTC (rev 2222) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-11-08 19:33:31 UTC (rev 2223) @@ -257,11 +257,8 @@ amis::gui::MenuManip::Instance()->DestroyInstance(); amis::gui::MainWndParts::Instance()->DestroyInstance(); - if (amis::Preferences::Instance()->mbIsSelfVoicing == true) - { - AudioSequencePlayer::Instance()->DestroyInstance(); DataTree::Instance()->DestroyInstance(); - } + AudioSequencePlayer::Instance()->DestroyInstance(); if (mpRecentBooks) delete mpRecentBooks; Modified: branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2007-11-05 22:19:49 UTC (rev 2222) +++ branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2007-11-08 19:33:31 UTC (rev 2223) @@ -941,6 +941,8 @@ if ((*it).first) { // Only do something on inward iteration lib::node *n = (*it).second; + //we are fiddling with things here...setting systemComponent only works (*should work*) because we are + //messing with something const char *teststr = n->get_attribute("system-required"); if (teststr) { Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp 2007-11-05 22:19:49 UTC (rev 2222) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp 2007-11-08 19:33:31 UTC (rev 2223) @@ -159,9 +159,9 @@ int idx = m_ListSkips.AddString(entry); m_ListSkips.SetItemData(idx,(DWORD)p_test); - //false = skip this item - if (p_test->getCurrentState() == false) m_ListSkips.SetCheck(idx, 1); - else m_ListSkips.SetCheck(idx, 0); + //false = skip this item (display as unchecked) + if (p_test->getCurrentState() == false) m_ListSkips.SetCheck(idx, 0); + else m_ListSkips.SetCheck(idx, 1); } } } @@ -265,9 +265,9 @@ AudioSequencePlayer::Instance()->Play(seq); - //if it's checked, it means we don't want to play it - if (m_ListSkips.GetCheck(i)) p_test->setCurrentState(false); - else p_test->setCurrentState(true); + //if it's checked, it means we want to play it + if (m_ListSkips.GetCheck(i)) p_test->setCurrentState(true); + else p_test->setCurrentState(false); } BEGIN_MESSAGE_MAP(SkipDialog, CDialog) Modified: branches/amis3/DefaultLangpack/AmisLangpack/AmisLangpack.rc =================================================================== (Binary files differ) Modified: branches/amis3/DefaultLangpack/amisAccessibleUi.xml =================================================================== --- branches/amis3/DefaultLangpack/amisAccessibleUi.xml 2007-11-05 22:19:49 UTC (rev 2222) +++ branches/amis3/DefaultLangpack/amisAccessibleUi.xml 2007-11-08 19:33:31 UTC (rev 2223) @@ -1312,21 +1312,22 @@ </mnemonic> </control> </dialog> + <!--text changed--> <dialog mfcid="IDD_SKIP"> - <note>This dialog lets the user control rendering of skippable structures.</note> + <note>This dialog lets the user control rendering of reading options.</note> <caption> - <text>Skippable Items</text> + <text>Reading Options</text> <originalText>Skippable Items</originalText> <audio src="./audio/185_Skippable_Items.mp3" from="file:///c:/devel/amis/Defaultlangpack/prompts/prom00ba.smil#text_00ba" /> </caption> <switch element="description"> <description mfcid="IDC_STATIC" condition="hasSkippableStructures"> - <text>This book contains the following special structures. Check the ones you want skipped.</text> + <text>This book contains the following special types of items. Uncheck an item to turn off playback of all items of that type.</text> <originalText>This book contains the following special structures. Check the ones you want skipped.</originalText> <audio src="./audio/186_This_book_contains_the_followi.mp3" from="file:///c:/devel/amis/Defaultlangpack/prompts/prom00bb.smil#text_00bb" /> </description> <description mfcid="IDC_STATIC" condition="hasNoSkippableStructures"> - <text>This publication has no skippable elements.</text> + <text>This publication has no special reading options.</text> <originalText>This publication has no skippable elements.</originalText> <audio src="./audio/187_This_publication_has_no_skippa.mp3" from="file:///c:/devel/amis/Defaultlangpack/prompts/prom00bc.smil#text_00bc" /> </description> @@ -1347,12 +1348,12 @@ </control> <control mfcid="IDC_SKIPS" widget="list"> <caption> - <text>Skippable items</text> + <text>Reading options</text> <originalText>Skippable items</originalText> <audio src="./audio/188_Skippable_items.mp3" from="file:///c:/devel/amis/Defaultlangpack/prompts/prom00bd.smil#text_00bd" /> </caption> <description> - <text>Use the arrow keys to move around this list of skippable items.</text> + <text>Use the arrow keys to move around this list of reading options.</text> <originalText>Use the arrow keys to move around this list of skippable items.</originalText> <audio src="./audio/189_Use_the_arrow_keys_to_move_aro.mp3" from="file:///c:/devel/amis/Defaultlangpack/prompts/prom00be.smil#text_00be" /> </description> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-11-14 21:30:48
|
Revision: 2226 http://amis.svn.sourceforge.net/amis/?rev=2226&view=rev Author: marisademeglio Date: 2007-11-14 13:30:52 -0800 (Wed, 14 Nov 2007) Log Message: ----------- Search for books dialog works Still needs some UI improvements: - "enter" key annoyingly closes the dialog - double-click doesn't work on the list box to open a title. Also: the book titles aren't being retrieved, only the paths. Modified Paths: -------------- branches/amis3/AmisCore/include/util/SearchForFiles.h branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp branches/amis3/AmisCore/src/util/SearchForFiles.cpp branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp Modified: branches/amis3/AmisCore/include/util/SearchForFiles.h =================================================================== --- branches/amis3/AmisCore/include/util/SearchForFiles.h 2007-11-14 08:20:00 UTC (rev 2225) +++ branches/amis3/AmisCore/include/util/SearchForFiles.h 2007-11-14 21:30:52 UTC (rev 2226) @@ -34,20 +34,23 @@ void setRecursiveSearch(bool); bool isRecursiveSearch(); + //clears search results, search criteria, and search-exclusion criteria + void clearAll(); + void addSearchCriteria(std::string); - amis::StdStringList getSearchCriteria(); + amis::StdStringList* getSearchCriteria(); void clearSearchCriteria(); bool matchesSearchCriteria(std::string); void addSearchExclusionCriteria(std::string); - amis::StdStringList getSearchExclusionCriteria(); + amis::StdStringList* getSearchExclusionCriteria(); void clearSearchExclusionCriteria(); bool matchesSearchExclusionCriteria(std::string); //this function should ONLY be called by implementations of SearchForFiles void addSearchResult(const ambulant::net::url*); - amis::UrlList getSearchResults(); + amis::UrlList* getSearchResults(); void clearSearchResults(); private: Modified: branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-11-14 08:20:00 UTC (rev 2225) +++ branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-11-14 21:30:52 UTC (rev 2226) @@ -246,7 +246,7 @@ mpFileSearcher->setRecursiveSearch(true); mpFileSearcher->startSearch(mBookDirectory.get_file()); - mTextFiles = mpFileSearcher->getSearchResults(); + mTextFiles = (*(mpFileSearcher->getSearchResults())); //if we didn't find any text files, then use the nav file as our text file if (mTextFiles.size() == 0) mTextFiles.push_back(this->mNavFilepath); Modified: branches/amis3/AmisCore/src/util/SearchForFiles.cpp =================================================================== --- branches/amis3/AmisCore/src/util/SearchForFiles.cpp 2007-11-14 08:20:00 UTC (rev 2225) +++ branches/amis3/AmisCore/src/util/SearchForFiles.cpp 2007-11-14 21:30:52 UTC (rev 2226) @@ -57,9 +57,9 @@ mCriteria.push_back(criterion_lower); } -amis::StdStringList amis::util::SearchForFiles::getSearchCriteria() +amis::StdStringList* amis::util::SearchForFiles::getSearchCriteria() { - return mCriteria; + return &mCriteria; } void amis::util::SearchForFiles::addSearchExclusionCriteria(std::string criterion) { @@ -69,9 +69,9 @@ mExclusions.push_back(criterion_lower); } -amis::StdStringList amis::util::SearchForFiles::getSearchExclusionCriteria() +amis::StdStringList* amis::util::SearchForFiles::getSearchExclusionCriteria() { - return mExclusions; + return &mExclusions; } void amis::util::SearchForFiles::clearSearchExclusionCriteria() { @@ -83,7 +83,9 @@ } bool amis::util::SearchForFiles::matchesSearchExclusionCriteria(std::string data) { - return matchesList(data, mExclusions); + //be sure not to return true if the list is empty .. it gives the wrong impression + if (mExclusions.size() == 0) return false; + else return matchesList(data, mExclusions); } bool amis::util::SearchForFiles::matchesList(std::string data, StdStringList list) @@ -111,12 +113,19 @@ mResults.push_back(*searchResult); } -amis::UrlList amis::util::SearchForFiles::getSearchResults() +amis::UrlList* amis::util::SearchForFiles::getSearchResults() { - return mResults; + return &mResults; } void amis::util::SearchForFiles::clearSearchResults() { mResults.clear(); +} + +void amis::util::SearchForFiles::clearAll() +{ + clearSearchCriteria(); + clearSearchExclusionCriteria(); + clearSearchResults(); } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h 2007-11-14 08:20:00 UTC (rev 2225) +++ branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h 2007-11-14 21:30:52 UTC (rev 2226) @@ -17,6 +17,7 @@ SearchForFilesMFC(); ~SearchForFilesMFC(); + //the parameter is a folder path, with or without a trailing slash, e.g. "c:\daisybooks" int startSearch(std::string); void stopSearch(); Modified: branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h 2007-11-14 08:20:00 UTC (rev 2225) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h 2007-11-14 21:30:52 UTC (rev 2226) @@ -38,6 +38,7 @@ public: SearchForBooksDialog(CWnd* pParent = NULL); ~SearchForBooksDialog(); + ambulant::net::url getBookToLoad(); //Dialog Data enum { IDD = IDD_SEARCHDAISY }; protected: Modified: branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp 2007-11-14 08:20:00 UTC (rev 2225) +++ branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp 2007-11-14 21:30:52 UTC (rev 2226) @@ -40,11 +40,14 @@ { USES_CONVERSION; mbShouldStop = false; + std::string search_path = searchPath; clearSearchResults(); - + //make sure it has a trailing slash + if (search_path[search_path.length() - 1] != '\\') search_path += "\\"; + search_path += "*.*"; //call the search routine, which returns the number of files found - return recursiveSearch(A2T(searchPath.c_str())); + return recursiveSearch(A2T(search_path.c_str())); } void SearchForFilesMFC::stopSearch() @@ -61,7 +64,8 @@ int files_found = 0; CString cstr_path = path; - cstr_path.Append(_T("*.*")); + if (cstr_path.GetLength() == 0) return 0; + BOOL b_is_working = finder.FindFile(cstr_path); while (b_is_working) { @@ -99,8 +103,8 @@ } } - amis::UrlList results = getSearchResults(); - return results.size(); + amis::UrlList* results = getSearchResults(); + return results->size(); } //peek at the message queue Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-11-14 08:20:00 UTC (rev 2225) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-11-14 21:30:52 UTC (rev 2226) @@ -316,8 +316,10 @@ return mpRecentBooks; } +//this function is used by all functions here that lead to a book being opened void CAmisGuiMFC2App::openBook(const ambulant::net::url* filename) { + //TODO: AMIS says "TITLE" Playing etc even if the book couldn't be opened MainWndParts::Instance()->updateTitleBar(MainWndParts::TITLEBAR_APPNAME, CString(L"Amis")); MainWndParts::Instance()->updateTitleViewMode(); MainWndParts::Instance()->updateTitleSelfVoicing(Preferences::Instance()->mbIsSelfVoicing); @@ -580,5 +582,9 @@ void CAmisGuiMFC2App::OnSearchForBooks() { dialogs::SearchForBooksDialog search; - search.do_modal(); + if (search.do_modal() == IDOK) + { + ambulant::net::url book_url = search.getBookToLoad(); + this->openBook(&book_url); + } } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp 2007-11-14 08:20:00 UTC (rev 2225) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp 2007-11-14 21:30:52 UTC (rev 2226) @@ -92,21 +92,23 @@ void SearchForBooksDialog::populateListControl() { USES_CONVERSION; - CListCtrl* p_filelist = NULL; - p_filelist = (CListCtrl*)this->GetDlgItem(IDC_FILESFOUND); + CListBox* p_filelist = NULL; + p_filelist = (CListBox*)this->GetDlgItem(IDC_FILESFOUND); - amis::UrlList search_results = mSearcher.getSearchResults(); - - for (int i=0; i<search_results.size(); i++) + amis::UrlList* search_results = mSearcher.getSearchResults(); + amis::UrlList::iterator it; + int i = 0; + for (it = search_results->begin(); it != search_results->end(); ++it) { CString result; - result = A2T(search_results[i].get_url().c_str()); - p_filelist->InsertItem(i, result); + result = A2T(it->get_url().c_str()); + p_filelist->AddString(result); + i++; } - + p_filelist->SetFocus(); - if (search_results.size() == 0) + if (search_results->size() == 0) { CEdit* p_edit = (CEdit*)this->GetDlgItem(IDC_SEARCHPATH); p_edit->SetWindowText(_T("")); @@ -121,19 +123,22 @@ void SearchForBooksDialog::loadBook() { - CListCtrl* p_list = NULL; - p_list = (CListCtrl*)this->GetDlgItem(IDC_FILESFOUND); - int sel = p_list->GetSelectionMark(); - - if (sel > -1 && sel < p_list->GetItemCount()) + CListBox* p_list = NULL; + p_list = (CListBox*)this->GetDlgItem(IDC_FILESFOUND); + int sel = p_list->GetCurSel(); + if (sel > -1 && sel < p_list->GetCount()) { - amis::UrlList search_results = mSearcher.getSearchResults(); - mLoadBookOnDialogClose = search_results[sel]; + amis::UrlList* search_results = mSearcher.getSearchResults(); + mLoadBookOnDialogClose = (*search_results)[sel]; } - this->EndDialog(1); } +ambulant::net::url SearchForBooksDialog::getBookToLoad() +{ + return mLoadBookOnDialogClose; +} + BEGIN_MESSAGE_MAP(SearchForBooksDialog, CDialog) //{{AFX_MSG_MAP(SearchForBooksDialog) ON_WM_PAINT() @@ -186,10 +191,10 @@ mbShouldStopSearching = false; //clear the file list - CListCtrl* p_filelist = NULL; - p_filelist = (CListCtrl*)this->GetDlgItem(IDC_FILESFOUND); - int sz = p_filelist->GetItemCount(); - for (int i=sz - 1; i>=0; i--) p_filelist->DeleteItem(0); + CListBox* p_filelist = NULL; + p_filelist = (CListBox*)this->GetDlgItem(IDC_FILESFOUND); + int sz = p_filelist->GetCount(); + for (int i=sz - 1; i>=0; i--) p_filelist->DeleteString(0); CEdit* p_edit = NULL; p_edit = (CEdit*)this->GetDlgItem(IDC_SEARCHPATH); @@ -200,9 +205,6 @@ if (search_string.IsEmpty() == TRUE) return; - if (search_string[search_string.GetLength() - 1] == '\\') search_string += _T("*.*"); - else search_string += _T("\\*.*"); - //change the text on the side to say "searching" announceStatus(mpCaptionWhileSearching); @@ -214,16 +216,20 @@ p_button->EnableWindow(TRUE); //prepare the search tool - mSearcher.clearSearchResults(); - mSearcher.clearSearchCriteria(); - mSearcher.clearSearchExclusionCriteria(); + mSearcher.clearAll(); mSearcher.addSearchCriteria("ncc.htm"); mSearcher.addSearchCriteria(".opf"); - + //sometimes I see these temp files on my drive .. excluding them just to be safe + mSearcher.addSearchExclusionCriteria("_ncc.html"); + mSearcher.setRecursiveSearch(true); //start the search int files_found = mSearcher.startSearch(T2A(search_string)); populateListControl(); + if (files_found == 0) announceStatus(this->mpCaptionSearchCompleteNoFilesFound); + else if (files_found == 1) announceStatus(this->mpCaptionSearchCompleteOneFileFound); + else announceStatus(this->mpCaptionSearchCompleteFilesFound); + //reverse the gray-out button states p_button = (CButton*)this->GetDlgItem(IDC_STARTSEARCH); p_button->EnableWindow(TRUE); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-11-18 19:59:30
|
Revision: 2227 http://amis.svn.sourceforge.net/amis/?rev=2227&view=rev Author: marisademeglio Date: 2007-11-18 11:59:34 -0800 (Sun, 18 Nov 2007) Log Message: ----------- A bit of cleanup trying to find a memory leak (but the crashing-on-exit in the critical section makes it pretty much impossible) Added VolMaster files which help find the CD Rom drive. Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h branches/amis3/AmisGuiMFC2/include/gui/dialogs/OpenUrlDialog.h branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/GoToPageDialog.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/OpenUrlDialog.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp Added Paths: ----------- branches/amis3/AmisGuiMFC2/include/VolMaster.h branches/amis3/AmisGuiMFC2/src/VolMaster.cpp Removed Paths: ------------- branches/amis3/bin/settings/img/circle.ico branches/amis3/bin/settings/img/daisy.ico branches/amis3/bin/settings/img/daisy_wht.ico branches/amis3/bin/settings/img/keyboard.ico branches/amis3/bin/settings/img/mag.ico branches/amis3/bin/settings/img/minus.ico branches/amis3/bin/settings/img/speak.ico branches/amis3/bin/settings/img/speakno.ico branches/amis3/bin/settings/img/talkingbook.ico branches/amis3/bin/settings/img/talkingbook2.ico Modified: branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h 2007-11-14 21:30:52 UTC (rev 2226) +++ branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h 2007-11-18 19:59:34 UTC (rev 2227) @@ -20,6 +20,7 @@ //the parameter is a folder path, with or without a trailing slash, e.g. "c:\daisybooks" int startSearch(std::string); void stopSearch(); + int startSearchOnCdRom(); private: int recursiveSearch(LPCTSTR); Copied: branches/amis3/AmisGuiMFC2/include/VolMaster.h (from rev 2219, trunk/amis/AmisGuiMFC/ThirdPartyClasses/VolMaster.h) =================================================================== --- branches/amis3/AmisGuiMFC2/include/VolMaster.h (rev 0) +++ branches/amis3/AmisGuiMFC2/include/VolMaster.h 2007-11-18 19:59:34 UTC (rev 2227) @@ -0,0 +1,44 @@ +//////////////////////////////////////////////////////////////// +// MSDN Magazine -- January 2004 +// If this code works, it was written by Paul DiLascia. +// If not, I don't know who wrote it. +// Compiles with Visual Studio .NET on Windows XP. Tab size=3. +// +#pragma once + +////////////////// +// Handly class to encapsulate Windows' logical disk drive functions. +// +class CVolumeMaster { +public: + + // Get bitmask of logical drives--same as Windows fn. + DWORD GetLogicalDrives() + { + return ::GetLogicalDrives(); + } + + // Get drive type--same as Windows fn. + UINT GetDriveType(LPCTSTR lpPath) + { + return ::GetDriveType(lpPath); + } + + // Get logical drive strings as array of CStrings + int GetLogicalDriveStrings(CStringArray& ar); + + // Get volume information using CStrings instead of LPTSTR + BOOL GetVolumeInformation(LPCTSTR drive, // eg, "\\Server\Share" or "C:\" + CString& volname, // volume name (label) + DWORD& VolumeSerialNumber, // volume serial number + DWORD& MaximumComponentLength, // maximum component len (name between \'s) + DWORD& FileSystemFlags, // flags + CString& filesys); // file system--eg FAT or NTFS + + // Handy helpers to get human-readable names of things + static CString FormatDriveType(UINT type); + static CString FormatBitMask(DWORD bitmap, int group=5); + static CString FormatFileSystemFlags(DWORD flags, LPCTSTR sep); +}; + + Modified: branches/amis3/AmisGuiMFC2/include/gui/dialogs/OpenUrlDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/OpenUrlDialog.h 2007-11-14 21:30:52 UTC (rev 2226) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/OpenUrlDialog.h 2007-11-18 19:59:34 UTC (rev 2227) @@ -22,7 +22,6 @@ #ifndef OPENURLDIALOG_H #define OPENURLDIALOG_H - #include <string> #include "gui/dialogs/AmisDialogBase.h" #include "../resource.h" @@ -38,23 +37,18 @@ //DECLARE_DYNAMIC(OpenUrlDialog) public: - OpenUrlDialog(CWnd* pParent = NULL); // standard constructor + OpenUrlDialog(CWnd* pParent = NULL); virtual ~OpenUrlDialog(); virtual BOOL OnInitDialog(); - afx_msg void OnCancel(); - afx_msg void OnClose(); CString getUrl(); -// Dialog Data enum { IDD = IDD_OPENURL }; protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void DoDataExchange(CDataExchange* pDX); CString mUrl; protected: - //{{AFX_MSG(OpenUrlDialog) afx_msg void OnPaint(); - //}}AFX_MSG DECLARE_MESSAGE_MAP() }; } Modified: branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h 2007-11-14 21:30:52 UTC (rev 2226) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h 2007-11-18 19:59:34 UTC (rev 2227) @@ -39,20 +39,17 @@ SearchForBooksDialog(CWnd* pParent = NULL); ~SearchForBooksDialog(); ambulant::net::url getBookToLoad(); - //Dialog Data enum { IDD = IDD_SEARCHDAISY }; protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void DoDataExchange(CDataExchange* pDX); virtual BOOL OnInitDialog(); -protected: - //{{AFX_MSG(SearchForBooksDialog) - afx_msg void OnDblclkFilesfound(NMHDR*, LRESULT*); +protected: + afx_msg void OnDblclkFilesfound(); afx_msg void OnOpenbook(); afx_msg void OnPaint(); afx_msg void OnBrowse(); afx_msg void OnStartsearch(); - afx_msg void OnStopsearch(); - //}}AFX_MSG + afx_msg void OnStopsearch(); DECLARE_MESSAGE_MAP() private: @@ -71,6 +68,8 @@ CString mpCaptionSearchCompleteNoFilesFound; CString mpCaptionSearchCompleteOneFileFound; CString mpCaptionSearchCompleteFilesFound; +public: + virtual BOOL PreTranslateMessage(MSG* pMsg); }; } } Modified: branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp 2007-11-14 21:30:52 UTC (rev 2226) +++ branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp 2007-11-18 19:59:34 UTC (rev 2227) @@ -50,6 +50,28 @@ return recursiveSearch(A2T(search_path.c_str())); } +void SearchForFilesMFC::startSearchOnCdRom() +{ + //find the cdrom drive letter + CVolumeMaster vm; + CStringArray arDrives; + int n = vm.GetLogicalDriveStrings(arDrives); + + CString cd_drive; + + for (int i=0; i<n; i++) + { + if (GetDriveType(arDrives.GetAt(i)) == DRIVE_CDROM) + { + cd_drive = arDrives.GetAt(i); + break; + } + } + + if (cd_drive.IsEmpty() == FALSE) + { +} + void SearchForFilesMFC::stopSearch() { mbShouldStop = true; Copied: branches/amis3/AmisGuiMFC2/src/VolMaster.cpp (from rev 2219, trunk/amis/AmisGuiMFC/ThirdPartyClasses/VolMaster.cpp) =================================================================== --- branches/amis3/AmisGuiMFC2/src/VolMaster.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/src/VolMaster.cpp 2007-11-18 19:59:34 UTC (rev 2227) @@ -0,0 +1,137 @@ +//////////////////////////////////////////////////////////////// +// MSDN Magazine -- January 2004 +// If this code works, it was written by Paul DiLascia. +// If not, I don't know who wrote it. +// Compiles with Visual Studio .NET on Windows XP. Tab size=3. +// +#include "stdafx.h" +#include "VolMaster.h" + +////////////////// +// Get logical drive strings as CStringArray +// +int CVolumeMaster::GetLogicalDriveStrings(CStringArray& ar) +{ + const BUFLEN = 26*4; + TCHAR buf[BUFLEN+1]; + ::GetLogicalDriveStrings(BUFLEN, buf); + + for (LPCTSTR drive=buf; *drive; drive += _tcslen(drive)+1) { + ar.Add(drive); + } + return ar.GetSize(); +} + +////////////////// +// Get logical drive info using CStrings instead of LPTSTR buffers. +// +BOOL CVolumeMaster::GetVolumeInformation(LPCTSTR drive, + CString& volname, + DWORD& VolumeSerialNumber, + DWORD& MaximumComponentLength, + DWORD& FileSystemFlags, + CString& filesys) +{ + BOOL bRet= ::GetVolumeInformation(drive, + volname.GetBuffer(_MAX_FNAME), _MAX_FNAME, + &VolumeSerialNumber, + &MaximumComponentLength, + &FileSystemFlags, + filesys.GetBuffer(_MAX_FNAME), _MAX_FNAME); + volname.ReleaseBuffer(); + filesys.ReleaseBuffer(); + return bRet; +} + +////////////////// +// Convert bitmask to string "0010011011..." etc. +// If group is specified, adds a space every group bits for legibility. +// +CString CVolumeMaster::FormatBitMask(DWORD bitmask, int group) +{ + CString bits; + for (int i=0; i<32; i++) { + bits += (bitmask & 0x1) ? _T('1') : _T('0'); + if (group>0 && i%group+1 == group) + bits += _T(' '); + bitmask>>=1; + } + return bits; +} + +/////////////////// +// Get human-readable drive type. +// +CString CVolumeMaster::FormatDriveType(UINT type) +{ + + const struct { + UINT type; + LPCTSTR name; + } TypeNames[] = { + { DRIVE_UNKNOWN, _T("DRIVE_UNKNOWN") }, + { DRIVE_NO_ROOT_DIR, _T("DRIVE_NO_ROOT_DIR") }, + { DRIVE_REMOVABLE, _T("DRIVE_REMOVABLE") }, + { DRIVE_FIXED, _T("DRIVE_FIXED") }, + { DRIVE_REMOTE, _T("DRIVE_REMOTE") }, + { DRIVE_CDROM, _T("DRIVE_CDROM") }, + { DRIVE_RAMDISK, _T("DRIVE_RAMDISK") }, + { 0, NULL }, + }; + for (int i=0; TypeNames[i].name; i++) { + if (type==TypeNames[i].type) + return TypeNames[i].name; + } + CString str; + str.Format(_T("DRIVE TYPE %d"),type); + return str; +} + +/////////////////// +// Get human-readable FS flags, one per line. +// Adds sep (separator) between flags. +// +CString CVolumeMaster::FormatFileSystemFlags(DWORD flags, LPCTSTR sep) +{ +/* if (flags==0) + return _T("[none]"); + + const struct { + long flag; + LPCTSTR name; + } FlagNames[] = { + { FILE_NAMED_STREAMS, _T("FILE_NAMED_STREAMS") }, + { FILE_READ_ONLY_VOLUME, _T("FILE_READ_ONLY_VOLUME") }, + { FILE_SUPPORTS_OBJECT_IDS, _T("FILE_SUPPORTS_OBJECT_IDS") }, + { FILE_SUPPORTS_REPARSE_POINTS, _T("FILE_SUPPORTS_REPARSE_POINTS") }, + { FILE_SUPPORTS_SPARSE_FILES, _T("FILE_SUPPORTS_SPARSE_FILES") }, + { FILE_VOLUME_QUOTAS, _T("FILE_VOLUME_QUOTAS") }, + { FS_CASE_IS_PRESERVED, _T("FS_CASE_IS_PRESERVED") }, + { FS_CASE_SENSITIVE, _T("FS_CASE_SENSITIVE") }, + { FS_FILE_COMPRESSION, _T("FS_FILE_COMPRESSION") }, + { FS_FILE_ENCRYPTION, _T("FS_FILE_ENCRYPTION") }, + { FS_PERSISTENT_ACLS, _T("FS_PERSISTENT_ACLS") }, + { FS_UNICODE_STORED_ON_DISK, _T("FS_UNICODE_STORED_ON_DISK") }, + { FS_VOL_IS_COMPRESSED, _T("FS_VOL_IS_COMPRESSED") }, + { 0,NULL } + }; + + CString str; + static TCHAR buf[256]={0}; + for (int i=0; FlagNames[i].name; i++) { + if (flags & FlagNames[i].flag) { + str += FlagNames[i].name; + if (sep) + str += sep; + } + } + // remove last separator + str.SetAt(str.GetLength()-_tcslen(sep),0); + return str; + */ + + //we don't use this function right now...no need to formalize this return value + CString dummy = _T("dummy"); + return dummy; +} + Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-11-14 21:30:52 UTC (rev 2226) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-11-18 19:59:34 UTC (rev 2227) @@ -67,9 +67,6 @@ using namespace amis::gui; - -// CAmisGuiMFC2App - BEGIN_MESSAGE_MAP(CAmisGuiMFC2App, CWinApp) ON_COMMAND(ID_MENU_FILE_OPEN, OnFileOpen) ON_COMMAND(ID_MENU_PLAYPAUSE, OnPlayPause) @@ -97,19 +94,14 @@ ON_COMMAND(ID_MENU_FILE_SEARCHDRIVE, OnSearchForBooks) END_MESSAGE_MAP() - -// CAmisGuiMFC2App construction - CAmisGuiMFC2App::CAmisGuiMFC2App() { mpRecentBooks = NULL; } -///////////////////////////////////////////////////////////////////////////// -// The one and only CAmisGuiMFCApp object +//THE APPLICATION! CAmisGuiMFC2App theApp; -// CAmisGuiMFC2App initialization BOOL CAmisGuiMFC2App::InitInstance() { @@ -164,8 +156,7 @@ // 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. - if (!ProcessShellCommand(cmdInfo)) - return FALSE; + if (!ProcessShellCommand(cmdInfo)) return FALSE; // try to load shared MDI menus and accelerator table HINSTANCE hInst = AfxGetResourceHandle(); @@ -200,15 +191,9 @@ p_new_data_tree = DataTree::Instance(); string tmpStr = amis::Preferences::Instance()->mUiLang; - tmpStr = amis::util::FilePathTools::goRelativePath(mAppPath, tmpStr); - tmpStr = amis::util::FilePathTools::goRelativePath(tmpStr, "amisAccessibleUi.xml"); - tmpStr = amis::util::FilePathTools::getAsLocalFilePath(tmpStr); - - //"file:///..../amis/bin/settings/lang/eng-us/amisAccessibleUi.xml" - new_data_reader.setAppPath(mAppPath); amis::ErrorCode did_it_work = new_data_reader.readFile(tmpStr, p_new_data_tree); @@ -218,12 +203,12 @@ //test print to an output file //p_new_data_tree->testPrint("c:\\devel\\amis\\Langpacks\\sandbox\\dataout.txt"); - //DanToDo: This makes sure a clip is played first before any TTS. For some strange CoInitialize order between SAPI-TTS and Vupp, we must play an audio clip first, not a TTS...unless we open a book, in which case the CoInitialize of the IE-HTML view makes things work again !! :-| - AudioSequencePlayer::playPromptFromStringId("canceled"); + //DanToDo: This makes sure a clip is played first before any TTS. For some strange CoInitialize order between SAPI-TTS and Vupp, we must play an audio clip first, not a TTS...unless we open a book, in which case the CoInitialize of the IE-HTML view makes things work again !! :-| + AudioSequencePlayer::playPromptFromStringId("canceled"); - /* + /* AudioSequence* seq = new AudioSequence; - seq->append(L"AMIS"); + seq->append(L"AMIS"); seq->append(L"Text-to-speech engine is ready.Text-to-speech engine is ready.Text-to-speech engine is ready."); seq->append(L"Is it good ?"); AudioSequencePlayer::Instance()->Play(seq); @@ -233,20 +218,16 @@ //todo: a more robust solution should go here: // - what if the user re-enables self voicing via the AMIS prefs? // - what if they switch langpacks? + //maybe we should try to load the default language pack here, and exit if that doesn't work. else { amis::Preferences::Instance()->mbIsSelfVoicing = false; } //} - - return TRUE; } - -// CAmisGuiMFC2App message handlers - int CAmisGuiMFC2App::ExitInstance() { if (m_hMDIMenu != NULL) FreeResource(m_hMDIMenu); Modified: branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2007-11-14 21:30:52 UTC (rev 2226) +++ branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2007-11-18 19:59:34 UTC (rev 2227) @@ -164,8 +164,8 @@ SIZE my_player_callbacks::get_default_size() { SIZE size; - size.cx = 640; - size.cy = 480; + size.cx = 800; + size.cy = 600; return size; } Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/GoToPageDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/GoToPageDialog.cpp 2007-11-14 21:30:52 UTC (rev 2226) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/GoToPageDialog.cpp 2007-11-18 19:59:34 UTC (rev 2227) @@ -39,9 +39,7 @@ void GoToPageDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CGoToPageDialog) DDX_Text(pDX, IDC_PAGENUM, m_PageNumber); - //}}AFX_DATA_MAP } BOOL GoToPageDialog::OnInitDialog() @@ -67,9 +65,7 @@ BEGIN_MESSAGE_MAP(GoToPageDialog, CDialog) - //{{AFX_MSG_MAP(GoToPageDialog) ON_WM_PAINT() - //}}AFX_MSG_MAP END_MESSAGE_MAP() void GoToPageDialog::OnPaint() Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/OpenUrlDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/OpenUrlDialog.cpp 2007-11-14 21:30:52 UTC (rev 2226) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/OpenUrlDialog.cpp 2007-11-18 19:59:34 UTC (rev 2227) @@ -25,6 +25,10 @@ using namespace amis::gui::dialogs; +BEGIN_MESSAGE_MAP(OpenUrlDialog, CDialog) + ON_WM_PAINT() +END_MESSAGE_MAP() + //IMPLEMENT_DYNAMIC(OpenUrlDialog, CDialog) OpenUrlDialog::OpenUrlDialog(CWnd* pParent /*=NULL*/) @@ -43,9 +47,6 @@ } - -// OpenUrlDialog message handlers - BOOL OpenUrlDialog::OnInitDialog() { CDialog::OnInitDialog(); @@ -58,29 +59,12 @@ return FALSE; } -void OpenUrlDialog::OnCancel() -{ - CDialog::OnCancel(); -} - -void OpenUrlDialog::OnClose() -{ - CDialog::OnClose(); -} - CString OpenUrlDialog::getUrl() { return mUrl; } -BEGIN_MESSAGE_MAP(OpenUrlDialog, CDialog) - //{{AFX_MSG_MAP(CCurrentPositionDialog) - ON_WM_CLOSE() - ON_WM_PAINT() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - void OpenUrlDialog::OnPaint() { CPaintDC dc(this); // device context for painting Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp 2007-11-14 21:30:52 UTC (rev 2226) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp 2007-11-18 19:59:34 UTC (rev 2227) @@ -25,9 +25,19 @@ #include "../resource.h" #include "SearchForFilesMFC.h" #include "AmisCore.h" +#include "..\..\..\include\gui\dialogs\searchforbooksdialog.h" using namespace amis::gui::dialogs; +BEGIN_MESSAGE_MAP(SearchForBooksDialog, CDialog) + ON_WM_PAINT() + ON_BN_CLICKED(IDC_BROWSE, OnBrowse) + ON_BN_CLICKED(IDC_STARTSEARCH, OnStartsearch) + ON_BN_CLICKED(IDC_STOPSEARCH, OnStopsearch) + ON_LBN_DBLCLK(IDC_FILESFOUND, OnDblclkFilesfound) + ON_BN_CLICKED(IDC_OPENBOOK, OnOpenbook) +END_MESSAGE_MAP() + SearchForBooksDialog::SearchForBooksDialog(CWnd* pParent /*=NULL*/) : AmisDialogBase(SearchForBooksDialog::IDD) { @@ -139,17 +149,6 @@ return mLoadBookOnDialogClose; } -BEGIN_MESSAGE_MAP(SearchForBooksDialog, CDialog) - //{{AFX_MSG_MAP(SearchForBooksDialog) - ON_WM_PAINT() - ON_BN_CLICKED(IDC_BROWSE, OnBrowse) - ON_BN_CLICKED(IDC_STARTSEARCH, OnStartsearch) - ON_BN_CLICKED(IDC_STOPSEARCH, OnStopsearch) - ON_NOTIFY(NM_DBLCLK, IDC_FILESFOUND, OnDblclkFilesfound) - ON_BN_CLICKED(IDC_OPENBOOK, OnOpenbook) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - void SearchForBooksDialog::OnPaint() { CPaintDC dc(this); // device context for painting @@ -251,7 +250,37 @@ loadBook(); } -void SearchForBooksDialog::OnDblclkFilesfound(NMHDR* w1, LRESULT* w2) +void SearchForBooksDialog::OnDblclkFilesfound() { loadBook(); } + +BOOL amis::gui::dialogs::SearchForBooksDialog::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) + { + //if the textbox has focus and the user pressed enter, start searching + if (id == IDC_SEARCHPATH) + { + pMsg->wParam = NULL; + OnStartsearch(); + } + //if the files list has focus, open the selected book + else if (id == IDC_FILESFOUND) + { + pMsg->wParam = NULL; + loadBook(); + } + } + } + } + return AmisDialogBase::PreTranslateMessage(pMsg); +} Modified: branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp 2007-11-14 21:30:52 UTC (rev 2226) +++ branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp 2007-11-18 19:59:34 UTC (rev 2227) @@ -37,39 +37,31 @@ using namespace amis::gui::sidebar; +BEGIN_MESSAGE_MAP(CAmisSidebar, cdxCDynamicBarDlg) + ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnSelchangeTab) + ON_NOTIFY(TVN_SELCHANGED, IDC_TREE, OnSelchangeTree) + ON_NOTIFY(NM_CLICK, IDC_LIST_PAGE, OnPageListClick) + ON_NOTIFY(LVN_KEYDOWN, IDC_LIST_PAGE, OnPageListKeyDown) +END_MESSAGE_MAP() + CAmisSidebar::CAmisSidebar(CWnd* pParent /*=NULL*/) : cdxCDynamicBarDlg(CAmisSidebar::IDD, pParent) { - //{{AFX_DATA_INIT(CAmisSidebar) - m_iSel = -1; - //}}AFX_DATA_INIT m_iSel = 0; } CAmisSidebar::~CAmisSidebar() { + clearAll(); mImagesForTab.DeleteImageList(); } - -BEGIN_MESSAGE_MAP(CAmisSidebar, cdxCDynamicBarDlg) - //{{AFX_MSG_MAP(CAmisSidebar) - ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnSelchangeTab) - ON_NOTIFY(TVN_SELCHANGED, IDC_TREE, OnSelchangeTree) - ON_NOTIFY(NM_CLICK, IDC_LIST_PAGE, OnPageListClick) - ON_NOTIFY(LVN_KEYDOWN, IDC_LIST_PAGE, OnPageListKeyDown) - //}}AFX_MSG_MAP - -END_MESSAGE_MAP() - void CAmisSidebar::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAmisSidebar) DDX_Control(pDX, IDC_TAB, m_wndTab); DDX_Control(pDX, IDC_TREE, m_wndTree); DDX_Control(pDX, IDC_LIST_PAGE, m_wndPageList); - //}}AFX_DATA_MAP } void CAmisSidebar::clearAll() @@ -361,7 +353,7 @@ { } - //idea: amis should play an audio prompt for the chosen list + //TODO: amis should play an audio prompt for the chosen list } void CAmisSidebar::showNavMap() @@ -373,7 +365,7 @@ m_wndPageList.ShowWindow(SW_HIDE); m_wndTree.SetFocus(); this->RedrawWindow(); - //then amis should play an audio prompt "sections" + //TODO: amis should play an audio prompt "sections" } CNavListControl* CAmisSidebar::addNavListWidget() Deleted: branches/amis3/bin/settings/img/circle.ico =================================================================== (Binary files differ) Deleted: branches/amis3/bin/settings/img/daisy.ico =================================================================== (Binary files differ) Deleted: branches/amis3/bin/settings/img/daisy_wht.ico =================================================================== (Binary files differ) Deleted: branches/amis3/bin/settings/img/keyboard.ico =================================================================== (Binary files differ) Deleted: branches/amis3/bin/settings/img/mag.ico =================================================================== (Binary files differ) Deleted: branches/amis3/bin/settings/img/minus.ico =================================================================== (Binary files differ) Deleted: branches/amis3/bin/settings/img/speak.ico =================================================================== (Binary files differ) Deleted: branches/amis3/bin/settings/img/speakno.ico =================================================================== (Binary files differ) Deleted: branches/amis3/bin/settings/img/talkingbook.ico =================================================================== (Binary files differ) Deleted: branches/amis3/bin/settings/img/talkingbook2.ico =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-11-18 21:51:42
|
Revision: 2228 http://amis.svn.sourceforge.net/amis/?rev=2228&view=rev Author: marisademeglio Date: 2007-11-18 13:51:45 -0800 (Sun, 18 Nov 2007) Log Message: ----------- Added load from cd function Modified Paths: -------------- branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp Added Paths: ----------- branches/amis3/AmisGuiMFC2/include/gui/dialogs/MultipleBooksOnVolumeDialog.h branches/amis3/AmisGuiMFC2/include/util/ branches/amis3/AmisGuiMFC2/include/util/SearchForFilesMFC.h branches/amis3/AmisGuiMFC2/include/util/VolMaster.h branches/amis3/AmisGuiMFC2/src/gui/dialogs/MultipleBooksOnVolumeDialog.cpp branches/amis3/AmisGuiMFC2/src/util/ branches/amis3/AmisGuiMFC2/src/util/SearchForFilesMFC.cpp branches/amis3/AmisGuiMFC2/src/util/VolMaster.cpp Removed Paths: ------------- branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h branches/amis3/AmisGuiMFC2/include/VolMaster.h branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp branches/amis3/AmisGuiMFC2/src/VolMaster.cpp Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-11-18 21:51:45 UTC (rev 2228) @@ -190,6 +190,7 @@ } loadBookmarks(mpFiles->getBookmarksFilepath()); + return true; } //-------------------------------------------------- Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2007-11-18 21:51:45 UTC (rev 2228) @@ -368,7 +368,7 @@ LISTBOX IDC_BOOKLIST,7,27,239,124,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "&Open",IDC_OPENBOOK,71,159,50,14 - PUSHBUTTON "&Cancel",IDC_CANCEL,129,159,50,14 + PUSHBUTTON "&Cancel",IDCANCEL,129,159,50,14 END IDD_ABOUTBOX DIALOGEX 0, 0, 235, 97 Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-11-18 21:51:45 UTC (rev 2228) @@ -144,9 +144,6 @@ RelativePath=".\include\Preferences.h"> </File> <File - RelativePath=".\include\SearchForFilesMFC.h"> - </File> - <File RelativePath=".\include\stdafx.h"> </File> <File @@ -221,6 +218,9 @@ RelativePath=".\include\gui\dialogs\GoToPageDialog.h"> </File> <File + RelativePath=".\include\gui\dialogs\MultipleBooksOnVolumeDialog.h"> + </File> + <File RelativePath=".\include\gui\dialogs\OpenUrlDialog.h"> </File> <File @@ -271,6 +271,16 @@ </File> </Filter> </Filter> + <Filter + Name="util" + Filter=""> + <File + RelativePath=".\include\util\SearchForFilesMFC.h"> + </File> + <File + RelativePath=".\include\util\VolMaster.h"> + </File> + </Filter> </Filter> <Filter Name="src" @@ -309,9 +319,6 @@ </FileConfiguration> </File> <File - RelativePath=".\src\SearchForFilesMFC.cpp"> - </File> - <File RelativePath=".\src\stdafx.cpp"> <FileConfiguration Name="Debug|Win32"> @@ -499,6 +506,9 @@ </FileConfiguration> </File> <File + RelativePath=".\src\gui\dialogs\MultipleBooksOnVolumeDialog.cpp"> + </File> + <File RelativePath=".\src\gui\dialogs\OpenUrlDialog.cpp"> <FileConfiguration Name="Release|Win32"> @@ -639,6 +649,16 @@ </File> </Filter> </Filter> + <Filter + Name="util" + Filter=""> + <File + RelativePath=".\src\util\SearchForFilesMFC.cpp"> + </File> + <File + RelativePath=".\src\util\VolMaster.cpp"> + </File> + </Filter> </Filter> <Filter Name="SelfVoicing" Modified: branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2007-11-18 21:51:45 UTC (rev 2228) @@ -25,7 +25,7 @@ #include "dtb/Dtb.h" -#include "SearchForFilesMFC.h" +#include "util/SearchForFilesMFC.h" namespace amis { Deleted: branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h 2007-11-18 21:51:45 UTC (rev 2228) @@ -1,32 +0,0 @@ -#ifndef SEARCHFORFILESMFC_H -#define SEARCHFORFILESMFC_H - -#include <string> -#include <vector> -#include "stdafx.h" -#include "util/SearchForFiles.h" - -using namespace std; -namespace amis -{ -namespace util -{ -class SearchForFilesMFC : public amis::util::SearchForFiles -{ -public: - SearchForFilesMFC(); - ~SearchForFilesMFC(); - - //the parameter is a folder path, with or without a trailing slash, e.g. "c:\daisybooks" - int startSearch(std::string); - void stopSearch(); - int startSearchOnCdRom(); - -private: - int recursiveSearch(LPCTSTR); - void doEvents(); - bool mbShouldStop; -}; -} -} -#endif \ No newline at end of file Deleted: branches/amis3/AmisGuiMFC2/include/VolMaster.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/VolMaster.h 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisGuiMFC2/include/VolMaster.h 2007-11-18 21:51:45 UTC (rev 2228) @@ -1,44 +0,0 @@ -//////////////////////////////////////////////////////////////// -// MSDN Magazine -- January 2004 -// If this code works, it was written by Paul DiLascia. -// If not, I don't know who wrote it. -// Compiles with Visual Studio .NET on Windows XP. Tab size=3. -// -#pragma once - -////////////////// -// Handly class to encapsulate Windows' logical disk drive functions. -// -class CVolumeMaster { -public: - - // Get bitmask of logical drives--same as Windows fn. - DWORD GetLogicalDrives() - { - return ::GetLogicalDrives(); - } - - // Get drive type--same as Windows fn. - UINT GetDriveType(LPCTSTR lpPath) - { - return ::GetDriveType(lpPath); - } - - // Get logical drive strings as array of CStrings - int GetLogicalDriveStrings(CStringArray& ar); - - // Get volume information using CStrings instead of LPTSTR - BOOL GetVolumeInformation(LPCTSTR drive, // eg, "\\Server\Share" or "C:\" - CString& volname, // volume name (label) - DWORD& VolumeSerialNumber, // volume serial number - DWORD& MaximumComponentLength, // maximum component len (name between \'s) - DWORD& FileSystemFlags, // flags - CString& filesys); // file system--eg FAT or NTFS - - // Handy helpers to get human-readable names of things - static CString FormatDriveType(UINT type); - static CString FormatBitMask(DWORD bitmap, int group=5); - static CString FormatFileSystemFlags(DWORD flags, LPCTSTR sep); -}; - - Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-11-18 21:51:45 UTC (rev 2228) @@ -93,6 +93,8 @@ afx_msg void OnResetFontSize(); afx_msg void OnToggleContrast(); afx_msg void OnSearchForBooks(); + afx_msg void OnLoadCd(); + protected: HMENU m_hMDIMenu; HACCEL m_hMDIAccel; Added: branches/amis3/AmisGuiMFC2/include/gui/dialogs/MultipleBooksOnVolumeDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/MultipleBooksOnVolumeDialog.h (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/MultipleBooksOnVolumeDialog.h 2007-11-18 21:51:45 UTC (rev 2228) @@ -0,0 +1,62 @@ +/* +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 MULTIPLEBOOKSONVOLUMEDIALOG_H +#define MULTIPLEBOOKSONVOLUMEDIALOG_H + +#include "gui/dialogs/AmisDialogBase.h" +#include "../resource.h" +#include "ambulant/net/url.h" +#include "AmisCore.h" + +namespace amis +{ +namespace gui +{ +namespace dialogs +{ +class MultipleBooksOnVolumeDialog : public AmisDialogBase +{ +public: + //the pUrlList parameter has a default value only because the compiler requires it + MultipleBooksOnVolumeDialog(CWnd* pParent = NULL, amis::UrlList* pUrlList = NULL); + ~MultipleBooksOnVolumeDialog(); + ambulant::net::url getBookToLoad(); + enum { IDD = IDD_CDSEARCH }; + virtual BOOL PreTranslateMessage(MSG* pMsg); +protected: + virtual BOOL OnInitDialog(); + afx_msg void OnDblclkFilelist(); + afx_msg void OnOpenbook(); + afx_msg void OnPaint(); + DECLARE_MESSAGE_MAP() + +private: + void populateListControl(); + void loadBook(); + + ambulant::net::url mLoadBookOnDialogClose; + amis::UrlList* mpUrlList; +}; +} +} +} +#endif Modified: branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h 2007-11-18 21:51:45 UTC (rev 2228) @@ -24,7 +24,7 @@ #include "gui/dialogs/AmisDialogBase.h" #include "../resource.h" -#include "SearchForFilesMFC.h" +#include "util/SearchForFilesMFC.h" #include "ambulant/net/url.h" namespace amis @@ -41,10 +41,9 @@ ambulant::net::url getBookToLoad(); enum { IDD = IDD_SEARCHDAISY }; protected: - virtual void DoDataExchange(CDataExchange* pDX); virtual BOOL OnInitDialog(); protected: - afx_msg void OnDblclkFilesfound(); + afx_msg void OnDblclkFilelist(); afx_msg void OnOpenbook(); afx_msg void OnPaint(); afx_msg void OnBrowse(); Copied: branches/amis3/AmisGuiMFC2/include/util/SearchForFilesMFC.h (from rev 2227, branches/amis3/AmisGuiMFC2/include/SearchForFilesMFC.h) =================================================================== --- branches/amis3/AmisGuiMFC2/include/util/SearchForFilesMFC.h (rev 0) +++ branches/amis3/AmisGuiMFC2/include/util/SearchForFilesMFC.h 2007-11-18 21:51:45 UTC (rev 2228) @@ -0,0 +1,32 @@ +#ifndef SEARCHFORFILESMFC_H +#define SEARCHFORFILESMFC_H + +#include <string> +#include <vector> +#include "stdafx.h" +#include "util/SearchForFiles.h" + +using namespace std; +namespace amis +{ +namespace util +{ +class SearchForFilesMFC : public amis::util::SearchForFiles +{ +public: + SearchForFilesMFC(); + ~SearchForFilesMFC(); + + //the parameter is a folder path, with or without a trailing slash, e.g. "c:\daisybooks" + int startSearch(std::string); + void stopSearch(); + int startSearchOnCdRom(); + +private: + int recursiveSearch(LPCTSTR); + void doEvents(); + bool mbShouldStop; +}; +} +} +#endif \ No newline at end of file Copied: branches/amis3/AmisGuiMFC2/include/util/VolMaster.h (from rev 2227, branches/amis3/AmisGuiMFC2/include/VolMaster.h) =================================================================== --- branches/amis3/AmisGuiMFC2/include/util/VolMaster.h (rev 0) +++ branches/amis3/AmisGuiMFC2/include/util/VolMaster.h 2007-11-18 21:51:45 UTC (rev 2228) @@ -0,0 +1,44 @@ +//////////////////////////////////////////////////////////////// +// MSDN Magazine -- January 2004 +// If this code works, it was written by Paul DiLascia. +// If not, I don't know who wrote it. +// Compiles with Visual Studio .NET on Windows XP. Tab size=3. +// +#pragma once + +////////////////// +// Handly class to encapsulate Windows' logical disk drive functions. +// +class CVolumeMaster { +public: + + // Get bitmask of logical drives--same as Windows fn. + DWORD GetLogicalDrives() + { + return ::GetLogicalDrives(); + } + + // Get drive type--same as Windows fn. + UINT GetDriveType(LPCTSTR lpPath) + { + return ::GetDriveType(lpPath); + } + + // Get logical drive strings as array of CStrings + int GetLogicalDriveStrings(CStringArray& ar); + + // Get volume information using CStrings instead of LPTSTR + BOOL GetVolumeInformation(LPCTSTR drive, // eg, "\\Server\Share" or "C:\" + CString& volname, // volume name (label) + DWORD& VolumeSerialNumber, // volume serial number + DWORD& MaximumComponentLength, // maximum component len (name between \'s) + DWORD& FileSystemFlags, // flags + CString& filesys); // file system--eg FAT or NTFS + + // Handy helpers to get human-readable names of things + static CString FormatDriveType(UINT type); + static CString FormatBitMask(DWORD bitmap, int group=5); + static CString FormatFileSystemFlags(DWORD flags, LPCTSTR sep); +}; + + Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-11-18 21:51:45 UTC (rev 2228) @@ -90,7 +90,6 @@ { CString title = p_txt->getTextString().c_str(); title.Trim(); - //DanToDo: title text seems to be empty with HELP DTB. Not initialized properly in the backend parser ? amis::gui::MainWndParts::Instance()->updateTitleBar(amis::gui::MainWndParts::TITLEBAR_BOOKTITLE, title); } } Deleted: branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp 2007-11-18 21:51:45 UTC (rev 2228) @@ -1,149 +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 "stdafx.h" -#include "util/SearchForFiles.h" -#include "SearchForFilesMFC.h" -#include "ambulant/net/url.h" - -using namespace amis::util; - -SearchForFilesMFC::SearchForFilesMFC() -{ - mbShouldStop = false; -} - -SearchForFilesMFC::~SearchForFilesMFC() -{ - clearSearchResults(); -} - -int SearchForFilesMFC::startSearch(std::string searchPath) -{ - USES_CONVERSION; - mbShouldStop = false; - std::string search_path = searchPath; - - clearSearchResults(); - //make sure it has a trailing slash - if (search_path[search_path.length() - 1] != '\\') search_path += "\\"; - search_path += "*.*"; - //call the search routine, which returns the number of files found - return recursiveSearch(A2T(search_path.c_str())); -} - -void SearchForFilesMFC::startSearchOnCdRom() -{ - //find the cdrom drive letter - CVolumeMaster vm; - CStringArray arDrives; - int n = vm.GetLogicalDriveStrings(arDrives); - - CString cd_drive; - - for (int i=0; i<n; i++) - { - if (GetDriveType(arDrives.GetAt(i)) == DRIVE_CDROM) - { - cd_drive = arDrives.GetAt(i); - break; - } - } - - if (cd_drive.IsEmpty() == FALSE) - { -} - -void SearchForFilesMFC::stopSearch() -{ - mbShouldStop = true; -} - -int SearchForFilesMFC::recursiveSearch(LPCTSTR path) -{ - USES_CONVERSION; - - CFileFind finder; - CString filename; - int files_found = 0; - - CString cstr_path = path; - if (cstr_path.GetLength() == 0) return 0; - - BOOL b_is_working = finder.FindFile(cstr_path); - while (b_is_working) - { - b_is_working = finder.FindNextFile(); - - // handle messages - doEvents(); - - // received a stop signal - if (mbShouldStop == true) break; - - if (finder.IsDots()) continue; - - // if it's a directory, recursively search it - if (finder.IsDirectory() && isRecursiveSearch()) - { - CString str = finder.GetFilePath(); - files_found += recursiveSearch(str + _T("\\*.*")); - } - else - { - filename = finder.GetFileName(); - std::string str_filename = T2A(filename); - if (matchesSearchCriteria(str_filename) && !matchesSearchExclusionCriteria(str_filename)) - { - files_found++; - //save the file path - CString file_path = finder.GetFilePath(); - std::string file_path_string = T2A(file_path); - //TODO - //we assume that the search returns local files - ambulant::net::url file_path_url = ambulant::net::url::from_filename(file_path_string); - addSearchResult(&file_path_url); - } - } - } - - amis::UrlList* results = getSearchResults(); - return results->size(); -} - -//peek at the message queue -void SearchForFilesMFC::doEvents() -{ - MSG msg; - - while ( ::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE ) ) - { - if ( ::GetMessage(&msg, NULL, 0, 0)) - { - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - } - else - { - break; - } - } -} \ No newline at end of file Deleted: branches/amis3/AmisGuiMFC2/src/VolMaster.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/VolMaster.cpp 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisGuiMFC2/src/VolMaster.cpp 2007-11-18 21:51:45 UTC (rev 2228) @@ -1,137 +0,0 @@ -//////////////////////////////////////////////////////////////// -// MSDN Magazine -- January 2004 -// If this code works, it was written by Paul DiLascia. -// If not, I don't know who wrote it. -// Compiles with Visual Studio .NET on Windows XP. Tab size=3. -// -#include "stdafx.h" -#include "VolMaster.h" - -////////////////// -// Get logical drive strings as CStringArray -// -int CVolumeMaster::GetLogicalDriveStrings(CStringArray& ar) -{ - const BUFLEN = 26*4; - TCHAR buf[BUFLEN+1]; - ::GetLogicalDriveStrings(BUFLEN, buf); - - for (LPCTSTR drive=buf; *drive; drive += _tcslen(drive)+1) { - ar.Add(drive); - } - return ar.GetSize(); -} - -////////////////// -// Get logical drive info using CStrings instead of LPTSTR buffers. -// -BOOL CVolumeMaster::GetVolumeInformation(LPCTSTR drive, - CString& volname, - DWORD& VolumeSerialNumber, - DWORD& MaximumComponentLength, - DWORD& FileSystemFlags, - CString& filesys) -{ - BOOL bRet= ::GetVolumeInformation(drive, - volname.GetBuffer(_MAX_FNAME), _MAX_FNAME, - &VolumeSerialNumber, - &MaximumComponentLength, - &FileSystemFlags, - filesys.GetBuffer(_MAX_FNAME), _MAX_FNAME); - volname.ReleaseBuffer(); - filesys.ReleaseBuffer(); - return bRet; -} - -////////////////// -// Convert bitmask to string "0010011011..." etc. -// If group is specified, adds a space every group bits for legibility. -// -CString CVolumeMaster::FormatBitMask(DWORD bitmask, int group) -{ - CString bits; - for (int i=0; i<32; i++) { - bits += (bitmask & 0x1) ? _T('1') : _T('0'); - if (group>0 && i%group+1 == group) - bits += _T(' '); - bitmask>>=1; - } - return bits; -} - -/////////////////// -// Get human-readable drive type. -// -CString CVolumeMaster::FormatDriveType(UINT type) -{ - - const struct { - UINT type; - LPCTSTR name; - } TypeNames[] = { - { DRIVE_UNKNOWN, _T("DRIVE_UNKNOWN") }, - { DRIVE_NO_ROOT_DIR, _T("DRIVE_NO_ROOT_DIR") }, - { DRIVE_REMOVABLE, _T("DRIVE_REMOVABLE") }, - { DRIVE_FIXED, _T("DRIVE_FIXED") }, - { DRIVE_REMOTE, _T("DRIVE_REMOTE") }, - { DRIVE_CDROM, _T("DRIVE_CDROM") }, - { DRIVE_RAMDISK, _T("DRIVE_RAMDISK") }, - { 0, NULL }, - }; - for (int i=0; TypeNames[i].name; i++) { - if (type==TypeNames[i].type) - return TypeNames[i].name; - } - CString str; - str.Format(_T("DRIVE TYPE %d"),type); - return str; -} - -/////////////////// -// Get human-readable FS flags, one per line. -// Adds sep (separator) between flags. -// -CString CVolumeMaster::FormatFileSystemFlags(DWORD flags, LPCTSTR sep) -{ -/* if (flags==0) - return _T("[none]"); - - const struct { - long flag; - LPCTSTR name; - } FlagNames[] = { - { FILE_NAMED_STREAMS, _T("FILE_NAMED_STREAMS") }, - { FILE_READ_ONLY_VOLUME, _T("FILE_READ_ONLY_VOLUME") }, - { FILE_SUPPORTS_OBJECT_IDS, _T("FILE_SUPPORTS_OBJECT_IDS") }, - { FILE_SUPPORTS_REPARSE_POINTS, _T("FILE_SUPPORTS_REPARSE_POINTS") }, - { FILE_SUPPORTS_SPARSE_FILES, _T("FILE_SUPPORTS_SPARSE_FILES") }, - { FILE_VOLUME_QUOTAS, _T("FILE_VOLUME_QUOTAS") }, - { FS_CASE_IS_PRESERVED, _T("FS_CASE_IS_PRESERVED") }, - { FS_CASE_SENSITIVE, _T("FS_CASE_SENSITIVE") }, - { FS_FILE_COMPRESSION, _T("FS_FILE_COMPRESSION") }, - { FS_FILE_ENCRYPTION, _T("FS_FILE_ENCRYPTION") }, - { FS_PERSISTENT_ACLS, _T("FS_PERSISTENT_ACLS") }, - { FS_UNICODE_STORED_ON_DISK, _T("FS_UNICODE_STORED_ON_DISK") }, - { FS_VOL_IS_COMPRESSED, _T("FS_VOL_IS_COMPRESSED") }, - { 0,NULL } - }; - - CString str; - static TCHAR buf[256]={0}; - for (int i=0; FlagNames[i].name; i++) { - if (flags & FlagNames[i].flag) { - str += FlagNames[i].name; - if (sep) - str += sep; - } - } - // remove last separator - str.SetAt(str.GetLength()-_tcslen(sep),0); - return str; - */ - - //we don't use this function right now...no need to formalize this return value - CString dummy = _T("dummy"); - return dummy; -} - Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-11-18 21:51:45 UTC (rev 2228) @@ -22,16 +22,15 @@ #include "stdafx.h" #include "../resource.h" +#include "AmisCore.h" +#include "util/FilePathTools.h" +#include "Preferences.h" +#include "io/RecentBooksFileIO.h" #include "pdtb.h" - #include "dtb/nav/NavModel.h" - #include "DtbWithHooks.h" -#include "Preferences.h" -#include "io/RecentBooksFileIO.h" - #include "gui/AmisGuiMFC2.h" #include "gui/MainFrm.h" #include "gui/ChildFrm.h" @@ -40,18 +39,16 @@ #include "gui/MmView.h" #include "gui/MenuManip.h" #include "gui/TextRenderBrain.h" - #include "gui/sidebar/AmisSidebar.h" #include "gui/sidebar/AmisSidebarLoader.h" - #include "gui/dialogs/AmisFileDialog.h" #include "gui/dialogs/AboutDialog.h" #include "gui/dialogs/OpenUrlDialog.h" #include "gui/dialogs/SkipDialog.h" #include "gui/dialogs/GoToPageDialog.h" #include "gui/dialogs/SearchForBooksDialog.h" +#include "gui/dialogs/MultipleBooksOnVolumeDialog.h" -#include "util/FilePathTools.h" //#include "../AmisAudio/AmisAudio.h" //using namespace amis::audio; @@ -92,6 +89,7 @@ ON_COMMAND(ID_MENU_VIEW_LARGEFONT, OnIncreaseFontSize) ON_COMMAND(ID_MENU_VIEW_RESETFONT, OnResetFontSize) ON_COMMAND(ID_MENU_FILE_SEARCHDRIVE, OnSearchForBooks) + ON_COMMAND(ID_MENU_FILE_LOADCD, OnLoadCd) END_MESSAGE_MAP() CAmisGuiMFC2App::CAmisGuiMFC2App() @@ -568,4 +566,39 @@ ambulant::net::url book_url = search.getBookToLoad(); this->openBook(&book_url); } +} + +void CAmisGuiMFC2App::OnLoadCd() +{ + util::SearchForFilesMFC searcher; + //prepare the search tool + searcher.clearAll(); + searcher.addSearchCriteria("ncc.htm"); + searcher.addSearchCriteria(".opf"); + //sometimes I see these temp files on my drive .. excluding them just to be safe + searcher.addSearchExclusionCriteria("_ncc.html"); + searcher.setRecursiveSearch(true); + + int num_books = searcher.startSearchOnCdRom(); + + //TODO: localize this string + if (num_books == 0) AfxMessageBox(_T("No files found on this CD-ROM")); + else + { + amis::UrlList* p_results = searcher.getSearchResults(); + if (p_results->size() > 1) + { + dialogs::MultipleBooksOnVolumeDialog dlg(NULL, p_results); + if (dlg.do_modal() == IDOK) + { + openBook(&dlg.getBookToLoad()); + } + } + else + { + //open the first and only URL found + openBook(&(*p_results)[0]); + } + } + } \ No newline at end of file Added: branches/amis3/AmisGuiMFC2/src/gui/dialogs/MultipleBooksOnVolumeDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/MultipleBooksOnVolumeDialog.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/MultipleBooksOnVolumeDialog.cpp 2007-11-18 21:51:45 UTC (rev 2228) @@ -0,0 +1,139 @@ +/* +AMIS: Adaptive Multimedia Information System +Software for playing DAISY books +Homepage: http://amis.sf.net + +Copyright (C) 2004-2007 DAISY for All Project + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "stdafx.h" +#include "gui/dialogs/MultipleBooksOnVolumeDialog.h" +#include "../resource.h" +#include "AmisCore.h" + +using namespace amis::gui::dialogs; + +BEGIN_MESSAGE_MAP(MultipleBooksOnVolumeDialog, CDialog) + ON_WM_PAINT() + ON_LBN_DBLCLK(IDC_BOOKLIST, OnDblclkFilelist) + ON_BN_CLICKED(IDC_OPENBOOK, OnOpenbook) +END_MESSAGE_MAP() + +MultipleBooksOnVolumeDialog::MultipleBooksOnVolumeDialog(CWnd* pParent /*=NULL*/, amis::UrlList* pUrlList) + : AmisDialogBase(MultipleBooksOnVolumeDialog::IDD) +{ + mpUrlList = pUrlList; +} + +MultipleBooksOnVolumeDialog::~MultipleBooksOnVolumeDialog() +{ +} + +BOOL MultipleBooksOnVolumeDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + populateListControl(); + //set focus to the listbox + CWnd* p_control = NULL; + p_control = GetDlgItem(IDC_BOOKLIST); + if (p_control) + { + p_control->SetFocus(); + return FALSE; + } + // return TRUE unless you set the focus to a control + else return TRUE; +} + +//TODO: fill in titles, not URLs +void MultipleBooksOnVolumeDialog::populateListControl() +{ + USES_CONVERSION; + CListBox* p_filelist = NULL; + p_filelist = (CListBox*)this->GetDlgItem(IDC_BOOKLIST); + + amis::UrlList::iterator it; + int i = 0; + for (it = mpUrlList->begin(); it != mpUrlList->end(); ++it) + { + CString result; + result = A2T(it->get_url().c_str()); + p_filelist->AddString(result); + i++; + } + + p_filelist->SetFocus(); + CButton* p_button = (CButton*)this->GetDlgItem(IDC_OPENBOOK); + p_button->EnableWindow(TRUE); +} + +void MultipleBooksOnVolumeDialog::loadBook() +{ + CListBox* p_list = NULL; + p_list = (CListBox*)this->GetDlgItem(IDC_BOOKLIST); + int sel = p_list->GetCurSel(); + if (sel > -1 && sel < mpUrlList->size()) mLoadBookOnDialogClose = (*mpUrlList)[sel]; + this->EndDialog(1); +} + +ambulant::net::url MultipleBooksOnVolumeDialog::getBookToLoad() +{ + return mLoadBookOnDialogClose; +} + +void MultipleBooksOnVolumeDialog::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(); +} + +void MultipleBooksOnVolumeDialog::OnOpenbook() +{ + loadBook(); +} + +void MultipleBooksOnVolumeDialog::OnDblclkFilelist() +{ + loadBook(); +} + +BOOL MultipleBooksOnVolumeDialog::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) + { + //if the files list has focus, open the selected book + if (id == IDC_BOOKLIST) + { + pMsg->wParam = NULL; + loadBook(); + } + } + } + } + return AmisDialogBase::PreTranslateMessage(pMsg); +} Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp 2007-11-18 19:59:34 UTC (rev 2227) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp 2007-11-18 21:51:45 UTC (rev 2228) @@ -23,9 +23,8 @@ #include "stdafx.h" #include "gui/dialogs/SearchForBooksDialog.h" #include "../resource.h" -#include "SearchForFilesMFC.h" +#include "util/SearchForFilesMFC.h" #include "AmisCore.h" -#include "..\..\..\include\gui\dialogs\searchforbooksdialog.h" using namespace amis::gui::dialogs; @@ -34,7 +33,7 @@ ON_BN_CLICKED(IDC_BROWSE, OnBrowse) ON_BN_CLICKED(IDC_STARTSEARCH, OnStartsearch) ON_BN_CLICKED(IDC_STOPSEARCH, OnStopsearch) - ON_LBN_DBLCLK(IDC_FILESFOUND, OnDblclkFilesfound) + ON_LBN_DBLCLK(IDC_FILESFOUND, OnDblclkFilelist) ON_BN_CLICKED(IDC_OPENBOOK, OnOpenbook) END_MESSAGE_MAP() @@ -56,14 +55,6 @@ { } -void SearchForBooksDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(SearchForBooks) - - //}}AFX_DATA_MAP -} - BOOL SearchForBooksDialog::OnInitDialog() { CDialog::OnInitDialog(); @@ -105,10 +96,10 @@ CListBox* p_filelist = NULL; p_filelist = (CListBox*)this->GetDlgItem(IDC_FILESFOUND); - amis::UrlList* search_results = mSearcher.getSearchResults(); + amis::UrlList* p_search_results = mSearcher.getSearchResults(); amis::UrlList::iterator it; int i = 0; - for (it = search_results->begin(); it != search_results->end(); ++it) + for (it = p_search_results->begin(); it != p_search_results->end(); ++it) { CString result; result = A2T(it->get_url().c_str()); @@ -118,7 +109,7 @@ p_filelist->SetFocus(); - if (search_results->size() == 0) + if (p_search_results->size() == 0) { CEdit* p_edit = (CEdit*)this->GetDlgItem(IDC_SEARCHPATH); p_edit->SetWindowText(_T("")); @@ -136,11 +127,8 @@ CListBox* p_list = NULL; p_list = (CListBox*)this->GetDlgItem(IDC_FILESFOUND); int sel = p_list->GetCurSel(); - if (sel > -1 && sel < p_list->GetCount()) - { - amis::UrlList* search_results = mSearcher.getSearchResults(); - mLoadBookOnDialogClose = (*search_results)[sel]; - } + amis::UrlList* p_search_results = mSearcher.getSearchResults(); + if (sel > -1 && sel < p_search_results->size()) mLoadBookOnDialogClose = (*p_search_results)[sel]; this->EndDialog(1); } @@ -250,12 +238,12 @@ loadBook(); } -void SearchForBooksDialog::OnDblclkFilesfound() +void SearchForBooksDialog::OnDblclkFilelist() { loadBook(); } -BOOL amis::gui::dialogs::SearchForBooksDialog::PreTranslateMessage(MSG* pMsg) +BOOL SearchForBooksDialog::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) { Copied: branches/amis3/AmisGuiMFC2/src/util/SearchForFilesMFC.cpp (from rev 2227, branches/amis3/AmisGuiMFC2/src/SearchForFilesMFC.cpp) =================================================================== --- branches/amis3/AmisGuiMFC2/src/util/SearchForFilesMFC.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/src/util/SearchForFilesMFC.cpp 2007-11-18 21:51:45 UTC (rev 2228) @@ -0,0 +1,155 @@ +/* +AMIS: Adaptive Multimedia Information System +Software for playing DAISY books +Homepage: http://amis.sf.net + +Copyright (C) 2004-2007 DAISY for All Project + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#include "stdafx.h" +#include "util/SearchForFiles.h" +#include "util/SearchForFilesMFC.h" +#include "ambulant/net/url.h" +#include "util/VolMaster.h" + +using namespace amis::util; + +SearchForFilesMFC::SearchForFilesMFC() +{ + mbShouldStop = false; +} + +SearchForFilesMFC::~SearchForFilesMFC() +{ + clearSearchResults(); +} + +int SearchForFilesMFC::startSearch(std::string searchPath) +{ + USES_CONVERSION; + mbShouldStop = false; + std::string search_path = searchPath; + + clearSearchResults(); + //make sure it has a trailing slash + if (search_path[search_path.length() - 1] != '\\') search_path += "\\"; + search_path += "*.*"; + //call the search routine, which returns the number of files found + return recursiveSearch(A2T(search_path.c_str())); +} + +int SearchForFilesMFC::startSearchOnCdRom() +{ + USES_CONVERSION; + //find the cdrom drive letter + CVolumeMaster vm; + CStringArray arDrives; + int n = vm.GetLogicalDriveStrings(arDrives); + CString cd_drive; + int files_found = 0; + + for (int i=0; i<n; i++) + { + if (GetDriveType(arDrives.GetAt(i)) == DRIVE_CDROM) + { + cd_drive = arDrives.GetAt(i); + break; + } + } + + if (cd_drive.IsEmpty() == FALSE) + { + files_found = startSearch(T2A(cd_drive)); + } + + return files_found; +} + +void SearchForFilesMFC::stopSearch() +{ + mbShouldStop = true; +} + +int SearchForFilesMFC::recursiveSearch(LPCTSTR path) +{ + USES_CONVERSION; + + CFileFind finder; + CString filename; + int files_found = 0; + + CString cstr_path = path; + if (cstr_path.GetLength() == 0) return 0; + + BOOL b_is_working = finder.FindFile(cstr_path); + while (b_is_working) + { + b_is_working = finder.FindNextFile(); + + // handle messages + doEvents(); + + // received a stop signal + if (mbShouldStop == true) break; + + if (finder.IsDots()) continue; + + // if it's a directory, recursively search it + if (finder.IsDirectory() && isRecursiveSearch()) + { + CString str = finder.GetFilePath(); + files_found += recursiveSearch(str + _T("\\*.*")); + } + else + { + filename = finder.GetFileName(); + std::string str_filename = T2A(filename); + if (matchesSearchCriteria(str_filename) && !matchesSearchExclusionCriteria(str_filename)) + { + files_found++; + //save the file path + CString file_path = finder.GetFilePath(); + std::string file_path_string = T2A(file_path); + //TODO + //we assume that the search returns local files + ambulant::net::url file_path_url = ambulant::net::url::from_filename(file_path_string); + addSearchResult(&file_path_url); + } + } + } + + amis::UrlList* results = getSearchResults(); + return results->size(); +} + +//peek at the message queue +void SearchForFilesMFC::doEvents() +{ + MSG msg; + + while ( ::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE ) ) + { + if ( ::GetMessage(&msg, NULL, 0, 0)) + { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + else + { + break; + } + } +} \ No newline at end of file Copied: branches/amis3/AmisGuiMFC2/src/util/VolMaster.cpp (from rev 2227, branches/amis3/AmisGuiMFC2/src/VolMaster.cpp) =================================================================== --- branches/amis3/AmisGuiMFC2/src/util/VolMaster.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/src/util/VolMaster.cpp 2007-11-18 21:51:45 UTC (rev 2228) @@ -0,0 +1,137 @@ +//////////////////////////////////////////////////////////////// +// MSDN Magazine -- January 2004 +// If this code works, it was written by Paul DiLascia. +// If not, I don't know who wrote it. +// Compiles with Visual Studio .NET on Windows XP. Tab size=3. +// +#include "stdafx.h" +#include "util/VolMaster.h" + +////////////////// +// Get logical drive strings as CStringArray +// +int CVolumeMaster::GetLogicalDriveStrings(CStringArray& ar) +{ + const BUFLEN = 26*4; + TCHAR buf[BUFLEN+1]; + ::GetLogicalDriveStrings(BUFLEN, buf); + + for (LPCTSTR drive=buf; *drive; drive += _tcslen(drive)+1) { + ar.Add(drive); + } + return ar.GetSize(); +} + +////////////////// +// Get logical drive info using CStrings instead of LPTSTR buffers. +// +BOOL CVolumeMaster::GetVolumeInformation(LPCTSTR drive, + CString& volname, + DWORD& VolumeSerialNumber, + DWORD& MaximumComponentLength, + DWORD& FileSystemFlags, + CString& filesys) +{ + BOOL bRet= ::GetVolumeInformation(drive, + volname.GetBuffer(_MAX_FNAME), _MAX_FNAME, + &VolumeSerialNumber, + &MaximumComponentLength, + &FileSystemFlags, + filesys.GetBuffer(_MAX_FNAME), _MAX_FNAME); + volname.ReleaseBuffer(); + filesys.ReleaseBuffer(); + return bRet; +} + +////////////////// +// Convert bitmask to string "0010011011..." etc. +// If group is specified, adds a space every group bits for legibility. +// +CString CVolumeMaster::FormatBitMask(DWORD bitmask, int group) +{ + CString bits; + for (int i=0; i<32; i++) { + bits += (bitmask & 0x1) ? _T('1') : _T('0'); + if (group>0 && i%group+1 == group) + bits += _T(' '); + bitmask>>=1; + } + return bits; +} + +/////////////////// +// Get human-readable drive type. +// +CString CVolumeMaster::FormatDriveType(UINT type) +{ + + const struct { + UINT type; + LPCTSTR name; + } TypeNames[] = { + { DRIVE_UNKNOWN, _T("DRIVE_UNKNOWN") }, + { DRIVE_NO_ROOT_DIR, _T("DRIVE_NO_ROOT_DIR") }, + { DRIVE_REMOVABLE, _T("DRIVE_REMOVABLE") }, + { DRIVE_FIXED, _T("DRIVE_FIXED") }, + { DRIVE_REMOTE, _T("DRIVE_REMOTE") }, + { DRIVE_CDROM, _T("DRIVE_CDROM") }, + { DRIVE_RAMDISK, _T("DRIVE_RAMDISK") }, + { 0, NULL }, + }; + for (int i=0; TypeNames[i].name; i++) { + if (type==TypeNames[i].type) + return TypeNames[i].name; + } + CString str; + str.Format(_T("DRIVE TYPE %d"),type); + return str; +} + +/////////////////// +// Get human-readable FS flags, one per line. +// Adds sep (separator) between flags. +// +CString CVolumeMaster::FormatFileSystemFlags(DWORD flags, LPCTSTR sep) +{ +/* if (flags==0) + return _T("[none]"); + + const struct { + long flag; + LPCTSTR name; + } FlagNames[] = { + { FILE_NAMED_STREAMS, _T("FILE_NAMED_STREAMS") }, + { FILE_READ_ONLY_VOLUME, _T("FILE_READ_ONLY_VOLUME") }, + { FILE_SUPPORTS_OBJECT_IDS, _T("FILE_SUPPORTS_OBJECT_IDS") }, + { FILE_SUPPORTS_REPARSE_POINTS, _T("FILE_SUPPORTS_REPARSE_POINTS") }, + { FILE_SUPPORTS_SPARSE_FILES, _T("FILE_SUPPORTS_SPARSE_FILES") }, + { FILE_VOLUME_QUOTAS, _T("FILE_VOLUME_QUOTAS") }, + { FS_CASE_IS_PRESERVED, _T("FS_CASE_IS_PRESERVED") }, + { FS_CASE_SENSITIVE, _T("FS_CASE_SENSITIVE") }, + { FS_FILE_COMPRESSION, _T("FS_FILE_COMPRESSION") }, + { FS_FILE_ENCRYPTION, _T("FS_FILE_ENCRYPTION") }, + { FS_PERSISTENT_ACLS, _T("FS_PERSISTENT_ACLS") }, + { FS_UNICODE_STORED_ON_DISK, _T("FS_UNICODE_STORED_ON_DISK") }, + { FS_VOL_IS_COMPRESSED, _T("FS_VOL_IS_COMPRESSED") }, + { 0,NULL } + }; + + CString str; + static TCHAR buf[256]={0}; + for (int i=0; FlagNames[i].name; i++) { + if (flags & FlagNames[i].flag) { + str += FlagNames[i].name; + if (sep) + str += sep; + } + } + // remove last separator + str.SetAt(str.GetLength()-_tcslen(sep),0); + return str; + */ + + //we don't use this function right now...no need to formalize this return value + CString dummy = _T("dummy"); + return dummy; +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-11-19 08:23:22
|
Revision: 2232 http://amis.svn.sourceforge.net/amis/?rev=2232&view=rev Author: marisademeglio Date: 2007-11-19 00:23:24 -0800 (Mon, 19 Nov 2007) Log Message: ----------- - Organized CSS files into folders. We will need a CSS parser (!) - Preferences get read from a file now - Prefs dialog simplified but not implemented yet - Moved Self-voicing/accessible UI data tree initialization to AmisGuiMFC2::initPathsAndFiles() function. Modified Paths: -------------- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h branches/amis3/AmisGuiMFC2/include/Preferences.h branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h branches/amis3/AmisGuiMFC2/include/io/PreferencesFileIO.h branches/amis3/AmisGuiMFC2/include/util/SearchForFilesMFC.h branches/amis3/AmisGuiMFC2/include/util/VolMaster.h branches/amis3/AmisGuiMFC2/resource.h branches/amis3/AmisGuiMFC2/src/Preferences.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp branches/amis3/AmisGuiMFC2/src/util/SearchForFilesMFC.cpp branches/amis3/AmisGuiMFC2/src/util/VolMaster.cpp branches/amis3/bin/settings/amisPrefs.xml.default branches/amis3/bin/settings/css/contrast/contrast1.css branches/amis3/bin/settings/css/contrast/contrast2.css branches/amis3/bin/settings/css/contrast/contrast3.css branches/amis3/bin/settings/css/default.css branches/amis3/bin/settings/css/font/font1.css branches/amis3/bin/settings/css/font/font2.css branches/amis3/bin/settings/css/font/font3.css branches/amis3/bin/settings/css/font/font4.css Added Paths: ----------- branches/amis3/AmisGuiMFC2/include/util/Color.h branches/amis3/AmisGuiMFC2/src/util/Color.cpp branches/amis3/bin/settings/css/dtbook.2005.basic.css Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2007-11-19 08:23:24 UTC (rev 2232) @@ -320,17 +320,12 @@ LTEXT "Select TTS voice:",IDC_SELTTSLABEL,7,32,59,8 COMBOBOX IDC_TTSVOICE,7,47,108,88,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - CONTROL "Start AMIS in the basic view mode.",IDC_BASIC,"Button", - BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,7,90,125,10 - CONTROL "Upon switching to basic view, tell the user how to go back to the default view.", - IDC_PROMPTONBASICVIEW,"Button",BS_AUTOCHECKBOX | - BS_MULTILINE | BS_NOTIFY | WS_TABSTOP,7,115,223,15 - CONTROL "Load the most recently read book when the software starts.", - IDC_LOADLASTDTB,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | - WS_TABSTOP,7,147,188,10 - LTEXT "Bookmarks directory:",IDC_BMKDIRLABEL,7,170,67,8 - EDITTEXT IDC_BMKDIR,7,180,111,13,ES_AUTOHSCROLL - PUSHBUTTON "Browse...",IDC_BMKDIRBROWSE,128,180,43,14,BS_NOTIFY + CONTROL "Pause AMIS when I switch to another program.", + IDC_PAUSEONLOSTFOCUS,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,7,77,164,10 + CONTROL "Load the most recently read book when AMIS starts.", + IDC_LOADLASTDTB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, + 106,181,10 END IDD_GOTOPAGE DIALOGEX 0, 0, 138, 66 Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2007-11-19 08:23:24 UTC (rev 2232) @@ -275,6 +275,9 @@ Name="util" Filter=""> <File + RelativePath=".\include\util\Color.h"> + </File> + <File RelativePath=".\include\util\SearchForFilesMFC.h"> </File> <File @@ -653,6 +656,9 @@ Name="util" Filter=""> <File + RelativePath=".\src\util\Color.cpp"> + </File> + <File RelativePath=".\src\util\SearchForFilesMFC.cpp"> </File> <File Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp 2007-11-19 08:23:24 UTC (rev 2232) @@ -49,7 +49,7 @@ string DataReader::getIniFilePath() { if (! mIniFilePath.empty()) return mIniFilePath; - mIniFilePath = amis::Preferences::Instance()->mUiLang; + mIniFilePath = amis::Preferences::Instance()->mUiLangDir; mIniFilePath = amis::util::FilePathTools::goRelativePath(mAppPath, mIniFilePath); mIniFilePath = amis::util::FilePathTools::goRelativePath(mIniFilePath, "resource.h.ini"); mIniFilePath = amis::util::FilePathTools::getAsLocalFilePath(mIniFilePath); Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-11-19 08:23:24 UTC (rev 2232) @@ -287,7 +287,7 @@ //string audio_dir = AUDIO_DIR; //audio_prompts_file = amis::FilePathTools::goRelativePath(audio_prompts_file, audio_dir); - string tmpStr = amis::Preferences::Instance()->mUiLang; + string tmpStr = amis::Preferences::Instance()->mUiLangDir; //CAmisGuiMFC2App* pApp = (CAmisGuiMFC2App *) AfxGetApp(); tmpStr = amis::util::FilePathTools::goRelativePath(theApp.getAppPath(), tmpStr); Modified: branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2007-11-19 08:23:24 UTC (rev 2232) @@ -23,9 +23,8 @@ #ifndef DtbWithHooks_H #define DtbWithHooks_H - -#include "dtb/Dtb.h" #include "util/SearchForFilesMFC.h" +#include "dtb/Dtb.h" namespace amis { Modified: branches/amis3/AmisGuiMFC2/include/Preferences.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/Preferences.h 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/include/Preferences.h 2007-11-19 08:23:24 UTC (rev 2232) @@ -22,29 +22,14 @@ #ifndef PREFERENCES_H #define PREFERENCES_H -#include <string> #include "stdafx.h" +#include "ambulant/net/url.h" +#include "util/Color.h" +#include <string> +#include "AmisCore.h" namespace amis { -class Color -{ -private: - COLORREF mColor; - std::string mColorHtml; -public: - Color(std::string); - Color(COLORREF); - void set(std::string); - void set(COLORREF); - COLORREF getAsColorRef(); - std::string getAsHtmlColor(); -private: - COLORREF htmlToRgb(std::string); - int _httoi(const TCHAR *value); - std::string getColorAsHtmlValue(COLORREF); -}; - class Preferences { protected: @@ -54,24 +39,16 @@ static Preferences* Instance(); void DestroyInstance(); ~Preferences(); + void scanDirectoriesForCssFiles(); - void resetColors(); - //app/general - std::string mUiLang; + string mUiLangDir; bool mbStartBasicView; - std::string mUserBmkDir; + string mUserBmkDir; bool mbLoadLastDtb; bool mbPromptOnBasicView; bool mbPauseOnApplicationLostFocus; - std::string mDefaultTocFont; - //Color - Color* mpTextBG; - Color* mpTextFG; - Color* mpPageBG; - Color* mpPageFG; - //Self Voicing bool mbIsSelfVoicing; int mTTSVoice; @@ -80,8 +57,22 @@ //did AMIS exit cleanly last time? bool mbExitWasClean; - std::string mSourceFilePath; + //CSS files + //directories get scanned, files are applied in alphabetical order + string mFontsizeCssDir; + amis::UrlList mFontsizeCssFiles; + string mContrastCssDir; + amis::UrlList mContrastCssFiles; + //one single default CSS file for user-preferred styles + ambulant::net::url mDefaultCssFile; + ambulant::net::url mSourceUrl; + + //these values come from parsing default.css + util::Color mDefaultHighlightFG; + util::Color mDefaultHighlightBG; + std::string mDefaultFontName; + private: static Preferences* pinstance; Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2007-11-19 08:23:24 UTC (rev 2232) @@ -21,6 +21,8 @@ */ // AmisGuiMFC2.h : main header file for the AmisGuiMFC2 application // +#ifndef AMISGUIMFC2_H +#define AMISGUIMFC2_H #pragma once #ifndef __AFXWIN_H__ @@ -37,16 +39,10 @@ #include "gui/MainFrm.h" #include "RecentBooks.h" -#include "../../AmisSelfVoicing\AudioSequencePlayer.h" - +#include "../../AmisSelfVoicing/AudioSequencePlayer.h" #include "../../AmisSelfVoicing/AccessibleUi/AccessibleUIDataReader.h" #define WITH_DAISY_PDTB - -// CAmisGuiMFC2App: -// See AmisGuiMFC2.cpp for the implementation of this class -// - #define MAX_ANYTHING 49 namespace amis @@ -65,7 +61,6 @@ std::string getAppPath(); amis::RecentBooks* getRecentBooks(); - void setPauseState(bool play); //Menu handlers @@ -117,4 +112,5 @@ } } -extern amis::gui::CAmisGuiMFC2App theApp; \ No newline at end of file +extern amis::gui::CAmisGuiMFC2App theApp; +#endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/SearchForBooksDialog.h 2007-11-19 08:23:24 UTC (rev 2232) @@ -22,9 +22,9 @@ #ifndef SEARCHFORBOOKSDIALOG_H #define SEARCHFORBOOKSDIALOG_H +#include "util/SearchForFilesMFC.h" #include "gui/dialogs/AmisDialogBase.h" #include "../resource.h" -#include "util/SearchForFilesMFC.h" #include "ambulant/net/url.h" namespace amis Modified: branches/amis3/AmisGuiMFC2/include/io/PreferencesFileIO.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/io/PreferencesFileIO.h 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/include/io/PreferencesFileIO.h 2007-11-19 08:23:24 UTC (rev 2232) @@ -64,7 +64,7 @@ /*end of sax methods*/ private: - void writeAll(); + void writeData(); DOMElement* createEntry(std::string, std::string); DOMElement* createEntry(std::string, bool); Added: branches/amis3/AmisGuiMFC2/include/util/Color.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/util/Color.h (rev 0) +++ branches/amis3/AmisGuiMFC2/include/util/Color.h 2007-11-19 08:23:24 UTC (rev 2232) @@ -0,0 +1,52 @@ +/* +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 COLOR_H +#define COLOR_H + +#include <string> + +namespace amis +{ +namespace util +{ +class Color +{ +private: + COLORREF mColor; + std::string mColorHtml; +public: + Color(); + Color(std::string); + Color(COLORREF); + void set(std::string); + void set(COLORREF); + COLORREF getAsColorRef(); + std::string getAsHtmlColor(); +private: + COLORREF htmlToRgb(std::string); + int _httoi(const TCHAR *value); + std::string getColorAsHtmlValue(COLORREF); +}; +} +} +#endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/include/util/SearchForFilesMFC.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/util/SearchForFilesMFC.h 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/include/util/SearchForFilesMFC.h 2007-11-19 08:23:24 UTC (rev 2232) @@ -1,12 +1,31 @@ +/* +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 SEARCHFORFILESMFC_H #define SEARCHFORFILESMFC_H +#include "stdafx.h" #include <string> -#include <vector> -#include "stdafx.h" #include "util/SearchForFiles.h" -using namespace std; namespace amis { namespace util Modified: branches/amis3/AmisGuiMFC2/include/util/VolMaster.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/util/VolMaster.h 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/include/util/VolMaster.h 2007-11-19 08:23:24 UTC (rev 2232) @@ -1,44 +1,71 @@ -//////////////////////////////////////////////////////////////// +/* +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 VOLMASTER_H +#define VOLMASTER_H + +//Taken from and modified slightly: // MSDN Magazine -- January 2004 // If this code works, it was written by Paul DiLascia. // If not, I don't know who wrote it. // Compiles with Visual Studio .NET on Windows XP. Tab size=3. // -#pragma once - -////////////////// -// Handly class to encapsulate Windows' logical disk drive functions. -// -class CVolumeMaster { +namespace amis +{ +namespace util +{ +//Class to encapsulate Windows' logical disk drive functions. +class CVolumeMaster +{ public: - // Get bitmask of logical drives--same as Windows fn. - DWORD GetLogicalDrives() - { - return ::GetLogicalDrives(); - } + // Get bitmask of logical drives--same as Windows fn. + DWORD GetLogicalDrives() + { + return ::GetLogicalDrives(); + } - // Get drive type--same as Windows fn. - UINT GetDriveType(LPCTSTR lpPath) - { - return ::GetDriveType(lpPath); - } + // Get drive type--same as Windows fn. + UINT GetDriveType(LPCTSTR lpPath) + { + return ::GetDriveType(lpPath); + } - // Get logical drive strings as array of CStrings - int GetLogicalDriveStrings(CStringArray& ar); + // Get logical drive strings as array of CStrings + int GetLogicalDriveStrings(CStringArray& ar); - // Get volume information using CStrings instead of LPTSTR - BOOL GetVolumeInformation(LPCTSTR drive, // eg, "\\Server\Share" or "C:\" - CString& volname, // volume name (label) - DWORD& VolumeSerialNumber, // volume serial number - DWORD& MaximumComponentLength, // maximum component len (name between \'s) - DWORD& FileSystemFlags, // flags - CString& filesys); // file system--eg FAT or NTFS + // Get volume information using CStrings instead of LPTSTR + BOOL GetVolumeInformation(LPCTSTR drive, // eg, "\\Server\Share" or "C:\" + CString& volname, // volume name (label) + DWORD& VolumeSerialNumber, // volume serial number + DWORD& MaximumComponentLength, // maximum component len (name between \'s) + DWORD& FileSystemFlags, // flags + CString& filesys); // file system--eg FAT or NTFS - // Handy helpers to get human-readable names of things - static CString FormatDriveType(UINT type); - static CString FormatBitMask(DWORD bitmap, int group=5); - static CString FormatFileSystemFlags(DWORD flags, LPCTSTR sep); + // Handy helpers to get human-readable names of things + static CString FormatDriveType(UINT type); + static CString FormatBitMask(DWORD bitmap, int group=5); + static CString FormatFileSystemFlags(DWORD flags, LPCTSTR sep); }; +} +} +#endif - Modified: branches/amis3/AmisGuiMFC2/resource.h =================================================================== --- branches/amis3/AmisGuiMFC2/resource.h 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/resource.h 2007-11-19 08:23:24 UTC (rev 2232) @@ -79,8 +79,10 @@ #define IDC_SELTTSLABEL 1072 #define IDC_PHRASES 1073 #define IDC_CONTRAST 1074 +#define IDC_PAUSEONLOSTFOCUS 1074 #define IDC_LISTCAPTION 1075 #define IDC_PHRASEPREVIEW 1075 +#define IDC_PAUSEONLOSTFOCUS2 1075 #define IDC_CONTRASTPREVIEW 1076 #define IDC_AMISNAME 1076 #define IDC_PAGEFG 1077 @@ -158,7 +160,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 191 #define _APS_NEXT_COMMAND_VALUE 32875 -#define _APS_NEXT_CONTROL_VALUE 1089 +#define _APS_NEXT_CONTROL_VALUE 1093 #define _APS_NEXT_SYMED_VALUE 141 #endif #endif Modified: branches/amis3/AmisGuiMFC2/src/Preferences.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2007-11-19 08:23:24 UTC (rev 2232) @@ -19,9 +19,12 @@ 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 "stdafx.h" #include "Preferences.h" +#include "gui/AmisGuiMFC2.h" +#include "util/SearchForFilesMFC.h" +#include "util/FilePathTools.h" using namespace amis; @@ -44,177 +47,53 @@ Preferences::Preferences() { - mpTextBG = new Color("#ffff00"); - mpTextFG = new Color("#000000"); - mpPageBG = new Color("#00008B"); - mpPageFG = new Color("#ffffff"); - mbPauseOnApplicationLostFocus = true; + mbIsSelfVoicing = false; + mbUseTTSNotAudio = false; + mbLoadLastDtb = false; + mbPromptOnBasicView = false; + mbStartBasicView = false; + mTTSVoice = -1; + mbExitWasClean = true; + mFontsizeCssFiles.clear(); + mContrastCssFiles.clear(); + //note that file paths here are hardcoded relative to the application directory + //whereas in the prefs XML file, they are relative to the prefs XML file + mFontsizeCssDir = "./settings/css/font/"; + mContrastCssDir = "./settings/css/contrast/"; + mUiLangDir = "./settings/lang/eng-US"; + mUserBmkDir = "./settings/bmk/"; - this->mbIsSelfVoicing = false; - this->mUiLang = "./settings/lang/eng-US/"; - this->mbUseTTSNotAudio = false; -} + ambulant::net::url app_path = ambulant::net::url::from_filename(theApp.getAppPath()); + mDefaultCssFile = ambulant::net::url::from_filename("./settings/css/default.css"); + mDefaultCssFile = mDefaultCssFile.join_to_base(app_path); -Preferences::~Preferences() -{ - this->mbIsSelfVoicing = false; - this->mbLoadLastDtb = false; - this->mbPromptOnBasicView = false; - this->mbStartBasicView = false; - if (mpPageBG != NULL) delete this->mpPageBG; - if (mpPageFG != NULL) delete this->mpPageFG; - if (mpTextBG != NULL) delete this->mpTextBG; - if (mpTextFG != NULL) delete this->mpTextFG; - this->mTTSVoice = -1; - this->mUiLang = ""; - this->mUserBmkDir = ""; - this->mDefaultTocFont = ""; - this->mbPauseOnApplicationLostFocus = true; - this->mbExitWasClean = true; + mDefaultHighlightFG.set("000000"); + mDefaultHighlightBG.set("FFFF00"); + mDefaultFontName = "Arial"; } -void Preferences::resetColors() +void Preferences::scanDirectoriesForCssFiles() { - mpTextBG->set("#ffff00"); - mpTextFG->set("#000000"); - mpPageBG->set("#00008B"); - mpPageFG->set("#ffffff"); -} - -//********************** -//amis::Color -Color::Color(std::string value) -{ - set(value); -} -Color::Color(COLORREF value) -{ - set(value); -} - -void Color::set(std::string value) -{ - mColorHtml.assign(value); - mColor = htmlToRgb(value); -} - -void Color::set(COLORREF value) -{ - mColor = value; - mColorHtml.assign(getColorAsHtmlValue(value)); -} - -COLORREF Color::getAsColorRef() -{ - return mColor; -} - -std::string Color::getAsHtmlColor() -{ - return mColorHtml; -} - - -COLORREF Color::htmlToRgb(std::string html_color) -{ - std::string clr = html_color; + amis::util::SearchForFilesMFC searcher; + searcher.addSearchCriteria(".css"); + //these files will only bother developers + searcher.addSearchExclusionCriteria(".svn"); + searcher.setRecursiveSearch(true); + if (searcher.startSearch(amis::util::FilePathTools::getAsLocalFilePath(mFontsizeCssDir)) > 0) + { + mFontsizeCssFiles = *searcher.getSearchResults(); + } + else AfxMessageBox(_T("No fontsize css files found"));//TODO Log this message instead - std::wstring wred, wgreen, wblue; - - USES_CONVERSION; - - if (clr.size() < 6) + searcher.clearSearchResults(); + if (searcher.startSearch(amis::util::FilePathTools::getAsLocalFilePath(mContrastCssDir)) > 0) { - return RGB(0,0,0); + mContrastCssFiles = *searcher.getSearchResults(); } - - //chop off the leading # sign - if (clr.substr(0, 1).compare("#") == 0) clr = clr.substr(1); - - wred = A2CW(clr.substr(0, 2).c_str()); - wgreen = A2CW(clr.substr(2, 2).c_str()); - wblue = A2CW(clr.substr(4, 2).c_str()); - - - int iRed = _httoi(wred.c_str());//_httoi((LPCTSTR)red.c_str()); - int iGreen = _httoi(wgreen.c_str()); - int iBlue = _httoi(wblue.c_str()); - - return RGB(iRed, iGreen, iBlue); - + else AfxMessageBox(_T("No contrast css files found"));//TODO Log this message instead } -//function taken from http://www.codeproject.com/string/hexstrtoint.asp -int Color::_httoi(const TCHAR *value) +Preferences::~Preferences() { - - struct CHexMap - { - TCHAR chr; - int value; - }; - const int HexMapL = 16; - CHexMap HexMap[HexMapL] = - { - {'0', 0}, {'1', 1}, - {'2', 2}, {'3', 3}, - {'4', 4}, {'5', 5}, - {'6', 6}, {'7', 7}, - {'8', 8}, {'9', 9}, - {'A', 10}, {'B', 11}, - {'C', 12}, {'D', 13}, - {'E', 14}, {'F', 15} - }; - - TCHAR *mstr = _tcsupr(_tcsdup(value)); - TCHAR *s = mstr; - - int result = 0; - - if (*s == '0' && *(s + 1) == 'X') - { - s += 2; - } - - bool firsttime = true; - - while (*s != '\0') - { - bool found = false; - for (int i = 0; i < HexMapL; i++) - { - if (*s == HexMap[i].chr) - { - if (!firsttime) result <<= 4; - result |= HexMap[i].value; - found = true; - break; - } - } - if (!found) break; - s++; - firsttime = false; - } - free(mstr); - return result; } -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); - BYTE bVal = GetBValue(color_ref); - - CString cstr; - cstr.Format(_T("#%02X%02X%02X"), rVal, gVal, bVal); - - ret_val = T2A(cstr); - - return ret_val; - -} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-11-19 08:23:24 UTC (rev 2232) @@ -26,6 +26,8 @@ #include "util/FilePathTools.h" #include "Preferences.h" #include "io/RecentBooksFileIO.h" +#include "io/PreferencesFileIO.h" +#include "util/SearchForFilesMFC.h" #include "pdtb.h" #include "dtb/nav/NavModel.h" @@ -176,53 +178,6 @@ //set the callback function to handle book key registration amis::dtb::DtbWithHooks::Instance()->setCallbackForPreprocessingBookKey(registerBookKeyFile); - - //marisa removed this if-statement - //the self-voicing data should be ready to go whether or not self-voicing is turned on at the start - //the self-voicing data is also the dynamic localization data, so it is used all over the place - //maybe this needs to be changed someday and all strings must be duplicated in the RC file .. ? for now it's ok. - //if (amis::Preferences::Instance()->mbIsSelfVoicing == true) - //{ - //read in the new self-voicing/accessible UI data - DataReader new_data_reader; - DataTree* p_new_data_tree; - p_new_data_tree = DataTree::Instance(); - - string tmpStr = amis::Preferences::Instance()->mUiLang; - tmpStr = amis::util::FilePathTools::goRelativePath(mAppPath, tmpStr); - tmpStr = amis::util::FilePathTools::goRelativePath(tmpStr, "amisAccessibleUi.xml"); - tmpStr = amis::util::FilePathTools::getAsLocalFilePath(tmpStr); - new_data_reader.setAppPath(mAppPath); - - amis::ErrorCode did_it_work = new_data_reader.readFile(tmpStr, p_new_data_tree); - - if (did_it_work == amis::OK) - { - //test print to an output file - //p_new_data_tree->testPrint("c:\\devel\\amis\\Langpacks\\sandbox\\dataout.txt"); - - //DanToDo: This makes sure a clip is played first before any TTS. For some strange CoInitialize order between SAPI-TTS and Vupp, we must play an audio clip first, not a TTS...unless we open a book, in which case the CoInitialize of the IE-HTML view makes things work again !! :-| - AudioSequencePlayer::playPromptFromStringId("canceled"); - - /* - AudioSequence* seq = new AudioSequence; - seq->append(L"AMIS"); - seq->append(L"Text-to-speech engine is ready.Text-to-speech engine is ready.Text-to-speech engine is ready."); - seq->append(L"Is it good ?"); - AudioSequencePlayer::Instance()->Play(seq); - */ - } - //if the UI file could not be read, then disable self-voicing - //todo: a more robust solution should go here: - // - what if the user re-enables self voicing via the AMIS prefs? - // - what if they switch langpacks? - //maybe we should try to load the default language pack here, and exit if that doesn't work. - else - { - amis::Preferences::Instance()->mbIsSelfVoicing = false; - } - //} - return TRUE; } @@ -265,25 +220,67 @@ void CAmisGuiMFC2App::initPathsAndFiles() { - //dummy book path - std::string url = "file://c:/devel/ambulant-documents/Flashlight/flashlight-dtb/ncc.html"; - mURL = ambulant::net::url::from_url(url); + //read the preferences + 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); + Preferences::Instance()->scanDirectoriesForCssFiles(); - //TODO replace with preferences' value - string bmk_dir = "./settings/bmk/"; - bmk_dir = amis::util::FilePathTools::goRelativePath(getAppPath(), bmk_dir); - very_temporary_bookmarks_dir = ambulant::net::url::from_filename(bmk_dir); - //read the recent books list - //TODO replace hardcoded path with Preferences::RecentBooksFilePath(); 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 io; - if (io.readFromFile(&the_book_path)) mpRecentBooks = io.getRecentBooks(); + amis::io::RecentBooksFileIO recent_books_io; + if (recent_books_io.readFromFile(&the_book_path)) mpRecentBooks = recent_books_io.getRecentBooks(); else mpRecentBooks = NULL; + + + //marisa removed this if-statement + //the self-voicing data should be ready to go whether or not self-voicing is turned on at the start + //the self-voicing data is also the dynamic localization data, so it is used all over the place + //maybe this needs to be changed someday and all strings must be duplicated in the RC file .. ? for now it's ok. + //if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + //{ + //read in the new self-voicing/accessible UI data + DataReader new_data_reader; + DataTree* p_new_data_tree; + p_new_data_tree = DataTree::Instance(); + + string tmpStr = amis::Preferences::Instance()->mUiLangDir; + tmpStr = amis::util::FilePathTools::goRelativePath(tmpStr, "amisAccessibleUi.xml"); + tmpStr = amis::util::FilePathTools::getAsLocalFilePath(tmpStr); + new_data_reader.setAppPath(mAppPath); + + amis::ErrorCode did_it_work = new_data_reader.readFile(tmpStr, p_new_data_tree); + + if (did_it_work == amis::OK) + { + //test print to an output file + //p_new_data_tree->testPrint("c:\\devel\\amis\\Langpacks\\sandbox\\dataout.txt"); + + //DanToDo: This makes sure a clip is played first before any TTS. For some strange CoInitialize order between SAPI-TTS and Vupp, we must play an audio clip first, not a TTS...unless we open a book, in which case the CoInitialize of the IE-HTML view makes things work again !! :-| + AudioSequencePlayer::playPromptFromStringId("canceled"); + + /* + AudioSequence* seq = new AudioSequence; + seq->append(L"AMIS"); + seq->append(L"Text-to-speech engine is ready.Text-to-speech engine is ready.Text-to-speech engine is ready."); + seq->append(L"Is it good ?"); + AudioSequencePlayer::Instance()->Play(seq); + */ + } + //if the UI file could not be read, then disable self-voicing + //todo: a more robust solution should go here: + // - what if the user re-enables self voicing via the AMIS prefs? + // - what if they switch langpacks? + //maybe we should try to load the default language pack here, and exit if that doesn't work. + else + { + amis::Preferences::Instance()->mbIsSelfVoicing = false; + } + //} + } const ambulant::net::url& CAmisGuiMFC2App::getBookURL() const { @@ -570,7 +567,7 @@ void CAmisGuiMFC2App::OnLoadCd() { - util::SearchForFilesMFC searcher; + amis::util::SearchForFilesMFC searcher; //prepare the search tool searcher.clearAll(); searcher.addSearchCriteria("ncc.htm"); Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-11-19 08:23:24 UTC (rev 2232) @@ -26,6 +26,7 @@ #include "gui/MainWndParts.h" #include "util/FilePathTools.h" #include "gui/AmisGuiMFC2.h" +#include "util/Color.h" #include <algorithm> @@ -66,15 +67,7 @@ //TODO: replace with preferences CSS file list string app_path = theApp.getAppPath(); app_path += "/"; - - mFontSizeCssFiles.push_back(ambulant::net::url::from_filename(amis::util::FilePathTools::goRelativePath(app_path, "../settings/font1.css"))); - mFontSizeCssFiles.push_back(ambulant::net::url::from_filename(amis::util::FilePathTools::goRelativePath(app_path, "../settings/font2.css"))); - mFontSizeCssFiles.push_back(ambulant::net::url::from_filename(amis::util::FilePathTools::goRelativePath(app_path, "../settings/font3.css"))); - mFontSizeCssFiles.push_back(ambulant::net::url::from_filename(amis::util::FilePathTools::goRelativePath(app_path, "../settings/font4.css"))); - mContrastCssUri = ambulant::net::url::from_filename(amis::util::FilePathTools::goRelativePath(app_path, "../settings/amis-contrast.css")); - mDefaultCssUri = ambulant::net::url::from_filename(amis::util::FilePathTools::goRelativePath(app_path, "../settings/amis-default.css")); - mpFontCss = NULL; mpContrastCss = NULL; mpDefaultCss = NULL; @@ -106,16 +99,15 @@ ambulant::net::url url = ambulant::net::url::from_url(urlstr); string text_elm_id = url.get_ref(); - //make sure our document still exists; otherwise force a reload by - //setting mCurrentUrl to "" - if (MainWndParts::Instance()->mpHtmlView->GetHtmlDocument() == NULL) { + //make sure our document still exists; otherwise force a reload by setting mCurrentUrl to "" + if (MainWndParts::Instance()->mpHtmlView->GetHtmlDocument() == NULL) + { this->mCurrentUrl = ambulant::net::url(); mTextElmId = ""; } bool sameDoc = url.same_document(mCurrentUrl); - // If it's identical ignore it (the previous call may still be waiting - // for the webDocumentComplete callback) + // If it's identical ignore it (the previous call may still be waiting for the webDocumentComplete callback) if (sameDoc && text_elm_id == mTextElmId) return; // If it's a different document: load it. @@ -180,8 +172,7 @@ string str_tag_name = OLE2A(tag_name); //convert the string to lower case before doing a comparison - std::transform(str_tag_name.begin(), str_tag_name.end(), - str_tag_name.begin(), (int(*)(int))tolower); + std::transform(str_tag_name.begin(), str_tag_name.end(), str_tag_name.begin(), (int(*)(int))tolower); if (str_tag_name.compare("img") == 0) { @@ -259,8 +250,8 @@ VariantInit(&var_fg); //get as strings from the preferences for highlight values - str_text_fg = amis::Preferences::Instance()->mpTextFG->getAsHtmlColor(); - str_text_bg = amis::Preferences::Instance()->mpTextBG->getAsHtmlColor(); + str_text_fg = amis::Preferences::Instance()->mDefaultHighlightFG.getAsHtmlColor(); + str_text_bg = amis::Preferences::Instance()->mDefaultHighlightBG.getAsHtmlColor(); //convert to chars const char* textfg_color = str_text_fg.c_str(); @@ -315,28 +306,13 @@ } void TextRenderBrain::htmlContrastOn() { -/* mb_flagContrast = true; - string fg, bg; - - fg = amis::Preferences::Instance()->mpPageFG->getAsHtmlColor(); - bg = amis::Preferences::Instance()->mpPageBG->getAsHtmlColor(); - - setPageContrast(fg, bg); -*/ mbContrastOn = true; - mpContrastCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&mContrastCssUri); + mpContrastCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&Preferences::Instance()->mContrastCssFiles[0]); } void TextRenderBrain::htmlContrastOff() { -/* mb_flagContrast = false; - string fg, bg; - fg = ""; - bg = ""; - - setPageContrast(fg, bg); -*/ mbContrastOn = false; MainWndParts::Instance()->mpHtmlView->removeStylesheet(mpContrastCss); } @@ -363,8 +339,12 @@ //remove the old stylesheet MainWndParts::Instance()->mpHtmlView->removeStylesheet(mpFontCss); - if (fontsz) mpFontCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&mFontSizeCssFiles[fontsz-1]); - + ambulant::net::url* css_url = NULL; + if (fontsz > 0 && fontsz <= Preferences::Instance()->mFontsizeCssFiles.size()) + { + css_url = &Preferences::Instance()->mFontsizeCssFiles[fontsz - 1]; + mpFontCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(css_url); + } if (isElementInView(pLastElm) == false) { VARIANT v_bool; @@ -454,7 +434,7 @@ //maintain the contrast settings (on/off) but use the new colors if (disableContrast == false) { - //repaint the sidebar contrast + //TODO repaint the sidebar contrast // MainWndParts::Instance()->mpSidebar->m_wndDlg.repaintContrast(); //repaint the html view contrast if it had been enabled @@ -463,7 +443,7 @@ //otherwise turn the contrast off everywhere else { - //turn off the sidebar contrast + //TODO turn off the sidebar contrast // MainWndParts::Instance()->mpSidebar->m_wndDlg.turnContrastOff(); //turn off the html view contrast @@ -494,8 +474,8 @@ VariantInit(&var_fg); //get as strings - str_text_fg = amis::Preferences::Instance()->mpTextFG->getAsHtmlColor(); - str_text_bg = amis::Preferences::Instance()->mpTextBG->getAsHtmlColor(); + str_text_fg = amis::Preferences::Instance()->mDefaultHighlightFG.getAsHtmlColor(); + str_text_bg = amis::Preferences::Instance()->mDefaultHighlightBG.getAsHtmlColor(); //convert to chars const char* textfg_color = str_text_fg.c_str(); @@ -515,8 +495,6 @@ //this function looks at the element's coordinates and the coordinates of the section of the //document which is being displayed, and decides if the element is visible or not -//however, stupid IE 7 broke it and it doesn't work anymore -//TODO fix this bool TextRenderBrain::isElementInView(IHTMLElement* pElm) { //the IHTMLELEMENT measurements @@ -555,9 +533,11 @@ IHTMLElement *pElem = NULL; IHTMLElement2 *pElem2 = NULL; hr = pDocument->QueryInterface(IID_IHTMLDocument3,(void**)&pDoc3); - if (SUCCEEDED(hr)) { + if (SUCCEEDED(hr)) + { hr = pDoc3->get_documentElement(&pElem); - if (SUCCEEDED(hr)) { + if (SUCCEEDED(hr)) + { hr = pElem->QueryInterface(IID_IHTMLElement2, (void**)&pElem2); } } @@ -569,7 +549,8 @@ CPoint scroll_pos, scroll_pos2; pContainer->get_scrollTop(&scroll_pos.y); pContainer->get_scrollLeft(&scroll_pos.x); - if (pElem2) { + if (pElem2) + { pElem2->get_scrollTop(&scroll_pos2.y); pElem2->get_scrollLeft(&scroll_pos2.x); scroll_pos.y += scroll_pos2.y; Modified: branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp 2007-11-19 08:23:24 UTC (rev 2232) @@ -70,9 +70,10 @@ //this file is local! and the address does not look like a URL. bool PreferencesFileIO::readFromFile(string filepath) { - mpPrefs = NULL; - ambulant::net::url file = ambulant::net::url::from_filename(filepath); - return this->parseFile(&file); + mpPrefs = Preferences::Instance(); + ambulant::net::url tmp_url = ambulant::net::url::from_filename(filepath); + mpPrefs->mSourceUrl = tmp_url; + return this->parseFile(&mpPrefs->mSourceUrl); } //-------------- @@ -101,43 +102,43 @@ { if (id.compare("ui-lang") == 0) { - mpPrefs->mUiLang = value; + mpPrefs->mUiLangDir = amis::util::FilePathTools::goRelativePath(mpPrefs->mSourceUrl.get_url(), value); } else if (id.compare("start-basic") == 0) { - if (value.compare("yes") == 0) + if (value.compare("yes") == 0) mpPrefs->mbStartBasicView = true; - else + else mpPrefs->mbStartBasicView = false; } else if (id.compare("user-bmk-dir") == 0) { - mpPrefs->mUserBmkDir = value; + mpPrefs->mUserBmkDir = amis::util::FilePathTools::goRelativePath(mpPrefs->mSourceUrl.get_url(), value); } else if (id.compare("load-last-dtb") == 0) { - if (value.compare("yes") == 0) + if (value.compare("yes") == 0) mpPrefs->mbLoadLastDtb = true; - else + else mpPrefs->mbLoadLastDtb = false; } else if (id.compare("self-voicing") == 0) { - if (value.compare("yes") == 0) + if (value.compare("yes") == 0) mpPrefs->mbIsSelfVoicing = true; - else + else mpPrefs->mbIsSelfVoicing = false; } else if (id.compare("use-tts-not-audio") == 0) { - if (value.compare("yes") == 0) + if (value.compare("yes") == 0) mpPrefs->mbUseTTSNotAudio = true; - else + else mpPrefs->mbUseTTSNotAudio = false; } else if (id.compare("tts-voice") == 0) @@ -147,29 +148,9 @@ mpPrefs->mTTSVoice = voice; } - else if (id.compare("highlight-fg") == 0) - { - mpPrefs->mpTextFG->set(value); - } - - else if (id.compare("highlight-bg") == 0) - { - mpPrefs->mpTextBG->set(value); - } - - else if (id.compare("contrast-fg") == 0) - { - mpPrefs->mpPageFG->set(value); - } - - else if (id.compare("contrast-bg") == 0) - { - mpPrefs->mpPageBG->set(value); - } - else if (id.compare("basic-view-prompt") == 0) { - if (value.compare("yes") == 0) + if (value.compare("yes") == 0) mpPrefs->mbPromptOnBasicView = true; else mpPrefs->mbPromptOnBasicView = false; @@ -183,11 +164,6 @@ mpPrefs->mbPauseOnApplicationLostFocus = false; } - else if (id.compare("default-toc-font") == 0) - { - mpPrefs->mDefaultTocFont = value; - } - else if (id.compare("exit-was-clean") == 0) { if (value.compare("yes") == 0) @@ -195,10 +171,26 @@ else mpPrefs->mbExitWasClean = false; } + else if (id.compare("fontsize-stylesheets-dir") == 0) + { + //TODO + //upgrade to ambulant url? + mpPrefs->mFontsizeCssDir = amis::util::FilePathTools::goRelativePath(mpPrefs->mSourceUrl.get_url(), value); + } + else if (id.compare("contrast-stylesheets-dir") == 0) + { + //TODO + //upgrade to ambulant url? + mpPrefs->mContrastCssDir = amis::util::FilePathTools::goRelativePath(mpPrefs->mSourceUrl.get_url(), value); + } + else if (id.compare("default-stylesheet") == 0) + { + ambulant::net::url css_file = ambulant::net::url::from_filename(value); + mpPrefs->mDefaultCssFile = css_file.join_to_base(*&mpPrefs->mSourceUrl); + } } - bool PreferencesFileIO::writeToFile(string filepath, amis::Preferences* pPrefs) { if (pPrefs == NULL) @@ -229,8 +221,8 @@ (xercesc_2_7::DOMDocumentType*)0); mpDoc = pDoc; - writeAll(); - + writeData(); + //initialize the DOM Writer pWriter = ((DOMImplementationLS*)pImpl)->createDOMWriter(); @@ -256,7 +248,7 @@ return true; } -void PreferencesFileIO::writeAll() +void PreferencesFileIO::writeData() { DOMElement* pGeneralSection = NULL; DOMElement* pEntry = NULL; @@ -265,7 +257,7 @@ pGeneralSection = mpDoc->createElement(X("section")); pGeneralSection->setAttribute(X("name"), X("general")); - pEntry = createEntry("ui-lang", mpPrefs->mUiLang.c_str()); + pEntry = createEntry("ui-lang", mpPrefs->mUiLangDir.c_str()); pGeneralSection->appendChild((DOMNode*)pEntry); pEntry = createEntry("start-basic", mpPrefs->mbStartBasicView); @@ -296,30 +288,18 @@ pEntry = createEntry("use-tts-not-audio", mpPrefs->mbUseTTSNotAudio); pGeneralSection->appendChild((DOMNode*)pEntry); - //text highlight foreground color - tmp_str = mpPrefs->mpTextFG->getAsHtmlColor(); - pEntry = createEntry("highlight-fg", tmp_str); + pEntry = createEntry("exit-was-clean", mpPrefs->mbExitWasClean); pGeneralSection->appendChild((DOMNode*)pEntry); - //text highlight background color - tmp_str = mpPrefs->mpTextBG->getAsHtmlColor(); - pEntry = createEntry("highlight-bg", tmp_str); + pEntry = createEntry("fontsize-stylesheets-dir", mpPrefs->mFontsizeCssDir); pGeneralSection->appendChild((DOMNode*)pEntry); - tmp_str = mpPrefs->mpPageFG->getAsHtmlColor(); - pEntry = createEntry("contrast-fg", tmp_str); + pEntry = createEntry("contrast-stylesheets-dir", mpPrefs->mContrastCssDir); pGeneralSection->appendChild((DOMNode*)pEntry); - tmp_str = mpPrefs->mpPageBG->getAsHtmlColor(); - pEntry = createEntry("contrast-bg", tmp_str); + pEntry = createEntry("default-stylesheet", mpPrefs->mDefaultCssFile.get_url()); pGeneralSection->appendChild((DOMNode*)pEntry); - pEntry = createEntry("default-toc-font", mpPrefs->mDefaultTocFont); - pGeneralSection->appendChild((DOMNode*)pEntry); - - pEntry = createEntry("exit-was-clean", mpPrefs->mbExitWasClean); - pGeneralSection->appendChild((DOMNode*)pEntry); - //get a pointer to the root element DOMElement* pRootElem = mpDoc->getDocumentElement(); //append the general section element Added: branches/amis3/AmisGuiMFC2/src/util/Color.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/util/Color.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/src/util/Color.cpp 2007-11-19 08:23:24 UTC (rev 2232) @@ -0,0 +1,164 @@ +/* +AMIS: Adaptive Multimedia Information System +Software for playing DAISY books +Homepage: http://amis.sf.net + +Copyright (C) 2004-2007 DAISY for All Project + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#include "stdafx.h" +#include "util/Color.h" + +using namespace amis::util; + +Color::Color() +{ +} + +Color::Color(std::string value) +{ + set(value); +} +Color::Color(COLORREF value) +{ + set(value); +} + +void Color::set(std::string value) +{ + mColorHtml.assign(value); + mColor = htmlToRgb(value); +} + +void Color::set(COLORREF value) +{ + mColor = value; + mColorHtml.assign(getColorAsHtmlValue(value)); +} + +COLORREF Color::getAsColorRef() +{ + return mColor; +} + +std::string Color::getAsHtmlColor() +{ + return mColorHtml; +} + + +COLORREF Color::htmlToRgb(std::string html_color) +{ + std::string clr = html_color; + + std::wstring wred, wgreen, wblue; + + USES_CONVERSION; + + if (clr.size() < 6) + { + return RGB(0,0,0); + } + + //chop off the leading # sign + if (clr.substr(0, 1).compare("#") == 0) clr = clr.substr(1); + + wred = A2CW(clr.substr(0, 2).c_str()); + wgreen = A2CW(clr.substr(2, 2).c_str()); + wblue = A2CW(clr.substr(4, 2).c_str()); + + + int iRed = _httoi(wred.c_str());//_httoi((LPCTSTR)red.c_str()); + int iGreen = _httoi(wgreen.c_str()); + int iBlue = _httoi(wblue.c_str()); + + return RGB(iRed, iGreen, iBlue); + +} + +//function taken from http://www.codeproject.com/string/hexstrtoint.asp +int Color::_httoi(const TCHAR *value) +{ + + struct CHexMap + { + TCHAR chr; + int value; + }; + const int HexMapL = 16; + CHexMap HexMap[HexMapL] = + { + {'0', 0}, {'1', 1}, + {'2', 2}, {'3', 3}, + {'4', 4}, {'5', 5}, + {'6', 6}, {'7', 7}, + {'8', 8}, {'9', 9}, + {'A', 10}, {'B', 11}, + {'C', 12}, {'D', 13}, + {'E', 14}, {'F', 15} + }; + + TCHAR *mstr = _tcsupr(_tcsdup(value)); + TCHAR *s = mstr; + + int result = 0; + + if (*s == '0' && *(s + 1) == 'X') + { + s += 2; + } + + bool firsttime = true; + + while (*s != '\0') + { + bool found = false; + for (int i = 0; i < HexMapL; i++) + { + if (*s == HexMap[i].chr) + { + if (!firsttime) result <<= 4; + result |= HexMap[i].value; + found = true; + break; + } + } + if (!found) break; + s++; + firsttime = false; + } + free(mstr); + return result; +} +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); + BYTE bVal = GetBValue(color_ref); + + CString cstr; + cstr.Format(_T("#%02X%02X%02X"), rVal, gVal, bVal); + + ret_val = T2A(cstr); + + return ret_val; + +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/util/SearchForFilesMFC.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/util/SearchForFilesMFC.cpp 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/src/util/SearchForFilesMFC.cpp 2007-11-19 08:23:24 UTC (rev 2232) @@ -55,7 +55,7 @@ { USES_CONVERSION; //find the cdrom drive letter - CVolumeMaster vm; + amis::util::CVolumeMaster vm; CStringArray arDrives; int n = vm.GetLogicalDriveStrings(arDrives); CString cd_drive; @@ -123,7 +123,7 @@ //save the file path CString file_path = finder.GetFilePath(); std::string file_path_string = T2A(file_path); - //TODO + //we assume that the search returns local files ambulant::net::url file_path_url = ambulant::net::url::from_filename(file_path_string); addSearchResult(&file_path_url); Modified: branches/amis3/AmisGuiMFC2/src/util/VolMaster.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/util/VolMaster.cpp 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/AmisGuiMFC2/src/util/VolMaster.cpp 2007-11-19 08:23:24 UTC (rev 2232) @@ -7,6 +7,8 @@ #include "stdafx.h" #include "util/VolMaster.h" +using namespace amis::util; + ////////////////// // Get logical drive strings as CStringArray // @@ -50,10 +52,10 @@ CString CVolumeMaster::FormatBitMask(DWORD bitmask, int group) { CString bits; - for (int i=0; i<32; i++) { + for (int i=0; i<32; i++) + { bits += (bitmask & 0x1) ? _T('1') : _T('0'); - if (group>0 && i%group+1 == group) - bits += _T(' '); + if (group>0 && i%group+1 == group) bits += _T(' '); bitmask>>=1; } return bits; @@ -65,10 +67,12 @@ CString CVolumeMaster::FormatDriveType(UINT type) { - const struct { + const struct + { UINT type; LPCTSTR name; - } TypeNames[] = { + } TypeNames[] = + { { DRIVE_UNKNOWN, _T("DRIVE_UNKNOWN") }, { DRIVE_NO_ROOT_DIR, _T("DRIVE_NO_ROOT_DIR") }, { DRIVE_REMOVABLE, _T("DRIVE_REMOVABLE") }, @@ -78,9 +82,9 @@ { DRIVE_RAMDISK, _T("DRIVE_RAMDISK") }, { 0, NULL }, }; - for (int i=0; TypeNames[i].name; i++) { - if (type==TypeNames[i].type) - return TypeNames[i].name; + for (int i=0; TypeNames[i].name; i++) + { + if (type==TypeNames[i].type) return TypeNames[i].name; } CString str; str.Format(_T("DRIVE TYPE %d"),type); Modified: branches/amis3/bin/settings/amisPrefs.xml.default =================================================================== --- branches/amis3/bin/settings/amisPrefs.xml.default 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/bin/settings/amisPrefs.xml.default 2007-11-19 08:23:24 UTC (rev 2232) @@ -11,10 +11,9 @@ <entry id="pause-lost-focus" value="no"/> <entry id="use-tts-not-audio" value="no"/> <entry id="exit-was-clean" value="yes"/> -</section> -<section name="css"> <entry id="fontsize-stylesheets-dir" value="./css/font/"/> <entry id="contrast-stylesheets-dir" value="./css/contrast/"/> -<entry id="default-stylesheet" value="./css/default.css"/> +<entry id="default-user-stylesheet" value="./css/default.css"/> +<entry id="zed-2005-stylesheet" value="./css/dtbook.2005.basic.css"/> </section> </preferences> Modified: branches/amis3/bin/settings/css/contrast/contrast1.css =================================================================== --- branches/amis3/bin/settings/css/contrast/contrast1.css 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/bin/settings/css/contrast/contrast1.css 2007-11-19 08:23:24 UTC (rev 2232) @@ -1,5 +1,13 @@ /*contrast CSS sheet*/ /*Navy background with yellow text*/ + +/*AMIS will pick up the background-color and color values for the body element and use them in the sidebar. +if the body element is not specified here, then you must include these values in this format: +(note that "amis-contrast" is a reserved word) + +.amis-contrast{background-color: navy; color: yellow} + +*/ body{ background-color: navy !important; color: yellow !important;} a {color: yellow !important;} a:hover {color: yellow !important; font-weight: bolder !important;} Modified: branches/amis3/bin/settings/css/contrast/contrast2.css =================================================================== --- branches/amis3/bin/settings/css/contrast/contrast2.css 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/bin/settings/css/contrast/contrast2.css 2007-11-19 08:23:24 UTC (rev 2232) @@ -1,5 +1,6 @@ /*contrast CSS sheet*/ /*Black background with white text*/ +/*see the file "contrast1.css" for special notes about CSS formatting*/ body{ background-color: black !important; color: white !important;} a {color: white !important;} a:hover {color: white !important; font-weight: bolder !important;} Modified: branches/amis3/bin/settings/css/contrast/contrast3.css =================================================================== --- branches/amis3/bin/settings/css/contrast/contrast3.css 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/bin/settings/css/contrast/contrast3.css 2007-11-19 08:23:24 UTC (rev 2232) @@ -1,4 +1,5 @@ /*contrast CSS sheet*/ /*Light yellow background and black text*/ +/*see the file "contrast1.css" for special notes about CSS formatting*/ body{ background-color: lightyellow !important; color: black !important;} Modified: branches/amis3/bin/settings/css/default.css =================================================================== --- branches/amis3/bin/settings/css/default.css 2007-11-19 04:28:09 UTC (rev 2231) +++ branches/amis3/bin/settings/css/default.css 2007-11-19 08:23:24 UTC (rev 2232) @@ -1,2 +1,10 @@ /*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 +if the body element is not specified here, then you must include these values in this format: +(note that "amis-default" is a reserved word) +.amis-default{font-family: arial, verdana, sans-serif;} +*/ +.amis-highlight {color: black; background-color: yellow} +body {font-family: arial, verdana, sans-serif;} \ No newline at end of file Added: branches/amis3/bin/settings/css/dtbook.2005.basic.css =================================================================== --- branches/amis3/bin/settings/css/dtbook.2005.basic.css (rev 0) +++ branches/amis3/bin/settings/css/dtbook.2005.basic.css 2007-11-19 08:23:24 UTC (rev 2232) @@ -0,0 +1,611 @@ +/* ------------------------------------------------------------ */ +/* dtbook.2005.basic.css + + Created 10-13-1999 by M. Moodie from M. Hakkinen's template + Modified 03-16-2000 and 09/06-2000 by M. Brown + Modified 12-12-2002 by Guillaume du Bourguet (BrailleNet) + M Gylling 2003-11-04: additions, merging and fixing of + Dtbvisv3.css, + dtbook-std.css, + dtbbase.css, into + dtbook.basic.css + version (2004-08-28, m gylling): + --> dtbook.2004.basic.css <-- + Changelist: + Added support for: bridgehead + hd + poem + linegroup + dateline + byline + epigraph + covertitle + + version (2005-01-18, m gylling and brandon nelson) + --> dtbook.2005.basic.css <-- + Changelist latest version: + Misc updates for Z39.86.2005 version of dtbook + + version (2006-08-18, b nelson) + Changelist: + Fixed inline pagenums + + version (2006-09-28, m gylling) + Changelist: + Fixed new http reference in this comment + + This CSS is supported and maintained by the Z39.86 committee. + You may modify and redistribute it, but please consider + donating enhancements back to the source. + + Contact: + mar...@tp... + z3...@ma... + WWW: http://www.daisy.org/z3986/2005/ + + Note: if you want to apply local/specific rules, + the best way to do that is to associate another + stylesheet with the dtbook document via an + additional xml-stylesheet link. + + In that additional stylesheet you can override + rules in or add rules to this stylesheet. + + If the proximity rule works to your disadvantage, + use the !important syntax to force things to order. */ +/* ------------------------------------------------------------ */ + +/* The following strings are searchable + to go directly to subsection: + + elements without display properties + base properties of whole doc + frontmatter + bodymatter + rearmatter + headings + pagenum, linenum + general block + general inlines + list.ul,list.ol + tables + images + +*/ + + +/* ------------------------------------------------------------- */ +/* elements without display properties */ +/* ------------------------------------------------------------- */ + +dtbook { + display:block; + width: 100%; +} + +head, head * { + display: none +} + + + +/* ------------------------------------------------------------- */ +/* base properties of whole doc */ +/* ------------------------------------------------------------- */ + +book { + display: block; + background-color: rgb(255,255,255); + color: rgb(0,0,0); + font-family: arial, verdana, sans-serif; + line-height: 1.5em; + margin-top: 4em; + margin-bottom: 2em; + margin-left: 6em; + margin-right: 6em; +} + +/* ------------------------------------------------------------- */ +/* frontmatter */ +/* ------------------------------------------------------------- */ + +frontmatter { + display: block; + margin-top: 1em; + margin-bottom: 1em; +} + +doctitle, docauthor, covertitle { + display: block; + font-weight: bold; + text-align: center; +} + +doctitle { + font-size: 2.0em; +} + +covertitle { + font-size: 1.5em; +} +docauthor { + font-style: italic; + font-size: 1.5em; +} + + + +/* ------------------------------------------------------------- */ +/* bodymatter */ +/* ------------------------------------------------------------- */ + +bodymatter { + display: block; + margin-top: 1em; + margin-bottom: 1em; +} + + +/* ------------------------------------------------------------- */ +/* rearmatter */ +/* ------------------------------------------------------------- */ + +rearmatter { + display: block; + margin-top: 1em; + margin-bottom: 1em; +} + +/* ------------------------------------------------------------- */ +/* headings */ +/* ------------------------------------------------------------- */ + +h1, h2, h3, h4, h5, h6, levelhd, bridgehead, hd { + display: block; + font-weight: bold; + margin-bottom: 0.5em; +} + +h1, level levelhd { + font-size: 1.7em; + margin-top: 1.5em +} +h2, level level levelhd { + font-size: 1.5em; + margin-top: 1.2em +} +h3, level level level levelhd { + font-size: 1.4em; + margin-top: 1.0em +} +h4, level level level level levelhd { + font-size: 1.3em; + margin-top: 1.0em +} +h5, level level level level level levelhd { + font-size: 1.2em; + margin-top: 1.0em +} +h6, level level level level level level levelhd { + font-size: 1.0em; + margin-top: 1.0em +} +bridgehead, hd { + font-size: 1.0em; + margin-top: 0.8em +} + +/* ------------------------------------------------------------- */ +/* pagenum, linenum */ +/* ------------------------------------------------------------- */ + +pagenum { + display: inline; + color: rgb(30,30,30); ... [truncated message content] |
From: <mar...@us...> - 2007-11-20 07:04:51
|
Revision: 2233 http://amis.svn.sourceforge.net/amis/?rev=2233&view=rev Author: marisademeglio Date: 2007-11-19 23:04:45 -0800 (Mon, 19 Nov 2007) Log Message: ----------- Highlight color can be overridden by default.css Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/Preferences.h branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h branches/amis3/AmisGuiMFC2/src/Preferences.cpp branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/bin/settings/css/contrast/contrast1.css branches/amis3/bin/settings/css/contrast/contrast2.css branches/amis3/bin/settings/css/contrast/contrast3.css branches/amis3/bin/settings/css/default.css branches/amis3/bin/settings/css/font/font1.css branches/amis3/bin/settings/css/font/font2.css branches/amis3/bin/settings/css/font/font3.css branches/amis3/bin/settings/css/font/font4.css Modified: branches/amis3/AmisGuiMFC2/include/Preferences.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/Preferences.h 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/AmisGuiMFC2/include/Preferences.h 2007-11-20 07:04:45 UTC (rev 2233) @@ -67,12 +67,15 @@ ambulant::net::url mDefaultCssFile; ambulant::net::url mSourceUrl; + + //these values come from parsing default.css + util::Color mHighlightFG; + util::Color mHighlightBG; + std::string mFontName; + int mFontSize; + util::Color mPageFG; + util::Color mPageBG; - //these values come from parsing default.css - util::Color mDefaultHighlightFG; - util::Color mDefaultHighlightBG; - std::string mDefaultFontName; - private: static Preferences* pinstance; Modified: branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2007-11-20 07:04:45 UTC (rev 2233) @@ -59,7 +59,6 @@ wstring getCurrentText(); void webDocumentComplete(); - private: void saveElementText(IHTMLElement*); void setFontSize(int); @@ -68,7 +67,7 @@ void htmlContrastOff(); void redoHighlightColors(); bool isElementInView(IHTMLElement*); - + void scanStylesheetForAdditionalData(IHTMLStyleSheet*); IHTMLElement* GetElementFromId(string id, const GUID *iid); IHTMLDocument2* GetDoc(); @@ -78,15 +77,12 @@ ambulant::net::url mCurrentUrl; string mTextElmId; wstring mCurrentElmText; - vector<ambulant::net::url> mFontSizeCssFiles; IHTMLElement* pLastElm; VARIANT mUnhighlightedBG; VARIANT mUnhighlightedFG; IHTMLStyleSheet* mpFontCss; IHTMLStyleSheet* mpContrastCss; IHTMLStyleSheet* mpDefaultCss; - ambulant::net::url mContrastCssUri; - ambulant::net::url mDefaultCssUri; private: static TextRenderBrain* pinstance; Modified: branches/amis3/AmisGuiMFC2/src/Preferences.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2007-11-20 07:04:45 UTC (rev 2233) @@ -68,9 +68,9 @@ mDefaultCssFile = ambulant::net::url::from_filename("./settings/css/default.css"); mDefaultCssFile = mDefaultCssFile.join_to_base(app_path); - mDefaultHighlightFG.set("000000"); - mDefaultHighlightBG.set("FFFF00"); - mDefaultFontName = "Arial"; + mHighlightFG.set("000000"); + mHighlightBG.set("FFFF00"); + mFontName = "Arial"; } void Preferences::scanDirectoriesForCssFiles() Modified: branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2007-11-20 07:04:45 UTC (rev 2233) @@ -632,7 +632,6 @@ //stylesheet doesn't override the default styling (i would like it to override this) res = pDoc->createStyleSheet(css_path_bstr, 0, &pStyleSheet); SysFreeString(css_path_bstr); - return pStyleSheet; } Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-11-20 07:04:45 UTC (rev 2233) @@ -149,7 +149,8 @@ { if (mbWaitForDocumentLoad) { - mpDefaultCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&mDefaultCssUri); + mpDefaultCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&Preferences::Instance()->mDefaultCssFile); + scanStylesheetForAdditionalData(mpDefaultCss); MainWndParts::Instance()->mpHtmlView->RedrawWindow(); mbWaitForDocumentLoad = false; @@ -250,8 +251,8 @@ VariantInit(&var_fg); //get as strings from the preferences for highlight values - str_text_fg = amis::Preferences::Instance()->mDefaultHighlightFG.getAsHtmlColor(); - str_text_bg = amis::Preferences::Instance()->mDefaultHighlightBG.getAsHtmlColor(); + str_text_fg = amis::Preferences::Instance()->mHighlightFG.getAsHtmlColor(); + str_text_bg = amis::Preferences::Instance()->mHighlightBG.getAsHtmlColor(); //convert to chars const char* textfg_color = str_text_fg.c_str(); @@ -308,6 +309,7 @@ { mbContrastOn = true; mpContrastCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&Preferences::Instance()->mContrastCssFiles[0]); + scanStylesheetForAdditionalData(mpContrastCss); } @@ -333,7 +335,7 @@ //1...4 = increasingly bigger void TextRenderBrain::setFontSize(int fontsz) { - if (fontsz > mFontSizeCssFiles.size() || fontsz < 1) fontsz = 0; + if (fontsz > Preferences::Instance()->mFontsizeCssFiles.size() || fontsz < 1) fontsz = 0; mFontSize = fontsz; //remove the old stylesheet @@ -344,6 +346,7 @@ { css_url = &Preferences::Instance()->mFontsizeCssFiles[fontsz - 1]; mpFontCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(css_url); + scanStylesheetForAdditionalData(mpFontCss); } if (isElementInView(pLastElm) == false) { @@ -474,8 +477,8 @@ VariantInit(&var_fg); //get as strings - str_text_fg = amis::Preferences::Instance()->mDefaultHighlightFG.getAsHtmlColor(); - str_text_bg = amis::Preferences::Instance()->mDefaultHighlightBG.getAsHtmlColor(); + str_text_fg = amis::Preferences::Instance()->mHighlightFG.getAsHtmlColor(); + str_text_bg = amis::Preferences::Instance()->mHighlightBG.getAsHtmlColor(); //convert to chars const char* textfg_color = str_text_fg.c_str(); @@ -579,17 +582,15 @@ int elm_bottom = elm_top + elm_height; int elm_right = elm_left + elm_width; - CString element_data; +/* CString element_data; element_data.Format(_T("*****\nElement \ttop = %d \tbottom = %d \tleft = %d \tright = %d \n****\n"), elm_top, elm_bottom, elm_left, elm_right); - CString screen_data; screen_data.Format(_T("******\nScreen \ttop = %d \tbottom = %d \tleft = %d \tright = %d \n****\n"), top_visible, bottom_visible, left_visible, right_visible); - -// TRACE(screen_data); -// TRACE(element_data); - + TRACE(screen_data); + TRACE(element_data); +*/ if (elm_top < top_visible || elm_bottom > bottom_visible) return false; if (elm_left < left_visible || elm_right > right_visible) return false; @@ -597,4 +598,67 @@ return true; } +//use the COM interface to get at the details of this stylesheet and apply them to the sidebar too +//it also gets the highlight colors for the main window from a selector called .amis-highlight +void TextRenderBrain::scanStylesheetForAdditionalData(IHTMLStyleSheet* pStylesheet) +{ + USES_CONVERSION; + //all the stupid COM objects... + IHTMLStyleSheetRulesCollection* p_rules; + long len; + IHTMLStyleSheetRule* p_rule; + if (!SUCCEEDED(pStylesheet->get_rules(&p_rules))) return; + if (!SUCCEEDED(p_rules->get_length(&len))) + { + p_rules->Release(); + return; + } + + for (long i = 0; i<len; i++) + { + //get a single style rule + if (!SUCCEEDED(p_rules->item(i, &p_rule))) continue; + + //get the rule's selector + BSTR selector_text; + if (!SUCCEEDED(p_rule->get_selectorText(&selector_text))) continue; + string str_selector_text = OLE2A(selector_text); + + //this gives the highlight colors + if (!str_selector_text.compare(".amis-highlight")) + { + IHTMLRuleStyle* p_rule_style; + if (SUCCEEDED(p_rule->get_style(&p_rule_style))) + { + VARIANT highlight_bg; + VARIANT highlight_fg; + VariantInit(&highlight_bg); + VariantInit(&highlight_fg); + //get background color + p_rule_style->get_backgroundColor(&highlight_bg); + p_rule_style->get_color(&highlight_fg); + Preferences::Instance()->mHighlightBG.set(OLE2A(highlight_bg.bstrVal)); + Preferences::Instance()->mHighlightFG.set(OLE2A(highlight_fg.bstrVal)); + p_rule_style->Release(); + } + } + else if (!str_selector_text.compare("body")) + { + IHTMLRuleStyle* p_rule_style; + if (SUCCEEDED(p_rule->get_style(&p_rule_style))) + { + //get fontsize + //get font family + //get color + //get background color + + p_rule_style->Release(); + } + } + p_rule->Release(); + + } //end for-loop through the rules collection + p_rules->Release(); +} + Modified: branches/amis3/bin/settings/css/contrast/contrast1.css =================================================================== --- branches/amis3/bin/settings/css/contrast/contrast1.css 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/bin/settings/css/contrast/contrast1.css 2007-11-20 07:04:45 UTC (rev 2233) @@ -1,13 +1,6 @@ /*contrast CSS sheet*/ /*Navy background with yellow text*/ - -/*AMIS will pick up the background-color and color values for the body element and use them in the sidebar. -if the body element is not specified here, then you must include these values in this format: -(note that "amis-contrast" is a reserved word) - -.amis-contrast{background-color: navy; color: yellow} - -*/ +/*AMIS will pick up the background-color and color values for the body element and use them in the sidebar.*/ body{ background-color: navy !important; color: yellow !important;} a {color: yellow !important;} a:hover {color: yellow !important; font-weight: bolder !important;} Modified: branches/amis3/bin/settings/css/contrast/contrast2.css =================================================================== --- branches/amis3/bin/settings/css/contrast/contrast2.css 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/bin/settings/css/contrast/contrast2.css 2007-11-20 07:04:45 UTC (rev 2233) @@ -1,6 +1,6 @@ /*contrast CSS sheet*/ /*Black background with white text*/ -/*see the file "contrast1.css" for special notes about CSS formatting*/ +/*AMIS will pick up the background-color and color values for the body element and use them in the sidebar.*/ body{ background-color: black !important; color: white !important;} a {color: white !important;} a:hover {color: white !important; font-weight: bolder !important;} Modified: branches/amis3/bin/settings/css/contrast/contrast3.css =================================================================== --- branches/amis3/bin/settings/css/contrast/contrast3.css 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/bin/settings/css/contrast/contrast3.css 2007-11-20 07:04:45 UTC (rev 2233) @@ -1,5 +1,5 @@ /*contrast CSS sheet*/ /*Light yellow background and black text*/ -/*see the file "contrast1.css" for special notes about CSS formatting*/ +/*AMIS will pick up the background-color and color values for the body element and use them in the sidebar.*/ body{ background-color: lightyellow !important; color: black !important;} Modified: branches/amis3/bin/settings/css/default.css =================================================================== --- branches/amis3/bin/settings/css/default.css 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/bin/settings/css/default.css 2007-11-20 07:04:45 UTC (rev 2233) @@ -1,10 +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 -if the body element is not specified here, then you must include these values in this format: -(note that "amis-default" is a reserved word) - -.amis-default{font-family: arial, verdana, sans-serif;} -*/ -.amis-highlight {color: black; background-color: yellow} +/*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} body {font-family: arial, verdana, sans-serif;} \ No newline at end of file Modified: branches/amis3/bin/settings/css/font/font1.css =================================================================== --- branches/amis3/bin/settings/css/font/font1.css 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/bin/settings/css/font/font1.css 2007-11-20 07:04:45 UTC (rev 2233) @@ -1,13 +1,6 @@ /*font size CSS sheet*/ -/*one level up in fontsize and line spacing*/ - -/*AMIS will pick up the font-size value for the body element and use it in the sidebar. -if the body element is not specified here, then you must include this value in this format: -(note that "amis-fontsize" is a reserved word) - -.amis-fontsize{font-size: 150%;} - -*/ +/*one level increase in fontsize and line spacing*/ +/*AMIS will pick up the font-size value for the body element and use it in the sidebar.*/ body { font-size: 150% !important; line-spacing: 125% !important; Modified: branches/amis3/bin/settings/css/font/font2.css =================================================================== --- branches/amis3/bin/settings/css/font/font2.css 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/bin/settings/css/font/font2.css 2007-11-20 07:04:45 UTC (rev 2233) @@ -1,6 +1,6 @@ /*font size CSS sheet*/ -/*two levels up in fontsize and line spacing*/ -/*see the file "font1.css" for special notes about CSS formatting*/ +/*two levels increase in fontsize and line spacing*/ +/*AMIS will pick up the font-size value for the body element and use it in the sidebar.*/ body { font-size: 175% !important; line-spacing: 150% !important; Modified: branches/amis3/bin/settings/css/font/font3.css =================================================================== --- branches/amis3/bin/settings/css/font/font3.css 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/bin/settings/css/font/font3.css 2007-11-20 07:04:45 UTC (rev 2233) @@ -1,6 +1,6 @@ /*font size CSS sheet*/ -/*three levels up in fontsize and line spacing*/ -/*see the file "font1.css" for special notes about CSS formatting*/ +/*three levels increase in fontsize and line spacing*/ +/*AMIS will pick up the font-size value for the body element and use it in the sidebar.*/ body { font-size: 200% !important; line-spacing: 175% !important; Modified: branches/amis3/bin/settings/css/font/font4.css =================================================================== --- branches/amis3/bin/settings/css/font/font4.css 2007-11-19 08:23:24 UTC (rev 2232) +++ branches/amis3/bin/settings/css/font/font4.css 2007-11-20 07:04:45 UTC (rev 2233) @@ -1,6 +1,6 @@ /*font size CSS sheet*/ -/*four levels up in fontsize and line spacing*/ -/*see the file "font1.css" for special notes about CSS formatting*/ +/*four levels increase in fontsize and line spacing*/ +/*AMIS will pick up the font-size value for the body element and use it in the sidebar.*/ body { font-size: 225% !important; line-spacing: 175% !important; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-11-21 02:46:05
|
Revision: 2235 http://amis.svn.sourceforge.net/amis/?rev=2235&view=rev Author: marisademeglio Date: 2007-11-20 18:46:07 -0800 (Tue, 20 Nov 2007) Log Message: ----------- More experiments with CSS highlighting. Fixed a bug in Dtb.cpp where the protected book decrypting function wasn't getting called. New observation: the memory is gushing out. Is it Ambulant's new datasource fix? Or the IE widget? Or the sidebar? TODO: check if it is significantly worse for protected books. Modified Paths: -------------- branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-11-21 00:33:09 UTC (rev 2234) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-11-21 02:46:07 UTC (rev 2235) @@ -62,6 +62,7 @@ //delete objects //we are purposely not deleting mpFileSearcher +//we are also purposely not deleting mpCallbackForPreprocessingBookKey void amis::dtb::Dtb::cleanUpObjects() { mbIsProtected = false; @@ -99,7 +100,7 @@ mpCustomTests = NULL; mUid.erase(); mDaisyVersion = 0; - mpCallbackForPreprocessingBookKey = NULL; + } amis::MediaGroup* amis::dtb::Dtb::getTitle() { Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-11-21 00:33:09 UTC (rev 2234) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-11-21 02:46:07 UTC (rev 2235) @@ -251,8 +251,8 @@ VariantInit(&var_fg); //get as strings from the preferences for highlight values - str_text_fg = amis::Preferences::Instance()->mHighlightFG.getAsHtmlHexColor() + " !important"; - str_text_bg = amis::Preferences::Instance()->mHighlightBG.getAsHtmlHexColor() + " !important"; + str_text_fg = amis::Preferences::Instance()->mHighlightFG.getAsHtmlHexColor(); + str_text_bg = amis::Preferences::Instance()->mHighlightBG.getAsHtmlHexColor(); //convert to chars const char* textfg_color = str_text_fg.c_str(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-12-03 14:25:25
|
Revision: 2238 http://amis.svn.sourceforge.net/amis/?rev=2238&view=rev Author: daniel_weck Date: 2007-12-03 06:25:28 -0800 (Mon, 03 Dec 2007) Log Message: ----------- - Daniel WECK * Fixed nasty bug where space character is escaped in URL syntax (%20). This is a hacky workaround that needs to be looked at properly. Modified Paths: -------------- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp Modified: branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2007-12-03 12:35:37 UTC (rev 2237) +++ branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2007-12-03 14:25:28 UTC (rev 2238) @@ -318,7 +318,7 @@ logSession("Destroy filtergraph"); stop(); - if (hEventHandler) { + if (hEventHandler && pIGB != NULL) { bCatchEvents = true; bProcessEvents = true; @@ -810,10 +810,10 @@ lstrcpy(wFileName, (const unsigned short *) iszFileName); #endif - std::string strFileName; strFileName.assign(iszFileName); + // if (pIGB) destroyFilterGraph(); createFilterGraph(); Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-12-03 12:35:37 UTC (rev 2237) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-12-03 14:25:28 UTC (rev 2238) @@ -18,6 +18,7 @@ #include "gui/MmView.h" +//#include "ambulant/net/url.h" using namespace amis::audio; using namespace amis::tts; @@ -296,6 +297,8 @@ src = amis::util::FilePathTools::goRelativePath(tmpStr, src); src = amis::util::FilePathTools::getAsLocalFilePath(src); + + //src = ambulant::net::url::urlpath2filepath(src); string clipBegin = ""; string clipEnd = ""; Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-03 12:35:37 UTC (rev 2237) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-03 14:25:28 UTC (rev 2238) @@ -51,7 +51,6 @@ #include "gui/dialogs/SearchForBooksDialog.h" #include "gui/dialogs/MultipleBooksOnVolumeDialog.h" - //#include "../AmisAudio/AmisAudio.h" //using namespace amis::audio; Modified: branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp 2007-12-03 12:35:37 UTC (rev 2237) +++ branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp 2007-12-03 14:25:28 UTC (rev 2238) @@ -102,7 +102,16 @@ { if (id.compare("ui-lang") == 0) { - mpPrefs->mUiLangDir = amis::util::FilePathTools::goRelativePath(mpPrefs->mSourceUrl.get_url(), value); + string strFileName = mpPrefs->mSourceUrl.get_url(); + + // TODO: This is a hacky workaround ! We need to globally make sure that URL syntax with escape characters is supported ! + int pos = strFileName.find("%20"); + while (pos != string::npos) { + strFileName = strFileName.replace(pos, 3, " "); + pos = strFileName.find("%20"); + } + + mpPrefs->mUiLangDir = amis::util::FilePathTools::goRelativePath(strFileName, value); } else if (id.compare("start-basic") == 0) @@ -115,7 +124,16 @@ else if (id.compare("user-bmk-dir") == 0) { - mpPrefs->mUserBmkDir = amis::util::FilePathTools::goRelativePath(mpPrefs->mSourceUrl.get_url(), value); + string strFileName = mpPrefs->mSourceUrl.get_url(); + + // TODO: This is a hacky workaround ! We need to globally make sure that URL syntax with escape characters is supported ! + int pos = strFileName.find("%20"); + while (pos != string::npos) { + strFileName = strFileName.replace(pos, 3, " "); + pos = strFileName.find("%20"); + } + + mpPrefs->mUserBmkDir = amis::util::FilePathTools::goRelativePath(strFileName, value); } else if (id.compare("load-last-dtb") == 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Jack J. <Jac...@cw...> - 2007-12-04 12:39:07
|
On 3 dec 2007, at 15:25, dan...@us... wrote: > Revision: 2238 > http://amis.svn.sourceforge.net/amis/?rev=2238&view=rev > Author: daniel_weck > Date: 2007-12-03 06:25:28 -0800 (Mon, 03 Dec 2007) > > Log Message: > ----------- > - Daniel WECK > * Fixed nasty bug where space character is escaped in URL syntax > (%20). This is a hacky workaround that needs to be looked at ... > Modified: branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp > =================================================================== > --- branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp > 2007-12-03 12:35:37 UTC (rev 2237) > +++ branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp > 2007-12-03 14:25:28 UTC (rev 2238) > @@ -102,7 +102,16 @@ > { > if (id.compare("ui-lang") == 0) > { > - mpPrefs->mUiLangDir = > amis::util::FilePathTools::goRelativePath(mpPrefs- > >mSourceUrl.get_url(), value); > + string strFileName = mpPrefs->mSourceUrl.get_url(); > + > + // TODO: This is a hacky workaround ! We need to globally make > sure that URL syntax with escape characters is supported ! > + int pos = strFileName.find("%20"); > + while (pos != string::npos) { > + strFileName = strFileName.replace(pos, 3, " "); > + pos = strFileName.find("%20"); > + } > + > + mpPrefs->mUiLangDir = > amis::util::FilePathTools::goRelativePath(strFileName, value); > } get_url() is the wrong call here. You should use is_local_file() to test whether the URL indeed refers to a local file and then get_file() to retrieve the filename. This will take care not only of %-escaping but also /-to-\ conversion, disk specs, etc. The intention is that ambulant::net::url provides everything to treat URLs as first class citizens. In other words, if you ever have to muck with the strings that come out of ambulant::net::url that should be considered a bug, and if you let me know I'll fix it. -- Jack Jansen, <Jac...@cw...>, http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman |
From: <dan...@us...> - 2007-12-03 15:21:31
|
Revision: 2239 http://amis.svn.sourceforge.net/amis/?rev=2239&view=rev Author: daniel_weck Date: 2007-12-03 07:21:25 -0800 (Mon, 03 Dec 2007) Log Message: ----------- - Daniel WECK * Fixed bug "crash on exit" (yes, there was another one). The source was still AmisSideBar::clearAll(), but I have no idea why ?! (I just removed the offending line). So, this will need further investigation for a proper fix. Modified Paths: -------------- branches/amis3/AmisAudio/AmisAudio.h branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp Modified: branches/amis3/AmisAudio/AmisAudio.h =================================================================== --- branches/amis3/AmisAudio/AmisAudio.h 2007-12-03 14:25:28 UTC (rev 2238) +++ branches/amis3/AmisAudio/AmisAudio.h 2007-12-03 15:21:25 UTC (rev 2239) @@ -73,8 +73,7 @@ AmisAudio(); public: - - //Two instances are used because AMIS should have two audio tracks - the book and the UI + static AmisAudio* Instance(); ///Deconstructor Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-12-03 14:25:28 UTC (rev 2238) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2007-12-03 15:21:25 UTC (rev 2239) @@ -69,6 +69,10 @@ { AudioSequencePlayer::Instance()->ClipAudioEndNotify(); } +bool AudioSequencePlayer::InstanceExists() { + + return pinstance != 0; + } AudioSequencePlayer* AudioSequencePlayer::Instance() { if (pinstance == 0) { Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h 2007-12-03 14:25:28 UTC (rev 2238) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.h 2007-12-03 15:21:25 UTC (rev 2239) @@ -54,6 +54,8 @@ void playAudioPrompt(amis::AudioNode* pAudio); public: + + static bool InstanceExists(); static AudioSequencePlayer* Instance(); void Play(AudioSequence* audioSequence, bool doNotRegisterInHistory = false); void Stop(); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-03 14:25:28 UTC (rev 2238) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-03 15:21:25 UTC (rev 2239) @@ -193,8 +193,12 @@ amis::gui::MainWndParts::Instance()->DestroyInstance(); DataTree::Instance()->DestroyInstance(); - AudioSequencePlayer::Instance()->DestroyInstance(); + if (AudioSequencePlayer::InstanceExists()) + { + AudioSequencePlayer::Instance()->DestroyInstance(); + } + if (mpRecentBooks) delete mpRecentBooks; return CWinApp::ExitInstance(); @@ -259,7 +263,7 @@ //p_new_data_tree->testPrint("c:\\devel\\amis\\Langpacks\\sandbox\\dataout.txt"); //DanToDo: This makes sure a clip is played first before any TTS. For some strange CoInitialize order between SAPI-TTS and Vupp, we must play an audio clip first, not a TTS...unless we open a book, in which case the CoInitialize of the IE-HTML view makes things work again !! :-| - AudioSequencePlayer::playPromptFromStringId("canceled"); + //AudioSequencePlayer::playPromptFromStringId("canceled"); /* AudioSequence* seq = new AudioSequence; Modified: branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp 2007-12-03 14:25:28 UTC (rev 2238) +++ branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp 2007-12-03 15:21:25 UTC (rev 2239) @@ -66,20 +66,26 @@ void CAmisSidebar::clearAll() { - if (m_wndTree) m_wndTree.DeleteAllItems(); - if (m_wndPageList) m_wndPageList.DeleteAllItems(); CNavListControl* p_navl = NULL; unsigned int sz = mNavLists.size(); for (int i=sz-1; i>=0; i--) { p_navl = mNavLists[i]; - p_navl->DeleteAllItems(); - p_navl->DestroyWindow(); + if (p_navl) { + //TODO: Why does this crash when enabled ??! + //p_navl->DeleteAllItems(); + p_navl->DestroyWindow(); + } mNavLists.pop_back(); - delete p_navl; + if (p_navl) { + delete p_navl; + } } + if (m_wndTree) m_wndTree.DeleteAllItems(); + if (m_wndPageList) m_wndPageList.DeleteAllItems(); + if (m_wndTab) { m_wndTab.DeleteAllItems(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-12-03 16:02:20
|
Revision: 2240 http://amis.svn.sourceforge.net/amis/?rev=2240&view=rev Author: daniel_weck Date: 2007-12-03 08:02:19 -0800 (Mon, 03 Dec 2007) Log Message: ----------- - Daniel WECK * Manually added the 2 new menu entries into resource.h.ini. This file will eventually be generated automatically based on resource.h (it's a simple format conversion) Modified Paths: -------------- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/DefaultLangpack/AmisLangpack/resource.h.ini Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2007-12-03 15:21:25 UTC (rev 2239) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2007-12-03 16:02:19 UTC (rev 2240) @@ -273,7 +273,7 @@ } AudioSequencePlayer::Instance()->Play(seq); } - } else if (nItemID >=0 && nItemID <=6) { // Yuuk ! UGLY ! This is only a temporary workaround ! //m_lastOpenPopupMenu == NULL && + } else if (nItemID >=0 && nItemID <=6) { //TODO: Yuuk ! UGLY ! This is only a temporary workaround ! //m_lastOpenPopupMenu == NULL && switch (nItemID) { case 0: Modified: branches/amis3/DefaultLangpack/AmisLangpack/resource.h.ini =================================================================== --- branches/amis3/DefaultLangpack/AmisLangpack/resource.h.ini 2007-12-03 15:21:25 UTC (rev 2239) +++ branches/amis3/DefaultLangpack/AmisLangpack/resource.h.ini 2007-12-03 16:02:19 UTC (rev 2240) @@ -144,6 +144,8 @@ IDS_FILE_OPEN_DAISY_BOOKS=61288 +ID_MENU_FILE_CLOSE=32871 +ID_MENU_FILE_OPENURL=32870 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-12-03 21:36:15
|
Revision: 2243 http://amis.svn.sourceforge.net/amis/?rev=2243&view=rev Author: daniel_weck Date: 2007-12-03 13:36:12 -0800 (Mon, 03 Dec 2007) Log Message: ----------- - Daniel WECK * Fixed bug: TTS speech rate was inverted. Modified Paths: -------------- branches/amis3/AmisAudio/AmisAudio.cpp branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp Modified: branches/amis3/AmisAudio/AmisAudio.cpp =================================================================== --- branches/amis3/AmisAudio/AmisAudio.cpp 2007-12-03 18:24:36 UTC (rev 2242) +++ branches/amis3/AmisAudio/AmisAudio.cpp 2007-12-03 21:36:12 UTC (rev 2243) @@ -473,14 +473,9 @@ void AmisAudio::adjustRate(double adjustment) { if (pDmpCtrl) { - if (adjustment < 0) {adjustment = 2;} else {adjustment = -2;} double value = mTau + adjustment; setRate(value); - return; } - double value = mTau + adjustment; - - setRate(value); } Modified: branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2007-12-03 18:24:36 UTC (rev 2242) +++ branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2007-12-03 21:36:12 UTC (rev 2243) @@ -1073,11 +1073,6 @@ } BOOL CDmpCtrl::setRate(double idRate) { - if (idRate != 1.0) { - int i = 1; //dsfds - } else { - int i = 1; //dsfds - } mRate = idRate; Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-03 18:24:36 UTC (rev 2242) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-03 21:36:12 UTC (rev 2243) @@ -57,6 +57,9 @@ #include "../../AmisSelfVoicing/TTSPlayer.h" //using namespace amis::tts; +#include "ambulant/gui/dx/dx_audio.h" +//#include "ambulant/gui/dx/dx_audio_player.h" + #ifdef _DEBUG #define new DEBUG_NEW #endif @@ -481,26 +484,27 @@ void CAmisGuiMFC2App::OnVolumeUp() { amis::audio::AmisAudio::Instance()->adjustVolume(10); - //TODO: where is Ambulant volume control ? - //ambulant::gui::dx::change_global_level(1.2); + ambulant::gui::dx::change_global_level(1.2); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_VOLUP, true, NULL); } void CAmisGuiMFC2App::OnVolumeDown() { amis::audio::AmisAudio::Instance()->adjustVolume(-10); - //TODO: where is Ambulant volume control ? - //ambulant::gui::dx::change_global_level(1.0/1.2); + ambulant::gui::dx::change_global_level(1.0/1.2); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_VOLDOWN, true, NULL); } void CAmisGuiMFC2App::OnSpeedUp() { - amis::audio::AmisAudio::Instance()->adjustRate(-0.2); + amis::audio::AmisAudio::Instance()->adjustRate(2); 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(-0.2); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_FASTER, true, NULL); } @@ -508,20 +512,27 @@ void CAmisGuiMFC2App::OnSpeedDown() { - amis::audio::AmisAudio::Instance()->adjustRate(0.2); + amis::audio::AmisAudio::Instance()->adjustRate(-2); 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(0.2); + //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_SLOWER, true, NULL); } void CAmisGuiMFC2App::OnSpeedNormal() { amis::audio::AmisAudio::Instance()->setRate(1.0); + amis::tts::TTSPlayer::Instance()->SetSpeechRate(0); + //TODO: this only works with my local hacked Ambulant API (addition of this setXX() function) + //ambulant::gui::dx::set_global_rate(1.0); + //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_NORMALSPEED, true, NULL); } Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp 2007-12-03 18:24:36 UTC (rev 2242) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp 2007-12-03 21:36:12 UTC (rev 2243) @@ -31,8 +31,10 @@ BOOL AmisDialogBase::PreTranslateMessage(MSG* pMsg) { - if (Preferences::Instance()->mbIsSelfVoicing == false) + if (Preferences::Instance()->mbIsSelfVoicing == false) { return CDialog::PreTranslateMessage(pMsg); + } + if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) { CWnd* cwnd = this->GetFocus(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-12-03 21:51:49
|
Revision: 2244 http://amis.svn.sourceforge.net/amis/?rev=2244&view=rev Author: daniel_weck Date: 2007-12-03 13:51:51 -0800 (Mon, 03 Dec 2007) Log Message: ----------- - Daniel WECK * Oops, previous commit did not work properly ! Fixed bug: TTS speech rate was inverted. Modified Paths: -------------- branches/amis3/AmisAudio/AmisAudio.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp Modified: branches/amis3/AmisAudio/AmisAudio.cpp =================================================================== --- branches/amis3/AmisAudio/AmisAudio.cpp 2007-12-03 21:36:12 UTC (rev 2243) +++ branches/amis3/AmisAudio/AmisAudio.cpp 2007-12-03 21:51:51 UTC (rev 2244) @@ -514,7 +514,7 @@ mTau=value; TRACE(_T("\n####################\n")); - TRACE(_T("\n#################### RATE BEFORE %lf\n", mTau)); + TRACE(_T("\n#################### RATE %lf\n", mTau)); if (mTau > 1.0) { @@ -536,8 +536,6 @@ //mTau=value; - TRACE(_T("\n#################### RATE AFTER %lf\n", mTau)); - TRACE(_T("\n####################\n")); pDmpCtrl->setRate(mTau); return; } Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-03 21:36:12 UTC (rev 2243) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-03 21:51:51 UTC (rev 2244) @@ -500,8 +500,7 @@ amis::audio::AmisAudio::Instance()->adjustRate(2); long currentRate = amis::tts::TTSPlayer::Instance()->GetSpeechRate(); - - amis::tts::TTSPlayer::Instance()->SetSpeechRate(currentRate+2); + 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(-0.2); @@ -515,8 +514,7 @@ amis::audio::AmisAudio::Instance()->adjustRate(-2); long currentRate = amis::tts::TTSPlayer::Instance()->GetSpeechRate(); - - amis::tts::TTSPlayer::Instance()->SetSpeechRate(currentRate-2); + 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(0.2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-12-03 22:40:54
|
Revision: 2245 http://amis.svn.sourceforge.net/amis/?rev=2245&view=rev Author: daniel_weck Date: 2007-12-03 14:40:56 -0800 (Mon, 03 Dec 2007) Log Message: ----------- - Daniel WECK * Fixed inverted Speed up / down (menu callbacks) * Fiddled with speed rate values, but the rendered audio is still weird: only the beginning of the phrase is accelerated, like rest clearly sounds slower...I have no idea why, we only use the SetCycleSpeed() method of Vupp. To be investigated. Modified Paths: -------------- branches/amis3/AmisAudio/AmisAudio.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp Modified: branches/amis3/AmisAudio/AmisAudio.cpp =================================================================== --- branches/amis3/AmisAudio/AmisAudio.cpp 2007-12-03 21:51:51 UTC (rev 2244) +++ branches/amis3/AmisAudio/AmisAudio.cpp 2007-12-03 22:40:56 UTC (rev 2245) @@ -473,7 +473,7 @@ void AmisAudio::adjustRate(double adjustment) { if (pDmpCtrl) { - double value = mTau + adjustment; + double value = mTau - adjustment; setRate(value); } } @@ -512,11 +512,7 @@ if (pDmpCtrl) { mTau=value; - - TRACE(_T("\n####################\n")); - TRACE(_T("\n#################### RATE %lf\n", mTau)); - if (mTau > 1.0) { double offset = mTau - 1.0; /* int n = offset / 0.2; Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-03 21:51:51 UTC (rev 2244) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-03 22:40:56 UTC (rev 2245) @@ -95,8 +95,8 @@ ON_COMMAND(ID_MENU_FILE_SEARCHDRIVE, OnSearchForBooks) ON_COMMAND(ID_MENU_FILE_LOADCD, OnLoadCd) ON_COMMAND(ID_MENU_PLAY_NORMALSPEED, OnSpeedNormal) - ON_COMMAND(ID_MENU_PLAY_SLOWER, OnSpeedUp) - ON_COMMAND(ID_MENU_PLAY_FASTER, OnSpeedDown) + ON_COMMAND(ID_MENU_PLAY_SLOWER, OnSpeedDown) + ON_COMMAND(ID_MENU_PLAY_FASTER, OnSpeedUp) ON_COMMAND(ID_MENU_PLAY_VOLUP, OnVolumeUp) ON_COMMAND(ID_MENU_PLAY_VOLDOWN, OnVolumeDown) END_MESSAGE_MAP() @@ -497,13 +497,13 @@ void CAmisGuiMFC2App::OnSpeedUp() { - amis::audio::AmisAudio::Instance()->adjustRate(2); + amis::audio::AmisAudio::Instance()->adjustRate(0.48); long currentRate = amis::tts::TTSPlayer::Instance()->GetSpeechRate(); - amis::tts::TTSPlayer::Instance()->SetSpeechRate(currentRate-2); + 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(-0.2); + //double rate = ambulant::gui::dx::change_global_rate(0.2); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_FASTER, true, NULL); } @@ -511,13 +511,13 @@ void CAmisGuiMFC2App::OnSpeedDown() { - amis::audio::AmisAudio::Instance()->adjustRate(-2); + amis::audio::AmisAudio::Instance()->adjustRate(-0.48); long currentRate = amis::tts::TTSPlayer::Instance()->GetSpeechRate(); - amis::tts::TTSPlayer::Instance()->SetSpeechRate(currentRate+2); + 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(0.2); + //double rate = ambulant::gui::dx::change_global_rate(-0.2); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_SLOWER, true, NULL); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-12-03 23:29:10
|
Revision: 2246 http://amis.svn.sourceforge.net/amis/?rev=2246&view=rev Author: daniel_weck Date: 2007-12-03 15:29:03 -0800 (Mon, 03 Dec 2007) Log Message: ----------- - Daniel WECK * Fixed bug: now plays both book and self-voicing UI with good acceleration settings. Slow-down is still missing, but that's a Vupp limitation as far as I can tell. Please note that I had to hack the Ambulant source code to achieve the desired speed sync between book and ui. The next revision of Ambulant will include the fix. Modified Paths: -------------- branches/amis3/AmisAudio/AmisAudio.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp Modified: branches/amis3/AmisAudio/AmisAudio.cpp =================================================================== --- branches/amis3/AmisAudio/AmisAudio.cpp 2007-12-03 22:40:56 UTC (rev 2245) +++ branches/amis3/AmisAudio/AmisAudio.cpp 2007-12-03 23:29:03 UTC (rev 2246) @@ -473,7 +473,7 @@ void AmisAudio::adjustRate(double adjustment) { if (pDmpCtrl) { - double value = mTau - adjustment; + double value = mTau + adjustment; setRate(value); } } @@ -522,6 +522,9 @@ } if (mTau < 1.0) { double offset = 1.0 - mTau; + + mTau = 0.5; + /* int n = offset / 0.2; offset *= 6; offset = n * 0.5; */ Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-03 22:40:56 UTC (rev 2245) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-03 23:29:03 UTC (rev 2246) @@ -497,27 +497,26 @@ void CAmisGuiMFC2App::OnSpeedUp() { - amis::audio::AmisAudio::Instance()->adjustRate(0.48); + amis::audio::AmisAudio::Instance()->adjustRate(1.12); 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(0.2); + double rate = ambulant::gui::dx::change_global_rate(1.12); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_FASTER, true, NULL); } void CAmisGuiMFC2App::OnSpeedDown() { - - amis::audio::AmisAudio::Instance()->adjustRate(-0.48); + amis::audio::AmisAudio::Instance()->adjustRate(-1.12); 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(-0.2); + double rate = ambulant::gui::dx::change_global_rate(-1.12); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_SLOWER, true, NULL); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-12-04 17:22:45
|
Revision: 2248 http://amis.svn.sourceforge.net/amis/?rev=2248&view=rev Author: daniel_weck Date: 2007-12-04 09:22:34 -0800 (Tue, 04 Dec 2007) Log Message: ----------- - Daniel WECK * Fixed URL vs FILE syntax problem (e.g. space escaped with %20) Modified Paths: -------------- branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp Modified: branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp =================================================================== --- branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp 2007-12-04 13:45:00 UTC (rev 2247) +++ branches/amis3/AmisCore/src/io/RecentBooksFileIO.cpp 2007-12-04 17:22:34 UTC (rev 2248) @@ -188,9 +188,9 @@ 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_url()); + local_file_name = amis::util::FilePathTools::getAsLocalFilePath(filepath->get_file()); else - local_file_name = amis::util::FilePathTools::getAsLocalFilePath(pFile->mFilePath.get_url()); + local_file_name = amis::util::FilePathTools::getAsLocalFilePath(pFile->mFilePath.get_file()); mpRecentBooks = pFile; Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-04 13:45:00 UTC (rev 2247) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-12-04 17:22:34 UTC (rev 2248) @@ -335,10 +335,18 @@ if (b_a_book_was_open) { + AudioSequencePlayer::Instance()->Stop(); + AudioSequencePlayer::playPromptFromStringId("generalBookError"); + AfxMessageBox(message2); openLastReadBook(); } - else AfxMessageBox(message1); + else + { + AudioSequencePlayer::Instance()->Stop(); + AudioSequencePlayer::playPromptFromStringId("generalBookError"); + AfxMessageBox(message1); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-12-04 17:40:45
|
Revision: 2249 http://amis.svn.sourceforge.net/amis/?rev=2249&view=rev Author: daniel_weck Date: 2007-12-04 09:40:41 -0800 (Tue, 04 Dec 2007) Log Message: ----------- - Daniel WECK * (more) Fixed URL vs FILE syntax problem (e.g. space escaped with %20) NOTE: CSS still not working. Modified Paths: -------------- branches/amis3/AmisCore/src/io/BookmarksFileIO.cpp branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/MultipleBooksOnVolumeDialog.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp Modified: branches/amis3/AmisCore/src/io/BookmarksFileIO.cpp =================================================================== --- branches/amis3/AmisCore/src/io/BookmarksFileIO.cpp 2007-12-04 17:22:34 UTC (rev 2248) +++ branches/amis3/AmisCore/src/io/BookmarksFileIO.cpp 2007-12-04 17:40:41 UTC (rev 2249) @@ -417,7 +417,7 @@ pWriter = ((DOMImplementationLS*)pImpl)->createDOMWriter(); //make sure the path to the file exists - string dir = amis::util::FilePathTools::getParentDirectory(filepath->get_url()); + string dir = amis::util::FilePathTools::getParentDirectory(filepath->get_file()); if (access(dir.c_str(), 0) == -1) { #if defined(AMIS_PLATFORM_WINDOWS) Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-12-04 17:22:34 UTC (rev 2248) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-12-04 17:40:41 UTC (rev 2249) @@ -173,14 +173,14 @@ { const ambulant::net::url* filepath = this->getSpine()->getNextFile(); if (filepath) - amis::gui::MainWndParts::Instance()->mpMmView->ScheduleReplaceDoc(filepath->get_url()); + amis::gui::MainWndParts::Instance()->mpMmView->ScheduleReplaceDoc(filepath->get_file()); } void DtbWithHooks::previousSmilDocument() { const ambulant::net::url* filepath = this->getSpine()->getPreviousFile(); if (filepath) - amis::gui::MainWndParts::Instance()->mpMmView->ScheduleReplaceDoc(filepath->get_url()); + amis::gui::MainWndParts::Instance()->mpMmView->ScheduleReplaceDoc(filepath->get_file()); } void DtbWithHooks::loadNavNode(nav::NavNode* pNav) Modified: branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2007-12-04 17:22:34 UTC (rev 2248) +++ branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2007-12-04 17:40:41 UTC (rev 2249) @@ -623,7 +623,7 @@ if (!SUCCEEDED(res)) return NULL; BSTR css_path_bstr; - CString css_path_cstr = A2T(stylesheet->get_url().c_str()); + CString css_path_cstr = A2T(stylesheet->get_file().c_str()); css_path_bstr = css_path_cstr.AllocSysString(); IHTMLStyleSheet* pStyleSheet; Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/MultipleBooksOnVolumeDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/MultipleBooksOnVolumeDialog.cpp 2007-12-04 17:22:34 UTC (rev 2248) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/MultipleBooksOnVolumeDialog.cpp 2007-12-04 17:40:41 UTC (rev 2249) @@ -71,7 +71,7 @@ for (it = mpUrlList->begin(); it != mpUrlList->end(); ++it) { CString result; - result = A2T(it->get_url().c_str()); + result = A2T(it->get_file().c_str()); p_filelist->AddString(result); i++; } Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp 2007-12-04 17:22:34 UTC (rev 2248) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/SearchForBooksDialog.cpp 2007-12-04 17:40:41 UTC (rev 2249) @@ -102,7 +102,7 @@ for (it = p_search_results->begin(); it != p_search_results->end(); ++it) { CString result; - result = A2T(it->get_url().c_str()); + result = A2T(it->get_file().c_str()); p_filelist->AddString(result); i++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2008-01-14 00:08:13
|
Revision: 2279 http://amis.svn.sourceforge.net/amis/?rev=2279&view=rev Author: daniel_weck Date: 2008-01-13 16:08:16 -0800 (Sun, 13 Jan 2008) Log Message: ----------- - Daniel WECK * Moving resource.h.ini so that the same configuration file is used for all languages. Modified Paths: -------------- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp Added Paths: ----------- branches/amis3/bin/settings/resource.h.ini Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp 2008-01-13 07:25:53 UTC (rev 2278) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AccessibleUI/AccessibleUIDataReader.cpp 2008-01-14 00:08:16 UTC (rev 2279) @@ -49,9 +49,10 @@ string DataReader::getIniFilePath() { if (! mIniFilePath.empty()) return mIniFilePath; - mIniFilePath = amis::Preferences::Instance()->mUiLangDir; + //mIniFilePath = amis::Preferences::Instance()->mUiLangDir; + mIniFilePath = "./settings/"; mIniFilePath = amis::util::FilePathTools::goRelativePath(mAppPath, mIniFilePath); - mIniFilePath = amis::util::FilePathTools::goRelativePath(mIniFilePath, "resource.h.ini"); + mIniFilePath = amis::util::FilePathTools::goRelativePath(mIniFilePath, "./resource.h.ini"); mIniFilePath = amis::util::FilePathTools::getAsLocalFilePath(mIniFilePath); return mIniFilePath; Added: branches/amis3/bin/settings/resource.h.ini =================================================================== --- branches/amis3/bin/settings/resource.h.ini (rev 0) +++ branches/amis3/bin/settings/resource.h.ini 2008-01-14 00:08:16 UTC (rev 2279) @@ -0,0 +1,156 @@ +; +[resources] + + + + +IDD_ABOUTBOX=100 +IDS_PROPSHT_CAPTION=102 +IDD_SIDEBAR=103 +IDD_PROPPAGE2=106 +IDD_PROPPAGE1=110 +IDD_PROPPAGE4=112 +ID_FOCUS_ON_SIDEBAR=123 +ID_HEAR_LAST_PROMPT=124 +ID_HEAR_INSTRUCTIONS=125 +ID_HEAR_LAST_TEXT_ENTRY=126 +ID_FOCUS_ON_TEXT=127 +IDR_MAINFRAME=128 +IDR_AMISTYPE=129 +ID_INCREASE_SECTION_DEPTH=130 +ID_DECREASE_SECTION_DEPTH=131 +ID_RESET_HIGHLIGHT_COLORS=132 +ID_TOGGLE_AUDIO_CONTENT_PLAYBACK=133 +ID_TOGGLE_AUDIO_SELFVOICING_PLAYBACK 134 +IDD_FIND=147 +VIEW_MENU_BASE_ID=150 +IDD_SKIP=153 +IDI_AMIS=164 +IDD_SEARCHDAISY=177 +IDD_GOTOPAGE=180 +IDD_CDSEARCH=181 +IDD_FULLSUMMARY=182 +IDD_CURRENTPOSITION=183 +IDD_NAVIGATIONOPTIONS=184 +IDI_LANGICON=185 +IDD_PROPPAGE3=185 +IDB_BOOKSHELFMAG=186 +BOOK_BASE_ID=200 +SECTION_DEPTH_BASE_ID=250 +NAVLIST_BASE_ID=300 +ID_MENU_GOTO_PAGE=352 +ID_MENU_FIND_IN_TEXT=353 +BOOKMARKS_BASE_ID=400 +IDC_TREE=1000 +IDC_TAB=1001 +IDC_SEARCHSTRING=1003 +IDC_SUMMARY=1004 +IDC_BASIC=1010 +IDC_BTN_BORDER=1011 +IDC_BTN_TEXTBG=1012 +IDC_BTN_PAGEBG=1013 +IDC_LIST_PAGE=1015 +IDC_TTSVOICE=1020 +IDC_BTN_RESETCOLORS=1028 +IDC_STARTSEARCH=1030 +IDC_BTN_TEXTFG=1030 +IDC_BTN_PAGEFG=1032 +IDC_SELFVOICING=1034 +IDC_PROMPTONBASICVIEW=1036 +IDC_BMKDIR=1037 +IDC_BROWSE=1038 +IDC_LOADLASTDTB=1041 +IDC_STOPSEARCH=1048 +IDC_PICTURE=1050 +IDC_SEARCHING=1051 +IDC_FILESFOUND=1052 +IDC_SKIPS=1054 +IDC_PAGENUM=1055 +IDC_SEARCHPATH=1056 +IDC_BOOKLIST=1058 +IDC_OPENBOOK=1059 +IDC_CANCEL=1060 +IDC_LANGICON=1065 +IDC_BTN_SELECTLANG=1066 +IDC_CANCELBUTTON=1067 +IDC_FINDNEXT=1068 +IDC_FINDPREV=1069 +IDC_BMKDIRBROWSE=1069 +IDC_BMKDIRLABEL=1071 +IDC_SELTTSLABEL=1072 +IDC_PHRASES=1073 +IDC_CONTRAST=1074 +IDC_LISTCAPTION=1075 +IDC_PHRASEPREVIEW=1075 +IDC_CONTRASTPREVIEW=1076 +IDC_AMISNAME=1076 +IDC_PAGEFG=1077 +IDC_COPYRIGHT=1077 +IDC_PAGEBG=1078 +IDC_TEXTFG=1079 +IDC_TEXTBG=1080 +IDC_BORDER=1081 +ID_MENU_FIND_IN_TEXT_NEXT=9000 +IDC_LANGLIST=9001 +ID_MENU_FIND_IN_TEXT_PREV=9001 +IDC_CURRLANG=9002 +IDC_VERSION=9006 +IDC_VERSIONNOTE=9007 +ID_MENU_FILE_LOADCD=32771 +ID_MENU_FILE_SEARCHDRIVE=32772 +ID_MENU_VIEW_BASIC=32776 +ID_MENU_VIEW_LARGEFONT=32778 +ID_MENU_VIEW_RESET=32779 +ID_MENU_PLAY_PLAY=32787 +ID_MENU_PLAY_PAUSE=32788 +ID_MENU_PLAY_FASTER=32789 +ID_MENU_PLAY_NORMALSPEED=32791 +ID_MENU_HELP_HELP=32798 +ID_MENU_INFO_SUMMARY=32800 +ID_MENU_FILE_PREFERENCES=32802 +ID_MENU_INFO_NAVOPTIONS=32804 +ID_MENU_INFO_CURRENTPOSITION=32805 +ID_MENU_VIEW_RESETFONT=32814 +ID_VIEW_CONTRAST=32818 +ID_MENU_VIEW_CONTRAST=32818 +ID_MENU_PLAY_ESCAPE=32819 +ID_MENU_INFO_SKIP=32820 +ID_MENU_HELP_CONTENTS=32821 +ID_MENU_PLAY_SLOWER=32822 +ID_MENU_FILE_EXIT=32823 +ID_MENU_VIEW_SIDEBAR_ONOFF=32825 +ID_FILE_RECENT_EMPTY=32828 +ID_EMPTY=32830 +ID_MENU_NAV_NEXTSECTION=32833 +ID_MENU_NAV_PREVSECTION=32834 +ID_MENU_NAV_PREVPHRASE=32835 +ID_MENU_NAV_NEXTPHRASE=32836 +ID_MENU_BMK_ADD=32837 +ID_MENU_FILE_OPEN=32838 +ID_MENU_HELP_ABOUT=32839 +ID_MENU_PLAY_VOLUP=32844 +ID_MENU_PLAY_VOLDOWN=32845 +ID_MENU_NAV_PREVPAGE=32854 +ID_MENU_NAV_NEXTPAGE=32856 +ID_MENU_NAV_FINDINTEXT=32859 +ID_MENU_NAV_GOTOPAGE=32860 +ID_MENU_PLAYPAUSE=32865 +IDS_NOSKIP=61245 +IDS_SELFOLDER_TITLE=61258 +IDS_SELFOLDER_INSTR=61259 +IDS_FOLDERDOESNOTEXIST=61279 +IDS_FOLDERINVALID=61280 +IDS_FOLDERCANTBECREATED=61281 +IDS_FILE_OPEN_DAISY_BOOKS=61288 + +ID_MENU_FILE_CLOSE=32871 +ID_MENU_FILE_OPENURL=32870 +IDD_OPENURL=190 + +_APS_3D_CONTROLS=1 +_APS_NEXT_RESOURCE_VALUE=190 +_APS_NEXT_COMMAND_VALUE=32866 +_APS_NEXT_CONTROL_VALUE=1078 +_APS_NEXT_SYMED_VALUE=140 + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2008-01-14 04:24:18
|
Revision: 2285 http://amis.svn.sourceforge.net/amis/?rev=2285&view=rev Author: daniel_weck Date: 2008-01-13 20:24:19 -0800 (Sun, 13 Jan 2008) Log Message: ----------- - Daniel WECK * Volume control fixed (now works for UI as well as BOOK). HOWEVER: I have enabled volume control on the book only, because it does not really make sense to provide a feature that the user already has via the OS-level volume control (global setting). AMIS provides an extra feature which is to adjust the BOOK volume, in case the MP3 audio does not match the OS volume. Modified Paths: -------------- branches/amis3/AmisAudio/AmisAudio.cpp branches/amis3/AmisAudio/AmisAudio.h branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp Modified: branches/amis3/AmisAudio/AmisAudio.cpp =================================================================== --- branches/amis3/AmisAudio/AmisAudio.cpp 2008-01-14 03:41:10 UTC (rev 2284) +++ branches/amis3/AmisAudio/AmisAudio.cpp 2008-01-14 04:24:19 UTC (rev 2285) @@ -86,7 +86,7 @@ pDmpCtrl = 0; mTau=1.0; mState=NOTACTIVE; - mVolume=100; + mVolume=1.0; mbAudioPlaybackEnabled = true; @@ -128,7 +128,7 @@ if (pDmpCtrl) { mState=PAUSE; //ACTIVE mTau=1.0; - mVolume = 100; + mVolume = 1.0; return; } switch(mState) @@ -139,7 +139,7 @@ mState=PAUSE; //ACTIVE // mRate = 1.0; mTau=1.0; - mVolume = 100; + mVolume = 1.0; return; } default: @@ -243,8 +243,7 @@ } } - //long volume = mVolume/10; - //pDmpCtrl->setVolume(volume); + pDmpCtrl->setVolume((long)(100*mVolume)); pDmpCtrl->play(); mState = PLAYING; return; @@ -407,7 +406,7 @@ getVolume() function ****************************************************************/ -unsigned AmisAudio::getVolume() +double AmisAudio::getVolume() { return mVolume; @@ -417,10 +416,10 @@ /**************************************************************** setVolume(char * value) function ****************************************************************/ -void AmisAudio::setVolume(unsigned int value) +void AmisAudio::setVolume(double value) { + mVolume = value; - switch(mState) { @@ -435,38 +434,24 @@ case PAUSE : case PLAYING : { - if(value>=0 && value<=100) - { - mVolume=value; - + if (pDmpCtrl) { - pDmpCtrl->setVolume((long)((double)value/10.0)); + pDmpCtrl->setVolume((long)(100*mVolume)); return ; } - - return; - //return returnMessage; - } - else - { - return; - //return"Volume out of range"; - } } } } //adjustment is positive or negative (louder or softer) -void AmisAudio::adjustVolume(int adjustment) +void AmisAudio::adjustVolume(double adjustment) { - int value; +mVolume *= adjustment; - value = mVolume + adjustment; - - setVolume(value); + setVolume(mVolume); } Modified: branches/amis3/AmisAudio/AmisAudio.h =================================================================== --- branches/amis3/AmisAudio/AmisAudio.h 2008-01-14 03:41:10 UTC (rev 2284) +++ branches/amis3/AmisAudio/AmisAudio.h 2008-01-14 04:24:19 UTC (rev 2285) @@ -108,14 +108,14 @@ void stop(); void pause(); int resume(); - unsigned int getVolume(); - void setVolume (unsigned int); + double getVolume(); + void setVolume (double); double getRate(); void setRate(double); bool isPlaying(); bool isActive(); - void adjustVolume(int); + void adjustVolume(double); void adjustRate(double); typedef void (*sendMessageCallbackFn)(void); @@ -126,7 +126,7 @@ //member variables std::string mFileName; //The file name being played - unsigned int mVolume; //The volume of the stream + double mVolume; //The volume of the stream State mState; //The state of the player double mTau; //This is the playback speed Modified: branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2008-01-14 03:41:10 UTC (rev 2284) +++ branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2008-01-14 04:24:19 UTC (rev 2285) @@ -6,7 +6,7 @@ #include "DmpCtl.h" #include "DmpPpg.h" - +#include <math.h> #include <string> using namespace std; @@ -1192,16 +1192,23 @@ IBasicAudio *pIBA; + if (pIGB->QueryInterface(IID_IBasicAudio, (void**) &pIBA) != S_OK) { + logSession("Set volume failed"); return false; } + bool bReturn = true; - ilVolume = 0 - ((10 - ilVolume) * 300); + +// val is the attenuation in decibels +// can be 0 to 100 - if (pIGB->QueryInterface(IID_IBasicAudio, (void**) &pIBA) != S_OK) { - logSession("Set volume failed"); return false; } +if (ilVolume < 0) ilVolume = 0; + if (ilVolume > 100) ilVolume = 100; + long cdb = (long)(20.0*log10((double)ilVolume/100.0)*100); - // Full volume is 0, and \x81E0,000 is silence - if (pIBA->put_Volume(ilVolume) != S_OK) bReturn = false; + //ilVolume = 0 - ((10 - ilVolume) * 300); + if (pIBA->put_Volume(cdb) != S_OK) bReturn = false; + if (bReturn == false) logSession("Set volume failed"); pIBA->Release(); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2008-01-14 03:41:10 UTC (rev 2284) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2008-01-14 04:24:19 UTC (rev 2285) @@ -494,14 +494,14 @@ void CAmisGuiMFC2App::OnVolumeUp() { - amis::audio::AmisAudio::Instance()->adjustVolume(10); + //amis::audio::AmisAudio::Instance()->adjustVolume(1.2); REMOVED because it makes more sense to allow book volume control than the whole application: otherwise users would use their OS-level volume control. ambulant::gui::dx::change_global_level(1.2); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_VOLUP, true, NULL); } void CAmisGuiMFC2App::OnVolumeDown() { - amis::audio::AmisAudio::Instance()->adjustVolume(-10); + //amis::audio::AmisAudio::Instance()->adjustVolume(1.0/1.2); REMOVED because it makes more sense to allow book volume control than the whole application: otherwise users would use their OS-level volume control. ambulant::gui::dx::change_global_level(1.0/1.2); //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_VOLDOWN, true, NULL); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-01-28 05:05:48
|
Revision: 2291 http://amis.svn.sourceforge.net/amis/?rev=2291&view=rev Author: marisademeglio Date: 2008-01-27 21:05:54 -0800 (Sun, 27 Jan 2008) Log Message: ----------- Added new preferences dialog and changed preferences class Renamed CAmisGuiMFC2App to CAmisApp Reorganized some functions in AmisGuiMFC2.cpp to keep the menu handler section clean. Modified Paths: -------------- branches/amis3/AmisCore/include/AmisCore.h 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/AmisGuiMFC2.h branches/amis3/AmisGuiMFC2/resource.h branches/amis3/AmisGuiMFC2/src/Preferences.cpp branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp branches/amis3/bin/settings/amisPrefs.xml.default Added Paths: ----------- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp Removed Paths: ------------- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp Modified: branches/amis3/AmisCore/include/AmisCore.h =================================================================== --- branches/amis3/AmisCore/include/AmisCore.h 2008-01-21 15:33:37 UTC (rev 2290) +++ branches/amis3/AmisCore/include/AmisCore.h 2008-01-28 05:05:54 UTC (rev 2291) @@ -68,6 +68,13 @@ namespace amis { + //get the media primitives declared first + class MediaNode; + class TextNode; + class ImageNode; + class AudioNode; + class MediaGroup; + typedef vector<string> StdStringList; typedef vector<ambulant::net::url> UrlList; @@ -77,18 +84,16 @@ typedef stdext::hash_map<std::string, std::string> StringMap; typedef stdext::hash_map<std::string, ambulant::net::url> UrlMap; typedef stdext::hash_map<std::string, bool> BooleanMap; + typedef stdext::hash_map<std::string, amis::MediaGroup*> StringMediaMap; #elif defined(AMIS_COMPILER_GCC) typedef __gnu_cxx::hash_map<std::string, std::string> StringMap; typedef __gnu_cxx::hash_map<std::string, ambulant::net::url> UrlMap; typedef __gnu_cxx::hash_map<std::string, bool> BooleanMap; + typedef __gnu_cxx::hash_map<std::string, amis::MediaGroup*> StringMediaMap; #endif - class MediaNode; - class TextNode; - class ImageNode; - class AudioNode; - class MediaGroup; + class Error; class RecentBookEntry; class RecentBooks; Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-01-21 15:33:37 UTC (rev 2290) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-01-28 05:05:54 UTC (rev 2291) @@ -88,22 +88,6 @@ BOTTOMMARGIN, 280 END - IDD_LANGUAGES, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 222 - TOPMARGIN, 7 - BOTTOMMARGIN, 215 - END - - IDD_PREFERENCES, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 249 - TOPMARGIN, 7 - BOTTOMMARGIN, 228 - END - IDD_GOTOPAGE, DIALOG BEGIN LEFTMARGIN, 7 @@ -151,6 +135,14 @@ TOPMARGIN, 7 BOTTOMMARGIN, 63 END + + IDD_PREFERENCES, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 249 + TOPMARGIN, 7 + BOTTOMMARGIN, 199 + END END #endif // APSTUDIO_INVOKED @@ -294,40 +286,6 @@ PUSHBUTTON "Cancel",IDCANCEL,158,266,50,14 END -IDD_LANGUAGES DIALOGEX 0, 0, 229, 223 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Language" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - LTEXT "Here you can change the language of the software. New language packs are detected automatically.", - IDC_STATIC,7,7,215,20 - ICON IDI_LANGICON,IDC_LANGICON,7,31,20,20 - LTEXT "You are currently using AMIS in",IDC_CURRLANG,34,35,142, - 8 - LTEXT "Your language choices are:",IDC_STATIC,7,57,56,8 - CONTROL "List1",IDC_LANGLIST,"SysListView32",LVS_SINGLESEL | - LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,77,215,111 - PUSHBUTTON "Select Language",IDC_BTN_SELECTLANG,165,200,57,15 -END - -IDD_PREFERENCES DIALOGEX 0, 0, 256, 236 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "General Preferences" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - CONTROL "Use self-voicing",IDC_SELFVOICING,"Button", - BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,8,8,75,10 - LTEXT "Select TTS voice:",IDC_SELTTSLABEL,7,32,59,8 - COMBOBOX IDC_TTSVOICE,7,47,108,88,CBS_DROPDOWNLIST | CBS_SORT | - WS_VSCROLL | WS_TABSTOP - CONTROL "Pause AMIS when I switch to another program.", - IDC_PAUSEONLOSTFOCUS,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,7,77,164,10 - CONTROL "Load the most recently read book when AMIS starts.", - IDC_LOADLASTDTB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, - 106,181,10 -END - IDD_GOTOPAGE DIALOGEX 0, 0, 138, 66 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Go To Page" @@ -412,7 +370,37 @@ PUSHBUTTON "Cancel",IDCANCEL,127,49,50,14 END +IDD_PREFERENCES DIALOGEX 0, 0, 256, 206 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | + WS_SYSMENU +CAPTION "Preferences" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "Use self-voicing",IDC_SELFVOICING,"Button", + BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,7,7,241,10 + LTEXT "Select TTS voice:",IDC_SELTTSLABEL,7,22,242,8 + COMBOBOX IDC_TTSVOICE,7,35,108,88,CBS_DROPDOWNLIST | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + CONTROL "Pause audio when switching applications", + IDC_PAUSEONLOSTFOCUS,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,7,59,242,10 + CONTROL "Highlight text as it is read aloud",IDC_HIGHLIGHTTEXT, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,78,242,10 + CONTROL "Load the most recently read book on startup", + IDC_LOADLASTDTB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, + 98,242,10 + CONTROL "Start in basic view mode",IDC_STARTBASIC,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,117,242,10 + LTEXT "You are currently using AMIS in:",IDC_CURRLANG,7,140, + 242,8 + COMBOBOX IDC_LANGCOMBO,7,153,113,30,CBS_DROPDOWN | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + ICON IDI_LANGICON,IDC_LANGICON,136,151,20,20 + DEFPUSHBUTTON "OK",IDOK,57,185,50,14 + PUSHBUTTON "Cancel",IDCANCEL,112,185,50,14 +END + ///////////////////////////////////////////////////////////////////////////// // // Bitmap Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2008-01-21 15:33:37 UTC (rev 2290) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2008-01-28 05:05:54 UTC (rev 2291) @@ -224,6 +224,9 @@ RelativePath=".\include\gui\dialogs\OpenUrlDialog.h"> </File> <File + RelativePath=".\include\gui\dialogs\PreferencesDialog.h"> + </File> + <File RelativePath=".\include\gui\dialogs\SearchForBooksDialog.h"> </File> <File @@ -521,6 +524,9 @@ </FileConfiguration> </File> <File + RelativePath=".\src\gui\dialogs\PreferencesDialog.cpp"> + </File> + <File RelativePath=".\src\gui\dialogs\SearchForBooksDialog.cpp"> </File> <File Modified: branches/amis3/AmisGuiMFC2/include/Preferences.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/Preferences.h 2008-01-21 15:33:37 UTC (rev 2290) +++ branches/amis3/AmisGuiMFC2/include/Preferences.h 2008-01-28 05:05:54 UTC (rev 2291) @@ -27,6 +27,7 @@ #include "util/Color.h" #include <string> #include "AmisCore.h" +#include "ModuleDescData.h" namespace amis { @@ -39,33 +40,45 @@ static Preferences* Instance(); void DestroyInstance(); ~Preferences(); + void scanAll(); + +private: void scanDirectoriesForCssFiles(); + void scanDirectoriesForLanguagePackFiles(); + void processLanguagePackModuleDescData(amis::ModuleDescData*); + void updateCurrentLanguagePackDirectory(); - //app/general - string mUiLangDir; +public: + string mUiLangId; bool mbStartBasicView; - string mUserBmkDir; - bool mbLoadLastDtb; - bool mbPromptOnBasicView; + bool mbLoadLastBook; bool mbPauseOnApplicationLostFocus; - - //Self Voicing bool mbIsSelfVoicing; int mTTSVoice; bool mbUseTTSNotAudio; - - //did AMIS exit cleanly last time? bool mbExitWasClean; + //Directories + string mUserBmkDir; + //the root language packs directory + string mUiLangDir; + string mFontsizeCssDir; + string mContrastCssDir; + //map the id of the language to the media label for the language + amis::StringMediaMap mLanguagePackLabels; + //CSS files - //directories get scanned, files are applied in alphabetical order - string mFontsizeCssDir; + //the list gets build from scanning the above directories + //at runtime, the files are applied/cycled through in alphabetical order amis::UrlList mFontsizeCssFiles; - string mContrastCssDir; amis::UrlList mContrastCssFiles; - //one single default CSS file for user-preferred styles ambulant::net::url mDefaultCssFile; + ambulant::net::url mZed2005CssFile; + //our currently-selected language pack's directory + std::string mCurrentLanguagePackDir; + + //the source preferences XML file ambulant::net::url mSourceUrl; //these values come from parsing default.css Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2008-01-21 15:33:37 UTC (rev 2290) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisGuiMFC2.h 2008-01-28 05:05:54 UTC (rev 2291) @@ -49,16 +49,15 @@ { namespace gui { -class CAmisGuiMFC2App : public CWinApp +class CAmisApp : public CWinApp { public: - CAmisGuiMFC2App(); + CAmisApp(); public: - -static bool beforeModalBox(); -static void afterModalBox(bool b_was_playing); -static void generalBookErrorMsgBox(CString str); + static bool beforeModalBox(); + static void afterModalBox(bool b_was_playing); + static void generalBookErrorMsgBox(CString str); virtual BOOL InitInstance(); virtual int ExitInstance(); @@ -94,14 +93,12 @@ afx_msg void OnToggleContrast(); afx_msg void OnSearchForBooks(); afx_msg void OnLoadCd(); - afx_msg void OnVolumeUp(); afx_msg void OnVolumeDown(); - afx_msg void OnSpeedUp(); afx_msg void OnSpeedDown(); afx_msg void OnSpeedNormal(); - + afx_msg void OnPreferences(); protected: HMENU m_hMDIMenu; HACCEL m_hMDIAccel; @@ -125,5 +122,5 @@ } } -extern amis::gui::CAmisGuiMFC2App theApp; +extern amis::gui::CAmisApp theApp; #endif \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/resource.h =================================================================== --- branches/amis3/AmisGuiMFC2/resource.h 2008-01-21 15:33:37 UTC (rev 2290) +++ branches/amis3/AmisGuiMFC2/resource.h 2008-01-28 05:05:54 UTC (rev 2291) @@ -6,9 +6,7 @@ #define IDS_PROPSHT_CAPTION 102 #define IDD_SIDEBAR 103 #define IDD_PROPPAGE1 110 -#define IDD_PREFERENCES 110 #define IDD_PROPPAGE4 112 -#define IDD_LANGUAGES 112 #define ID_FOCUS_ON_SIDEBAR 123 #define ID_HEAR_LAST_PROMPT 124 #define ID_HEAR_INSTRUCTIONS 125 @@ -35,6 +33,7 @@ #define IDB_BOOKSHELFMAG 186 #define IDD_DIALOG1 190 #define IDD_OPENURL 190 +#define IDD_PREFERENCES 191 #define BOOK_BASE_ID 200 #define SECTION_DEPTH_BASE_ID 250 #define NAVLIST_BASE_ID 300 @@ -59,6 +58,8 @@ #define IDC_BMKDIR 1037 #define IDC_BROWSE 1038 #define IDC_LOADLASTDTB 1041 +#define IDC_HIGHLIGHTTEXT 1042 +#define IDC_STARTBASIC 1043 #define IDC_STOPSEARCH 1048 #define IDC_PICTURE 1050 #define IDC_SEARCHING 1051 @@ -98,6 +99,8 @@ #define IDC_PUBLICATIONINFOCAPTION 1084 #define IDC_CURRENTPOSITION 1085 #define IDC_SEARCHINSTRUCTIONS 1088 +#define IDC_LANGCOMBO 1095 +#define IDC_COMBO1 1096 #define ID_MENU_FIND_IN_TEXT_NEXT 9000 #define IDC_LANGLIST 9001 #define ID_MENU_FIND_IN_TEXT_PREV 9001 @@ -158,9 +161,9 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 191 +#define _APS_NEXT_RESOURCE_VALUE 192 #define _APS_NEXT_COMMAND_VALUE 32875 -#define _APS_NEXT_CONTROL_VALUE 1093 +#define _APS_NEXT_CONTROL_VALUE 1097 #define _APS_NEXT_SYMED_VALUE 141 #endif #endif Modified: branches/amis3/AmisGuiMFC2/src/Preferences.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2008-01-21 15:33:37 UTC (rev 2290) +++ branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2008-01-28 05:05:54 UTC (rev 2291) @@ -25,6 +25,7 @@ #include "gui/AmisGuiMFC2.h" #include "util/SearchForFilesMFC.h" #include "util/FilePathTools.h" +#include "io/ModuleDescReader.h" using namespace amis; @@ -32,11 +33,8 @@ Preferences* Preferences::Instance() { - if (pinstance == 0) // is it the first call? - { - pinstance = new Preferences; // create sole instance - } - return pinstance; // address of sole instance + if (pinstance == 0) pinstance = new Preferences; + return pinstance; } @@ -47,11 +45,11 @@ Preferences::Preferences() { + mUiLangId = "eng-US"; mbPauseOnApplicationLostFocus = true; mbIsSelfVoicing = false; mbUseTTSNotAudio = false; - mbLoadLastDtb = false; - mbPromptOnBasicView = false; + mbLoadLastBook = false; mbStartBasicView = false; mTTSVoice = -1; mbExitWasClean = true; @@ -59,20 +57,41 @@ mContrastCssFiles.clear(); //note that file paths here are hardcoded relative to the application directory //whereas in the prefs XML file, they are relative to the prefs XML file + //they get overridden by reading in the preferences file; these defaults are just here as a safety measure mFontsizeCssDir = "./settings/css/font/"; mContrastCssDir = "./settings/css/contrast/"; - mUiLangDir = "./settings/lang/eng-US"; + mUiLangDir = "./settings/lang/"; mUserBmkDir = "./settings/bmk/"; ambulant::net::url app_path = ambulant::net::url::from_filename(theApp.getAppPath()); mDefaultCssFile = ambulant::net::url::from_filename("./settings/css/default.css"); mDefaultCssFile = mDefaultCssFile.join_to_base(app_path); + mZed2005CssFile = ambulant::net::url::from_filename("./settings/css/dtbook.2005.basic.css"); + mZed2005CssFile = mZed2005CssFile.join_to_base(app_path); mHighlightFG.set("000000"); mHighlightBG.set("FFFF00"); mFontName = "Arial"; } +//this function should be called after the preferences XML file has been parsed +void Preferences::scanAll() +{ + updateCurrentLanguagePackDirectory(); + scanDirectoriesForCssFiles(); + scanDirectoriesForLanguagePackFiles(); + +} + +void Preferences::updateCurrentLanguagePackDirectory() +{ + mCurrentLanguagePackDir = mUiLangDir; + //make sure it ends with a slash + int last_char = mCurrentLanguagePackDir.size() - 1; + if (mCurrentLanguagePackDir[last_char] != '/') mCurrentLanguagePackDir.append("/"); + mCurrentLanguagePackDir += mUiLangId + "/"; +} + void Preferences::scanDirectoriesForCssFiles() { amis::util::SearchForFilesMFC searcher; @@ -84,16 +103,66 @@ { mFontsizeCssFiles = *searcher.getSearchResults(); } - else AfxMessageBox(_T("No fontsize css files found"));//TODO Log this message instead + else TRACE(_T("No fontsize css files found"));//TODO Log this message instead searcher.clearSearchResults(); if (searcher.startSearch(amis::util::FilePathTools::getAsLocalFilePath(mContrastCssDir)) > 0) { mContrastCssFiles = *searcher.getSearchResults(); } - else AfxMessageBox(_T("No contrast css files found"));//TODO Log this message instead + else TRACE(_T("No contrast css files found"));//TODO Log this message instead } +//search for "moduleDesc.xml" files that inside the root language pack directory +//save the ones that have type="langpack" enabled="yes" on the root moduleDesc element +//store the language id and media group of the language label +void Preferences::scanDirectoriesForLanguagePackFiles() +{ + amis::util::SearchForFilesMFC searcher; + searcher.addSearchCriteria("moduleDesc.xml"); + //these files will only bother developers + searcher.addSearchExclusionCriteria(".svn"); + searcher.setRecursiveSearch(true); + if (searcher.startSearch(amis::util::FilePathTools::getAsLocalFilePath(mUiLangDir)) > 0) + { + amis::UrlList list = *searcher.getSearchResults(); + for (int i = 0; i<list.size(); i++) + { + amis::io::ModuleDescReader reader; + if (reader.readFromFile(&list[i])) + { + amis::ModuleDescData* p_data = reader.getModuleDescData(); + processLanguagePackModuleDescData(p_data); + if (p_data != NULL) delete p_data; + } + else + { + //TODO: log error + } + } + } + else TRACE(_T("No language pack files found"));//TODO Log this message instead +} + +void Preferences::processLanguagePackModuleDescData(amis::ModuleDescData* pData) +{ + if (pData == NULL) + { + //TODO : log error + return; + } + + if (pData->isEnabled() && pData->getModuleType() == amis::ModuleDescData::LANGPACK) + { + //track the media label and id of this language + amis::MediaGroup* p_media = pData->getLabel(); + string id = pData->getId(); + mLanguagePackLabels[id] = p_media; + } +} + Preferences::~Preferences() { + //TODO: delete the language pack media groups } + Copied: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp (from rev 2290, branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp) =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-01-28 05:05:54 UTC (rev 2291) @@ -0,0 +1,733 @@ +/* +AMIS: Adaptive Multimedia Information System +Software for playing DAISY books +Homepage: http://amis.sf.net + +Copyright (C) 2004-2007 DAISY for All Project + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "stdafx.h" +#include "../resource.h" +#include "AmisCore.h" +#include "util/FilePathTools.h" +#include "Preferences.h" +#include "io/RecentBooksFileIO.h" +#include "io/PreferencesFileIO.h" +#include "util/SearchForFilesMFC.h" + +#include "pdtb.h" +#include "dtb/nav/NavModel.h" +#include "DtbWithHooks.h" + +#include "gui/AmisGuiMFC2.h" +#include "gui/MainFrm.h" +#include "gui/ChildFrm.h" +#include "gui/MainWndParts.h" +#include "gui/MmDoc.h" +#include "gui/MmView.h" +#include "gui/MenuManip.h" +#include "gui/TextRenderBrain.h" +#include "gui/sidebar/AmisSidebar.h" +#include "gui/sidebar/AmisSidebarLoader.h" +#include "gui/dialogs/AmisFileDialog.h" +#include "gui/dialogs/AboutDialog.h" +#include "gui/dialogs/OpenUrlDialog.h" +#include "gui/dialogs/SkipDialog.h" +#include "gui/dialogs/GoToPageDialog.h" +#include "gui/dialogs/SearchForBooksDialog.h" +#include "gui/dialogs/MultipleBooksOnVolumeDialog.h" + +#include "../../AmisAudio/AmisAudio.h" +//using namespace amis::audio; + +#include "../../AmisSelfVoicing/TTSPlayer.h" +//using namespace amis::tts; + +#include "ambulant/gui/dx/dx_audio.h" +//#include "ambulant/gui/dx/dx_audio_player.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +using namespace amis::gui; + + +BEGIN_MESSAGE_MAP(CAmisApp, CWinApp) + ON_COMMAND(ID_MENU_FILE_OPEN, OnFileOpen) + ON_COMMAND(ID_MENU_PLAYPAUSE, OnPlayPause) + ON_COMMAND(ID_MENU_NAV_NEXTPHRASE, OnNavNextPhrase) + ON_COMMAND(ID_MENU_NAV_PREVPHRASE, OnNavPrevPhrase) + ON_COMMAND(ID_MENU_FILE_EXIT, OnFileExit) + ON_COMMAND(ID_MENU_NAV_NEXTSECTION, OnNavNextSection) + ON_COMMAND(ID_MENU_NAV_PREVSECTION, OnNavPreviousSection) + ON_COMMAND_RANGE(BOOK_BASE_ID, BOOK_BASE_ID + MAX_ANYTHING, OnFileRecentBook) + ON_COMMAND_RANGE(SECTION_DEPTH_BASE_ID, SECTION_DEPTH_BASE_ID + MAX_ANYTHING, OnNavShowSectionDepth) + ON_COMMAND(ID_MENU_NAV_NEXTPAGE, OnNavNextPage) + ON_COMMAND(ID_MENU_NAV_PREVPAGE, OnNavPrevPage) + ON_COMMAND(ID_MENU_FILE_CLOSE, OnFileClose) + ON_COMMAND(ID_MENU_HELP_ABOUT, OnAbout) + ON_COMMAND(ID_MENU_VIEW_SIDEBAR_ONOFF, OnViewSidebarOnoff) + ON_COMMAND(ID_MENU_PLAY_ESCAPE, OnPlayEscape) + ON_COMMAND(ID_MENU_FILE_OPENFROMURL, OnFileOpenFromUrl) + ON_COMMAND(ID_MENU_INFO_SKIP, OnSkipInfo) + ON_COMMAND(ID_MENU_BMK_ADD, OnAddBookmark) + ON_COMMAND_RANGE(BOOKMARKS_BASE_ID, BOOKMARKS_BASE_ID + MAX_ANYTHING, OnSelectBookmark) + ON_COMMAND(ID_MENU_NAV_GOTOPAGE, OnGoToPage) + ON_COMMAND(ID_MENU_VIEW_CONTRAST, OnToggleContrast) + ON_COMMAND(ID_MENU_VIEW_LARGEFONT, OnIncreaseFontSize) + ON_COMMAND(ID_MENU_VIEW_RESETFONT, OnResetFontSize) + ON_COMMAND(ID_MENU_FILE_SEARCHDRIVE, OnSearchForBooks) + ON_COMMAND(ID_MENU_FILE_LOADCD, OnLoadCd) + ON_COMMAND(ID_MENU_PLAY_NORMALSPEED, OnSpeedNormal) + ON_COMMAND(ID_MENU_PLAY_SLOWER, OnSpeedDown) + ON_COMMAND(ID_MENU_PLAY_FASTER, OnSpeedUp) + ON_COMMAND(ID_MENU_PLAY_VOLUP, OnVolumeUp) + ON_COMMAND(ID_MENU_PLAY_VOLDOWN, OnVolumeDown) + ON_COMMAND(ID_MENU_FILE_PREFERENCES, OnPreferences) + +END_MESSAGE_MAP() + +CAmisApp::CAmisApp() +{ + mpRecentBooks = NULL; +} + +//THE APPLICATION! +CAmisApp theApp; + + +BOOL CAmisApp::InitInstance() +{ + //this says "use the registry instead of ini files" (for windows-specific app preferences). we use it for UAKs + SetRegistryKey(_T("Amis")); + + // InitCommonControls() is required on Windows XP if an application + // manifest specifies use of ComCtl32.dll version 6 or later to enable + // visual styles. Otherwise, any window creation will fail. + InitCommonControls(); + + CWinApp::InitInstance(); + + mbBookIsOpen = false; + mAppPath = ""; + initPathsAndFiles(); + + AfxEnableControlContainer(); + +#ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL +#else + Enable3dControlsStatic(); // Call this when linking to MFC statically +#endif + + CMultiDocTemplate* pDocTemplate; + pDocTemplate = new CMultiDocTemplate( + IDR_AMISTYPE, + RUNTIME_CLASS(amis::gui::MmDoc), + RUNTIME_CLASS(amis::gui::CChildFrame), + RUNTIME_CLASS(amis::gui::MmView) + ); + + + //this instantiates a new document and loads resources associated with + //the doc template + //in our case, this opens an HTML view and loads the AMISTYPE menu + AddDocTemplate(pDocTemplate); + + // 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)) return FALSE; + + m_pMainWnd = pFrame; + + // Parse command line for standard shell commands, DDE, file open + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + // 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. + if (!ProcessShellCommand(cmdInfo)) return FALSE; + + // try to load shared MDI menus and accelerator table + HINSTANCE hInst = AfxGetResourceHandle(); + m_hMDIMenu = ::LoadMenu(hInst, MAKEINTRESOURCE(IDR_AMISTYPE)); + m_hMDIAccel = ::LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_AMISTYPE)); + + //why won't this work?? + //MainWndParts::Instance()->mpMainFrame->SetIcon(AfxGetApp()->LoadIcon(IDI_AMIS), TRUE); + + amis::gui::MenuManip::Instance()->setupMenusNothingOpen(); + amis::gui::MenuManip::Instance()->refreshRecentBooksListMenu(); + + // The main window has been initialized, so show and update it + pFrame->ShowWindow(SW_SHOWMAXIMIZED); + pFrame->UpdateWindow(); + + //load user keys into the ambulant plugin engine + addUserKeysToAmbulantPluginEngine(); + //set the callback function to handle book key registration + amis::dtb::DtbWithHooks::Instance()->setCallbackForPreprocessingBookKey(registerBookKeyFile); + + return TRUE; +} + +int CAmisApp::ExitInstance() +{ + if (m_hMDIMenu != NULL) FreeResource(m_hMDIMenu); + if (m_hMDIAccel != NULL)FreeResource(m_hMDIAccel); + + amis::dtb::DtbWithHooks::Instance()->DestroyInstance(); + amis::Preferences::Instance()->DestroyInstance(); + amis::gui::sidebar::AmisSidebarLoader::Instance()->DestroyInstance(); + amis::gui::TextRenderBrain::Instance()->DestroyInstance(); + amis::gui::MenuManip::Instance()->DestroyInstance(); + amis::gui::MainWndParts::Instance()->DestroyInstance(); + + DataTree::Instance()->DestroyInstance(); + + if (AudioSequencePlayer::InstanceExists()) + { + AudioSequencePlayer::Instance()->DestroyInstance(); + } + + if (mpRecentBooks) delete mpRecentBooks; + + return CWinApp::ExitInstance(); +} + +std::string CAmisApp::getAppPath() +{ + USES_CONVERSION; + + if (mAppPath == "") + { + TCHAR szBuffer[256]; + GetModuleFileName(NULL, szBuffer, 256); + CString cstr_app_path = szBuffer; + int pos = cstr_app_path.ReverseFind('\\'); + if (pos >= 0) cstr_app_path = cstr_app_path.Mid(0, pos + 1); + mAppPath = W2CA(cstr_app_path); + } + + return mAppPath; +} + +void CAmisApp::initPathsAndFiles() +{ + //read the preferences + 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); + + //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::RecentBooksFileIO recent_books_io; + if (recent_books_io.readFromFile(&the_book_path)) mpRecentBooks = recent_books_io.getRecentBooks(); + else mpRecentBooks = NULL; + + + //marisa removed this if-statement + //the self-voicing data should be ready to go whether or not self-voicing is turned on at the start + //the self-voicing data is also the dynamic localization data, so it is used all over the place + //maybe this needs to be changed someday and all strings must be duplicated in the RC file .. ? for now it's ok. + //if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + //{ + //read in the new self-voicing/accessible UI data + DataReader new_data_reader; + DataTree* p_new_data_tree; + p_new_data_tree = DataTree::Instance(); + + string tmpStr = amis::Preferences::Instance()->mCurrentLanguagePackDir; + tmpStr = amis::util::FilePathTools::goRelativePath(tmpStr, "amisAccessibleUi.xml"); + tmpStr = amis::util::FilePathTools::getAsLocalFilePath(tmpStr); + new_data_reader.setAppPath(mAppPath); + + amis::ErrorCode did_it_work = new_data_reader.readFile(tmpStr, p_new_data_tree); + + if (did_it_work == amis::OK) + { + //test print to an output file + //p_new_data_tree->testPrint("c:\\devel\\amis\\Langpacks\\sandbox\\dataout.txt"); + + //DanToDo: This makes sure a clip is played first before any TTS. For some strange CoInitialize order between SAPI-TTS and Vupp, we must play an audio clip first, not a TTS...unless we open a book, in which case the CoInitialize of the IE-HTML view makes things work again !! :-| + //AudioSequencePlayer::playPromptFromStringId("canceled"); + + /* + AudioSequence* seq = new AudioSequence; + seq->append(L"AMIS"); + seq->append(L"Text-to-speech engine is ready.Text-to-speech engine is ready.Text-to-speech engine is ready."); + seq->append(L"Is it good ?"); + AudioSequencePlayer::Instance()->Play(seq); + */ + } + //if the UI file could not be read, then disable self-voicing + //todo: a more robust solution should go here: + // - what if the user re-enables self voicing via the AMIS prefs? + // - what if they switch langpacks? + //maybe we should try to load the default language pack here, and exit if that doesn't work. + else + { + amis::Preferences::Instance()->mbIsSelfVoicing = false; + } + //} + +} +const ambulant::net::url& CAmisApp::getBookURL() const +{ + return this->mURL; +} + +amis::RecentBooks* CAmisApp::getRecentBooks() +{ + return mpRecentBooks; +} + +//this function is used by all functions here that lead to a book being opened +void CAmisApp::openBook(const ambulant::net::url* filename) +{ + //TODO: AMIS says "TITLE" Playing etc even if the book couldn't be opened + MainWndParts::Instance()->updateTitleBar(MainWndParts::TITLEBAR_APPNAME, CString(L"Amis")); + MainWndParts::Instance()->updateTitleViewMode(); + MainWndParts::Instance()->updateTitleSelfVoicing(Preferences::Instance()->mbIsSelfVoicing); + + bool b_a_book_was_open = false; + + //close the open book + if (mbBookIsOpen == true) + { + b_a_book_was_open = true; + OnFileClose(); + } + + if (!filename->is_empty_path()) + { + //TODO: Doesn't this "temp" variable need to become something more durable ? (I have just fixed it with the User BMK dir) + very_temporary_bookmarks_dir = ambulant::net::url::from_filename(amis::Preferences::Instance()->mUserBmkDir); + + if (amis::dtb::DtbWithHooks::Instance()->open(filename, &very_temporary_bookmarks_dir)) + { + mbBookIsOpen = true; + amis::dtb::DtbWithHooks::Instance()->startReading(true); + } + else + { + //TODO localize these messages + CString message1 = _T("Error opening book"); + CString message2 = _T("Error opening book. Reloading previous book."); + + if (b_a_book_was_open) + { + generalBookErrorMsgBox(message2); + openLastReadBook(); + } + else + { + generalBookErrorMsgBox(message1); + } + } + } +} +void CAmisApp::openLastReadBook() +{ + //close any open book + OnFileClose(); + + if (mpRecentBooks->getLastRead()) + openBook(&mpRecentBooks->getLastRead()->mPath); +} + +/******************************* +* start of the menu handlers +********************************/ +void CAmisApp::OnFileOpen() +{ + amis::gui::dialogs::AmisFileDialog* p_dlg = new amis::gui::dialogs::AmisFileDialog(amis::gui::dialogs::AmisFileDialog::getFileOpenFilter()); + string filename = p_dlg->showOpen(); + if (filename == "") return; + + //the user is able to open UAK files through AMIS + if (isUserKeyFile(filename)) + { + importUserKeysIntoRegistry(filename); + } + else + { + ambulant::net::url book_path = ambulant::net::url::from_filename(filename); + openBook(&book_path); + } +} + + +void CAmisApp::OnPlayPause() +{ + if (MainWndParts::Instance()->mpMainFrame->mbWasPlayingWhenLostFocus) { + MainWndParts::Instance()->mpMainFrame->mbWasPlayingWhenLostFocus = false; + } + + MmView *view = MainWndParts::Instance()->mpMmView; + assert(view); // XXXJack: or what to do if view == NULL? Skip? + if (view->isPlaying() == true) + { + view->OnFilePause(); + } + else + { + view->OnFilePlay(); + } +} + +void CAmisApp::OnNavPrevPhrase() +{ + amis::dtb::DtbWithHooks::Instance()->previousPhrase(); +} + +void CAmisApp::OnNavNextPhrase() +{ + amis::dtb::DtbWithHooks::Instance()->nextPhrase(); +} + + +void CAmisApp::OnFileExit() +{ + CWnd * ptr = AfxGetMainWnd(); + ptr->SendMessage(WM_CLOSE); +} + + +void CAmisApp::OnFileRecentBook(UINT id) +{ + if (mpRecentBooks == NULL) return; + + UINT selection = id - BOOK_BASE_ID; + string filename = ""; + + amis::RecentBookEntry* p_book = NULL; + p_book = mpRecentBooks->getEntry(selection); + + openBook(&p_book->mPath); +} + +void CAmisApp::OnNavNextSection() +{ + amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.nextSection(); +} + +void CAmisApp::OnNavPreviousSection() +{ + amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.previousSection(); +} +void CAmisApp::OnNavShowSectionDepth(UINT id) +{ + int level = id - SECTION_DEPTH_BASE_ID; + amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.expandSections(level); +} + +void CAmisApp::OnNavNextPage() +{ + amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.nextPage(); +} + +void CAmisApp::OnNavPrevPage() +{ + amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.previousPage(); +} + +//TODO need to fix this...how do I stop ambulant? +void CAmisApp::OnFileClose() +{ + if (mbBookIsOpen) + { + //the order matters here + amis::dtb::DtbWithHooks::Instance()->DestroyInstance(); + MainWndParts::Instance()->mpMmView->OnDestroy(); + amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.clearAll(); + amis::gui::MenuManip::Instance()->setupMenusNothingOpen(); + mbBookIsOpen = false; + } +} + +void CAmisApp::OnVolumeUp() +{ + //amis::audio::AmisAudio::Instance()->adjustVolume(1.2); REMOVED because it makes more sense to allow book volume control than the whole application: otherwise users would use their OS-level volume control. + ambulant::gui::dx::change_global_level(1.2); + //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_VOLUP, true, NULL); +} + +void CAmisApp::OnVolumeDown() +{ + //amis::audio::AmisAudio::Instance()->adjustVolume(1.0/1.2); REMOVED because it makes more sense to allow book volume control than the whole application: otherwise users would use their OS-level volume control. + ambulant::gui::dx::change_global_level(1.0/1.2); + //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_VOLDOWN, true, NULL); +} + +void CAmisApp::OnSpeedUp() +{ + amis::audio::AmisAudio::Instance()->adjustRate(1.12); + + 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); + + //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_FASTER, true, NULL); +} + +void CAmisApp::OnSpeedDown() +{ + amis::audio::AmisAudio::Instance()->adjustRate(-1.12); + + 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); + + //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_SLOWER, true, NULL); +} + +void CAmisApp::OnSpeedNormal() +{ + amis::audio::AmisAudio::Instance()->setRate(1.0); + + amis::tts::TTSPlayer::Instance()->SetSpeechRate(0); + + //TODO: this only works with my local hacked Ambulant API (addition of this setXX() function) + ambulant::gui::dx::set_global_rate(1.0); + + //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_NORMALSPEED, true, NULL); +} + + +void CAmisApp::OnAbout() +{ + amis::gui::dialogs::AboutDialog about; + about.do_modal(); +} + +void CAmisApp::OnViewSidebarOnoff() +{ + MainWndParts::Instance()->toggleSidebar(); +} + +void CAmisApp::OnPlayEscape() +{ + MmView *view = MainWndParts::Instance()->mpMmView; + assert(view); + view->escapeCurrent(); +} + +void CAmisApp::OnFileOpenFromUrl() +{ + USES_CONVERSION; + + amis::gui::dialogs::OpenUrlDialog dlg; + string str_url = ""; + + if (dlg.do_modal() == IDOK) + { + str_url = T2A(dlg.getUrl()); + ambulant::net::url book_url = ambulant::net::url::from_url(str_url); + openBook(&book_url); + } +} + +void CAmisApp::OnSkipInfo() +{ + amis::gui::dialogs::SkipDialog skip_dialog; + skip_dialog.initializeData(amis::dtb::DtbWithHooks::Instance()->getCustomTestSet()); + skip_dialog.do_modal(); + amis::dtb::DtbWithHooks::Instance()->updateCustomTestStates(); +} + +void CAmisApp::OnAddBookmark() +{ + amis::dtb::Bookmark* p_bmk = NULL; + p_bmk = amis::dtb::DtbWithHooks::Instance()->addBookmark(); + if (p_bmk) MenuManip::Instance()->addBookmark(p_bmk); +} + +void CAmisApp::OnSelectBookmark(UINT id) +{ + int idx; + idx = id - BOOKMARKS_BASE_ID; + + amis::dtb::DtbWithHooks::Instance()->loadBookmark(idx); +} + +void CAmisApp::OnGoToPage() +{ + amis::gui::dialogs::GoToPageDialog dialog; + if (dialog.do_modal() == IDOK) + { + wstring page_number = dialog.getPageNumber(); + amis::dtb::nav::NavModel* p_nav_model = NULL; + p_nav_model = amis::dtb::DtbWithHooks::Instance()->getNavModel(); + if (p_nav_model->hasPages() && p_nav_model->getPageList() != NULL) + { + amis::dtb::nav::PageTarget* p_page = NULL; + p_page = p_nav_model->getPageList()->findPage(page_number); + if (p_page) amis::dtb::DtbWithHooks::Instance()->loadNavNode(p_page); + } + } +} + +void CAmisApp::OnToggleContrast() +{ + bool is_contrast_on = amis::gui::TextRenderBrain::Instance()->toggleContrast(); + MenuManip::Instance()->setViewItemCheckmark(is_contrast_on, ID_MENU_VIEW_CONTRAST); +} +void CAmisApp::OnIncreaseFontSize() +{ + TextRenderBrain::Instance()->increaseFontSize(); +} +void CAmisApp::OnResetFontSize() +{ + TextRenderBrain::Instance()->resetFontSize(); +} +void CAmisApp::OnSearchForBooks() +{ + dialogs::SearchForBooksDialog search; + if (search.do_modal() == IDOK) + { + ambulant::net::url book_url = search.getBookToLoad(); + this->openBook(&book_url); + } +} +void CAmisApp::OnLoadCd() +{ + amis::util::SearchForFilesMFC searcher; + //prepare the search tool + searcher.clearAll(); + searcher.addSearchCriteria("ncc.htm"); + searcher.addSearchCriteria(".opf"); + //sometimes I see these temp files on my drive .. excluding them just to be safe + searcher.addSearchExclusionCriteria("_ncc.html"); + searcher.setRecursiveSearch(true); + + int num_books = searcher.startSearchOnCdRom(); + + //TODO: localize this string + if (num_books == 0) + { + generalBookErrorMsgBox(_T("No files found on this CD-ROM")); + } + else + { + amis::UrlList* p_results = searcher.getSearchResults(); + if (p_results->size() > 1) + { + dialogs::MultipleBooksOnVolumeDialog dlg(NULL, p_results); + if (dlg.do_modal() == IDOK) + { + openBook(&dlg.getBookToLoad()); + } + } + else + { + //open the first and only URL found + openBook(&(*p_results)[0]); + } + } +} + +void CAmisApp::OnPreferences() +{ + +} + +/*************************************************** +* (MED) I moved these functions out of the menu handler area +*****************************************************/ + +/** + * 'pauseState' function parameter: + * - FALSE => state is set to "PLAYING", the "PAUSE" action button is therefore shown + * - TRUE => state is set to "PAUSED", the "PLAY" action button is therefore shown + */ +void CAmisApp::setPauseState(bool pauseState) +{ + + //DanToDo: I don't think Amis3 has a toolbar, so for now the following code is useless (should be removed definitely ?). + //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); +} + +bool CAmisApp::beforeModalBox() { + + if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + { + //AudioSequencePlayer::Instance()->Stop(); + } + + MmView *view = MainWndParts::Instance()->mpMmView; + bool b_was_playing = view->isPlaying(); + + if (b_was_playing == true) + { + view->OnFilePause(); + } + + return b_was_playing; +} +void CAmisApp::afterModalBox(bool b_was_playing) { + + if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + { + AudioSequencePlayer::Instance()->Stop(); + + AudioSequencePlayer::playPromptFromStringId("dialogClosed"); + AudioSequencePlayer::Instance()->waitForSequenceEnd(); + } + + //resume playback + if (b_was_playing == true) + { + MmView *view = MainWndParts::Instance()->mpMmView; + view->OnFilePlay(); + } +} + +void CAmisApp::generalBookErrorMsgBox(CString str) +{ + + bool b = beforeModalBox(); + AudioSequencePlayer::Instance()->Stop(); + AudioSequencePlayer::playPromptFromStringId("generalBookError"); + AfxMessageBox(str); + afterModalBox(b); +} + Deleted: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2008-01-21 15:33:37 UTC (rev 2290) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2008-01-28 05:05:54 UTC (rev 2291) @@ -1,721 +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 "stdafx.h" -#include "../resource.h" -#include "AmisCore.h" -#include "util/FilePathTools.h" -#include "Preferences.h" -#include "io/RecentBooksFileIO.h" -#include "io/PreferencesFileIO.h" -#include "util/SearchForFilesMFC.h" - -#include "pdtb.h" -#include "dtb/nav/NavModel.h" -#include "DtbWithHooks.h" - -#include "gui/AmisGuiMFC2.h" -#include "gui/MainFrm.h" -#include "gui/ChildFrm.h" -#include "gui/MainWndParts.h" -#include "gui/MmDoc.h" -#include "gui/MmView.h" -#include "gui/MenuManip.h" -#include "gui/TextRenderBrain.h" -#include "gui/sidebar/AmisSidebar.h" -#include "gui/sidebar/AmisSidebarLoader.h" -#include "gui/dialogs/AmisFileDialog.h" -#include "gui/dialogs/AboutDialog.h" -#include "gui/dialogs/OpenUrlDialog.h" -#include "gui/dialogs/SkipDialog.h" -#include "gui/dialogs/GoToPageDialog.h" -#include "gui/dialogs/SearchForBooksDialog.h" -#include "gui/dialogs/MultipleBooksOnVolumeDialog.h" - -#include "../../AmisAudio/AmisAudio.h" -//using namespace amis::audio; - -#include "../../AmisSelfVoicing/TTSPlayer.h" -//using namespace amis::tts; - -#include "ambulant/gui/dx/dx_audio.h" -//#include "ambulant/gui/dx/dx_audio_player.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - - -using namespace amis::gui; - - -BEGIN_MESSAGE_MAP(CAmisGuiMFC2App, CWinApp) - ON_COMMAND(ID_MENU_FILE_OPEN, OnFileOpen) - ON_COMMAND(ID_MENU_PLAYPAUSE, OnPlayPause) - ON_COMMAND(ID_MENU_NAV_NEXTPHRASE, OnNavNextPhrase) - ON_COMMAND(ID_MENU_NAV_PREVPHRASE, OnNavPrevPhrase) - ON_COMMAND(ID_MENU_FILE_EXIT, OnFileExit) - ON_COMMAND(ID_MENU_NAV_NEXTSECTION, OnNavNextSection) - ON_COMMAND(ID_MENU_NAV_PREVSECTION, OnNavPreviousSection) - ON_COMMAND_RANGE(BOOK_BASE_ID, BOOK_BASE_ID + MAX_ANYTHING, OnFileRecentBook) - ON_COMMAND_RANGE(SECTION_DEPTH_BASE_ID, SECTION_DEPTH_BASE_ID + MAX_ANYTHING, OnNavShowSectionDepth) - ON_COMMAND(ID_MENU_NAV_NEXTPAGE, OnNavNextPage) - ON_COMMAND(ID_MENU_NAV_PREVPAGE, OnNavPrevPage) - ON_COMMAND(ID_MENU_FILE_CLOSE, OnFileClose) - ON_COMMAND(ID_MENU_HELP_ABOUT, OnAbout) - ON_COMMAND(ID_MENU_VIEW_SIDEBAR_ONOFF, OnViewSidebarOnoff) - ON_COMMAND(ID_MENU_PLAY_ESCAPE, OnPlayEscape) - ON_COMMAND(ID_MENU_FILE_OPENFROMURL, OnFileOpenFromUrl) - ON_COMMAND(ID_MENU_INFO_SKIP, OnSkipInfo) - ON_COMMAND(ID_MENU_BMK_ADD, OnAddBookmark) - ON_COMMAND_RANGE(BOOKMARKS_BASE_ID, BOOKMARKS_BASE_ID + MAX_ANYTHING, OnSelectBookmark) - ON_COMMAND(ID_MENU_NAV_GOTOPAGE, OnGoToPage) - ON_COMMAND(ID_MENU_VIEW_CONTRAST, OnToggleContrast) - ON_COMMAND(ID_MENU_VIEW_LARGEFONT, OnIncreaseFontSize) - ON_COMMAND(ID_MENU_VIEW_RESETFONT, OnResetFontSize) - ON_COMMAND(ID_MENU_FILE_SEARCHDRIVE, OnSearchForBooks) - ON_COMMAND(ID_MENU_FILE_LOADCD, OnLoadCd) - ON_COMMAND(ID_MENU_PLAY_NORMALSPEED, OnSpeedNormal) - ON_COMMAND(ID_MENU_PLAY_SLOWER, OnSpeedDown) - ON_COMMAND(ID_MENU_PLAY_FASTER, OnSpeedUp) - ON_COMMAND(ID_MENU_PLAY_VOLUP, OnVolumeUp) - ON_COMMAND(ID_MENU_PLAY_VOLDOWN, OnVolumeDown) -END_MESSAGE_MAP() - -CAmisGuiMFC2App::CAmisGuiMFC2App() -{ - mpRecentBooks = NULL; -} - -//THE APPLICATION! -CAmisGuiMFC2App theApp; - - -BOOL CAmisGuiMFC2App::InitInstance() -{ - //this says "use the registry instead of ini files" (for windows-specific app preferences). we use it for UAKs - SetRegistryKey(_T("Amis")); - - // InitCommonControls() is required on Windows XP if an application - // manifest specifies use of ComCtl32.dll version 6 or later to enable - // visual styles. Otherwise, any window creation will fail. - InitCommonControls(); - - CWinApp::InitInstance(); - - mbBookIsOpen = false; - mAppPath = ""; - initPathsAndFiles(); - - AfxEnableControlContainer(); - -#ifdef _AFXDLL - Enable3dControls(); // Call this when using MFC in a shared DLL -#else - Enable3dControlsStatic(); // Call this when linking to MFC statically -#endif - - CMultiDocTemplate* pDocTemplate; - pDocTemplate = new CMultiDocTemplate( - IDR_AMISTYPE, - RUNTIME_CLASS(amis::gui::MmDoc), - RUNTIME_CLASS(amis::gui::CChildFrame), - RUNTIME_CLASS(amis::gui::MmView) - ); - - - //this instantiates a new document and loads resources associated with - //the doc template - //in our case, this opens an HTML view and loads the AMISTYPE menu - AddDocTemplate(pDocTemplate); - - // 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)) return FALSE; - - m_pMainWnd = pFrame; - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // 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. - if (!ProcessShellCommand(cmdInfo)) return FALSE; - - // try to load shared MDI menus and accelerator table - HINSTANCE hInst = AfxGetResourceHandle(); - m_hMDIMenu = ::LoadMenu(hInst, MAKEINTRESOURCE(IDR_AMISTYPE)); - m_hMDIAccel = ::LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_AMISTYPE)); - - //why won't this work?? - //MainWndParts::Instance()->mpMainFrame->SetIcon(AfxGetApp()->LoadIcon(IDI_AMIS), TRUE); - - amis::gui::MenuManip::Instance()->setupMenusNothingOpen(); - amis::gui::MenuManip::Instance()->refreshRecentBooksListMenu(); - - // The main window has been initialized, so show and update it - pFrame->ShowWindow(SW_SHOWMAXIMIZED); - pFrame->UpdateWindow(); - - //load user keys into the ambulant plugin engine - addUserKeysToAmbulantPluginEngine(); - //set the callback function to handle book key registration - amis::dtb::DtbWithHooks::Instance()->setCallbackForPreprocessingBookKey(registerBookKeyFile); - - return TRUE; -} - -int CAmisGuiMFC2App::ExitInstance() -{ - if (m_hMDIMenu != NULL) FreeResource(m_hMDIMenu); - if (m_hMDIAccel != NULL)FreeResource(m_hMDIAccel); - - amis::dtb::DtbWithHooks::Instance()->DestroyInstance(); - amis::Preferences::Instance()->DestroyInstance(); - amis::gui::sidebar::AmisSidebarLoader::Instance()->DestroyInstance(); - amis::gui::TextRenderBrain::Instance()->DestroyInstance(); - amis::gui::MenuManip::Instance()->DestroyInstance(); - amis::gui::MainWndParts::Instance()->DestroyInstance(); - - DataTree::Instance()->DestroyInstance(); - - if (AudioSequencePlayer::InstanceExists()) - { - AudioSequencePlayer::Instance()->DestroyInstance(); - } - - if (mpRecentBooks) delete mpRecentBooks; - - return CWinApp::ExitInstance(); -} - -std::string CAmisGuiMFC2App::getAppPath() -{ - USES_CONVERSION; - - if (mAppPath == "") - { - TCHAR szBuffer[256]; - GetModuleFileName(NULL, szBuffer, 256); - CString cstr_app_path = szBuffer; - int pos = cstr_app_path.ReverseFind('\\'); - if (pos >= 0) cstr_app_path = cstr_app_path.Mid(0, pos + 1); - mAppPath = W2CA(cstr_app_path); - } - - return mAppPath; -} - -void CAmisGuiMFC2App::initPathsAndFiles() -{ - //read the preferences - 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); - Preferences::Instance()->scanDirectoriesForCssFiles(); - - //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::RecentBooksFileIO recent_books_io; - if (recent_books_io.readFromFile(&the_book_path)) mpRecentBooks = recent_books_io.getRecentBooks(); - else mpRecentBooks = NULL; - - - //marisa removed this if-statement - //the self-voicing data should be ready to go whether or not self-voicing is turned on at the start - //the self-voicing data is also the dynamic localization data, so it is used all over the place - //maybe this needs to be changed someday and all strings must be duplicated in the RC file .. ? for now it's ok. - //if (amis::Preferences::Instance()->mbIsSelfVoicing == true) - //{ - //read in the new self-voicing/accessible UI data - DataReader new_data_reader; - DataTree* p_new_data_tree; - p_new_data_tree = DataTree::Instance(); - - string tmpStr = amis::Preferences::Instance()->mUiLangDir; - tmpStr = amis::util::FilePathTools::goRelativePath(tmpStr, "amisAccessibleUi.xml"); - tmpStr = amis::util::FilePathTools::getAsLocalFilePath(tmpStr); - new_data_reader.setAppPath(mAppPath); - - amis::ErrorCode did_it_work = new_data_reader.readFile(tmpStr, p_new_data_tree); - - if (did_it_work == amis::OK) - { - //test print to an output file - //p_new_data_tree->testPrint("c:\\devel\\amis\\Langpacks\\sandbox\\dataout.txt"); - - //DanToDo: This makes sure a clip is played first before any TTS. For some strange CoInitialize order between SAPI-TTS and Vupp, we must play an audio clip first, not a TTS...unless we open a book, in which case the CoInitialize of the IE-HTML view makes things work again !! :-| - //AudioSequencePlayer::playPromptFromStringId("canceled"); - - /* - AudioSequence* seq = new AudioSequence; - seq->append(L"AMIS"); - seq->append(L"Text-to-speech engine is ready.Text-to-speech engine is ready.Text-to-speech engine is ready."); - seq->append(L"Is it good ?"); - AudioSequencePlayer::Instance()->Play(seq); - */ - } - //if the UI file could not be read, then disable self-voicing - //todo: a more robust solution should go here: - // - what if the user re-enables self voicing via the AMIS prefs? - // - what if they switch langpacks? - //maybe we should try to load the default language pack here, and exit if that doesn't work. - else - { - amis::Preferences::Instance()->mbIsSelfVoicing = false; - } - //} - -} -const ambulant::net::url& CAmisGuiMFC2App::getBookURL() const -{ - return this->mURL; -} - -amis::RecentBooks* CAmisGuiMFC2App::getRecentBooks() -{ - return mpRecentBooks; -} - -//this function is used by all functions here that lead to a book being opened -void CAmisGuiMFC2App::openBook(const ambulant::net::url* filename) -{ - //TODO: AMIS says "TITLE" Playing etc even if the book couldn't be opened - MainWndParts::Instance()->updateTitleBar(MainWndParts::TITLEBAR_APPNAME, CString(L"Amis")); - MainWndParts::Instance()->updateTitleViewMode(); - MainWndParts::Instance()->updateTitleSelfVoicing(Preferences::Instance()->mbIsSelfVoicing); - - bool b_a_book_was_open = false; - - //close the open book - if (mbBookIsOpen == true) - { - b_a_book_was_open = true; - OnFileClose(); - } - - if (!filename->is_empty_path()) - { - //TODO: Doesn't this "temp" variable need to become something more durable ? (I have just fixed it with the User BMK dir) - very_temporary_bookmarks_dir = ambulant::net::url::from_filename(amis::Preferences::Instance()->mUserBmkDir); - - if (amis::dtb::DtbWithHooks::Instance()->open(filename, &very_temporary_bookmarks_dir)) - { - mbBookIsOpen = true; - amis::dtb::DtbWithHooks::Instance()->startReading(true); - } - else - { - //TODO localize these messages - CString message1 = _T("Error opening book"); - CString message2 = _T("Error opening book. Reloading previous book."); - - if (b_a_book_was_open) - { - generalBookErrorMsgBox(message2); - openLastReadBook(); - } - else - { - generalBookErrorMsgBox(message1); - } - } - } -} -void CAmisGuiMFC2App::openLastReadBook() -{ - //close any open book - OnFileClose(); - - if (mpRecentBooks->getLastRead()) - openBook(&mpRecentBooks->getLastRead()->mPath); -} - -void CAmisGuiMFC2App::OnFileOpen() -{ - amis::gui::dialogs::AmisFileDialog* p_dlg = new amis::gui::dialogs::AmisFileDialog(amis::gui::dialogs::AmisFileDialog::getFileOpenFilter()); - string filename = p_dlg->showOpen(); - if (filename == "") return; - - //the user is able to open UAK files through AMIS - if (isUserKeyFile(filename)) - { - importUserKeysIntoRegistry(filename); - } - else - { - ambulant::net::url book_path = ambulant::net::url::from_filename(filename); - openBook(&book_path); - } -} - -/** - * 'pauseState' function parameter: - * - FALSE => state is set to "PLAYING", the "PAUSE" action button is therefore shown - * - TRUE => state is set to "PAUSED", the "PLAY" action button is therefore shown - */ -void CAmisGuiMFC2App::setPauseState(bool pauseState) -{ - - //DanToDo: I don't think Amis3 has a toolbar, so for now the following code is useless (should be removed definitely ?). - //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); -} - -void CAmisGuiMFC2App::OnPlayPause() -{ - if (MainWndParts::Instance()->mpMainFrame->mbWasPlayingWhenLostFocus) { - MainWndParts::Instance()->mpMainFrame->mbWasPlayingWhenLostFocus = false; - } - - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); // XXXJack: or what to do if view == NULL? Skip? - if (view->isPlaying() == true) - { - view->OnFilePause(); - } - else - { - view->OnFilePlay(); - } -} - -void CAmisGuiMFC2App::OnNavPrevPhrase() -{ - amis::dtb::DtbWithHooks::Instance()->previousPhrase(); -} - -void CAmisGuiMFC2App::OnNavNextPhrase() -{ - amis::dtb::DtbWithHooks::Instance()->nextPhrase(); -} - - -void CAmisGuiMFC2App::OnFileExit() -{ - CWnd * ptr = AfxGetMainWnd(); - ptr->SendMessage(WM_CLOSE); -} - - -void CAmisGuiMFC2App::OnFileRecentBook(UINT id) -{ - if (mpRecentBooks == NULL) return; - - UINT selection = id - BOOK_BASE_ID; - string filename = ""; - - amis::RecentBookEntry* p_book = NULL; - p_book = mpRecentBooks->getEntry(selection); - - openBook(&p_book->mPath); -} - -void CAmisGuiMFC2App::OnNavNextSection() -{ - amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.nextSection(); -} - -void CAmisGuiMFC2App::OnNavPreviousSection() -{ - amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.previousSection(); -} -void CAmisGuiMFC2App::OnNavShowSectionDepth(UINT id) -{ - int level = id - SECTION_DEPTH_BASE_ID; - amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.expandSections(level); -} - -void CAmisGuiMFC2App::OnNavNextPage() -{ - amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.nextPage(); -} - -void CAmisGuiMFC2App::OnNavPrevPage() -{ - amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.previousPage(); -} - -//TODO need to fix this...how do I stop ambulant? -void CAmisGuiMFC2App::OnFileClose() -{ - if (mbBookIsOpen) - { - //the order matters here - amis::dtb::DtbWithHooks::Instance()->DestroyInstance(); - MainWndParts::Instance()->mpMmView->OnDestroy(); - amis::gui::MainWndParts::Instance()->mpSidebar->m_wndDlg.clearAll(); - amis::gui::MenuManip::Instance()->setupMenusNothingOpen(); - mbBookIsOpen = false; - } -} - -void CAmisGuiMFC2App::OnVolumeUp() -{ - //amis::audio::AmisAudio::Instance()->adjustVolume(1.2); REMOVED because it makes more sense to allow book volume control than the whole application: otherwise users would use their OS-level volume control. - ambulant::gui::dx::change_global_level(1.2); - //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_VOLUP, true, NULL); -} - -void CAmisGuiMFC2App::OnVolumeDown() -{ - //amis::audio::AmisAudio::Instance()->adjustVolume(1.0/1.2); REMOVED because it makes more sense to allow book volume control than the whole application: otherwise users would use their OS-level volume control. - ambulant::gui::dx::change_global_level(1.0/1.2); - //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_VOLDOWN, true, NULL); -} - -void CAmisGuiMFC2App::OnSpeedUp() -{ - amis::audio::AmisAudio::Instance()->adjustRate(1.12); - - 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); - - //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_FASTER, true, NULL); -} - -void CAmisGuiMFC2App::OnSpeedDown() -{ - amis::audio::AmisAudio::Instance()->adjustRate(-1.12); - - 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); - - //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_SLOWER, true, NULL); -} - -void CAmisGuiMFC2App::OnSpeedNormal() -{ - amis::audio::AmisAudio::Instance()->setRate(1.0); - - amis::tts::TTSPlayer::Instance()->SetSpeechRate(0); - - //TODO: this only works with my local hacked Ambulant API (addition of this setXX() function) - ambulant::gui::dx::set_global_rate(1.0); - - //amis::gui::spoken::AudioSequencePlayer::Instance()->playPromptFromUiId(ID_MENU_PLAY_NORMALSPEED, true, NULL); -} - - -void CAmisGuiMFC2App::OnAbout() -{ - amis::gui::dialogs::AboutDialog about; - about.do_modal(); -} - -void CAmisGuiMFC2App::OnViewSidebarOnoff() -{ - MainWndParts::Instance()->toggleSidebar(); -} - -void CAmisGuiMFC2App::OnPlayEscape() -{ - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); - view->escapeCurrent(); -} - -void CAmisGuiMFC2App::OnFileOpenFromUrl() -{ - USES_CONVERSION; - - amis::gui::dialogs::OpenUrlDi... [truncated message content] |
From: <mar...@us...> - 2008-01-28 06:18:00
|
Revision: 2293 http://amis.svn.sourceforge.net/amis/?rev=2293&view=rev Author: marisademeglio Date: 2008-01-27 22:18:04 -0800 (Sun, 27 Jan 2008) Log Message: ----------- Preferences dialog language combo box has options in it that are linked to the Prefs XML file. Still to-do: 1. update flag icon 2. tts voice selection 3. Proper "restart to see changes" message box 4. Trace cause of AMIS hanging on exit after the preferences dialog was invoked. Not sure that the two are linked. NOTE TO DEVELOPER(S)! The prefs XML file has changed. Be sure to run "makeLocalCopiesOfDefaults.bat" Modified Paths: -------------- branches/amis3/AmisCore/src/dtb/nav/NavModel.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.cpp branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp branches/amis3/AmisGuiMFC2/src/Preferences.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/ChildFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/HtmlDoc.cpp branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp Modified: branches/amis3/AmisCore/src/dtb/nav/NavModel.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/nav/NavModel.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisCore/src/dtb/nav/NavModel.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -86,6 +86,7 @@ NavNodeList* p_list = it->second; if (p_list != NULL) delete p_list; mpSmilIdNodeMap->erase(it); + it = mpSmilIdNodeMap->begin(); } delete mpSmilIdNodeMap; } Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -4,7 +4,7 @@ #include "TTSPlayer.h" -#include "gui\AmisGuiMFC2.h" +#include "gui\AmisApp.h" #include "util/FilePathTools.h" Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/PreTranslateMessageHandler.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -1,6 +1,6 @@ #include ".\pretranslatemessagehandler.h" -//#include "gui/AmisGuiMFC2.h" +//#include "gui/AmisApp.h" PreTranslateMessageHandler::PreTranslateMessageHandler(int idUiDialog) { Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-01-28 06:18:04 UTC (rev 2293) @@ -19,7 +19,7 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// AmisGuiMFC2.h : main header file for the AmisGuiMFC2 application +// AmisApp.h : main header file for the AmisGuiMFC2 application // #ifndef AMISGUIMFC2_H #define AMISGUIMFC2_H @@ -74,10 +74,10 @@ afx_msg void OnNavNextPhrase(); afx_msg void OnFileExit(); afx_msg void OnFileRecentBook(UINT); - afx_msg void OnNavNextSection(); + afx_msg void OnNavNextSection(); afx_msg void OnNavPreviousSection(); afx_msg void OnNavShowSectionDepth(UINT); - afx_msg void OnNavNextPage(); + afx_msg void OnNavNextPage(); afx_msg void OnNavPrevPage(); afx_msg void OnFileClose(); afx_msg void OnAbout(); Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -25,7 +25,7 @@ #include "gui/sidebar/AmisSidebarLoader.h" #include "RecentBooks.h" #include "io/RecentBooksFileIO.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisApp.h" #include "gui/MenuManip.h" #include "gui/TextRenderBrain.h" #include "ambulant/net/url.h" Modified: branches/amis3/AmisGuiMFC2/src/Preferences.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -22,7 +22,7 @@ #include "stdafx.h" #include "Preferences.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisApp.h" #include "util/SearchForFilesMFC.h" #include "util/FilePathTools.h" #include "io/ModuleDescReader.h" @@ -133,7 +133,8 @@ { amis::ModuleDescData* p_data = reader.getModuleDescData(); processLanguagePackModuleDescData(p_data); - if (p_data != NULL) delete p_data; + //don't delete the data, we'll need it later + //this is a known (small) memory leak though! } else { @@ -163,6 +164,13 @@ Preferences::~Preferences() { - //TODO: delete the language pack media groups + amis::StringMediaMap::iterator it = mLanguagePackLabels.begin(); + while (mLanguagePackLabels.size() > 0) + { + amis::MediaGroup* p_media = it->second; + if (p_media != NULL) delete p_media; + mLanguagePackLabels.erase(it); + it = mLanguagePackLabels.begin(); + } } Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -50,6 +50,7 @@ #include "gui/dialogs/GoToPageDialog.h" #include "gui/dialogs/SearchForBooksDialog.h" #include "gui/dialogs/MultipleBooksOnVolumeDialog.h" +#include "gui/dialogs/PreferencesDialog.h" #include "../../AmisAudio/AmisAudio.h" //using namespace amis::audio; @@ -655,7 +656,24 @@ void CAmisApp::OnPreferences() { - + dialogs::PreferencesDialog prefs; + if (prefs.do_modal() == IDOK) + { + Preferences::Instance()->mbIsSelfVoicing = prefs.mbIsSelfVoicing; + Preferences::Instance()->mbPauseOnApplicationLostFocus = prefs.mbShouldPauseOnLostFocus; + Preferences::Instance()->mbStartBasicView = prefs.mbShouldStartInBasicView; + Preferences::Instance()->mbLoadLastBook = prefs.mbShouldLoadLastBookOnStartup; + + if (prefs.mUiLanguageId != Preferences::Instance()->mUiLangId) + { + Preferences::Instance()->mUiLangId = prefs.mUiLanguageId; + //TODO: replace with real message from localized file + AfxMessageBox(_T("Please restart to change the language of AMIS")); + } + + amis::io::PreferencesFileIO prefs_io; + prefs_io.writeToFile(Preferences::Instance()->mSourceUrl.get_file(), Preferences::Instance()); + } } /*************************************************** Modified: branches/amis3/AmisGuiMFC2/src/gui/ChildFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/ChildFrm.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/gui/ChildFrm.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -21,7 +21,7 @@ */ #include "stdafx.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisApp.h" #include "gui/ChildFrm.h" #include "gui/MainFrm.h" Modified: branches/amis3/AmisGuiMFC2/src/gui/HtmlDoc.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/HtmlDoc.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/gui/HtmlDoc.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -21,7 +21,7 @@ */ #include "stdafx.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisApp.h" #include "gui/HtmlDoc.h" Modified: branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -27,7 +27,7 @@ #include "stdafx.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisApp.h" #include "gui/HtmlDoc.h" #include "gui/HtmlView.h" #include "gui/MainWndParts.h" @@ -637,9 +637,9 @@ void CAmisHtmlView::removeStylesheet(IHTMLStyleSheet* pStyleSheet) { - if (!pStyleSheet) return; - pStyleSheet->put_disabled(VARIANT_TRUE); - pStyleSheet->Release(); + if (!pStyleSheet) return; + pStyleSheet->put_disabled(VARIANT_TRUE); + pStyleSheet->Release(); pStyleSheet = NULL; } Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -1,47 +1,47 @@ -/* -AMIS: Adaptive Multimedia Information System -Software for playing DAISY books -Homepage: http://amis.sf.net - -Copyright (C) 2004-2007 DAISY for All Project - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#include "stdafx.h" -#include "gui/AmisGuiMFC2.h" - -#include "gui/MainFrm.h" -#include "gui/MainWndParts.h" -#include "Preferences.h" -#include "DtbWithHooks.h" -#include "../../AmisAudio/AmisAudio.h" -#include "io/BookmarksFileIO.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -using namespace amis::audio; -using namespace amis::gui; - -// CMainFrame - -IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) - -BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) +/* +AMIS: Adaptive Multimedia Information System +Software for playing DAISY books +Homepage: http://amis.sf.net + +Copyright (C) 2004-2007 DAISY for All Project + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#include "stdafx.h" +#include "gui/AmisApp.h" + +#include "gui/MainFrm.h" +#include "gui/MainWndParts.h" +#include "Preferences.h" +#include "DtbWithHooks.h" +#include "../../AmisAudio/AmisAudio.h" +#include "io/BookmarksFileIO.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +using namespace amis::audio; +using namespace amis::gui; + +// CMainFrame + +IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) //{{AFX_MSG_MAP(CMainFrame) ON_WM_CREATE() //ON_MESSAGE(WM_MESSAGETOAMIS, OnMessageFromPlugin) @@ -56,108 +56,108 @@ ON_WM_EXITMENULOOP() //ON_WM_KEYDOWN() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - - -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +static UINT indicators[] = { + ID_SEPARATOR, // status line indicator + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + + +// CMainFrame construction/destruction + +CMainFrame::CMainFrame() +{ mbWasPlayingWhenLostFocus = false; m_lastOpenPopupMenu = NULL; - mCommonPreTranslateMessageHandler = new PreTranslateMessageHandler(-1); -} - -CMainFrame::~CMainFrame() -{ + mCommonPreTranslateMessageHandler = new PreTranslateMessageHandler(-1); +} + +CMainFrame::~CMainFrame() +{ - delete mCommonPreTranslateMessageHandler; -} - - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - if (!m_wndSidebar.Create(_T("the sidebar"), this, CSize(0, 0), - TRUE /*bHasGripper*/, AFX_IDW_CONTROLBAR_FIRST + 32)) - { - - TRACE0("Failed to create mybar\n"); - return -1; // fail to create - } - - m_wndSidebar.SetBarStyle(m_wndSidebar.GetBarStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); - - m_wndSidebar.EnableDocking(CBRS_ALIGN_ANY); - - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - // TODO: Delete these three lines if you don't want the toolbar to - // be dockable - EnableDocking(CBRS_ALIGN_ANY); - #ifdef _SCB_REPLACE_MINIFRAME - m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd); - #endif - - DockControlBar(&m_wndSidebar, AFX_IDW_DOCKBAR_LEFT); - - MainWndParts::Instance()->mpSidebar = &m_wndSidebar; - MainWndParts::Instance()->mpStatusBar = &m_wndStatusBar; - MainWndParts::Instance()->mpMainFrame = this; - - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CMDIFrameWnd::PreCreateWindow(cs) ) - return FALSE; - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE - | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE | WS_SYSMENU; - - return TRUE; -} - - -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CMDIFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CMDIFrameWnd::Dump(dc); -} - -#endif //_DEBUG - + delete mCommonPreTranslateMessageHandler; +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + if (!m_wndSidebar.Create(_T("the sidebar"), this, CSize(0, 0), + TRUE /*bHasGripper*/, AFX_IDW_CONTROLBAR_FIRST + 32)) + { + + TRACE0("Failed to create mybar\n"); + return -1; // fail to create + } + + m_wndSidebar.SetBarStyle(m_wndSidebar.GetBarStyle() | + CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); + + m_wndSidebar.EnableDocking(CBRS_ALIGN_ANY); + + if (!m_wndStatusBar.Create(this) || + !m_wndStatusBar.SetIndicators(indicators, + sizeof(indicators)/sizeof(UINT))) + { + TRACE0("Failed to create status bar\n"); + return -1; // fail to create + } + + // TODO: Delete these three lines if you don't want the toolbar to + // be dockable + EnableDocking(CBRS_ALIGN_ANY); + #ifdef _SCB_REPLACE_MINIFRAME + m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd); + #endif + + DockControlBar(&m_wndSidebar, AFX_IDW_DOCKBAR_LEFT); + + MainWndParts::Instance()->mpSidebar = &m_wndSidebar; + MainWndParts::Instance()->mpStatusBar = &m_wndStatusBar; + MainWndParts::Instance()->mpMainFrame = this; + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CMDIFrameWnd::PreCreateWindow(cs) ) + return FALSE; + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE + | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE | WS_SYSMENU; + + return TRUE; +} + + +// CMainFrame diagnostics + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CMDIFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CMDIFrameWnd::Dump(dc); +} + +#endif //_DEBUG + + void CMainFrame::OnMenuSelect( UINT nItemID, UINT nFlags, HMENU hSysMenu ) { @@ -166,7 +166,7 @@ CFrameWnd::OnMenuSelect(nItemID, nFlags, hSysMenu); -if (amis::Preferences::Instance()->mbIsSelfVoicing == false) +if (amis::Preferences::Instance()->mbIsSelfVoicing == false) { return; } @@ -331,19 +331,19 @@ { int idx = nItemID - BOOK_BASE_ID; -amis::RecentBookEntry* p_entry = theApp.getRecentBooks()->getEntry(idx); - -//DanTodo: surely, there must be a way to get a title instead of rendering the URL with TTS ??! (see bookmark methd commented below) +amis::RecentBookEntry* p_entry = theApp.getRecentBooks()->getEntry(idx); + +//DanTodo: surely, there must be a way to get a title instead of rendering the URL with TTS ??! (see bookmark methd commented below) string str = p_entry->mPath.get_url(); seq->append(A2T(str.c_str())); - AudioSequencePlayer::Instance()->Play(seq); - - //CString cstr_filepath = A2T(filepath.c_str()); - - /* -amis::io::BookmarksFileIO bmk_file_io; -bmk_file_io.readFromFile(&p_entry->mPath); + AudioSequencePlayer::Instance()->Play(seq); + //CString cstr_filepath = A2T(filepath.c_str()); + + /* +amis::io::BookmarksFileIO bmk_file_io; +bmk_file_io.readFromFile(&p_entry->mPath); + amis::MediaGroup* p_title = NULL; p_title = bmk_file_io.getBookmarkSet()->getTitle(); @@ -384,7 +384,7 @@ int idx = nItemID - BOOKMARKS_BASE_ID; - //amis::dtb::BookmarkSet* p_bmks = amis::dtb::DtbWithHooks::Instance()->getBookmarks(); + //amis::dtb::BookmarkSet* p_bmks = amis::dtb::DtbWithHooks::Instance()->getBookmarks(); //amis::dtb::PositionMark* p_mark = p_bmks->getItem(idx); amis::MediaGroup* p_note = amis::dtb::DtbWithHooks::Instance()->getBookmarks()->getItem(idx)->mpNote; @@ -418,56 +418,56 @@ } } else -if (nItemID > SECTION_DEPTH_BASE_ID && nItemID <= (SECTION_DEPTH_BASE_ID + MAX_ANYTHING)) - { - string strPrompt; - switch (nItemID) { - case (SECTION_DEPTH_BASE_ID+1): { - strPrompt = "numeric_one"; - break; - } - case (SECTION_DEPTH_BASE_ID+2): { - strPrompt = "numeric_two"; - break; - } - case (SECTION_DEPTH_BASE_ID+3): { - strPrompt = "numeric_three"; - break; - } - case (SECTION_DEPTH_BASE_ID+4): { - strPrompt = "numeric_four"; - break; - } - case (SECTION_DEPTH_BASE_ID+5): { - strPrompt = "numeric_five"; - break; - } - case (SECTION_DEPTH_BASE_ID+6): { - strPrompt = "numeric_six"; - break; - } - case (SECTION_DEPTH_BASE_ID+7): { - strPrompt = "numeric_seven"; - break; - } - case (SECTION_DEPTH_BASE_ID+8): { - strPrompt = "numeric_eight"; - break; - } - case (SECTION_DEPTH_BASE_ID+9): { - strPrompt = "numeric_nine"; - break; - } - } - if (!strPrompt.empty()) { - //seq->append(strPrompt.c_str()); TEST ONLY - - delete seq; - seq = AudioSequencePlayer::playPromptItemFromStringId(strPrompt, false, NULL); - - AudioSequencePlayer::Instance()->Play(seq); - } - +if (nItemID > SECTION_DEPTH_BASE_ID && nItemID <= (SECTION_DEPTH_BASE_ID + MAX_ANYTHING)) + { + string strPrompt; + switch (nItemID) { + case (SECTION_DEPTH_BASE_ID+1): { + strPrompt = "numeric_one"; + break; + } + case (SECTION_DEPTH_BASE_ID+2): { + strPrompt = "numeric_two"; + break; + } + case (SECTION_DEPTH_BASE_ID+3): { + strPrompt = "numeric_three"; + break; + } + case (SECTION_DEPTH_BASE_ID+4): { + strPrompt = "numeric_four"; + break; + } + case (SECTION_DEPTH_BASE_ID+5): { + strPrompt = "numeric_five"; + break; + } + case (SECTION_DEPTH_BASE_ID+6): { + strPrompt = "numeric_six"; + break; + } + case (SECTION_DEPTH_BASE_ID+7): { + strPrompt = "numeric_seven"; + break; + } + case (SECTION_DEPTH_BASE_ID+8): { + strPrompt = "numeric_eight"; + break; + } + case (SECTION_DEPTH_BASE_ID+9): { + strPrompt = "numeric_nine"; + break; + } + } + if (!strPrompt.empty()) { + //seq->append(strPrompt.c_str()); TEST ONLY + + delete seq; + seq = AudioSequencePlayer::playPromptItemFromStringId(strPrompt, false, NULL); + + AudioSequencePlayer::Instance()->Play(seq); + } + } @@ -549,7 +549,7 @@ CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu); -if (amis::Preferences::Instance()->mbIsSelfVoicing == false) +if (amis::Preferences::Instance()->mbIsSelfVoicing == false) { return; } @@ -621,7 +621,7 @@ //m_OpenMenu = pMenu; CMDIFrameWnd::OnInitMenu(pMenu); -if (amis::Preferences::Instance()->mbIsSelfVoicing == false) +if (amis::Preferences::Instance()->mbIsSelfVoicing == false) { return; } @@ -637,8 +637,8 @@ //pMenu->DeleteMenu( i, MF_BYPOSITION ); ; } - -//MENUITEMINFO* pMenuItemInfo; + +//MENUITEMINFO* pMenuItemInfo; //GetMenuInfo(pMenu->GetSafeHmenu(),pMenuItemInfo); //pMenu->DeleteMenu(3, MF_BYPOSITION); @@ -668,23 +668,23 @@ { CMDIFrameWnd::OnEnterMenuLoop(bIsTrackPopupMenu); -if (amis::Preferences::Instance()->mbIsSelfVoicing == false) +if (amis::Preferences::Instance()->mbIsSelfVoicing == false) { return; } - - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); // XXXJack: or what to do if view == NULL? Skip? + + MmView *view = MainWndParts::Instance()->mpMmView; + assert(view); // XXXJack: or what to do if view == NULL? Skip? bool b_BookIsPlaying = view->isPlaying(); // BOOK Audio Player mbWasPlayingWhenLostFocus = b_BookIsPlaying; if (mbWasPlayingWhenLostFocus) { - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); // XXXJack: or what to do if view == NULL? Skip? - view->OnFilePause(); + MmView *view = MainWndParts::Instance()->mpMmView; + assert(view); // XXXJack: or what to do if view == NULL? Skip? + view->OnFilePause(); //view->OnFilePlay(); } @@ -695,7 +695,7 @@ CMDIFrameWnd::OnExitMenuLoop(bIsTrackPopupMenu); -if (amis::Preferences::Instance()->mbIsSelfVoicing == false) +if (amis::Preferences::Instance()->mbIsSelfVoicing == false) { return; } @@ -704,9 +704,9 @@ if (mbWasPlayingWhenLostFocus) { - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); // XXXJack: or what to do if view == NULL? Skip? - //view->OnFilePause(); + MmView *view = MainWndParts::Instance()->mpMmView; + assert(view); // XXXJack: or what to do if view == NULL? Skip? + //view->OnFilePause(); view->OnFilePlay(); } mbWasPlayingWhenLostFocus = false; @@ -817,9 +817,9 @@ if ( nState == WA_INACTIVE ) { if ( ! AfxGetMainWnd()->IsChild(pWndOther) ) { - - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); // XXXJack: or what to do if view == NULL? Skip? + + MmView *view = MainWndParts::Instance()->mpMmView; + assert(view); // XXXJack: or what to do if view == NULL? Skip? bool b_BookIsPlaying = view->isPlaying(); // BOOK Audio Player @@ -829,12 +829,12 @@ if (mbWasPlayingWhenLostFocus) { - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); // XXXJack: or what to do if view == NULL? Skip? - view->OnFilePause(); + MmView *view = MainWndParts::Instance()->mpMmView; + assert(view); // XXXJack: or what to do if view == NULL? Skip? + view->OnFilePause(); //view->OnFilePlay(); -if (amis::Preferences::Instance()->mbIsSelfVoicing == true) +if (amis::Preferences::Instance()->mbIsSelfVoicing == true) { AudioSequencePlayer::Instance()->Stop(); } @@ -845,12 +845,12 @@ } else { //WA_ACTIVE if (mbWasPlayingWhenLostFocus) { - MmView *view = MainWndParts::Instance()->mpMmView; - assert(view); // XXXJack: or what to do if view == NULL? Skip? - //view->OnFilePause(); + MmView *view = MainWndParts::Instance()->mpMmView; + assert(view); // XXXJack: or what to do if view == NULL? Skip? + //view->OnFilePause(); view->OnFilePlay(); -if (amis::Preferences::Instance()->mbIsSelfVoicing == true) +if (amis::Preferences::Instance()->mbIsSelfVoicing == true) { AudioSequencePlayer::Instance()->RepeatLast(); } Modified: branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -24,7 +24,7 @@ #include "gui/MenuManip.h" #include "gui/MainWndParts.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisApp.h" #include "DtbWithHooks.h" #include "RecentBooks.h" #include "dtb/nav/NavModel.h" @@ -104,57 +104,57 @@ p_model = amis::dtb::DtbWithHooks::Instance()->getNavModel(); if (p_model == NULL) return; - int max_depth = p_model->getNavMap()->getMaxDepth(); - - 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 "Navigate" - p_menu = p_menu->GetSubMenu(3); - - //get "Show Section Depth" popup - p_menu = p_menu->GetSubMenu(2); - - //clear all menu items - int num_entries = p_menu->GetMenuItemCount(); - for (int i=num_entries-1; i>=0; i--) - p_menu->RemoveMenu(i, MF_BYPOSITION); - - //add 1...max_depth items - for (int i=1; i<=max_depth; i++) - { - CString menu_label; - menu_label.Format(_T("&%d"), i); - BOOL ret = p_menu->AppendMenu(MF_STRING, SECTION_DEPTH_BASE_ID + i, menu_label); - } - - //get the main menu - p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); - //get "Navigate" - p_menu = p_menu->GetSubMenu(3); - - if (p_model->hasPages() == false) - { - p_menu->EnableMenuItem(ID_MENU_NAV_NEXTPAGE, MF_BYCOMMAND | MF_GRAYED); - p_menu->EnableMenuItem(ID_MENU_NAV_PREVPAGE, MF_BYCOMMAND | MF_GRAYED); - p_menu->EnableMenuItem(ID_MENU_NAV_GOTOPAGE, MF_BYCOMMAND | MF_GRAYED); - } - else - { - p_menu->EnableMenuItem(ID_MENU_NAV_NEXTPAGE, MF_BYCOMMAND | MF_ENABLED); - p_menu->EnableMenuItem(ID_MENU_NAV_PREVPAGE, MF_BYCOMMAND | MF_ENABLED); - p_menu->EnableMenuItem(ID_MENU_NAV_GOTOPAGE, MF_BYCOMMAND | MF_ENABLED); + int max_depth = p_model->getNavMap()->getMaxDepth(); + + 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 "Navigate" + p_menu = p_menu->GetSubMenu(3); + + //get "Show Section Depth" popup + p_menu = p_menu->GetSubMenu(2); + + //clear all menu items + int num_entries = p_menu->GetMenuItemCount(); + for (int i=num_entries-1; i>=0; i--) + p_menu->RemoveMenu(i, MF_BYPOSITION); + + //add 1...max_depth items + for (int i=1; i<=max_depth; i++) + { + CString menu_label; + menu_label.Format(_T("&%d"), i); + BOOL ret = p_menu->AppendMenu(MF_STRING, SECTION_DEPTH_BASE_ID + i, menu_label); } + + //get the main menu + p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); + //get "Navigate" + p_menu = p_menu->GetSubMenu(3); + + if (p_model->hasPages() == false) + { + p_menu->EnableMenuItem(ID_MENU_NAV_NEXTPAGE, MF_BYCOMMAND | MF_GRAYED); + p_menu->EnableMenuItem(ID_MENU_NAV_PREVPAGE, MF_BYCOMMAND | MF_GRAYED); + p_menu->EnableMenuItem(ID_MENU_NAV_GOTOPAGE, MF_BYCOMMAND | MF_GRAYED); + } + else + { + p_menu->EnableMenuItem(ID_MENU_NAV_NEXTPAGE, MF_BYCOMMAND | MF_ENABLED); + p_menu->EnableMenuItem(ID_MENU_NAV_PREVPAGE, MF_BYCOMMAND | MF_ENABLED); + p_menu->EnableMenuItem(ID_MENU_NAV_GOTOPAGE, MF_BYCOMMAND | MF_ENABLED); + } } //@todo //this doesn't work like it should! individual menu items can't be enabled or grayed-out, but whole menus can void MenuManip::setupMenusNothingOpen() { - //get the main menu + //get the main menu CMenu* p_main_menu = NULL; p_main_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); assert(p_main_menu); @@ -188,7 +188,7 @@ void MenuManip::setupMenusSomethingOpen(amis::dtb::BookmarkSet* pBookmarks) { - //get the main menu + //get the main menu CMenu* p_main_menu = NULL; p_main_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); assert(p_main_menu); @@ -322,84 +322,84 @@ if (p_mark) addBookmark(p_mark); } } - -void MenuManip::setPauseState(bool pauseState) -{ - - CMenu* p_menu = NULL; - p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); - if (p_menu == NULL) - { - return; - } - - p_menu = p_menu->GetSubMenu(2); - assert(p_menu); - - bool b_BookIsPlaying = MainWndParts::Instance()->mpMainFrame->mbWasPlayingWhenLostFocus || !pauseState; - - UiItem* p_uiItem = DataTree::Instance()->findUiItemInContainers(ID_MENU_PLAYPAUSE, (b_BookIsPlaying ? "canPause" : "canPlay")); - if (p_uiItem != NULL) { - Label* accelerator = NULL; - if (p_uiItem->getUiItemType() == ACTION) { - accelerator = ((Action*)p_uiItem)->getKeyboardAccelerator(); - } - Label* mnemonic = NULL; - if (p_uiItem->getUiItemType() == ACTION) { - mnemonic = ((Action*)p_uiItem)->getMnemonic(); - } - Label* p_caption = p_uiItem->getCaption(); - if (p_caption != NULL) { - TextAudioPair* pair = p_caption->getContents(); - if (pair != NULL) { - amis::TextNode* textNode = pair->getText(); - if (textNode != NULL) { - wstring str = textNode->getTextString(); - - if (mnemonic != NULL) { - TextAudioPair* pair = mnemonic->getContents(); - if (pair != NULL) { - TextNode* node = pair->getText(); - if (node != NULL) { - wstring strMnemonic = node->getTextString(); - int index = str.find_first_of(strMnemonic, 0); - if (index != -1) { - str.insert(index, _T("&")); - } - } - } - } - - if (accelerator != NULL) { - str.append(_T("\t")); - //char* text = accelerator.c_str(); - //str.append(accelerator.c_str()); - TextAudioPair* pair = accelerator->getContents(); - if (pair != NULL) { - TextNode* node = pair->getText(); - if (node != NULL) { - str.append(node->getTextString()); - } - } - - //str2.append(info.dwTypeData); - } - p_menu->ModifyMenu(0, MF_BYPOSITION, ID_MENU_PLAYPAUSE, str.c_str()); - } - } - } - } - - /*if (pauseState) - { - // If book is paused, then we display a "play" action - p_menu->ModifyMenu(0, MF_BYPOSITION, ID_MENU_PLAYPAUSE, L"&Play\tSpace"); - } - else - { - // If book is playing, then we display a "pause" action - p_menu->ModifyMenu(0, MF_BYPOSITION, ID_MENU_PLAYPAUSE, L"&Pause\tSpace"); - }*/ - - + +void MenuManip::setPauseState(bool pauseState) +{ + + CMenu* p_menu = NULL; + p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); + if (p_menu == NULL) + { + return; + } + + p_menu = p_menu->GetSubMenu(2); + assert(p_menu); + + bool b_BookIsPlaying = MainWndParts::Instance()->mpMainFrame->mbWasPlayingWhenLostFocus || !pauseState; + + UiItem* p_uiItem = DataTree::Instance()->findUiItemInContainers(ID_MENU_PLAYPAUSE, (b_BookIsPlaying ? "canPause" : "canPlay")); + if (p_uiItem != NULL) { + Label* accelerator = NULL; + if (p_uiItem->getUiItemType() == ACTION) { + accelerator = ((Action*)p_uiItem)->getKeyboardAccelerator(); + } + Label* mnemonic = NULL; + if (p_uiItem->getUiItemType() == ACTION) { + mnemonic = ((Action*)p_uiItem)->getMnemonic(); + } + Label* p_caption = p_uiItem->getCaption(); + if (p_caption != NULL) { + TextAudioPair* pair = p_caption->getContents(); + if (pair != NULL) { + amis::TextNode* textNode = pair->getText(); + if (textNode != NULL) { + wstring str = textNode->getTextString(); + + if (mnemonic != NULL) { + TextAudioPair* pair = mnemonic->getContents(); + if (pair != NULL) { + TextNode* node = pair->getText(); + if (node != NULL) { + wstring strMnemonic = node->getTextString(); + int index = str.find_first_of(strMnemonic, 0); + if (index != -1) { + str.insert(index, _T("&")); + } + } + } + } + + if (accelerator != NULL) { + str.append(_T("\t")); + //char* text = accelerator.c_str(); + //str.append(accelerator.c_str()); + TextAudioPair* pair = accelerator->getContents(); + if (pair != NULL) { + TextNode* node = pair->getText(); + if (node != NULL) { + str.append(node->getTextString()); + } + } + + //str2.append(info.dwTypeData); + } + p_menu->ModifyMenu(0, MF_BYPOSITION, ID_MENU_PLAYPAUSE, str.c_str()); + } + } + } + } + + /*if (pauseState) + { + // If book is paused, then we display a "play" action + p_menu->ModifyMenu(0, MF_BYPOSITION, ID_MENU_PLAYPAUSE, L"&Play\tSpace"); + } + else + { + // If book is playing, then we display a "pause" action + p_menu->ModifyMenu(0, MF_BYPOSITION, ID_MENU_PLAYPAUSE, L"&Pause\tSpace"); + }*/ + + } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -27,7 +27,7 @@ #include "gui/MmDoc.h" #include "gui/MmView.h" #include "gui/HtmlView.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisApp.h" #include "io/UrlInputSource.h" Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -25,7 +25,7 @@ #include "gui/TextRenderBrain.h" #include "gui/MainWndParts.h" #include "util/FilePathTools.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisApp.h" #include "util/Color.h" #include <algorithm> Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -23,7 +23,7 @@ #include "Preferences.h" #include "gui/MainWndParts.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisApp.h" using namespace amis::gui::dialogs; Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -23,7 +23,7 @@ #include "gui/dialogs/AmisFileDialog.h" #include "../resource.h" #include "Preferences.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisApp.h" using namespace amis::gui::dialogs; Modified: branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/gui/sidebar/AmisSidebar.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -26,7 +26,7 @@ #include "dtb/nav/NavModel.h" #include "dtb/nav/NavMap.h" #include "dtb/nav/NavNode.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisApp.h" #include "../../../resource.h" #ifdef _DEBUG Modified: branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp 2008-01-28 05:09:40 UTC (rev 2292) +++ branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp 2008-01-28 06:18:04 UTC (rev 2293) @@ -235,13 +235,13 @@ pWriter = ((DOMImplementationLS*)pImpl)->createDOMWriter(); //make sure the path to the file exists - string dir = amis::util::FilePathTools::getParentDirectory(mFilepath.get_file()); + string dir = amis::util::FilePathTools::getParentDirectory(filepath); if (access(dir.c_str(), 0) == -1) { _mkdir(dir.c_str()); } - pFormTarget = new LocalFileFormatTarget(mFilepath.get_file().c_str()); + pFormTarget = new LocalFileFormatTarget(filepath.c_str()); DOMNode* pDocNode = (DOMNode*)mpDoc; pWriter->writeNode(pFormTarget, *pDocNode); @@ -265,7 +265,7 @@ pGeneralSection = mpDoc->createElement(X("section")); pGeneralSection->setAttribute(X("name"), X("general")); - pEntry = createEntry("ui-lang-id", mpPrefs->mUiLangId.c_str()); + pEntry = createEntry("ui-lang-id", mpPrefs->mUiLangId); pGeneralSection->appendChild((DOMNode*)pEntry); pEntry = createEntry("start-basic", mpPrefs->mbStartBasicView); @@ -300,7 +300,7 @@ pGeneralSection->appendChild((DOMNode*)pEntry); //Directories - pEntry = createEntry("ui-lang-dir", mpPrefs->mUiLangDir.c_str()); + pEntry = createEntry("ui-lang-dir", mpPrefs->mUiLangDir); pGeneralSection->appendChild((DOMNode*)pEntry); pEntry = createEntry("user-bmk-dir", mpPrefs->mUserBmkDir); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-01-29 00:48:09
|
Revision: 2294 http://amis.svn.sourceforge.net/amis/?rev=2294&view=rev Author: marisademeglio Date: 2008-01-28 16:48:10 -0800 (Mon, 28 Jan 2008) Log Message: ----------- Changed structure of Preferences class and made all relevant updates elsewhere. Split up text highlighting so that the presence of highlight colors can be controlled via the preferences dialog. Modified Paths: -------------- branches/amis3/AmisCore/include/AmisCore.h branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp branches/amis3/AmisGuiMFC2/include/Preferences.h branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h branches/amis3/AmisGuiMFC2/include/gui/HtmlView.h branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h branches/amis3/AmisGuiMFC2/resource.h branches/amis3/AmisGuiMFC2/src/Preferences.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp branches/amis3/bin/settings/amisPrefs.xml.default Modified: branches/amis3/AmisCore/include/AmisCore.h =================================================================== --- branches/amis3/AmisCore/include/AmisCore.h 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisCore/include/AmisCore.h 2008-01-29 00:48:10 UTC (rev 2294) @@ -68,12 +68,17 @@ namespace amis { - //get the media primitives declared first class MediaNode; class TextNode; class ImageNode; class AudioNode; class MediaGroup; + class Error; + class RecentBookEntry; + class RecentBooks; + class ModuleDescData; + class SearchDTBText; + class SearchDTBParser; typedef vector<string> StdStringList; typedef vector<ambulant::net::url> UrlList; @@ -84,23 +89,14 @@ typedef stdext::hash_map<std::string, std::string> StringMap; typedef stdext::hash_map<std::string, ambulant::net::url> UrlMap; typedef stdext::hash_map<std::string, bool> BooleanMap; - typedef stdext::hash_map<std::string, amis::MediaGroup*> StringMediaMap; + typedef stdext::hash_map<std::string, amis::ModuleDescData*> StringModuleMap; #elif defined(AMIS_COMPILER_GCC) typedef __gnu_cxx::hash_map<std::string, std::string> StringMap; typedef __gnu_cxx::hash_map<std::string, ambulant::net::url> UrlMap; typedef __gnu_cxx::hash_map<std::string, bool> BooleanMap; - typedef __gnu_cxx::hash_map<std::string, amis::MediaGroup*> StringMediaMap; + typedef __gnu_cxx::hash_map<std::string, amis::ModuleDescData*> StringModuleMap; #endif - - - class Error; - class RecentBookEntry; - class RecentBooks; - class ModuleDescData; - class SearchDTBText; - class SearchDTBParser; - namespace dtb { class Dtb; Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-01-29 00:48:10 UTC (rev 2294) @@ -376,10 +376,10 @@ CAPTION "Preferences" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "Use self-voicing",IDC_SELFVOICING,"Button", + 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 - COMBOBOX IDC_TTSVOICE,7,35,108,88,CBS_DROPDOWNLIST | CBS_SORT | + COMBOBOX IDC_TTSVOICES,7,35,108,88,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP CONTROL "Pause audio when switching applications", IDC_PAUSEONLOSTFOCUS,"Button",BS_AUTOCHECKBOX | @@ -387,14 +387,14 @@ CONTROL "Highlight text as it is read aloud",IDC_HIGHLIGHTTEXT, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,78,242,10 CONTROL "Load the most recently read book on startup", - IDC_LOADLASTDTB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, + IDC_LOADLASTBOOK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, 98,242,10 - CONTROL "Start in basic view mode",IDC_STARTBASIC,"Button", + CONTROL "Start in basic view mode",IDC_STARTINBASICVIEW,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,117,242,10 LTEXT "You are currently using AMIS in:",IDC_CURRLANG,7,140, 242,8 - COMBOBOX IDC_LANGCOMBO,7,153,113,30,CBS_DROPDOWN | CBS_SORT | - WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_INSTALLEDLANGUAGES,7,153,113,30,CBS_DROPDOWN | + CBS_SORT | WS_VSCROLL | WS_TABSTOP ICON IDI_LANGICON,IDC_LANGICON,136,151,20,20 DEFPUSHBUTTON "OK",IDOK,57,185,50,14 PUSHBUTTON "Cancel",IDCANCEL,112,185,50,14 Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/AudioSequencePlayer.cpp 2008-01-29 00:48:10 UTC (rev 2294) @@ -307,40 +307,30 @@ } void AudioSequencePlayer::playAudioPrompt(amis::AudioNode* pAudio) { + ambulant::net::url audio_src = ambulant::net::url::from_filename(pAudio->getSrc()); - string src = pAudio->getSrc(); + amis::ModuleDescData* p_langpack_data = amis::Preferences::Instance()->getCurrentLanguageData(); + audio_src = audio_src.join_to_base(*p_langpack_data->getXmlFileName()); - //string audio_dir = AUDIO_DIR; - //audio_prompts_file = amis::FilePathTools::goRelativePath(audio_prompts_file, audio_dir); + string src = audio_src.get_file(); + string clipBegin = ""; + string clipEnd = ""; - string tmpStr = amis::Preferences::Instance()->mUiLangDir; - //CAmisGuiMFC2App* pApp = (CAmisGuiMFC2App *) AfxGetApp(); - tmpStr = amis::util::FilePathTools::goRelativePath(theApp.getAppPath(), tmpStr); - - src = amis::util::FilePathTools::goRelativePath(tmpStr, src); - src = amis::util::FilePathTools::getAsLocalFilePath(src); + if (pAudio->getClipBegin().size() > 0) + { + clipBegin = stringReplaceAll(pAudio->getClipBegin(), "npt=", ""); + } - //src = ambulant::net::url::urlpath2filepath(src); - - string clipBegin = ""; - string clipEnd = ""; + if (pAudio->getClipEnd().size() > 0) + { + clipEnd = stringReplaceAll(pAudio->getClipEnd(), "npt=", ""); + } - if (pAudio->getClipBegin().size() > 0) - { - clipBegin = stringReplaceAll(pAudio->getClipBegin(), "npt=", ""); + AmisAudio::Instance()->play(src.c_str(), + (char*)clipBegin.c_str(), + (char*)clipEnd.c_str()); +} - } - - if (pAudio->getClipEnd().size() > 0) - { - clipEnd = stringReplaceAll(pAudio->getClipEnd(), "npt=", ""); - } - - AmisAudio::Instance()->play(src.c_str(), - (char*)clipBegin.c_str(), - (char*)clipEnd.c_str()); - -} unsigned __stdcall AudioSequencePlayer::ThreadProc(void* Arg) { USES_CONVERSION; @@ -946,11 +936,15 @@ TextAudioPair* pair = label->getContents(); if (pair != NULL) { amis::AudioNode* audio = pair->getAudio(); - if (!Preferences::Instance()->mbUseTTSNotAudio && audio != NULL) { + if (!Preferences::Instance()->getUseTTSNotAudio() && audio != NULL) + { seq->append(audio); - } else { + } + else + { TextNode* textN = pair->getText(); - if (textN != NULL) { + if (textN != NULL) + { seq->append(textN->getTextString().c_str()); } } @@ -973,10 +967,11 @@ if (pair != NULL) { amis::AudioNode* audio = pair->getAudio(); - if (!Preferences::Instance()->mbUseTTSNotAudio && audio != NULL) + if (!Preferences::Instance()->getUseTTSNotAudio() && audio != NULL) { seq->append(audio); - } else + } + else { TextNode * textN = pair->getText(); if (textN != NULL) @@ -996,10 +991,11 @@ if (pair != NULL) { amis::AudioNode* audio = pair->getAudio(); - if (!Preferences::Instance()->mbUseTTSNotAudio && audio != NULL) + if (!Preferences::Instance()->getUseTTSNotAudio() && audio != NULL) { seq->append(audio); - } else + } + else { TextNode * textN = pair->getText(); if (textN != NULL) @@ -1022,11 +1018,15 @@ TextAudioPair* pair = pi->getContents(); if (pair != NULL) { amis::AudioNode* audio = pair->getAudio(); - if (!Preferences::Instance()->mbUseTTSNotAudio && audio != NULL) { + if (!Preferences::Instance()->getUseTTSNotAudio() && audio != NULL) + { seq->append(audio); - } else { + } + else + { TextNode * textN = pair->getText(); - if (textN != NULL) { + if (textN != NULL) + { seq->append(textN->getTextString().c_str()); } } Modified: branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/AmisSelfVoicing/TTSPlayer.cpp 2008-01-29 00:48:10 UTC (rev 2294) @@ -196,7 +196,7 @@ m_iV->SetInterest( SPFEI_ALL_TTS_EVENTS, SPFEI_ALL_TTS_EVENTS ); - ChangeVoice(amis::Preferences::Instance()->mTTSVoice); + ChangeVoice(amis::Preferences::Instance()->getTTSVoiceIndex()); //ChangeVoice(FALSE); m_iV->SetVolume(50); //TODO: this value works well on my laptop/configuration...but how about other machines ?? Modified: branches/amis3/AmisGuiMFC2/include/Preferences.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/Preferences.h 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/include/Preferences.h 2008-01-29 00:48:10 UTC (rev 2294) @@ -37,57 +37,107 @@ Preferences(); public: + //these should be private some day + //these values (should) come from parsing default.css + util::Color mHighlightFG; + util::Color mHighlightBG; + std::string mFontName; + int mFontSize; + util::Color mPageFG; + util::Color mPageBG; + +public: static Preferences* Instance(); void DestroyInstance(); ~Preferences(); + //the preferences IO class should call this function after reading in the XML file void scanAll(); + + //ACCESSORS + void setUiLangId(string); + string getUiLangId(); + + void setStartInBasicView(bool); + bool getStartInBasicView(); + + void setLoadLastBook(bool); + bool getLoadLastBook(); + + void setPauseOnLostFocus(bool); + bool getPauseOnLostFocus(); + + void setIsSelfVoicing(bool); + bool getIsSelfVoicing(); + + void setTTSVoiceIndex(int); + int getTTSVoiceIndex(); + + void setUseTTSNotAudio(bool); + bool getUseTTSNotAudio(); + + void setWasExitClean(bool); + bool getWasExitClean(); + + void setHighlightText(bool); + bool getHighlightText(); + + void setUserBmkDir(const ambulant::net::url*); + const ambulant::net::url* getUserBmkDir(); + void setLangpacksDir(const ambulant::net::url*); + const ambulant::net::url* getLangpacksDir(); + + void setFontsizeCssDir(const ambulant::net::url*); + const ambulant::net::url* getFontsizeCssDir(); + + void setContrastCssDir(const ambulant::net::url*); + const ambulant::net::url* getContrastCssDir(); + + void setUserCssFile(const ambulant::net::url*); + const ambulant::net::url* getUserCssFile(); + + void setZed2005CssFile(const ambulant::net::url*); + const ambulant::net::url* getZed2005CssFile(); + + void setSourceUrl(const ambulant::net::url*); + const ambulant::net::url* getSourceUrl(); + + amis::UrlList* getFontsizeCssFiles(); + amis::UrlList* getContrastCssFiles(); + amis::StringModuleMap* getInstalledLanguages(); + amis::ModuleDescData* getCurrentLanguageData(); + private: void scanDirectoriesForCssFiles(); void scanDirectoriesForLanguagePackFiles(); void processLanguagePackModuleDescData(amis::ModuleDescData*); - void updateCurrentLanguagePackDirectory(); -public: string mUiLangId; - bool mbStartBasicView; + bool mbStartInBasicView; bool mbLoadLastBook; - bool mbPauseOnApplicationLostFocus; + bool mbPauseOnLostFocus; bool mbIsSelfVoicing; - int mTTSVoice; + int mTTSVoiceIndex; bool mbUseTTSNotAudio; - bool mbExitWasClean; - - //Directories - string mUserBmkDir; - //the root language packs directory - string mUiLangDir; - string mFontsizeCssDir; - string mContrastCssDir; - //map the id of the language to the media label for the language - amis::StringMediaMap mLanguagePackLabels; - - //CSS files - //the list gets build from scanning the above directories - //at runtime, the files are applied/cycled through in alphabetical order + bool mbWasExitClean; + bool mbHighlightText; + ambulant::net::url mUserBmkDir; + ambulant::net::url mLangpacksDir; + ambulant::net::url mFontsizeCssDir; + ambulant::net::url mContrastCssDir; + ambulant::net::url mUserCssFile; + ambulant::net::url mZed2005CssFile; + + //the following gets calculated at runtime + //1. map the id of the language to the module description (path, media label, etc) + amis::StringModuleMap mInstalledLanguages; + //2. the fontsize css files amis::UrlList mFontsizeCssFiles; + //3. the contrast css files amis::UrlList mContrastCssFiles; - ambulant::net::url mDefaultCssFile; - ambulant::net::url mZed2005CssFile; - - //our currently-selected language pack's directory - std::string mCurrentLanguagePackDir; - + //the source preferences XML file ambulant::net::url mSourceUrl; - - //these values come from parsing default.css - util::Color mHighlightFG; - util::Color mHighlightBG; - std::string mFontName; - int mFontSize; - util::Color mPageFG; - util::Color mPageBG; private: static Preferences* pinstance; Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-01-29 00:48:10 UTC (rev 2294) @@ -104,7 +104,8 @@ HACCEL m_hMDIAccel; private: - void initPathsAndFiles(); + void initializePathsAndFiles(); + void initializeSelfVoicing(); void openBook(const ambulant::net::url*); void openLastReadBook(); std::string mAppPath; @@ -112,7 +113,6 @@ ambulant::net::url mURL; amis::RecentBooks* mpRecentBooks; bool mbBookIsOpen; - ambulant::net::url very_temporary_bookmarks_dir; public: //afx_msg void OnAppAbout(); DECLARE_MESSAGE_MAP() Modified: branches/amis3/AmisGuiMFC2/include/gui/HtmlView.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/HtmlView.h 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/include/gui/HtmlView.h 2008-01-29 00:48:10 UTC (rev 2294) @@ -53,7 +53,7 @@ CAmisHtmlDoc* GetDocument(); //returns a pointer to the stylesheet - IHTMLStyleSheet* applyStylesheet(ambulant::net::url*); + IHTMLStyleSheet* applyStylesheet(const ambulant::net::url*); void removeStylesheet(IHTMLStyleSheet*); virtual void OnDraw(CDC*); // overridden to draw this view Modified: branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2008-01-29 00:48:10 UTC (rev 2294) @@ -52,8 +52,8 @@ bool toggleContrast(); bool isContrastOn(); - void highlightUriTarget(amis::TextNode*); - void highlightUriTarget(std::string url); + void gotoUriTarget(amis::TextNode*); + void gotoUriTarget(std::string url); void redoPageColors(bool bDisableContrast=false); wstring getCurrentText(); @@ -62,9 +62,10 @@ private: void saveElementText(IHTMLElement*); void setFontSize(int); - void highlightElementAtId(string); + void showElementAtId(string); void htmlContrastOn(); void htmlContrastOff(); + void setHighlightColors(IHTMLElement*); void redoHighlightColors(); bool isElementInView(IHTMLElement*); void scanStylesheetForAdditionalData(IHTMLStyleSheet*); @@ -77,12 +78,12 @@ ambulant::net::url mCurrentUrl; string mTextElmId; wstring mCurrentElmText; - IHTMLElement* pLastElm; + IHTMLElement* mpLastElm; VARIANT mUnhighlightedBG; VARIANT mUnhighlightedFG; IHTMLStyleSheet* mpFontCss; IHTMLStyleSheet* mpContrastCss; - IHTMLStyleSheet* mpDefaultCss; + IHTMLStyleSheet* mpUserCss; private: static TextRenderBrain* pinstance; Modified: branches/amis3/AmisGuiMFC2/resource.h =================================================================== --- branches/amis3/AmisGuiMFC2/resource.h 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/resource.h 2008-01-29 00:48:10 UTC (rev 2294) @@ -49,17 +49,20 @@ #define IDC_BTN_PAGEBG 1013 #define IDC_LIST_PAGE 1015 #define IDC_TTSVOICE 1020 +#define IDC_TTSVOICES 1020 #define IDC_BTN_RESETCOLORS 1028 #define IDC_STARTSEARCH 1030 #define IDC_BTN_TEXTFG 1030 #define IDC_BTN_PAGEFG 1032 #define IDC_SELFVOICING 1034 +#define IDC_ISSELFVOICING 1034 #define IDC_PROMPTONBASICVIEW 1036 #define IDC_BMKDIR 1037 #define IDC_BROWSE 1038 #define IDC_LOADLASTDTB 1041 +#define IDC_LOADLASTBOOK 1041 #define IDC_HIGHLIGHTTEXT 1042 -#define IDC_STARTBASIC 1043 +#define IDC_STARTINBASICVIEW 1043 #define IDC_STOPSEARCH 1048 #define IDC_PICTURE 1050 #define IDC_SEARCHING 1051 @@ -100,7 +103,7 @@ #define IDC_CURRENTPOSITION 1085 #define IDC_SEARCHINSTRUCTIONS 1088 #define IDC_LANGCOMBO 1095 -#define IDC_COMBO1 1096 +#define IDC_INSTALLEDLANGUAGES 1095 #define ID_MENU_FIND_IN_TEXT_NEXT 9000 #define IDC_LANGLIST 9001 #define ID_MENU_FIND_IN_TEXT_PREV 9001 Modified: branches/amis3/AmisGuiMFC2/src/Preferences.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/src/Preferences.cpp 2008-01-29 00:48:10 UTC (rev 2294) @@ -45,28 +45,32 @@ Preferences::Preferences() { - mUiLangId = "eng-US"; - mbPauseOnApplicationLostFocus = true; - mbIsSelfVoicing = false; - mbUseTTSNotAudio = false; - mbLoadLastBook = false; - mbStartBasicView = false; - mTTSVoice = -1; - mbExitWasClean = true; + setUiLangId("eng-US"); + setPauseOnLostFocus(true); + setIsSelfVoicing(false); + setUseTTSNotAudio(false); + setLoadLastBook(false); + setStartInBasicView(false); + setTTSVoiceIndex(-1); + setWasExitClean(true); mFontsizeCssFiles.clear(); mContrastCssFiles.clear(); //note that file paths here are hardcoded relative to the application directory //whereas in the prefs XML file, they are relative to the prefs XML file //they get overridden by reading in the preferences file; these defaults are just here as a safety measure - mFontsizeCssDir = "./settings/css/font/"; - mContrastCssDir = "./settings/css/contrast/"; - mUiLangDir = "./settings/lang/"; - mUserBmkDir = "./settings/bmk/"; + mFontsizeCssDir = ambulant::net::url::from_filename("./settings/css/font/"); + mContrastCssDir = ambulant::net::url::from_filename("./settings/css/contrast/"); + mLangpacksDir = ambulant::net::url::from_filename("./settings/lang/"); + mUserBmkDir = ambulant::net::url::from_filename("./settings/bmk/"); + mUserCssFile = ambulant::net::url::from_filename("./settings/css/default.css"); + mZed2005CssFile = ambulant::net::url::from_filename("./settings/css/dtbook.2005.basic.css"); ambulant::net::url app_path = ambulant::net::url::from_filename(theApp.getAppPath()); - mDefaultCssFile = ambulant::net::url::from_filename("./settings/css/default.css"); - mDefaultCssFile = mDefaultCssFile.join_to_base(app_path); - mZed2005CssFile = ambulant::net::url::from_filename("./settings/css/dtbook.2005.basic.css"); + mFontsizeCssDir = mFontsizeCssDir.join_to_base(app_path); + mContrastCssDir = mContrastCssDir.join_to_base(app_path); + mLangpacksDir = mLangpacksDir.join_to_base(app_path); + mUserBmkDir = mUserBmkDir.join_to_base(app_path); + mUserCssFile = mUserCssFile.join_to_base(app_path); mZed2005CssFile = mZed2005CssFile.join_to_base(app_path); mHighlightFG.set("000000"); @@ -77,21 +81,11 @@ //this function should be called after the preferences XML file has been parsed void Preferences::scanAll() { - updateCurrentLanguagePackDirectory(); scanDirectoriesForCssFiles(); scanDirectoriesForLanguagePackFiles(); } -void Preferences::updateCurrentLanguagePackDirectory() -{ - mCurrentLanguagePackDir = mUiLangDir; - //make sure it ends with a slash - int last_char = mCurrentLanguagePackDir.size() - 1; - if (mCurrentLanguagePackDir[last_char] != '/') mCurrentLanguagePackDir.append("/"); - mCurrentLanguagePackDir += mUiLangId + "/"; -} - void Preferences::scanDirectoriesForCssFiles() { amis::util::SearchForFilesMFC searcher; @@ -99,18 +93,18 @@ //these files will only bother developers searcher.addSearchExclusionCriteria(".svn"); searcher.setRecursiveSearch(true); - if (searcher.startSearch(amis::util::FilePathTools::getAsLocalFilePath(mFontsizeCssDir)) > 0) + if (searcher.startSearch(mFontsizeCssDir.get_file()) > 0) { mFontsizeCssFiles = *searcher.getSearchResults(); } - else TRACE(_T("No fontsize css files found"));//TODO Log this message instead + else TRACE(_T("No fontsize css files found\n"));//TODO Log this message instead searcher.clearSearchResults(); - if (searcher.startSearch(amis::util::FilePathTools::getAsLocalFilePath(mContrastCssDir)) > 0) + if (searcher.startSearch(mContrastCssDir.get_file()) > 0) { mContrastCssFiles = *searcher.getSearchResults(); } - else TRACE(_T("No contrast css files found"));//TODO Log this message instead + else TRACE(_T("No contrast css files found\n"));//TODO Log this message instead } //search for "moduleDesc.xml" files that inside the root language pack directory @@ -123,7 +117,7 @@ //these files will only bother developers searcher.addSearchExclusionCriteria(".svn"); searcher.setRecursiveSearch(true); - if (searcher.startSearch(amis::util::FilePathTools::getAsLocalFilePath(mUiLangDir)) > 0) + if (searcher.startSearch(mLangpacksDir.get_file()) > 0) { amis::UrlList list = *searcher.getSearchResults(); for (int i = 0; i<list.size(); i++) @@ -132,45 +126,216 @@ if (reader.readFromFile(&list[i])) { amis::ModuleDescData* p_data = reader.getModuleDescData(); - processLanguagePackModuleDescData(p_data); - //don't delete the data, we'll need it later - //this is a known (small) memory leak though! + if (p_data == NULL) + { + //TODO: log error - no data available for language pack + TRACE(_T("No data available for language pack\n")); + } + else + { + if (p_data->isEnabled() && p_data->getModuleType() == amis::ModuleDescData::LANGPACK) + { + string id = p_data->getId(); + mInstalledLanguages[id] = p_data; + } + } } else { - //TODO: log error + //TODO: log error - could not read language pack file + TRACE(_T("Could not read language pack file\n")); } } } - else TRACE(_T("No language pack files found"));//TODO Log this message instead + else TRACE(_T("No language pack files found\n"));//TODO Log this message instead } -void Preferences::processLanguagePackModuleDescData(amis::ModuleDescData* pData) +Preferences::~Preferences() { - if (pData == NULL) + amis::StringModuleMap::iterator it = mInstalledLanguages.begin(); + while (mInstalledLanguages.size() > 0) { - //TODO : log error - return; + amis::ModuleDescData* p_module = it->second; + if (p_module != NULL) delete p_module; + mInstalledLanguages.erase(it); + it = mInstalledLanguages.begin(); } +} - if (pData->isEnabled() && pData->getModuleType() == amis::ModuleDescData::LANGPACK) - { - //track the media label and id of this language - amis::MediaGroup* p_media = pData->getLabel(); - string id = pData->getId(); - mLanguagePackLabels[id] = p_media; - } +//************************************ +//ACCESSORS +void Preferences::setUiLangId(string value) +{ + mUiLangId = value; } +string Preferences::getUiLangId() +{ + return mUiLangId; +} -Preferences::~Preferences() +void Preferences::setStartInBasicView(bool value) { - amis::StringMediaMap::iterator it = mLanguagePackLabels.begin(); - while (mLanguagePackLabels.size() > 0) - { - amis::MediaGroup* p_media = it->second; - if (p_media != NULL) delete p_media; - mLanguagePackLabels.erase(it); - it = mLanguagePackLabels.begin(); - } + mbStartInBasicView = value; } +bool Preferences::getStartInBasicView() +{ + return mbStartInBasicView; +} + +void Preferences::setLoadLastBook(bool value) +{ + mbLoadLastBook = value; +} + +bool Preferences::getLoadLastBook() +{ + return mbLoadLastBook; +} + +void Preferences::setPauseOnLostFocus(bool value) +{ + mbPauseOnLostFocus = value; +} + +bool Preferences::getPauseOnLostFocus() +{ + return mbPauseOnLostFocus; +} + +void Preferences::setIsSelfVoicing(bool value) +{ + mbIsSelfVoicing = value; +} + +bool Preferences::getIsSelfVoicing() +{ + return mbIsSelfVoicing; +} + +void Preferences::setTTSVoiceIndex(int value) +{ + mTTSVoiceIndex = value; +} + +int Preferences::getTTSVoiceIndex() +{ + return mTTSVoiceIndex; +} + +void Preferences::setUseTTSNotAudio(bool value) +{ + mbUseTTSNotAudio = value; +} + +bool Preferences::getUseTTSNotAudio() +{ + return mbUseTTSNotAudio; +} + +void Preferences::setWasExitClean(bool value) +{ + mbWasExitClean = value; +} + +bool Preferences::getWasExitClean() +{ + return mbWasExitClean; +} +void Preferences::setHighlightText(bool value) +{ + mbHighlightText = value; +} +bool Preferences::getHighlightText() +{ + return mbHighlightText; +} +void Preferences::setUserBmkDir(const ambulant::net::url* value) +{ + mUserBmkDir = *value; +} + +const ambulant::net::url* Preferences::getUserBmkDir() +{ + return &mUserBmkDir; +} + +void Preferences::setLangpacksDir(const ambulant::net::url* value) +{ + mLangpacksDir = *value; +} + +const ambulant::net::url* Preferences::getLangpacksDir() +{ + return &mLangpacksDir; +} + +void Preferences::setFontsizeCssDir(const ambulant::net::url* value) +{ + mFontsizeCssDir = *value; +} + +const ambulant::net::url* Preferences::getFontsizeCssDir() +{ + return &mFontsizeCssDir; +} + +void Preferences::setContrastCssDir(const ambulant::net::url* value) +{ + mContrastCssDir = *value; +} + +const ambulant::net::url* Preferences::getContrastCssDir() +{ + return &mContrastCssDir; +} + +void Preferences::setUserCssFile(const ambulant::net::url* value) +{ + mUserCssFile = *value; +} + +const ambulant::net::url* Preferences::getUserCssFile() +{ + return &mUserCssFile; +} + +void Preferences::setZed2005CssFile(const ambulant::net::url* value) +{ + mZed2005CssFile = *value; +} + +const ambulant::net::url* Preferences::getZed2005CssFile() +{ + return &mZed2005CssFile; +} + +void Preferences::setSourceUrl(const ambulant::net::url* value) +{ + mSourceUrl = *value; +} + +const ambulant::net::url* Preferences::getSourceUrl() +{ + return &mSourceUrl; +} + +amis::UrlList* Preferences::getFontsizeCssFiles() +{ + return &mFontsizeCssFiles; +} + +amis::UrlList* Preferences::getContrastCssFiles() +{ + return &mContrastCssFiles; +} +amis::StringModuleMap* Preferences::getInstalledLanguages() +{ + return &mInstalledLanguages; +} + +amis::ModuleDescData* Preferences::getCurrentLanguageData() +{ + amis::ModuleDescData* p_data = mInstalledLanguages[mUiLangId]; + return p_data; +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-01-29 00:48:10 UTC (rev 2294) @@ -127,8 +127,8 @@ mbBookIsOpen = false; mAppPath = ""; - initPathsAndFiles(); - + initializePathsAndFiles(); + initializeSelfVoicing(); AfxEnableControlContainer(); #ifdef _AFXDLL @@ -232,7 +232,7 @@ return mAppPath; } -void CAmisApp::initPathsAndFiles() +void CAmisApp::initializePathsAndFiles() { //read the preferences amis::io::PreferencesFileIO prefs_io; @@ -247,26 +247,21 @@ amis::io::RecentBooksFileIO recent_books_io; if (recent_books_io.readFromFile(&the_book_path)) mpRecentBooks = recent_books_io.getRecentBooks(); else mpRecentBooks = NULL; +} - - //marisa removed this if-statement - //the self-voicing data should be ready to go whether or not self-voicing is turned on at the start - //the self-voicing data is also the dynamic localization data, so it is used all over the place - //maybe this needs to be changed someday and all strings must be duplicated in the RC file .. ? for now it's ok. - //if (amis::Preferences::Instance()->mbIsSelfVoicing == true) - //{ - //read in the new self-voicing/accessible UI data +void CAmisApp::initializeSelfVoicing() +{ DataReader new_data_reader; DataTree* p_new_data_tree; p_new_data_tree = DataTree::Instance(); - string tmpStr = amis::Preferences::Instance()->mCurrentLanguagePackDir; - tmpStr = amis::util::FilePathTools::goRelativePath(tmpStr, "amisAccessibleUi.xml"); - tmpStr = amis::util::FilePathTools::getAsLocalFilePath(tmpStr); + //a lang module file points to the moduleDescData.xml in the top-level directory of every langpack + const ambulant::net::url* lang_module_file = amis::Preferences::Instance()->getCurrentLanguageData()->getXmlFileName(); + ambulant::net::url lang_xml_file = ambulant::net::url::from_filename("amisAccessibleUi.xml"); + lang_xml_file = lang_xml_file.join_to_base(*lang_module_file); new_data_reader.setAppPath(mAppPath); + amis::ErrorCode did_it_work = new_data_reader.readFile(lang_xml_file.get_file(), p_new_data_tree); - amis::ErrorCode did_it_work = new_data_reader.readFile(tmpStr, p_new_data_tree); - if (did_it_work == amis::OK) { //test print to an output file @@ -290,10 +285,9 @@ //maybe we should try to load the default language pack here, and exit if that doesn't work. else { - amis::Preferences::Instance()->mbIsSelfVoicing = false; + amis::Preferences::Instance()->setIsSelfVoicing(false); } - //} - + } const ambulant::net::url& CAmisApp::getBookURL() const { @@ -311,7 +305,7 @@ //TODO: AMIS says "TITLE" Playing etc even if the book couldn't be opened MainWndParts::Instance()->updateTitleBar(MainWndParts::TITLEBAR_APPNAME, CString(L"Amis")); MainWndParts::Instance()->updateTitleViewMode(); - MainWndParts::Instance()->updateTitleSelfVoicing(Preferences::Instance()->mbIsSelfVoicing); + MainWndParts::Instance()->updateTitleSelfVoicing(Preferences::Instance()->getIsSelfVoicing()); bool b_a_book_was_open = false; @@ -324,10 +318,8 @@ if (!filename->is_empty_path()) { - //TODO: Doesn't this "temp" variable need to become something more durable ? (I have just fixed it with the User BMK dir) - very_temporary_bookmarks_dir = ambulant::net::url::from_filename(amis::Preferences::Instance()->mUserBmkDir); - - if (amis::dtb::DtbWithHooks::Instance()->open(filename, &very_temporary_bookmarks_dir)) + if (amis::dtb::DtbWithHooks::Instance()->open + (filename, amis::Preferences::Instance()->getUserBmkDir())) { mbBookIsOpen = true; amis::dtb::DtbWithHooks::Instance()->startReading(true); @@ -659,20 +651,20 @@ dialogs::PreferencesDialog prefs; if (prefs.do_modal() == IDOK) { - Preferences::Instance()->mbIsSelfVoicing = prefs.mbIsSelfVoicing; - Preferences::Instance()->mbPauseOnApplicationLostFocus = prefs.mbShouldPauseOnLostFocus; - Preferences::Instance()->mbStartBasicView = prefs.mbShouldStartInBasicView; - Preferences::Instance()->mbLoadLastBook = prefs.mbShouldLoadLastBookOnStartup; + Preferences::Instance()->setIsSelfVoicing(prefs.mbIsSelfVoicing); + Preferences::Instance()->setPauseOnLostFocus(prefs.mbPauseOnLostFocus); + Preferences::Instance()->setStartInBasicView(prefs.mbStartInBasicView); + Preferences::Instance()->setLoadLastBook(prefs.mbLoadLastBook); - if (prefs.mUiLanguageId != Preferences::Instance()->mUiLangId) + if (prefs.mUiLanguageSelection != Preferences::Instance()->getUiLangId()) { - Preferences::Instance()->mUiLangId = prefs.mUiLanguageId; + Preferences::Instance()->getUiLangId() = prefs.mUiLanguageSelection; //TODO: replace with real message from localized file AfxMessageBox(_T("Please restart to change the language of AMIS")); } amis::io::PreferencesFileIO prefs_io; - prefs_io.writeToFile(Preferences::Instance()->mSourceUrl.get_file(), Preferences::Instance()); + prefs_io.writeToFile(Preferences::Instance()->getSourceUrl()->get_file(), Preferences::Instance()); } } @@ -706,7 +698,7 @@ bool CAmisApp::beforeModalBox() { - if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + if (amis::Preferences::Instance()->getIsSelfVoicing() == true) { //AudioSequencePlayer::Instance()->Stop(); } @@ -723,7 +715,7 @@ } void CAmisApp::afterModalBox(bool b_was_playing) { - if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + if (amis::Preferences::Instance()->getIsSelfVoicing() == true) { AudioSequencePlayer::Instance()->Stop(); Modified: branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2008-01-29 00:48:10 UTC (rev 2294) @@ -319,7 +319,7 @@ } } #endif - TextRenderBrain::Instance()->highlightUriTarget(newurl); + TextRenderBrain::Instance()->gotoUriTarget(newurl); delete url; return 0; } @@ -602,7 +602,7 @@ return bRetVal; } -IHTMLStyleSheet* CAmisHtmlView::applyStylesheet(ambulant::net::url* stylesheet) +IHTMLStyleSheet* CAmisHtmlView::applyStylesheet(const ambulant::net::url* stylesheet) { USES_CONVERSION; Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-01-29 00:48:10 UTC (rev 2294) @@ -166,7 +166,7 @@ CFrameWnd::OnMenuSelect(nItemID, nFlags, hSysMenu); -if (amis::Preferences::Instance()->mbIsSelfVoicing == false) +if (amis::Preferences::Instance()->getIsSelfVoicing() == false) { return; } @@ -549,7 +549,7 @@ CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu); -if (amis::Preferences::Instance()->mbIsSelfVoicing == false) +if (amis::Preferences::Instance()->getIsSelfVoicing() == false) { return; } @@ -621,7 +621,7 @@ //m_OpenMenu = pMenu; CMDIFrameWnd::OnInitMenu(pMenu); -if (amis::Preferences::Instance()->mbIsSelfVoicing == false) +if (amis::Preferences::Instance()->getIsSelfVoicing() == false) { return; } @@ -668,7 +668,7 @@ { CMDIFrameWnd::OnEnterMenuLoop(bIsTrackPopupMenu); -if (amis::Preferences::Instance()->mbIsSelfVoicing == false) +if (amis::Preferences::Instance()->getIsSelfVoicing() == false) { return; } @@ -695,7 +695,7 @@ CMDIFrameWnd::OnExitMenuLoop(bIsTrackPopupMenu); -if (amis::Preferences::Instance()->mbIsSelfVoicing == false) +if (amis::Preferences::Instance()->getIsSelfVoicing() == false) { return; } @@ -719,7 +719,7 @@ BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) { - if (amis::Preferences::Instance()->mbIsSelfVoicing == true && + if (amis::Preferences::Instance()->getIsSelfVoicing() == true && (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP)) { CWnd* cwnd = this->GetFocus(); @@ -812,7 +812,7 @@ //TODO: focus lost detection doesn't work when a modal dialog is used on top of the main application window. // The consequence is that the book is stopped anyway because modal dialogs stop book audio by default, // and the dialog-related speech doesn't stop. - if (Preferences::Instance()->mbPauseOnApplicationLostFocus == true) + if (Preferences::Instance()->getPauseOnLostFocus() == true) { if ( nState == WA_INACTIVE ) { if ( ! AfxGetMainWnd()->IsChild(pWndOther) ) { @@ -834,7 +834,7 @@ view->OnFilePause(); //view->OnFilePlay(); -if (amis::Preferences::Instance()->mbIsSelfVoicing == true) +if (amis::Preferences::Instance()->getIsSelfVoicing() == true) { AudioSequencePlayer::Instance()->Stop(); } @@ -850,7 +850,7 @@ //view->OnFilePause(); view->OnFilePlay(); -if (amis::Preferences::Instance()->mbIsSelfVoicing == true) +if (amis::Preferences::Instance()->getIsSelfVoicing() == true) { AudioSequencePlayer::Instance()->RepeatLast(); } Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-01-29 00:48:10 UTC (rev 2294) @@ -39,14 +39,10 @@ TextRenderBrain* TextRenderBrain::Instance() { - if (pinstance == 0) // is it the first call? - { - pinstance = new TextRenderBrain; // create sole instance - } - return pinstance; // address of sole instance + if (pinstance == 0) pinstance = new TextRenderBrain; + return pinstance; } - void TextRenderBrain::DestroyInstance() { delete pinstance; @@ -57,21 +53,16 @@ mFontSize = 0; mbWaitForDocumentLoad = false; mbContrastOn = false; - pLastElm = NULL; + mpLastElm = NULL; VariantInit(&mUnhighlightedFG); VariantInit(&mUnhighlightedBG); - mCurrentUrl = ambulant::net::url(); + mCurrentUrl = ambulant::net::url(); - //TODO: replace with preferences CSS file list - string app_path = theApp.getAppPath(); - app_path += "/"; - mpFontCss = NULL; mpContrastCss = NULL; - mpDefaultCss = NULL; - + mpUserCss = NULL; } TextRenderBrain::~TextRenderBrain() @@ -81,19 +72,19 @@ /*if (mpFontCss) delete mpFontCss; if (mpContrastCss) delete mpContrastCss; - if (mpDefaultCss) delete mpDefaultCss; + if (mpUserCss) delete mpUserCss; */ //TODO: should delete variants too } -void TextRenderBrain::highlightUriTarget(amis::TextNode* pText) +void TextRenderBrain::gotoUriTarget(amis::TextNode* pText) { - highlightUriTarget(pText->getSrc()); + gotoUriTarget(pText->getSrc()); } //TODO: make sure this path comparison works for Japanese too -void TextRenderBrain::highlightUriTarget(std::string urlstr) +void TextRenderBrain::gotoUriTarget(std::string urlstr) { USES_CONVERSION; ambulant::net::url url = ambulant::net::url::from_url(urlstr); @@ -106,12 +97,12 @@ mTextElmId = ""; } - bool sameDoc = url.same_document(mCurrentUrl); + bool is_same_doc = url.same_document(mCurrentUrl); // If it's identical ignore it (the previous call may still be waiting for the webDocumentComplete callback) - if (sameDoc && text_elm_id == mTextElmId) return; + if (is_same_doc && text_elm_id == mTextElmId) return; // If it's a different document: load it. - if (!sameDoc) + if (!is_same_doc) { //save the current ID mTextElmId = text_elm_id; @@ -140,7 +131,7 @@ //save the current ID mTextElmId = text_elm_id; - highlightElementAtId(mTextElmId); + showElementAtId(mTextElmId); } } @@ -149,8 +140,9 @@ { if (mbWaitForDocumentLoad) { - mpDefaultCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&Preferences::Instance()->mDefaultCssFile); - scanStylesheetForAdditionalData(mpDefaultCss); + mpUserCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet + (Preferences::Instance()->getUserCssFile()); + scanStylesheetForAdditionalData(mpUserCss); MainWndParts::Instance()->mpHtmlView->RedrawWindow(); mbWaitForDocumentLoad = false; @@ -158,7 +150,7 @@ if (mFontSize > 0) setFontSize(mFontSize); if (mbContrastOn) htmlContrastOn(); - highlightElementAtId(mTextElmId); + showElementAtId(mTextElmId); } } @@ -206,15 +198,37 @@ } } -void TextRenderBrain::highlightElementAtId(string elm_id) +void TextRenderBrain::showElementAtId(string elmId) { - USES_CONVERSION; + if (elmId.size() == 0) return; + IHTMLElement* p_elm = NULL; + p_elm = GetElementFromId(elmId, 0); + if (p_elm == NULL) return; - if (elm_id.size() == 0) return; + //save the element text + //this is just a convenient place for this function call, since it minimizes DOM searching + saveElementText(p_elm); - IHTMLElement* pElm = NULL; - pElm = GetElementFromId(elm_id, 0); + //set background/foreground colors for the element + if (Preferences::Instance()->getHighlightText() == true) setHighlightColors(p_elm); + //scroll into view + if (isElementInView(p_elm) == false) + { + VARIANT v_bool; + v_bool.vt = VT_BOOL; + v_bool.boolVal = TRUE; + + p_elm->scrollIntoView(v_bool); + } + mpLastElm = p_elm; +} +void TextRenderBrain::setHighlightColors(IHTMLElement* pElm) +{ + USES_CONVERSION; + + if (pElm == NULL) return; + //save last-style data since we'll be replacing it before using it VARIANT copy_last_bg; VARIANT copy_last_fg; @@ -227,67 +241,48 @@ copy_last_bg.bstrVal = mUnhighlightedBG.bstrVal; copy_last_fg.bstrVal = mUnhighlightedFG.bstrVal; - if (pElm) - { - IHTMLStyle* pStyle = NULL; + IHTMLStyle* p_style = NULL; - //save the current style info before changing it - pElm->get_style(&pStyle); - pStyle->get_backgroundColor(&mUnhighlightedBG); - pStyle->get_color(&mUnhighlightedFG); + //save the current style info before changing it + pElm->get_style(&p_style); + p_style->get_backgroundColor(&mUnhighlightedBG); + p_style->get_color(&mUnhighlightedFG); - //save the element text - //this is just a convenient place for this function call, since it - //minimizes DOM searching (we've already had to find the correct element by id at this point, - //so why not grab the text while we're at it) - saveElementText(pElm); + //variables for the highlight colors + string str_text_fg, str_text_bg; + VARIANT var_bg; + VARIANT var_fg; - //variables for the highlight colors - string str_text_fg, str_text_bg; - VARIANT var_bg; - VARIANT var_fg; - - VariantInit(&var_bg); - VariantInit(&var_fg); + VariantInit(&var_bg); + VariantInit(&var_fg); - //get as strings from the preferences for highlight values - str_text_fg = amis::Preferences::Instance()->mHighlightFG.getAsHtmlHexColor(); - str_text_bg = amis::Preferences::Instance()->mHighlightBG.getAsHtmlHexColor(); + //get as strings from the preferences for highlight values + str_text_fg = amis::Preferences::Instance()->mHighlightFG.getAsHtmlHexColor(); + str_text_bg = amis::Preferences::Instance()->mHighlightBG.getAsHtmlHexColor(); - //convert to chars - const char* textfg_color = str_text_fg.c_str(); - const char* textbg_color = str_text_bg.c_str(); + //convert to chars + const char* textfg_color = str_text_fg.c_str(); + const char* textbg_color = str_text_bg.c_str(); - //convert to bstr/variant - var_fg.vt = VT_BSTR; - var_fg.bstrVal = A2BSTR(textfg_color); - var_bg.vt = VT_BSTR; - var_bg.bstrVal = A2BSTR(textbg_color); + //convert to bstr/variant + var_fg.vt = VT_BSTR; + var_fg.bstrVal = A2BSTR(textfg_color); + var_bg.vt = VT_BSTR; + var_bg.bstrVal = A2BSTR(textbg_color); - //set the properties - //this puts the preferred highlighting colors into pStyle - pStyle->put_backgroundColor(var_bg); - pStyle->put_color(var_fg); + //set the properties + //this puts the preferred highlighting colors into pStyle + p_style->put_backgroundColor(var_bg); + p_style->put_color(var_fg); - //reset the last highlighted element's style - if (pLastElm) - { - IHTMLStyle* pLastStyle = NULL; - pLastElm->get_style(&pLastStyle); - //set the properties - pLastStyle->put_backgroundColor(copy_last_bg); - pLastStyle->put_color(copy_last_fg); - } - - if (isElementInView(pElm) == false) - { - VARIANT v_bool; - v_bool.vt = VT_BOOL; - v_bool.boolVal = TRUE; - - pElm->scrollIntoView(v_bool); - } - pLastElm = pElm; + //reset the last highlighted element's style + if (mpLastElm != NULL) + { + IHTMLStyle* p_last_style = NULL; + mpLastElm->get_style(&p_last_style); + //set the properties + p_last_style->put_backgroundColor(copy_last_bg); + p_last_style->put_color(copy_last_fg); } } @@ -298,7 +293,7 @@ //turns the contrast on or off. returns the new state of the contrast (true = on) bool TextRenderBrain::toggleContrast() { -// MainWndParts::Instance()->mpSidebar->m_wndDlg.toggleContrast(); + //MainWndParts::Instance()->mpSidebar->m_wndDlg.toggleContrast(); if (mbContrastOn) htmlContrastOff(); else htmlContrastOn(); @@ -308,7 +303,9 @@ void TextRenderBrain::htmlContrastOn() { mbContrastOn = true; - mpContrastCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&Preferences::Instance()->mContrastCssFiles[0]); + amis::UrlList* list = Preferences::Instance()->getContrastCssFiles(); + ambulant::net::url url = (*list)[0]; + mpContrastCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&url); scanStylesheetForAdditionalData(mpContrastCss); } @@ -335,25 +332,25 @@ //1...4 = increasingly bigger void TextRenderBrain::setFontSize(int fontsz) { - if (fontsz > Preferences::Instance()->mFontsizeCssFiles.size() || fontsz < 1) fontsz = 0; + if (fontsz > Preferences::Instance()->getFontsizeCssFiles()->size() || fontsz < 1) fontsz = 0; mFontSize = fontsz; //remove the old stylesheet MainWndParts::Instance()->mpHtmlView->removeStylesheet(mpFontCss); ambulant::net::url* css_url = NULL; - if (fontsz > 0 && fontsz <= Preferences::Instance()->mFontsizeCssFiles.size()) + if (fontsz > 0 && fontsz <= Preferences::Instance()->getFontsizeCssFiles()->size()) { - css_url = &Preferences::Instance()->mFontsizeCssFiles[fontsz - 1]; + css_url = &(*Preferences::Instance()->getFontsizeCssFiles())[fontsz - 1]; mpFontCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(css_url); scanStylesheetForAdditionalData(mpFontCss); } - if (isElementInView(pLastElm) == false) + if (isElementInView(mpLastElm) == false) { VARIANT v_bool; v_bool.vt = VT_BOOL; v_bool.boolVal = TRUE; - pLastElm->scrollIntoView(v_bool); + mpLastElm->scrollIntoView(v_bool); } } @@ -438,7 +435,7 @@ if (disableContrast == false) { //TODO repaint the sidebar contrast -// MainWndParts::Instance()->mpSidebar->m_wndDlg.repaintContrast(); + //MainWndParts::Instance()->mpSidebar->m_wndDlg.repaintContrast(); //repaint the html view contrast if it had been enabled if (mbContrastOn) htmlContrastOn(); @@ -447,7 +444,7 @@ else { //TODO turn off the sidebar contrast -// MainWndParts::Instance()->mpSidebar->m_wndDlg.turnContrastOff(); + //MainWndParts::Instance()->mpSidebar->m_wndDlg.turnContrastOff(); //turn off the html view contrast htmlContrastOff(); @@ -462,10 +459,10 @@ IHTMLStyle* pStyle = NULL; - if (pLastElm != NULL) + if (mpLastElm != NULL) { //get a pointer to the style - pLastElm->get_style(&pStyle); + mpLastElm->get_style(&pStyle); //variables for the colors string str_text_fg, str_text_bg; @@ -500,6 +497,8 @@ //document which is being displayed, and decides if the element is visible or not bool TextRenderBrain::isElementInView(IHTMLElement* pElm) { + if (pElm == NULL) return false; + //the IHTMLELEMENT measurements long elm_width = 0; long elm_height = 0; Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisDialogBase.cpp 2008-01-29 00:48:10 UTC (rev 2294) @@ -33,14 +33,19 @@ BOOL AmisDialogBase::PreTranslateMessage(MSG* pMsg) { - if (Preferences::Instance()->mbIsSelfVoicing == false) { + if (Preferences::Instance()->getIsSelfVoicing() == false) + { return CDialog::PreTranslateMessage(pMsg); } if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) { - CWnd* cwnd = this->GetFocus(); - if (cwnd) mCommonPreTranslateMessageHandler->handle(true, NULL, pMsg, (cwnd == NULL ? -1 : cwnd->GetDlgCtrlID())); + CWnd* cwnd = this->GetFocus(); + if (cwnd) + { + mCommonPreTranslateMessageHandler->handle + (true, NULL, pMsg, (cwnd == NULL ? -1 : cwnd->GetDlgCtrlID())); + } } return CDialog::PreTranslateMessage(pMsg); @@ -49,7 +54,7 @@ INT_PTR AmisDialogBase::do_modal() { /* - if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + if (amis::Preferences::Instance()->getIsSelfVoicing() == true) { AudioSequencePlayer::Instance()->Stop(); } @@ -69,7 +74,7 @@ theApp.afterModalBox(b); /* - if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + if (amis::Preferences::Instance()->getIsSelfVoicing() == true) { AudioSequencePlayer::Instance()->Stop(); @@ -110,7 +115,7 @@ void AmisDialogBase::on_paint() { - if (amis::Preferences::Instance()->mbIsSelfVoicing == false) + if (amis::Preferences::Instance()->getIsSelfVoicing() == false) { mbFlag_FirstDraw = false; return; @@ -118,7 +123,7 @@ if(mbFlag_FirstDraw) { - if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + if (amis::Preferences::Instance()->getIsSelfVoicing() == true) { AudioSequencePlayer::playDialogTextControlsFromUiId(mId); } Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/AmisFileDialog.cpp 2008-01-29 00:48:10 UTC (rev 2294) @@ -47,7 +47,7 @@ bool b = amis::gui::CAmisApp::beforeModalBox(); -if (amis::Preferences::Instance()->mbIsSelfVoicing == true) + if (amis::Preferences::Instance()->getIsSelfVoicing() == true) { AudioSequencePlayer::playPromptFromStringId("OpenFile_notSelfVoicing"); } Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/SkipDialog.cpp 2008-01-29 00:48:10 UTC (rev 2294) @@ -43,7 +43,7 @@ : AmisDialogBase(SkipDialog::IDD) { - if (Preferences::Instance()->mbIsSelfVoicing == true) + if (Preferences::Instance()->getIsSelfVoicing() == true) { mpSkipDialogVoicing = new amis::gui::dialogs::SkipDialogVoicing(this); } @@ -53,7 +53,7 @@ SkipDialog::~SkipDialog() { - if (Preferences::Instance()->mbIsSelfVoicing == true) + if (Preferences::Instance()->getIsSelfVoicing() == true) { delete mpSkipDialogVoicing; } @@ -61,7 +61,7 @@ BOOL SkipDialog::PreTranslateMessage(MSG* pMsg) { - if (Preferences::Instance()->mbIsSelfVoicing == false) + if (Preferences::Instance()->getIsSelfVoicing() == false) { return CDialog::PreTranslateMessage(pMsg); } @@ -194,7 +194,7 @@ p_test = (amis::dtb::CustomTest*)m_ListSkips.GetItemData(i); if (p_test == NULL) return; - if (Preferences::Instance()->mbIsSelfVoicing == true) + if (Preferences::Instance()->getIsSelfVoicing() == true) { mpSkipDialogVoicing->OnSelchangeSkips(); } Modified: branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp 2008-01-28 06:18:04 UTC (rev 2293) +++ branches/amis3/AmisGuiMFC2/src/io/PreferencesFileIO.cpp 2008-01-29 00:48:10 UTC (rev 2294) @@ -72,8 +72,8 @@ { mpPrefs = Preferences::Instance(); ambulant::net::url tmp_url = ambulant::net::url::from_filename(filepath); - mpPrefs->mSourceUrl = tmp_url; - bool ret = parseFile(&mpPrefs->mSourceUrl); + mpPrefs->setSourceUrl(&tmp_url); + bool ret = parseFile(&tmp_url); if (ret) mpPrefs->scanAll(); return ret; } @@ -102,99 +102,105 @@ void PreferencesFileIO::addEntry(string id, string value) { + ambulant::net::url source_url = *(mpPrefs->getSourceUrl()); + if (id.compare("ui-lang-id") == 0) { - mpPrefs->mUiLangId = value; + mpPrefs->setUiLangId(value); } - else if (id.compare("start-basic") == 0) + else if (id.compare("start-in-basic-view") == 0) { if (value.compare("yes") == 0) - mpPrefs->mbStartBasicView = true; + mpPrefs->setStartInBasicView(true); else - mpPrefs->mbStartBasicView = false; + mpPrefs->setStartInBasicView(false); } else if (id.compare("load-last-book") == 0) { if (value.compare("yes") == 0) - mpPrefs->mbLoadLastBook = true; + mpPrefs->setLoadLastBook(true); else - mpPrefs->mbLoadLastBook = false; + mpPrefs->setLoadLastBook(false); } - else if (id.compare("self-voicing") == 0) + else if (id.compare("is-self-voicing") == 0) { if (value.compare("yes") == 0) - mpPrefs->mbIsSelfVoicing = true; + mpPrefs->setIsSelfVoicing(true); else - mpPrefs->mbIsSelfVoicing = false; + mpPrefs->setIsSelfVoicing(false); } - + else if (id.compare("highlight-text") == 0) + { + if (value.compare("yes") == 0) + mpPrefs->setHighlightText(true); + else + mpPrefs->setHighlightText(false); + } else if (id.compare("use-tts-not-audio") == 0) { if (value.compare("yes") == 0) - mpPrefs->mbUseTTSNotAudio = true; + mpPrefs->setUseTTSNotAudio(true); else - mpPrefs->mbUseTTSNotAudio = false; + mpPrefs->setUseTTSNotAudio(false); } - else if (id.compare("tts-voice") == 0) + else if (id.compare("tts-voice-index") == 0) { int voice; voice = atoi(value.c_str()); - mpPrefs->mTTSVoice = voice; + mpPrefs->setTTSVoiceIndex(voice); } - else if (id.compare("pause-lost-focus") == 0) + else if (id.compare("pause-on-lost-focus") == 0) { if (value.compare("yes") == 0) - mpPrefs->mbPauseOnApplicationLostFocus = true; + mpPrefs->setPauseOnLostFocus(true); else - mpPrefs->mbPauseOnApplicationLostFocus = false; + mpPrefs->setPauseOnLostFocus(false); } - else if (id.compare("exit-was-clean") == 0) + else if (id.compare("was-exit-clean") == 0) { if (value.compare("yes") == 0) - mpPrefs->mbExitWasClean = true; + mpPrefs->setWasExitClean(true); else - mpPrefs->mbExitWasClean = false; + mpPrefs->setWasExitClean(false); } - else if (id.compare("default-stylesheet") == 0) + else if (id.compare("user-css-file") == 0) { - ambulant::net::url css_file = ambulant::net::url::from_filename(value); - mpPrefs->mDefaultCssFile = css_file.join_to_base(*&mpPrefs->mSourceUrl); + ambulant::net::url file = ambulant::net::url::from_filename(value); + file = file.join_to_base(source_url); + mpPrefs->setUserCssFile(&file); } - else if (id.compare("zed-2005-stylesheet") == 0) + else if (id.compare("zed-2005-css-file") == 0) { - ambulant::net::url css_file = ambulant::net::url::from_filename(value); - mpPrefs->mZed2005CssFile = css_file.join_to_base(*&mpPrefs->mSourceUrl); + ambulant::net::url file = ambulant::net::url::from_filename(value); + file = file.join_to_base(source_url); + mpPrefs->setZed2005CssFile(&file); } - //Directories - else if (id.compare("ui-lang-dir") == 0) + else if (id.compare("langpacks-dir") == 0) { - //TODO - //upgrade to ambulant url? - string strFileName = mpPrefs->mSourceUrl.get_file(); - mpPrefs->mUiLangDir = amis::util::FilePathTools::goRelativePath(strFileName, value); + ambulant::net::url file = ambulant::net::url::from_filename(value); + file = file.join_to_base(source_url); + mpPrefs->setLangpacksDir(&file); } - - else if (id.compare("fontsize-stylesheets-dir") == 0) + else if (id.compare("fontsize-css-dir") == 0) { - //TODO - //upgrade to ambulant url? - mpPrefs->mFontsizeCssDir = amis::util::FilePathTools::goRelativePath(mpPrefs->mSourceUrl.get_file(), value); + ambulant::net::url file = ambulant::net::url::from_filename(value); + file = file.join_to_base(source_url); + mpPrefs->setFontsizeCssDir(&file); } - else if (id.compare("contrast-stylesheets-dir") == 0) + else if (id.compare("contrast-css-dir") == 0) { - //TODO - //upgrade to ambulant url? - mpPrefs->mContrastCssDir = amis::util::FilePathTools::goRelativePath(mpPrefs->mSourceUrl.get_file(), value); + ambulant::net::url file = ambulant::net::url::from_filename(value); + file = file.join_to_base(source_url); + mpPrefs->setContrastCssDir(&file); } else if (id.compare("user-bmk-dir") == 0) { - //TODO - //upgrade to ambulant url? - string strFileName = mpPrefs->mSourceUrl.get_file(); - mpPrefs->mUserBmkDir = amis::util::FilePathTools::goRelativePath(strFileName, value); + ambulant::net::url file = ambulant::net::url::from_filename(value); + file = file.join_to_base(source_url); + mpPrefs->setUserBmkDir(&file); } } @@ -265,51 +271,54 @@ pGeneralSection = mpDoc->createElement(X("section")); pGeneralSection->setAttribute(X("name"), X("general")); - pEntry = createEntry("ui-lang-id", mpPrefs->mUiLangId); + pEntry = createEntry("ui-lang-id", mpPrefs->getUiLangId()); pGeneralSection->appendChild((DOMNode*)pEntry); - pEntry = createEntry("start-basic", mpPrefs->mbStartBasicView); + pEntry = createEntry("start-in-basic-view", mpPrefs->getStartInBasicView()); pGeneralSection->appendChild((DOMNode*)pEntry); - pEntry = createEntry("load-last-book", mpPrefs->mbLoadLastBook); + pEntry = createEntry("load-last-book", mpPrefs->getLoadLastBook()); pGeneralSection->appendChild((DOMNode*)pEntry); - pEntry = createEntry("self-voicing", mpPrefs->mbIsSelfVoicing); + pEntry = createEntry("is-self-voicing", mpPrefs->getIsSelfVoicing()); pGeneralSection->appendChild((DOMNode*)pEntry); + + pEntry = createEntry("highlight-text", mpPrefs->getHighlightText()); + pGeneralSection->appendChild((DOMNode*)pEntry); std::string voice; char buff[5]; - itoa(mpPrefs->mTTSVoice, buff, 10); + itoa(mpPrefs->getTTSVoiceIndex(), buff, 10); voice.assign(buff); - pEntry = createEntry("tts-voice", voice); + pEntry = createEntry("tts-voice-index", voice); pGeneralSection->appendChild((DOMNode*)pEntry); - pEntry = createEntry("pause-lost-focus", mpPrefs->mbPauseOnApplicationLostFocus); + pEntry = createEntry("pause-on-lost-focus", mpPrefs->getPauseOnLostFocus()); pGeneralSection->appendChild((DOMNode*)pEntry); - pEntry = createEntry("use-tts-not-audio", mpPrefs->mbUseTTSNotAudio); + pEntry = createEntry("use-tts-not-audio", mpPrefs->getUseTTSNotAudio()); pGeneralSection->appendChild((DOMNode*)pEntry); - pEntry = createEntry("exit-was-clean", mpPrefs->mbExitWasClean); + pEntry = createEntry("was-exit-clean", mpPrefs->getWasExitClean()); pGeneralSection->appendChild((DOMNode*)pEntry); - pEntry = createEntry("default-stylesheet", mpPrefs->mDefaultCssFile.get_file()); + pEntry = createEntry("user-css-file", mpPrefs->getUserCssFile()->get_file()); pGeneralSection->appendChild((DOMNode*)pEntry); - pEntry = createEntry("zed-2005-stylesheet", mpPrefs->mZed2005CssFile.get_file()); + pEntry = createEntry("zed-2005-css-file", mpPrefs->getZed2005CssFile()->get_file()); pGeneralSection->appendChild((DOMNode*)pEntry); //Directories - pEntry = createEntry("ui-lang-dir", mpPrefs->mUiLangDir); + pEntry = createEntry("langpacks-dir", mpPrefs->getLangpacksDir()->get_file()); pGeneralSection->appendChild((DOMNode*)pEntry); - pEntry = createEntry("user-bmk-dir", mpPrefs->mUserBmkDir); + pEntry = createEntry("user-bmk-dir", mpPrefs->getUserBmkDir()->get_file()); pGeneralSection->appendChild((DOMNode*)pEntry); - pEntry = createEntry("fontsize-stylesheets-dir", mpPrefs->mFontsizeCssDir); + pEntry = createEntry("fontsize-css-dir", mpPrefs->getFontsizeCssD... [truncated message content] |
From: <mar...@us...> - 2008-02-01 01:20:07
|
Revision: 2302 http://amis.svn.sourceforge.net/amis/?rev=2302&view=rev Author: marisademeglio Date: 2008-01-31 17:20:08 -0800 (Thu, 31 Jan 2008) Log Message: ----------- Started PublicationSummaryDialog Modified Metadata so that it can support multiple entries for one metadata name (e.g. many dc:creator tags to list many authors) Modified Paths: -------------- branches/amis3/AmisCore/include/dtb/Dtb.h branches/amis3/AmisCore/include/dtb/Metadata.h branches/amis3/AmisCore/include/io/NccFileReader.h branches/amis3/AmisCore/include/io/OpfFileReader.h branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisCore/src/dtb/Metadata.cpp branches/amis3/AmisCore/src/io/NccFileReader.cpp branches/amis3/AmisCore/src/io/OpfFileReader.cpp branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/resource.h Added Paths: ----------- branches/amis3/AmisGuiMFC2/include/gui/dialogs/PublicationSummaryDialog.h branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp Modified: branches/amis3/AmisCore/include/dtb/Dtb.h =================================================================== --- branches/amis3/AmisCore/include/dtb/Dtb.h 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/include/dtb/Dtb.h 2008-02-01 01:20:08 UTC (rev 2302) @@ -38,7 +38,7 @@ namespace dtb { typedef bool (*ProtectedBookKeyHandlerFunctionPtr)(const ambulant::net::url*, const ambulant::net::url*); - +enum DaisyVersion {UNDEFINED, DAISY_202, ZED_2002, ZED_2005}; class Dtb { public: @@ -73,7 +73,7 @@ void setNewLastmark(ambulant::net::url); ambulant::net::url calculateUriOfData(amis::dtb::smil::SmilMediaGroup*); - int getDaisyVersion(); + amis::dtb::DaisyVersion getDaisyVersion(); bool isProtected(); void setCallbackForPreprocessingBookKey(ProtectedBookKeyHandlerFunctionPtr); @@ -105,7 +105,7 @@ string mLastSearchResult; string mLastSearchedTextFile; amis::util::SearchForFiles* mpFileSearcher; - int mDaisyVersion; + amis::dtb::DaisyVersion mDaisyVersion; bool mbIsProtected; ProtectedBookKeyHandlerFunctionPtr mpCallbackForPreprocessingBookKey; }; Modified: branches/amis3/AmisCore/include/dtb/Metadata.h =================================================================== --- branches/amis3/AmisCore/include/dtb/Metadata.h 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/include/dtb/Metadata.h 2008-02-01 01:20:08 UTC (rev 2302) @@ -48,9 +48,9 @@ ~Metadata(); //!get a metadata item - wstring getMetadata(string); + wstring getMetadataContent(string); + MetaItem* getMetadata(string); void addMetadata(MetaItem*); - MetaItem* getLastAdded(); private: void clearVector(); Modified: branches/amis3/AmisCore/include/io/NccFileReader.h =================================================================== --- branches/amis3/AmisCore/include/io/NccFileReader.h 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/include/io/NccFileReader.h 2008-02-01 01:20:08 UTC (rev 2302) @@ -72,6 +72,7 @@ bool mbFlag_ProcessMetadataChars; amis::dtb::Metadata* mpMetadata; + amis::dtb::MetaItem* mpCurrentMetaItem; Modified: branches/amis3/AmisCore/include/io/OpfFileReader.h =================================================================== --- branches/amis3/AmisCore/include/io/OpfFileReader.h 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/include/io/OpfFileReader.h 2008-02-01 01:20:08 UTC (rev 2302) @@ -86,6 +86,8 @@ StdStringList mItemRefs; //the input filename const ambulant::net::url* mpFilename; + //temporary metadata item + amis::dtb::MetaItem* mpCurrentMetaItem; }; } } Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2008-02-01 01:20:08 UTC (rev 2302) @@ -51,7 +51,7 @@ mpCustomTests = NULL; mpFileSearcher = NULL; mUid.erase(); - mDaisyVersion = 0; + mDaisyVersion = UNDEFINED; mpCallbackForPreprocessingBookKey = NULL; } //destructor @@ -99,7 +99,7 @@ mpTextSmilMap = NULL; mpCustomTests = NULL; mUid.erase(); - mDaisyVersion = 0; + mDaisyVersion = UNDEFINED; } amis::MediaGroup* amis::dtb::Dtb::getTitle() @@ -169,7 +169,7 @@ if (DtbFileSet::isNccFile(fileUrl)) { - mDaisyVersion = 2; + mDaisyVersion = DAISY_202; if (!processNcc(mpFiles->getNavFilepath())) { return false; @@ -177,7 +177,8 @@ } else if (DtbFileSet::isOpfFile(fileUrl)) { - mDaisyVersion = 3; + //TODO: differentiate between 2005 and 2002 + mDaisyVersion = ZED_2005; if (!processOpf(mpFiles->getOpfFilepath())) return false; if (!processNcx(mpFiles->getNavFilepath())) return false; @@ -185,7 +186,7 @@ } else { - mDaisyVersion = 0; + mDaisyVersion = UNDEFINED; //TODO: flag not supported return false; } @@ -281,12 +282,12 @@ mUid = getUid(); mpTitle = new amis::MediaGroup(); amis::TextNode* p_title_text = new amis::TextNode(); - p_title_text->setTextString(mpMetadata->getMetadata("dc:title")); + p_title_text->setTextString(mpMetadata->getMetadataContent("dc:title")); mpTitle->setText(p_title_text); mpAuthor = new amis::MediaGroup(); amis::TextNode* p_author_text = new amis::TextNode(); - p_author_text->setTextString(mpMetadata->getMetadata("dc:creator")); + p_author_text->setTextString(mpMetadata->getMetadataContent("dc:creator")); mpAuthor->setText(p_author_text); //TODO: get the audio for the title (author audio not available in Daisy 202) @@ -351,12 +352,12 @@ if (mpMetadata == NULL) return 0; - wstring w_uid = mpMetadata->getMetadata("dc:Identifier"); + wstring w_uid = mpMetadata->getMetadataContent("dc:Identifier"); if (w_uid.size() == 0) - w_uid = mpMetadata->getMetadata("dc:identifier"); + w_uid = mpMetadata->getMetadataContent("dc:identifier"); if (w_uid.size() == 0) - w_uid = mpMetadata->getMetadata("ncc:identifier"); + w_uid = mpMetadata->getMetadataContent("ncc:identifier"); return w_uid; } @@ -639,7 +640,7 @@ return fullpath; } -int amis::dtb::Dtb::getDaisyVersion() +amis::dtb::DaisyVersion amis::dtb::Dtb::getDaisyVersion() { return mDaisyVersion; } @@ -687,9 +688,9 @@ if (!pMetadata) return false; //metadata uses wide strings - std::wstring w_version = pMetadata->getMetadata("prod:pdtb-version"); - std::wstring w_key = pMetadata->getMetadata("prod:pdtb-bookKey"); - std::wstring w_ncc = pMetadata->getMetadata("prod:pdtb-nccFile"); + std::wstring w_version = pMetadata->getMetadataContent("prod:pdtb-version"); + std::wstring w_key = pMetadata->getMetadataContent("prod:pdtb-bookKey"); + std::wstring w_ncc = pMetadata->getMetadataContent("prod:pdtb-nccFile"); #if defined(AMIS_COMPILER_MSVC) std::string s_version = T2A(w_version.c_str()); Modified: branches/amis3/AmisCore/src/dtb/Metadata.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Metadata.cpp 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/src/dtb/Metadata.cpp 2008-02-01 01:20:08 UTC (rev 2302) @@ -24,6 +24,7 @@ #include <string> #include <iostream> +#include <algorithm> #include "util/FilePathTools.h" using namespace std; @@ -38,17 +39,30 @@ clearVector(); } -wstring amis::dtb::Metadata::getMetadata(string metaname) +//This is case-insensitive +amis::dtb::MetaItem* amis::dtb::Metadata::getMetadata(string metaname) { - wstring return_value; for (int i = 0; i<mMetaList.size(); i++) { - if (mMetaList[i]->mName.compare(metaname) == 0) + //convert to lowercase first + std::string name1 = metaname; + std::string name2 = mMetaList[i]->mName; + std::transform(name1.begin(), name1.end(), name1.begin(), (int(*)(int))tolower); + std::transform(name2.begin(), name2.end(), name2.begin(), (int(*)(int))tolower); + + if (name1.compare(name2) == 0) { - return_value.assign(mMetaList[i]->mContent); - break; + return mMetaList[i]; } } + return NULL; +} + +wstring amis::dtb::Metadata::getMetadataContent(string metaname) +{ + wstring return_value; + MetaItem* p_item = getMetadata(metaname); + if (p_item != NULL) return_value = p_item->mContent; return return_value; } @@ -57,14 +71,6 @@ mMetaList.push_back(pNewItem); } -amis::dtb::MetaItem* amis::dtb::Metadata::getLastAdded() -{ - if (mMetaList.size() > 0) - return mMetaList.back(); - else - return NULL; -} - //delete all metaitem objects in the list of metadata void amis::dtb::Metadata::clearVector() { Modified: branches/amis3/AmisCore/src/io/NccFileReader.cpp =================================================================== --- branches/amis3/AmisCore/src/io/NccFileReader.cpp 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/src/io/NccFileReader.cpp 2008-02-01 01:20:08 UTC (rev 2302) @@ -31,6 +31,7 @@ amis::io::NccFileReader::NccFileReader() { mpMetadata = NULL; + mpCurrentMetaItem = NULL; } amis::io::NccFileReader::~NccFileReader() @@ -112,19 +113,30 @@ const XMLCh* const localname, const XMLCh* const qname) { - //local variable char* element_name = XMLString::transcode(qname); - - if (strcmp(element_name, "a") == 0) - { - mbFlag_GetChars = false; - } - string tmpstr; tmpstr.assign(element_name); - if (tmpstr.substr(0, 3).compare("dc:") == 0) + if (tmpstr.substr(0, 3).compare("dc:") == 0 || tmpstr.compare("meta") == 0) + { + if (mbFlag_ProcessMetadataChars == true && mpCurrentMetaItem != NULL) + { + //if the meta item has content already, add to it + //this is because some metadata names might appear more than once, like several authors + //we don't need to provide atomic navigation for each, so just list them like "A, B, C, ..." + if (mpCurrentMetaItem->mContent.size() > 0) + { + mpCurrentMetaItem->mContent.append(L", "); + mpCurrentMetaItem->mContent.append(mTempChars); + } + else + { + mpCurrentMetaItem->mContent.assign(mTempChars); + } + } mbFlag_ProcessMetadataChars = false; - + } + + if (strcmp(element_name, "a") == 0) mbFlag_GetChars = false; XMLString::release(&element_name); } @@ -133,14 +145,9 @@ if (mbFlag_GetChars == true) { mTempChars.append((wchar_t*)chars); - - if (mbFlag_ProcessMetadataChars == true) + //process metadata characters at endElement because the value of mContent might need to be appended + if (mbFlag_ProcessMetadataChars == false) { - if (mpMetadata->getLastAdded() != NULL) - mpMetadata->getLastAdded()->mContent.assign(mTempChars); - } - else - { amis::MediaGroup* p_media_label; if (mListType == 0) @@ -345,25 +352,35 @@ void amis::io::NccFileReader::processMetadata(string tagname, const Attributes* pAttrs) { - amis::dtb::MetaItem* p_meta_item = new amis::dtb::MetaItem(); + amis::dtb::MetaItem* p_meta_item = NULL; //it's a dublin core if (tagname.substr(0, 3).compare("dc:") == 0) { - p_meta_item->mName.assign(tagname); mbFlag_GetChars = true; mbFlag_ProcessMetadataChars = true; + //account for dc:creator already existing - we might just append content to it + if (tagname == "dc:creator" && mpMetadata->getMetadata("dc:creator") != NULL) + { + p_meta_item = mpMetadata->getMetadata("dc:creator"); + } + else + { + p_meta_item = new amis::dtb::MetaItem(); + p_meta_item->mName.assign(tagname); + } } //it's just a plain "meta" else { + p_meta_item = new amis::dtb::MetaItem(); mbFlag_GetChars = false; string meta_name = SimpleAttrs::get("name", pAttrs); wstring meta_content = SimpleAttrs::getw("content", pAttrs); p_meta_item->mName.assign(meta_name); p_meta_item->mContent = meta_content; } - + mpCurrentMetaItem = p_meta_item; mpMetadata->addMetadata(p_meta_item); } Modified: branches/amis3/AmisCore/src/io/OpfFileReader.cpp =================================================================== --- branches/amis3/AmisCore/src/io/OpfFileReader.cpp 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/src/io/OpfFileReader.cpp 2008-02-01 01:20:08 UTC (rev 2302) @@ -124,7 +124,7 @@ mTextFilename = temp.join_to_base(*mpFilename); } //add the smil files to the manifest list - //text/sml hack for bookshare books + //the media type "text/sml" is used in bookshare books else if ((media_type == "application/smil" || media_type == "text/sml") && id.size() > 0) { string filename = SimpleAttrs::get("href", &attributes); @@ -141,21 +141,34 @@ else if (node_name.compare("meta") == 0 || node_name.substr(0, 3).compare("dc:") == 0) { - amis::dtb::MetaItem* p_meta = new amis::dtb::MetaItem(); - + amis::dtb::MetaItem* p_meta_item = NULL; + //just a plain "meta" tag with all data in attributes if (node_name.compare("meta") == 0) { - p_meta->mName.assign(SimpleAttrs::get("name", &attributes)); + mbFlag_GetChars = false; + p_meta_item = new amis::dtb::MetaItem(); + string meta_name = SimpleAttrs::get("name", &attributes); + wstring meta_content = SimpleAttrs::getw("content", &attributes); + p_meta_item->mName.assign(meta_name); + p_meta_item->mContent = meta_content; } + //it's a dublin core (with character data) else { - p_meta->mName.assign(node_name); + mbFlag_GetChars = true; + if (node_name == "dc:Creator" && mpMetadata->getMetadata("dc:creator") != NULL) + { + p_meta_item = mpMetadata->getMetadata("dc:creator"); + } + else + { + p_meta_item = new amis::dtb::MetaItem(); + p_meta_item->mName.assign(node_name); + } } - - mpMetadata->addMetadata(p_meta); - + mpCurrentMetaItem = p_meta_item; + mpMetadata->addMetadata(p_meta_item); mTempChars.erase(); - mbFlag_GetChars = true; } } @@ -170,9 +183,17 @@ XMLString::release(&element_name); if (node_name.substr(0, 3).compare("dc:") == 0 || - node_name.compare("meta") == 0) + node_name.compare("meta") == 0 && mpCurrentMetaItem != NULL) { - mbFlag_GetChars = false; + if (mpCurrentMetaItem->mContent.size() > 0) + { + mpCurrentMetaItem->mContent.append(L", "); + mpCurrentMetaItem->mContent.append(mTempChars); + } + else + { + mpCurrentMetaItem->mContent.assign(mTempChars); + } } else if (node_name.compare("manifest") == 0) { @@ -186,13 +207,7 @@ void amis::io::OpfFileReader::characters(const XMLCh *const chars, const unsigned int length) { - if (mbFlag_GetChars == true) - { - mTempChars.append((wchar_t*)chars); - - if (mpMetadata->getLastAdded() != NULL) - mpMetadata->getLastAdded()->mContent.assign(mTempChars); - } + if (mbFlag_GetChars == true) mTempChars.append((wchar_t*)chars); } void amis::io::OpfFileReader::sortSpine() Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-02-01 01:20:08 UTC (rev 2302) @@ -120,7 +120,7 @@ BOTTOMMARGIN, 90 END - IDD_PUBLICATIONINFO, DIALOG + IDD_PUBLICATIONSUMMARY, DIALOG BEGIN LEFTMARGIN, 6 RIGHTMARGIN, 393 @@ -222,10 +222,7 @@ POPUP "&Info" BEGIN MENUITEM "&Reading Options...", ID_MENU_INFO_SKIP - MENUITEM SEPARATOR - MENUITEM "&Full Summary", ID_MENU_INFO_SUMMARY - MENUITEM "&Current Position", ID_MENU_INFO_CURRENTPOSITION - MENUITEM "&Navigation Options", ID_MENU_INFO_NAVOPTIONS + MENUITEM "&Publication Summary", ID_PUBLICATION_SUMMARY END POPUP "&Help" BEGIN @@ -340,7 +337,7 @@ DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP END -IDD_PUBLICATIONINFO DIALOGEX 0, 0, 400, 278 +IDD_PUBLICATIONSUMMARY DIALOGEX 0, 0, 400, 278 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Publication Summary" FONT 8, "MS Sans Serif", 0, 0, 0x0 Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2008-02-01 01:20:08 UTC (rev 2302) @@ -227,6 +227,9 @@ RelativePath=".\include\gui\dialogs\PreferencesDialog.h"> </File> <File + RelativePath=".\include\gui\dialogs\PublicationSummaryDialog.h"> + </File> + <File RelativePath=".\include\gui\dialogs\SearchForBooksDialog.h"> </File> <File @@ -521,6 +524,9 @@ RelativePath=".\src\gui\dialogs\PreferencesDialog.cpp"> </File> <File + RelativePath=".\src\gui\dialogs\PublicationSummaryDialog.cpp"> + </File> + <File RelativePath=".\src\gui\dialogs\SearchForBooksDialog.cpp"> </File> <File Added: branches/amis3/AmisGuiMFC2/include/gui/dialogs/PublicationSummaryDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/PublicationSummaryDialog.h (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/PublicationSummaryDialog.h 2008-02-01 01:20:08 UTC (rev 2302) @@ -0,0 +1,72 @@ +/* +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 +*/ +#ifndef PUBLICATIONSUMMARY_H +#define PUBLICATIONSUMMARY_H + +#include "gui/dialogs/AmisDialogBase.h" +#include "../resource.h" +#include "AmisCore.h" +#include "Media.h" + +namespace amis +{ +namespace gui +{ +namespace dialogs +{ +class PublicationSummaryDialog : public AmisDialogBase +{ +public: + PublicationSummaryDialog(CWnd* pParent = NULL); + ~PublicationSummaryDialog(); + virtual BOOL PreTranslateMessage(MSG*); + enum { IDD = IDD_PUBLICATIONSUMMARY }; + //call this first + void setBook(amis::dtb::Dtb*); + +protected: + virtual BOOL OnInitDialog(); + afx_msg void OnPaint(); + virtual void DoDataExchange(CDataExchange*); + DECLARE_MESSAGE_MAP() + +private: + amis::dtb::Dtb* mpBook; + amis::MediaGroup* mpTitle; + wstring mCreator; + string mCurrentPage; + int mTotalPages; + wstring mCurrentTimestamp; + string mTimeRemaining; + amis::MediaGroup* mpSectionName; + int mNumSubsections; + int mNumPages; + wstring mTotalTime; + wstring mPublisher; + wstring mDescription; + wstring mDate; + wstring mFormat; +}; +} +} +} +#endif Modified: branches/amis3/AmisGuiMFC2/resource.h =================================================================== --- branches/amis3/AmisGuiMFC2/resource.h 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisGuiMFC2/resource.h 2008-02-01 01:20:08 UTC (rev 2302) @@ -28,6 +28,7 @@ #define IDD_CDSEARCH 181 #define IDD_FULLSUMMARY 182 #define IDD_PUBLICATIONINFO 182 +#define IDD_PUBLICATIONSUMMARY 182 #define IDI_LANGICON 185 #define IDD_PROPPAGE3 185 #define IDB_BOOKSHELFMAG 186 @@ -50,7 +51,6 @@ #define IDC_LIST_PAGE 1015 #define IDC_TTSVOICE 1020 #define IDC_TTSVOICES 1020 -#define IDC_TTSVOICES2 1021 #define IDC_BTN_RESETCOLORS 1028 #define IDC_STARTSEARCH 1030 #define IDC_BTN_TEXTFG 1030 @@ -151,6 +151,7 @@ #define ID_MENU_PLAYPAUSE 32865 #define ID_MENU_FILE_OPENFROMURL 32870 #define ID_MENU_FILE_CLOSE 32871 +#define ID_PUBLICATION_SUMMARY 32875 #define IDS_NOSKIP 61245 #define IDS_SELFOLDER_TITLE 61258 #define IDS_SELFOLDER_INSTR 61259 @@ -165,7 +166,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 192 -#define _APS_NEXT_COMMAND_VALUE 32875 +#define _APS_NEXT_COMMAND_VALUE 32876 #define _APS_NEXT_CONTROL_VALUE 1098 #define _APS_NEXT_SYMED_VALUE 141 #endif Added: branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp 2008-02-01 01:20:08 UTC (rev 2302) @@ -0,0 +1,110 @@ +/* +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/PublicationSummaryDialog.h" +#include "../resource.h" +#include "AmisCore.h" +#include "dtb/Dtb.h" +#include "Media.h" + +using namespace amis::gui::dialogs; + +BEGIN_MESSAGE_MAP(PublicationSummaryDialog, CDialog) + ON_WM_KEYUP() + ON_WM_KEYDOWN() + ON_WM_PAINT() +END_MESSAGE_MAP() + +PublicationSummaryDialog::PublicationSummaryDialog(CWnd* pParent /*=NULL*/) + : AmisDialogBase(PublicationSummaryDialog::IDD) +{ +} + +PublicationSummaryDialog::~PublicationSummaryDialog() +{ +} + +void PublicationSummaryDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} +BOOL PublicationSummaryDialog::OnInitDialog() +{ + return CDialog::OnInitDialog(); +} + +void PublicationSummaryDialog::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 PublicationSummaryDialog::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); +} + +void PublicationSummaryDialog::setBook(amis::dtb::Dtb* pBook) +{ + mpBook = pBook; + amis::dtb::Metadata* p_meta = mpBook->getMetadata(); + amis::dtb::DaisyVersion version = mpBook->getDaisyVersion(); + + mpTitle = mpBook->getTitle(); + mCreator = p_meta->getMetadataContent("dc:creator"); + + if (version == amis::dtb::DAISY_202) + mTotalTime = p_meta->getMetadataContent("ncc:totalTime"); + else if (version == amis::dtb::ZED_2002 || version == amis::dtb::ZED_2005) + mTotalTime = p_meta->getMetadataContent("dtb:totalTime"); + + mPublisher = p_meta->getMetadataContent("dc:Publisher"); + mDescription = p_meta->getMetadataContent("dc:Description"); + mDate = p_meta->getMetadataContent("dc:Date"); + + mFormat = p_meta->getMetadataContent("dc:Format"); + //also check for the deprecated "ncc:format" + if (mFormat.size() == 0 && version == amis::dtb::DAISY_202) + mFormat = p_meta->getMetadataContent("ncc:format"); + + +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-02-02 06:23:40
|
Revision: 2303 http://amis.svn.sourceforge.net/amis/?rev=2303&view=rev Author: marisademeglio Date: 2008-02-01 22:23:44 -0800 (Fri, 01 Feb 2008) Log Message: ----------- PublicationSummaryDialog works. Bug in getting section name for Zed books. Modified Paths: -------------- branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisCore/src/dtb/nav/PageList.cpp branches/amis3/AmisCore/src/io/OpfFileReader.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/include/gui/MmView.h branches/amis3/AmisGuiMFC2/include/gui/dialogs/PublicationSummaryDialog.h branches/amis3/AmisGuiMFC2/resource.h branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2008-02-02 06:23:44 UTC (rev 2303) @@ -328,6 +328,18 @@ mpSpine = opf_file_reader.getSpine(); mpMetadata = opf_file_reader.getMetadata(); + //fill in the text for the title and the author + mUid = getUid(); + mpTitle = new amis::MediaGroup(); + amis::TextNode* p_title_text = new amis::TextNode(); + p_title_text->setTextString(mpMetadata->getMetadataContent("dc:Title")); + mpTitle->setText(p_title_text); + + mpAuthor = new amis::MediaGroup(); + amis::TextNode* p_author_text = new amis::TextNode(); + p_author_text->setTextString(mpMetadata->getMetadataContent("dc:Creator")); + mpAuthor->setText(p_author_text); + const ambulant::net::url* navfile = opf_file_reader.getNavFilename(); const ambulant::net::url* resfile = opf_file_reader.getResourceFilename(); const ambulant::net::url* txtfile = opf_file_reader.getTextFilename(); Modified: branches/amis3/AmisCore/src/dtb/nav/PageList.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/nav/PageList.cpp 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisCore/src/dtb/nav/PageList.cpp 2008-02-02 06:23:44 UTC (rev 2303) @@ -49,14 +49,19 @@ } +//start and end are playorder values; use end=-1 for the end of a set int amis::dtb::nav::PageList::countPagesInRange(int start, int end) { int page_count = 0; for (unsigned int i=0; i<this->getLength(); i++) { - if (this->getAtIndex(i)->getPlayOrder() >= start && this->getAtIndex(i)->getPlayOrder() < end) + int play_order = getAtIndex(i)->getPlayOrder(); + if (end != -1 && play_order >= start && play_order < end) page_count++; + else if (end == -1 && play_order >= start) + page_count++; + } return page_count; Modified: branches/amis3/AmisCore/src/io/OpfFileReader.cpp =================================================================== --- branches/amis3/AmisCore/src/io/OpfFileReader.cpp 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisCore/src/io/OpfFileReader.cpp 2008-02-02 06:23:44 UTC (rev 2303) @@ -159,6 +159,7 @@ if (node_name == "dc:Creator" && mpMetadata->getMetadata("dc:creator") != NULL) { p_meta_item = mpMetadata->getMetadata("dc:creator"); + if (p_meta_item == NULL) p_meta_item = new amis::dtb::MetaItem(); } else { Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-02-02 06:23:44 UTC (rev 2303) @@ -222,7 +222,8 @@ POPUP "&Info" BEGIN MENUITEM "&Reading Options...", ID_MENU_INFO_SKIP - MENUITEM "&Publication Summary", ID_PUBLICATION_SUMMARY + MENUITEM "&Publication Summary", ID_MENU_INFO_PUBLICATION_SUMMARY + END POPUP "&Help" BEGIN @@ -342,7 +343,8 @@ CAPTION "Publication Summary" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - LTEXT "About: TITLE by CREATOR",IDC_DIALOGCAPTION,6,7,387,17 + LTEXT "About: TITLE by CREATOR", + IDC_PUBLICATIONSUMMARYDLGCAPTION,6,7,387,17 LTEXT "About your current position:", IDC_CURRENTPOSITIONCAPTION,6,27,387,17 LISTBOX IDC_CURRENTPOSITION,6,47,387,49,LBS_SORT | Modified: branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2008-02-02 06:23:44 UTC (rev 2303) @@ -56,7 +56,7 @@ amis::dtb::Bookmark* addBookmark(); void loadBookmark(int); amis::dtb::smil::SmilMediaGroup* loadSmilFromUrl(const ambulant::net::url*); - + private: void addToRecentBooks(); void makeAllNavContainerLabelsHumanReadable(); Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-02-02 06:23:44 UTC (rev 2303) @@ -99,6 +99,7 @@ afx_msg void OnSpeedDown(); afx_msg void OnSpeedNormal(); afx_msg void OnPreferences(); + afx_msg void OnPublicationSummary(); protected: HMENU m_hMDIMenu; HACCEL m_hMDIAccel; Modified: branches/amis3/AmisGuiMFC2/include/gui/MmView.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MmView.h 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisGuiMFC2/include/gui/MmView.h 2008-02-02 06:23:44 UTC (rev 2303) @@ -127,9 +127,13 @@ void lastPhrase(); void escapeCurrent(); + //returns smilfile#id (updated every time the id changes) + const ambulant::net::url* getCurrentUrl(); + //pasted in by Marisa from AMIS' last copy of MmView.h - private: +private: ambulant::gui::dx::dx_player *CreatePlayerInstance(const ambulant::net::url& u); + ambulant::net::url m_current_url; public: // player_feedback interface: void document_loaded(ambulant::lib::document *doc); Modified: branches/amis3/AmisGuiMFC2/include/gui/dialogs/PublicationSummaryDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/PublicationSummaryDialog.h 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/PublicationSummaryDialog.h 2008-02-02 06:23:44 UTC (rev 2303) @@ -50,16 +50,18 @@ DECLARE_MESSAGE_MAP() private: + bool calculateData(); + void displayData(); amis::dtb::Dtb* mpBook; amis::MediaGroup* mpTitle; wstring mCreator; - string mCurrentPage; - int mTotalPages; + amis::MediaGroup* mpCurrentPage; + int mTotalNumPages; wstring mCurrentTimestamp; string mTimeRemaining; amis::MediaGroup* mpSectionName; int mNumSubsections; - int mNumPages; + int mNumPagesForSection; wstring mTotalTime; wstring mPublisher; wstring mDescription; Modified: branches/amis3/AmisGuiMFC2/resource.h =================================================================== --- branches/amis3/AmisGuiMFC2/resource.h 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisGuiMFC2/resource.h 2008-02-02 06:23:44 UTC (rev 2303) @@ -97,6 +97,7 @@ #define IDC_URL 1079 #define IDC_TEXTBG 1080 #define IDC_DIALOGCAPTION 1080 +#define IDC_PUBLICATIONSUMMARYDLGCAPTION 1080 #define IDC_BORDER 1081 #define IDC_PUBLICATIONINFO 1081 #define IDC_CURRENTPOSITIONCAPTION 1082 @@ -151,7 +152,7 @@ #define ID_MENU_PLAYPAUSE 32865 #define ID_MENU_FILE_OPENFROMURL 32870 #define ID_MENU_FILE_CLOSE 32871 -#define ID_PUBLICATION_SUMMARY 32875 +#define ID_MENU_INFO_PUBLICATION_SUMMARY 32876 #define IDS_NOSKIP 61245 #define IDS_SELFOLDER_TITLE 61258 #define IDS_SELFOLDER_INSTR 61259 @@ -166,7 +167,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 192 -#define _APS_NEXT_COMMAND_VALUE 32876 +#define _APS_NEXT_COMMAND_VALUE 32877 #define _APS_NEXT_CONTROL_VALUE 1098 #define _APS_NEXT_SYMED_VALUE 141 #endif Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2008-02-02 06:23:44 UTC (rev 2303) @@ -366,4 +366,3 @@ theApp.setPauseState(false); return NULL; } - Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-02-02 06:23:44 UTC (rev 2303) @@ -51,6 +51,7 @@ #include "gui/dialogs/SearchForBooksDialog.h" #include "gui/dialogs/MultipleBooksOnVolumeDialog.h" #include "gui/dialogs/PreferencesDialog.h" +#include "gui/dialogs/PublicationSummaryDialog.h" #include "../../AmisAudio/AmisAudio.h" //using namespace amis::audio; @@ -101,7 +102,7 @@ ON_COMMAND(ID_MENU_PLAY_VOLUP, OnVolumeUp) ON_COMMAND(ID_MENU_PLAY_VOLDOWN, OnVolumeDown) ON_COMMAND(ID_MENU_FILE_PREFERENCES, OnPreferences) - + ON_COMMAND(ID_MENU_INFO_PUBLICATION_SUMMARY, OnPublicationSummary) END_MESSAGE_MAP() CAmisApp::CAmisApp() @@ -672,6 +673,13 @@ } } +void CAmisApp::OnPublicationSummary() +{ + dialogs::PublicationSummaryDialog summary; + summary.setBook(amis::dtb::DtbWithHooks::Instance()); + summary.DoModal(); +} + /*************************************************** * (MED) I moved these functions out of the menu handler area *****************************************************/ Modified: branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisGuiMFC2/src/gui/MmView.cpp 2008-02-02 06:23:44 UTC (rev 2303) @@ -1048,10 +1048,10 @@ // Finally, if this node has an ID we may want to update the table of contents. if (!id || strlen(id) == 0) return; - ambulant::net::url current_url = player->get_url(); + m_current_url = player->get_url(); std::string id_string; id_string.assign(id); - current_url = current_url.add_fragment(id_string); + m_current_url = m_current_url.add_fragment(id_string); // We also store the URL that the most recent text node refers to, // this is used as a starting point for searches. @@ -1061,7 +1061,7 @@ } //set the lastmark - amis::dtb::DtbWithHooks::Instance()->setNewLastmark(current_url); + amis::dtb::DtbWithHooks::Instance()->setNewLastmark(m_current_url); } @@ -1075,3 +1075,7 @@ } +const ambulant::net::url* MmView::getCurrentUrl() +{ + return &m_current_url; +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp 2008-02-01 01:20:08 UTC (rev 2302) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp 2008-02-02 06:23:44 UTC (rev 2303) @@ -26,6 +26,10 @@ #include "AmisCore.h" #include "dtb/Dtb.h" #include "Media.h" +#include "ambulant/net/url.h" +#include "gui/MmView.h" +#include "gui/MainWndParts.h" +#include "util/FilePathTools.h" using namespace amis::gui::dialogs; @@ -50,6 +54,13 @@ } BOOL PublicationSummaryDialog::OnInitDialog() { + if (mpBook == NULL) + { + //TODO: log error + return FALSE; + } + if (calculateData() == true) + displayData(); return CDialog::OnInitDialog(); } @@ -84,10 +95,34 @@ void PublicationSummaryDialog::setBook(amis::dtb::Dtb* pBook) { + //clear all the data (it will get refreshed) + mCreator.erase(); + mCurrentTimestamp.erase(); + mDate.erase(); + mDescription.erase(); + mFormat.erase(); + mNumPagesForSection = 0; + mNumSubsections = 0; + mPublisher.clear(); + mTimeRemaining.erase(); + mTotalNumPages = 0; + mTotalTime.erase(); + mpCurrentPage = NULL; + mpBook = NULL; + mpSectionName = NULL; + mpTitle = NULL; + mpBook = pBook; +} + +bool PublicationSummaryDialog::calculateData() +{ + if (mpBook == NULL) return false; + amis::dtb::Metadata* p_meta = mpBook->getMetadata(); amis::dtb::DaisyVersion version = mpBook->getDaisyVersion(); - + amis::dtb::nav::NavModel* p_nav = mpBook->getNavModel(); + mpTitle = mpBook->getTitle(); mCreator = p_meta->getMetadataContent("dc:creator"); @@ -105,6 +140,108 @@ if (mFormat.size() == 0 && version == amis::dtb::DAISY_202) mFormat = p_meta->getMetadataContent("ncc:format"); + mTotalNumPages = p_nav->getPageList()->getLength(); + //the address for the currently-playing node + const ambulant::net::url* p_url = MainWndParts::Instance()->mpMmView->getCurrentUrl(); + string id = p_url->get_ref(); + string file = amis::util::FilePathTools::getFileName(p_url->get_url()); + file = file + "#" + id; + + amis::dtb::nav::PageTarget* p_page = NULL; + amis::dtb::nav::NavPoint* p_section = NULL; + p_page = (amis::dtb::nav::PageTarget*)p_nav->getNodeForSmilId(file, mpBook->getNavModel()->getPageList()); + p_section = (amis::dtb::nav::NavPoint*)p_nav->getNodeForSmilId(file, mpBook->getNavModel()->getNavMap()); + if (p_page != NULL) mpCurrentPage = p_page->getLabel(); + if (p_section != NULL) + { + mpSectionName = p_section->getLabel(); + mNumSubsections = p_section->getNumChildren(); + //the number of pages in a section is calculated using playorder, which doesn't exist in Zed 2002 + if (version == amis::dtb::DAISY_202 || version == amis::dtb::ZED_2005) + { + int start_play_order, end_play_order; + if (p_section->getFirstSibling() == NULL) end_play_order = -1; + else end_play_order = p_section->getFirstSibling()->getPlayOrder(); + start_play_order = p_section->getPlayOrder(); + mNumPagesForSection = p_nav->getPageList()->countPagesInRange(start_play_order, end_play_order); + } + } + else + { + mNumSubsections = 0; + mNumPagesForSection = 0; + } + + //TODO: figure out current timestamp + return true; } +//this will be taken over by the accessible ui list/prompt data +//for now, it's just temporary to a. see how it looks and b. see if the data is correct +void PublicationSummaryDialog::displayData() +{ + CStatic* p_caption = (CStatic*)GetDlgItem(IDC_PUBLICATIONSUMMARYDLGCAPTION); + CListBox* p_current_pos = (CListBox*)GetDlgItem(IDC_CURRENTPOSITION); + CListBox* p_pub_info = (CListBox*)GetDlgItem(IDC_PUBLICATIONINFO); + + CString caption, title, author; + if (mpTitle != NULL) + title.Format(_T("About: \"%s\""), mpTitle->getText()->getTextString().c_str()); + else + title = _T("Title not available"); + if (mCreator.size() > 0) + author.Format(_T("written by %s"), mCreator.c_str()); + else + author = _T("Author not available"); + caption.Append(title); + caption.Append(_T(", ")); + caption.Append(author); + p_caption->SetWindowText(caption); + + CString current_page, current_time, current_section, publisher, description, total_time, date, format; + + if (mpCurrentPage != NULL) + { + current_page.Format(_T("On page %s of %d total pages"), + mpCurrentPage->getText()->getTextString().c_str(), mTotalNumPages); + p_current_pos->AddString(current_page); + } + + //TODO: if time data is available + current_time.Format(_T("At %s; %s remaining"), + _T("TODO"), _T("TODO")); + p_current_pos->AddString(current_time); + + if (mpSectionName != NULL) + { + current_section.Format(_T("In section %s, which contains %d subsections and %d pages."), + mpSectionName->getText()->getTextString().c_str(), mNumSubsections, mNumPagesForSection); + p_current_pos->AddString(current_section); + } + if (mPublisher.size() > 0) + { + publisher.Format(_T("Published by %s"), mPublisher.c_str()); + p_pub_info->AddString(publisher); + } + if (mDescription.size() > 0) + { + description.Format(_T("Description: %s"), mDescription.c_str()); + p_pub_info->AddString(description); + } + if (mTotalTime.size() > 0) + { + total_time.Format(_T("Total length (time): %s"), mTotalTime.c_str()); + p_pub_info->AddString(total_time); + } + if (mDate.size() > 0) + { + date.Format(_T("Date: %s"), mDate.c_str()); + p_pub_info->AddString(date); + } + if (mFormat.size() > 0) + { + format.Format(_T("Format: %s"), mFormat.c_str()); + p_pub_info->AddString(format); + } +} \ 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-02-02 17:53:31
|
Revision: 2304 http://amis.svn.sourceforge.net/amis/?rev=2304&view=rev Author: marisademeglio Date: 2008-02-02 09:53:35 -0800 (Sat, 02 Feb 2008) Log Message: ----------- Cleaned up "TODO" notes in the code (I'm generating a list of all) Modified Paths: -------------- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp branches/amis3/AmisAudio/TPBReader2/dmp/dmp.cpp branches/amis3/AmisCore/include/dtb/nav/NavPoint.h branches/amis3/AmisCore/src/dtb/Bookmarks.cpp branches/amis3/AmisCore/testAmisCoreWithGui/ChildFrm.cpp branches/amis3/AmisCore/testAmisCoreWithGui/MainFrm.cpp branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGui.aps branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGui.cpp branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGui.rc branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGuiDoc.cpp branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGuiView.cpp branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp Added Paths: ----------- branches/amis3/AmisCore/testAmisCoreWin32/testAmisCore.sln Modified: branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2008-02-02 06:23:44 UTC (rev 2303) +++ branches/amis3/AmisAudio/TPBReader2/dmp/DmpCtl.cpp 2008-02-02 17:53:35 UTC (rev 2304) @@ -101,7 +101,7 @@ ///////////////////////////////////////////////////////////////////////////// // Property pages -// TODO: Add more property pages as needed. Remember to increase the count! +// Add more property pages as needed. Remember to increase the count! //NO_ACTIVEX /* BEGIN_PROPPAGEIDS(CDmpCtrl, 1) @@ -162,7 +162,7 @@ /* BOOL CDmpCtrl::CDmpCtrlFactory::UpdateRegistry(BOOL bRegister) { - // TODO: Verify that your control follows apartment-model threading rules. + // Verify that your control follows apartment-model threading rules. // Refer to MFC TechNote 64 for more information. // If your control does not conform to the apartment-model rules, then // you must modify the code below, changing the 6th parameter from @@ -1187,7 +1187,7 @@ BOOL CDmpCtrl::setVolume(long ilVolume) { - // TODO: Add your dispatch handler code here + // Add your dispatch handler code here logSession("Try set volume"); IBasicAudio *pIBA; Modified: branches/amis3/AmisAudio/TPBReader2/dmp/dmp.cpp =================================================================== --- branches/amis3/AmisAudio/TPBReader2/dmp/dmp.cpp 2008-02-02 06:23:44 UTC (rev 2303) +++ branches/amis3/AmisAudio/TPBReader2/dmp/dmp.cpp 2008-02-02 17:53:35 UTC (rev 2304) @@ -31,7 +31,7 @@ BOOL bInit = COleControlModule::InitInstance(); if (bInit) - // TODO: Add your own module initialization code here. + // Add your own module initialization code here. { } @@ -44,7 +44,7 @@ int CDmpApp::ExitInstance() { - // TODO: Add your own module termination code here. + // Add your own module termination code here. return COleControlModule::ExitInstance(); } Modified: branches/amis3/AmisCore/include/dtb/nav/NavPoint.h =================================================================== --- branches/amis3/AmisCore/include/dtb/nav/NavPoint.h 2008-02-02 06:23:44 UTC (rev 2303) +++ branches/amis3/AmisCore/include/dtb/nav/NavPoint.h 2008-02-02 17:53:35 UTC (rev 2304) @@ -44,8 +44,7 @@ NavPoint* getParent(); NavPoint* next(); - //@todo - //finish this function + //@todo: finish previous() function NavPoint* previous(); void resetChildCount(); int getNumChildren(); Modified: branches/amis3/AmisCore/src/dtb/Bookmarks.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Bookmarks.cpp 2008-02-02 06:23:44 UTC (rev 2303) +++ branches/amis3/AmisCore/src/dtb/Bookmarks.cpp 2008-02-02 17:53:35 UTC (rev 2304) @@ -179,8 +179,7 @@ void amis::dtb::BookmarkSet::deleteItem(unsigned int idx) { - //@todo - //write this function + //@todo: write this deleteItem(..) function } void amis::dtb::BookmarkSet::setTitle(amis::MediaGroup* pData) Added: branches/amis3/AmisCore/testAmisCoreWin32/testAmisCore.sln =================================================================== --- branches/amis3/AmisCore/testAmisCoreWin32/testAmisCore.sln (rev 0) +++ branches/amis3/AmisCore/testAmisCoreWin32/testAmisCore.sln 2008-02-02 17:53:35 UTC (rev 2304) @@ -0,0 +1,29 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AmisCore", "..\AmisCore.vcproj", "{E0F81CE5-9C15-4E36-BC71-42BE1C0F2406}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testAmisCore", "testAmisCore.vcproj", "{EF232C4C-7F7A-496F-A2DC-E658C2845330}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {E0F81CE5-9C15-4E36-BC71-42BE1C0F2406}.Debug.ActiveCfg = Debug|Win32 + {E0F81CE5-9C15-4E36-BC71-42BE1C0F2406}.Debug.Build.0 = Debug|Win32 + {E0F81CE5-9C15-4E36-BC71-42BE1C0F2406}.Release.ActiveCfg = Release|Win32 + {E0F81CE5-9C15-4E36-BC71-42BE1C0F2406}.Release.Build.0 = Release|Win32 + {EF232C4C-7F7A-496F-A2DC-E658C2845330}.Debug.ActiveCfg = Debug|Win32 + {EF232C4C-7F7A-496F-A2DC-E658C2845330}.Debug.Build.0 = Debug|Win32 + {EF232C4C-7F7A-496F-A2DC-E658C2845330}.Release.ActiveCfg = Release|Win32 + {EF232C4C-7F7A-496F-A2DC-E658C2845330}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal Modified: branches/amis3/AmisCore/testAmisCoreWithGui/ChildFrm.cpp =================================================================== --- branches/amis3/AmisCore/testAmisCoreWithGui/ChildFrm.cpp 2008-02-02 06:23:44 UTC (rev 2303) +++ branches/amis3/AmisCore/testAmisCoreWithGui/ChildFrm.cpp 2008-02-02 17:53:35 UTC (rev 2304) @@ -22,7 +22,7 @@ CChildFrame::CChildFrame() { - // TODO: add member initialization code here + // add member initialization code here } CChildFrame::~CChildFrame() @@ -32,7 +32,7 @@ BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) { - // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs + // Modify the Window class or styles here by modifying the CREATESTRUCT cs if( !CMDIChildWnd::PreCreateWindow(cs) ) return FALSE; Modified: branches/amis3/AmisCore/testAmisCoreWithGui/MainFrm.cpp =================================================================== --- branches/amis3/AmisCore/testAmisCoreWithGui/MainFrm.cpp 2008-02-02 06:23:44 UTC (rev 2303) +++ branches/amis3/AmisCore/testAmisCoreWithGui/MainFrm.cpp 2008-02-02 17:53:35 UTC (rev 2304) @@ -32,7 +32,7 @@ CMainFrame::CMainFrame() { - // TODO: add member initialization code here + // add member initialization code here } CMainFrame::~CMainFrame() @@ -60,7 +60,7 @@ TRACE0("Failed to create status bar\n"); return -1; // fail to create } - // TODO: Delete these three lines if you don't want the toolbar to be dockable + // Delete these three lines if you don't want the toolbar to be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); @@ -72,7 +72,7 @@ { if( !CMDIFrameWnd::PreCreateWindow(cs) ) return FALSE; - // TODO: Modify the Window class or styles here by modifying + // Modify the Window class or styles here by modifying // the CREATESTRUCT cs return TRUE; Modified: branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGui.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGui.cpp =================================================================== --- branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGui.cpp 2008-02-02 06:23:44 UTC (rev 2303) +++ branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGui.cpp 2008-02-02 17:53:35 UTC (rev 2304) @@ -35,7 +35,7 @@ CtestAmisCoreWithGuiApp::CtestAmisCoreWithGuiApp() { - // TODO: add construction code here, + // add construction code here, // Place all significant initialization in InitInstance } @@ -67,7 +67,8 @@ // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored - // TODO: You should modify this string to be something appropriate + + // You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(4); // Load standard INI file options (including MRU) Modified: branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGui.rc =================================================================== --- branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGui.rc 2008-02-02 06:23:44 UTC (rev 2303) +++ branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGui.rc 2008-02-02 17:53:35 UTC (rev 2304) @@ -237,13 +237,13 @@ BEGIN BLOCK "040904e4" BEGIN - VALUE "CompanyName", "TODO: <Company name>" - VALUE "FileDescription", "TODO: <File description>" + VALUE "CompanyName", "<Company name>" + VALUE "FileDescription", "<File description>" VALUE "FileVersion", "1.0.0.1" VALUE "InternalName", "testAmisCoreWithGui.exe" - VALUE "LegalCopyright", "TODO: (c) <Company name>. All rights reserved." + VALUE "LegalCopyright", "(c) <Company name>. All rights reserved." VALUE "OriginalFilename", "testAmisCoreWithGui.exe" - VALUE "ProductName", "TODO: <Product name>" + VALUE "ProductName", "<Product name>" VALUE "ProductVersion", "1.0.0.1" END END Modified: branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGuiDoc.cpp =================================================================== --- branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGuiDoc.cpp 2008-02-02 06:23:44 UTC (rev 2303) +++ branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGuiDoc.cpp 2008-02-02 17:53:35 UTC (rev 2304) @@ -23,7 +23,7 @@ CtestAmisCoreWithGuiDoc::CtestAmisCoreWithGuiDoc() { - // TODO: add one-time construction code here + // add one-time construction code here } @@ -36,7 +36,7 @@ if (!CDocument::OnNewDocument()) return FALSE; - // TODO: add reinitialization code here + // add reinitialization code here // (SDI documents will reuse this document) return TRUE; @@ -51,11 +51,11 @@ { if (ar.IsStoring()) { - // TODO: add storing code here + // add storing code here } else { - // TODO: add loading code here + // add loading code here } } Modified: branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGuiView.cpp =================================================================== --- branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGuiView.cpp 2008-02-02 06:23:44 UTC (rev 2303) +++ branches/amis3/AmisCore/testAmisCoreWithGui/testAmisCoreWithGuiView.cpp 2008-02-02 17:53:35 UTC (rev 2304) @@ -27,7 +27,7 @@ CtestAmisCoreWithGuiView::CtestAmisCoreWithGuiView() { - // TODO: add construction code here + // add construction code here } @@ -37,7 +37,7 @@ BOOL CtestAmisCoreWithGuiView::PreCreateWindow(CREATESTRUCT& cs) { - // TODO: Modify the Window class or styles here by modifying + // Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); @@ -52,7 +52,7 @@ if (!pDoc) return; - // TODO: add draw code for native data here + // add draw code for native data here } @@ -66,12 +66,12 @@ void CtestAmisCoreWithGuiView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { - // TODO: add extra initialization before printing + // add extra initialization before printing } void CtestAmisCoreWithGuiView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { - // TODO: add cleanup after printing + // add cleanup after printing } Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2008-02-02 06:23:44 UTC (rev 2303) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2008-02-02 17:53:35 UTC (rev 2304) @@ -118,7 +118,7 @@ if (this->getDaisyVersion() == 2) test_id.append("-on"); bool state = p_tests->getCustomTest(i)->getCurrentState() | playAll; ambulant::smil2::test_attrs::set_current_system_component_value(test_id, state); - //TODO + //TODO: review skippability across document boundaries //this commented-out line in mmview might be interesting: //player->set_custom_test ... //we need to decide 1. if it will make ambulant listen to custom test changes on the active file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |