diff options
Diffstat (limited to 'cd/test/cdtest/drivers.c')
| -rwxr-xr-x | cd/test/cdtest/drivers.c | 53 | 
1 files changed, 51 insertions, 2 deletions
| diff --git a/cd/test/cdtest/drivers.c b/cd/test/cdtest/drivers.c index 93918d5..dd23331 100755 --- a/cd/test/cdtest/drivers.c +++ b/cd/test/cdtest/drivers.c @@ -32,6 +32,8 @@ extern tCTC ctgc;  #define DXF  #define DGN  #define PDF +#define CDDBG +#define SVG  static int LoadCanvas(char* ctx_name, cdContext* ctx, char *filename)  { @@ -69,7 +71,7 @@ static int SaveCanvas(char* ctx_name, cdContext* ctx, char *data)    canvas = cdCreateCanvas(ctx, data);    if (!canvas)    { -    IupMessage("Error!", "Can not create canvas."); +    IupMessagef("Error!", "Could not create canvas of driver %s.", ctx_name);      return IUP_DEFAULT;    } @@ -196,6 +198,27 @@ static int fEPS(void)  }  #endif +/*-------------------------------------------------------------------------*/ +/* Copia o conteudo do canvas para um arquivo SVG.                  */ +/*-------------------------------------------------------------------------*/ +#ifdef SVG +#include <cdsvg.h> + +static int fSVG(void) +{ +  char filename[1024]="*.svg"; +  char data[1024]; + +  if (IupGetFile(filename)>=0)  +  {  +    sprintf(data, "%s -s%d", filename, (int)(ctgc.res * 25.4)); +    return SaveCanvas("CD_SVG", CD_SVG, data); +  } + +  return IUP_DEFAULT; +} +#endif +  #ifdef PDF  #include <cdpdf.h> @@ -327,6 +350,26 @@ static int fPlayMF(void)  }  #endif +#ifdef CDDBG +#include <cddebug.h> +/*-------------------------------------------------------------------------*/ +/* Copia o conteudo do canvas para um arquivo metafile do CD.              */ +/*-------------------------------------------------------------------------*/ +static int fDebug(void) +{ +  char filename[1024]="*.mf"; +  char data[1000]; + +  if (IupGetFile(filename)>=0)  +  {  +    sprintf(data, "%s %gx%g %g", filename, ((double)ctgc.w)/ctgc.res, ((double)ctgc.h)/ctgc.res, ctgc.res); +    return SaveCanvas("CD_DEBUG", CD_DEBUG, data); +  } + +  return IUP_DEFAULT; +} +#endif +  /*-------------------------------------------------------------------------*/  /* Copia o conteudo do canvas para um arquivo WMF.                         */  /*-------------------------------------------------------------------------*/ @@ -389,7 +432,6 @@ static int fPrint(void)  {    char *data = "CDTEST.PRN -d";    return SaveCanvas("CD_PRINTER", CD_PRINTER, data); -  return IUP_DEFAULT;  }  #endif @@ -408,6 +450,10 @@ void DriversInit(void)    IupSetFunction("cmdPS", (Icallback) fPS);    IupSetFunction("cmdEPS", (Icallback) fEPS);  #endif +#ifdef SVG +  IupSetAttribute(IupGetHandle("itSVG"), IUP_ACTIVE, IUP_YES); +  IupSetFunction("cmdSVG", (Icallback) fSVG); +#endif  #ifdef PDF    IupSetAttribute(IupGetHandle("itPDF"), IUP_ACTIVE, IUP_YES);    IupSetFunction("cmdPDF", (Icallback) fPDF); @@ -432,6 +478,9 @@ void DriversInit(void)    IupSetAttribute(IupGetHandle("itDGN"), IUP_ACTIVE, IUP_YES);    IupSetFunction("cmdDGN", (Icallback) fDGN);  #endif +#ifdef CDDBG +  IupSetFunction("cmdDebug", (Icallback) fDebug); +#endif  #ifdef CGM    IupSetAttribute(IupGetHandle("itCGMb"), IUP_ACTIVE, IUP_YES);    IupSetFunction("cmdCGMb", (Icallback) fCGMb); | 
