Logo Search packages:      
Sourcecode: codeblocks version File versions  Download package

void wxPdfDocument::WriteCell ( double  h,
const wxString &  txt,
int  border = wxPDF_BORDER_NONE,
int  fill = 0,
const wxPdfLink link = wxPdfLink(-1) 
) [virtual]

This method prints text with cell attributes from the current position.

When the right margin is reached (or the
character is met) a line break occurs and text continues from the left margin. Upon method exit, the current position is left just at the end of the text. It is possible to put a link on the text.

Parameters:
hLine height
txtString to print
borderIndicates if borders must be drawn around the cell. The value can be

  • wxPDF_BORDER_NONE no border
  • wxPDF_BORDER_LEFT left border
  • wxPDF_BORDER_RIGHT right border
  • wxPDF_BORDER_TOP top border
  • wxPDF_BORDER_BOTTOM bottom border
  • wxPDF_BORDER_FRAME border on all sides

or a combination of them.

fillIndicates if the cell background must be painted (1) or transparent (0). Default value: 0.
linkURL or identifier returned by AddLink()
See also:
SetFont(), SetTextColor(), AddLink(), MultiCell(), SetAutoPageBreak()

Definition at line 1329 of file pdfdoc.cpp.

References Cell(), GetCellMargin(), GetStringWidth(), m_cMargin, m_lMargin, m_rMargin, m_w, m_x, m_y, and SetCellMargin().

Referenced by Write(), and WriteXmlCell().

{
  // Output text in flowing mode
  wxString s = txt;
  s.Replace(_T("\r"),_T("")); // remove carriage returns
  int nb = s.Length();

  // handle single space character
  if ((nb == 1) && s[0] == _T(' '))
  {
    m_x += GetStringWidth(s);
    return;
  }

  double saveCellMargin = GetCellMargin();
  SetCellMargin(0);

  double w = m_w - m_rMargin - m_x;
  double wmax = (w - 2 * m_cMargin) + wxPDF_EPSILON;

  int sep = -1;
  int i = 0;
  int j = 0;
  double len=0;
  int nl = 1;
  wxChar c;
  while (i < nb)
  {
    // Get next character
    c = s[i];
    if (c == _T('\n'))
    {
      // Explicit line break
      Cell(w, h, s.SubString(j,i-1), border, 2, wxPDF_ALIGN_LEFT, fill, link);
      i++;
      sep = -1;
      j = i;
      len = 0;
      if (nl == 1)
      {
        m_x = m_lMargin;
        w = m_w - m_rMargin - m_x;
        wmax = (w - 2 * m_cMargin);
      }
      nl++;
      continue;
    }
    if (c == _T(' '))
    {
      sep = i;
    }
    len = GetStringWidth(s.SubString(j, i));
    if (len > wmax)
    {
      // Automatic line break
      if (sep == -1)
      {
        if (m_x > m_lMargin)
        {
          // Move to next line
          m_x = m_lMargin;
          m_y += h;
          w = m_w - m_rMargin -m_x;
          wmax = (w - 2 * m_cMargin);
          i++;
          nl++;
          continue;
        }
        if (i == j)
        {
          i++;
        }
        Cell(w, h,s.SubString(j, i-1), border, 2, wxPDF_ALIGN_LEFT, fill, link);
      }
      else
      {
        Cell(w, h, s.SubString(j, sep-1), border, 2, wxPDF_ALIGN_LEFT, fill, link);
        i = sep + 1;
      }
      sep = -1;
      j = i;
      len = 0;
      if (nl == 1)
      {
        m_x = m_lMargin;
        w = m_w - m_rMargin - m_x;
        wmax = (w - 2 * m_cMargin);
      }
      nl++;
    }
    else
    {
      i++;
    }
  }
  // Last chunk
  if (i != j)
  {
    Cell(len, h, s.SubString(j,i-1), border, 0, wxPDF_ALIGN_LEFT, fill, link);
  }

  // Following statement was in PHP code, but seems to be in error.
  // m_x += GetStringWidth(s.SubString(j, i-1));
  SetCellMargin(saveCellMargin);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index