]> git.saurik.com Git - wxWidgets.git/commitdiff
replaced NormalizeFontSizes with SetStandardFonts
authorVáclav Slavík <vslavik@fastmail.fm>
Fri, 24 Sep 2004 09:55:10 +0000 (09:55 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Fri, 24 Sep 2004 09:55:10 +0000 (09:55 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29313 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/html/htmlwin.h
include/wx/html/htmprint.h
include/wx/html/winpars.h
src/html/htmlwin.cpp
src/html/htmprint.cpp
src/html/winpars.cpp

index 62f044657310a876a5a7611d5aebf68c0c7a35ed..f2cee731bb075807e378c6920e98846fb34f8f27 100644 (file)
@@ -130,8 +130,11 @@ public:
     void SetFonts(wxString normal_face, wxString fixed_face,
                   const int *sizes = NULL);
 
-    // Sets font sizes to be relative to the given size or the system default size
-    void NormalizeFontSizes(int size=-1);
+    // Sets font sizes to be relative to the given size or the system
+    // default size; use either specified or default font
+    void SetStandardFonts(int size = -1,
+                          const wxString& normal_face = wxEmptyString,
+                          const wxString& fixed_face = wxEmptyString);
     
     // Sets space between text and window borders.
     void SetBorders(int b) {m_Borders = b;}
index e2a27bc59b8d0e5d57af47f648805266dd2977ea..393e4da0e3311ef194951f873f2b79a6c73901fe 100644 (file)
@@ -59,8 +59,11 @@ public:
     // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
     void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes = NULL);
 
-    // Sets font sizes to be relative to the given size or the system default size
-    void NormalizeFontSizes(int size=-1);
+    // Sets font sizes to be relative to the given size or the system
+    // default size; use either specified or default font
+    void SetStandardFonts(int size = -1,
+                          const wxString& normal_face = wxEmptyString,
+                          const wxString& fixed_face = wxEmptyString);
 
     // [x,y] is position of upper-left corner of printing rectangle (see SetSize)
     // from is y-coordinate of the very first visible cell
@@ -145,8 +148,11 @@ public:
     // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
     void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes = NULL);
 
-    // Sets font sizes to be relative to the given size or the system default size
-    void NormalizeFontSizes(int size=-1);
+    // Sets font sizes to be relative to the given size or the system
+    // default size; use either specified or default font
+    void SetStandardFonts(int size = -1,
+                          const wxString& normal_face = wxEmptyString,
+                          const wxString& fixed_face = wxEmptyString);
 
     void SetMargins(float top = 25.2, float bottom = 25.2, float left = 25.2, float right = 25.2, 
                     float spaces = 5);
@@ -243,8 +249,11 @@ public:
     void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes = 0);
     // Sets fonts to be used when displaying HTML page. (if size null then default sizes used)
 
-    void NormalizeFontSizes(int size=-1);
-    // Sets font sizes to be relative to the given size or the system default size
+    // Sets font sizes to be relative to the given size or the system
+    // default size; use either specified or default font
+    void SetStandardFonts(int size = -1,
+                          const wxString& normal_face = wxEmptyString,
+                          const wxString& fixed_face = wxEmptyString);
     
     wxPrintData *GetPrintData();
     wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
@@ -263,6 +272,14 @@ private:
     int m_FontsSizesArr[7];
     int *m_FontsSizes;
     wxString m_FontFaceFixed, m_FontFaceNormal;
+
+    enum FontMode
+    {
+        FontMode_Explicit,
+        FontMode_Standard
+    };
+    FontMode m_fontMode;
+    
     wxString m_Headers[2], m_Footers[2];
     wxWindow *m_ParentWindow;
 
index 67217628f8734c3832247d826596265162a300e7..fd60faf187eeb49fe926e0631d1626003cdab1be 100644 (file)
@@ -72,8 +72,11 @@ public:
     // Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
     void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes = NULL);
 
-    // Sets font sizes to be relative to the given size or the system default size
-    void NormalizeFontSizes(int size=-1);
+    // Sets font sizes to be relative to the given size or the system
+    // default size; use either specified or default font
+    void SetStandardFonts(int size = -1,
+                          const wxString& normal_face = wxEmptyString,
+                          const wxString& fixed_face = wxEmptyString);
     
     // Adds tags module. see wxHtmlTagsModule for details.
     static void AddModule(wxHtmlTagsModule *module);
