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

int wxPdfDocument::TextBox ( double  w,
double  h,
const wxString &  txt,
int  halign = wxPDF_ALIGN_JUSTIFY,
int  valign = wxPDF_ALIGN_TOP,
int  border = 0,
int  fill = 0 
) [virtual]

This method counts the number of lines a text will occupy in respect to a given maximal width.

Parameters:
wWidth of cells. If 0, they extend up to the right margin of the page.
hHeight of cells.
txtString to print
halignAllows to center or align the text. Possible values are:

  • 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 (default)
valignAllows to vertical align the text. Possible values are:

  • wxPDF_ALIGN_TOP align the text at the top of the box
  • wxPDF_ALIGN_MIDDLE center the text vertically in the box
  • wxPDF_ALIGN_BOTTOM align the text at the bottom of the box
borderIndicates if borders must be drawn around the text box. 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.

Definition at line 1282 of file pdfdoc.cpp.

References Line(), LineCount(), m_fontSize, m_x, m_y, MultiCell(), Rect(), SetX(), and SetY().

{
  double xi = m_x;
  double yi = m_y;

  double hrow  = m_fontSize;
  int textrows = LineCount(w, txt);
  int maxrows  = (int) floor(h / hrow);
  int rows     = (textrows < maxrows) ? textrows : maxrows;

  double dy = 0;
  if (valign == wxPDF_ALIGN_MIDDLE)
  {
    dy = (h - rows * hrow) / 2;
  }
  else if (valign == wxPDF_ALIGN_BOTTOM)
  {
    dy = h - rows * hrow;
  }

  SetY(yi+dy);
  SetX(xi);
  int trail = MultiCell(w, hrow, txt, 0, halign, fill, rows);

  if (border == wxPDF_BORDER_FRAME)
  {
    Rect(xi, yi, w, h);
  }
  else
  {
    if (border & wxPDF_BORDER_LEFT)   Line(xi,yi,xi,yi+h);
    if (border & wxPDF_BORDER_RIGHT)  Line(xi+w,yi,xi+w,yi+h);
    if (border & wxPDF_BORDER_TOP)    Line(xi,yi,xi+w,yi);
    if (border & wxPDF_BORDER_BOTTOM) Line(xi,yi+h,xi+w,yi+h);
  }

  return trail;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index