JIndex JNamedConstant::PrepareToRender ( const JExprRenderer& renderer, const JPoint& upperLeft, const JSize fontSize, JExprRectList* rectList ) { if (strcmp(JPGetStdNamedConstName(itsNameIndex), JPGetPiString()) == 0) { JRect ourRect; ourRect.top = upperLeft.y; ourRect.left = upperLeft.x; ourRect.bottom = upperLeft.y + renderer.GetLineHeight(fontSize); ourRect.right = upperLeft.x + renderer.GetGreekCharWidth(fontSize, kGreekPiChar); const JCoordinate ourMidline = ourRect.ycenter(); return rectList->AddRect(ourRect, ourMidline, fontSize, this); } else { return JFunction::PrepareToRender(renderer, upperLeft, fontSize, rectList); } }
void JFunctionWithVar::DrawString ( const JExprRenderer& renderer, const JCoordinate left, const JCoordinate midline, const JSize fontSize, const JString& str ) const { JCoordinate x = left; const JCharacter* greekPrefix = JPGetGreekCharPrefixString(); const JSize greekPrefixLength = JPGetGreekCharPrefixLength(); JString s = str; JIndex greekIndex; while (s.LocateSubstring(greekPrefix, &greekIndex) && greekIndex < s.GetLength() - greekPrefixLength + 1) { if (greekIndex > 1) { const JString s1 = s.GetSubstring(1, greekIndex-1); renderer.DrawString(x, midline, fontSize, s1); x += renderer.GetStringWidth(fontSize, s1); } const JCharacter c = s.GetCharacter(greekIndex + greekPrefixLength); renderer.DrawGreekCharacter(x, midline, fontSize, c); x += renderer.GetGreekCharWidth(fontSize, c); s.RemoveSubstring(1, greekIndex + greekPrefixLength); } if (!s.IsEmpty()) { renderer.DrawString(x, midline, fontSize, s); } }
JSize JFunctionWithVar::GetStringWidth ( const JExprRenderer& renderer, const JSize fontSize, const JString& str ) const { JSize w = 0; const JCharacter* greekPrefix = JPGetGreekCharPrefixString(); const JSize greekPrefixLength = JPGetGreekCharPrefixLength(); JString s = str; JIndex greekIndex; while (s.LocateSubstring(greekPrefix, &greekIndex) && greekIndex < s.GetLength() - greekPrefixLength + 1) { if (greekIndex > 1) { const JString s1 = s.GetSubstring(1, greekIndex-1); w += renderer.GetStringWidth(fontSize, s1); } const JCharacter c = s.GetCharacter(greekIndex + greekPrefixLength); w += renderer.GetGreekCharWidth(fontSize, c); s.RemoveSubstring(1, greekIndex + greekPrefixLength); } if (!s.IsEmpty()) { w += renderer.GetStringWidth(fontSize, s); } return w; }