]> git.saurik.com Git - wxWidgets.git/commitdiff
preserve window's content when changing the fonts
authorVáclav Slavík <vslavik@fastmail.fm>
Tue, 7 Mar 2006 18:31:49 +0000 (18:31 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Tue, 7 Mar 2006 18:31:49 +0000 (18:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index 389e2211ec6d9a76c3a07aee2eab2c043389e254..719173bedbaf763cd890b3a9608dc83542465bb1 100644 (file)
@@ -269,9 +269,13 @@ protected:
     void StopAutoScrolling();
 #endif // wxUSE_CLIPBOARD
 
-protected:
     wxString DoSelectionToText(wxHtmlSelection *sel);
 
+private:
+    // implementation of SetPage()
+    bool DoSetPage(const wxString& source);
+
+protected:
     // This is pointer to the first cell in parsed data.  (Note: the first cell
     // is usually top one = all other cells are sub-cells of this one)
     wxHtmlContainerCell *m_Cell;
index 7654b4b86282455c5365a3c213c075e3f556127b..fc42f4cb5ae77528d3595dee823fa3340cb2beab 100644 (file)
@@ -237,30 +237,29 @@ void wxHtmlWindow::SetRelatedStatusBar(int bar)
 
 void wxHtmlWindow::SetFonts(const wxString& normal_face, const wxString& fixed_face, const int *sizes)
 {
-    wxString op = m_OpenedPage;
-
     m_Parser->SetFonts(normal_face, fixed_face, sizes);
-    // fonts changed => contents invalid, so reload the page:
-    SetPage(wxT("<html><body></body></html>"));
-    if (!op.empty())
-        LoadPage(op);
+
+    // re-layout the page after changing fonts:
+    DoSetPage(*(m_Parser->GetSource()));
 }
 
 void wxHtmlWindow::SetStandardFonts(int size,
                                     const wxString& normal_face,
                                     const wxString& fixed_face)
 {
-    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);
-}
 
+    // re-layout the page after changing fonts:
+    DoSetPage(*(m_Parser->GetSource()));
+}
 
 bool wxHtmlWindow::SetPage(const wxString& source)
+{
+    m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString;
+    return DoSetPage(source);
+}
+
+bool wxHtmlWindow::DoSetPage(const wxString& source)
 {
     wxString newsrc(source);
 
@@ -307,7 +306,7 @@ bool wxHtmlWindow::SetPage(const wxString& source)
     dc->SetMapMode(wxMM_TEXT);
     SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF));
     SetBackgroundImage(wxNullBitmap);
-    m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString;
+
     m_Parser->SetDC(dc);
     if (m_Cell)
     {
@@ -326,7 +325,7 @@ bool wxHtmlWindow::SetPage(const wxString& source)
 
 bool wxHtmlWindow::AppendToPage(const wxString& source)
 {
-    return SetPage(*(GetParser()->GetSource()) + source);
+    return DoSetPage(*(GetParser()->GetSource()) + source);
 }
 
 bool wxHtmlWindow::LoadPage(const wxString& location)