void AtCell::Draw(wxPoint point, int fontsize) { MathCell::Draw(point, fontsize); Configuration *configuration = Configuration::Get(); double scale = configuration->GetScale(); wxDC& dc = configuration->GetDC(); if (DrawThisCell(point) && InUpdateRegion()) { wxPoint bs, in; bs.x = point.x; bs.y = point.y; m_baseCell->DrawList(bs, fontsize); in.x = point.x + m_baseCell->GetFullWidth(scale) + SCALE_PX(4, scale); in.y = point.y + m_baseCell->GetMaxDrop() + + m_indexCell->GetMaxCenter() - SCALE_PX(7, scale); m_indexCell->DrawList(in, MAX(MC_MIN_SIZE, fontsize - 3)); SetPen(); dc.DrawLine(in.x - SCALE_PX(2, scale), bs.y - m_baseCell->GetMaxCenter(), in.x - SCALE_PX(2, scale), in.y); UnsetPen(); } }
void FracCell::Draw(wxPoint point) { if (DrawThisCell(point) && InUpdateRegion()) { Cell::Draw(point); Configuration *configuration = (*m_configuration); wxDC *dc = configuration->GetDC(); wxPoint num, denom; if (m_exponent && !m_isBrokenIntoLines) { num.x = point.x; num.y = point.y; denom.x = point.x + m_num->GetFullWidth() + m_expDivideWidth; denom.y = num.y; m_num->DrawList(num); m_denom->DrawList(denom); int fontsize1 = Scale_Px(m_fontSize); wxASSERT(fontsize1 > 0); dc->SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, configuration->GetFontName(TS_VARIABLE))); dc->DrawText(wxT("/"), point.x + m_num->GetFullWidth(), point.y - m_num->GetMaxCenter() + MC_TEXT_PADDING); } else { num.x = point.x + m_horizontalGapLeft + (m_width - m_horizontalGapLeft - m_horizontalGapRight - m_num->GetFullWidth()) / 2; num.y = point.y - m_num->GetMaxHeight() + m_num->GetMaxCenter() - Scale_Px(2); m_num->DrawList(num); denom.x = point.x + m_horizontalGapLeft + (m_width - m_horizontalGapLeft - m_horizontalGapRight - m_denom->GetFullWidth()) / 2; denom.y = point.y + m_denom->GetMaxCenter() + Scale_Px(2); m_denom->DrawList(denom); SetPen(1.2); if (m_fracStyle != FC_CHOOSE) dc->DrawLine(point.x + m_horizontalGapLeft + (*m_configuration)->GetDefaultLineWidth() / 2, point.y, point.x + m_width - m_horizontalGapRight - (*m_configuration)->GetDefaultLineWidth() / 2, point.y ); UnsetPen(); } } }
void FracCell::Draw(wxPoint point, int fontsize) { MathCell::Draw(point, fontsize); CellParser *parser = CellParser::Get(); if (DrawThisCell(point) && InUpdateRegion()) { wxDC& dc = parser->GetDC(); double scale = parser->GetScale(); wxPoint num, denom; if (m_exponent && !m_isBroken) { double scale = parser->GetScale(); num.x = point.x; num.y = point.y; denom.x = point.x + m_num->GetFullWidth(scale) + m_expDivideWidth; denom.y = num.y; m_num->DrawList(num, fontsize); m_denom->DrawList(denom, fontsize); int fontsize1 = (int) ((double)(fontsize) * scale + 0.5); dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, parser->GetFontName(TS_VARIABLE))); dc.DrawText(wxT("/"), point.x + m_num->GetFullWidth(scale), point.y - m_num->GetMaxCenter() + SCALE_PX(MC_TEXT_PADDING, scale)); } else { num.x = point.x + (m_width - m_num->GetFullWidth(scale)) / 2; num.y = point.y - m_num->GetMaxHeight() + m_num->GetMaxCenter() - SCALE_PX(2, scale); m_num->DrawList(num, MAX(MC_MIN_SIZE, fontsize - FRAC_DEC)); denom.x = point.x + (m_width - m_denom->GetFullWidth(scale)) / 2; denom.y = point.y + m_denom->GetMaxCenter() + SCALE_PX(2, scale); m_denom->DrawList(denom, MAX(MC_MIN_SIZE, fontsize - FRAC_DEC)); SetPen(); if (m_fracStyle != FC_CHOOSE) dc.DrawLine(point.x + m_horizontalGap, point.y, point.x + m_width - m_horizontalGap, point.y); UnsetPen(); } } }
void FracCell::Draw(CellParser& parser, wxPoint point, int fontsize, bool all) { if (DrawThisCell(parser, point)) { wxDC& dc = parser.GetDC(); double scale = parser.GetScale(); wxPoint num, denom; if (m_exponent && !m_isBroken) { double scale = parser.GetScale(); num.x = point.x; num.y = point.y; denom.x = point.x + m_num->GetFullWidth(scale) + m_expDivideWidth; denom.y = num.y; m_num->Draw(parser, num, fontsize, true); m_denom->Draw(parser, denom, fontsize, true); int fontsize1 = (int) ((double)(fontsize) * scale + 0.5); dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, false, false, false, parser.GetFontName(TS_VARIABLE))); dc.DrawText(wxT("/"), point.x + m_num->GetFullWidth(scale), point.y - m_num->GetMaxCenter() + SCALE_PX(MC_TEXT_PADDING, scale)); } else { num.x = point.x + (m_width - m_num->GetFullWidth(scale)) / 2; num.y = point.y - m_num->GetMaxHeight() + m_num->GetMaxCenter() - SCALE_PX(2, scale); m_num->Draw(parser, num, MAX(MC_MIN_SIZE, fontsize - FRAC_DEC), true); denom.x = point.x + (m_width - m_denom->GetFullWidth(scale)) / 2; denom.y = point.y + m_denom->GetMaxCenter() + SCALE_PX(2, scale); m_denom->Draw(parser, denom, MAX(MC_MIN_SIZE, fontsize - FRAC_DEC), true); SetPen(parser); if (m_fracStyle != FC_CHOOSE) dc.DrawLine(point.x, point.y, point.x + m_width, point.y); UnsetPen(parser); } } MathCell::Draw(parser, point, fontsize, all); }
void ConjugateCell::Draw(CellParser& parser, wxPoint point, int fontsize) { double scale = parser.GetScale(); wxDC& dc = parser.GetDC(); if (DrawThisCell(parser, point)) { SetPen(parser); wxPoint in; in.x = point.x + SCALE_PX(4, scale); in.y = point.y; m_innerCell->DrawList(parser, in, fontsize); dc.DrawLine(point.x + SCALE_PX(2, scale), point.y - m_center + SCALE_PX(2, scale), point.x + m_width - SCALE_PX(2, scale) - 1, point.y - m_center + SCALE_PX(2, scale) ); // point.y - m_center + m_height - SCALE_PX(2, scale)); UnsetPen(parser); } MathCell::Draw(parser, point, fontsize); }
void ConjugateCell::Draw(wxPoint point) { Cell::Draw(point); if (DrawThisCell(point) && InUpdateRegion()) { Configuration *configuration = (*m_configuration); wxDC *dc = configuration->GetDC(); SetPen(); wxPoint in; in.x = point.x + Scale_Px(4); in.y = point.y; m_innerCell->DrawList(in); dc->DrawLine(point.x + Scale_Px(2), point.y - m_center + Scale_Px(2), point.x + m_width - Scale_Px(2) - 1, point.y - m_center + Scale_Px(2) ); // point.y - m_center + m_height - Scale_Px(2)); UnsetPen(); } }
void SqrtCell::Draw(CellParser& parser, wxPoint point, int fontsize, bool all) { if (DrawThisCell(parser, point)) { wxDC& dc = parser.GetDC(); double scale = parser.GetScale(); wxPoint in(point); if (parser.CheckTeXFonts()) { SetPen(parser); in.x += m_signWidth; double scale = parser.GetScale(); int fontsize1 = (int)(SIGN_FONT_SCALE*scale*fontsize*m_signFontScale + 0.5); dc.SetFont(wxFont(fontsize1, wxMODERN, false, false, false, parser.GetTeXCMEX())); SetForeground(parser); if (m_signType < 4) { dc.DrawText( m_signType == 1 ? wxT("p") : m_signType == 2 ? wxT("q") : m_signType == 3 ? wxT("r") : wxT("s"), point.x, point.y - m_innerCell->GetMaxCenter() - m_signTop); } else { int yBottom = point.y + m_innerCell->GetMaxDrop() - 3.2*m_signTop; int yTop = point.y - m_innerCell->GetMaxCenter() - m_signTop; int dy = m_signSize / 10; dc.DrawText(wxT("t"), point.x, yBottom); dc.DrawText(wxT("v"), point.x, yTop); while (yTop < yBottom) { yTop += dy; dc.DrawText(wxT("u"), point.x, yTop); } } dc.DrawLine(point.x + m_signWidth, point.y - m_innerCell->GetMaxCenter(), point.x + m_signWidth + m_innerCell->GetFullWidth(scale), point.y - m_innerCell->GetMaxCenter()); UnsetPen(parser); } else { in.x += SCALE_PX(10, scale) + SCALE_PX(1, scale) + 1; SetPen(parser); dc.DrawLine(point.x, point.y, point.x + SCALE_PX(3, scale), point.y - SCALE_PX(1, scale)); dc.DrawLine(point.x + SCALE_PX(3, scale), point.y - SCALE_PX(1, scale), point.x + SCALE_PX(7, scale), point.y + m_height - m_center - SCALE_PX(4, scale)); dc.DrawLine(point.x + SCALE_PX(3, scale) + 1, point.y - SCALE_PX(1, scale), point.x + SCALE_PX(7, scale) + 1, point.y + m_height - m_center - SCALE_PX(4, scale)); dc.DrawLine(point.x + SCALE_PX(7, scale) + 1, point.y + m_height - m_center - SCALE_PX(4, scale), point.x + SCALE_PX(10, scale), point.y - m_center + SCALE_PX(2, scale)); dc.DrawLine(point.x + SCALE_PX(10, scale), point.y - m_center + SCALE_PX(2, scale), point.x + m_width - SCALE_PX(1, scale), point.y - m_center + SCALE_PX(2, scale)); dc.DrawLine(point.x + m_width - SCALE_PX(1, scale), point.y - m_center + SCALE_PX(2, scale), point.x + m_width - SCALE_PX(1, scale), point.y - m_center + SCALE_PX(6, scale)); UnsetPen(parser); } m_innerCell->Draw(parser, in, fontsize, true); } MathCell::Draw(parser, point, fontsize, all); }
void ParenCell::Draw(CellParser& parser, wxPoint point, int fontsize) { if (DrawThisCell(parser, point)) { double scale = parser.GetScale(); wxDC& dc = parser.GetDC(); wxPoint in(point); if (parser.CheckTeXFonts()) { in.x = point.x + m_signWidth; SetForeground(parser); int fontsize1 = (int) ((m_parenFontSize * scale + 0.5)); dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, m_bigParenType < 1 ? parser.GetTeXCMRI() : parser.GetTeXCMEX())); if (m_bigParenType < 2) { dc.DrawText(m_bigParenType == 0 ? wxT("(") : wxT(PAREN_OPEN), point.x, point.y - m_center + SCALE_PX(MC_TEXT_PADDING, scale) - (m_bigParenType > 0 ? m_signTop : 0)); dc.DrawText(m_bigParenType == 0 ? wxT(")") : wxT(PAREN_CLOSE), point.x + m_signWidth + m_innerCell->GetFullWidth(scale), point.y - m_center + SCALE_PX(MC_TEXT_PADDING, scale) - (m_bigParenType > 0 ? m_signTop : 0)); } else { int top = point.y - m_center - m_signTop; int bottom = point.y + m_height - m_center - m_signTop - m_signSize / 2; dc.DrawText(wxT(PAREN_OPEN_TOP), point.x, top); dc.DrawText(wxT(PAREN_CLOSE_TOP), point.x + m_signWidth + m_innerCell->GetFullWidth(scale), top); dc.DrawText(wxT(PAREN_OPEN_BOTTOM), point.x, bottom); dc.DrawText(wxT(PAREN_CLOSE_BOTTOM), point.x + m_signWidth + m_innerCell->GetFullWidth(scale), bottom); top = top + m_signSize / 2; if (top <= bottom) { while (top < bottom) { dc.DrawText(wxT(PAREN_OPEN_EXTEND), point.x, top-1); dc.DrawText(wxT(PAREN_CLOSE_EXTEND), point.x + m_width - m_signWidth, top-1); top += m_signSize / 10; } } } } else { #if defined __WXMSW__ in.x += m_charWidth; int fontsize1 = (int) ((PAREN_FONT_SIZE * scale + 0.5)); SetForeground(parser); if (m_height < (3*m_charHeight)/2) { fontsize1 = (int) ((fontsize * scale + 0.5)); dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, parser.GetFontName())); dc.DrawText(wxT("("), point.x + m_charWidth - m_charWidth1, point.y - m_charHeight1 / 2); dc.DrawText(wxT(")"), point.x + m_width - m_charWidth, point.y - m_charHeight1 / 2); } else { dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, parser.GetSymbolFontName(), wxFONTENCODING_CP1250)); dc.DrawText(PAREN_LEFT_TOP, point.x, point.y - m_center); dc.DrawText(PAREN_LEFT_BOTTOM, point.x, point.y + m_height - m_center - m_charHeight); dc.DrawText(PAREN_RIGHT_TOP, point.x + m_width - m_charWidth, point.y - m_center); dc.DrawText(PAREN_RIGHT_BOTTOM, point.x + m_width - m_charWidth, point.y + m_height - m_center - m_charHeight); int top, bottom; top = point.y - m_center + m_charHeight/2; bottom = point.y + m_height - m_center - (4*m_charHeight)/3; if (top <= bottom) { while (top < bottom) { dc.DrawText(PAREN_LEFT_EXTEND, point.x, top); dc.DrawText(PAREN_RIGHT_EXTEND, point.x + m_width - m_charWidth, top); top += (2*m_charHeight)/3; } dc.DrawText(PAREN_LEFT_EXTEND, point.x, point.y + m_height - m_center - (3*m_charHeight)/2); dc.DrawText(PAREN_RIGHT_EXTEND, point.x + m_width - m_charWidth, point.y + m_height - m_center - (3*m_charHeight)/2); } } #else in.x = point.x + SCALE_PX(6, scale); SetPen(parser); // left dc.DrawLine(point.x + SCALE_PX(5, scale), point.y - m_innerCell->GetMaxCenter() + SCALE_PX(1, scale), point.x + SCALE_PX(2, scale), point.y - m_innerCell->GetMaxCenter() + SCALE_PX(7, scale)); dc.DrawLine(point.x + SCALE_PX(2, scale), point.y - m_innerCell->GetMaxCenter() + SCALE_PX(7, scale), point.x + SCALE_PX(2, scale), point.y + m_innerCell->GetMaxDrop() - SCALE_PX(7, scale)); dc.DrawLine(point.x + SCALE_PX(2, scale), point.y + m_innerCell->GetMaxDrop() - SCALE_PX(7, scale), point.x + SCALE_PX(5, scale), point.y + m_innerCell->GetMaxDrop() - SCALE_PX(1, scale)); // right dc.DrawLine(point.x + m_width - SCALE_PX(5, scale) - 1, point.y - m_innerCell->GetMaxCenter() + SCALE_PX(1, scale), point.x + m_width - SCALE_PX(2, scale) - 1, point.y - m_innerCell->GetMaxCenter() + SCALE_PX(7, scale)); dc.DrawLine(point.x + m_width - SCALE_PX(2, scale) - 1, point.y - m_innerCell->GetMaxCenter() + SCALE_PX(7, scale), point.x + m_width - SCALE_PX(2, scale) - 1, point.y + m_innerCell->GetMaxDrop() - SCALE_PX(7, scale)); dc.DrawLine(point.x + m_width - SCALE_PX(2, scale) - 1, point.y + m_innerCell->GetMaxDrop() - SCALE_PX(7, scale), point.x + m_width - SCALE_PX(5, scale) - 1, point.y + m_innerCell->GetMaxDrop() - SCALE_PX(1, scale)); UnsetPen(parser); #endif } m_innerCell->DrawList(parser, in, fontsize); } MathCell::Draw(parser, point, fontsize); }
void SqrtCell::Draw(wxPoint point, int fontsize) { MathCell::Draw(point, fontsize); CellParser *parser = CellParser::Get(); if (DrawThisCell(point) && InUpdateRegion()) { wxDC& dc = parser->GetDC(); double scale = parser->GetScale(); wxPoint in(point); if (parser->CheckTeXFonts()) { SetPen(); in.x += m_signWidth; double scale = parser->GetScale(); int fontsize1 = (int)(SIGN_FONT_SCALE*scale*fontsize*m_signFontScale + 0.5); dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, parser->GetTeXCMEX())); SetForeground(); if (m_signType < 4) { dc.DrawText( m_signType == 1 ? wxT("p") : m_signType == 2 ? wxT("q") : m_signType == 3 ? wxT("r") : wxT("s"), point.x, point.y - m_innerCell->GetMaxCenter() - m_signTop); } else { int yBottom = point.y + m_innerCell->GetMaxDrop() - 3.2*m_signTop; int yTop = point.y - m_innerCell->GetMaxCenter() - m_signTop; int dy = m_signSize / 10; wxASSERT_MSG((yTop != 0) || (yBottom != 0),_("Font issue? The contents of a sqrt() has the size 0.")); wxASSERT_MSG(dy>0,_("Font issue: The sqrt() sign has the size 0! Installing http://www.math.union.edu/~dpvc/jsmath/download/jsMath-fonts.html and checking \"Use JSmath fonts\" in the configuration dialogue should be a workaround.")); if(dy <= 0) dy = 1; dc.DrawText(wxT("t"), point.x, yBottom); dc.DrawText(wxT("v"), point.x, yTop); while (yTop < yBottom) { yTop += dy; dc.DrawText(wxT("u"), point.x, yTop); } } dc.DrawLine(point.x + m_signWidth, point.y - m_innerCell->GetMaxCenter(), point.x + m_signWidth + m_innerCell->GetFullWidth(scale), point.y - m_innerCell->GetMaxCenter()); UnsetPen(); } else { in.x += SCALE_PX(10, scale) + SCALE_PX(1, scale) + 1; SetPen(); dc.DrawLine(point.x, point.y, point.x + SCALE_PX(3, scale), point.y - SCALE_PX(1, scale)); dc.DrawLine(point.x + SCALE_PX(3, scale), point.y - SCALE_PX(1, scale), point.x + SCALE_PX(7, scale), point.y + m_height - m_center - SCALE_PX(4, scale)); dc.DrawLine(point.x + SCALE_PX(3, scale) + 1, point.y - SCALE_PX(1, scale), point.x + SCALE_PX(7, scale) + 1, point.y + m_height - m_center - SCALE_PX(4, scale)); dc.DrawLine(point.x + SCALE_PX(7, scale) + 1, point.y + m_height - m_center - SCALE_PX(4, scale), point.x + SCALE_PX(10, scale), point.y - m_center + SCALE_PX(2, scale)); dc.DrawLine(point.x + SCALE_PX(10, scale), point.y - m_center + SCALE_PX(2, scale), point.x + m_width - SCALE_PX(1, scale), point.y - m_center + SCALE_PX(2, scale)); dc.DrawLine(point.x + m_width - SCALE_PX(1, scale), point.y - m_center + SCALE_PX(2, scale), point.x + m_width - SCALE_PX(1, scale), point.y - m_center + SCALE_PX(6, scale)); UnsetPen(); } m_innerCell->DrawList(in, fontsize); } }
void IntCell::Draw(CellParser& parser, wxPoint point, int fontsize, bool all) { if (DrawThisCell(parser, point)) { wxDC& dc = parser.GetDC(); double scale = parser.GetScale(); wxPoint base(point), under(point), over(point), var(point), sign(point); if (parser.CheckTeXFonts()) { SetForeground(parser); int fontsize1 = (int) ((fontsize * scale * 1.5 + 0.5)); dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, false, false, false, parser.GetTeXCMEX())); dc.DrawText(wxT("\x5A"), sign.x, sign.y - m_signTop); } else { #if defined __WXMSW__ SetForeground(parser); int fontsize1 = (int) ((INTEGRAL_FONT_SIZE * scale + 0.5)); int m_signWCenter = m_signWidth / 2; dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, false, false, false, parser.GetSymbolFontName())); dc.DrawText(wxT(INTEGRAL_TOP), sign.x + m_signWCenter - m_charWidth / 2, sign.y - (m_signSize + 1) / 2); dc.DrawText(wxT(INTEGRAL_BOTTOM), sign.x + m_signWCenter - m_charWidth / 2, sign.y + (m_signSize + 1) / 2 - m_charHeight); int top, bottom; top = sign.y - (m_signSize + 1) / 2 + m_charHeight / 2; bottom = sign.y + (m_signSize + 1) / 2 - (3 * m_charHeight) / 2; if (top <= bottom) { while (top < bottom) { dc.DrawText(wxT(INTEGRAL_EXTEND), point.x + m_signWCenter - m_charWidth / 2, top); top += (2*m_charHeight)/3; } dc.DrawText(wxT(INTEGRAL_EXTEND), point.x + m_signWCenter - m_charWidth / 2, sign.y + (m_signSize + 1) / 2 - (3 * m_charHeight) / 2); } #else SetPen(parser); // top decoration int m_signWCenter = m_signWidth / 2; dc.DrawLine(sign.x + m_signWCenter, sign.y - (m_signSize + 1) / 2 + SCALE_PX(12, scale) - 1, sign.x + m_signWCenter + SCALE_PX(3, scale), sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale)); dc.DrawLine(sign.x + m_signWCenter + SCALE_PX(3, scale), sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale), sign.x + m_signWCenter + SCALE_PX(6, scale), sign.y - (m_signSize + 1) / 2); dc.DrawLine(sign.x + m_signWCenter + SCALE_PX(6, scale), sign.y - (m_signSize + 1) / 2, sign.x + m_signWCenter + SCALE_PX(9, scale), sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale)); // bottom decoration dc.DrawLine(sign.x + m_signWCenter, sign.y + (m_signSize + 1) / 2 - SCALE_PX(12, scale) + 1, sign.x + m_signWCenter - SCALE_PX(3, scale), sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale)); dc.DrawLine(sign.x + m_signWCenter - SCALE_PX(3, scale), sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale), sign.x + m_signWCenter - SCALE_PX(6, scale), sign.y + (m_signSize + 1) / 2); dc.DrawLine(sign.x + m_signWCenter - SCALE_PX(6, scale), sign.y + (m_signSize + 1) / 2, sign.x + m_signWCenter - SCALE_PX(9, scale), sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale)); // line dc.DrawLine(sign.x + m_signWCenter, sign.y - (m_signSize + 1) / 2 + SCALE_PX(12, scale) - 1, sign.x + m_signWCenter, sign.y + (m_signSize + 1) / 2 - SCALE_PX(12, scale) + 1); UnsetPen(parser); #endif } if (m_intStyle == INT_DEF) { under.x += m_signWidth; under.y = point.y + m_signSize / 2 + m_under->GetMaxCenter() + SCALE_PX(2, scale) - m_signSize / 3; m_under->Draw(parser, under, MAX(MC_MIN_SIZE, fontsize - 5), true); if (parser.CheckTeXFonts()) over.x += 2*m_signWidth; else over.x += m_signWidth; over.y = point.y - m_signSize / 2 - m_over->GetMaxDrop() - SCALE_PX(2, scale) + m_signSize / 3; m_over->Draw(parser, over, MAX(MC_MIN_SIZE, fontsize - 5), true); if (parser.CheckTeXFonts()) { base.x += m_signWidth + MAX(m_over->GetFullWidth(scale) + m_signWidth, m_under->GetFullWidth(scale)); } else base.x += m_signWidth + MAX(m_over->GetFullWidth(scale), m_under->GetFullWidth(scale)); } else if (parser.CheckTeXFonts()) base.x += 2*m_signWidth; else base.x += m_signWidth; m_base->Draw(parser, base, fontsize, true); var.x = base.x + m_base->GetFullWidth(scale); m_var->Draw(parser, var, fontsize, true); } MathCell::Draw(parser, point, fontsize, all); }
void ParenCell::Draw(CellParser& parser, wxPoint point, int fontsize) { if (DrawThisCell(parser, point)) { double scale = parser.GetScale(); wxDC& dc = parser.GetDC(); wxPoint in(point); if (parser.CheckTeXFonts()) { in.x = point.x + m_signWidth; SetForeground(parser); int fontsize1 = (int) ((m_parenFontSize * scale + 0.5)); dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, m_bigParenType < 1 ? parser.GetTeXCMRI() : parser.GetTeXCMEX())); if (m_bigParenType < 2) { dc.DrawText(m_bigParenType == 0 ? wxT("(") : wxT(PAREN_OPEN), point.x, point.y - m_center + SCALE_PX(MC_TEXT_PADDING, scale) - (m_bigParenType > 0 ? m_signTop : 0)); dc.DrawText(m_bigParenType == 0 ? wxT(")") : wxT(PAREN_CLOSE), point.x + m_signWidth + m_innerCell->GetFullWidth(scale), point.y - m_center + SCALE_PX(MC_TEXT_PADDING, scale) - (m_bigParenType > 0 ? m_signTop : 0)); } else { int top = point.y - m_center - m_signTop; int bottom = point.y + m_height - m_center - m_signTop - m_signSize / 2; dc.DrawText(wxT(PAREN_OPEN_TOP), point.x, top); dc.DrawText(wxT(PAREN_CLOSE_TOP), point.x + m_signWidth + m_innerCell->GetFullWidth(scale), top); dc.DrawText(wxT(PAREN_OPEN_BOTTOM), point.x, bottom); dc.DrawText(wxT(PAREN_CLOSE_BOTTOM), point.x + m_signWidth + m_innerCell->GetFullWidth(scale), bottom); top = top + m_signSize / 2; wxASSERT_MSG(m_signSize>=10,_("Font issue: The Parenthesis sign is too small!")); if(m_signSize <= 10) m_signSize = 10; if (top <= bottom) { while (top < bottom) { dc.DrawText(wxT(PAREN_OPEN_EXTEND), point.x, top-1); dc.DrawText(wxT(PAREN_CLOSE_EXTEND), point.x + m_width - m_signWidth, top-1); top += m_signSize / 10; } } } } else { #if defined __WXMSW__ in.x += m_charWidth; int fontsize1 = (int) ((PAREN_FONT_SIZE * scale + 0.5)); SetForeground(parser); if (m_height < (3*m_charHeight)/2) { fontsize1 = (int) ((fontsize * scale + 0.5)); dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, parser.GetFontName())); dc.DrawText(wxT("("), point.x + m_charWidth - m_charWidth1, point.y - m_charHeight1 / 2); dc.DrawText(wxT(")"), point.x + m_width - m_charWidth, point.y - m_charHeight1 / 2); } else { dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, parser.GetSymbolFontName(), wxFONTENCODING_CP1250)); dc.DrawText(PAREN_LEFT_TOP, point.x, point.y - m_center); dc.DrawText(PAREN_LEFT_BOTTOM, point.x, point.y + m_height - m_center - m_charHeight); dc.DrawText(PAREN_RIGHT_TOP, point.x + m_width - m_charWidth, point.y - m_center); dc.DrawText(PAREN_RIGHT_BOTTOM, point.x + m_width - m_charWidth, point.y + m_height - m_center - m_charHeight); int top, bottom; top = point.y - m_center + m_charHeight/2; bottom = point.y + m_height - m_center - (4*m_charHeight)/3; wxASSERT_MSG(m_charHeight>=2,_("Font issue: The char height is too small! Installing http://www.math.union.edu/~dpvc/jsmath/download/jsMath-fonts.html and checking \"Use JSmath fonts\" in the configuration dialogue should be a workaround.")); if(m_charHeight <= 2) m_charHeight = 2; if (top <= bottom) { while (top < bottom) { dc.DrawText(PAREN_LEFT_EXTEND, point.x, top); dc.DrawText(PAREN_RIGHT_EXTEND, point.x + m_width - m_charWidth, top); top += (2*m_charHeight)/3; } dc.DrawText(PAREN_LEFT_EXTEND, point.x, point.y + m_height - m_center - (3*m_charHeight)/2); dc.DrawText(PAREN_RIGHT_EXTEND, point.x + m_width - m_charWidth, point.y + m_height - m_center - (3*m_charHeight)/2); } } #else in.x = point.x + SCALE_PX(6, scale); SetPen(parser); // left dc.DrawLine(point.x + SCALE_PX(5, scale), point.y - m_innerCell->GetMaxCenter() + SCALE_PX(1, scale), point.x + SCALE_PX(2, scale), point.y - m_innerCell->GetMaxCenter() + SCALE_PX(7, scale)); dc.DrawLine(point.x + SCALE_PX(2, scale), point.y - m_innerCell->GetMaxCenter() + SCALE_PX(7, scale), point.x + SCALE_PX(2, scale), point.y + m_innerCell->GetMaxDrop() - SCALE_PX(7, scale)); dc.DrawLine(point.x + SCALE_PX(2, scale), point.y + m_innerCell->GetMaxDrop() - SCALE_PX(7, scale), point.x + SCALE_PX(5, scale), point.y + m_innerCell->GetMaxDrop() - SCALE_PX(1, scale)); // right dc.DrawLine(point.x + m_width - SCALE_PX(5, scale) - 1, point.y - m_innerCell->GetMaxCenter() + SCALE_PX(1, scale), point.x + m_width - SCALE_PX(2, scale) - 1, point.y - m_innerCell->GetMaxCenter() + SCALE_PX(7, scale)); dc.DrawLine(point.x + m_width - SCALE_PX(2, scale) - 1, point.y - m_innerCell->GetMaxCenter() + SCALE_PX(7, scale), point.x + m_width - SCALE_PX(2, scale) - 1, point.y + m_innerCell->GetMaxDrop() - SCALE_PX(7, scale)); dc.DrawLine(point.x + m_width - SCALE_PX(2, scale) - 1, point.y + m_innerCell->GetMaxDrop() - SCALE_PX(7, scale), point.x + m_width - SCALE_PX(5, scale) - 1, point.y + m_innerCell->GetMaxDrop() - SCALE_PX(1, scale)); UnsetPen(parser); #endif } m_innerCell->DrawList(parser, in, fontsize); } MathCell::Draw(parser, point, fontsize); }
void IntCell::Draw(wxPoint point, int fontsize) { MathCell::Draw(point, fontsize); CellParser *parser = CellParser::Get(); if (DrawThisCell(point) && InUpdateRegion()) { wxDC& dc = parser->GetDC(); double scale = parser->GetScale(); wxPoint base(point), under(point), over(point), var(point), sign(point); if (parser->CheckTeXFonts()) { SetForeground(); int fontsize1 = (int) ((fontsize * scale * 1.5 + 0.5)); dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, parser->GetTeXCMEX())); dc.DrawText(wxT("\x5A"), sign.x, sign.y - m_signTop); } else { #if defined __WXMSW__ SetForeground(); int fontsize1 = (int) ((INTEGRAL_FONT_SIZE * scale + 0.5)); int m_signWCenter = m_signWidth / 2; dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, parser->GetSymbolFontName())); dc.DrawText(INTEGRAL_TOP, sign.x + m_signWCenter - m_charWidth / 2, sign.y - (m_signSize + 1) / 2); dc.DrawText(INTEGRAL_BOTTOM, sign.x + m_signWCenter - m_charWidth / 2, sign.y + (m_signSize + 1) / 2 - m_charHeight); int top, bottom; top = sign.y - (m_signSize + 1) / 2 + m_charHeight / 2; bottom = sign.y + (m_signSize + 1) / 2 - (3 * m_charHeight) / 2; if (top <= bottom) { wxASSERT_MSG(m_charHeight>=2,_("Font issue: The char height is too small! Installing http://www.math.union.edu/~dpvc/jsmath/download/jsMath-fonts.html and checking \"Use JSmath fonts\" in the configuration dialogue should be a workaround.")); if(m_charHeight <= 2) m_charHeight = 2; while (top < bottom) { dc.DrawText(INTEGRAL_EXTEND, point.x + m_signWCenter - m_charWidth / 2, top); top += (2*m_charHeight)/3; } dc.DrawText(INTEGRAL_EXTEND, point.x + m_signWCenter - m_charWidth / 2, sign.y + (m_signSize + 1) / 2 - (3 * m_charHeight) / 2); } #else SetPen(); // top decoration int m_signWCenter = m_signWidth / 2; dc.DrawLine(sign.x + m_signWCenter, sign.y - (m_signSize + 1) / 2 + SCALE_PX(12, scale) - 1, sign.x + m_signWCenter + SCALE_PX(3, scale), sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale)); dc.DrawLine(sign.x + m_signWCenter + SCALE_PX(3, scale), sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale), sign.x + m_signWCenter + SCALE_PX(6, scale), sign.y - (m_signSize + 1) / 2); dc.DrawLine(sign.x + m_signWCenter + SCALE_PX(6, scale), sign.y - (m_signSize + 1) / 2, sign.x + m_signWCenter + SCALE_PX(9, scale), sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale)); // bottom decoration dc.DrawLine(sign.x + m_signWCenter, sign.y + (m_signSize + 1) / 2 - SCALE_PX(12, scale) + 1, sign.x + m_signWCenter - SCALE_PX(3, scale), sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale)); dc.DrawLine(sign.x + m_signWCenter - SCALE_PX(3, scale), sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale), sign.x + m_signWCenter - SCALE_PX(6, scale), sign.y + (m_signSize + 1) / 2); dc.DrawLine(sign.x + m_signWCenter - SCALE_PX(6, scale), sign.y + (m_signSize + 1) / 2, sign.x + m_signWCenter - SCALE_PX(9, scale), sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale)); // line dc.DrawLine(sign.x + m_signWCenter, sign.y - (m_signSize + 1) / 2 + SCALE_PX(12, scale) - 1, sign.x + m_signWCenter, sign.y + (m_signSize + 1) / 2 - SCALE_PX(12, scale) + 1); UnsetPen(); #endif } if (m_intStyle == INT_DEF) { under.x += m_signWidth; under.y = point.y + m_signSize / 2 + m_under->GetMaxCenter() + SCALE_PX(2, scale) - m_signSize / 3; m_under->DrawList(under, MAX(MC_MIN_SIZE, fontsize - 5)); if (parser->CheckTeXFonts()) over.x += 2*m_signWidth; else over.x += m_signWidth; over.y = point.y - m_signSize / 2 - m_over->GetMaxDrop() - SCALE_PX(2, scale) + m_signSize / 3; m_over->DrawList(over, MAX(MC_MIN_SIZE, fontsize - 5)); if (parser->CheckTeXFonts()) { base.x += m_signWidth + MAX(m_over->GetFullWidth(scale) + m_signWidth, m_under->GetFullWidth(scale)); } else base.x += m_signWidth + MAX(m_over->GetFullWidth(scale), m_under->GetFullWidth(scale)); } else if (parser->CheckTeXFonts()) base.x += 2*m_signWidth; else base.x += m_signWidth; m_base->DrawList(base, fontsize); var.x = base.x + m_base->GetFullWidth(scale); m_var->DrawList(var, fontsize); } }
void GroupCell::Draw(CellParser& parser, wxPoint point, int fontsize) { double scale = parser.GetScale(); wxDC& dc = parser.GetDC(); if (m_width == -1 || m_height == -1) { RecalculateWidths(parser, fontsize); RecalculateSize(parser, fontsize); } if (DrawThisCell(parser, point)) { // draw a thick line for 'page break' // and return if (m_groupType == GC_TYPE_PAGEBREAK) { wxRect rect = GetRect(false); int y = rect.GetY(); wxPen pen(parser.GetColor(TS_CURSOR), 1, wxPENSTYLE_DOT); dc.SetPen(pen); dc.DrawLine(0, y , 10000, y); MathCell::Draw(parser, point, fontsize); return; } // // Paint background if we have a text cell // if (m_groupType == GC_TYPE_TEXT) { wxRect rect = GetRect(false); int y = rect.GetY(); if (m_height > 0 && m_width > 0 && y>=0) { wxBrush br(parser.GetColor(TS_TEXT_BACKGROUND)); dc.SetBrush(br); wxPen pen(parser.GetColor(TS_TEXT_BACKGROUND)); dc.SetPen(pen); dc.DrawRectangle(0, y , 10000, rect.GetHeight()); } } // // Draw input and output // SetPen(parser); wxPoint in(point); parser.Outdated(false); m_input->DrawList(parser, in, fontsize); if (m_groupType == GC_TYPE_CODE && m_input->m_next) parser.Outdated(((EditorCell *)(m_input->m_next))->ContainsChanges()); if (m_output != NULL && !m_hide) { MathCell *tmp = m_output; int drop = tmp->GetMaxDrop(); in.y += m_input->GetMaxDrop() + m_output->GetMaxCenter(); m_outputRect.y = in.y - m_output->GetMaxCenter(); m_outputRect.x = in.x; while (tmp != NULL) { if (!tmp->m_isBroken) { tmp->m_currentPoint.x = in.x; tmp->m_currentPoint.y = in.y; if (tmp->DrawThisCell(parser, in)) tmp->Draw(parser, in, MAX(tmp->IsMath() ? m_mathFontSize : m_fontSize, MC_MIN_SIZE)); if (tmp->m_nextToDraw != NULL) { if (tmp->m_nextToDraw->BreakLineHere()) { in.x = m_indent; in.y += drop + tmp->m_nextToDraw->GetMaxCenter(); if (tmp->m_bigSkip) in.y += MC_LINE_SKIP; drop = tmp->m_nextToDraw->GetMaxDrop(); } else in.x += (tmp->GetWidth() + MC_CELL_SKIP); } } else { if (tmp->m_nextToDraw != NULL && tmp->m_nextToDraw->BreakLineHere()) { in.x = m_indent; in.y += drop + tmp->m_nextToDraw->GetMaxCenter(); if (tmp->m_bigSkip) in.y += MC_LINE_SKIP; drop = tmp->m_nextToDraw->GetMaxDrop(); } } tmp = tmp->m_nextToDraw; } } parser.Outdated(false); MathCell *editable = GetEditable(); if (editable != NULL && editable->IsActive()) { dc.SetPen( *(wxThePenList->FindOrCreatePen(parser.GetColor(TS_ACTIVE_CELL_BRACKET), 2, wxPENSTYLE_SOLID))); // window linux, set a pen dc.SetBrush( *(wxTheBrushList->FindOrCreateBrush(parser.GetColor(TS_ACTIVE_CELL_BRACKET)))); //highlight c. } else { dc.SetPen( *(wxThePenList->FindOrCreatePen(parser.GetColor(TS_CELL_BRACKET), 1, wxPENSTYLE_SOLID))); // window linux, set a pen dc.SetBrush( *(wxTheBrushList->FindOrCreateBrush(parser.GetColor(TS_CELL_BRACKET)))); //highlight c. } if ((!m_hide) && (!m_hiddenTree)) { dc.SetBrush(*wxTRANSPARENT_BRUSH); } if (IsFoldable()) { // draw a square wxPoint *points = new wxPoint[4]; points[0].x = point.x - SCALE_PX(10, scale); points[0].y = point.y - m_center; points[1].x = point.x - SCALE_PX(10, scale); points[1].y = point.y - m_center + SCALE_PX(10, scale); points[2].x = point.x; points[2].y = point.y - m_center + SCALE_PX(10, scale); points[3].x = point.x; points[3].y = point.y - m_center; dc.DrawPolygon(4, points); delete [] points; } else { // draw a triangle and line wxPoint *points = new wxPoint[3]; points[0].x = point.x - SCALE_PX(10, scale); points[0].y = point.y - m_center; points[1].x = point.x - SCALE_PX(10, scale); points[1].y = point.y - m_center + SCALE_PX(10, scale); points[2].x = point.x; points[2].y = point.y - m_center; dc.DrawPolygon(3, points); delete [] points; // vertical dc.DrawLine(point.x - SCALE_PX(10, scale), point.y - m_center, point.x - SCALE_PX(10, scale), point.y - m_center + m_height); // bottom horizontal dc.DrawLine(point.x - SCALE_PX(10, scale), point.y - m_center + m_height, point.x - SCALE_PX(2, scale) , point.y - m_center + m_height); // middle horizontal if (m_groupType == GC_TYPE_CODE && m_output != NULL && !m_hide) { dc.DrawLine(point.x - SCALE_PX(6, scale), point.y - m_center + m_input->GetMaxHeight(), point.x - SCALE_PX(10, scale), point.y - m_center + m_input->GetMaxHeight()); } } UnsetPen(parser); } MathCell::Draw(parser, point, fontsize); }