X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/169ee06c4473d63581b0b1ab04ef6d02c015fb09..b4d1ebf058c64f5b9e0ddf3264ce8a801eae4f79:/src/html/htmlwin.cpp diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index ab653caf7b..962fa16d1e 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -26,7 +26,6 @@ #endif #include "wx/html/htmlwin.h" - #include "wx/html/forcelnk.h" @@ -46,12 +45,12 @@ wxHtmlWindow::wxHtmlWindow(wxWindow *parent, wxWindowID id, const wxPoint& pos, { m_tmpMouseMoved = FALSE; m_tmpLastLink = wxEmptyString; - m_tmpCanDraw = TRUE; + m_tmpCanDrawLocks = 0; m_FS = new wxFileSystem(); m_RelatedStatusBar = -1; m_RelatedFrame = NULL; m_TitleFormat = "%s"; - m_OpenedPage = m_OpenedAnchor = wxEmptyString; + m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString; m_Cell = NULL; m_Parser = new wxHtmlWinParser(this); m_Parser -> SetFS(m_FS); @@ -96,8 +95,11 @@ void wxHtmlWindow::SetRelatedStatusBar(int bar) void wxHtmlWindow::SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, const int *sizes) { + wxString op = m_OpenedPage; + m_Parser -> SetFonts(normal_face, normal_italic_mode, fixed_face, fixed_italic_mode, sizes); - if (!m_OpenedPage.IsEmpty()) LoadPage(m_OpenedPage); + SetPage(wxT("")); // fonts changed => contents invalid + if (!op.IsEmpty()) LoadPage(op); } @@ -108,18 +110,18 @@ bool wxHtmlWindow::SetPage(const wxString& source) dc -> SetMapMode(wxMM_TEXT); SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF)); - m_OpenedPage = m_OpenedAnchor = wxEmptyString; + m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString; m_Parser -> SetDC(dc); if (m_Cell) { - delete m_Cell; - m_Cell = NULL; + delete m_Cell; + m_Cell = NULL; } m_Cell = (wxHtmlContainerCell*) m_Parser -> Parse(source); delete dc; m_Cell -> SetIndent(m_Borders, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS); m_Cell -> SetAlignHor(wxHTML_ALIGN_CENTER); CreateLayout(); - Refresh(); + if (m_tmpCanDrawLocks == 0) Refresh(); return TRUE; } @@ -132,7 +134,7 @@ bool wxHtmlWindow::LoadPage(const wxString& location) SetCursor(*wxHOURGLASS_CURSOR); wxYield(); - m_tmpCanDraw = FALSE; + m_tmpCanDrawLocks++; if (m_HistoryOn && (m_HistoryPos != -1)) { // store scroll position into history item int x, y; ViewStart(&x, &y); @@ -141,7 +143,7 @@ bool wxHtmlWindow::LoadPage(const wxString& location) if (location[0] == '#') { // local anchor wxString anch = location.Mid(1) /*1 to end*/; - m_tmpCanDraw = TRUE; + m_tmpCanDrawLocks--; rt_val = ScrollToAnchor(anch); } @@ -157,7 +159,7 @@ bool wxHtmlWindow::LoadPage(const wxString& location) wxString err; err.Printf(_("The browser is unable to open requested location :\n\n%s"), WXSTRINGCAST location); - m_tmpCanDraw = TRUE; + m_tmpCanDrawLocks--; Refresh(); wxMessageBox(err, "Error"); @@ -185,17 +187,17 @@ bool wxHtmlWindow::LoadPage(const wxString& location) node = node -> GetNext(); } if (src == wxEmptyString) { - if (m_DefaultFilter == NULL) m_DefaultFilter = GetDefaultFilter(); - src = m_DefaultFilter -> ReadFile(*f); - } + if (m_DefaultFilter == NULL) m_DefaultFilter = GetDefaultFilter(); + src = m_DefaultFilter -> ReadFile(*f); + } m_FS -> ChangePathTo(f -> GetLocation()); rt_val = SetPage(src); m_OpenedPage = f -> GetLocation(); if (f -> GetAnchor() != wxEmptyString) { - m_tmpCanDraw = TRUE; +// m_tmpCanDrawLocks--; ScrollToAnchor(f -> GetAnchor()); - m_tmpCanDraw = FALSE; +// m_tmpCanDrawLocks++; } delete f; @@ -215,7 +217,8 @@ bool wxHtmlWindow::LoadPage(const wxString& location) SetCursor(*wxSTANDARD_CURSOR); - m_tmpCanDraw = TRUE; + wxYield(); + m_tmpCanDrawLocks--; Refresh(); return rt_val; } @@ -237,13 +240,14 @@ bool wxHtmlWindow::ScrollToAnchor(const wxString& anchor) } -void wxHtmlWindow::SetTitle(const wxString& title) +void wxHtmlWindow::OnSetTitle(const wxString& title) { if (m_RelatedFrame) { wxString tit; tit.Printf(m_TitleFormat, title.c_str()); m_RelatedFrame -> SetTitle(tit); } + m_OpenedPageTitle = title; } @@ -270,17 +274,17 @@ void wxHtmlWindow::CreateLayout() #endif GetClientSize(&ClientWidth, &ClientHeight); m_Cell -> Layout(ClientWidth); - if (ClientHeight < m_Cell -> GetHeight()) { + if (ClientHeight < m_Cell -> GetHeight()) { SetScrollbars(wxHTML_SCROLL_STEP, wxHTML_SCROLL_STEP, m_Cell -> GetWidth() / wxHTML_SCROLL_STEP, m_Cell -> GetHeight() / wxHTML_SCROLL_STEP /*cheat: top-level frag is always container*/); } - else { /* we fit into window, no need for scrollbars */ - SetScrollbars(1, 1, 0, 0); // disable... - GetClientSize(&ClientWidth, &ClientHeight); - m_Cell -> Layout(ClientWidth); // ...and relayout - } + else { /* we fit into window, no need for scrollbars */ + SetScrollbars(1, 1, 0, 0); // disable... + GetClientSize(&ClientWidth, &ClientHeight); + m_Cell -> Layout(ClientWidth); // ...and relayout + } } } @@ -290,6 +294,9 @@ void wxHtmlWindow::ReadCustomization(wxConfigBase *cfg, wxString path) { wxString oldpath; wxString tmp; + int p_fontsizes[7]; + wxString p_fff, p_ffn; + int p_imf, p_imn; if (path != wxEmptyString) { oldpath = cfg -> GetPath(); @@ -297,14 +304,15 @@ void wxHtmlWindow::ReadCustomization(wxConfigBase *cfg, wxString path) } m_Borders = cfg -> Read("wxHtmlWindow/Borders", m_Borders); - m_Parser -> m_FontFaceFixed = cfg -> Read("wxHtmlWindow/FontFaceFixed", m_Parser -> m_FontFaceFixed); - m_Parser -> m_FontFaceNormal = cfg -> Read("wxHtmlWindow/FontFaceNormal", m_Parser -> m_FontFaceNormal); - m_Parser -> m_ItalicModeFixed = cfg -> Read("wxHtmlWindow/ItalicModeFixed", m_Parser -> m_ItalicModeFixed); - m_Parser -> m_ItalicModeNormal = cfg -> Read("wxHtmlWindow/ItalicModeNormal", m_Parser -> m_ItalicModeNormal); + p_fff = cfg -> Read("wxHtmlWindow/FontFaceFixed", m_Parser -> m_FontFaceFixed); + p_ffn = cfg -> Read("wxHtmlWindow/FontFaceNormal", m_Parser -> m_FontFaceNormal); + p_imf = cfg -> Read("wxHtmlWindow/ItalicModeFixed", m_Parser -> m_ItalicModeFixed); + p_imn = cfg -> Read("wxHtmlWindow/ItalicModeNormal", m_Parser -> m_ItalicModeNormal); for (int i = 0; i < 7; i++) { tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i); - m_Parser -> m_FontsSizes[i] = cfg -> Read(tmp, m_Parser -> m_FontsSizes[i]); + p_fontsizes[i] = cfg -> Read(tmp, m_Parser -> m_FontsSizes[i]); } + SetFonts(p_ffn, p_imn, p_fff, p_imf, p_fontsizes); if (path != wxEmptyString) cfg -> SetPath(oldpath); @@ -349,10 +357,13 @@ bool wxHtmlWindow::HistoryBack() l = m_History[m_HistoryPos].GetPage(); a = m_History[m_HistoryPos].GetAnchor(); m_HistoryOn = FALSE; + m_tmpCanDrawLocks++; if (a == wxEmptyString) LoadPage(l); else LoadPage(l + "#" + a); m_HistoryOn = TRUE; Scroll(0, m_History[m_HistoryPos].GetPos()); +// wxYield(); + m_tmpCanDrawLocks--; Refresh(); return TRUE; } @@ -372,10 +383,13 @@ bool wxHtmlWindow::HistoryForward() l = m_History[m_HistoryPos].GetPage(); a = m_History[m_HistoryPos].GetAnchor(); m_HistoryOn = FALSE; + m_tmpCanDrawLocks++; if (a == wxEmptyString) LoadPage(l); else LoadPage(l + "#" + a); m_HistoryOn = TRUE; Scroll(0, m_History[m_HistoryPos].GetPos()); +// wxYield(); + m_tmpCanDrawLocks--; Refresh(); return TRUE; } @@ -425,7 +439,7 @@ void wxHtmlWindow::OnDraw(wxDC& dc) wxRegionIterator upd(GetUpdateRegion()); // get the update rect list int v_y, v_h; - if (!m_tmpCanDraw) return; + if (m_tmpCanDrawLocks > 0) return; dc.SetMapMode(wxMM_TEXT); #if defined(_MSC_VER) && (_MSC_VER == 1200) ::SetMapMode((HDC)dc.GetHDC(), MM_TEXT);