/* Draw the column titles, visible, between col and lastcol, include it. Column titles marked will be draw with the appropriate feedback. -> col1 - First column to have its title drawn -> col2 - Last column to have its title drawn */ void iupMatrixDrawColumnTitle(Ihandle* ih, int col1, int col2) { int x1, y1, x2, y2; int col, active; char str[100]; long framecolor; IFniiiiiiC draw_cb; if (!ih->data->lines.sizes[0]) return; if (col1 > ih->data->columns.last || col2 < ih->data->columns.first) return; if (col1 < ih->data->columns.first) col1 = ih->data->columns.first; if (col2 > ih->data->columns.last) col2 = ih->data->columns.last; /* Start the position of the first column title */ y1 = 0; y2 = ih->data->lines.sizes[0]; x1 = ih->data->columns.sizes[0]; for(col = ih->data->columns.first; col < col1; col++) x1 += ih->data->columns.sizes[col]; framecolor = cdIupConvertColor(iupAttribGetStr(ih, "FRAMECOLOR")); active = iupdrvIsActive(ih); draw_cb = (IFniiiiiiC)IupGetCallback(ih, "DRAW_CB"); /* Draw the titles */ for(col = col1; col <= col2; col++) { /* If it is an hide column (size = 0), no draw the title */ if(ih->data->columns.sizes[col] == 0) continue; x2 = x1 + ih->data->columns.sizes[col]; /* If it doesn't have title, the loop just calculate the final position */ if (ih->data->lines.sizes[0]) { int marked = iupMatrixColumnIsMarked(ih, col); iMatrixDrawFrameRectTitle(ih, 0, col, x1, x2, y1, y2, framecolor, str); iMatrixDrawBackground(ih, x1, x2, y1, y2, marked, active, 0, col); iMatrixDrawCellValue(ih, x1, x2, y1, y2, IMAT_T_CENTER, marked, active, 0, col, draw_cb); iMatrixDrawSortSign(ih, x2, y1, y2, col, active, str); } x1 = x2; } }
/* Draw the column titles, visible, between col and lastcol, include it. Column titles marked will be draw with the appropriate feedback. -> col1 - First column to have its title drawn -> col2 - Last column to have its title drawn */ void iupMatrixDrawTitleColumns(Ihandle* ih, int col1, int col2) { int x1, y1, x2, y2, first_col; int col, active, alignment, framehighlight; long framecolor; IFniiiiiiC draw_cb; if (!ih->data->lines.dt[0].size) return; if (ih->data->columns.num_noscroll>1 && col1==1 && col2==ih->data->columns.num_noscroll-1) { first_col = 0; x1 = 0; } else { if (col1 > ih->data->columns.last || col2 < ih->data->columns.first) return; if (col1 < ih->data->columns.first) col1 = ih->data->columns.first; if (col2 > ih->data->columns.last) col2 = ih->data->columns.last; first_col = ih->data->columns.first; x1 = 0; for (col = 0; col< ih->data->columns.num_noscroll; col++) x1 += ih->data->columns.dt[col].size; } /* Start the position of the first column title */ y1 = 0; y2 = ih->data->lines.dt[0].size; iupMATRIX_CLIPAREA(ih, x1, ih->data->w-1, y1, y2); cdCanvasClip(ih->data->cd_canvas, CD_CLIPAREA); /* Find the initial position of the first column */ if (first_col==ih->data->columns.first) x1 -= ih->data->columns.first_offset; for(col = first_col; col < col1; col++) x1 += ih->data->columns.dt[col].size; framecolor = cdIupConvertColor(iupAttribGetStr(ih, "FRAMECOLOR")); framehighlight = iupAttribGetInt(ih, "FRAMETITLEHIGHLIGHT"); active = iupdrvIsActive(ih); draw_cb = (IFniiiiiiC)IupGetCallback(ih, "DRAW_CB"); alignment = iMatrixDrawGetAlignmentLin0(ih); /* Draw the titles */ for(col = col1; col <= col2; col++) { /* If it is an hide column (size = 0), no draw the title */ if(ih->data->columns.dt[col].size == 0) continue; x2 = x1 + ih->data->columns.dt[col].size; /* If it doesn't have title, the loop just calculate the final position */ if (ih->data->lines.dt[0].size) { int sort = 0; int marked = iupMatrixColumnIsMarked(ih, col); iMatrixDrawBackground(ih, x1, x2, y1, y2, marked, active, 0, col); iMatrixDrawFrameRectTitle(ih, 0, col, x1, x2, y1, y2, framecolor, framehighlight); if (iMatrixDrawSortSign(ih, x2, y1, y2, col, active)) sort = IMAT_DROPBOX_W; /* same space is used by the sort sign */ iMatrixDrawCellValue(ih, x1, x2-sort, y1, y2, alignment, marked, active, 0, col, draw_cb, framecolor); } x1 = x2; } cdCanvasClip(ih->data->cd_canvas, CD_CLIPOFF); }