Numworks Epsilon  1.4.1
Graphing Calculator Operating System
script_node_cell.cpp
Go to the documentation of this file.
1 #include "script_node_cell.h"
2 #include <kandinsky/point.h>
3 #include <escher.h>
4 
5 namespace Code {
6 
7 constexpr char ScriptNodeCell::k_parentheses[];
8 
10  HighlightCell(),
11  m_scriptNode(nullptr),
12  m_scriptStore(nullptr)
13 {
14 }
15 
17  m_scriptNode = scriptNode;
18 }
19 
21  m_scriptStore = scriptStore;
22 }
23 
26  KDSize nameSize = KDText::stringSize(m_scriptNode->name(), k_fontSize);
27  if (m_scriptNode->type() == ScriptNode::Type::Function) {
29  }
30  ctx->drawString(m_scriptStore->scriptAtIndex(m_scriptNode->scriptIndex()).name(), KDPoint(0, Metric::TableCellLabelTopMargin + nameSize.height() + k_verticalMargin), k_fontSize, Palette::GreyDark, isHighlighted()? Palette::Select : KDColorWhite);
31 }
32 
34  if (m_scriptNode->name() == nullptr) {
35  return KDSizeZero;
36  }
37  KDSize size1 = KDText::stringSize(m_scriptNode->name(), k_fontSize);
38  KDSize size2 = KDText::stringSize(m_scriptStore->scriptAtIndex(m_scriptNode->scriptIndex()).name(), k_fontSize);
39  KDSize size3 = KDSizeZero;
40  if (m_scriptNode->type() == ScriptNode::Type::Function) {
42  }
43  return KDSize(size1.width() + size3.width() > size2.width() ? size1.width() + size3.width() : size2.width(), Metric::TableCellLabelTopMargin + size1.width() + k_verticalMargin + size2.width());
44 }
45 
47  TableCell(),
49 {
50 }
51 
53  m_scriptNodeView.setScriptNode(scriptNode);
54  reloadCell();
55 }
56 
58  m_scriptNodeView.setScriptStore(scriptStore);
59 }
60 
61 void ScriptNodeCell::setHighlighted(bool highlight) {
62  TableCell::setHighlighted(highlight);
64 }
65 
69 }
70 
71 }
void setHighlighted(bool highlight) override
void reloadCell() override
KDPoint drawString(const char *text, KDPoint p, KDText::FontSize size=KDText::FontSize::Large, KDColor textColor=KDColorBlack, KDColor backgroundColor=KDColorWhite, int maxLength=-1)
Definition: context_text.cpp:9
constexpr KDCoordinate width() const
Definition: size.h:10
static KDSize stringSize(const char *text, FontSize size=FontSize::Large)
Definition: text.cpp:6
void setScriptNode(ScriptNode *node)
static constexpr KDColor GreyDark
Definition: palette.h:15
void drawRect(KDContext *ctx, KDRect rect) const override
void setScriptNode(ScriptNode *scriptNode)
Definition: point.h:6
Definition: size.h:6
Definition: app.cpp:7
constexpr KDColor KDColorWhite
Definition: color.h:42
ScriptNodeView m_scriptNodeView
static constexpr KDColor Select
Definition: palette.h:17
static constexpr KDCoordinate TableCellLabelTopMargin
Definition: metric.h:18
constexpr KDColor KDColorBlack
Definition: color.h:41
static constexpr char k_parentheses[]
bool isHighlighted() const
void setScriptStore(ScriptStore *scriptStore)
void layoutSubviews() override
Definition: table_cell.cpp:37
Definition: rect.h:26
constexpr KDSize KDSizeZero
Definition: size.h:17
void setScriptStore(ScriptStore *scriptStore)
virtual void setHighlighted(bool highlight)
virtual void reloadCell()
virtual KDSize minimalSizeForOptimalDisplay() const override
constexpr KDCoordinate height() const
Definition: size.h:11