Numworks Epsilon  1.4.1
Graphing Calculator Operating System
function_banner_delegate.cpp
Go to the documentation of this file.
2 #include "../constant.h"
3 
4 using namespace Poincare;
5 
6 namespace Shared {
7 
8 void FunctionBannerDelegate::reloadBannerViewForCursorOnFunction(CurveViewCursor * cursor, Function * function, char symbol) {
9  char buffer[k_maxNumberOfCharacters+PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
10  const char * space = " ";
11  int spaceLength = strlen(space);
12  const char * legend = "0=";
13  int legendLength = strlen(legend);
14  int numberOfChar = 0;
15  strlcpy(buffer, legend, legendLength+1);
16  numberOfChar += legendLength;
17  buffer[0] = symbol;
18  numberOfChar += PrintFloat::convertFloatToText<double>(cursor->x(), buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
19  strlcpy(buffer+numberOfChar, space, spaceLength+1);
20  buffer[k_maxDigitLegendLength+2] = 0;
21  bannerView()->setLegendAtIndex(buffer, 0);
22 
23  numberOfChar = 0;
24  legend = "0(x)=";
25  legendLength = strlen(legend);
26  numberOfChar += legendLength;
27  strlcpy(buffer, legend, legendLength+1);
28  buffer[2] = symbol;
29  buffer[0] = function->name()[0];
30  numberOfChar += PrintFloat::convertFloatToText<double>(cursor->y(), buffer+legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
31  strlcpy(buffer+numberOfChar, space, spaceLength+1);
32  buffer[k_maxDigitLegendLength+5] = 0;
33  bannerView()->setLegendAtIndex(buffer, 1);
34 }
35 
36 }
static constexpr int MediumNumberOfSignificantDigits
Definition: constant.h:7
size_t strlcpy(char *dst, const char *src, size_t len)
Definition: strlcpy.c:3
size_t strlen(const char *s)
Definition: strlen.c:3
static constexpr int LargeNumberOfSignificantDigits
Definition: constant.h:6