index 0068fec835793f4927829c8fda4ea58846001ea5..b140267e3c5a8f6f7507a0d7c26580bf70411949 100644 (file)
@@ -246,24 +246,21 @@ void wxHtmlWindow::SetFonts(wxString normal_face, wxString fixed_face, const int
     m_Parser->SetFonts(normal_face, fixed_face, sizes);
     // fonts changed => contents invalid, so reload the page:
     SetPage(wxT("<html><body></body></html>"));
-    if (!op.IsEmpty()) LoadPage(op);
+    if (!op.empty())
+        LoadPage(op);
 }
 
-void wxHtmlWindow::NormalizeFontSizes(int size)
+void wxHtmlWindow::SetStandardFonts(int size,
+                                    const wxString& normal_face,
+                                    const wxString& fixed_face)
 {
-    int f_sizes[7];
-    if (size == -1)
-        size = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize();
-
-    f_sizes[0] = int(size * 0.6);
-    f_sizes[1] = int(size * 0.8);
-    f_sizes[2] = size;
-    f_sizes[3] = int(size * 1.2);
-    f_sizes[4] = int(size * 1.4);
-    f_sizes[5] = int(size * 1.6);
-    f_sizes[6] = int(size * 1.8);
-    
-    SetFonts(wxEmptyString, wxEmptyString, f_sizes);
+    wxString op = m_OpenedPage;
+
+    m_Parser->SetStandardFonts(size, normal_face, fixed_face);
+    // fonts changed => contents invalid, so reload the page:
+    SetPage(wxT("<html><body></body></html>"));
+    if (!op.empty())
+        LoadPage(op);
 }
 
 
index 4e91a6baaf5eb46590f5942d74e282948253210a..d9623d0a6e413d6970f7fa1780eb603c88dbf835 100644 (file)
@@ -98,25 +98,17 @@ void wxHtmlDCRenderer::SetFonts(wxString normal_face, wxString fixed_face,
                                 const int *sizes)
 {
     m_Parser->SetFonts(normal_face, fixed_face, sizes);
-    if (m_DC == NULL && m_Cells != NULL) m_Cells->Layout(m_Width);
+    if (m_DC == NULL && m_Cells != NULL)
+        m_Cells->Layout(m_Width);
 }
 
-
-void wxHtmlDCRenderer::NormalizeFontSizes(int size)
+void wxHtmlDCRenderer::SetStandardFonts(int size,
+                                        const wxString& normal_face,
+                                        const wxString& fixed_face)
 {
-    int f_sizes[7];
-    if (size == -1)
-        size = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize();
-
-    f_sizes[0] = int(size * 0.6);
-    f_sizes[1] = int(size * 0.8);
-    f_sizes[2] = size;
-    f_sizes[3] = int(size * 1.2);
-    f_sizes[4] = int(size * 1.4);
-    f_sizes[5] = int(size * 1.6);
-    f_sizes[6] = int(size * 1.8);
-    
-    SetFonts(wxEmptyString, wxEmptyString, f_sizes);
+    m_Parser->SetStandardFonts(size, normal_face, fixed_face);
+    if (m_DC == NULL && m_Cells != NULL)
+        m_Cells->Layout(m_Width);
 }
 
 
@@ -470,22 +462,12 @@ void wxHtmlPrintout::SetFonts(wxString normal_face, wxString fixed_face,
     m_RendererHdr->SetFonts(normal_face, fixed_face, sizes);
 }
 
-
-void wxHtmlPrintout::NormalizeFontSizes(int size)
+void wxHtmlPrintout::SetStandardFonts(int size,
+                                      const wxString& normal_face,
+                                      const wxString& fixed_face)
 {
-    int f_sizes[7];
-    if (size == -1)
-        size = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize();
-
-    f_sizes[0] = int(size * 0.6);
-    f_sizes[1] = int(size * 0.8);
-    f_sizes[2] = size;
-    f_sizes[3] = int(size * 1.2);
-    f_sizes[4] = int(size * 1.4);
-    f_sizes[5] = int(size * 1.6);
-    f_sizes[6] = int(size * 1.8);
-    
-    SetFonts(wxEmptyString, wxEmptyString, f_sizes);
+    m_Renderer->SetStandardFonts(size, normal_face, fixed_face);
+    m_RendererHdr->SetStandardFonts(size, normal_face, fixed_face);
 }
 
 
