Numworks Epsilon  1.4.1
Graphing Calculator Operating System
table_cell.cpp
Go to the documentation of this file.
1 #include <escher/table_cell.h>
2 #include <escher/palette.h>
3 #include <escher/metric.h>
4 
7  m_layout(layout)
8 {
9 }
10 
12  return nullptr;
13 }
14 
16  return nullptr;
17 }
18 
20  return nullptr;
21 }
22 
24  return (labelView() != nullptr) + (accessoryView()!= nullptr) + (subAccessoryView()!= nullptr);
25 }
26 
28  if (index == 0) {
29  return labelView();
30  }
31  if (index == 1) {
32  return accessoryView();
33  }
34  return subAccessoryView();
35 }
36 
38  KDCoordinate width = bounds().width();
39  KDCoordinate height = bounds().height();
40  View * label = labelView();
41  if (label) {
42  KDSize labelSize = label->minimalSizeForOptimalDisplay();
43  switch (m_layout) {
44  case Layout::Vertical:
46  break;
47  default:
49  break;
50  }
51  }
52  View * accessory = accessoryView();
53  if (accessory) {
54  KDSize accessorySize = accessory->minimalSizeForOptimalDisplay();
55  switch (m_layout) {
56  case Layout::Vertical:
57  accessory->setFrame(KDRect(k_separatorThickness+k_accessoryMargin, height-k_separatorThickness-accessorySize.height()-k_accessoryBottomMargin,
58  width-2*k_separatorThickness - k_accessoryMargin, accessorySize.height()));
59  break;
60  default:
62  accessorySize.width(), height-2*k_separatorThickness));
63  break;
64  }
65  }
66  View * subAccessory = subAccessoryView();
67  if (subAccessory && accessory) {
68  KDSize accessorySize = accessory->minimalSizeForOptimalDisplay();
69  KDSize subAccessorySize = subAccessory->minimalSizeForOptimalDisplay();
70  subAccessory->setFrame(KDRect(width-k_separatorThickness-k_accessoryMargin-accessorySize.width()-subAccessorySize.width(), k_separatorThickness,
71  subAccessorySize.width(), height-2*k_separatorThickness));
72  }
73 }
74 
75 void TableCell::drawRect(KDContext * ctx, KDRect rect) const {
76  KDCoordinate width = bounds().width();
77  KDCoordinate height = bounds().height();
78  KDColor backgroundColor = isHighlighted() ? Palette::Select : KDColorWhite;
80  // Draw rectangle around cell
85  }
virtual View * accessoryView() const
Definition: table_cell.cpp:15
View * subviewAtIndex(int index) override
Definition: table_cell.cpp:27
void setFrame(KDRect frame)
Definition: view.cpp:125
int16_t KDCoordinate
Definition: coordinate.h:6
constexpr KDCoordinate width() const
Definition: size.h:10
static constexpr KDCoordinate k_separatorThickness
Definition: table_cell.h:21
TableCell(Layout layout=Layout::Horizontal)
Definition: table_cell.cpp:5
Definition: size.h:6
int numberOfSubviews() const override
Definition: table_cell.cpp:23
constexpr KDColor KDColorWhite
Definition: color.h:42
void drawRect(KDContext *ctx, KDRect rect) const override
Definition: table_cell.cpp:75
static constexpr KDCoordinate k_labelMargin
Definition: table_cell.h:22
static constexpr KDColor Select
Definition: palette.h:17
static constexpr KDCoordinate TableCellLabelTopMargin
Definition: metric.h:18
bool isHighlighted() const
virtual View * subAccessoryView() const
Definition: table_cell.cpp:19
virtual KDSize minimalSizeForOptimalDisplay() const
Definition: view.cpp:183
void layoutSubviews() override
Definition: table_cell.cpp:37
Definition: rect.h:26
void fillRect(KDRect rect, KDColor color)
Definition: context_rect.cpp:8
Definition: color.h:6
Definition: view.h:23
KDCoordinate width() const
Definition: rect.h:39
virtual View * labelView() const
Definition: table_cell.cpp:11
static constexpr KDCoordinate k_accessoryMargin
Definition: table_cell.h:23
static constexpr KDColor GreyBright
Definition: palette.h:13
KDCoordinate height() const
Definition: rect.h:40
KDRect bounds() const
Definition: view.cpp:157
constexpr KDCoordinate height() const
Definition: size.h:11