Ejemplo n.º 1
0
/* Change the CD foreground color, for the selected color to draw a cell with
   its FOREGROUND COLOR. This involves checking if there is a color attribute
   that cell.  If no, uses a color attribute for the line, else if no for the
   column,  else if no  for the entire matrix.   Finally,  if not find any of
   these, use the default color.
   -> lin, col - cell coordinates, in IUP format - i.e., l,l represents the left
                 top cell of the matrix; lin and col values = 0 represents the
                 title lines and columns.
   -> mark - indicate if a cell is marked. If yes, its color is attenuated.
*/
static unsigned long iMatrixDrawSetFgColor(Ihandle* ih, int lin, int col, int mark)
{
    unsigned char r = 0, g = 0, b = 0;
    iupMatrixGetFgRGB(ih, lin, col, &r, &g, &b);

    if (mark)
    {
        r = IMAT_ATENUATION(r);
        g = IMAT_ATENUATION(g);
        b = IMAT_ATENUATION(b);
    }

    return cdCanvasForeground(ih->data->cddbuffer, cdEncodeColor(r, g, b));
}
Ejemplo n.º 2
0
void iupMatrixAddMarkedAttenuation(Ihandle* ih, unsigned char *r, unsigned char *g, unsigned char *b)
{
  char* hlcolor = iupAttribGetStr(ih, "HLCOLOR");
  unsigned char hl_r, hl_g, hl_b;
  if (iupStrToRGB(hlcolor, &hl_r, &hl_g, &hl_b))
  {
    unsigned char a = (unsigned char)iupAttribGetInt(ih, "HLCOLORALPHA");
    *r = iupALPHABLEND(*r, hl_r, a);
    *g = iupALPHABLEND(*g, hl_g, a);
    *b = iupALPHABLEND(*b, hl_b, a);
  }

  *r = IMAT_ATENUATION(*r);
  *g = IMAT_ATENUATION(*g);
  *b = IMAT_ATENUATION(*b);
}
Ejemplo n.º 3
0
/* Change the CD foreground color, for the selected color to draw a cell with
   its BACKGROUND COLOR. This involves checking if there is a color attribute
   that cell.  If no, uses a color attribute for the line, else if no for the
   column,  else if no  for the entire matrix.   Finally,  if not find any of
   these, use the default color.
   -> lin, col - cell coordinates, in IUP format - i.e., l,l represents the left
                 top cell of the matrix; lin and col values = 0 represents the
                 title lines and columns.
   -> mark - indicate if a cell is marked. If yes, its color is attenuated.
*/
static unsigned long iMatrixDrawSetBgColor(Ihandle* ih, int lin, int col, int mark, int active)
{
    unsigned char r = 255, g = 255, b = 255;

    iupMatrixGetBgRGB(ih, lin, col, &r, &g, &b);

    if (mark)
    {
        r = IMAT_ATENUATION(r);
        g = IMAT_ATENUATION(g);
        b = IMAT_ATENUATION(b);
    }

    if (!active)
    {
        r = cdIupLIGTHER(r);
        g = cdIupLIGTHER(g);
        b = cdIupLIGTHER(b);
    }

    return cdCanvasForeground(ih->data->cddbuffer, cdEncodeColor(r, g, b));
}
Ejemplo n.º 4
0
static void iMatrixDrawToggle(Ihandle* ih, int x2, int y1, int y2, int lin, int col, int marked, int active)
{
  int x1;
  long bgcolor = ih->data->bgcolor_cd;

  /* toggle area */
  iupMatrixDrawSetToggleArea(&x1, &y1, &x2, &y2);

  /* toggle background */
  if (marked)
  {
    unsigned char bg_r, bg_g, bg_b;
    cdDecodeColor(bgcolor, &bg_r, &bg_g, &bg_b);
    bg_r = IMAT_ATENUATION(bg_r);
    bg_g = IMAT_ATENUATION(bg_g);
    bg_b = IMAT_ATENUATION(bg_b);
    bgcolor = cdEncodeColor(bg_r, bg_g, bg_b);
  }
  cdCanvasForeground(ih->data->cd_canvas, bgcolor);
  iupMATRIX_BOX(ih, x1, x2, y1, y2);

  /* toggle frame */
  iMatrixDrawSetFgColor(ih, lin, col, marked, active);
  iupMATRIX_RECT(ih, x1, x2, y1, y2);

  /* toggle check */
  if (iupAttribGetIntId2(ih, "TOGGLEVALUE", lin, col))
  {
    int half = IMAT_TOGGLE_SIZE/2;
    iupMATRIX_LINE(ih, x1 + half - 2, y2 - 2, x1 + half - 2 + 6, y2 - 2 - 6);
    iupMATRIX_LINE(ih, x1 + half - 2, y2 - 3, x1 + half - 2 + 6, y2 - 3 - 6);
    iupMATRIX_LINE(ih, x1 + half - 2, y2 - 4, x1 + half - 2 + 5, y2 - 4 - 5);

    iupMATRIX_LINE(ih, x1 + half - 2, y2 - 2, x1 + half - 2 - 2, y2 - 2 - 2);
    iupMATRIX_LINE(ih, x1 + half - 2, y2 - 3, x1 + half - 2 - 2, y2 - 3 - 2);
    iupMATRIX_LINE(ih, x1 + half - 2, y2 - 4, x1 + half - 2 - 1, y2 - 4 - 1);
  }
}