@@ -664,6 +646,7 @@ void wxHtmlEasyPrinting::SetFooter(const wxString& footer, int pg)
 void wxHtmlEasyPrinting::SetFonts(wxString normal_face, wxString fixed_face,
                                   const int *sizes)
 {
+    m_fontMode = FontMode_Explicit;
     m_FontFaceNormal = normal_face;
     m_FontFaceFixed = fixed_face;
 
@@ -676,21 +659,14 @@ void wxHtmlEasyPrinting::SetFonts(wxString normal_face, wxString fixed_face,
         m_FontsSizes = NULL;
 }
 
-void wxHtmlEasyPrinting::NormalizeFontSizes(int size)
+void wxHtmlEasyPrinting::SetStandardFonts(int size,
+                                          const wxString& normal_face,
+                                          const wxString& fixed_face)
 {
-    int f_sizes[7];
-    if (size == -1)
-        size = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize();
-
-    f_sizes[0] = int(size * 0.6);
-    f_sizes[1] = int(size * 0.8);
-    f_sizes[2] = size;
-    f_sizes[3] = int(size * 1.2);
-    f_sizes[4] = int(size * 1.4);
-    f_sizes[5] = int(size * 1.6);
-    f_sizes[6] = int(size * 1.8);
-    
-    SetFonts(wxEmptyString, wxEmptyString, f_sizes);
+    m_fontMode = FontMode_Standard;
+    m_FontFaceNormal = normal_face;
+    m_FontFaceFixed = fixed_face;
+    m_FontsSizesArr[0] = size;
 }
 
 
@@ -698,7 +674,15 @@ wxHtmlPrintout *wxHtmlEasyPrinting::CreatePrintout()
 {
     wxHtmlPrintout *p = new wxHtmlPrintout(m_Name);
 
-    p->SetFonts(m_FontFaceNormal, m_FontFaceFixed, m_FontsSizes);
+    if (m_fontMode == FontMode_Explicit)
+    {
+        p->SetFonts(m_FontFaceNormal, m_FontFaceFixed, m_FontsSizes);
+    }
+    else // FontMode_Standard
+    {
+        p->SetStandardFonts(m_FontsSizesArr[0],
+                            m_FontFaceNormal, m_FontFaceFixed);
+    }
 
     p->SetHeader(m_Headers[0], wxPAGE_EVEN);
     p->SetHeader(m_Headers[1], wxPAGE_ODD);
index 77769c411f2e9f44480e97780230d7710888f8ed..087c236a0713da22eab13d699854227d7ffbc0f7 100644 (file)
@@ -154,11 +154,15 @@ void wxHtmlWinParser::SetFonts(wxString normal_face, wxString fixed_face,
                     }
 }
 
-void wxHtmlWinParser::NormalizeFontSizes(int size)
+void wxHtmlWinParser::SetStandardFonts(int size,
+                                       const wxString& normal_face,
+                                       const wxString& fixed_face)
 {
+    wxFont defaultFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
+    
     int f_sizes[7];
     if (size == -1)
-        size = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize();
+        size = defaultFont.GetPointSize();
 
     f_sizes[0] = int(size * 0.6);
     f_sizes[1] = int(size * 0.8);
@@ -167,8 +171,11 @@ void wxHtmlWinParser::NormalizeFontSizes(int size)
     f_sizes[4] = int(size * 1.4);
     f_sizes[5] = int(size * 1.6);
     f_sizes[6] = int(size * 1.8);
+
+    wxString normal = normal_face.empty() ? 
+                      defaultFont.GetFaceName() : normal_face;
     
-    SetFonts(wxEmptyString, wxEmptyString, f_sizes);
+    SetFonts(normal, fixed_face, f_sizes);
 }
 
 void wxHtmlWinParser::InitParser(const wxString& source)