Esempio n. 1
0
void cdIupDrawHorizSunkenMark(cdCanvas *canvas, int x1, int x2, int y, long light_shadow, long dark_shadow)
{
  cdCanvasForeground(canvas, dark_shadow);
  cdCanvasLine(canvas, x1, y+1, x2, y+1);
  cdCanvasForeground(canvas, light_shadow);
  cdCanvasLine(canvas, x1, y, x2, y);
}
Esempio n. 2
0
static void iDialDrawCircular(Ihandle* ih)
{
  double delta = 2 * M_PI / ih->data->num_div, a = ih->data->angle;
  int i, xc = ih->data->w / 2, yc = ih->data->h / 2, wide;
  ih->data->radius = dialmin(ih->data->w, ih->data->h) / 2 - 2 * IDIAL_SPACE;

  wide = (int)(2 * ih->data->radius);
  cdCanvasForeground(ih->data->cd_canvas, ih->data->mid_shadow);
  cdCanvasLineWidth(ih->data->cd_canvas, 2);
  cdCanvasArc(ih->data->cd_canvas, xc, yc, wide-1, wide-1, -135, 45.0);
  cdCanvasLineWidth(ih->data->cd_canvas, 1);
  cdCanvasForeground(ih->data->cd_canvas, ih->data->bgcolor);
  cdCanvasSector(ih->data->cd_canvas, xc, yc, wide-2, wide-2, 0.0, 360.0);
  cdCanvasForeground(ih->data->cd_canvas, ih->data->light_shadow);
  cdCanvasArc(ih->data->cd_canvas, xc, yc, wide, wide, 45, 225);
  cdCanvasForeground(ih->data->cd_canvas, ih->data->dark_shadow);
  cdCanvasArc(ih->data->cd_canvas, xc, yc, wide, wide, -135, 45);

  for (i = 0; i < ih->data->num_div; ++i)
  {
    int x2 = (int)(xc + (ih->data->radius - 6) * cos(a));
    int y2 = (int)(yc + (ih->data->radius - 6) * sin(a));

    if (i == 0)
    {
      cdCanvasForeground(ih->data->cd_canvas, CD_BLACK);
      cdCanvasLine(ih->data->cd_canvas, xc, yc, x2, y2);
    }

    iDialDrawCircularMark(ih, x2-2, y2-2);
    a += delta;
  }

  iDialDrawCircularMark(ih, xc-2, yc-2);
}
Esempio n. 3
0
static void iDialDrawVerticalBackground(Ihandle* ih, double amin, double amax, int *ymin, int *ymax)
{
  double delta  = (0.5 * M_PI - amin) / IDIAL_NCOLORS;
  double a, yc  = ih->data->h / 2.0;
  *ymin = *ymax = ih->data->h / 2;
  for (a = amin; a < 0.5 * M_PI; a += delta)    /* shading */
  {
    int y0 = (int)(yc - ih->data->radius * cos(a));
    int y1 = (int)(yc - ih->data->radius * cos(a+delta));
    cdCanvasForeground(ih->data->cd_canvas, iDialGetFgColor(ih, a, amin));
    cdCanvasBox(ih->data->cd_canvas, IDIAL_SPACE+1, ih->data->w-1-IDIAL_SPACE-2, y0, y1);

    if (y0 < *ymin) *ymin = y0;

    if (abs(y1-y0) < 2)
      continue;
  }
  for (a = 0.5 * M_PI; a < amax; a += delta)
  {
    int y0 = (int)(yc + ih->data->radius * fabs(cos(a)));
    int y1 = (int)(yc + ih->data->radius * fabs(cos(a+delta)));
    cdCanvasForeground(ih->data->cd_canvas, iDialGetFgColor(ih, a, amin));
    cdCanvasBox(ih->data->cd_canvas, IDIAL_SPACE+1, ih->data->w-1-IDIAL_SPACE-2, y0, y1);

    if (y1 > *ymax) *ymax = y1;

    if (abs(y1-y0) < 2)
      continue;
  }
}
Esempio n. 4
0
static void iDialDrawHorizontalBackground(Ihandle* ih,double amin,double amax, int *xmin, int *xmax)
{
  double delta = (0.5 * M_PI - amin) / IDIAL_NCOLORS;
  double a, xc = ih->data->w / 2.0;
  *xmin = *xmax = ih->data->w / 2;
  for (a = amin; a < 0.5 * M_PI; a += delta)
  {
    int x0=(int)(xc - ih->data->radius * cos(a));
    int x1=(int)(xc - ih->data->radius * cos(a + delta));
    cdCanvasForeground(ih->data->cd_canvas,iDialGetFgColor(ih, a, amin));
    cdCanvasBox(ih->data->cd_canvas, x0, x1, IDIAL_SPACE+2, ih->data->h-1-IDIAL_SPACE-1);

    if (x0 < *xmin) *xmin = x0;

    if (abs(x1 - x0) < 2)
      continue;
  }
  for (a = 0.5 * M_PI; a < amax; a += delta)
  {
    int x0 =(int)(xc + ih->data->radius * fabs(cos(a)));
    int x1 =(int)(xc + ih->data->radius * fabs(cos(a + delta)));
    cdCanvasForeground(ih->data->cd_canvas, iDialGetFgColor(ih, a, amin));
    cdCanvasBox(ih->data->cd_canvas, x0, x1, IDIAL_SPACE+2, ih->data->h-1-IDIAL_SPACE-1);

    if (x1 > *xmax) *xmax = x1;

    if (abs(x1-x0) < 2)
      continue;
  }
}
Esempio n. 5
0
static int draw_cb(Ihandle* h, int i, int j, int xmin, int xmax, int ymin, int ymax, cdCanvas* canvas)
{
    int xm = (xmax + xmin) / 2;
    int ym = (ymax + ymin) / 2;
    static char buffer[64];

    if (i == 1 && j == 2) return IUP_DEFAULT;
    if (i == 2 && j == 1) return IUP_DEFAULT;
    if (i == 2 && j == 2) return IUP_DEFAULT;
    if (i == 5 && j == 6) return IUP_DEFAULT;
    if (i == 6 && j == 5) return IUP_DEFAULT;
    if (i == 6 && j == 6) return IUP_DEFAULT;

    if (i == 1 && j == 1)
        cdCanvasForeground(canvas, CD_WHITE);
    else
        cdCanvasForeground(canvas, cdEncodeColor(
                               (unsigned char)(i*20),
                               (unsigned char)(j*100),
                               (unsigned char)(i+100)));
    cdCanvasBox(canvas, xmin, xmax, ymin, ymax);
    cdCanvasTextAlignment(canvas, CD_CENTER);
    cdCanvasForeground(canvas, CD_BLACK);
    sprintf(buffer, "(%02d, %02d)", i, j);
    cdCanvasText(canvas, xm, ym, buffer);

    return IUP_DEFAULT;
}
Esempio n. 6
0
void cdIupDrawVertSunkenMark(cdCanvas *canvas, int x, int y1, int y2, long light_shadow, long dark_shadow)
{
  cdCanvasForeground(canvas, dark_shadow);
  cdCanvasLine(canvas, x-1, y1, x-1, y2);
  cdCanvasForeground(canvas, light_shadow);
  cdCanvasLine(canvas,   x, y1,   x, y2);
}
Esempio n. 7
0
static int draw_cb(Ihandle* h, int i, int j, int xmin, int xmax, int ymin, int ymax, cdCanvas* canvas) 
{
  if (((i%2) && (j%2)) || (((i+1)%2) && ((j+1)%2))) 
    cdCanvasForeground(canvas, CD_WHITE);
  else 
    cdCanvasForeground(canvas, CD_BLACK);
  cdCanvasBox(canvas, xmin, xmax, ymin, ymax);

  return IUP_DEFAULT;
}
Esempio n. 8
0
void cdIupDrawFocusRect(cdCanvas *canvas, int x1, int y1, int x2, int y2)
{
  int old_linestyle = cdCanvasLineStyle(canvas, CD_DOTTED);
  int old_foreground = cdCanvasForeground(canvas, CD_WHITE);
  int old_writemode = cdCanvasWriteMode(canvas, CD_XOR);

  cdCanvasRect(canvas, x1, x2, y1, y2);

  cdCanvasWriteMode(canvas, old_writemode);
  cdCanvasForeground(canvas, old_foreground);
  cdCanvasLineStyle(canvas, old_linestyle);
}
Esempio n. 9
0
void cdIupDrawRaiseRect(cdCanvas *canvas, int x1, int y1, int x2, int y2, long light_shadow, long mid_shadow, long dark_shadow)
{
  cdCanvasForeground(canvas, light_shadow);
  cdCanvasLine(canvas, x1, y1+1,   x1, y2);
  cdCanvasLine(canvas, x1,  y2, x2-1, y2);

  cdCanvasForeground(canvas, dark_shadow);
  cdCanvasLine(canvas, x1, y1, x2, y1);
  cdCanvasLine(canvas, x2, y1, x2, y2);

  cdCanvasForeground(canvas, mid_shadow);
  cdCanvasLine(canvas, x1+1, y1+1, x2-1, y1+1);
  cdCanvasLine(canvas, x2-1, y1+2, x2-1, y2-1);
}
Esempio n. 10
0
static void iMatrixDrawComboFeedback(Ihandle* ih, int x2, int y1, int y2, int active, long framecolor)
{
    int xh2, yh2, x1;

    /* feedback area */
    x2 -= IMAT_PADDING_W/2 + IMAT_FRAME_W/2;
    x1  = x2 - IMAT_COMBOBOX_W;
    y1 += IMAT_PADDING_H/2 + IMAT_FRAME_H/2;
    y2 -= IMAT_PADDING_H/2 + IMAT_FRAME_H/2;

    /* feedback background */
    iMatrixDrawSetBgColor(ih, 0, 0, 0, active);
    iupMATRIX_BOX(ih, x1, x2, y1, y2);

    /* feedback frame */
    cdCanvasForeground(ih->data->cddbuffer, framecolor);
    iupMATRIX_RECT(ih, x1, x2, y1, y2);

    /* feedback arrow */
    xh2 = x2 - IMAT_COMBOBOX_W / 2;
    yh2 = y2 - (y2 - y1) / 2;

    cdCanvasBegin(ih->data->cddbuffer, CD_FILL);
    iupMATRIX_VERTEX(ih, xh2, yh2 + 3);
    iupMATRIX_VERTEX(ih, xh2 + 4, yh2 - 1);
    iupMATRIX_VERTEX(ih, xh2 - 4, yh2 - 1);
    cdCanvasEnd(ih->data->cddbuffer);
}
Esempio n. 11
0
/*

%F Muda a largura da coluna interativamente, so muda a linha na tela.
   Qando o usuario termina o drag, a funcao iupmatColresFinish e chamada
   para realmente mudar a largura da coluna.
%i h : handle da matriz,
   x : coordenada x do mouse (coordenadas do canvas).

*/
void iupmatColresMove(Ihandle *h, int x)
{
  Tmat *mat=(Tmat*)matrix_data(h);
  int y1,y2, charwidth,charheight;

  iupdrvGetCharSize(h,&charwidth,&charheight);

  /* Se tamanho da coluna ficou muito pequeno, nao muda tamanho da coluna */
  if (x < DragColStartPos+charwidth+DECOR_X)
    return;

  y1 = mat_ht(mat);
  y2 = YmaxCanvas(mat);

  cdCanvasWriteMode(mat->cdcanvas, CD_XOR);
  cdCanvasForeground(mat->cdcanvas, RESIZE_COLOR);

  /* Se nao e a primeira vez, retira linha antiga */
  if (Lastxpos != -1)
    cdCanvasLine(mat->cdcanvas,Lastxpos,INVY(y1),Lastxpos,INVY(y2));

  cdCanvasLine(mat->cdcanvas,x,INVY(y1),x,INVY(y2));

  Lastxpos = x;
  cdCanvasWriteMode(mat->cdcanvas, CD_REPLACE);
}
Esempio n. 12
0
/*

%F Termina o resize interativo de colunas. Chama a funcao ChangeMatrixWidth para
   mudar realmente o tamanho da coluna.
%i h : handle da matriz,
   x : coordenada x do mouse (coordenadas do canvas).

*/
void iupmatColresFinish(Ihandle *h, int x)
{
  int  charwidth,charheight, width;
  int  y1, y2;
  Tmat *mat=(Tmat*)matrix_data(h);

  iupdrvGetCharSize(h,&charwidth,&charheight);
  width = x - DragColStartPos-DECOR_X;

  if (width < charwidth)
    width = charwidth ;  /* Tamanho minimo para a celula */

  /* Apaga feedback */
  if (Lastxpos != -1)
  {

    y1 = mat_ht(mat);
    y2 = YmaxCanvas(mat);

    cdCanvasWriteMode(mat->cdcanvas,CD_XOR);
    cdCanvasForeground(mat->cdcanvas,RESIZE_COLOR);
    cdCanvasLine(mat->cdcanvas,Lastxpos,INVY(y1),Lastxpos,INVY(y2));
    cdCanvasWriteMode(mat->cdcanvas,CD_REPLACE);

  }

  ChangeMatrixWH(h,DragCol,width+DECOR_X,MAT_COL);
  Dragging = 0;
}
Esempio n. 13
0
void iupMatrixColResFinish(Ihandle* ih, int x)
{
  char str[100];
  int width = x - ih->data->colres_drag_col_start_x;
  if (width < 0)
    width = 0;

  /* delete feedback */
  if (ih->data->colres_drag_col_last_x != -1)
  {
    int y1 = ih->data->lines.sizes[0];  /* from the bottom of the line of titles */
    int y2 = ih->data->h-1;             /* to the bottom of the matrix */

    cdCanvasWriteMode(ih->data->cdcanvas, CD_XOR);
    cdCanvasForeground(ih->data->cdcanvas, IMAT_RESIZE_COLOR);               
    cdCanvasLine(ih->data->cdcanvas, ih->data->colres_drag_col_last_x, iupMatrixInvertYAxis(ih, y1), 
                                     ih->data->colres_drag_col_last_x, iupMatrixInvertYAxis(ih, y2));
    cdCanvasWriteMode(ih->data->cdcanvas, CD_REPLACE);
  }

  ih->data->colres_dragging = 0;

  sprintf(str, "RASTERWIDTH%d", ih->data->colres_drag_col);
  iupAttribSetInt(ih, str, width-IMAT_PADDING_W-IMAT_FRAME_W);
  sprintf(str, "WIDTH%d", ih->data->colres_drag_col);
  iupAttribSetStr(ih, str, NULL);

  ih->data->need_calcsize = 1;
  iupMatrixDraw(ih, 0);
}
Esempio n. 14
0
/* Change the column width interactively, just change the line in the screen.
   When the user finishes the drag, the iupMatrixColResFinish function is called
   to truly change the column width. */
