Ejemplo n.º 1
0
static void cells_createcanvas(TCells* obj, Ihandle *self)
{
  if (!obj->cdcanvas)
    obj->cdcanvas = cdCreateCanvas(CD_IUP, self);

  if (obj->cdcanvas)
  {
    cdCanvasActivate(obj->cdcanvas);
    obj->cddbuffer = cdCreateCanvas(CD_DBUFFER, obj->cdcanvas);
  }
}
Ejemplo n.º 2
0
static int iColorbarMapMethod(Ihandle* ih)
{
  ih->data->cdcanvas = cdCreateCanvas(CD_IUP, ih);
  if (!ih->data->cdcanvas)
    return IUP_ERROR;

  /* this can fail if canvas size is zero */
  ih->data->cddbuffer = cdCreateCanvas(CD_DBUFFER, ih->data->cdcanvas);

  return IUP_NOERROR;
}
Ejemplo n.º 3
0
static int iColorBrowserResize_CB(Ihandle* ih)
{
  if (!ih->data->cddbuffer)
  {
    /* update canvas size */
    cdCanvasActivate(ih->data->cdcanvas);

    /* this can fail if canvas size is zero */
    ih->data->cddbuffer = cdCreateCanvas(CD_DBUFFERRGB, ih->data->cdcanvas);
  }

  if (!ih->data->cddbuffer)
    return IUP_DEFAULT;

  /* update size */
  iColorBrowserUpdateSize(ih);

  iColorBrowserUpdateCursorHue(ih);
  iColorBrowserUpdateCursorSI(ih);

  /* update render */
  iColorBrowserRenderImageHue(ih);
  iColorBrowserRenderImageSI(ih);

  return IUP_DEFAULT;
}
Ejemplo n.º 4
0
/* Callback called when the tree has its size altered
   dx, dy: Canvas size, in pixels.                    */
