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.

w Width of cells. If 0, they extend up to the right margin of the page.
h Height of cells.
txt String to print
halign Allows 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)
valign Allows 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
border Indicates 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.
fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.

Definition at line 1274 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;

  int trail = MultiCell(w, hrow, txt, 0, halign, fill, rows);

  if (border == wxPDF_BORDER_FRAME)
    Rect(xi, yi, w, h);
    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;

Generated by  Doxygen 1.6.0   Back to index