Base data editing page in GTK client.

This commit is contained in:
2020-03-05 21:06:58 +01:00
parent d8035452d8
commit 118c15f6c9
13 changed files with 620 additions and 229 deletions

View File

@@ -3,19 +3,18 @@ using Gtk;
namespace EstusShots.Gtk.Controls
{
public class DataColumn : TreeViewColumn
public abstract class DataColumn : TreeViewColumn
{
public DataColumn()
protected DataColumn(string propertyName)
{
PropertyName = propertyName;
Title = propertyName;
Resizable = true;
Reorderable = true;
}
public DataColumn(string propertyName) : this()
{
PropertyName = propertyName;
Title = propertyName;
}
public abstract string ValueAttribute { get; }
/// <summary>
/// The name of the property in the data source, that should be show nin the view
@@ -26,6 +25,64 @@ namespace EstusShots.Gtk.Controls
/// Applies the given transformation on each item in the column.
/// This changes only the display of the value.
/// </summary>
public Func<object, string> Format { get; set; }
public abstract Func<object, string> DisplayConverter { get; set; }
/// <summary>
/// Cell renderer for rows in the column
/// </summary>
public abstract CellRenderer Cell { get; set; }
}
public class DataColumnText : DataColumn
{
public DataColumnText(string propertyName) : base(propertyName)
{
ValueAttribute = "text";
Cell = new CellRendererText();
PackStart(Cell, true);
}
public override string ValueAttribute { get; }
public override Func<object, string> DisplayConverter { get; set; }
/// <summary>
/// Cell renderer for rows in the column
/// </summary>
public sealed override CellRenderer Cell { get; set; }
}
public class DataColumnBool : DataColumn
{
public DataColumnBool(string propertyName) : base(propertyName)
{
ValueAttribute = "active";
Cell = new CellRendererToggle();
PackStart(Cell, true);
}
public override string ValueAttribute { get; }
public override Func<object, string> DisplayConverter { get; set; }
public sealed override CellRenderer Cell { get; set; }
}
public class DataColumnDouble : DataColumn
{
public DataColumnDouble(string propertyName) : base(propertyName)
{
ValueAttribute = "text";
Cell = new CellRendererSpin();
PackStart(Cell, true);
}
public int Digits
{
set => SetAttributes(Cell, "digits", value);
}
public override string ValueAttribute { get; }
public override Func<object, string> DisplayConverter { get; set; }
public sealed override CellRenderer Cell { get; set; }
}
}