forked from paulfitz/daff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCombinedTableBody.hx
133 lines (112 loc) · 2.99 KB
/
CombinedTableBody.hx
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// -*- mode:java; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
#if !TOPLEVEL
package coopy;
#end
/**
*
* Body of a table that has embedded meta-data.
*
*/
class CombinedTableBody implements Table {
private var parent : CombinedTable;
private var dx : Int;
private var dy : Int;
private var all : Table;
private var meta : Table;
/**
*
* Constructor.
* @param parent the composite table
*
*/
public function new(parent: CombinedTable, dx: Int, dy: Int) : Void {
this.parent = parent;
this.dx = dx;
this.dy = dy;
all = parent.all();
}
public function getTable() : Table {
return this;
}
public var height(get,never) : Int;
public var width(get,never) : Int;
public function get_width() : Int {
return all.width-1;
}
public function get_height() : Int {
return all.height-dy+1;
}
public function getCell(x: Int, y: Int) : Dynamic {
if (y==0) {
if (meta==null) {
meta = parent.getMeta().asTable();
}
return meta.getCell(x+dx,0);
}
return all.getCell(x+dx,y+dy-1);
}
public function setCell(x: Int, y: Int, c: Dynamic) : Void {
if (y==0) {
all.setCell(x+dx,0,c);
return;
}
all.setCell(x+dx,y+dy-1,c);
}
public function toString() : String {
return SimpleTable.tableToString(this);
}
public function getCellView() : View {
return all.getCellView();
}
public function isResizable() : Bool {
return all.isResizable();
}
public function resize(w: Int, h: Int) : Bool {
return all.resize(w+1,h+dy);
}
public function clear() : Void {
all.clear();
dx = 0;
dy = 0;
}
public function insertOrDeleteRows(fate: Array<Int>, hfate: Int) : Bool {
var fate2 = new Array<Int>();
for (y in 0...dy) {
fate2.push(y);
}
var hdr = true;
for (f in fate) {
if (hdr) {
hdr = false;
continue;
}
fate2.push((f>=0)?(f+dy-1):f);
}
return all.insertOrDeleteRows(fate2,hfate+dy-1);
}
public function insertOrDeleteColumns(fate: Array<Int>, wfate: Int) : Bool {
var fate2 = new Array<Int>();
for (x in 0...(dx+1)) {
fate2.push(x);
}
for (f in fate) {
fate2.push((f>=0)?(f+dx+1):f);
}
return all.insertOrDeleteColumns(fate2,wfate+dx);
}
public function trimBlank() : Bool {
return all.trimBlank();
}
public function getData() : Dynamic {
return null;
}
public function clone() : Table {
return new CombinedTable(all.clone());
}
public function create() : Table {
return new CombinedTable(all.create());
}
public function getMeta() : Meta {
return parent.getMeta();
}
}