Skip to content

Instantly share code, notes, and snippets.

@jerstlouis
Created October 17, 2014 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jerstlouis/02f334d0cccca8741618 to your computer and use it in GitHub Desktop.
Save jerstlouis/02f334d0cccca8741618 to your computer and use it in GitHub Desktop.
import "ecere"
enum FancyState { start, finish, fail };
class FancyString : struct
{
public property const String s
{
set { s = CopyString(value); }
get { return s; }
}
String s;
public FancyState state;
~FancyString()
{
delete s;
}
void OnDisplay(Surface surface, int x, int y, int width, void * fieldData, Alignment alignment, DataDisplayFlags displayFlags)
{
ListBox lb = fieldData;
Box box = surface.box;
switch(state)
{
case start:
surface.background = beige;
//surface.foreground = yellow;
break;
case finish:
surface.background = lightGreen;
//surface.foreground = green;
break;
case fail:
surface.background = tomato;
//surface.foreground = red;
break;
}
surface.Clip({ 0, box.top, lb.clientSize.w, box.bottom});
surface.textOpacity = false;
surface.Clear(colorBuffer); // This would clear the cell to the background color
surface.Clip(box);
s.OnDisplay(surface, x, y, width, fieldData, alignment, displayFlags);
}
}
class Form1 : Window
{
caption = $"Form1";
background = formColor;
borderStyle = sizable;
hasMaximize = true;
hasMinimize = true;
hasClose = true;
clientSize = { 632, 438 };
ListBox listBox1 { this, caption = $"listBox1", size = { 444, 164 }, position = { 160, 128 }, hasHeader = true };
DataField fldName { dataType = class(FancyString), userData = listBox1, width = 100, header = "Name" };
DataField fldInt { dataType = class(int), width = 50, header = "Integer" };
DataField fldDate { dataType = class(Date), width = 200, header = "Date" };
Form1()
{
DataRow r;
DateTime now { };
now.GetLocalTime();
listBox1.AddField(fldName);
listBox1.AddField(fldInt);
listBox1.AddField(fldDate);
r = listBox1.AddRow();
r.SetData(fldName, FancyString { s = "Cool String", state = start });
r.SetData(fldInt, 32);
r.SetData(fldDate, now);
r = listBox1.AddRow();
r.SetData(fldName, FancyString { s = "Here", state = finish });
r.SetData(fldInt, 12);
r.SetData(fldDate, now);
r = listBox1.AddRow();
r.SetData(fldName, FancyString { s = "OK", state = fail });
r.SetData(fldInt, 51);
r.SetData(fldDate, now);
}
}
Form1 form1 {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment