tableview

package
v0.0.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BridgeTable

type BridgeTable interface {
	SetRows(rows int)
	Redraw()
	SetDrawCellHandler(fn func(ctx fltk_bridge.TableContext, row, col int, x, y, w, h int))
	SetEventHandler(fn func(row int) bool)
	GetSelectedRow() int
	Widget() fltk_bridge.Widget

	SetColumnCount(cols int)
	SetColumnWidth(col, width int)
	AllowColumnResizing()
	EnableColumnHeaders()
	SetColumnHeaderHeight(h int)
	SetBackgroundColor(color fltk_bridge.Color)
}

BridgeTable is the minimal interface TableView needs from the underlying FLTK table.

type DataSource

type DataSource interface {
	NumberOfRows(tv *TableView) int
	CellForColumn(tv *TableView, row, col int) *TableViewCell
}

DataSource:提供行数与 Cell

type Delegate

type Delegate interface {
	DidSelectRow(tv *TableView, row int)
	RowHeight(tv *TableView, row int) int // 返回 0 表示使用默认高度
}

Delegate:交互与布局(可选实现)

type TableColumn

type TableColumn struct {
	Identifier string
	Title      string
	Width      int
	Align      fltk_bridge.Align
}

type TableView

type TableView struct {
	// contains filtered or unexported fields
}

func New

func New(x, y, w, h int) (*TableView, error)

func (*TableView) AddColumn

func (tv *TableView) AddColumn(c TableColumn)

func (*TableView) Dequeue

func (tv *TableView) Dequeue(reuseID string) *TableViewCell

func (*TableView) Enqueue

func (tv *TableView) Enqueue(c *TableViewCell)

func (*TableView) GetSelectedRow

func (tv *TableView) GetSelectedRow() int

GetSelectedRow returns the 0-based index of the selected row, or -1 if none.

func (*TableView) Raw

func (tv *TableView) Raw() BridgeTable

Raw returns the underlying BridgeTable (e.g. for win.Raw().Add(tv.Raw().Widget())).

func (*TableView) ReloadData

func (tv *TableView) ReloadData()

func (*TableView) SetBackgroundColor added in v0.0.22

func (tv *TableView) SetBackgroundColor(color fltk_bridge.Color)

SetBackgroundColor sets the table viewport background, including the empty area below the last row.

func (*TableView) SetCustomDraw

func (tv *TableView) SetCustomDraw(fn func(ctx fltk_bridge.TableContext, row, col, x, y, w, h int))

SetCustomDraw sets a custom cell-drawing function called for every visible row. When set, it replaces the default DataSource-driven cell drawing.

func (*TableView) SetDataSource

func (tv *TableView) SetDataSource(ds DataSource)

func (*TableView) SetDefaultRowHeight

func (tv *TableView) SetDefaultRowHeight(h int)

func (*TableView) SetDelegate

func (tv *TableView) SetDelegate(d Delegate)

func (*TableView) SetHeaderHeight

func (tv *TableView) SetHeaderHeight(h int)

func (*TableView) View

func (tv *TableView) View() *view.UIView

View implements view.Viewable — enables root.AddSubview(tv).

type TableViewCell

type TableViewCell struct {
	ReuseID string

	Text      string
	Font      fltk_bridge.Font
	FontSize  int
	TextColor fltk_bridge.Color
	Align     fltk_bridge.Align
	Selected  bool
	// contains filtered or unexported fields
}

TableViewCell:UITableViewCell 的最小抽象

func NewCell

func NewCell(reuseID string) *TableViewCell

func (*TableViewCell) Col

func (c *TableViewCell) Col() int

func (*TableViewCell) PrepareForReuse

func (c *TableViewCell) PrepareForReuse()

PrepareForReuse:复用前清理状态

func (*TableViewCell) Row

func (c *TableViewCell) Row() int

func (*TableViewCell) SetText

func (c *TableViewCell) SetText(text string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL