Forked from jerstlouis/gist:02f334d0cccca8741618
Last active
August 29, 2015 14:07
-
-
Save dardevelin/9f279d974290b85d1e1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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