don't distribute extra space between 0 width cells in justified paragraphs (this looks visually wrong)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27348 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
fef7400f9c
commit
a1ae1090ee
@ -637,7 +637,8 @@ void wxHtmlContainerCell::Layout(int w)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxHtmlCell *cell = m_Cells, *line = m_Cells;
|
wxHtmlCell *cell = m_Cells,
|
||||||
|
*line = m_Cells;
|
||||||
wxHtmlCell *nextCell;
|
wxHtmlCell *nextCell;
|
||||||
long xpos = 0, ypos = m_IndentTop;
|
long xpos = 0, ypos = m_IndentTop;
|
||||||
int xdelta = 0, ybasicpos = 0, ydiff;
|
int xdelta = 0, ybasicpos = 0, ydiff;
|
||||||
@ -755,24 +756,62 @@ void wxHtmlContainerCell::Layout(int w)
|
|||||||
ypos += ysizeup;
|
ypos += ysizeup;
|
||||||
|
|
||||||
if (m_AlignHor != wxHTML_ALIGN_JUSTIFY || cell == NULL)
|
if (m_AlignHor != wxHTML_ALIGN_JUSTIFY || cell == NULL)
|
||||||
|
{
|
||||||
while (line != cell)
|
while (line != cell)
|
||||||
{
|
{
|
||||||
line->SetPos(line->GetPosX() + xdelta,
|
line->SetPos(line->GetPosX() + xdelta,
|
||||||
ypos + line->GetPosY());
|
ypos + line->GetPosY());
|
||||||
line = line->GetNext();
|
line = line->GetNext();
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else // align == justify
|
||||||
{
|
{
|
||||||
int counter = 0;
|
// we have to distribute the extra horz space between the cells
|
||||||
int step = (s_width - xpos);
|
// on this line
|
||||||
if (step < 0) step = 0;
|
|
||||||
xcnt--;
|
// an added complication is that some cells have fixed size and
|
||||||
if (xcnt > 0) while (line != cell)
|
// shouldn't get any increment (it so happens that these cells
|
||||||
|
// also don't allow line break on them which provides with an
|
||||||
|
// easy way to test for this)
|
||||||
|
|
||||||
|
const int step = s_width - xpos;
|
||||||
|
if ( step > 0 )
|
||||||
{
|
{
|
||||||
line->SetPos(line->GetPosX() + s_indent +
|
// first count the cells which will get extra space
|
||||||
(counter++ * step / xcnt),
|
int total = 0;
|
||||||
ypos + line->GetPosY());
|
for ( wxHtmlCell *c = line; c != cell; c = c->GetNext() )
|
||||||
line = line->GetNext();
|
{
|
||||||
|
if ( c->IsLinebreakAllowed() )
|
||||||
|
total++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// and now extra space to those cells which merit it
|
||||||
|
if ( total )
|
||||||
|
{
|
||||||
|
for ( int n = 0; line != cell; line = line->GetNext() )
|
||||||
|
{
|
||||||
|
line->SetPos(line->GetPosX() + s_indent +
|
||||||
|
((n * step) / total),
|
||||||
|
line->GetPosY() + ypos);
|
||||||
|
|
||||||
|
if ( line->IsLinebreakAllowed() )
|
||||||
|
{
|
||||||
|
// offset the next cell relative to this one
|
||||||
|
// thus increasing our size
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // no extra space to distribute
|
||||||
|
{
|
||||||
|
// just set the indent properly
|
||||||
|
while (line != cell)
|
||||||
|
{
|
||||||
|
line->SetPos(line->GetPosX() + s_indent,
|
||||||
|
line->GetPosY() + ypos);
|
||||||
|
line = line->GetNext();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user