On the table control, we need to change a bit EditControl method where we define in which color the current row will be painted. (Here, I provided you with a link where you can choose RGB colors to paint the hell at your own.)
// Color the active line in a table FormControl editControl(int column, int row) { #DEFINE.colorDarkTurkoise(112,147,219) // colors at your personal perception of hell #DEFINE.colorNeonBlue(77,77,255) #DEFINE.colorRosyBrown(255,193,193) #DEFINE.colorSaddleBrown(139,69,19) int oldStrColor = WinApi::RGB2int(#colorRosyBrown); // colors for cells not in focus int oldIntColor = WinApi::RGB2int(#colorSaddleBrown); int newIntColor = WinApi::RGB2int(#colorNeonBlue); // colors for the selected line int newStrColor = WinApi::RGB2int(#colorDarkTurkoise); ; // this is columns with int controls if ((column == 2) || (column == 4)) { // not in the header if (row > 1) { // this is in the selected line if (row == table.row()) intEdit.backgroundColor(newIntColor); else intEdit.backgroundColor(oldIntColor); return intEdit; } // this is the header else { if (row == table.row()) editline.backgroundColor(newStrColor); else editline.backgroundColor(oldStrColor); return editline; } } else { if (row == table.row()) editline.backgroundColor(newStrColor); else editline.backgroundColor(oldStrColor); return editline; } }
So, when the user selects another row, all its controls change their color--it's your responsibility to return the correct form control: StringEdit, IntEdit and so on.
The second method where we redraw the form is activeCellChanged.
public void activeCellChanged() { ; super(); // do not forget to repaint the form! element.redraw(); }
Coloring can be realized much more complicated with different color scheme, calculated conditions etc.
No comments:
Post a Comment