Files
Upsilon/apps/code/toolbox.h
Léa Saviot 92789330de [code] Search function in the code Toolbox.
When the user types a letter, the toolbox scrolls to the first row that begins
with said letter (without considering if it is lower or upper case). If
there is not such a row, the toolbox scrolls to the first row that has a
letter higher than the typed letter.

Change-Id: I353d23560d8a4d618d96426c393b024e7fb487af
2017-11-21 17:30:04 +01:00

43 lines
1.3 KiB
C++

#ifndef CODE_TOOLBOX_H
#define CODE_TOOLBOX_H
#include <apps/i18n.h>
#include <escher.h>
#include <ion/events.h>
#include <kandinsky/text.h>
namespace Code {
class Toolbox : public ::Toolbox {
public:
typedef void (*Action)(void * sender, const char * text);
Toolbox();
void setAction(Action action);
// StackViewController
bool handleEvent(Ion::Events::Event event) override;
protected:
KDCoordinate rowHeight(int j) override;
bool selectLeaf(ToolboxMessageTree * selectedMessageTree) override;
const ToolboxMessageTree * rootModel() override;
MessageTableCellWithMessage * leafCellAtIndex(int index) override;
MessageTableCellWithChevron* nodeCellAtIndex(int index) override;
int maxNumberOfDisplayedRows() override;
constexpr static int k_maxNumberOfDisplayedRows = 13; // = 240/(13+2*3)
// 13 = minimal string height size
// 3 = vertical margins
private:
constexpr static KDCoordinate k_nodeRowHeight = 40;
constexpr static KDCoordinate k_leafRowHeight = 40;
constexpr static KDText::FontSize k_fontSize = KDText::FontSize::Small;
void scrollToLetter(char letter);
void scrollToAndSelectChild(int i);
Action m_action;
MessageTableCellWithMessage m_leafCells[k_maxNumberOfDisplayedRows];
MessageTableCellWithChevron m_nodeCells[k_maxNumberOfDisplayedRows];
};
}
#endif