image_table_view.h
2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef PROBABILITY_IMAGE_TABLE_VIEW_H
#define PROBABILITY_IMAGE_TABLE_VIEW_H
#include <escher.h>
#include "calculation/calculation.h"
namespace Probability {
class CalculationController;
class ImageCell : public HighlightCell {
public:
ImageCell();
void reloadCell() override;
void setImage(const Image * image, const Image * focusedImage);
constexpr static KDCoordinate k_width = 39;
constexpr static KDCoordinate k_height = 23;
private:
int numberOfSubviews() const override;
View * subviewAtIndex(int index) override;
void layoutSubviews() override;
ImageView m_iconView;
const Image * m_icon;
const Image * m_focusedIcon;
};
class ImageTableView : public View, public Responder, public SimpleListViewDataSource, public SelectableTableViewDataSource {
public:
ImageTableView(Responder * parentResponder, Law * law, Calculation * calculation, CalculationController * calculationController);
void drawRect(KDContext * ctx, KDRect rect) const override;
KDSize minimalSizeForOptimalDisplay() const override;
bool handleEvent(Ion::Events::Event event) override;
void didBecomeFirstResponder() override;
void willExitResponderChain(Responder * nextFirstResponder) override;
void select(bool select);
void setHighlight(bool highlight);
int numberOfRows() override;
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
KDCoordinate cellHeight() override;
HighlightCell * reusableCell(int index) override;
int reusableCellCount() override;
constexpr static KDCoordinate k_outline = 1;
constexpr static KDCoordinate k_margin = 3;
constexpr static KDCoordinate k_totalMargin = k_outline+k_margin;
constexpr static KDCoordinate k_oneCellWidth = 2*k_totalMargin+ImageCell::k_width;
constexpr static KDCoordinate k_oneCellHeight = 2*k_totalMargin+ImageCell::k_height;
private:
int numberOfSubviews() const override;
View * subviewAtIndex(int index) override;
void layoutSubviews() override;
void setCalculationAccordingToIndex(int index);
void hideDropdown();
constexpr static int k_numberOfImages = 4;
ImageCell m_imageCells[k_numberOfImages];
SelectableTableView m_selectableTableView;
bool m_isSelected;
int m_selectedIcon;
Law * m_law;
Calculation * m_calculation;
CalculationController * m_calculationController;
};
}
#endif