Ejemplo n.º 1
0
/*
void MathPrintout::RecalculateSize()
{
  wxConfig *config = (wxConfig *)wxConfig::Get();
  int fontsize = 12;
  config->Read(wxT("fontSize"), &fontsize);
  GroupCell* tmp = m_tree;
  double scale = GetPPIScale();

  wxDC *dc = GetDC();
  CellParser parser(*dc, scale);
  int marginX, marginY;
  GetPageMargins(&marginX, &marginY);
  marginX += SCALE_PX(MC_BASE_INDENT, scale);
  parser.SetIndent(marginX);

  while (tmp != NULL)
  {
    tmp->RecalculateSize(parser, fontsize, false);
    tmp = tmp->m_next;
  }
}
*/
void MathPrintout::Recalculate()
{
  wxConfig *config = (wxConfig *)wxConfig::Get();
  int fontsize = 12;
  config->Read(wxT("fontSize"), &fontsize);
  int mfontsize = fontsize;
  config->Read(wxT("mathfontsize"), &mfontsize);
  GroupCell* tmp = (GroupCell *)m_tree;
  double scale = GetPPIScale();

  wxDC *dc = GetDC();
  CellParser parser(*dc, scale);

  int marginX, marginY;
  GetPageMargins(&marginX, &marginY);
  int pageWidth, pageHeight;
  GetPageSizePixels(&pageWidth, &pageHeight);

  parser.SetClientWidth(pageWidth - marginX - marginY
                        - SCALE_PX(MC_BASE_INDENT, scale));

  marginX += SCALE_PX(MC_BASE_INDENT, scale);
  parser.SetIndent(marginX);

  while (tmp != NULL)
  {
    tmp->Recalculate(parser, fontsize, mfontsize);
    tmp = (GroupCell *)tmp->m_next;
  }
}
Ejemplo n.º 2
0
void Bitmap::Layout()
{
  if (m_tree->GetType() != MC_TYPE_GROUP)
  {
    RecalculateWidths();
    BreakUpCells();
    BreakLines();
    RecalculateSize();
  }
  else {
    int fontsize = 12;
    wxConfig::Get()->Read(wxT("fontSize"), &fontsize);
    int mfontsize = fontsize;
    wxConfig::Get()->Read(wxT("mathfontsize"), &mfontsize);
    GroupCell* tmp = (GroupCell *)m_tree;

    wxMemoryDC dc;
    dc.SelectObject(m_bmp);
    CellParser parser(dc);
    parser.SetClientWidth(BM_FULL_WIDTH);

    while (tmp != NULL)
    {
      tmp->Recalculate(parser, fontsize, mfontsize);
      tmp = (GroupCell *)tmp->m_next;
    }
  }

  int width, height;
  GetMaxPoint(&width, &height);
  m_bmp.Create(width, height);

  Draw();
}
Ejemplo n.º 3
0
bool Emfout::Layout()
{
  if(m_recalculationDc == NULL)
    return false;
  
  (*m_configuration)->SetContext(*m_recalculationDc);

  if (m_tree->GetType() != MC_TYPE_GROUP)
  {
    RecalculateWidths();
    BreakUpCells();
    BreakLines();
    RecalculateHeight();
  }
  else
  {
    GroupCell *tmp = dynamic_cast<GroupCell *>(m_tree);
    while (tmp != NULL)
    {
      tmp->Recalculate();
      tmp = dynamic_cast<GroupCell *>(tmp->m_next);
    }
  }

  if(!m_recalculationDc->IsOk())
  {
    return false;
  }

  GetMaxPoint(&m_width, &m_height);
  if(m_dc != NULL)
  {
    m_dc->Close();
    wxDELETE(m_dc);
  }
  // Let's switch to a DC of the right size for our object.
  m_dc = new wxEnhMetaFileDC(m_filename, m_width, m_height);
  if(m_dc != NULL)
  {
    (*m_configuration)->SetContext(*m_dc);
    
    Draw();
    // Closing the DC seems to trigger the actual output of the file.
    m_dc->Close();
    wxDELETE(m_dc);
    m_dc = NULL;
  }
  return true;
}