[Amis-vcs] SF.net SVN: amis: [2384] branches/amis3
Brought to you by:
julienq,
marisademeglio
From: <mar...@us...> - 2008-03-03 05:25:19
|
Revision: 2384 http://amis.svn.sourceforge.net/amis/?rev=2384&view=rev Author: marisademeglio Date: 2008-03-02 21:25:23 -0800 (Sun, 02 Mar 2008) Log Message: ----------- Fontsize buttons now enable/disable like they should Page styles work too Modified Paths: -------------- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h branches/amis3/AmisGuiMFC2/resource.h branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/bin/settings/basicToolbar.xml branches/amis3/bin/settings/css/amis.css branches/amis3/bin/settings/resource.h.ini Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-03 05:25:23 UTC (rev 2384) @@ -182,8 +182,6 @@ BEGIN MENUITEM "None", ID_AMIS_NO_PAGE_STYLES , CHECKED - MENUITEM "sample 1", 351 - MENUITEM "sample 2", 352 END MENUITEM "Bi&gger Font", ID_AMIS_BIGGER_FONT MENUITEM "S&maller Font", ID_AMIS_SMALLER_FONT Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-03 05:25:23 UTC (rev 2384) @@ -99,6 +99,9 @@ afx_msg void OnPreferences(); afx_msg void OnPublicationSummary(); afx_msg void OnToggleView(); + afx_msg void OnClearPageStyle(); + afx_msg void OnApplyPageStyle(UINT); + afx_msg void OnNextPageStyle(); protected: HMENU m_hMDIMenu; HACCEL m_hMDIAccel; @@ -108,6 +111,7 @@ void initializeSelfVoicing(); void openBook(const ambulant::net::url*); void openLastReadBook(); + void updateFontSizeButtons(); std::string mAppPath; std::string mLocalizationDll; ambulant::net::url mURL; Modified: branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/include/gui/MainFrm.h 2008-03-03 05:25:23 UTC (rev 2384) @@ -78,6 +78,9 @@ afx_msg void OnUpdateCmdUiCheckSidebar(CCmdUI*); afx_msg void OnUpdateCmdUiFindInText(CCmdUI*); afx_msg void OnUpdateCmdUiPlayPause(CCmdUI*); + afx_msg void OnUpdateCmdUiPageStyle(CCmdUI*); + afx_msg void OnUpdateCmdUiBiggerFont(CCmdUI*); + afx_msg void OnUpdateCmdUiSmallerFont(CCmdUI*); DECLARE_MESSAGE_MAP() public: afx_msg void OnSize(UINT nType, int cx, int cy); Modified: branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h 2008-03-03 05:25:23 UTC (rev 2384) @@ -43,6 +43,7 @@ void addBookmark(amis::dtb::PositionMark*); void loadBookmarks(amis::dtb::BookmarkSet*); void setupNavigationOptions(); + void addPageStyles(); private: static MenuManip* pinstance; }; Modified: branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2008-03-03 05:25:23 UTC (rev 2384) @@ -49,13 +49,19 @@ void resetFontSize(); void increaseFontSize(); - bool toggleContrast(); - bool isContrastOn(); + void decreaseFontSize(); + int getFontLevel(); + int getMaxFontLevel(); void gotoUriTarget(amis::TextNode*); void gotoUriTarget(std::string url); - void redoPageColors(bool bDisableContrast=false); + void applyPageStyle(int); + void clearPageStyle(); + void applyNextPageStyle(); + int getCurrentCustomStyleIndex(); + + void redoPageColors(); wstring getCurrentText(); void webDocumentComplete(); @@ -63,8 +69,6 @@ void saveElementText(IHTMLElement*); void setFontSize(int); void showElementAtId(string); - void htmlContrastOn(); - void htmlContrastOff(); void unHighlightPreviousElement(); void setHighlightColors(IHTMLElement*); void redoHighlightColors(); @@ -75,7 +79,6 @@ int mFontSize; bool mbWaitForDocumentLoad; - bool mbContrastOn; ambulant::net::url mCurrentUrl; string mTextElmId; wstring mCurrentElmText; @@ -83,9 +86,10 @@ VARIANT mUnhighlightedBG; VARIANT mUnhighlightedFG; IHTMLStyleSheet* mpFontCss; - IHTMLStyleSheet* mpContrastCss; + IHTMLStyleSheet* mpStyleCss; IHTMLStyleSheet* mpUserCss; - + int mCurrentStyleIdx; + bool mbStyleOn; private: static TextRenderBrain* pinstance; Modified: branches/amis3/AmisGuiMFC2/resource.h =================================================================== --- branches/amis3/AmisGuiMFC2/resource.h 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/resource.h 2008-03-03 05:25:23 UTC (rev 2384) @@ -14,7 +14,6 @@ #define ID_AMIS_RESET_HIGHLIGHT_COLORS 132 #define ID_AMIS_TOGGLE_AUDIO_CONTENT_PLAYBACK 133 #define ID_AMIS_TOGGLE_AUDIO_SELFVOICING_PLAYBACK 134 -#define ID_AMIS_NEXT_PAGE_STYLE 142 #define IDD_FIND 147 #define AMIS_VIEW_MENU_BASE_ID 150 #define IDD_SKIP 153 @@ -32,6 +31,7 @@ #define AMIS_NAVLIST_BASE_ID 300 #define AMIS_PAGE_STYLE_BASE_ID 350 #define AMIS_BOOKMARKS_BASE_ID 400 +#define ID_AMIS_NEXT_PAGE_STYLE 450 #define ID_AMBULANT_PLAY 700 #define IDC_TREE 1000 #define IDC_TAB 1001 Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 05:25:23 UTC (rev 2384) @@ -108,6 +108,9 @@ ON_COMMAND(ID_AMIS_SHOW_PREFERENCES, OnPreferences) ON_COMMAND(ID_AMIS_SHOW_PUBLICATION_SUMMARY, OnPublicationSummary) ON_COMMAND(ID_AMIS_TOGGLE_VIEW, OnToggleView) + ON_COMMAND(ID_AMIS_NO_PAGE_STYLES, OnClearPageStyle) + ON_COMMAND_RANGE(AMIS_PAGE_STYLE_BASE_ID, AMIS_PAGE_STYLE_BASE_ID + AMIS_MAX_ANYTHING, OnApplyPageStyle) + ON_COMMAND(ID_AMIS_NEXT_PAGE_STYLE, OnNextPageStyle) END_MESSAGE_MAP() CAmisApp::CAmisApp() @@ -200,7 +203,7 @@ MainWndParts::Instance()->mpMainFrame->SetIcon(AfxGetApp()->LoadIcon(IDI_AMIS), TRUE); amis::gui::MenuManip::Instance()->refreshRecentBooksListMenu(); - + amis::gui::MenuManip::Instance()->addPageStyles(); // The main window has been initialized, so show and update it pFrame->ShowWindow(SW_SHOWMAXIMIZED); pFrame->UpdateWindow(); @@ -656,11 +659,13 @@ { amis::util::Log::Instance()->writeMessage("Increase font size", "CAmisApp::OnIncreaseFontSize", "AmisGuiMFC2"); TextRenderBrain::Instance()->increaseFontSize(); + updateFontSizeButtons(); } void CAmisApp::OnDecreaseFontSize() { amis::util::Log::Instance()->writeMessage("Reset font size", "CAmisApp::OnResetFontSize", "AmisGuiMFC2"); - TextRenderBrain::Instance()->resetFontSize(); + TextRenderBrain::Instance()->decreaseFontSize(); + updateFontSizeButtons(); } void CAmisApp::OnSearchForBooks() { @@ -746,7 +751,6 @@ else amis::util::Log::Instance()->writeMessage("Dialog cancelled", "CAmisApp::OnPreferences", "AmisGuiMFC2"); } - void CAmisApp::OnPublicationSummary() { dialogs::PublicationSummaryDialog summary; @@ -754,11 +758,24 @@ summary.setBook(amis::dtb::DtbWithHooks::Instance()); summary.DoModal(); } - void CAmisApp::OnToggleView() { MainWndParts::Instance()->toggleViewMode(); } +void CAmisApp::OnClearPageStyle() +{ + TextRenderBrain::Instance()->clearPageStyle(); +} +void CAmisApp::OnApplyPageStyle(UINT id) +{ + int idx; + idx = id - AMIS_PAGE_STYLE_BASE_ID; + TextRenderBrain::Instance()->applyPageStyle(idx); +} +void CAmisApp::OnNextPageStyle() +{ + TextRenderBrain::Instance()->applyNextPageStyle(); +} /*************************************************** * (MED) I moved these functions out of the menu handler area *****************************************************/ @@ -770,20 +787,7 @@ */ void CAmisApp::setPauseState(bool pauseState) { - - //TODO: re-add toolbar - //if (MainWndParts::Instance()->mpMainFrame->m_wndDefaultToolbar) - { - //MainWndParts::Instance()->mpMainFrame->m_wndDefaultToolbar.setPauseState(pauseState); - } - - //if (MainWndParts::Instance()->mpMainFrame->m_wndBasicToolbar) - { - //MainWndParts::Instance()->mpMainFrame->m_wndBasicToolbar.setPauseState(pauseState); - } - amis::gui::MenuManip::Instance()->setPauseState(pauseState); - MainWndParts::Instance()->updateTitlePlayState(!pauseState); } @@ -832,3 +836,24 @@ afterModalBox(b); } +void CAmisApp::updateFontSizeButtons() +{ + int font_level = TextRenderBrain::Instance()->getFontLevel(); + int max = TextRenderBrain::Instance()->getMaxFontLevel(); + bool can_increase = true; + bool can_decrease = true; + if (font_level == 0) + { + can_decrease = false; + can_increase = true; + } + else if (font_level == max) + { + can_decrease = true; + can_increase = false; + } + MainWndParts::Instance()->mpDefaultToolbar->enable(ID_AMIS_BIGGER_FONT, can_increase); + MainWndParts::Instance()->mpBasicToolbar->enable(ID_AMIS_BIGGER_FONT, can_increase); + MainWndParts::Instance()->mpDefaultToolbar->enable(ID_AMIS_SMALLER_FONT, can_decrease); + MainWndParts::Instance()->mpBasicToolbar->enable(ID_AMIS_SMALLER_FONT, can_decrease); +} \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-03 05:25:23 UTC (rev 2384) @@ -27,6 +27,7 @@ #include "Preferences.h" #include "DtbWithHooks.h" #include "gui/MenuManip.h" +#include "gui/TextRenderBrain.h" #include "gui/self-voicing/directshow/dx_audio_player.h" @@ -66,8 +67,6 @@ ON_UPDATE_COMMAND_UI(ID_AMIS_NEXT_PAGE, OnUpdateCmdUiPageCommands) ON_UPDATE_COMMAND_UI(ID_AMIS_PREVIOUS_PAGE, OnUpdateCmdUiPageCommands) ON_UPDATE_COMMAND_UI(ID_AMIS_GOTO_PAGE, OnUpdateCmdUiPageCommands) - ON_UPDATE_COMMAND_UI(ID_AMIS_BIGGER_FONT, OnUpdateCmdUiGeneral) - ON_UPDATE_COMMAND_UI(ID_AMIS_SMALLER_FONT, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_ADD_BOOKMARK, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_FASTER, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_CLOSE_BOOK, OnUpdateCmdUiGeneral) @@ -75,7 +74,7 @@ ON_UPDATE_COMMAND_UI(ID_AMIS_SLOWER, OnUpdateCmdUiPlaySlower) ON_UPDATE_COMMAND_UI(ID_AMIS_FOCUS_ON_TEXT, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_TOGGLE_AUDIO_CONTENT_PLAYBACK, OnUpdateCmdUiGeneral) - ON_UPDATE_COMMAND_UI(ID_AMIS_NO_PAGE_STYLES, OnUpdateCmdUiGeneral) + ON_UPDATE_COMMAND_UI(ID_AMIS_NO_PAGE_STYLES, OnUpdateCmdUiPageStyle) ON_UPDATE_COMMAND_UI(ID_AMIS_PLAYPAUSE, OnUpdateCmdUiPlayPause) ON_UPDATE_COMMAND_UI(ID_AMIS_ESCAPE, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_RESET_SPEED, OnUpdateCmdUiGeneral) @@ -86,10 +85,13 @@ ON_UPDATE_COMMAND_UI(ID_AMIS_FIND_IN_TEXT, OnUpdateCmdUiFindInText) ON_UPDATE_COMMAND_UI(ID_AMIS_SHOW_PUBLICATION_SUMMARY, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_NEXT_PAGE_STYLE, OnUpdateCmdUiGeneral) - //TODO: make these more intelligent + //TODO: make these two more intelligent ON_UPDATE_COMMAND_UI(ID_AMIS_INCREASE_SECTION_DEPTH, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_DECREASE_SECTION_DEPTH, OnUpdateCmdUiGeneral) ON_UPDATE_COMMAND_UI(ID_AMIS_TOGGLE_SIDEBAR, OnUpdateCmdUiCheckSidebar) + ON_UPDATE_COMMAND_UI_RANGE(AMIS_PAGE_STYLE_BASE_ID, AMIS_PAGE_STYLE_BASE_ID + AMIS_MAX_ANYTHING, OnUpdateCmdUiPageStyle) + ON_UPDATE_COMMAND_UI(ID_AMIS_SMALLER_FONT, OnUpdateCmdUiSmallerFont) + ON_UPDATE_COMMAND_UI(ID_AMIS_BIGGER_FONT, OnUpdateCmdUiBiggerFont) //}}AFX_MSG_MAP ON_WM_SIZE() END_MESSAGE_MAP() @@ -500,7 +502,43 @@ else updateUiCommandState(pCmdUi, false); } +void amis::gui::CMainFrame::OnUpdateCmdUiPageStyle(CCmdUI* pCmdUi) +{ + if (theApp.isBookOpen()) + { + int curr = TextRenderBrain::Instance()->getCurrentCustomStyleIndex(); + + if (curr == -1) + { + if (pCmdUi->m_nID == ID_AMIS_NO_PAGE_STYLES) pCmdUi->SetCheck(1); + else pCmdUi->SetCheck(0); + } + else + { + if (curr == pCmdUi->m_nID - AMIS_PAGE_STYLE_BASE_ID) pCmdUi->SetCheck(1); + else pCmdUi->SetCheck(0); + } + updateUiCommandState(pCmdUi, true); + } + else + updateUiCommandState(pCmdUi, false); +} +void amis::gui::CMainFrame::OnUpdateCmdUiSmallerFont(CCmdUI* pCmdUi) +{ + if (theApp.isBookOpen() && TextRenderBrain::Instance()->getFontLevel() > 0) + updateUiCommandState(pCmdUi, true); + else + updateUiCommandState(pCmdUi, false); +} +void amis::gui::CMainFrame::OnUpdateCmdUiBiggerFont(CCmdUI* pCmdUi) +{ + if (theApp.isBookOpen() && TextRenderBrain::Instance()->getFontLevel() < TextRenderBrain::Instance()->getMaxFontLevel()) + updateUiCommandState(pCmdUi, true); + else + updateUiCommandState(pCmdUi, false); +} +//TODO: this doesn't work void amis::gui::CMainFrame::OnSize(UINT nType, int cx, int cy) { CMDIFrameWnd::OnSize(nType, cx, cy); Modified: branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2008-03-03 05:25:23 UTC (rev 2384) @@ -29,7 +29,8 @@ #include "RecentBooks.h" #include "dtb/nav/NavModel.h" #include "gui/TextRenderBrain.h" - +#include "util/FilePathTools.h" +#include "Preferences.h" using namespace amis::gui; MenuManip* MenuManip::pinstance = 0; @@ -221,18 +222,15 @@ void MenuManip::setPauseState(bool pauseState) { - CMenu* p_menu = NULL; p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); - if (p_menu == NULL) - { - return; - } - + if (p_menu == NULL) return; + p_menu = p_menu->GetSubMenu(2); assert(p_menu); - bool b_BookIsPlaying = MainWndParts::Instance()->mpMainFrame->mbWasPlayingWhenLostFocus || !pauseState; + bool b_BookIsPlaying = MainWndParts::Instance()->mpMainFrame->mbWasPlayingWhenLostFocus + || !pauseState; UiItem* p_uiItem = DataTree::Instance()->findUiItemInContainers(ID_AMIS_PLAYPAUSE, (b_BookIsPlaying ? "canPause" : "canPlay")); if (p_uiItem != NULL) { @@ -251,7 +249,6 @@ TextNodeSV* textNode = pair->getText(); if (textNode != NULL) { wstring str = textNode->getTextString(); - if (mnemonic != NULL) { TextAudioPair* pair = mnemonic->getContents(); if (pair != NULL) { @@ -268,8 +265,6 @@ if (accelerator != NULL) { str.append(_T("\t")); - //char* text = accelerator.c_str(); - //str.append(accelerator.c_str()); TextAudioPair* pair = accelerator->getContents(); if (pair != NULL) { TextNodeSV* node = pair->getText(); @@ -277,25 +272,39 @@ str.append(node->getTextString()); } } - - //str2.append(info.dwTypeData); } p_menu->ModifyMenu(0, MF_BYPOSITION, ID_AMIS_PLAYPAUSE, str.c_str()); } } } } +} - /*if (pauseState) +void MenuManip::addPageStyles() +{ + USES_CONVERSION; + + CMenu* p_menu = NULL; + p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); + //exit if no menu is present..this could mean we are in basic view mode + if (p_menu == NULL) return; + //get to "view" + p_menu = p_menu->GetSubMenu(1); + //get to "page styles" + p_menu = p_menu->GetSubMenu(3); + int num_entries = p_menu->GetMenuItemCount(); + int i; + //remove all but the first one ("None") + for (i=num_entries-1; i>=1; i--) + p_menu->RemoveMenu(i, MF_BYPOSITION); + + //add all the page styles in the settings/css/customStyles folder + amis::UrlList custom_styles = *Preferences::Instance()->getCustomCssFiles(); + for (i=0; i<custom_styles.size(); i++) { - // If book is paused, then we display a "play" action - p_menu->ModifyMenu(0, MF_BYPOSITION, ID_MENU_PLAYPAUSE, L"&Play\tSpace"); + CString menu_label; + string file_name = amis::util::FilePathTools::getFileName(custom_styles[i].get_file()); + menu_label = A2T(file_name.c_str()); + p_menu->AppendMenu(MF_STRING, AMIS_PAGE_STYLE_BASE_ID + i, menu_label); } - else - { - // If book is playing, then we display a "pause" action - p_menu->ModifyMenu(0, MF_BYPOSITION, ID_MENU_PLAYPAUSE, L"&Pause\tSpace"); - }*/ - - } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-03-03 05:25:23 UTC (rev 2384) @@ -52,30 +52,22 @@ { mFontSize = 0; mbWaitForDocumentLoad = false; - mbContrastOn = false; mpPreviousElm = NULL; - + mbStyleOn = false; + mCurrentStyleIdx = -1; VariantInit(&mUnhighlightedFG); VariantInit(&mUnhighlightedBG); mCurrentUrl = ambulant::net::url(); mpFontCss = NULL; - mpContrastCss = NULL; + mpStyleCss = NULL; mpUserCss = NULL; } TextRenderBrain::~TextRenderBrain() { - - //these crash.. - - /*if (mpFontCss) delete mpFontCss; - if (mpContrastCss) delete mpContrastCss; - if (mpUserCss) delete mpUserCss; - */ - - //TODO: should delete variants too + //TODO: should delete variants } void TextRenderBrain::gotoUriTarget(amis::TextNode* pText) @@ -148,7 +140,7 @@ //refresh font size and contrast settings for the newly loaded page if (mFontSize > 0) setFontSize(mFontSize); - if (mbContrastOn) htmlContrastOn(); + if (mbStyleOn) applyPageStyle(mCurrentStyleIdx); showElementAtId(mTextElmId); } @@ -287,50 +279,69 @@ p_style->put_backgroundColor(var_bg); p_style->put_color(var_fg); } - -bool TextRenderBrain::isContrastOn() +int TextRenderBrain::getFontLevel() { - return mbContrastOn; + return mFontSize; } -//turns the contrast on or off. returns the new state of the contrast (true = on) -bool TextRenderBrain::toggleContrast() +int TextRenderBrain::getMaxFontLevel() { - //MainWndParts::Instance()->mpSidebar->m_wndDlg.toggleContrast(); - - if (mbContrastOn) htmlContrastOff(); - else htmlContrastOn(); - - return mbContrastOn; + return 4; } -void TextRenderBrain::htmlContrastOn() +int TextRenderBrain::getCurrentCustomStyleIndex() { - amis::util::Log::Instance()->writeMessage("HTML contrast turned on", "TextRenderBrain::htmlContrastOn", "AmisGuiMFC2"); - mbContrastOn = true; + return mCurrentStyleIdx; +} +void TextRenderBrain::applyPageStyle(int idx) +{ + clearPageStyle(); + amis::util::Log::Instance()->writeMessage("Applying custom style", "TextRenderBrain::applyPageStyle", "AmisGuiMFC2"); + mbStyleOn = true; amis::UrlList* list = Preferences::Instance()->getCustomCssFiles(); - ambulant::net::url url = (*list)[0]; - mpContrastCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&url); - scanStylesheetForAdditionalData(mpContrastCss); + ambulant::net::url url = (*list)[idx]; + mCurrentStyleIdx = idx; + mpStyleCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(&url); + scanStylesheetForAdditionalData(mpStyleCss); } +void TextRenderBrain::applyNextPageStyle() +{ + amis::UrlList* p_list = Preferences::Instance()->getCustomCssFiles(); + int sz = p_list->size(); + if (mCurrentStyleIdx >= -1 && + mCurrentStyleIdx < sz-1) + { + int tmp = mCurrentStyleIdx; + clearPageStyle(); + mCurrentStyleIdx = tmp + 1; + applyPageStyle(mCurrentStyleIdx); + } + else + { + clearPageStyle(); + } +} -void TextRenderBrain::htmlContrastOff() +void TextRenderBrain::clearPageStyle() { - amis::util::Log::Instance()->writeMessage("HTML contrast turned off", "TextRenderBrain::htmlContrastOff", "AmisGuiMFC2"); - mbContrastOn = false; - MainWndParts::Instance()->mpHtmlView->removeStylesheet(mpContrastCss); + amis::util::Log::Instance()->writeMessage("Clearing page style", "TextRenderBrain::clearPageStyle", "AmisGuiMFC2"); + mbStyleOn = false; + mCurrentStyleIdx = -1; + MainWndParts::Instance()->mpHtmlView->removeStylesheet(mpStyleCss); } void TextRenderBrain::increaseFontSize() { amis::util::Log::Instance()->writeMessage("Font size increased", "TextRenderBrain::increaseFontSize", "AmisGuiMFC2"); - //MainWndParts::Instance()->mpSidebar->m_wndDlg.increaseFontSize(); if (mFontSize >= 0 && mFontSize < 4) setFontSize(mFontSize + 1); } - +void TextRenderBrain::decreaseFontSize() +{ + amis::util::Log::Instance()->writeMessage("Font size decreased", "TextRenderBrain::decreaseFontSize", "AmisGuiMFC2"); + if (mFontSize > 0 && mFontSize <=4) setFontSize(mFontSize - 1); +} void TextRenderBrain::resetFontSize() { amis::util::Log::Instance()->writeMessage("Font size reset", "TextRenderBrain::resetFontSize", "AmisGuiMFC2"); - //MainWndParts::Instance()->mpSidebar->m_wndDlg.resetFontSize(); setFontSize(0); } //set the font size @@ -351,6 +362,10 @@ mpFontCss = MainWndParts::Instance()->mpHtmlView->applyStylesheet(css_url); scanStylesheetForAdditionalData(mpFontCss); } + else + { + mpFontCss = NULL; + } if (isElementInView(mpPreviousElm) == false) { VARIANT v_bool; @@ -433,31 +448,12 @@ return mCurrentElmText; } -void TextRenderBrain::redoPageColors(bool disableContrast) +void TextRenderBrain::redoPageColors() { if (Preferences::Instance()->getHighlightText() == true) redoHighlightColors(); else unHighlightPreviousElement(); - - //maintain the contrast settings (on/off) but use the new colors - if (disableContrast == false) - { - //TODO repaint the sidebar contrast - //MainWndParts::Instance()->mpSidebar->m_wndDlg.repaintContrast(); - - //repaint the html view contrast if it had been enabled - if (mbContrastOn) htmlContrastOn(); - } - //otherwise turn the contrast off everywhere - else - { - //TODO turn off the sidebar contrast - //MainWndParts::Instance()->mpSidebar->m_wndDlg.turnContrastOff(); - - //turn off the html view contrast - htmlContrastOff(); - } } //this is called to refresh the page colors //the colors might have changed but the element cursor hasn't moved yet @@ -465,9 +461,7 @@ void TextRenderBrain::redoHighlightColors() { USES_CONVERSION; - IHTMLStyle* pStyle = NULL; - if (mpPreviousElm != NULL) { //get a pointer to the style @@ -477,8 +471,6 @@ string str_text_fg, str_text_bg; VARIANT var_bg; VARIANT var_fg; - - VariantInit(&var_bg); VariantInit(&var_fg); Modified: branches/amis3/bin/settings/basicToolbar.xml =================================================================== --- branches/amis3/bin/settings/basicToolbar.xml 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/bin/settings/basicToolbar.xml 2008-03-03 05:25:23 UTC (rev 2384) @@ -7,7 +7,7 @@ </toggle> <button src="./img/basicToolbar/media_seek_forward.ico" mfcid="ID_AMIS_NEXT_PHRASE"/> <separator/> - <button src="./img/basicToolbar/style.ico" mfcid="ID_AMIS_SLOWER"/> + <button src="./img/basicToolbar/style.ico" mfcid="ID_AMIS_NEXT_PAGE_STYLE"/> <separator/> <button src="./img/basicToolbar/display.ico" mfcid="ID_AMIS_TOGGLE_VIEW"/> </toolbar> Modified: branches/amis3/bin/settings/css/amis.css =================================================================== --- branches/amis3/bin/settings/css/amis.css 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/bin/settings/css/amis.css 2008-03-03 05:25:23 UTC (rev 2384) @@ -1,5 +1,5 @@ /*default CSS sheet*/ /*"amis-highlight" is a reserved word that AMIS will look for to find the highlight colors*/ /*use the body element selector to specify what font you want, etc. AMIS will pick up the font family for the body element and use it in the sidebar*/ -.amis-highlight {color: white; background-color: green} +.amis-highlight {color: black; background-color: yellow} body {font-family: arial, verdana, sans-serif;} \ No newline at end of file Modified: branches/amis3/bin/settings/resource.h.ini =================================================================== --- branches/amis3/bin/settings/resource.h.ini 2008-03-03 05:17:32 UTC (rev 2383) +++ branches/amis3/bin/settings/resource.h.ini 2008-03-03 05:25:23 UTC (rev 2384) @@ -33,6 +33,7 @@ AMIS_NAVLIST_BASE_ID=300 AMIS_PAGE_STYLE_BASE_ID=350 AMIS_BOOKMARKS_BASE_ID=400 +ID_AMIS_NEXT_PAGE_STYLE=450 ID_AMBULANT_PLAY=700 IDC_TREE=1000 IDC_TAB=1001 @@ -124,7 +125,6 @@ _APS_NEXT_RESOURCE_VALUE=192 _APS_NEXT_COMMAND_VALUE=32952 _APS_NEXT_CONTROL_VALUE=1106 -_APS_NEXT_SYMED_VALUE=142 +_APS_NEXT_SYMED_VALUE=143 - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |