- line->SetPos(line->GetPosX() + s_indent +
- (counter++ * step / xcnt),
- ypos + line->GetPosY());
- line = line->GetNext();
+ // first count the cells which will get extra space
+ int total = -1;
+
+ const wxHtmlCell *c;
+ if ( line != cell )
+ {
+ for ( c = line; c != cell; c = c->GetNext() )
+ {
+ if ( c->IsLinebreakAllowed() )
+ {
+ total++;
+ }
+ }
+ }
+
+ // and now extra space to those cells which merit it
+ if ( total )
+ {
+ // first visible cell on line is not moved:
+ while (line !=cell && !line->IsLinebreakAllowed())
+ {
+ line->SetPos(line->GetPosX() + s_indent,
+ line->GetPosY() + ypos);
+ line = line->GetNext();
+ }
+
+ if (line != cell)
+ {
+ line->SetPos(line->GetPosX() + s_indent,
+ line->GetPosY() + ypos);
+
+ 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
+ {
+ // this will cause the code to enter "else branch" below:
+ step = 0;
+ }
+ }
+ // else branch:
+ if ( step <= 0 ) // 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();
+ }