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

void wxPdfDocument::UseTemplate ( int  templateId,
double  x = -1,
double  y = -1,
double  width = 0,
double  height = 0 
)

Uses a template in current page or in another template.

Uses the specified template just like an image in the current page or in another template.

All parameters are optional. The width or height is calculated using GetTemplateSize internally. By default the size as defined by BeginTemplate is used.

Parameters:
templateIdA valid template ID
xThe x coordinate
yThe y coordinate
widthThe new width of the template
heightThe new height of the template
See also:
BeginTemplate(), EndTemplate(), ImportPage()

Attention: The template may be displayed distorted, if both width and height are given with values > 0 and do not correspond to the dimensions of the template.

Definition at line 125 of file pdftemplate.cpp.

References Double2String(), wxPdfTemplate::GetHeight(), wxPdfTemplate::GetIndex(), GetTemplateSize(), wxPdfTemplate::GetWidth(), wxPdfTemplate::GetX(), wxPdfTemplate::GetY(), m_currentTemplate, m_h, m_inTemplate, m_k, m_page, m_templatePrefix, wxPdfTemplate::m_templates, wxPdfTemplate::m_used, and OutAscii().

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

  wxPdfTemplate* tpl;
  wxPdfTemplatesMap::iterator templateIter = (*m_templates).find(templateId);
  if (templateIter != (*m_templates).end())
  {
    tpl = templateIter->second;
  }
  else
  {
    wxLogWarning(_("wxPdfDocument::UseTemplate: Template %d does not exist!"), templateId);
    return;
  }
            
  if (m_inTemplate)
  {
    (*(m_currentTemplate->m_templates))[templateId] = tpl;
  }

  if (x < 0) x = tpl->GetX();
  if (y < 0) y = tpl->GetY();
  GetTemplateSize(templateId, w, h);

  double xScale = w / tpl->GetWidth();
  double yScale = h / tpl->GetHeight();
  double xTrans = (x - xScale * tpl->GetX()) * m_k;
  double yTrans = (m_h - (y + h) - yScale * tpl->GetY()) * m_k;
  OutAscii(wxString(_T("q ")) +
           Double2String(xScale, 4) + wxString(_T(" 0 0 ")) +
           Double2String(yScale, 4) + wxString(_T(" ")) +
           Double2String(xTrans, 2) + wxString(_T(" ")) +
           Double2String(yTrans, 2) +  wxString(_T(" cm"))); // Translate
  OutAscii(m_templatePrefix + wxString::Format(_T("%d Do Q"), tpl->GetIndex()));
  tpl->m_used = true;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index