void JNamedConstant::Render ( const JExprRenderer& renderer, const JExprRectList& rectList ) const { if (strcmp(JPGetStdNamedConstName(itsNameIndex), JPGetPiString()) == 0) { // find ourselves in the list JIndex ourIndex; const JBoolean found = rectList.FindFunction(this, &ourIndex); assert( found ); const JRect ourRect = rectList.GetRect(ourIndex); const JCoordinate ourMidline = rectList.GetMidline(ourIndex); const JSize fontSize = rectList.GetFontSize(ourIndex); // draw the greek character for pi renderer.DrawGreekCharacter(ourRect.left, ourMidline, fontSize, kGreekPiChar); } else { JFunction::Render(renderer, 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); } }