/////////////////////////////////////////////////////////////////////////////
-// Name: htmlcell.cpp
+// Name: src/html/htmlcell.cpp
// Purpose: wxHtmlCell - basic element of HTML output
// Author: Vaclav Slavik
// RCS-ID: $Id$
#include "wx/wxprec.h"
-#include "wx/defs.h"
-
-#if wxUSE_HTML && wxUSE_STREAMS
-
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
-#ifndef WXPRECOMP
+#if wxUSE_HTML && wxUSE_STREAMS
+
+#ifndef WX_PRECOMP
+ #include "wx/dynarray.h"
#include "wx/brush.h"
#include "wx/colour.h"
#include "wx/dc.h"
+ #include "wx/settings.h"
+ #include "wx/module.h"
+ #include "wx/wxcrtvararg.h"
#endif
#include "wx/html/htmlcell.h"
#include "wx/html/htmlwin.h"
-#include "wx/settings.h"
-#include "wx/module.h"
-#include "wx/dynarray.h"
#include <stdlib.h>
}
-bool wxHtmlCell::AdjustPagebreak(int *pagebreak, int* WXUNUSED(known_pagebreaks), int WXUNUSED(number_of_pages)) const
+bool wxHtmlCell::AdjustPagebreak(int *pagebreak,
+ wxArrayInt& WXUNUSED(known_pagebreaks)) const
{
if ((!m_CanLiveOnPagebreak) &&
m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak)
wxHtmlWordCell::wxHtmlWordCell(const wxString& word, const wxDC& dc) : wxHtmlCell()
{
m_Word = word;
- dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent);
+ wxCoord w, h, d;
+ dc.GetTextExtent(m_Word, &w, &h, &d);
+ m_Width = w;
+ m_Height = h;
+ m_Descent = d;
SetCanLiveOnPagebreak(false);
m_allowLinebreak = true;
}
}
-
-bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak, int* known_pagebreaks, int number_of_pages) const
+bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak,
+ wxArrayInt& known_pagebreaks) const
{
if (!m_CanLiveOnPagebreak)
- return wxHtmlCell::AdjustPagebreak(pagebreak, known_pagebreaks, number_of_pages);
+ return wxHtmlCell::AdjustPagebreak(pagebreak, known_pagebreaks);
- else
- {
- wxHtmlCell *c = GetFirstChild();
- bool rt = false;
- int pbrk = *pagebreak - m_PosY;
+ wxHtmlCell *c = GetFirstChild();
+ bool rt = false;
+ int pbrk = *pagebreak - m_PosY;
- while (c)
- {
- if (c->AdjustPagebreak(&pbrk, known_pagebreaks, number_of_pages))
- rt = true;
- c = c->GetNext();
- }
- if (rt)
- *pagebreak = pbrk + m_PosY;
- return rt;
+ while (c)
+ {
+ if (c->AdjustPagebreak(&pbrk, known_pagebreaks))
+ rt = true;
+ c = c->GetNext();
}
+ if (rt)
+ *pagebreak = pbrk + m_PosY;
+ return rt;
}
-
void wxHtmlContainerCell::Layout(int w)
{
wxHtmlCell::Layout(w);
if ( step > 0 )
{
// first count the cells which will get extra space
- int total = 0;
+ int total = -1;
const wxHtmlCell *c;
if ( line != cell )
{
- for ( c = line->GetNext(); c != cell; c = c->GetNext() )
+ for ( c = line; c != cell; c = c->GetNext() )
{
if ( c->IsLinebreakAllowed() )
{
// and now extra space to those cells which merit it
if ( total )
{
- // first cell on line is not moved:
- line->SetPos(line->GetPosX() + s_indent,
- line->GetPosY() + ypos);
+ // 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();
+ }
- line = line->GetNext();
for ( int n = 0; line != cell; line = line->GetNext() )
{
if ( line->IsLinebreakAllowed() )
int wdi;
wxString wd = tag.GetParam(wxT("WIDTH"));
- if (wd[wd.Length()-1] == wxT('%'))
+ if (wd[wd.length()-1] == wxT('%'))
{
wxSscanf(wd.c_str(), wxT("%i%%"), &wdi);
SetWidthFloat(wdi, wxHTML_UNITS_PERCENT);