Update of /cvsroot/mahogany/M/src/modules
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3948/src/modules

Modified Files:
        HtmlViewer.cpp TextViewer.cpp 
Log Message:
better/more general fix for the font-overriding problem:
 1. added new CreateFontFromDesc() function (and put it new wxMGuiUtils.cpp
    together with EnsureAvailableTextEncoding() which used to be in
    wxMApp.cpp)
 2. default font family and size are now wxDEFAULT/-1
 3. use CreateFontFromDesc() from message view, composer and folder view
    and don't use the returned font if it's invalid


Index: HtmlViewer.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/HtmlViewer.cpp,v
retrieving revision 1.77
retrieving revision 1.78
diff -b -u -2 -r1.77 -r1.78
--- HtmlViewer.cpp      27 Jun 2006 00:35:07 -0000      1.77
+++ HtmlViewer.cpp      19 Aug 2006 13:12:00 -0000      1.78
@@ -141,6 +141,6 @@
    void AddColourAttr(const wxChar *attr, const wxColour& col);
 
-   // calculate font size
-   int CalculateFontSize(int diff);
+   // calculate HTML font size for the given font
+   int CalculateFontSize(const wxFont& font);
 
    // get the name of the virtual file for the n-th image we use
@@ -845,10 +845,17 @@
 }
 
-int HtmlViewer::CalculateFontSize(int diff)
+int HtmlViewer::CalculateFontSize(const wxFont& font)
 {
+   if ( !font.Ok() )
+   {
+      // use default size
+      return 0;
+   }
+
    // map the point size into the HTML font size so that if the standard font
    // size is 12pt, 6pt is very small and 24pt is very big
    //
    // this is not very rigorous, of course...
+   int diff = font.GetPointSize() - wxNORMAL_FONT->GetPointSize();
    if ( diff > 0 )
       diff /= 4;
@@ -902,7 +909,6 @@
    m_htmlText += _T(">");
 
-   wxFont font = profileValues.GetFont();
-
-   int diff = CalculateFontSize(font.GetPointSize() - DEFAULT_FONT_SIZE);
+   wxFont font(profileValues.GetFont());
+   int diff = CalculateFontSize(font);
    if ( diff )
    {
@@ -914,5 +920,5 @@
    //
    // TODO: use <font face="...">
-   if ( font.IsFixedWidth() )
+   if ( font.Ok() && font.IsFixedWidth() )
    {
       m_htmlText << _T("<tt>");
@@ -926,8 +932,5 @@
 void HtmlViewer::ShowRawHeaders(const String& header)
 {
-   const ProfileValues& profileValues = GetOptions();
-   wxFont font = profileValues.GetFont();
-
-   int diff = CalculateFontSize(font.GetPointSize() - DEFAULT_FONT_SIZE);
+   int diff = CalculateFontSize(GetOptions().GetFont());
    m_htmlText << _T("<pre>") << _T("<font size=") << 
wxString::Format(_T("%+d"), diff) << _T(">")
               << MakeHtmlSafe(header) << _T("</font>") << _T("</pre>");

Index: TextViewer.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/TextViewer.cpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -b -u -2 -r1.67 -r1.68
--- TextViewer.cpp      16 Jan 2006 20:32:28 -0000      1.67
+++ TextViewer.cpp      19 Aug 2006 13:12:00 -0000      1.68
@@ -550,5 +550,7 @@
    const ProfileValues& profileValues = GetOptions();
 
-   m_window->SetFont(profileValues.GetFont());
+   wxFont font(profileValues.GetFont());
+   if ( font.Ok() )
+      m_window->SetFont(font);
    m_window->SetForegroundColour(profileValues.FgCol);
    m_window->SetBackgroundColour(profileValues.BgCol);


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to