-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender_callbacks.go
52 lines (45 loc) · 1.93 KB
/
render_callbacks.go
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
// Copyright © 2016 Pennock Tech, LLC.
// All rights reserved, except as granted under license.
// Licensed per file LICENSE.txt
package tabular // import "go.pennock.tech/tabular"
// InvokeRenderCallbacks is used by rendering packages to trigger a table-wide
// invocation of render-time callbacks.
//
// We first invoke pre-cell callbacks going: table->column->row->cell
// We then invoke regular render callbacks cell->row->column->table
func (t *ATable) InvokeRenderCallbacks() {
ec := t.ErrorContainer
invokePropertyCallbacks(t.tableItselfCallbacks, CB_AT_RENDER_PRECELL, t, ec)
for _, col := range t.columns {
invokePropertyCallbacks(col.columnItselfCallbacks, CB_AT_RENDER_PRECELL, &col, ec)
}
if t.headerRow != nil {
t.headerRow.invokeRenderCallbacks(t, ec)
}
for _, row := range t.rows {
row.invokeRenderCallbacks(t, ec)
}
for _, col := range t.columns {
invokePropertyCallbacks(col.columnItselfCallbacks, CB_AT_RENDER_POSTCELL, &col, ec)
}
invokePropertyCallbacks(t.tableItselfCallbacks, CB_AT_RENDER_POSTCELL, t, ec)
}
func (row *Row) invokeRenderCallbacks(t *ATable, ec ErrorReceiver) {
invokePropertyCallbacks(row.rowItselfCallbacks, CB_AT_RENDER_PRECELL, row, ec)
for i := range row.cells {
ptr := &row.cells[i]
col := ptr.columnOfTable()
invokePropertyCallbacks(t.tableCellCallbacks, CB_AT_RENDER_PRECELL, ptr, ec)
if col != nil {
invokePropertyCallbacks(col.cellCallbacks, CB_AT_RENDER_PRECELL, ptr, row.ErrorContainer)
}
invokePropertyCallbacks(row.rowCellCallbacks, CB_AT_RENDER_PRECELL, ptr, ec)
invokePropertyCallbacks(t.tableCellCallbacks, CB_AT_RENDER, ptr, ec)
invokePropertyCallbacks(ptr.callbacks, CB_AT_RENDER, ptr, ec)
invokePropertyCallbacks(row.rowCellCallbacks, CB_AT_RENDER_POSTCELL, ptr, ec)
if col != nil {
invokePropertyCallbacks(col.cellCallbacks, CB_AT_RENDER_POSTCELL, ptr, row.ErrorContainer)
}
}
invokePropertyCallbacks(row.rowItselfCallbacks, CB_AT_RENDER_POSTCELL, row, ec)
}