void iupMatrixColResMove(Ihandle* ih, int x)
{
  int y1, y2;

  int width = x - ih->data->colres_drag_col_start_x;
  if (width < 0)
    return;

  y1 = ih->data->lines.sizes[0];  /* from the bottom of the line of titles */
  y2 = ih->data->h-1;             /* to the bottom of the matrix */

  cdCanvasWriteMode(ih->data->cdcanvas, CD_XOR);
  cdCanvasForeground(ih->data->cdcanvas, IMAT_RESIZE_COLOR);

  /* If it is not the first time, move old line */
  if (ih->data->colres_drag_col_last_x != -1)
  {
    cdCanvasLine(ih->data->cdcanvas, ih->data->colres_drag_col_last_x, iupMatrixInvertYAxis(ih, y1), 
                                     ih->data->colres_drag_col_last_x, iupMatrixInvertYAxis(ih, y2));
  }

  cdCanvasLine(ih->data->cdcanvas, x, iupMatrixInvertYAxis(ih, y1), 
                                   x, iupMatrixInvertYAxis(ih, y2));

  ih->data->colres_drag_col_last_x = x;
  cdCanvasWriteMode(ih->data->cdcanvas, CD_REPLACE);
}
Esempio n. 15
0
/** 
 * Repaint function for one cell in a given coordinate;
 *  (assume that the canvas is already activated). 
 */
static void repaint_cell_in(TCells* obj, int i, int j, 
int xmin, int xmax, int ymin, int ymax) {
  int k;
  int w = obj->width;
  int h = obj->height;
  int hspan = 1;
  int vspan = 1;

  /* Checking if the cells is out of range. (no span will affect it!) */
  if (xmin > w || ymax < 0) return;
 
  /* Calculating cell spans */
  hspan = get_hspan(obj, i, j);
  vspan = get_vspan(obj, i, j);

  /* if any span is set to zero, then another cell invaded its space and
   * the cell does not need to draw itself */
  if (hspan == 0 || vspan == 0) return;

  /* Increasing cell's width and height according to its spans */
  for(k = 1; k < hspan; k++) xmax += get_width(obj, j+k);
  for(k = 1; k < vspan; k++) ymin -= get_height(obj, i+k);

  /* Checking if the cell expanded enough to appear inside the canvas */
  if (xmax < 0 || ymin > h) return;

  /* Calling application's draw callback */
  call_apl_draw(obj, xmin, xmax, ymin, ymax, i, j);

  /* Drawing a box in cell's area */
  if (obj->boxed) { 
     cdCanvasForeground(obj->cddbuffer,CD_BLACK);
     cdCanvasRect(obj->cddbuffer,xmin, xmax, ymin, ymax);
  }
}
Esempio n. 16
0
static void iMatrixDrawDropFeedback(Ihandle* ih, int x2, int y1, int y2, int active, long framecolor)
{
  int xh2, yh2, x1;

  /* feedback area */
  iupMatrixDrawSetDropFeedbackArea(&x1, &y1, &x2, &y2);

  /* feedback background */
  iMatrixDrawSetBgColor(ih, 0, 0, 0, active);
  iupMATRIX_BOX(ih, x1, x2, y1, y2);

  /* feedback frame */
  cdCanvasForeground(ih->data->cd_canvas, framecolor);
  iupMATRIX_RECT(ih, x1, x2, y1, y2);

  /* feedback arrow */
  xh2 = x2 - IMAT_DROPBOX_W/2;
  yh2 = y2 - (y2 - y1)/2;

  cdCanvasBegin(ih->data->cd_canvas, CD_FILL);
  iupMATRIX_VERTEX(ih, xh2, yh2 + 3);
  iupMATRIX_VERTEX(ih, xh2 + 4, yh2 - 1);
  iupMATRIX_VERTEX(ih, xh2 - 4, yh2 - 1);
  cdCanvasEnd(ih->data->cd_canvas);
}
Esempio n. 17
0
/* Change the column width interactively, just change the line in the screen.
   When the user finishes the drag, the iupMatrixColResFinish function is called
   to truly change the column width. */
void iupMatrixColResMove(Ihandle* ih, int x)
{
  int y1, y2;

  int delta = x - ih->data->colres_drag_col_start_x;
  int width = ih->data->columns.dt[ih->data->colres_drag_col].size + delta;
  if (width < 0)
    return;

  y1 = ih->data->lines.dt[0].size;  /* from the bottom of the line of titles */
  y2 = ih->data->h-1;             /* to the bottom of the matrix */

  cdCanvasWriteMode(ih->data->cdcanvas, CD_XOR);
  cdCanvasForeground(ih->data->cdcanvas, ih->data->colres_color);

  /* If it is not the first time, move old line */
  if (ih->data->colres_drag_col_last_x != -1)
  {
    cdCanvasLine(ih->data->cdcanvas, ih->data->colres_drag_col_last_x, iupMATRIX_INVERTYAXIS(ih, y1), 
                                     ih->data->colres_drag_col_last_x, iupMATRIX_INVERTYAXIS(ih, y2));
  }

  cdCanvasLine(ih->data->cdcanvas, x, iupMATRIX_INVERTYAXIS(ih, y1), 
                                   x, iupMATRIX_INVERTYAXIS(ih, y2));

  ih->data->colres_drag_col_last_x = x;
  cdCanvasWriteMode(ih->data->cdcanvas, CD_REPLACE);
}
Esempio n. 18
0
void iupMatrixColResFinish(Ihandle* ih, int x)
{
  int delta = x - ih->data->colres_drag_col_start_x;
  int width = ih->data->columns.dt[ih->data->colres_drag_col].size + delta;
  if (width < 0)
    width = 0;

  /* delete feedback */
  if (ih->data->colres_drag_col_last_x != -1)
  {
    int y1 = ih->data->lines.dt[0].size;  /* from the bottom of the line of titles */
    int y2 = ih->data->h-1;             /* to the bottom of the matrix */

    cdCanvasWriteMode(ih->data->cdcanvas, CD_XOR);
    cdCanvasForeground(ih->data->cdcanvas, ih->data->colres_color);               
    cdCanvasLine(ih->data->cdcanvas, ih->data->colres_drag_col_last_x, iupMATRIX_INVERTYAXIS(ih, y1), 
                                     ih->data->colres_drag_col_last_x, iupMATRIX_INVERTYAXIS(ih, y2));
    cdCanvasWriteMode(ih->data->cdcanvas, CD_REPLACE);
  }

  ih->data->colres_dragging = 0;

  iupAttribSetIntId(ih, "RASTERWIDTH", ih->data->colres_drag_col, width-IMAT_PADDING_W-IMAT_FRAME_W);
  iupAttribSetId(ih, "WIDTH", ih->data->colres_drag_col, NULL);

  ih->data->need_calcsize = 1;
  iupMatrixDraw(ih, 0);

  {
    IFni cb = (IFni)IupGetCallback(ih, "COLRESIZE_CB");
    if (cb)
      cb(ih, ih->data->colres_drag_col);
  }
}
Esempio n. 19
0
/* Change the column width interactively, just change the line in the screen.
   When the user finishes the drag, the iupMatrixColResFinish function is called
   to truly change the column width (x : x mouse coordinate (canvas coordinate)).
*/
void iupMatrixColResMove(Ihandle* ih, int x)
{
  int y1, y2, charwidth, charheight;

  iupdrvFontGetCharSize(ih, &charwidth, &charheight);

  /* If the size column was tiny, no change the size column */
  if(x < DragColStartPos + charwidth + IMAT_DECOR_X)
    return;

  y1 = ih->data->lin.titlewh;
  y2 = ih->data->YmaxC;

  cdCanvasWriteMode(ih->data->cdcanvas, CD_XOR);
  cdCanvasForeground(ih->data->cdcanvas, IMAT_RESIZE_COLOR);

  /* If it is not the first time, move old line */
  if(Lastxpos != -1)
    cdCanvasLine(ih->data->cdcanvas, Lastxpos, (ih->data->YmaxC - (y1)), Lastxpos, (ih->data->YmaxC - (y2)));

  cdCanvasLine(ih->data->cdcanvas, x, (ih->data->YmaxC - (y1)), x, (ih->data->YmaxC - (y2)));

  Lastxpos = x;
  cdCanvasWriteMode(ih->data->cdcanvas, CD_REPLACE);
}
Esempio n. 20
0
static void iMatrixDrawSort(Ihandle* ih, int x2, int y1, int y2, int xc, int lin, int col, char* sort)
{
  int yc;

  /* Create an space between text and cell margin */
  x2 -= IMAT_DECOR_X / 2;       xc -= IMAT_DECOR_X / 2;

  /* Set the color used to draw the text */
  if((lin > 0 && ih->data->lin.inactive[lin-1]) ||
     (col > 0 && ih->data->col.inactive[col-1]) ||
     !IupGetInt(ih, "ACTIVE"))
    cdCanvasForeground(ih->data->cddbuffer, IMAT_CD_INACTIVE_COLOR);
  else
    iMatrixDrawSetFgColor(ih, lin, col, 0);

  yc = (int)( (y1 + y2 ) / 2.0 - .5);

  cdCanvasBegin(ih->data->cddbuffer, CD_FILL);

  if(iupStrEqualNoCase(sort, "UP"))
  {
    CdVertex(x2 - 5, yc + 2);
    CdVertex(x2 - 1, yc - 2);
    CdVertex(x2 - 9, yc - 2);
  }
  else
  {
    CdVertex(x2 - 1, yc + 2);
    CdVertex(x2 - 9, yc + 2);
    CdVertex(x2 - 5, yc - 2);
  }

  cdCanvasEnd(ih->data->cddbuffer);
}
Esempio n. 21
0
/* Finish the interactive resize of columns. Call ChangeMatrixWidth to truly change
   the column size (x : x mouse coordinate (canvas coordinate)).
*/
void iupMatrixColResFinish(Ihandle* ih, int x)
{
  int charwidth, charheight, width;
  int y1, y2;

  iupdrvFontGetCharSize(ih, &charwidth, &charheight);
  width = x - DragColStartPos - IMAT_DECOR_X;

  if(width < charwidth)
    width = charwidth ;  /* min size to the cell */

  /* delete feedback */
  if(Lastxpos != -1)
  {
    y1 = ih->data->lin.titlewh;
    y2 = ih->data->YmaxC;

    cdCanvasWriteMode(ih->data->cdcanvas, CD_XOR);
    cdCanvasForeground(ih->data->cdcanvas, IMAT_RESIZE_COLOR);
    cdCanvasLine(ih->data->cdcanvas, Lastxpos, (ih->data->YmaxC - (y1)), Lastxpos, (ih->data->YmaxC - (y2)));
    cdCanvasWriteMode(ih->data->cdcanvas, CD_REPLACE);
  }

  iMatrixColResChangeMatrixWH(ih, DragCol, width + IMAT_DECOR_X, IMAT_MAT_COL);
  Dragging = 0;
}
Esempio n. 22
0
int canvas_action_cb(Ihandle* canvas)
{
  int x, y, canvas_width, canvas_height;
  unsigned int ri, gi, bi;
  imImage* image;
  cdCanvas* cd_canvas = (cdCanvas*)IupGetAttribute(canvas, "cdCanvas");
  Ihandle* config = (Ihandle*)IupGetAttribute(canvas, "CONFIG");
  const char* background = IupConfigGetVariableStrDef(config, "MainWindow", "Background", "255 255 255");

  IupGetIntInt(canvas, "DRAWSIZE", &canvas_width, &canvas_height);

  cdCanvasActivate(cd_canvas);

  /* draw the background */
  sscanf(background, "%u %u %u", &ri, &gi, &bi);
  cdCanvasBackground(cd_canvas, cdEncodeColor((unsigned char)ri, (unsigned char)gi, (unsigned char)bi));
  cdCanvasClear(cd_canvas);

  /* draw the image at the center of the canvas */
  image = (imImage*)IupGetAttribute(canvas, "IMAGE");
  if (image)
  {
    int view_width, view_height;
    Ihandle* zoom_val = IupGetDialogChild(canvas, "ZOOMVAL");
    double zoom_index = IupGetDouble(zoom_val, "VALUE");
    double zoom_factor = pow(2, zoom_index);

    float posy = IupGetFloat(canvas, "POSY");
    float posx = IupGetFloat(canvas, "POSX");

    view_width = (int)(zoom_factor * image->width);
    view_height = (int)(zoom_factor * image->height);

    if (canvas_width < view_width)
      x = (int)floor(-posx*view_width);
    else
      x = (canvas_width - view_width) / 2;

    if (canvas_height < view_height)
    {
      /* posy is top-bottom, CD is bottom-top.
         invert posy reference (YMAX-DY - POSY) */
      float dy = IupGetFloat(canvas, "DY");
      posy = 1.0f - dy - posy;
      y = (int)floor(-posy*view_height);
    }
    else
      y = (canvas_height - view_height) / 2;

    /* black line around the image */
    cdCanvasForeground(cd_canvas, CD_BLACK);
    cdCanvasRect(cd_canvas, x - 1, x + view_width, y - 1, y + view_height);

    imcdCanvasPutImage(cd_canvas, image, x, y, view_width, view_height, 0, 0, 0, 0);
  }

  cdCanvasFlush(cd_canvas);
  return IUP_DEFAULT;
}
Esempio n. 23
0
/* Draw a box, like a pressed button.
   -> px1, px2 - left bottom coordinates
   -> pdx, pdy - width and height
   -> lin, col - cell coordinates (to calculate the color)
*/
static void iMatrixDrawBoxPressed(Ihandle* ih, int px1, int py1, int pdx, int pdy, int lin, int col)
{
  int px2 = px1 + pdx - 1;
  int py2 = py1 + pdy - 1 - 1;

  if(pdx < 2 || pdy < 2)
    return;

  cdCanvasForeground(ih->data->cddbuffer, IMAT_CD_TS);
  CdLine(px2, py1, px2, py2);
  CdLine(px1, py2, px2, py2);
  cdCanvasForeground(ih->data->cddbuffer, IMAT_CD_BS);
  CdLine(px1, py1, px1, py2);
  CdLine(px1, py1, px2, py1);
  iMatrixDrawSetTitleBgColor(ih, lin, col);
  CdBox(px1 + 1, px2 - 1, py1 + 1, py2 - 1);
}
Esempio n. 24
0
static void iDialDrawCircularMark(Ihandle* ih, int x1, int y1)
{
  cdCanvasForeground(ih->data->cd_canvas, ih->data->bgcolor);
  cdCanvasBox(ih->data->cd_canvas,x1, x1+4, y1, y1+4);

  cdCanvasForeground(ih->data->cd_canvas, ih->data->light_shadow);
  cdCanvasLine(ih->data->cd_canvas, x1,   y1+1, x1,   y1+3);
  cdCanvasLine(ih->data->cd_canvas, x1+1, y1+4, x1+3, y1+4);

  cdCanvasForeground(ih->data->cd_canvas, ih->data->mid_shadow);
  cdCanvasLine(ih->data->cd_canvas, x1+1, y1, x1+4, y1);
  cdCanvasLine(ih->data->cd_canvas, x1+4, y1, x1+4, y1+3);

  cdCanvasForeground(ih->data->cd_canvas, ih->data->dark_shadow);
  cdCanvasLine(ih->data->cd_canvas, x1+2, y1,   x1+3, y1);
  cdCanvasLine(ih->data->cd_canvas, x1+4, y1+1, x1+4, y1+2);
}
Esempio n. 25
0
static void iMatrixDrawFrameRectTitle(Ihandle* ih, int lin, int col, int x1, int x2, int y1, int y2, long framecolor, char* str)
{
    /* avoid drawing over the frame of the next cell */
    x2 -= IMAT_FRAME_W/2;
    y2 -= IMAT_FRAME_H/2;

    /* right line */
    iMatrixDrawFrameVertLineCell(ih, lin, col, x2, y1, y2, framecolor, str);
    if (col==0)
    {
        /* left line */
        cdCanvasForeground(ih->data->cddbuffer, framecolor);
        iupMATRIX_LINE(ih, x1, y1, x1, y2);
        x1++;
    }
    else if (col==1 && ih->data->columns.sizes[0] == 0)
    {
        /* If does not have line titles then draw the >> left line << of the cell frame */
        iMatrixDrawFrameVertLineCell(ih, lin, col-1, x1, y1, y2-1, framecolor, str);
        x1++;
    }

    /* Titles have a white line near the frame, at left */
    cdCanvasForeground(ih->data->cddbuffer, CD_WHITE);
    iupMATRIX_LINE(ih, x1, y1+1, x1, y2-1);

    /* bottom line */
    iMatrixDrawFrameHorizLineCell(ih, lin, col, x1, x2, y2, framecolor, str);
    if (lin==0)
    {
        /* top line */
        cdCanvasForeground(ih->data->cddbuffer, framecolor);
        iupMATRIX_LINE(ih, x1, y1, x2, y1);
        y1++;
    }
    else if (lin==1 && ih->data->lines.sizes[0] == 0)
    {
        /* If does not have column titles then draw the >> top line << of the cell frame */
        iMatrixDrawFrameHorizLineCell(ih, lin-1, col, x1, x2-1, y1, framecolor, str);
        y1++;
    }

    /* Titles have a white line near the frame, at top */
    cdCanvasForeground(ih->data->cddbuffer, CD_WHITE);
    iupMATRIX_LINE(ih, x1, y1, x2-1, y1);
}
Esempio n. 26
0
static void iColorBrowserDlgColorCnvRepaint(IcolorDlgData* colordlg_data)
{
  int x, y, w, h, width, height, box_size = 10;

  if (!colordlg_data->cd_canvas_color)
    return;

  cdCanvasActivate(colordlg_data->cd_canvas_color);

  cdCanvasGetSize(colordlg_data->cd_canvas_color, &width, &height, NULL, NULL);

  cdCanvasBackground(colordlg_data->cd_canvas_color, CD_WHITE);
  cdCanvasClear(colordlg_data->cd_canvas_color);

  w = (width+box_size-1)/box_size;
  h = (height+box_size-1)/box_size;

  cdCanvasForeground(colordlg_data->cd_canvas_color, CD_GRAY);

  for (y = 0; y < h; y++)
  {                              
    for (x = 0; x < w; x++)
    {
      if (((x%2) && (y%2)) || (((x+1)%2) && ((y+1)%2)))
      {
        int xmin, xmax, ymin, ymax;

        xmin = x*box_size;
        xmax = xmin+box_size;
        ymin = y*box_size;
        ymax = ymin+box_size;

        cdCanvasBox(colordlg_data->cd_canvas_color, xmin, xmax, ymin, ymax);
      }
    }
  }

  cdCanvasForeground(colordlg_data->cd_canvas_color, colordlg_data->previous_color);
  cdCanvasBox(colordlg_data->cd_canvas_color, 0, width/2, 0, height);

  cdCanvasForeground(colordlg_data->cd_canvas_color, colordlg_data->color);
  cdCanvasBox(colordlg_data->cd_canvas_color, width/2+1, width, 0, height);

  cdCanvasFlush(colordlg_data->cd_canvas_color);
}
Esempio n. 27
0
static void iGaugeDrawText(Ihandle* ih, int xmid)
{
  int x, y, xmin, xmax, ymin, ymax;
  char* text = ih->data->text;

  cdIupSetFont(ih, ih->data->cddbuffer, IupGetAttribute(ih, "FONT"));
  cdCanvasTextAlignment(ih->data->cddbuffer, CD_CENTER);
  cdCanvasBackOpacity(ih->data->cddbuffer, CD_TRANSPARENT);

  x = (int)(0.5 * ih->data->w);
  y = (int)(0.5 * ih->data->h);

  if(text == NULL)
  {
    char* m = iupStrGetMemory(30);
    sprintf(m, "%.1f%%", 100 * (ih->data->value - ih->data->vmin) / (ih->data->vmax - ih->data->vmin));
    text = m;
  }

  cdCanvasGetTextBox(ih->data->cddbuffer, x, y, text, &xmin, &xmax, &ymin, &ymax);

  if(xmid < xmin)
  {
    cdCanvasForeground(ih->data->cddbuffer, ih->data->fgcolor);
    cdCanvasText(ih->data->cddbuffer, x, y, text);
  }
  else if(xmid > xmax)
  {
    cdCanvasForeground(ih->data->cddbuffer, ih->data->bgcolor);
    cdCanvasText(ih->data->cddbuffer, x, y, text);
  }
  else
  {
    cdCanvasClip(ih->data->cddbuffer, CD_CLIPAREA);
    cdCanvasClipArea(ih->data->cddbuffer, xmin, xmid, ymin, ymax);
    cdCanvasForeground(ih->data->cddbuffer, ih->data->bgcolor);
    cdCanvasText(ih->data->cddbuffer, x, y, text);

    cdCanvasClipArea(ih->data->cddbuffer, xmid, xmax, ymin, ymax);
    cdCanvasForeground(ih->data->cddbuffer, ih->data->fgcolor);
    cdCanvasText(ih->data->cddbuffer, x, y, text);
    cdCanvasClip(ih->data->cddbuffer, CD_CLIPOFF);
  }
}
Esempio n. 28
0
static int iMatrixDrawFrameVertLineCell(Ihandle* ih, int lin, int col, int x, int y1, int y2, long framecolor)
{
  int transp = iMatrixDrawGetFrameVertColor(ih, lin, col, &framecolor);
  if (transp)
    return 1;

  cdCanvasForeground(ih->data->cd_canvas, framecolor);
  iupMATRIX_LINE(ih, x, y1, x, y2);    /* right vertical line */
  return 0;
}
Esempio n. 29
0
static int iMatrixDrawFrameHorizLineCell(Ihandle* ih, int lin, int col, int x1, int x2, int y, long framecolor)
{
  int transp = iMatrixDrawGetFrameHorizColor(ih, lin, col, &framecolor);
  if (transp)
    return 1;

  cdCanvasForeground(ih->data->cd_canvas, framecolor);
  iupMATRIX_LINE(ih, x1, y, x2, y);   /* bottom horizontal line */
  return 0;
}
Esempio n. 30
0
 virtual void mapped_()
 {
     L("Canvas mapped");
     cdInitContextPlus();
     cdUseContextPlus(1);
     canvas_ = cdCreateCanvas(CD_IUP, *this);
     cdCanvasForeground(canvas_, CD_BLUE);
     cdCanvasSetAttribute(canvas_, "ANTIALIAS", "0");
     //cdUseContextPlus(0);
 }