X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2d1d813e2dc392d2480a2dc9cdf61ce6330db72d..7875e5ff98026892cca756bb7efd82b32ec192fc:/src/html/htmlcell.cpp diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index 4747a35f43..5ea2d4b802 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -283,7 +283,7 @@ void wxHtmlWordCell::Split(wxDC& dc, wxPoint pt1 = (selFrom == wxDefaultPosition) ? wxDefaultPosition : selFrom - GetAbsPos(); wxPoint pt2 = (selTo == wxDefaultPosition) ? - wxPoint(m_Width, wxDefaultPosition.y) : selTo - GetAbsPos(); + wxPoint(m_Width, wxDefaultCoord) : selTo - GetAbsPos(); wxCoord charW, charH; unsigned len = m_Word.length(); @@ -385,7 +385,7 @@ void wxHtmlWordCell::Draw(wxDC& dc, int x, int y, #endif bool drawSelectionAfterCell = false; - + if ( info.GetState().GetSelectionState() == wxHTML_SEL_CHANGING ) { // Selection changing, we must draw the word piecewise: @@ -716,7 +716,7 @@ void wxHtmlContainerCell::Layout(int w) curLineWidth += cell->GetMaxTotalWidth(); cell = cell->GetNext(); - + // compute length of the next word that would be added: nextWordWidth = 0; if (cell) @@ -728,9 +728,9 @@ void wxHtmlContainerCell::Layout(int w) nextCell = nextCell->GetNext(); } while (nextCell && !nextCell->IsLinebreakAllowed()); } - + // force new line if occured: - if ((cell == NULL) || + if ((cell == NULL) || (xpos + nextWordWidth > s_width && cell->IsLinebreakAllowed())) { if (xpos > MaxLineWidth) MaxLineWidth = xpos; @@ -781,41 +781,38 @@ void wxHtmlContainerCell::Layout(int w) // first count the cells which will get extra space int total = 0; - const wxHtmlCell *c, - *prev = NULL, - *next = NULL; - for ( c = line; c != cell; prev = c, c = next ) + const wxHtmlCell *c; + if ( line != cell ) { - next = c->GetNext(); - if ( c->IsLinebreakAllowed() && - (next == cell || next->IsLinebreakAllowed()) && - (!prev || prev->IsLinebreakAllowed()) ) + for ( c = line->GetNext(); c != cell; c = c->GetNext() ) { - total++; + if ( c->IsLinebreakAllowed() ) + { + total++; + } } } // and now extra space to those cells which merit it if ( total ) { - prev = - next = NULL; - for ( int n = 0; line != cell; prev = line, line = line->GetNext() ) - { - line->SetPos(line->GetPosX() + s_indent + - ((n * step) / total), - line->GetPosY() + ypos); + // first cell on line is not moved: + line->SetPos(line->GetPosX() + s_indent, + line->GetPosY() + ypos); - next = line->GetNext(); - if ( line->IsLinebreakAllowed() && - (next == cell || - next->IsLinebreakAllowed()) && - (!prev || prev->IsLinebreakAllowed()) ) + line = line->GetNext(); + for ( int n = 0; line != cell; line = line->GetNext() ) + { + if ( line->IsLinebreakAllowed() ) { // offset the next cell relative to this one // thus increasing our size n++; } + + line->SetPos(line->GetPosX() + s_indent + + ((n * step) / total), + line->GetPosY() + ypos); } } else @@ -865,7 +862,7 @@ void wxHtmlContainerCell::Layout(int w) if (curLineWidth > m_MaxTotalWidth) m_MaxTotalWidth = curLineWidth; - + m_MaxTotalWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); MaxLineWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); if (m_Width < MaxLineWidth) m_Width = MaxLineWidth; @@ -1089,10 +1086,10 @@ wxHtmlCell *wxHtmlContainerCell::FindCellByPos(wxCoord x, wxCoord y, if ( cell->IsFormattingCell() ) continue; int cellY = cell->GetPosY(); - if (!( y < cellY || (y < cellY + cell->GetHeight() && + if (!( y < cellY || (y < cellY + cell->GetHeight() && x < cell->GetPosX() + cell->GetWidth()) )) continue; - + c = cell->FindCellByPos(x - cell->GetPosX(), y - cellY, flags); if (c) return c; } @@ -1178,7 +1175,7 @@ static bool IsEmptyContainer(wxHtmlContainerCell *cell) } void wxHtmlContainerCell::RemoveExtraSpacing(bool top, bool bottom) -{ +{ if ( top ) SetIndent(0, wxHTML_INDENT_TOP); if ( bottom ) @@ -1212,13 +1209,13 @@ void wxHtmlContainerCell::RemoveExtraSpacing(bool top, bool bottom) } } } - + if ( bottom ) { wxArrayPtrVoid arr; for ( c = m_Cells; c; c = c->GetNext() ) arr.Add((void*)c); - + for ( int i = arr.GetCount() - 1; i >= 0; i--) { c = (wxHtmlCell*)arr[i];