[Amis-vcs] SF.net SVN: amis: [2155] branches/amis3
Brought to you by:
julienq,
marisademeglio
From: <mar...@us...> - 2007-09-23 20:14:15
|
Revision: 2155 http://amis.svn.sourceforge.net/amis/?rev=2155&view=rev Author: marisademeglio Date: 2007-09-23 13:14:17 -0700 (Sun, 23 Sep 2007) Log Message: ----------- Hooked up contrast, text size. Contrast works but not on all documents (this is a stylesheet problem). Text size needs debugging. Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp branches/amis3/AmisGuiMFC2/src/gui/MainWndParts.cpp branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/bin/settings/amis-contrast.css Modified: branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/AmisGuiMFC2/include/gui/MenuManip.h 2007-09-23 20:14:17 UTC (rev 2155) @@ -40,7 +40,7 @@ void refreshRecentBooksListMenu(); void setupMenusSomethingOpen(amis::dtb::BookmarkSet*); void setupMenusNothingOpen(); - void setSidebarItemCheckmark(bool); + void setViewItemCheckmark(bool, UINT); void addBookmark(amis::dtb::PositionMark*); void loadBookmarks(amis::dtb::BookmarkSet*); private: Modified: branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2007-09-23 20:14:17 UTC (rev 2155) @@ -49,7 +49,8 @@ void resetFontSize(); void increaseFontSize(); - void toggleContrast(); + bool toggleContrast(); + bool isContrastOn(); void highlightUriTarget(amis::TextNode*); void highlightUriTarget(std::string url); @@ -63,8 +64,8 @@ void saveElementText(IHTMLElement*); void setFontSize(int); void highlightElementAtId(string); - void pageContrastOn(); - void pageContrastOff(); + void htmlContrastOn(); + void htmlContrastOff(); void redoHighlightColors(); bool isElementInView(IHTMLElement*); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisGuiMFC2.cpp 2007-09-23 20:14:17 UTC (rev 2155) @@ -21,28 +21,33 @@ */ #include "stdafx.h" +#include "../resource.h" + +#include "dtb/nav/NavModel.h" + +#include "DtbWithHooks.h" + +#include "io/RecentBooksFileIO.h" + #include "gui/AmisGuiMFC2.h" #include "gui/MainFrm.h" -#include "gui/sidebar/AmisSidebar.h" #include "gui/ChildFrm.h" #include "gui/MainWndParts.h" - -#include "../resource.h" - #include "gui/MmDoc.h" #include "gui/MmView.h" #include "gui/MenuManip.h" +#include "gui/TextRenderBrain.h" + +#include "gui/sidebar/AmisSidebar.h" + #include "gui/dialogs/AmisFileDialog.h" -#include "util/FilePathTools.h" - -#include "DtbWithHooks.h" -#include "io/RecentBooksFileIO.h" #include "gui/dialogs/AboutDialog.h" #include "gui/dialogs/OpenUrlDialog.h" #include "gui/dialogs/SkipDialog.h" #include "gui/dialogs/GoToPageDialog.h" -#include "dtb/nav/NavModel.h" +#include "util/FilePathTools.h" + #ifdef _DEBUG #define new DEBUG_NEW #endif @@ -74,7 +79,9 @@ ON_COMMAND(ID_MENU_BMK_ADD, OnAddBookmark) ON_COMMAND_RANGE(BOOKMARKS_BASE_ID, BOOKMARKS_BASE_ID + MAX_ANYTHING, OnSelectBookmark) ON_COMMAND(ID_MENU_NAV_GOTOPAGE, OnGoToPage) - + ON_COMMAND(ID_MENU_VIEW_CONTRAST, OnToggleContrast) + ON_COMMAND(ID_MENU_VIEW_LARGEFONT, OnIncreaseFontSize) + ON_COMMAND(ID_MENU_VIEW_RESETFONT, OnResetFontSize) END_MESSAGE_MAP() @@ -364,6 +371,7 @@ } else { + //TODO: localize this AfxMessageBox(_T("Error opening book")); } } @@ -407,4 +415,18 @@ if (p_page) amis::dtb::DtbWithHooks::Instance()->loadNavNode(p_page); } } +} + +void CAmisGuiMFC2App::OnToggleContrast() +{ + bool is_contrast_on = amis::gui::TextRenderBrain::Instance()->toggleContrast(); + MenuManip::Instance()->setViewItemCheckmark(is_contrast_on, ID_MENU_VIEW_CONTRAST); +} +void CAmisGuiMFC2App::OnIncreaseFontSize() +{ + TextRenderBrain::Instance()->increaseFontSize(); +} +void CAmisGuiMFC2App::OnResetFontSize() +{ + TextRenderBrain::Instance()->resetFontSize(); } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/MainWndParts.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainWndParts.cpp 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/AmisGuiMFC2/src/gui/MainWndParts.cpp 2007-09-23 20:14:17 UTC (rev 2155) @@ -75,7 +75,7 @@ void MainWndParts::toggleSidebar() { mbSidebarVisible = !mbSidebarVisible; - MenuManip::Instance()->setSidebarItemCheckmark(mbSidebarVisible); + MenuManip::Instance()->setViewItemCheckmark(mbSidebarVisible, ID_MENU_VIEW_SIDEBAR_ONOFF); //if the window is hidden, show it if (!mpSidebar->ShowWindow(SW_SHOWNA)) mpMainFrame->ShowControlBar(mpSidebar, TRUE, TRUE); Modified: branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/AmisGuiMFC2/src/gui/MenuManip.cpp 2007-09-23 20:14:17 UTC (rev 2155) @@ -218,12 +218,16 @@ //info menu p_main_menu->EnableMenuItem(5, MF_BYPOSITION | MF_ENABLED); + //uncheck "high contrast" + bool is_contrast_on = TextRenderBrain::Instance()->isContrastOn(); + setViewItemCheckmark(is_contrast_on, ID_MENU_VIEW_CONTRAST); + setupNavigationOptions(); loadBookmarks(pBookmarks); } -void MenuManip::setSidebarItemCheckmark(bool isChecked) +void MenuManip::setViewItemCheckmark(bool isChecked, UINT itemId) { CMenu* p_menu = NULL; p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); @@ -232,8 +236,8 @@ p_menu = p_menu->GetSubMenu(1); assert(p_menu); - if (isChecked == true) p_menu->CheckMenuItem(ID_MENU_VIEW_SIDEBAR_ONOFF, MF_CHECKED); - else p_menu->CheckMenuItem(ID_MENU_VIEW_SIDEBAR_ONOFF, MF_UNCHECKED); + if (isChecked == true) p_menu->CheckMenuItem(itemId, MF_CHECKED); + else p_menu->CheckMenuItem(itemId, MF_UNCHECKED); } void MenuManip::addBookmark(amis::dtb::PositionMark* pBmk) @@ -245,6 +249,7 @@ CMenu* p_menu = NULL; CString menu_label; p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); + //get "bookmarks" p_menu = p_menu->GetSubMenu(4); amis::TextNode* p_text = NULL; Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2007-09-23 20:14:17 UTC (rev 2155) @@ -151,7 +151,7 @@ //refresh font size and contrast settings for the newly loaded page if (mFontSize > 0) setFontSize(mFontSize); - if (mbContrastOn) pageContrastOn(); + if (mbContrastOn) htmlContrastOn(); highlightElementAtId(mCurrentUrl.get_ref()); } @@ -285,30 +285,21 @@ } } -void TextRenderBrain::toggleContrast() +bool TextRenderBrain::isContrastOn() { + return mbContrastOn; +} +//turns the contrast on or off. returns the new state of the contrast (true = on) +bool TextRenderBrain::toggleContrast() +{ // MainWndParts::Instance()->mpSidebar->m_wndDlg.toggleContrast(); -// MainWndParts::Instance()->MenuManip()->setContrast(mb_flagContrast); -/* CMenu* p_menu = MainWndParts::Instance()->mpMainFrame->GetMenu(); - if (mb_flagContrast == true) - { - //uncheck the contrast item - p_menu->CheckMenuItem(ID_VIEW_CONTRAST, MF_UNCHECKED); - pageContrastOff(); - } - else - { - //check the contrast item - p_menu->CheckMenuItem(ID_VIEW_CONTRAST, MF_CHECKED); - pageContrastOn(); - } - */ + if (mbContrastOn) htmlContrastOff(); + else htmlContrastOn(); - if (mbContrastOn) pageContrastOff(); - else pageContrastOn(); + return mbContrastOn; } -void TextRenderBrain::pageContrastOn() +void TextRenderBrain::htmlContrastOn() { /* mb_flagContrast = true; string fg, bg; @@ -323,7 +314,7 @@ } -void TextRenderBrain::pageContrastOff() +void TextRenderBrain::htmlContrastOff() { /* mb_flagContrast = false; string fg, bg; @@ -358,8 +349,7 @@ //remove the old stylesheet MainWndParts::Instance()->mpHtmlView->removeStylesheet(mpFontCss); - if (fontsz) - MainWndParts::Instance()->mpHtmlView->applyStylesheet(&mFontSizeCssFiles[fontsz-1]); + if (fontsz) MainWndParts::Instance()->mpHtmlView->applyStylesheet(&mFontSizeCssFiles[fontsz-1]); if (isElementInView(pLastElm) == false) { @@ -454,7 +444,7 @@ // MainWndParts::Instance()->mpSidebar->m_wndDlg.repaintContrast(); //repaint the html view contrast if it had been enabled - if (mbContrastOn) this->pageContrastOn(); + if (mbContrastOn) htmlContrastOn(); } //otherwise turn the contrast off everywhere else @@ -463,7 +453,7 @@ // MainWndParts::Instance()->mpSidebar->m_wndDlg.turnContrastOff(); //turn off the html view contrast - this->pageContrastOff(); + htmlContrastOff(); } } //this is called to refresh the page colors Modified: branches/amis3/bin/settings/amis-contrast.css =================================================================== --- branches/amis3/bin/settings/amis-contrast.css 2007-09-23 00:05:58 UTC (rev 2154) +++ branches/amis3/bin/settings/amis-contrast.css 2007-09-23 20:14:17 UTC (rev 2155) @@ -1,3 +1,6 @@ /*contrast CSS sheet*/ body{ background-color: blue; color: white;} +h1 {color: green;} +a {text-decoration: none;} +a:hover {background-color: red;} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |