Exemplo n.º 1
0
static void iMatrixDrawSetCellClipping(Ihandle* ih, int x1, int x2, int y1, int y2)
{
    int old_clip = cdCanvasClip(ih->data->cddbuffer, CD_QUERY);
    if (old_clip == CD_CLIPAREA)
    {
        cdCanvasGetClipArea(ih->data->cddbuffer, &(ih->data->clip_x1), &(ih->data->clip_x2), &(ih->data->clip_y1), &(ih->data->clip_y2));
        y1 = iupMATRIX_INVERTYAXIS(ih, y1);
        y2 = iupMATRIX_INVERTYAXIS(ih, y2);
        if (x1 > x2) {
            int tmp = x1;
            x1 = x2;
            x2 = tmp;
        }
        if (y1 > y2) {
            int tmp = y1;
            y1 = y2;
            y2 = tmp;
        }
        if (x1 < ih->data->clip_x1) x1 = ih->data->clip_x1;
        if (x2 > ih->data->clip_x2) x2 = ih->data->clip_x2;
        if (y1 < ih->data->clip_y1) y1 = ih->data->clip_y1;
        if (y2 > ih->data->clip_y2) y2 = ih->data->clip_y2;
        cdCanvasClipArea(ih->data->cddbuffer, x1, x2, y1, y2);
        cdCanvasClip(ih->data->cddbuffer, CD_CLIPAREA);
    }
}
Exemplo n.º 2
0
int wdCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax)
{
  int xminr, xmaxr, yminr, ymaxr;
  int clip = cdCanvasGetClipArea(canvas, &xminr, &xmaxr, &yminr, &ymaxr);
  _wCanvas2World(canvas, xminr, yminr, *xmin, *ymin);
  _wCanvas2World(canvas, xmaxr, ymaxr, *xmax, *ymax);
  return clip;
}
Exemplo n.º 3
0
Arquivo: wd.c Projeto: LuaDist/cd
int wdCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax)
{
  int xminr, xmaxr, yminr, ymaxr, clip;
  assert(canvas);
  if (!_cdCheckCanvas(canvas)) return CD_ERROR;

  clip = cdCanvasGetClipArea(canvas, &xminr, &xmaxr, &yminr, &ymaxr);
  _wCanvas2World(canvas, xminr, yminr, *xmin, *ymin);
  _wCanvas2World(canvas, xmaxr, ymaxr, *xmax, *ymax);
  return clip;
}
Exemplo n.º 4
0
/* Function used to call the client; is used when a cell must be repainted. */
static void iCellsCallDrawCb(Ihandle* ih, int xmin, int xmax, int ymin, int ymax, int i, int j)
{
  int oldxmin, oldxmax, oldymin, oldymax, oldclip;
  int w = ih->data->w;
  int h = ih->data->h;
  IFniiiiiiC draw_cb;
  cdCanvas* old_cnv = cdActiveCanvas();

  /* Getting clipping area for post restore */
  oldclip = cdCanvasClip(ih->data->cd_canvas, CD_QUERY);
  cdCanvasGetClipArea(ih->data->cd_canvas, &oldxmin, &oldxmax, &oldymin, &oldymax);

  if (ih->data->clipped)  /* Clipping the cell area */
  { 
    int cxmin, cxmax, cymin, cymax;
    cdCanvasClip(ih->data->cd_canvas, CD_CLIPAREA);
    cxmin = xmin < 0 ? 0 : xmin;
    cymin = ymin < 0 ? 0 : ymin;
    cxmax = xmax > w ? w : xmax;
    cymax = ymax > h ? h : ymax;
    cdCanvasClipArea(ih->data->cd_canvas, cxmin, cxmax, cymin, cymax);
  }

  draw_cb = (IFniiiiiiC)IupGetCallback(ih, "DRAW_CB");
  if (draw_cb)
  {
    if (old_cnv != ih->data->cd_canvas) /* backward compatibility code */
      cdActivate(ih->data->cd_canvas);

    draw_cb(ih, i, j, xmin, xmax, ymin, ymax, ih->data->cd_canvas);

    if (old_cnv && old_cnv != ih->data->cd_canvas)
    {
      cdActivate(old_cnv);
      cdCanvasActivate(ih->data->cd_canvas);
    }
  }

  cdCanvasClip(ih->data->cd_canvas, oldclip);
  cdCanvasClipArea(ih->data->cd_canvas, oldxmin, oldxmax, oldymin, oldymax);
}
Exemplo n.º 5
0
/** 
 * Function used to call the client; is used when a cell must be repainted.
 */
static void call_apl_draw(TCells* obj, int xmin, int xmax, 
int ymin, int ymax, int i, int j) {
  int cxmin, cxmax, cymin, cymax;
  int oldxmin, oldxmax, oldymin, oldymax;
  int w = obj->width;
  int h = obj->height;

  /* Getting clipping area for post restore */
  int oldclip = cdCanvasClip(obj->cddbuffer,CD_QUERY);
  cdCanvasGetClipArea(obj->cddbuffer,&oldxmin, &oldxmax, &oldymin, &oldymax);

  /* Clipoing the cell area */
  if (obj->clipped) { 
     cdCanvasClip(obj->cddbuffer, CD_CLIPAREA);
     cxmin = xmin < 0 ? 0 : xmin;
     cymin = ymin < 0 ? 0 : ymin;
     cxmax = xmax > w ? w : xmax;
     cymax = ymax > h ? h : ymax;
     cdCanvasClipArea(obj->cddbuffer, xmin, xmax, ymin, ymax);
  }

  /* Calling the application draw callback. */
  { 
     TDrawCb func = (TDrawCb)IupGetCallback(obj->self, IUP_DRAW_CB);
     if (func)
     {
       cdCanvas* old_cnv = cdActiveCanvas();
       if (old_cnv != obj->cddbuffer) /* backward compatibility code */
       cdActivate(obj->cddbuffer);

       func(obj->self, i, j, xmin, xmax, ymin, ymax, obj->cddbuffer);

       if (old_cnv != obj->cddbuffer)
         cdActivate(old_cnv);
     }
  }

  /* Restoring clipping attributes */
  cdCanvasClip(obj->cddbuffer,oldclip);
  cdCanvasClipArea(obj->cddbuffer, oldxmin, oldxmax, oldymin, oldymax);
}