static int iTreeResizeCB(Ihandle* ih, int dx, int dy)
{
  if(!ih->data->cddbuffer)
  {
    /* update canvas size */
    cdCanvasActivate(ih->data->cdcanvas);

    /* this can fail if canvas size is zero */
    ih->data->cddbuffer = cdCreateCanvas(CD_DBUFFER, ih->data->cdcanvas);
    if(ih->data->cddbuffer)
      iTreeInitTree(ih);
  }

  if(!ih->data->cddbuffer)
    return IUP_DEFAULT;

  /* update canvas size */
  cdCanvasActivate(ih->data->cddbuffer);
  ih->data->XmaxC = dx - 1;
  ih->data->YmaxC = dy - 1;

  /* update render */
  iupTreeEditCheckHidden(ih);
  
  return IUP_DEFAULT;
}
Ejemplo n.º 5
0
int main(int argc, char **argv)
{
  Ihandle *dialog, *canvas;

  IupOpen(&argc, &argv);

  canvas = IupCanvas(NULL);
  IupSetAttribute(canvas, "RASTERSIZE", "300x200"); /* initial size */
  IupSetAttribute(canvas, "SCROLLBAR", "YES");
  IupSetAttribute(canvas, "XMAX", "599");
  IupSetAttribute(canvas, "YMAX", "399");

  IupSetCallback(canvas, "SCROLL_CB",  (Icallback)scroll_cb);
  IupSetCallback(canvas, "RESIZE_CB",  (Icallback)resize_cb);
  IupSetCallback(canvas, "ACTION",  (Icallback)action);
                   
  dialog = IupDialog(canvas);
  IupSetAttribute(dialog, "TITLE", "Scrollbar Test");

  IupMap(dialog);
  cdcanvas = cdCreateCanvas(CD_IUP, canvas);
  IupSetAttribute(canvas, "RASTERSIZE", NULL);  /* release the minimum limitation */
  
  IupShowXY(dialog,IUP_CENTER,IUP_CENTER);

  IupMainLoop();

  cdKillCanvas(cdcanvas);
  IupDestroy(dialog);

  IupClose();

  return EXIT_SUCCESS;

}
Ejemplo n.º 6
0
static int map_cb(Ihandle *ih)
{
  cdCanvas *cdcanvas;

#ifdef USE_IUPDRAW
  cdcanvas = cdCreateCanvas(CD_IUPDRAW, ih);
#else
  cdcanvas = cdCreateCanvas(CD_IUP, ih);
#endif
  if (!cdcanvas)
    return IUP_DEFAULT;

  IupSetAttribute(ih, "_APP_CDCANVAS", (char*)cdcanvas);

  return IUP_DEFAULT;
}
Ejemplo n.º 7
0
static int iColorbarResize_CB(Ihandle* ih)
{
  if (!ih->data->cddbuffer)
  {
    /* update canvas size */
    cdCanvasActivate(ih->data->cdcanvas);

    /* this can fail if canvas size is zero */
    ih->data->cddbuffer = cdCreateCanvas(CD_DBUFFER, ih->data->cdcanvas);
  }

  if (!ih->data->cddbuffer)
    return IUP_DEFAULT;

  /* update size */
  cdCanvasActivate(ih->data->cddbuffer);
  cdCanvasGetSize(ih->data->cddbuffer, &ih->data->w, &ih->data->h, NULL, NULL);

  /* update render */
  cdCanvasBackground(ih->data->cddbuffer, ih->data->bgcolor);
  cdCanvasClear(ih->data->cddbuffer);
  iColorbarRenderPreview(ih);
  iColorbarRenderCells(ih);

  return IUP_DEFAULT;
}
Ejemplo n.º 8
0
static int iMatrixResize_CB(Ihandle* ih)
{
  if (!ih->data->cddbuffer)
  {
    /* update canvas size */
    cdCanvasActivate(ih->data->cdcanvas);

    /* this can fail if canvas size is zero */
    ih->data->cddbuffer = cdCreateCanvas(CD_DBUFFER, ih->data->cdcanvas);
  }

  if (!ih->data->cddbuffer)
    return IUP_DEFAULT;

  /* update size */
  cdCanvasActivate(ih->data->cddbuffer);
  cdCanvasGetSize(ih->data->cddbuffer, &ih->data->w, &ih->data->h, NULL, NULL);

  iupMatrixEditForceHidden(ih);

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

  return IUP_DEFAULT;
}
Ejemplo n.º 9
0
void main(void)
{
	cdCanvas *canvas;
	canvas = cdCreateCanvas(CD_METAFILE,"TESTE.MF 100x100");
	cdActivate(canvas);
	draw();
	cdKillCanvas(canvas);
}
Ejemplo n.º 10
0
static int iCellsMapMethod(Ihandle* ih)
{
  ih->data->cd_canvas = cdCreateCanvas(CD_IUPDBUFFER, ih);
  if (!ih->data->cd_canvas)
    return IUP_ERROR;

  return IUP_NOERROR;
}
Ejemplo n.º 11
0
void SimpleCreateCanvasWindow(void)
{
  /* creates the canvas based in an existing window */
  if (contextplus) cdUseContextPlus(1);
  winCanvas = cdCreateCanvas(CD_IUP, winData);
  if (contextplus) cdUseContextPlus(0);
  curCanvas = winCanvas;
}
Ejemplo n.º 12
0
cdCanvas* cdCreateCanvasf(cdContext *context, const char* format, ...)
{
  char data[10240];
  va_list arglist;
  va_start(arglist, format);
  vsnprintf(data, 10240, format, arglist);

  return cdCreateCanvas(context, data);
}
Ejemplo n.º 13
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);
 }
