2 #include "../global_preferences.h" 3 #include "../apps_container.h" 4 #include "../../poincare/src/layout/baseline_relative_layout.h" 5 #include "../../poincare/src/layout/string_layout.h" 13 SubController::SubController(
Responder * parentResponder) :
15 m_editableCell(&m_selectableTableView, this, m_draftTextBuffer),
16 m_selectableTableView(this),
17 m_messageTreeModel(nullptr)
21 for (
int i = 0; i < k_totalNumberOfCell; i++) {
27 m_complexFormatLayout[0] =
new StringLayout(text,
sizeof(text));
31 for (
int i = 0; i < 2; i++) {
32 m_complexFormatCells[i].
setExpression(m_complexFormatLayout[i]);
34 m_editableCell.
setMessage(I18n::Message::SignificantFigures);
39 for (
int i = 0; i < 2; i++) {
40 if (m_complexFormatLayout[i]) {
41 delete m_complexFormatLayout[i];
42 m_complexFormatLayout[i] =
nullptr;
48 if (m_messageTreeModel) {
55 return &m_selectableTableView;
59 if (m_messageTreeModel->
label() == I18n::Message::ExamMode) {
78 if (m_messageTreeModel->
label() == I18n::Message::ExamMode) {
87 if (m_messageTreeModel->
label() == I18n::Message::About) {
103 myContainer->refreshPreferences();
109 stackController()->
pop();
116 if (m_messageTreeModel) {
125 return &m_editableCell;
126 }
else if (type == 1) {
127 assert(index >= 0 && index < 2);
128 return &m_complexFormatCells[index];
130 assert(index >= 0 && index < k_totalNumberOfCell);
131 return &m_cells[index];
137 return k_totalNumberOfCell;
149 if (m_messageTreeModel->
label() == I18n::Message::ComplexFormat) {
152 if (m_messageTreeModel->
label() == I18n::Message::DisplayMode && j ==
numberOfRows()-1) {
171 return (offsetY - 1) / height;
175 if (m_messageTreeModel->
label() == I18n::Message::ComplexFormat) {
179 if (m_messageTreeModel->
label() == I18n::Message::DisplayMode && index ==
numberOfRows()-1) {
191 myCell->
setMessage(I18n::Message::ExamModeActive);
193 if (m_messageTreeModel->
label() == I18n::Message::About) {
195 const char * accessoryMessage =
nullptr;
196 char serialNumber[Ion::SerialNumberLength+1];
203 accessoryMessage = serialNumber;
217 m_messageTreeModel = (
MessageTree *)messageTreeModel;
235 float floatBody = Expression::approximateToScalar<float>(text, *globalContext);
237 floatBody = PrintFloat::k_numberOfPrintedSignificantDigits;
242 if (floatBody > PrintFloat::k_numberOfStoredSignificantDigits) {
243 floatBody = PrintFloat::k_numberOfStoredSignificantDigits;
245 Preferences::sharedPreferences()->setNumberOfSignificantDigits((
char)
std::round(floatBody));
257 void SubController::setPreferenceWithValueIndex(I18n::Message message,
int valueIndex) {
258 if (message == I18n::Message::AngleUnit) {
261 if (message == I18n::Message::DisplayMode) {
262 Preferences::sharedPreferences()->setDisplayMode((
PrintFloat::Mode)valueIndex);
264 if (message == I18n::Message::ComplexFormat) {
269 int SubController::valueIndexForPreference(I18n::Message message) {
270 if (message == I18n::Message::AngleUnit) {
271 return (
int)Preferences::sharedPreferences()->angleUnit();
273 if (message == I18n::Message::DisplayMode) {
274 return (
int)Preferences::sharedPreferences()->displayMode();
276 if (message == I18n::Message::ComplexFormat) {
277 return (
int)Preferences::sharedPreferences()->complexFormat();
void didBecomeFirstResponder() override
void displayExamModePopUp(bool activate)
void setAccessoryText(const char *textBody)
int writeTextInBuffer(char *buffer, int bufferSize) const
void displayModalViewController(ViewController *vc, float verticalAlignment, float horizontalAlignment, KDCoordinate topMargin=0, KDCoordinate leftMargin=0, KDCoordinate bottomMargin=0, KDCoordinate rightMargin=0)
HighlightCell * selectedCell()
void willDisplayCellForIndex(HighlightCell *cell, int index) override
void setMessageTreeModel(const MessageTree *messageTreeModel)
Responder * parentResponder() const
static constexpr KDColor GreyDark
const char * patchLevel()
int reusableCellCount(int type) override
void setAccessoryFontSize(KDText::FontSize fontSize)
KDCoordinate cumulatedHeightFromIndex(int j) override
int numberOfChildren() const
bool textFieldDidFinishEditing(TextField *textField, const char *text, Ion::Events::Event event) override
const char * accessoryText()
HighlightCell * reusableCell(int index, int type) override
virtual Poincare::Context * localContext()
void reloadData(bool setFirstResponder=true)
const char * title() override
enum Message uint16_t enum Language uint16_t const char * translate(Message m, Language l=(Language) 0)
void setAccessoryText(const char *text)
void didEnterResponderChain(Responder *previousFirstResponder) override
void setAccessoryTextColor(KDColor color)
I18n::Message label() const
void reloadCellAtLocation(int i, int j)
void setExpression(Poincare::ExpressionLayout *expressionLayout)
int typeAtLocation(int i, int j) override
void getSerialNumber(char *buffer)
void setMessageFontSize(KDText::FontSize fontSize)
static constexpr KDCoordinate ExamPopUpBottomMargin
void setMessage(I18n::Message message)
const Container * container() const
static constexpr KDCoordinate ParameterCellHeight
void setFirstResponder(Responder *responder)
virtual bool textFieldShouldFinishEditing(TextField *textField, Ion::Events::Event event)=0
ExamMode examMode() const
virtual const MessageTree * children(int index) const =0
virtual bool handleEvent(Ion::Events::Event event) override
bool handleEvent(Ion::Events::Event event) override
int numberOfRows() override
const char * softwareVersion()
int indexFromCumulatedHeight(KDCoordinate offsetY) override
int strcmp(const char *s1, const char *s2)
void selectCellAtLocation(int i, int j)
static constexpr KDCoordinate PopUpRightMargin
void viewWillAppear() override
bool textFieldShouldFinishEditing(TextField *textField, Ion::Events::Event event) override
void viewDidDisappear() override
KDCoordinate rowHeight(int j) override
static GlobalPreferences * sharedGlobalPreferences()
static constexpr KDCoordinate ExamPopUpTopMargin
static constexpr KDCoordinate PopUpLeftMargin