X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0cb9cfb22f6c0a67b0ee6dc7c29ab63397a4a8af..aedcc0dc8266fbc73d6bb513bf6c6b0f17932afa:/src/html/htmlcell.cpp diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index cb0ce6904c..7881b478f0 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -8,7 +8,7 @@ ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ -#pragma implementation +#pragma implementation "htmlcell.h" #endif #include "wx/wxprec.h" @@ -17,7 +17,7 @@ #if wxUSE_HTML && wxUSE_STREAMS -#ifdef __BORDLANDC__ +#ifdef __BORLANDC__ #pragma hdrstop #endif @@ -68,7 +68,7 @@ void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y, -bool wxHtmlCell::AdjustPagebreak(int *pagebreak) const +bool wxHtmlCell::AdjustPagebreak(int *pagebreak, int* WXUNUSED(known_pagebreaks), int WXUNUSED(number_of_pages)) const { if ((!m_CanLiveOnPagebreak) && m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak) @@ -115,6 +115,14 @@ const wxHtmlCell* wxHtmlCell::Find(int WXUNUSED(condition), const void* WXUNUSED } +wxHtmlCell *wxHtmlCell::FindCellByPos(wxCoord x, wxCoord y) const +{ + if ( x >= 0 && x < m_Width && y >= 0 && y < m_Height ) + return wxConstCast(this, wxHtmlCell); + + return NULL; +} + //----------------------------------------------------------------------------- // wxHtmlWordCell @@ -207,10 +215,10 @@ int wxHtmlContainerCell::GetIndentUnits(int ind) const -bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak) const +bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak, int* known_pagebreaks, int number_of_pages) const { if (!m_CanLiveOnPagebreak) - return wxHtmlCell::AdjustPagebreak(pagebreak); + return wxHtmlCell::AdjustPagebreak(pagebreak, known_pagebreaks, number_of_pages); else { @@ -220,7 +228,7 @@ bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak) const while (c) { - if (c->AdjustPagebreak(&pbrk)) + if (c->AdjustPagebreak(&pbrk, known_pagebreaks, number_of_pages)) rt = TRUE; c = c->GetNext(); } @@ -247,8 +255,8 @@ void wxHtmlContainerCell::Layout(int w) m_Width = 0; for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) cell->Layout(0); - // this does two things: it recursively calls this code on all child - // contrainers and resets children's position to (0,0) + // this does two things: it recursively calls this code on all + // child contrainers and resets children's position to (0,0) return; } @@ -400,9 +408,8 @@ void wxHtmlContainerCell::Layout(int w) void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) { // container visible, draw it: - if ((y + m_PosY < view_y2) && (y + m_PosY + m_Height > view_y1)) + if ((y + m_PosY <= view_y2) && (y + m_PosY + m_Height > view_y1)) { - if (m_UseBkColour) { wxBrush myb = wxBrush(m_BkColour, wxSOLID); @@ -422,10 +429,10 @@ void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) dc.SetPen(mypen1); dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX, y + m_PosY + m_Height - 1); - dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX + m_Width - 1, y + m_PosY); + dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX + m_Width, y + m_PosY); dc.SetPen(mypen2); dc.DrawLine(x + m_PosX + m_Width - 1, y + m_PosY, x + m_PosX + m_Width - 1, y + m_PosY + m_Height - 1); - dc.DrawLine(x + m_PosX, y + m_PosY + m_Height - 1, x + m_PosX + m_Width - 1, y + m_PosY + m_Height - 1); + dc.DrawLine(x + m_PosX, y + m_PosY + m_Height - 1, x + m_PosX + m_Width, y + m_PosY + m_Height - 1); } if (m_Cells) @@ -457,21 +464,24 @@ void wxHtmlContainerCell::DrawInvisible(wxDC& dc, int x, int y) } +wxColour wxHtmlContainerCell::GetBackgroundColour() +{ + if (m_UseBkColour) + return m_BkColour; + else + return wxNullColour; +} + + wxHtmlLinkInfo *wxHtmlContainerCell::GetLink(int x, int y) const { - wxHtmlCell *c = m_Cells; - int cx, cy, cw, ch; + wxHtmlCell *cell = FindCellByPos(x, y); - while (c) - { - cx = c->GetPosX(), cy = c->GetPosY(); - cw = c->GetWidth(), ch = c->GetHeight(); - if ((x >= cx) && (x < cx + cw) && (y >= cy) && (y < cy + ch)) - return c->GetLink(x - cx, y - cy); - c = c->GetNext(); - } - return NULL; + // VZ: I don't know if we should pass absolute or relative coords to + // wxHtmlCell::GetLink()? As the base class version just ignores them + // anyhow, it hardly matters right now but should still be clarified + return cell ? cell->GetLink(x, y) : NULL; } @@ -550,25 +560,29 @@ const wxHtmlCell* wxHtmlContainerCell::Find(int condition, const void* param) co } - -void wxHtmlContainerCell::OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event) +wxHtmlCell *wxHtmlContainerCell::FindCellByPos(wxCoord x, wxCoord y) const { - if (m_Cells) + for ( const wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext() ) { - wxHtmlCell *c = m_Cells; - while (c) + int cx = cell->GetPosX(), + cy = cell->GetPosY(); + + if ( (cx <= x) && (cx + cell->GetWidth() > x) && + (cy <= y) && (cy + cell->GetHeight() > y) ) { - if ( (c->GetPosX() <= x) && - (c->GetPosY() <= y) && - (c->GetPosX() + c->GetWidth() > x) && - (c->GetPosY() + c->GetHeight() > y)) - { - c->OnMouseClick(parent, x - c->GetPosX(), y - c->GetPosY(), event); - break; - } - c = c->GetNext(); + return cell->FindCellByPos(x - cx, y - cy); } } + + return NULL; +} + + +void wxHtmlContainerCell::OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event) +{ + wxHtmlCell *cell = FindCellByPos(x, y); + if ( cell ) + cell->OnMouseClick(parent, x, y, event); }