// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "htmlwin.h"
-#pragma implementation "htmlproc.h"
-#endif
-
#include "wx/wxprec.h"
#include "wx/defs.h"
//-----------------------------------------------------------------------------
WX_DECLARE_OBJARRAY(wxHtmlHistoryItem, wxHtmlHistoryArray);
-WX_DEFINE_OBJARRAY(wxHtmlHistoryArray);
+WX_DEFINE_OBJARRAY(wxHtmlHistoryArray)
WX_DECLARE_LIST(wxHtmlProcessor, wxHtmlProcessorList);
-WX_DEFINE_LIST(wxHtmlProcessorList);
+WX_DEFINE_LIST(wxHtmlProcessorList)
//-----------------------------------------------------------------------------
// wxHtmlWindow
m_lastDoubleClick = 0;
#endif // wxUSE_CLIPBOARD
m_backBuffer = NULL;
+ m_eraseBgInOnPaint = false;
+ m_tmpSelFromCell = NULL;
}
bool wxHtmlWindow::Create(wxWindow *parent, wxWindowID id,
-void wxHtmlWindow::SetFonts(wxString normal_face, 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);
- // 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);
wxDELETE(m_selection);
+ // we will soon delete all the cells, so clear pointers to them:
+ m_tmpSelFromCell = NULL;
+
// pass HTML through registered processors:
if (m_Processors || m_GlobalProcessors)
{
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)
{
bool wxHtmlWindow::AppendToPage(const wxString& source)
{
- return SetPage(*(GetParser()->GetSource()) + source);
+ return DoSetPage(*(GetParser()->GetSource()) + source);
}
bool wxHtmlWindow::LoadPage(const wxString& location)
#if wxUSE_CLIPBOARD
if ( m_selection )
{
-#ifdef __UNIX__
+#if defined(__UNIX__) && !defined(__WXMAC__)
wxTheClipboard->UsePrimarySelection(t == Primary);
#else // !__UNIX__
// Primary selection exists only under X11, so don't do anything under
return true;
}
}
+#else
+ wxUnusedVar(t);
#endif // wxUSE_CLIPBOARD
return false;
{
if ( !m_bmpBg.Ok() )
{
- // we used to do nothing at all here but we do have to erase background
- // now that we reuse it (instead of overwriting it) in OnPaint() below
- event.Skip();
-
+ // don't even skip the event, if we don't have a bg bitmap we're going
+ // to overwrite background in OnPaint() below anyhow, so letting the
+ // default handling take place would only result in flicker, just set a
+ // flag to erase the background below
+ m_eraseBgInOnPaint = true;
return;
}
{
wxPaintDC dc(this);
- if (m_tmpCanDrawLocks > 0 || m_Cell == NULL) return;
+ if (m_tmpCanDrawLocks > 0 || m_Cell == NULL)
+ return;
int x, y;
GetViewStart(&x, &y);
m_backBuffer = new wxBitmap(sz.x, sz.y);
dcm.SelectObject(*m_backBuffer);
- // preserve the existing background, otherwise we'd erase anything the user
- // code had drawn in its EVT_ERASE_BACKGROUND handler when we do the Blit
- // back below
- dcm.Blit(0, rect.GetTop(),
- sz.x, rect.GetBottom() - rect.GetTop() + 1,
- &dc,
- 0, rect.GetTop());
+ if ( m_eraseBgInOnPaint )
+ {
+ dcm.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID));
+ dcm.Clear();
+
+ m_eraseBgInOnPaint = false;
+ }
+ else // someone has already erased the background, keep it
+ {
+ // preserve the existing background, otherwise we'd erase anything the
+ // user code had drawn in its EVT_ERASE_BACKGROUND handler when we do
+ // the Blit back below
+ dcm.Blit(0, rect.GetTop(),
+ sz.x, rect.GetBottom() - rect.GetTop() + 1,
+ &dc,
+ 0, rect.GetTop());
+ }
PrepareDC(dcm);
dcm.SetMapMode(wxMM_TEXT);
CaptureMouse();
}
}
+#else
+ wxUnusedVar(event);
#endif // wxUSE_CLIPBOARD
}
void wxHtmlWindow::OnKeyUp(wxKeyEvent& event)
{
- if ( IsSelectionEnabled() &&
- event.GetKeyCode() == 'C' && event.ControlDown() )
+ if ( IsSelectionEnabled() && event.GetKeyCode() == 'C' && event.CmdDown() )
{
(void) CopySelection();
}