[escher] break table view and table view data source in two files

Change-Id: I98407e8900727d1ce8fea78c721f56192a24e1f8
This commit is contained in:
Émilie Feral
2016-09-29 17:37:23 +02:00
parent 7130496707
commit dad80001af
6 changed files with 35 additions and 25 deletions

View File

@@ -23,6 +23,7 @@ objs += $(addprefix escher/src/,\
tab_view_controller.o\
table_view.o\
table_view_cell.o\
table_view_data_source.o\
text_field.o\
text_view.o\
tiled_view.o\

View File

@@ -22,6 +22,7 @@
#include <escher/tab_view_controller.h>
#include <escher/table_view.h>
#include <escher/table_view_cell.h>
#include <escher/table_view_data_source.h>
#include <escher/tiled_view.h>
#include <escher/view.h>
#include <escher/view_controller.h>

View File

@@ -2,28 +2,7 @@
#define ESCHER_TABLE_VIEW_H
#include <escher/scroll_view.h>
class TableViewDataSource {
public:
virtual int numberOfRows() = 0;
virtual int numberOfColumns() = 0;
virtual void willDisplayCellAtLocation(View * cell, int i, int j);
virtual KDCoordinate columnWidth(int i) = 0;
virtual KDCoordinate rowHeight(int j) = 0;
/* return the number of pixels to include in offset to display the column i at
the top */
virtual KDCoordinate cumulatedWidthFromIndex(int i) = 0;
virtual KDCoordinate cumulatedHeightFromIndex(int j) = 0;
/* return the number of columns (starting with first ones) that can be fully
* displayed in offsetX pixels.
* Caution: if the offset is exactly the size of n columns, the function
* returns n-1. */
virtual int indexFromCumulatedWidth(KDCoordinate offsetX) = 0;
virtual int indexFromCumulatedHeight(KDCoordinate offsetY) = 0;
virtual View * reusableCell(int index, int type) = 0;
virtual int reusableCellCount(int type) = 0;
virtual int typeAtLocation(int i, int j) = 0;
};
#include <escher/table_view_data_source.h>
class TableView : public ScrollView {
public:

View File

@@ -0,0 +1,28 @@
#ifndef ESCHER_TABLE_VIEW_DATA_SOURCE_H
#define ESCHER_TABLE_VIEW_DATA_SOURCE_H
#include <escher/view.h>
class TableViewDataSource {
public:
virtual int numberOfRows() = 0;
virtual int numberOfColumns() = 0;
virtual void willDisplayCellAtLocation(View * cell, int i, int j);
virtual KDCoordinate columnWidth(int i) = 0;
virtual KDCoordinate rowHeight(int j) = 0;
/* return the number of pixels to include in offset to display the column i at
the top */
virtual KDCoordinate cumulatedWidthFromIndex(int i) = 0;
virtual KDCoordinate cumulatedHeightFromIndex(int j) = 0;
/* return the number of columns (starting with first ones) that can be fully
* displayed in offsetX pixels.
* Caution: if the offset is exactly the size of n columns, the function
* returns n-1. */
virtual int indexFromCumulatedWidth(KDCoordinate offsetX) = 0;
virtual int indexFromCumulatedHeight(KDCoordinate offsetY) = 0;
virtual View * reusableCell(int index, int type) = 0;
virtual int reusableCellCount(int type) = 0;
virtual int typeAtLocation(int i, int j) = 0;
};
#endif

View File

@@ -7,9 +7,6 @@ extern "C" {
#define MIN(x,y) ((x)<(y) ? (x) : (y))
void TableViewDataSource::willDisplayCellAtLocation(View * cell, int i, int j) {
}
TableView::TableView(TableViewDataSource * dataSource, KDCoordinate topMargin, KDCoordinate rightMargin,
KDCoordinate bottomMargin, KDCoordinate leftMargin) :
ScrollView(&m_contentView, topMargin, rightMargin, bottomMargin, leftMargin),

View File

@@ -0,0 +1,4 @@
#include <escher/table_view_data_source.h>
void TableViewDataSource::willDisplayCellAtLocation(View * cell, int i, int j) {
}