srccontrols/matrix/iupmat_draw.c
void iupMatrixDrawTitleColumns(Ihandle* ih, int col1, int col2)
{
  int x1, y1, x2, y2, first_col, adjust_merged_col = 0;
  int col, active, col_alignment, lin_alignment, framehighlight;
  long framecolor;
  IFniiiiiiC draw_cb;

  /* here lin==0 always */

  if (!ih->data->lines.dt[0].size)
    return;

  if (ih->data->merge_info_count)
    adjust_merged_col = iMatrixAdjustVisibleColToMergedCells(ih, &col1, 0, 0);

  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 (!adjust_merged_col && 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, iupMatrixGetWidth(ih) - 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;
  if (adjust_merged_col)
  {
    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");
  col_alignment = iupMatrixGetColAlignmentLin0(ih);
  lin_alignment = iupMatrixGetLinAlignment(ih, 0);

  /* Draw the titles */
  for (col = col1; col <= col2; col++)
  {
    int merged, i;

    /* If it is hidden column (size = 0), do not draw the title */
    if (ih->data->columns.dt[col].size == 0)
      continue;

    merged = 0;
    if (ih->data->merge_info_count)
      merged = iupMatrixGetMerged(ih, 0, col);

    x2 = x1 + ih->data->columns.dt[col].size;

    if (merged)
    {
      int startLin, endLin, startCol, endCol;
      iupMatrixGetMergedRect(ih, merged, &startLin, &endLin, &startCol, &endCol);

      if (0 == startLin && col == startCol) /* merged start */
      {
        for (i = startCol + 1; i <= endCol; i++)
          x2 += ih->data->columns.dt[i].size;
      }
      else
        continue;  /* ignore internal merged */
    }

    /* 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_PADDING_W / 2 + IMAT_FEEDBACK_SIZE + IMAT_PADDING_W / 2; /* same space is used by the sort sign */

      iMatrixDrawCellValue(ih, x1, x2 - sort, y1, y2, col_alignment, lin_alignment, marked, active, 0, col, draw_cb, framecolor);
    }

    x1 = x2;
  }

  cdCanvasClip(ih->data->cd_canvas, CD_CLIPOFF);
}
/* 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 */
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
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, adjust_merged_col = 0;
  int col, active, col_alignment, lin_alignment, framehighlight;
  long framecolor;
  IFniiiiiiC draw_cb;
  if (!ih->data->lines.dt[0].size)
    return;
  if (ih->data->merge_info_count)
    adjust_merged_col = iMatrixAdjustVisibleColToMergedCells(ih, &col1, 0, 0);
  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 (!adjust_merged_col && 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;
  }
  y1 = 0;
  y2 = ih->data->lines.dt[0].size;
  iupMATRIX_CLIPAREA(ih, x1, iupMatrixGetWidth(ih) - 1, y1, y2);
  cdCanvasClip(ih->data->cd_canvas, CD_CLIPAREA);
  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;
  if (adjust_merged_col)
  {
    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");
  col_alignment = iupMatrixGetColAlignmentLin0(ih);
  lin_alignment = iupMatrixGetLinAlignment(ih, 0);
  for (col = col1; col <= col2; col++)
  {
    int merged, i;
    if (ih->data->columns.dt[col].size == 0)
      continue;
    merged = 0;
    if (ih->data->merge_info_count)
      merged = iupMatrixGetMerged(ih, 0, col);
    x2 = x1 + ih->data->columns.dt[col].size;
    if (merged)
    {
      int startLin, endLin, startCol, endCol;
      iupMatrixGetMergedRect(ih, merged, &startLin, &endLin, &startCol, &endCol);
      if (0 == startLin && col == startCol) 
      {
        for (i = startCol + 1; i <= endCol; i++)
          x2 += ih->data->columns.dt[i].size;
      }
      else
        continue;  
    }
    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_PADDING_W / 2 + IMAT_FEEDBACK_SIZE + IMAT_PADDING_W / 2; 
      iMatrixDrawCellValue(ih, x1, x2 - sort, y1, y2, col_alignment, lin_alignment, marked, active, 0, col, draw_cb, framecolor);
    }
    x1 = x2;
  }
  cdCanvasClip(ih->data->cd_canvas, CD_CLIPOFF);
}
void iupMatrixDrawTitleColumns ( Ihandle * ih , int col1 , int col2 ) { int x1 , y1 , x2 , y2 , first_col , adjust_merged_col = 0 ; int col , active , col_alignment , lin_alignment , framehighlight ; long framecolor ; IFniiiiiiC draw_cb ; if ( ! ih -> data -> lines . dt [ 0 ] . size ) return ; if ( ih -> data -> merge_info_count ) adjust_merged_col = iMatrixAdjustVisibleColToMergedCells ( ih , & col1 , 0 , 0 ) ; 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 ( ! adjust_merged_col && 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 ; } y1 = 0 ; y2 = ih -> data -> lines . dt [ 0 ] . size ; iupMATRIX_CLIPAREA ( ih , x1 , iupMatrixGetWidth ( ih ) - 1 , y1 , y2 ) ; cdCanvasClip ( ih -> data -> cd_canvas , CD_CLIPAREA ) ; 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 ; if ( adjust_merged_col ) { for ( col = first_col ; col > col1 ; col -- ) x1 -= ih -> data -> columns . dt [ col ] . size ; } framecolor = cdIupConvertColor ( iupAttribGetStr ( ih , " " ) ) ; framehighlight = iupAttribGetInt ( ih , " " ) ; active = iupdrvIsActive ( ih ) ; draw_cb = ( IFniiiiiiC ) IupGetCallback ( ih , " " ) ; col_alignment = iupMatrixGetColAlignmentLin0 ( ih ) ; lin_alignment = iupMatrixGetLinAlignment ( ih , 0 ) ; for ( col = col1 ; col <= col2 ; col ++ ) { int merged , i ; if ( ih -> data -> columns . dt [ col ] . size == 0 ) continue ; merged = 0 ; if ( ih -> data -> merge_info_count ) merged = iupMatrixGetMerged ( ih , 0 , col ) ; x2 = x1 + ih -> data -> columns . dt [ col ] . size ; if ( merged ) { int startLin , endLin , startCol , endCol ; iupMatrixGetMergedRect ( ih , merged , & startLin , & endLin , & startCol , & endCol ) ; if ( 0 == startLin && col == startCol ) { for ( i = startCol + 1 ; i <= endCol ; i ++ ) x2 += ih -> data -> columns . dt [ i ] . size ; } else continue ; } 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_PADDING_W / 2 + IMAT_FEEDBACK_SIZE + IMAT_PADDING_W / 2 ; iMatrixDrawCellValue ( ih , x1 , x2 - sort , y1 , y2 , col_alignment , lin_alignment , marked , active , 0 , col , draw_cb , framecolor ) ; } x1 = x2 ; } cdCanvasClip ( ih -> data -> cd_canvas , CD_CLIPOFF ) ; }
Draw the column titles, visible, between col and lastcol, include it.
Draw the column titles visible between col and lastcol include it .
/* here lin==0 always */ /* Start the position of the first column title */ /* Find the initial position of the first column */ /* Draw the titles */ /* If it is hidden column (size = 0), do not draw the title */ /* merged start */ /* ignore internal merged */ /* If it doesn't have title, the loop just calculate the final position */ /* same space is used by the sort sign */