Created
October 17, 2014 04:02
-
-
Save jerstlouis/2fcb48b0cecec3eb0bd4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) | |
| { | |
| 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.Clear(colorBuffer); // This would clear the cell to the background color | |
| 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