2 #include "../apps_container.h" 3 #include "../../poincare/src/layout/condensed_sum_layout.h" 4 #include "../../poincare/src/layout/string_layout.h" 5 #include "../../poincare/src/layout/horizontal_layout.h" 17 m_step(
Step::FirstParameter),
22 m_graphView(graphView),
23 m_legendView(this, sumSymbol),
43 m_legendView.setSumSymbol(
m_step);
80 m_legendView.setLegendMessage(legendMessageAtStep(
m_step),
m_step);
86 m_legendView.setEditableZone(
m_endSum);
92 m_legendView.setLegendMessage(legendMessageAtStep(
m_step),
m_step);
94 m_legendView.setSumSymbol(
m_step);
116 m_legendView.setEditableZone(
m_endSum);
130 double floatBody = Expression::approximateToScalar<double>(text, *globalContext);
150 double parameter =
NAN;
168 return handleEnter();
176 bool SumGraphController::handleEnter() {
186 m_legendView.setEditableZone(
m_endSum);
188 m_legendView.setLegendMessage(legendMessageAtStep(
m_step),
m_step);
192 TextFieldDelegateApp * myApp =
static_cast<TextFieldDelegateApp *
>(
app());
195 m_legendView.setLegendMessage(I18n::Message::Default,
m_step);
198 myApp->setFirstResponder(
this);
204 SumGraphController::LegendView::LegendView(SumGraphController * controller,
char sumSymbol) :
206 m_sumLayout(nullptr),
208 m_editableZone(controller, m_draftText, m_draftText,
TextField::maxBufferSize(), controller,
false,
KDText::FontSize::Small, 0.0f, 0.5f,
KDColorBlack,
Palette::GreyMiddle),
209 m_sumSymbol(sumSymbol)
214 SumGraphController::LegendView::~LegendView() {
215 if (m_sumLayout !=
nullptr) {
217 m_sumLayout =
nullptr;
221 void SumGraphController::LegendView::drawRect(
KDContext * ctx,
KDRect rect)
const {
225 KDSize SumGraphController::LegendView::minimalSizeForOptimalDisplay()
const {
226 return KDSize(0, k_legendHeight);
229 void SumGraphController::LegendView::setLegendMessage(I18n::Message message, Step step) {
230 m_legend.setMessage(message);
231 layoutSubviews(step);
234 void SumGraphController::LegendView::setEditableZone(
double d) {
237 m_editableZone.setText(buffer);
240 void SumGraphController::LegendView::setSumSymbol(Step step,
double start,
double end,
double result,
ExpressionLayout * functionLayout) {
241 assert(step == Step::Result || functionLayout ==
nullptr);
244 m_sumLayout =
nullptr;
246 const char sigma[] = {
' ', m_sumSymbol};
247 if (step == Step::FirstParameter) {
249 }
else if (step == Step::SecondParameter) {
265 childrenLayouts[1] = functionLayout;
266 childrenLayouts[0] = m_sumLayout;
269 m_sum.setExpression(m_sumLayout);
270 if (step == Step::Result) {
271 m_sum.setAlignment(0.5f, 0.5f);
273 m_sum.setAlignment(0.0f, 0.5f);
275 layoutSubviews(step);
278 int SumGraphController::LegendView::numberOfSubviews()
const {
282 View * SumGraphController::LegendView::subviewAtIndex(
int index) {
283 assert(index >= 0 && index < 3);
288 return &m_editableZone;
293 void SumGraphController::LegendView::layoutSubviews() {
294 layoutSubviews(Step::FirstParameter);
297 void SumGraphController::LegendView::layoutSubviews(Step step) {
300 KDSize legendSize = m_legend.minimalSizeForOptimalDisplay();
302 if (legendSize.
width() > 0) {
303 m_sum.setFrame(
KDRect(0, k_symbolHeightMargin, width-legendSize.
width(), m_sum.minimalSizeForOptimalDisplay().height()));
304 m_legend.setFrame(
KDRect(width-legendSize.
width(), 0, legendSize.
width(), heigth));
306 m_sum.setFrame(bounds());
312 case Step::FirstParameter:
313 m_editableZone.setFrame(
KDRect(2*largeCharSize.
width(), k_symbolHeightMargin+k_sigmaHeight/2, k_editableZoneWidth, k_editableZoneHeight));
315 case Step::SecondParameter:
316 m_editableZone.setFrame(
KDRect(2*largeCharSize.
width(), k_symbolHeightMargin+k_sigmaHeight/2-k_editableZoneHeight, k_editableZoneWidth, k_editableZoneHeight));
bool textFieldDidFinishEditing(TextField *textField, const char *text, Ion::Events::Event event) override
static constexpr int MediumNumberOfSignificantDigits
void setText(const char *text)
constexpr KDCoordinate width() const
Responder * parentResponder() const
void setBannerView(View *bannerView)
void setOkView(View *okView)
size_t strlcpy(char *dst, const char *src, size_t len)
virtual double sumBetweenBounds(double start, double end, Poincare::Context *context) const =0
virtual Poincare::Context * localContext()
static constexpr float k_cursorRightMarginRatio
virtual bool handleZoom(Ion::Events::Event event)
size_t strlen(const char *s)
bool textFieldDidAbortEditing(TextField *textField, const char *text) override
void displayWarning(I18n::Message warningMessage)
void didEnterResponderChain(Responder *previousFirstResponder) override
InteractiveCurveViewRange * m_graphRange
Poincare::Context * globalContext()
static constexpr int LargeNumberOfSignificantDigits
void setAreaHighlight(float start, float end)
const char * name() const
constexpr KDColor KDColorBlack
void moveTo(double x, double y)
static constexpr KDColor GreyMiddle
bool textFieldDidReceiveEvent(TextField *textField, Ion::Events::Event event) override
void panToMakePointVisible(float x, float y, float topMarginRatio, float rightMarginRatio, float bottomMarginRation, float leftMarginRation)
constexpr KDRect KDRectZero
void fillRect(KDRect rect, KDColor color)
bool textFieldDidReceiveEvent(TextField *textField, Ion::Events::Event event) override
virtual float evaluateAtAbscissa(float x, Poincare::Context *context) const
void setCursorView(View *cursorView)
void setFirstResponder(Responder *responder)
void selectMainView(bool mainViewSelected)
void setFunction(Function *function)
static constexpr KDSize charSize(FontSize size=FontSize::Large)
void selectFunction(Function *function)
static constexpr float k_cursorLeftMarginRatio
virtual void setAreaHighlightColor(bool highlightColor)
bool handleEvent(Ion::Events::Event event) override
CurveViewCursor * m_cursor
virtual bool moveCursorHorizontallyToPosition(double position)
void viewWillAppear() override