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 LimitCell::Draw(wxPoint point, int fontsize) { MathCell::Draw(point, fontsize); if (DrawThisCell(point) && InUpdateRegion()) { Configuration *configuration = Configuration::Get(); double scale = configuration->GetScale(); wxPoint base(point), under(point), name(point); name.x = point.x + MAX(m_name->GetFullWidth(scale), m_under->GetFullWidth(scale)) / 2 - m_name->GetFullWidth(scale) / 2; m_name->DrawList(name, fontsize); under.x = point.x + MAX(m_name->GetFullWidth(scale), m_under->GetFullWidth(scale)) / 2 - m_under->GetFullWidth(scale) / 2; under.y = point.y + m_name->GetMaxDrop() + m_under->GetMaxCenter(); m_under->DrawList(under, MAX(MIN_LIMIT_FONT_SIZE, fontsize - LIMIT_FONT_SIZE_DECREASE)); base.x += MAX(m_name->GetFullWidth(scale), m_under->GetFullWidth(scale)); m_base->DrawList(base, fontsize); } }
void SlideShow::Draw(wxPoint point) { Cell::Draw(point); // If the animation leaves the screen the timer is stopped automatically. if(m_animationRunning) ReloadTimer(); if (DrawThisCell(point) && (m_images[m_displayed] != NULL)) { // Start the timer once the animation appears on the screen. // But start it only once: Else the animation could be refreshed // more frequent than it can be drawn. Each update of the animation // will trigger this function and will trigger the animation to be // restarted anyway. // Configuration *configuration = (*m_configuration); if(configuration->GetPrinting()) { m_images[m_displayed]->Recalculate(configuration->GetZoomFactor() * PRINT_SIZE_MULTIPLIER); } else { m_images[m_displayed]->Recalculate(); } if (!InUpdateRegion()) return; wxDC *dc = configuration->GetDC(); wxMemoryDC bitmapDC; // Slide show cells have a red border except if they are selected if (m_drawBoundingBox) dc->SetPen(*(wxThePenList->FindOrCreatePen(configuration->GetColor(TS_SELECTION)))); else dc->SetPen(*wxRED_PEN); dc->DrawRectangle(wxRect(point.x, point.y - m_center, m_width, m_height)); wxBitmap bitmap = (configuration->GetPrinting() ? m_images[m_displayed]->GetBitmap(configuration->GetZoomFactor() * PRINT_SIZE_MULTIPLIER) : m_images[m_displayed]->GetBitmap()); bitmapDC.SelectObject(bitmap); int imageBorderWidth = m_imageBorderWidth; if (m_drawBoundingBox) { imageBorderWidth = Scale_Px(3); dc->SetBrush(*(wxTheBrushList->FindOrCreateBrush(configuration->GetColor(TS_SELECTION)))); dc->DrawRectangle(wxRect(point.x, point.y - m_center, m_width, m_height)); } dc->Blit(point.x + imageBorderWidth, point.y - m_center + imageBorderWidth, m_width - 2 * imageBorderWidth, m_height - 2 * imageBorderWidth, &bitmapDC, imageBorderWidth - m_imageBorderWidth, imageBorderWidth - m_imageBorderWidth); } else // The cell isn't drawn => No need to keep it's image cache for now. ClearCache(); // If we need a selection border on another redraw we will be informed by OnPaint() again. m_drawBoundingBox = false; }
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 DiffCell::Draw(CellParser& parser, wxPoint point, int fontsize) { MathCell::Draw(parser, point, fontsize); if (DrawThisCell(parser, point) && InUpdateRegion()) { wxPoint bs, df; df.x = point.x; df.y = point.y; m_diffCell->DrawList(parser, df, fontsize); bs.x = point.x + m_diffCell->GetFullWidth(parser.GetScale()) + 2*MC_CELL_SKIP; bs.y = point.y; m_baseCell->DrawList(parser, bs, fontsize); } }
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 ExptCell::Draw(wxPoint point) { if (DrawThisCell(point) && InUpdateRegion()) { Cell::Draw(point); wxPoint bs, pw; bs.x = point.x; bs.y = point.y; m_baseCell->DrawList(bs); pw.x = point.x + m_baseCell->GetFullWidth() - MC_TEXT_PADDING; pw.y = point.y - m_baseCell->GetMaxCenter() - m_powCell->GetMaxHeight() + m_powCell->GetMaxCenter() + Scale_Px((8 * m_fontSize) / 10 + MC_EXP_INDENT); m_powCell->DrawList(pw); } }
void ExptCell::Draw(wxPoint point, int fontsize) { MathCell::Draw(point, fontsize); if (DrawThisCell(point) && InUpdateRegion()) { Configuration *configuration = Configuration::Get(); double scale = configuration->GetScale(); wxPoint bs, pw; bs.x = point.x; bs.y = point.y; m_baseCell->DrawList(bs, fontsize); pw.x = point.x + m_baseCell->GetFullWidth(scale) - SCALE_PX(MC_TEXT_PADDING, scale); pw.y = point.y - m_baseCell->GetMaxCenter() - m_powCell->GetMaxHeight() + m_powCell->GetMaxCenter() + SCALE_PX((8 * fontsize) / 10 + MC_EXP_INDENT, scale); m_powCell->DrawList(pw, MAX(MC_MIN_SIZE, fontsize - EXPT_DEC)); } }
void SubCell::Draw(wxPoint point, int fontsize) { MathCell::Draw(point, fontsize); if (DrawThisCell(point) && InUpdateRegion()) { Configuration *configuration = Configuration::Get(); double scale = configuration->GetScale(); 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(2, scale); in.y = point.y + m_baseCell->GetMaxDrop() + m_indexCell->GetMaxCenter() - SCALE_PX((8 * fontsize) / 10 + MC_EXP_INDENT, scale); m_indexCell->DrawList(in, MAX(MC_MIN_SIZE, fontsize - SUB_DEC)); } }
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(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(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); } }