1

I can color cells by specifying a Row format or a column format but that applies the coloring/formatting to the entire row or column. I'd like to set each cell's color based on some criteria. When I include the ... coloring tags in the setCDKMatrixCell() call those characters get set to the cell text not used to format the cell.

Is there another way? Or any ideas on how to modify the drawCDKMatrixCell to do this?

void drawCDKMatrixCell() {
...

if (matrix->dominant == ROW) {
    highlight = matrix->rowtitle[absolute_row][0] & A_ATTRIBUTES;
}
else if (matrix->dominant == COL) {
    highlight = matrix->coltitle[col][0] & A_ATTRIBUTES;
}

/* Draw in the cell info. */
for (x = 1; x <= matrix->colwidths[col]; x++) {
        chtype ch = (((x <= infolen) && !isHiddenDisplayType(disptype))
                     ? (CharOf(MATRIX_INFO(matrix, vrow, vcol)[x - 1]) | highlight)
                     : matrix->filler);


    (void) mvwaddch(cell, 1, x, ch | highlight);
}
...
jterm
  • 973
  • 1
  • 12
  • 32

1 Answers1

1

Cells are drawn using a private function

static void drawCDKMatrixCell (CDKMATRIX *matrix,
                               int row,
                               int col,
                               int vrow,
                               int vcol,
                               chtype attr,
                               boolean Box)

which simply uses mvwaddch for each character in the cell. The information for that is set using

int setCDKMatrixCell (CDKMATRIX *matrix, int row, int col, const char *value)

and stored in the matrix as char (not chtype). If the drawCDKMatrixCell function were modified, say, to use char2Chtype to construct the data, then you could do what you're asking.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • thanks for the advice. I included the code hunk I believe is responsible for coloring. Would you mind pointing out how to use char2Chtype to set the color? My confusion is b/c the text is written char by char and OR'd with the "highlight'. Not sure exactly how that works. – jterm Dec 14 '16 at 15:19