Numworks Epsilon  1.4.1
Graphing Calculator Operating System
table_view.h
Go to the documentation of this file.
1 #ifndef ESCHER_TABLE_VIEW_H
2 #define ESCHER_TABLE_VIEW_H
3 
4 #include <escher/palette.h>
5 #include <escher/scroll_view.h>
8 
9 class TableView : public ScrollView {
10 public:
12 
15 
16  virtual void scrollToCell(int i, int j);
17  HighlightCell * cellAtLocation(int i, int j);
18  void reloadCellAtLocation(int i, int j);
19  KDSize minimalSizeForOptimalDisplay() const override;
20 protected:
21 #if ESCHER_VIEW_LOGGING
22  const char * className() const override;
23 #endif
25  void layoutSubviews() override;
26  class ContentView : public View {
27  public:
28  ContentView(TableView * tableView, TableViewDataSource * dataSource, KDCoordinate horizontalCellOverlap, KDCoordinate verticalCellOverlap);
29  KDSize minimalSizeForOptimalDisplay() const override;
30 
31  void setHorizontalCellOverlap(KDCoordinate o) { m_horizontalCellOverlap = o; }
32  void setVerticalCellOverlap(KDCoordinate o) { m_verticalCellOverlap = o; }
33 
34  void scrollToCell(int i, int j) const;
35  void reloadCellAtLocation(int i, int j);
36  HighlightCell * cellAtLocation(int i, int j);
37  void resizeToFitContent();
39  protected:
40 #if ESCHER_VIEW_LOGGING
41  const char * className() const override;
42 #endif
43  private:
44  KDCoordinate height() const;
45  KDCoordinate width() const;
46 
47  int numberOfSubviews() const override;
48  View * subviewAtIndex(int index) override;
49  void layoutSubviews() override;
50 
51  /* realCellWidth enables to handle list view for which
52  * TableViewDataSource->cellWidht = 0 */
53  KDCoordinate columnWidth(int x) const;
54  /* These two methods transform an index (of subview for instance) into
55  * coordinates that refer to the data source entire table */
56  int absoluteColumnNumberFromSubviewIndex(int index) const;
57  int absoluteRowNumberFromSubviewIndex(int index) const;
58  int numberOfFullyDisplayableRows() const;
59  int numberOfFullyDisplayableColumns() const;
60  int numberOfDisplayableRows() const;
61  int numberOfDisplayableColumns() const;
62  int rowsScrollingOffset() const;
63  int columnsScrollingOffset() const;
64  int typeOfSubviewAtIndex(int index) const;
65  /* This method transform a index (of subview for instance) into an index
66  * refering to the set of cells of type "type". */
67  int typeIndexFromSubviewIndex(int index, int type) const;
68  TableView * m_tableView;
69  TableViewDataSource * m_dataSource;
70  KDCoordinate m_horizontalCellOverlap;
71  KDCoordinate m_verticalCellOverlap;
72  };
74 };
75 
76 #endif
void setHorizontalCellOverlap(KDCoordinate o)
Definition: table_view.h:31
int16_t KDCoordinate
Definition: coordinate.h:6
ContentView(TableView *tableView, TableViewDataSource *dataSource, KDCoordinate horizontalCellOverlap, KDCoordinate verticalCellOverlap)
Definition: table_view.cpp:55
void layoutSubviews() override
Definition: table_view.cpp:40
void setVerticalCellOverlap(KDCoordinate o)
Definition: table_view.h:14
virtual void scrollToCell(int i, int j)
Definition: table_view.cpp:26
KDSize minimalSizeForOptimalDisplay() const override
Definition: table_view.cpp:64
HighlightCell * cellAtLocation(int i, int j)
Definition: table_view.cpp:30
void setVerticalCellOverlap(KDCoordinate o)
Definition: table_view.h:32
void scrollToCell(int i, int j) const
Definition: table_view.cpp:93
TableViewDataSource * dataSource()
Definition: table_view.cpp:20
Definition: size.h:6
void reloadCellAtLocation(int i, int j)
Definition: table_view.cpp:49
KDSize minimalSizeForOptimalDisplay() const override
Definition: table_view.cpp:16
void setHorizontalCellOverlap(KDCoordinate o)
Definition: table_view.h:13
Definition: view.h:23
TableViewDataSource * dataSource()
Definition: table_view.cpp:68
ContentView m_contentView
Definition: table_view.h:73
HighlightCell * cellAtLocation(int i, int j)
Definition: table_view.cpp:121
void reloadCellAtLocation(int i, int j)
Definition: table_view.cpp:98
TableView(TableViewDataSource *dataSource, ScrollViewDataSource *scrollDataSource)
Definition: table_view.cpp:10