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

void wxPdfDocument::Cell ( double  w,
double  h = 0.,
const wxString &  txt = wxEmptyString,
int  border = wxPDF_BORDER_NONE,
int  ln = 0,
int  align = wxPDF_ALIGN_LEFT,
int  fill = 0,
const wxPdfLink link = wxPdfLink(-1) 
) [virtual]

Prints a cell (rectangular area) with optional borders, background color and character string.

The upper-left corner of the cell corresponds to the current position. The text can be aligned or centered. After the call, the current position moves to the right or to the next line. It is possible to put a link on the text. If automatic page breaking is enabled and the cell goes beyond the limit, a page break is done before outputting.

Parameters:
wCell width. If 0, the cell extends up to the right margin.
hCell height. Default value: 0.
txtString to print. Default value: empty string.
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.

lnIndicates where the current position should go after the call. Possible values are:

  • 0: to the right
  • 1: to the beginning of the next line
  • 2: below

Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: 0.

alignAllows to center or align the text. Possible values are:

  • L or empty string: left align (default value)
  • C: center
  • R: right align
  • wxPDF_ALIGN_LEFT align the text at the left margin
  • wxPDF_ALIGN_CENTER center the text
  • wxPDF_ALIGN_RIGHT align the text at the right margin
  • wxPDF_ALIGN_JUSTIFY justify the text
fillIndicates if the cell background must be painted (1) or transparent (0). Default value: 0.
linkURL or identifier returned by AddLink().
See also:
SetFont(), SetDrawColor(), SetFillColor(), SetTextColor(), SetLineWidth(), AddLink(), Ln(), MultiCell(), Write(), SetAutoPageBreak()

Definition at line 913 of file pdfdoc.cpp.

References AcceptPageBreak(), AddPage(), DoDecoration(), Double2String(), wxPdfColour::GetColor(), GetStringWidth(), wxPdfLink::IsValid(), Link(), m_cMargin, m_colorFlag, m_curOrientation, m_currentFont, m_decoration, m_fontSize, m_h, m_inFooter, m_k, m_lasth, m_lMargin, m_pageBreakTrigger, m_rMargin, m_textColor, m_w, m_ws, m_x, m_y, Out(), OutAscii(), TextEscape(), wxPdfFont::UpdateUsedChars(), and wxPDF_BORDER_NONE.

Referenced by ClippedCell(), MultiCell(), WriteCell(), and WriteXmlCell().

{
  // Output a cell
  double x, y;
  double k = m_k;
  if (m_y + h > m_pageBreakTrigger && !m_inFooter && AcceptPageBreak())
  {
    // Automatic page break
    x = m_x;
    double ws = m_ws;
    if (ws > 0)
    {
      m_ws = 0;
      Out("0 Tw");
    }
    AddPage(m_curOrientation);
    m_x = x;
    if (ws > 0)
    {
      m_ws = ws;
      OutAscii(Double2String(ws*k,3)+wxString(_T(" Tw")));
    }
  }
  if ( w == 0)
  {
    w = m_w - m_rMargin - m_x;
  }
  wxString s = wxEmptyString;
  if (fill == 1 || border == wxPDF_BORDER_FRAME)
  {
    s = Double2String(m_x*k,2) + wxString(_T(" ")) +
        Double2String((m_h-m_y)*k,2) + wxString(_T(" ")) +
        Double2String(w*k,2) + wxString(_T(" ")) +
        Double2String(-h*k,2);
    if (fill == 1)
    {
      if (border == wxPDF_BORDER_FRAME)
      {
        s += wxString(_T(" re B "));
      }
      else
      {
        s += wxString(_T(" re f "));
      }
    }
    else
    {
      s += wxString(_T(" re S "));
    }
  }
  if (border != wxPDF_BORDER_NONE && border != wxPDF_BORDER_FRAME)
  {
    x = m_x;
    y = m_y;
    if (border & wxPDF_BORDER_LEFT)
    {
      s += Double2String(x*k,2) + wxString(_T(" ")) +
           Double2String((m_h-y)*k,2) + wxString(_T(" m ")) +
           Double2String(x*k,2) + wxString(_T(" ")) +
           Double2String((m_h-(y+h))*k,2) + wxString(_T(" l S "));
    }
    if (border & wxPDF_BORDER_TOP)
    {
      s += Double2String(x*k,2) + wxString(_T(" ")) +
           Double2String((m_h-y)*k,2) + wxString(_T(" m ")) +
           Double2String((x+w)*k,2) + wxString(_T(" ")) +
           Double2String((m_h-y)*k,2) + wxString(_T(" l S "));
    }
    if (border & wxPDF_BORDER_RIGHT)
    {
      s += Double2String((x+w)*k,2) + wxString(_T(" ")) +
           Double2String((m_h-y)*k,2) + wxString(_T(" m ")) +
           Double2String((x+w)*k,2) + wxString(_T(" ")) +
           Double2String((m_h-(y+h))*k,2) + wxString(_T(" l S "));
    }
    if (border & wxPDF_BORDER_BOTTOM)
    {
      s += Double2String(x*k,2) + wxString(_T(" ")) +
           Double2String((m_h-(y+h))*k,2) + wxString(_T(" m ")) +
           Double2String((x+w)*k,2) + wxString(_T(" ")) +
           Double2String((m_h-(y+h))*k,2) + wxString(_T(" l S "));
    }
  }
  if (s.Length() > 0)
  {
    bool newline = txt.Length() == 0;
    OutAscii(s, newline);
    s = _T("");
  }

  if (txt.Length() > 0)
  {
    double width = GetStringWidth(txt);
    double dx;
    if (align == wxPDF_ALIGN_RIGHT)
    {
      dx = w - m_cMargin - width;
    }
    else if (align == wxPDF_ALIGN_CENTER)
    {
      dx = (w - width) / 2;
    }
    else
    {
      dx = m_cMargin;
    }
    if (m_colorFlag)
    {
      s += wxString(_T("q ")) + m_textColor.GetColor(false) + wxString(_T(" "));
    }
    s += wxString(_T("BT ")) +
         Double2String((m_x+dx)*k,2) + wxString(_T(" ")) +
         Double2String((m_h-(m_y+.5*h+.3*m_fontSize))*k,2) + wxString(_T(" Td ("));
    OutAscii(s,false);
    TextEscape(txt,false);
    s = _T(") Tj ET");
    if (m_currentFont != 0)
    {
      m_currentFont->UpdateUsedChars(txt);
    }

    if (m_decoration & wxPDF_FONT_DECORATION)
    {
      s += wxString(_T(" ")) + DoDecoration(m_x+dx,m_y+.5*h+.3*m_fontSize,txt);
    }
    if (m_colorFlag)
    {
      s += wxString(_T(" Q"));
    }
    if (link.IsValid())
    {
      Link(m_x+dx,m_y+.5*h-.5*m_fontSize,width,m_fontSize,link);
    }
    OutAscii(s);
  }
  m_lasth = h;
  if (ln > 0)
  {
    // Go to next line
    m_y += h;
    if ( ln == 1)
    {
      m_x = m_lMargin;
    }
  }
  else
  {
    m_x += w;
  }
}

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