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

int wxPdfDocument::BeginTemplate ( double  x = 0,
double  y = 0,
double  width = 0,
double  height = 0 

Starts a new Template.

Starts a new template, optionally with own dimensions. The margins have to adapted to the new template size. For writing outside the template, for example to build a clipped template, the margins and "cursor" position have to be set manually after the call to BeginTemplate().

If no dimensions are given, the template uses the current page size. The method returns the ID of the current template. The ID is used to reference a template in the UseTemplate() method. Warning: A template once created is embedded in the resulting PDF document at all events, even if it is not used.

x The x-coordinate given in user units
y The y-coordinate given in user units
width The width given in user units
height The height given in user units
int The ID of the created template
See also:
EndTemplate(), UseTemplate()
Attention: Calls to BeginTemplate can not be nested!

Definition at line 58 of file pdftemplate.cpp.

References m_autoPageBreak, wxPdfTemplate::m_autoPageBreakSave, m_bMargin, wxPdfTemplate::m_bMarginSave, m_currentTemplate, wxPdfTemplate::m_h, m_h, wxPdfTemplate::m_hSave, m_inTemplate, m_lMargin, wxPdfTemplate::m_lMarginSave, m_page, m_rMargin, wxPdfTemplate::m_rMarginSave, m_templateId, m_tMargin, wxPdfTemplate::m_tMarginSave, wxPdfTemplate::m_w, m_w, wxPdfTemplate::m_wSave, wxPdfTemplate::m_x, m_x, wxPdfTemplate::m_xSave, wxPdfTemplate::m_y, m_y, wxPdfTemplate::m_ySave, SetAutoPageBreak(), SetRightMargin(), and SetXY().

  if (m_page <= 0)
    wxLogError(_("wxPdfDocument::BeginTemplate: You have to add a page first!"));
    return 0;

  // Save settings
  m_currentTemplate = new wxPdfTemplate(m_templateId);

  m_currentTemplate->m_xSave = m_x;
  m_currentTemplate->m_ySave = m_y;
  m_currentTemplate->m_hSave = m_h;
  m_currentTemplate->m_wSave = m_w;
  m_currentTemplate->m_autoPageBreakSave = m_autoPageBreak;
  m_currentTemplate->m_bMarginSave = m_bMargin;
  m_currentTemplate->m_tMarginSave = m_tMargin;
  m_currentTemplate->m_lMarginSave = m_lMargin;
  m_currentTemplate->m_rMarginSave = m_rMargin;

  if (x <= 0) x = 0;
  if (y <= 0) y = 0;
  if (w <= 0) w = m_w;
  if (h <= 0) h = m_h;

  // Define own height and width to calculate positions correctly
  m_h = h;
  m_w = w;

  m_currentTemplate->m_x = x;
  m_currentTemplate->m_y = y;
  m_currentTemplate->m_w = w;
  m_currentTemplate->m_h = h;

  m_inTemplate = true;
  SetXY(x + m_lMargin, y + m_tMargin);
  SetRightMargin(m_w - w + m_rMargin);

  (*m_templates)[m_templateId] = m_currentTemplate;

  return m_templateId;

Generated by  Doxygen 1.6.0   Back to index