Ejemplo n.º 14
0
/* Main program */
int main(int argc, char **argv)
{
    Ihandle *dlg, *cb;

    /* Initializes IUP */
    IupOpen(&argc, &argv);
    IupControlsOpen();


    /* Creates a canvas associated with the redraw action */
    cnvs = IupCanvas(NULL);
    IupSetCallback(cnvs, "ACTION", (Icallback)redraw_cb);

    /* Sets size, minimum and maximum values, position and size of the thumb   */
    /* of the horizontal scrollbar of the canvas                               */
    IupSetAttributes(cnvs, "RASTERSIZE=200x300");

    cb = IupColorbar();
    IupSetAttribute(cb, "RASTERSIZE", "70x");
    IupSetAttribute(cb, "EXPAND", "VERTICAL");
    IupSetAttribute(cb, "NUM_PARTS", "2");
    IupSetAttribute(cb, "SHOW_SECONDARY", "YES");
    IupSetCallback(cb, "SELECT_CB", (Icallback)select_cb);
    IupSetCallback(cb, "CELL_CB", (Icallback)cell_cb);
    IupSetCallback(cb, "SWITCH_CB", (Icallback)switch_cb);
//  IupSetAttribute(cb, "SQUARED", "NO");
    IupSetAttribute(cb, "PREVIEW_SIZE", "60");

    /* Creates a dialog with a vbox containing the canvas and the colorbar. */
    dlg = IupDialog(IupHbox(cnvs, cb, NULL));

    /* Sets the dialog's title, so that it is mapped properly */
    IupSetAttribute(dlg, "TITLE", "IupColorbar");

    /* Maps the dialog. This must be done before the creation of the CD canvas */
    IupMap(dlg);

    /* Creates a CD canvas of type CD_IUP */
    cdcanvas = cdCreateCanvas(CD_IUP, cnvs);

    /* Shows dialog on the center of the screen */
    IupShow(dlg);

    /* Initializes IUP main loop */
    IupMainLoop();

    /* Finishes IUP */
    IupClose();

    /* Program finished successfully */
    return EXIT_SUCCESS;

}
Ejemplo n.º 15
0
Archivo: wdhdcpy.c Proyecto: LuaDist/cd
void wdCanvasHardcopy(cdCanvas *canvas, cdContext* ctx, void *data, void(*draw_func)(cdCanvas *canvas_copy))
{
  /* Create a visualization surface. */
  cdCanvas *canvas_copy = cdCreateCanvas(ctx, data);
  if (!canvas_copy) return;

  /* Do hardcopy. */
  _wdHdcpyDoit(canvas, canvas_copy, draw_func);

  /* Destroy visualization surface. */
  cdKillCanvas(canvas_copy);
}
Ejemplo n.º 16
0
static int iMatrixMapMethod(Ihandle* ih)
{
  ih->data->cdcanvas = cdCreateCanvas(CD_IUP, ih);
  if (!ih->data->cdcanvas)
    return IUP_ERROR;

  /* this can fail if canvas size is zero */
  ih->data->cddbuffer = cdCreateCanvas(CD_DBUFFER, ih->data->cdcanvas);

  if (IupGetCallback(ih, "VALUE_CB"))
  {
    ih->data->callback_mode = 1;

    if (!IupGetCallback(ih, "VALUE_EDIT_CB"))
      iupAttribSetStr(ih, "READONLY", "YES");
  }

  iupMatrixMemAlloc(ih);

  return IUP_NOERROR;
}
Ejemplo n.º 17
0
void DrawCanvasDriver(cdContext* ctx, char* StrData)
{
  cdCanvas* tmpCanvas = cdCreateCanvas(ctx, StrData);
  if (tmpCanvas == NULL) 
  {
    printf("CreateCanvas(%s) - Failed!\n", StrData);
    return;
  }
  printf("CreateCanvas(%s)\n", StrData);
  SimpleDraw(tmpCanvas);
  cdKillCanvas(tmpCanvas);
  printf("KillCanvas()\n");
}
Ejemplo n.º 18
0
static void drawTestCD(Ihandle* ih)
{
    cdCanvas* canvas = cdCreateCanvas(CD_IUP, ih);
    int w = IupGetInt(ih, "PREVIEWWIDTH");
    int h = IupGetInt(ih, "PREVIEWHEIGHT");

    cdCanvasClear(canvas);
    cdCanvasForeground(canvas, cdEncodeColor(255, 0 , 0));

    cdCanvasLine(canvas, 0, 0, w-1, h-1);
    cdCanvasLine(canvas, 0, h-1, w-1, 0);
    cdKillCanvas(canvas);
}
Ejemplo n.º 19
0
int SimpleDrawImageRGB(void)
{
  use_opengl = 0;
  if (dbCanvas) cdKillCanvas(dbCanvas);

  if (contextplus) cdUseContextPlus(1);
  dbCanvas = cdCreateCanvas(CD_DBUFFERRGB, winCanvas);
  if (contextplus) cdUseContextPlus(0);

  curCanvas = dbCanvas;
  SimpleDraw(curCanvas);

  return 0;
}
Ejemplo n.º 20
0
static int map_cb(Ihandle *ih)
{
  cdCanvas *canvas = cdCreateCanvas(CD_IUP, ih);

  /* World size is fixed */
  wdCanvasWindow(canvas, 0, WORLD_W, 0, WORLD_H);

  /* handle scrollbar in world coordinates, so we only have to update DX/DY */
  IupSetAttribute(ih, "XMIN", "0");
  IupSetAttribute(ih, "YMIN", "0");
  IupSetfAttribute(ih, "XMAX", "%d", WORLD_W);
  IupSetfAttribute(ih, "YMAX", "%d", WORLD_H);

  return IUP_DEFAULT;
}
Ejemplo n.º 21
0
//void SimpleDrawTest(cdCanvas* canvas)
void SimpleDrawTestImageRGB(cdCanvas* canvas)
{
  int size = 2048*2048;
  unsigned char *red, *green, *blue;
  cdCanvas* canvas = cdCreateCanvas(CD_IMAGERGB, "2048x2048");
  cdActivate(canvas);

  red = calloc(size, 1);
  green = calloc(size, 1);
  blue = calloc(size, 1);

  cdPutImageRectRGB(2048, 2048, red, green, blue, 0, 3, 2048, 2017, 0, 2047, 3, 2020);

  free(red);
  free(green);
  free(blue);

  cdKillCanvas(canvas);
}
Ejemplo n.º 22
0
static int iDialResize_CB(Ihandle* ih)
{
  if (!ih->data->cddbuffer)
  {
    /* update canvas size */
    cdCanvasActivate(ih->data->cdcanvas);

    /* this can fail if canvas size is zero */
    ih->data->cddbuffer = cdCreateCanvas(CD_DBUFFER, ih->data->cdcanvas);
  }

  if (!ih->data->cddbuffer)
    return IUP_DEFAULT;

  /* update size */
  cdCanvasActivate(ih->data->cddbuffer);
  cdCanvasGetSize(ih->data->cddbuffer, &ih->data->w, &ih->data->h, NULL, NULL);

  /* update number of divisions */
  switch(ih->data->orientation)
  {
  case IDIAL_VERTICAL:
    ih->data->num_div = (int)((ih->data->h-2 * IDIAL_SPACE-2) * ih->data->density);
    break;

  case IDIAL_HORIZONTAL:
    ih->data->num_div = (int)((ih->data->w-2 * IDIAL_SPACE-2) * ih->data->density);
    break;

  case IDIAL_CIRCULAR:
    ih->data->num_div = (int)((dialmin(ih->data->w, ih->data->h)-2 * IDIAL_SPACE-2) * ih->data->density);
    break;
  }

  if (ih->data->num_div < 3) ih->data->num_div = 3;

  /* update render */
  cdCanvasBackground(ih->data->cddbuffer, ih->data->bgcolor);
  cdCanvasClear(ih->data->cddbuffer);
  ih->data->Draw(ih);
  
  return IUP_DEFAULT;
}
Ejemplo n.º 23
0
void ColorbarTest(void)
{
  Ihandle *dlg, *cb;
  
  IupControlsOpen();

  /* Creates a canvas associated with the redraw action */
  canvas = IupCanvas(NULL) ;
  IupSetCallback(canvas, "ACTION", (Icallback)redraw_cb);
  IupSetAttribute(canvas, "RASTERSIZE", "200x300");

  cb = IupColorbar(); 
  IupSetAttribute(cb, "RASTERSIZE",     "70x");
  IupSetAttribute(cb, "EXPAND",         "VERTICAL");
  IupSetAttribute(cb, "NUM_PARTS",      "2");
  IupSetAttribute(cb, "SHOW_SECONDARY", "YES");
  IupSetAttribute(cb, "PREVIEW_SIZE",   "60");
//  IupSetAttribute(cb, "ACTIVE",   "NO");
//  IupSetAttribute(cb, "BGCOLOR",   "128 0 255");

  IupSetCallback(cb, "SELECT_CB", (Icallback)select_cb);
  IupSetCallback(cb, "CELL_CB",   (Icallback)cell_cb);
  IupSetCallback(cb, "SWITCH_CB", (Icallback)switch_cb);
  IupSetCallback(cb, "EXTENDED_CB", (Icallback)extended_cb);

  dlg = IupDialog(IupHbox(canvas, cb, NULL));
  IupSetAttribute(dlg, "MARGIN", "5x5");
  
  IupSetAttribute(dlg, "TITLE", "IupColorbar");
  
  /* Maps the dlg. This must be done before the creation of the CD canvas.
     Could also use MAP_CB callback. */
  IupMap(dlg);
 
  cdcanvas = cdCreateCanvas(CD_IUP, canvas);
   
  IupPopup(dlg, IUP_CENTER, IUP_CENTER);

  cdKillCanvas(cdcanvas);
}
Ejemplo n.º 24
0
static int iGaugeResize_CB(Ihandle* ih)
{
  if (!ih->data->cddbuffer)
  {
    /* update canvas size */
    cdCanvasActivate(ih->data->cdcanvas);

    /* this can fail if canvas size is zero */
    ih->data->cddbuffer = cdCreateCanvas(CD_DBUFFER, ih->data->cdcanvas);
  }

  if (!ih->data->cddbuffer)
    return IUP_DEFAULT;

  /* update size */
  cdCanvasActivate(ih->data->cddbuffer);
  cdCanvasGetSize(ih->data->cddbuffer,&ih->data->w,&ih->data->h,NULL,NULL);

  /* update render */
  iGaugeDrawGauge(ih);

  return IUP_DEFAULT;
}
Ejemplo n.º 25
0
int SimpleDrawGL(void)
{
  char StrData[100];
  int w, h;
  double w_mm, h_mm;

  if (use_opengl)
    return 0;

  cdCanvasGetSize(curCanvas, &w, &h, &w_mm, &h_mm);

  sprintf(StrData, "%dx%d %g", w, h, ((double)w/w_mm));

  if (dbCanvas) cdKillCanvas(dbCanvas);

  dbCanvas = cdCreateCanvas(CD_GL, StrData);

  curCanvas = dbCanvas;
  use_opengl = 1;
  SimpleDraw(curCanvas);

  return 0;
}
Ejemplo n.º 26
0
int canvas_map_cb(Ihandle* canvas)
{
  cdCanvas* cd_canvas = cdCreateCanvas(CD_IUPDBUFFER, canvas);
  IupSetAttribute(canvas, "cdCanvas", (char*)cd_canvas);
  return IUP_DEFAULT;
}
Ejemplo n.º 27
0
static int iColorBrowserDlgColorCnvMap_CB(Ihandle* ih)
{
  IcolorDlgData* colordlg_data = (IcolorDlgData*)iupAttribGetInherit(ih, "_IUP_GC_DATA");
  colordlg_data->cd_canvas_color = cdCreateCanvas(CD_IUPDBUFFERRGB, ih);
  return IUP_DEFAULT;
}
Ejemplo n.º 28
0
static int cbCanvasMap(Ihandle* iup_canvas)
{
  cdCanvas* cd_canvas = cdCreateCanvas(CD_IUP, iup_canvas);
  IupSetAttribute(IupGetDialog(iup_canvas), "cdCanvas", (char*)cd_canvas);
  return IUP_DEFAULT;
}
Ejemplo n.º 29
0
/************************************************************\
* Gera um plasma de todos os valores de h em um circulo.     *
\************************************************************/
void hls_hplasma(int iw, int ih, int cl, uchar *ur, uchar *ug, uchar *ub)
{
  int i, j;
  float h;
  float fr, fg, fb;
  int r, g, b;
  long int os;
  int x, y;
  float x1, y1, x2, y2;
  int rd;
  int rs, rb;
  cdCanvas *rgb;
  char buf[200];

  sprintf(buf, "%dx%d %p %p %p", iw, ih, ur, ug, ub);
  rgb = cdCreateCanvas(CD_IMAGERGB, buf);

  /* desenha o plasma */
  os = 0;
  for (i = 0; i < ih; i++) {
    for (j = 0; j < iw; j++) {
      x = iw/2 - j; y = ih/2 - i;
      rd = sq(x) + sq(y);
      rb = sq(iw/2); rs = sq(iw/2 - cl);
      if ((rd < rb) && (rd > rs)) {;
        h = (float) (atan2(i - ih/2, j - iw/2) * pi_180);
        hls_hls2rgb(h, 0.5f, 1.0f, &fr, &fg, &fb);
        r = (int) (fr * 255.0f);
        g = (int) (fg * 255.0f);
        b = (int) (fb * 255.0f);
        ur[os + j] = touchar(r);
        ug[os + j] = touchar(g);
        ub[os + j] = touchar(b);
      } else {
        ur[os + j] = shade_r;
        ug[os + j] = shade_g;
        ub[os + j] = shade_b;
      }
    }
    os += iw;
  }

  /* desenha marcaccoes de 60 em 60 */
  cdCanvasForeground(rgb, cdEncodeColor(shade_dr, shade_dg, shade_db));
  x1 = 0.0f; y1 = ih/2.0f; x2 = 6.0f; y2 = ih/2.0f;
  cdCanvasLine(rgb, (int) x1, (int) y1, (int) x2, (int) y2);
  rot(&x1, &y1, &x2, &y2, ih);
  cdCanvasForeground(rgb, cdEncodeColor(shade_lr, shade_lg, shade_lb));
  cdCanvasLine(rgb, (int) x1, (int) y1, (int) x2, (int) y2);
  rot(&x1, &y1, &x2, &y2, ih);
  cdCanvasForeground(rgb, cdEncodeColor(shade_dr, shade_dg, shade_db));
  cdCanvasLine(rgb, (int) x1, (int) y1, (int) x2, (int) y2);
  rot(&x1, &y1, &x2, &y2, ih);
  cdCanvasForeground(rgb, cdEncodeColor(shade_lr, shade_lg, shade_lb));
  cdCanvasLine(rgb, (int) x1, (int) y1, (int) x2, (int) y2);
  rot(&x1, &y1, &x2, &y2, ih);
  cdCanvasForeground(rgb, cdEncodeColor(shade_dr, shade_dg, shade_db));
  cdCanvasLine(rgb, (int) x1, (int) y1, (int) x2, (int) y2);
  rot(&x1, &y1, &x2, &y2, ih);
  cdCanvasLine(rgb, (int) x1, (int) y1, (int) x2, (int) y2);

  /* desenha a borda */
  cdCanvasForeground(rgb, cdEncodeColor(shade_dr, shade_dg, shade_db));
  cdCanvasArc(rgb, iw/2, iw/2, iw, iw, 45.0, 225.0);
  cdCanvasForeground(rgb, cdEncodeColor(shade_lr, shade_lg, shade_lb));
  cdCanvasArc(rgb, iw/2, iw/2, iw, iw, 225.0, 45.0);

  cdCanvasForeground(rgb, cdEncodeColor(shade_lr, shade_lg, shade_lb));
  cdCanvasArc(rgb, iw/2, iw/2, iw-2*cl, iw-2*cl, 45.0, 225.0);
  cdCanvasForeground(rgb, cdEncodeColor(shade_dr, shade_dg, shade_db));
  cdCanvasArc(rgb, iw/2, iw/2, iw-2*cl, iw-2*cl, 225.0, 45.0);

  cdKillCanvas(rgb);
}