Ejemplo n.º 1
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.º 2
0
void PsychGiveHelp(void)
{  
    PsychGenericScriptType		*cellVector;

	// Special case: Asked to return help in a cell array of strings?
	if (strlen(PsychGetFunctionName()) < 2) {
		// Yes. Return a 3 element cell array of strings, each containing one
		// of the three help text arguments:
		PsychAllocOutCellVector(1, FALSE, 3,  &cellVector);
		PsychSetCellVectorStringElement(0, functionUseHELP, cellVector);
		PsychSetCellVectorStringElement(1, BreakLines(functionSynopsisHELP, 80), cellVector);
		PsychSetCellVectorStringElement(2, functionSeeAlsoHELP, cellVector);
		
		return;
	}
	
	// No, standard path: Print to console of runtime system:
	printf("\nUsage:\n\n%s\n",functionUseHELP);
	if (functionSynopsisHELP != NULL) printf("\n%s\n", BreakLines(functionSynopsisHELP, 80));
	if (functionSeeAlsoHELP  != NULL) printf("\nSee also: %s\n", BreakLines(functionSeeAlsoHELP, 80));
}
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;
}
Ejemplo n.º 4
0
// We assume that appended cells will be in a new line!
void GroupCell::RecalculateAppended(CellParser& parser)
{
  if (m_appendedCells == NULL)
    return;

  MathCell *tmp = m_appendedCells;
  int fontsize = m_fontSize;
  double scale = parser.GetScale();

  // Recalculate widths of cells
  while (tmp != NULL) {
    tmp->RecalculateWidths(parser, tmp->IsMath() ? m_mathFontSize : m_fontSize);
    tmp = tmp->m_next;
  }

  // Breakup cells and break lines
  BreakUpCells(m_appendedCells, parser, fontsize, parser.GetClientWidth());
  BreakLines(m_appendedCells, parser.GetClientWidth());

  // Recalculate size of cells
  tmp = m_appendedCells;
  while (tmp != NULL) {
    tmp->RecalculateSize(parser,  tmp->IsMath() ? m_mathFontSize : m_fontSize);
    tmp = tmp->m_next;
  }

  // Update widths
  tmp = m_appendedCells;
  while (tmp != NULL) {
    if (tmp->BreakLineHere() || tmp == m_appendedCells) {
      m_width = MAX(m_width, tmp->GetLineWidth(scale));
      m_outputRect.width = MAX(m_outputRect.width, tmp->GetLineWidth(scale));
      m_height += tmp->GetMaxHeight();
      if (tmp->m_bigSkip)
        m_height += MC_LINE_SKIP;
      m_outputRect.height += tmp->GetMaxHeight() + MC_LINE_SKIP;
    }
    tmp = tmp->m_nextToDraw;
  }

  m_appendedCells = NULL;
}
Ejemplo n.º 5
0
void GroupCell::RecalculateWidths(CellParser& parser, int fontsize)
{
  if (m_width == -1 || m_height == -1 || parser.ForceUpdate())
  {
    // special case of 'line cell'
    if (m_groupType == GC_TYPE_PAGEBREAK) {
      m_width = 10;
      m_height = 2;
      ResetData();
      return;
    }

    UnBreakUpCells();

    double scale = parser.GetScale();
    m_input->RecalculateWidthsList(parser, fontsize);

    // recalculate the position of input in ReEvaluateSelection!
    if (m_input->m_next != NULL) {
      m_input->m_next->m_currentPoint.x = m_currentPoint.x + m_input->GetWidth() + MC_CELL_SKIP;
    }

    if (m_output == NULL || m_hide) {
      m_width = m_input->GetFullWidth(scale);
    }

    else {
      MathCell *tmp = m_output;
      while (tmp != NULL) {
        tmp->RecalculateWidths(parser, tmp->IsMath() ? m_mathFontSize : m_fontSize);
        tmp = tmp->m_next;
      }
      // This is not correct, m_width will be computed correctly in RecalculateSize!
      m_width = m_input->GetFullWidth(scale);
    }

    BreakUpCells(parser, m_fontSize, parser.GetClientWidth());
    BreakLines(parser.GetClientWidth());
  }
  ResetData();
}
Ejemplo n.º 6
0
void PsychGiveHelp(void)
{  
		printf("\nUsage:\n\n%s\n",functionUseHELP);
		if (functionSynopsisHELP != NULL) 
			printf("\n%s\n",BreakLines(functionSynopsisHELP,72));
}
Ejemplo n.º 7
0
void GroupCell::BreakLines(int fullWidth)
{
  BreakLines(m_output, fullWidth);
}