TableView.CellStyle

Available per-cell style customization options. Use one of the constructors provided to set the values conveniently, or default construct it and set individual values yourself. Just remember to set the flags so your values are actually used. If the flag isn't set, the field is ignored and the system default is used instead.

This is returned by the getCellStyle delegate.

class TableView
struct CellStyle {
Color textColor;
Color backgroundColor;
}

Constructors

this
this(Color textColor)

Sets just a custom text color, leaving the background as the default. Use caution with certain colors as it may have illeglible contrast on the (unknown to you) background color.

this
this(Color textColor, Color backgroundColor)

Sets a custom text and background color.

Members

Enums

Flags
enum Flags

available options to combine into flags

Variables

flags
int flags;

bitmask of Flags

Examples

// assumes you have a variables called `my_data` which is an array of arrays of numbers
auto table = new TableView(window);
// snip: you would set up columns here

// this is how you provide data to the table view class
table.getData = delegate(int row, int column, scope void delegate(in char[]) sink) {
	import std.conv;
	sink(to!string(my_data[row][column]));
};

// and this is how you customize the colors
table.getCellStyle = delegate(int row, int column) {
	return (my_data[row][column] < 0) ?
		TableView.CellStyle(Color.red); // make negative numbers red
		: TableView.CellStyle.init; // leave the rest alone
};
// snip: you would call table.setItemCount here then continue with the rest of your window setup work

Meta

History

Added November 27, 2021 (dub v10.4)