preserve window's content when changing the fonts

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2006-03-07 18:31:49 +00:00
parent 3568f700f6
commit 73de5077ce
2 changed files with 19 additions and 16 deletions

View File

@@ -269,9 +269,13 @@ protected:
void StopAutoScrolling(); void StopAutoScrolling();
#endif // wxUSE_CLIPBOARD #endif // wxUSE_CLIPBOARD
protected:
wxString DoSelectionToText(wxHtmlSelection *sel); 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 // 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) // is usually top one = all other cells are sub-cells of this one)
wxHtmlContainerCell *m_Cell; wxHtmlContainerCell *m_Cell;

View File

@@ -237,30 +237,29 @@ void wxHtmlWindow::SetRelatedStatusBar(int bar)
void wxHtmlWindow::SetFonts(const wxString& normal_face, const wxString& fixed_face, const int *sizes) 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); m_Parser->SetFonts(normal_face, fixed_face, sizes);
// fonts changed => contents invalid, so reload the page:
SetPage(wxT("<html><body></body></html>")); // re-layout the page after changing fonts:
if (!op.empty()) DoSetPage(*(m_Parser->GetSource()));
LoadPage(op);
} }
void wxHtmlWindow::SetStandardFonts(int size, void wxHtmlWindow::SetStandardFonts(int size,
const wxString& normal_face, const wxString& normal_face,
const wxString& fixed_face) const wxString& fixed_face)
{ {
wxString op = m_OpenedPage;
m_Parser->SetStandardFonts(size, normal_face, fixed_face); m_Parser->SetStandardFonts(size, normal_face, fixed_face);
// fonts changed => contents invalid, so reload the page:
SetPage(wxT("<html><body></body></html>")); // re-layout the page after changing fonts:
if (!op.empty()) DoSetPage(*(m_Parser->GetSource()));
LoadPage(op);
} }
bool wxHtmlWindow::SetPage(const wxString& source) 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); wxString newsrc(source);
@@ -307,7 +306,7 @@ bool wxHtmlWindow::SetPage(const wxString& source)
dc->SetMapMode(wxMM_TEXT); dc->SetMapMode(wxMM_TEXT);
SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF)); SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF));
SetBackgroundImage(wxNullBitmap); SetBackgroundImage(wxNullBitmap);
m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString;
m_Parser->SetDC(dc); m_Parser->SetDC(dc);
if (m_Cell) if (m_Cell)
{ {
@@ -326,7 +325,7 @@ bool wxHtmlWindow::SetPage(const wxString& source)
bool wxHtmlWindow::AppendToPage(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) bool wxHtmlWindow::LoadPage(const wxString& location)