[Amis-vcs] SF.net SVN: amis: [2405] branches/amis3
Brought to you by:
julienq,
marisademeglio
From: <mar...@us...> - 2008-03-13 23:44:12
|
Revision: 2405 http://amis.svn.sourceforge.net/amis/?rev=2405&view=rev Author: marisademeglio Date: 2008-03-13 16:44:17 -0700 (Thu, 13 Mar 2008) Log Message: ----------- Updates to text style dialog. It's almost working. Modified Paths: -------------- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h branches/amis3/AmisGuiMFC2/include/gui/dialogs/TextStyleDialog.h branches/amis3/AmisGuiMFC2/include/util/Color.h branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp branches/amis3/AmisGuiMFC2/src/gui/dialogs/TextStyleDialog.cpp branches/amis3/AmisGuiMFC2/src/util/Color.cpp branches/amis3/bin/settings/css/amis.css Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-12 03:45:11 UTC (rev 2404) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-03-13 23:44:17 UTC (rev 2405) @@ -418,17 +418,18 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN LTEXT "Font:",IDC_FONTLABEL,7,7,155,12 - COMBOBOX IDC_FONT,7,20,155,30,CBS_DROPDOWN | CBS_SORT | + COMBOBOX IDC_FONT,7,20,155,63,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP LTEXT "Highlighted text color:",IDC_HIGHLIGHTFOREGROUNDLABEL,7, 45,155,11 - COMBOBOX IDC_HIGHLIGHTFOREGROUND,7,57,155,30,CBS_DROPDOWN | - CBS_SORT | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_HIGHLIGHTFOREGROUND,7,57,155,63,CBS_DROPDOWN | + WS_VSCROLL | WS_TABSTOP LTEXT "Highlight background color:", IDC_HIGHLIGHTBACKGROUNDLABEL,7,83,156,8 - COMBOBOX IDC_HIGHLIGHTBACKGROUND,7,98,156,12,CBS_DROPDOWN | - CBS_SORT | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_TEXTSTYLEPREVIEW,211,7,175,135,ES_AUTOHSCROLL + COMBOBOX IDC_HIGHLIGHTBACKGROUND,7,98,156,52,CBS_DROPDOWN | + WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_TEXTSTYLEPREVIEW,211,7,175,135,ES_MULTILINE | + ES_AUTOHSCROLL DEFPUSHBUTTON "OK",IDOK,39,128,50,14 PUSHBUTTON "Cancel",IDCANCEL,101,128,50,14 END Modified: branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-12 03:45:11 UTC (rev 2404) +++ branches/amis3/AmisGuiMFC2/include/gui/AmisApp.h 2008-03-13 23:44:17 UTC (rev 2405) @@ -106,6 +106,7 @@ afx_msg void OnClearPageStyle(); afx_msg void OnApplyPageStyle(UINT); afx_msg void OnNextPageStyle(); + afx_msg void OnShowTextStyle(); protected: HMENU m_hMDIMenu; HACCEL m_hMDIAccel; Modified: branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2008-03-12 03:45:11 UTC (rev 2404) +++ branches/amis3/AmisGuiMFC2/include/gui/TextRenderBrain.h 2008-03-13 23:44:17 UTC (rev 2405) @@ -56,6 +56,7 @@ void gotoUriTarget(amis::TextNode*); void gotoUriTarget(std::string url); + void saveDefaultCss(); void applyPageStyle(int); void clearPageStyle(); void applyNextPageStyle(); Modified: branches/amis3/AmisGuiMFC2/include/gui/dialogs/TextStyleDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/TextStyleDialog.h 2008-03-12 03:45:11 UTC (rev 2404) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/TextStyleDialog.h 2008-03-13 23:44:17 UTC (rev 2405) @@ -24,6 +24,7 @@ #include "gui/dialogs/AmisDialogBase.h" #include "../resource.h" +#include "util/Color.h" BOOL CALLBACK EnumFontCallback (LPLOGFONT, LPTEXTMETRIC, DWORD, LPARAM); @@ -33,14 +34,15 @@ { namespace dialogs { - class TextStyleDialog : public AmisDialogBase { public: TextStyleDialog(CWnd* pParent = NULL); ~TextStyleDialog(); enum { IDD = IDD_TEXTSTYLE }; - + amis::util::Color getHighlightForegroundColor(); + amis::util::Color getHighlightBackgroundColor(); + std::string getFontName(); protected: void initializeCombos(); virtual BOOL OnInitDialog(); @@ -54,6 +56,10 @@ protected: afx_msg void OnPaint(); DECLARE_MESSAGE_MAP() +private: + amis::util::Color mHighlightBG; + amis::util::Color mHighlightFG; + std::string mFontName; }; } } Modified: branches/amis3/AmisGuiMFC2/include/util/Color.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/util/Color.h 2008-03-12 03:45:11 UTC (rev 2404) +++ branches/amis3/AmisGuiMFC2/include/util/Color.h 2008-03-13 23:44:17 UTC (rev 2405) @@ -41,6 +41,7 @@ Color(COLORREF); void set(std::string); void set(COLORREF); + void setWithHtmlName(std::string); COLORREF getAsColorRef(); std::string getAsHtmlHexColor(); std::string getHexValueForNamedColor(std::string); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-12 03:45:11 UTC (rev 2404) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-13 23:44:17 UTC (rev 2405) @@ -54,6 +54,7 @@ #include "gui/dialogs/MultipleBooksOnVolumeDialog.h" #include "gui/dialogs/PreferencesDialog.h" #include "gui/dialogs/PublicationSummaryDialog.h" +#include "gui/dialogs/TextStyleDialog.h" #include "gui/self-voicing/directshow/dx_audio_player.h" @@ -113,6 +114,7 @@ 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) + ON_COMMAND(ID_AMIS_SHOW_TEXTSTYLE, OnShowTextStyle) END_MESSAGE_MAP() CAmisApp::CAmisApp() @@ -809,6 +811,19 @@ { TextRenderBrain::Instance()->applyNextPageStyle(); } +void CAmisApp::OnShowTextStyle() +{ + amis::gui::dialogs::TextStyleDialog dlg; + if (dlg.DoModal() == IDOK) + { + Preferences::Instance()->mHighlightBG = dlg.getHighlightBackgroundColor(); + Preferences::Instance()->mHighlightFG = dlg.getHighlightForegroundColor(); + Preferences::Instance()->mFontName = dlg.getFontName(); + TextRenderBrain::Instance()->saveDefaultCss(); + TextRenderBrain::Instance()->redoPageColors(); + } +} + /*************************************************** * (MED) I moved these functions out of the menu handler area *****************************************************/ Modified: branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-03-12 03:45:11 UTC (rev 2404) +++ branches/amis3/AmisGuiMFC2/src/gui/TextRenderBrain.cpp 2008-03-13 23:44:17 UTC (rev 2405) @@ -288,6 +288,22 @@ { return mCurrentStyleIdx; } +//take the values in Preferences and write them to file +void TextRenderBrain::saveDefaultCss() +{ + string fg = Preferences::Instance()->mHighlightFG.getAsHtmlHexColor(); + string bg = Preferences::Instance()->mHighlightBG.getAsHtmlHexColor(); + string font = Preferences::Instance()->mFontName; + ofstream cssfile; + cssfile.open(Preferences::Instance()->getAmisCssFile()->get_file().c_str(), ios::out); + cssfile<<"/*default CSS sheet*/"<<endl; + cssfile<<"/*DO NOT EDIT! YOUR CHANGES WILL BE LOST!*/"<<endl; + cssfile<<"/*\"amis-highlight\" is a reserved word that AMIS will look for to find the highlight colors*/"<<endl; + cssfile<<"/*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*/"<<endl; + cssfile<<".amis-highlight {color: "<<fg<<"; background-color: "<<bg<<";}"<<endl; + cssfile<<"body {font-family: "<<font<<";}"<<endl; + cssfile.close(); +} void TextRenderBrain::applyPageStyle(int idx) { clearPageStyle(); Modified: branches/amis3/AmisGuiMFC2/src/gui/dialogs/TextStyleDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/TextStyleDialog.cpp 2008-03-12 03:45:11 UTC (rev 2404) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/TextStyleDialog.cpp 2008-03-13 23:44:17 UTC (rev 2405) @@ -26,6 +26,7 @@ #include "AmisCore.h" #include "util/Color.h" #include "Preferences.h" +#include "..\..\..\include\gui\dialogs\textstyledialog.h" using namespace amis::gui::dialogs; @@ -38,7 +39,7 @@ ON_CBN_SETFOCUS(IDC_HIGHLIGHTFOREGROUND, OnCbnSetfocusHighlightForeground) ON_CBN_SELCHANGE(IDC_HIGHLIGHTBACKGROUND, OnCbnSelchangeHighlightBackground) ON_CBN_SETFOCUS(IDC_HIGHLIGHTBACKGROUND, OnCbnSetfocusHighlightBackground) - ON_WM_PAINT() + ON_WM_PAINT() END_MESSAGE_MAP() BOOL CALLBACK EnumFontCallback (LPLOGFONT lplf, LPTEXTMETRIC lptm, DWORD dwType, LPARAM lpData) @@ -57,6 +58,9 @@ } BOOL TextStyleDialog::OnInitDialog() { + mFontName = Preferences::Instance()->mFontName; + mHighlightBG = Preferences::Instance()->mHighlightBG; + mHighlightFG = Preferences::Instance()->mHighlightFG; initializeCombos(); return CDialog::OnInitDialog(); } @@ -77,14 +81,16 @@ int background_sel = -1; int i = 0; amis::StringMap::iterator it = p_all_colors->begin(); + std::string highlight_bg = Preferences::Instance()->mHighlightBG.getAsHtmlHexColor(); + std::string highlight_fg = Preferences::Instance()->mHighlightFG.getAsHtmlHexColor(); while (it != p_all_colors->end()) { CString label = A2T(it->first.c_str()); p_foreground_list->AddString(label); p_background_list->AddString(label); - if (it->second == Preferences::Instance()->mHighlightBG.getAsHtmlHexColor()) + if (it->second == highlight_bg) background_sel = i; - if (it->second == Preferences::Instance()->mHighlightFG.getAsHtmlHexColor()) + if (it->second == highlight_fg) foreground_sel = i; i++; it++; @@ -93,7 +99,7 @@ p_background_list->SetCurSel(background_sel); CClientDC dc(this); - EnumFonts (dc, 0,(FONTENUMPROC)EnumFontCallback,(LPARAM)this); + EnumFonts (dc, 0,(FONTENUMPROC)EnumFontCallback,(LPARAM)this->GetDlgItem(IDC_FONT)); } void TextStyleDialog::OnPaint() { @@ -124,22 +130,55 @@ return AmisDialogBase::PreTranslateMessage(pMsg); } +amis::util::Color TextStyleDialog::getHighlightForegroundColor() +{ + return mHighlightFG; +} + +amis::util::Color TextStyleDialog::getHighlightBackgroundColor() +{ + return mHighlightBG; +} + +std::string TextStyleDialog::getFontName() +{ + return mFontName; +} + //widget event handlers void TextStyleDialog::OnCbnSelchangeFont() { + USES_CONVERSION; + CString tmp; + CComboBox* p_font_list = (CComboBox*)GetDlgItem(IDC_FONT); + p_font_list->GetWindowText(tmp); + mFontName = T2A(tmp); } void TextStyleDialog::OnCbnSetfocusFont() { } void TextStyleDialog::OnCbnSelchangeHighlightForeground() { + USES_CONVERSION; + CString tmp; + CComboBox* p_foreground_list = (CComboBox*)GetDlgItem(IDC_HIGHLIGHTFOREGROUND); + + p_foreground_list->GetWindowText(tmp); + if (tmp == "") tmp = "black"; + mHighlightFG.setWithHtmlName(T2A(tmp)); } void TextStyleDialog::OnCbnSetfocusHighlightForeground() { } void TextStyleDialog::OnCbnSelchangeHighlightBackground() { + USES_CONVERSION; + CString tmp; + CComboBox* p_background_list = (CComboBox*)GetDlgItem(IDC_HIGHLIGHTBACKGROUND); + p_background_list->GetWindowText(tmp); + if (tmp == "") tmp = "yellow"; + mHighlightBG.setWithHtmlName(T2A(tmp)); } void TextStyleDialog::OnCbnSetfocusHighlightBackground() { -} \ No newline at end of file +} Modified: branches/amis3/AmisGuiMFC2/src/util/Color.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/util/Color.cpp 2008-03-12 03:45:11 UTC (rev 2404) +++ branches/amis3/AmisGuiMFC2/src/util/Color.cpp 2008-03-13 23:44:17 UTC (rev 2405) @@ -192,6 +192,11 @@ mColor = htmlToRgb(value); } +void Color::setWithHtmlName(std::string value) +{ + mColorHtml = mColorHexMap[value]; + mColor = htmlToRgb(value); +} void Color::set(COLORREF value) { mColor = value; Modified: branches/amis3/bin/settings/css/amis.css =================================================================== --- branches/amis3/bin/settings/css/amis.css 2008-03-12 03:45:11 UTC (rev 2404) +++ branches/amis3/bin/settings/css/amis.css 2008-03-13 23:44:17 UTC (rev 2405) @@ -1,5 +1,6 @@ /*default CSS sheet*/ +/*DO NOT EDIT! YOUR CHANGES WILL BE LOST!*/ /*"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: black; background-color: yellow} -body {font-family: arial, verdana, sans-serif;} \ No newline at end of file +.amis-highlight {color: #000000; background-color: #FFFF00;} +body {font-family: verdana;} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |