我可以通过指定行格式或列格式来为单元格着色,但这会将着色/格式应用于整行或整列。我想根据某些标准设置每个单元格的颜色。当我在 setCDKMatrixCell()
调用中包含 ... 着色标签时,这些字符会设置为不用于设置单元格格式的单元格文本。
还有别的办法吗?或者关于如何修改 drawCDKMatrixCell 以执行此操作的任何想法?
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);
}
...
最佳答案
单元格是使用私有(private)函数绘制的
static void drawCDKMatrixCell (CDKMATRIX *matrix,
int row,
int col,
int vrow,
int vcol,
chtype attr,
boolean Box)
它只是对单元格中的每个字符使用 mvwaddch
。其信息是使用
int setCDKMatrixCell (CDKMATRIX *matrix, int row, int col, const char *value)
并作为char
(不是chtype
)存储在矩阵中。如果修改了 drawCDKMatrixCell
函数,例如,使用 char2Chtype
构造数据,那么您就可以按照您的要求进行操作。
关于c++ - 在NCurses CDK Matrix中,单个细胞可以着色吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41047037/