summaryrefslogtreecommitdiff
path: root/test/simple
diff options
context:
space:
mode:
Diffstat (limited to 'test/simple')
-rw-r--r--test/simple/.cvsignore21
-rw-r--r--test/simple/config.mak25
-rw-r--r--test/simple/gdiplustest.cpp116
-rw-r--r--test/simple/iupmain.c83
-rw-r--r--test/simple/makefile.linux18
-rw-r--r--test/simple/makefile.mingw320
-rw-r--r--test/simple/simple.bat3
-rw-r--r--test/simple/simple.c1312
-rw-r--r--test/simple/simple.dsp83
-rw-r--r--test/simple/simple.h54
-rw-r--r--test/simple/simple.led93
-rw-r--r--test/simple/simple.sln20
-rw-r--r--test/simple/simple.vcproj131
-rw-r--r--test/simple/simple_led.c125
-rw-r--r--test/simple/teste.cpp219
15 files changed, 2323 insertions, 0 deletions
diff --git a/test/simple/.cvsignore b/test/simple/.cvsignore
new file mode 100644
index 0000000..c29a181
--- /dev/null
+++ b/test/simple/.cvsignore
@@ -0,0 +1,21 @@
+*.emf
+*.mf
+*.cgm
+*.eps
+*.ps
+*.wmf
+*.pdf
+simple_debug.txt
+so_locations
+*.dep
+*.wdep
+*.loh
+.plan
+.project
+*.err
+Makefile
+*.make
+*.suo
+*.ncb
+*.opt
+*.user
diff --git a/test/simple/config.mak b/test/simple/config.mak
new file mode 100644
index 0000000..319568a
--- /dev/null
+++ b/test/simple/config.mak
@@ -0,0 +1,25 @@
+APPNAME = simple
+
+#SRC = simple.c simple_led.c iupmain.c
+SRC = teste.cpp
+
+#DBG = Yes
+USE_CD=Yes
+USE_IUP=Yes
+
+simple_led.c: simple.led
+ ledc -f simple_loadled -o simple_led.c simple.led
+
+USE_STATIC = Yes
+
+#IUP = ../../../iup
+#CD = ../..
+
+USE_IM = Yes
+
+#ifneq ($(findstring Win, $(TEC_SYSNAME)), )
+# LIBS = cdpdflib cdgdiplus gdiplus
+#else
+# SLIB = $(CD)/lib/$(TEC_UNAME)/libcdpdflib.a $(CD)/lib/$(TEC_UNAME)/libcdxrender.a
+# LIBS = Xrender Xft
+#endif
diff --git a/test/simple/gdiplustest.cpp b/test/simple/gdiplustest.cpp
new file mode 100644
index 0000000..af7b643
--- /dev/null
+++ b/test/simple/gdiplustest.cpp
@@ -0,0 +1,116 @@
+#include <windows.h>
+#include <gdiplus.h>
+using namespace Gdiplus;
+
+/* Visual C++ 7.1 + SP1
+ GDI+ 1.0 File Version 5.1.3102.2180
+*/
+
+void DrawLineMarks(Graphics* graphics, Pen* greenPen, int x, int y, int w, int h)
+{
+ graphics->DrawLine(greenPen, x+w-1, y-5, x+w-1, y+5); // end markers
+ graphics->DrawLine(greenPen, x-5, y+h-1, x+5, y+h-1);
+}
+
+void SimpleImageTest(HWND hWnd)
+{
+ int x, y;
+ Graphics* graphics = new Graphics(hWnd);
+ graphics->Clear(Color(255, 255, 255)); // white background
+
+ Bitmap image(16, 16, PixelFormat24bppRGB);
+ image.SetResolution(graphics->GetDpiX(), graphics->GetDpiX());
+
+ /* black pixel border */
+ for (y = 0; y < 16; y++)
+ image.SetPixel(0, y, Color(0, 0, 0));
+ for (y = 0; y < 16; y++)
+ image.SetPixel(15, y, Color(0, 0, 0));
+ for (x = 1; x < 15; x++)
+ image.SetPixel(x, 0, Color(0, 0, 0));
+ for (x = 1; x < 15; x++)
+ image.SetPixel(x, 15, Color(0, 0, 0));
+
+ /* light yellow contents */
+ for (y = 1; y < 15; y++)
+ for (x = 1; x < 15; x++)
+ image.SetPixel(x, y, Color(192, 192, 0));
+
+ Pen redPen(Color(255, 0, 0), 1);
+ redPen.SetDashStyle(DashStyleDash);
+ Pen greenPen(Color(0, 255, 0), 1);
+ greenPen.SetDashStyle(DashStyleDash);
+
+ // I add {} to avoid reusing some Rect in the next test
+
+ graphics->SetPixelOffsetMode(PixelOffsetModeHalf); // pixel center is (.5,.5) instead of (0, 0)
+
+ // NO zoom
+ {
+ RectF actualRect(10, 10, 16, 16);
+ graphics->DrawImage(&image, 10, 10);
+ graphics->DrawRectangle(&redPen, actualRect);
+ DrawLineMarks(graphics, &greenPen, 10, 10, 16, 16);
+ }
+
+ // zoom using Bilinear Interpolation
+ {
+ RectF zoomRect(50, 10, 160, 160);
+ graphics->SetInterpolationMode(InterpolationModeBilinear);
+ graphics->DrawImage(&image, zoomRect);
+ graphics->DrawRectangle(&redPen, zoomRect);
+ DrawLineMarks(graphics, &greenPen, 50, 10, 160, 160);
+ }
+
+ // zoom using Nearest Neighborhood
+ {
+ RectF zoomRect2(250, 10, 160, 160);
+ graphics->SetInterpolationMode(InterpolationModeNearestNeighbor);
+ graphics->DrawImage(&image, zoomRect2);
+ graphics->DrawRectangle(&redPen, zoomRect2);
+ DrawLineMarks(graphics, &greenPen, 250, 10, 160, 160);
+ }
+
+
+ // Using a source image size, smaller than actual
+
+
+ // NO zoom
+ {
+ RectF actualRect3(10, 200, 16, 16);
+ graphics->DrawImage(&image, actualRect3, 0, 0, 16-1, 16-1, UnitPixel, NULL, NULL);
+ graphics->DrawRectangle(&redPen, actualRect3);
+ DrawLineMarks(graphics, &greenPen, 10, 400, 16, 16);
+ }
+
+ // zoom using Bilinear Interpolation
+ {
+ RectF zoomRect6(50, 200, 160, 160);
+ graphics->SetInterpolationMode(InterpolationModeBilinear);
+ graphics->DrawImage(&image, zoomRect6, 0, 0, 16-1, 16-1, UnitPixel, NULL, NULL);
+ graphics->DrawRectangle(&redPen, zoomRect6);
+ DrawLineMarks(graphics, &greenPen, 50, 400, 160, 160);
+ }
+
+ // zoom using Nearest Neighborhood
+ {
+ RectF zoomRect7(250, 200, 160, 160);
+ graphics->SetInterpolationMode(InterpolationModeNearestNeighbor);
+ graphics->DrawImage(&image, zoomRect7, 0, 0, 16-1, 16-1, UnitPixel, NULL, NULL);
+ graphics->DrawRectangle(&redPen, zoomRect7);
+ DrawLineMarks(graphics, &greenPen, 250, 400, 160, 160);
+ }
+
+ delete graphics;
+}
+
+#include <iup.h>
+
+extern "C" char* winData;
+extern "C" void SimpleDrawTest(void);
+
+void SimpleDrawTest(void)
+{
+ HWND hWnd = (HWND)IupGetAttribute((Ihandle*)winData, "HWND");
+ SimpleImageTest(hWnd);
+}
diff --git a/test/simple/iupmain.c b/test/simple/iupmain.c
new file mode 100644
index 0000000..7db2672
--- /dev/null
+++ b/test/simple/iupmain.c
@@ -0,0 +1,83 @@
+
+#include <iup.h>
+#include <cd.h>
+
+#include "simple.h"
+
+int cmdExit(void)
+{
+ return IUP_CLOSE;
+}
+
+void simple_loadled (void);
+
+int main(void)
+{
+ IupOpen();
+
+ cdInitContextPlus();
+
+ simple_loadled();
+
+ IupSetAttribute(IupGetHandle("SimpleDialog"), "PLACEMENT", "MAXIMIZED");
+ IupShow(IupGetHandle("SimpleDialog"));
+
+ SimpleCreateCanvas((char*)IupGetHandle("SimpleCanvas"));
+
+ IupSetFunction("cmdExit", (Icallback) cmdExit);
+
+ IupSetFunction("SimplePlayClipboard", (Icallback) SimplePlayClipboard);
+ IupSetFunction("SimplePlayCGMText", (Icallback) SimplePlayCGMText);
+ IupSetFunction("SimplePlayCGMBin", (Icallback) SimplePlayCGMBin);
+ IupSetFunction("SimplePlayMetafile", (Icallback) SimplePlayMetafile);
+ IupSetFunction("SimplePlayWMF", (Icallback) SimplePlayWMF);
+ IupSetFunction("SimplePlayEMF", (Icallback) SimplePlayEMF);
+
+ IupSetFunction("SimpleDrawDebug", (Icallback) SimpleDrawDebug);
+ IupSetFunction("SimpleDrawWindow", (Icallback) SimpleDrawWindow);
+ IupSetFunction("SimpleDrawCGMText", (Icallback) SimpleDrawCGMText);
+ IupSetFunction("SimpleDrawCGMBin", (Icallback) SimpleDrawCGMBin);
+ IupSetFunction("SimpleDrawDXF", (Icallback) SimpleDrawDXF);
+ IupSetFunction("SimpleDrawDGN", (Icallback) SimpleDrawDGN);
+ IupSetFunction("SimpleDrawEMF", (Icallback) SimpleDrawEMF);
+ IupSetFunction("SimpleDrawMetafile", (Icallback) SimpleDrawMetafile);
+ IupSetFunction("SimpleDrawPDF", (Icallback) SimpleDrawPDF);
+ IupSetFunction("SimpleDrawPS", (Icallback) SimpleDrawPS);
+ IupSetFunction("SimpleDrawEPS", (Icallback) SimpleDrawEPS);
+ IupSetFunction("SimpleDrawWMF", (Icallback) SimpleDrawWMF);
+ IupSetFunction("SimpleDrawPrint", (Icallback) SimpleDrawPrint);
+ IupSetFunction("SimpleDrawPrintDialog", (Icallback) SimpleDrawPrintDialog);
+ IupSetFunction("SimpleDrawClipboardBitmap", (Icallback) SimpleDrawClipboardBitmap);
+ IupSetFunction("SimpleDrawClipboardMetafile", (Icallback) SimpleDrawClipboardMetafile);
+ IupSetFunction("SimpleDrawClipboardEMF", (Icallback) SimpleDrawClipboardEMF);
+ IupSetFunction("SimpleDrawImage", (Icallback) SimpleDrawImage);
+ IupSetFunction("SimpleDrawImageRGB", (Icallback) SimpleDrawImageRGB);
+ IupSetFunction("SimpleDrawSimulate", (Icallback) SimpleDrawSimulate);
+
+ IupSetFunction("SimpleNotXor", (Icallback) SimpleNotXor);
+ IupSetFunction("SimpleXor", (Icallback) SimpleXor);
+ IupSetFunction("SimpleReplace", (Icallback) SimpleReplace);
+ IupSetFunction("SimpleClippingOff", (Icallback) SimpleClippingOff);
+ IupSetFunction("SimpleClippingArea", (Icallback) SimpleClippingArea);
+ IupSetFunction("SimpleClippingPolygon", (Icallback) SimpleClippingPolygon);
+ IupSetFunction("SimpleClippingRegion", (Icallback) SimpleClippingRegion);
+ IupSetFunction("SimpleContextPlus", (Icallback) SimpleContextPlus);
+ IupSetFunction("SimpleTransform", (Icallback) SimpleTransform);
+
+ IupSetFunction("SimpleDrawAll", (Icallback) SimpleDrawAll);
+ IupSetFunction("SimpleDrawTextAlign", (Icallback) SimpleDrawTextAlign);
+ IupSetFunction("SimpleDrawTextFonts", (Icallback) SimpleDrawTextFonts);
+ IupSetFunction("SimpleDrawTest", (Icallback) SimpleDrawTest);
+
+ IupSetFunction("SimpleRepaint", (Icallback) SimpleDrawRepaint);
+
+ SimpleDrawWindow();
+
+ IupMainLoop();
+
+ SimpleKillCanvas();
+
+ IupClose();
+
+ return 1;
+}
diff --git a/test/simple/makefile.linux b/test/simple/makefile.linux
new file mode 100644
index 0000000..5d014e0
--- /dev/null
+++ b/test/simple/makefile.linux
@@ -0,0 +1,18 @@
+CC = gcc
+
+CFLAGS = -I../cd/include -I../iup/include -I/usr/X11R6/include
+
+LIBS = -L../cd/lib/Linux26 -L../iup/lib/Linux26 -L/usr/X11R6/lib \
+ -lcdiup -lcd -liup \
+ -lXm -lXpm -lXmu -lXt -lXext -lX11
+
+OBJS = simple.o iupmain.o
+
+simple.o: simple.c simple.h
+ $(CC) -o $@ -c simple.c $(CFLAGS)
+
+iupmain.o: iupmain.c simple.h
+ $(CC) -o $@ -c iupmain.c $(CFLAGS)
+
+simple: $(OBJS)
+ $(CC) -o $@ $(OBJS) $(LIBS)
diff --git a/test/simple/makefile.mingw3 b/test/simple/makefile.mingw3
new file mode 100644
index 0000000..cf735e8
--- /dev/null
+++ b/test/simple/makefile.mingw3
@@ -0,0 +1,20 @@
+CC = gcc
+
+CFLAGS = -I../cd/include -I../iup/include
+
+LIBS = -L../cd/lib/mingw3 -L../iup/lib/mingw3 \
+ -lcdiup -lcd -liup \
+ -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lole32 -lcomctl32
+
+OBJS = simple.o iupmain.o
+
+all: simple.exe
+
+simple.o: simple.c simple.h
+ $(CC) -o $@ -c simple.c $(CFLAGS)
+
+iupmain.o: iupmain.c simple.h
+ $(CC) -o $@ -c iupmain.c $(CFLAGS)
+
+simple.exe: $(OBJS)
+ $(CC) -o $@ $(OBJS) $(LIBS)
diff --git a/test/simple/simple.bat b/test/simple/simple.bat
new file mode 100644
index 0000000..fa8f118
--- /dev/null
+++ b/test/simple/simple.bat
@@ -0,0 +1,3 @@
+@echo off
+REM Script generated automatically by tecmake v3.13
+..\bin\Win32\simple.exe %*
diff --git a/test/simple/simple.c b/test/simple/simple.c
new file mode 100644
index 0000000..efdee2e
--- /dev/null
+++ b/test/simple/simple.c
@@ -0,0 +1,1312 @@
+/*
+
+ Simple Draw Application
+
+ Shows the same picture on several canvas. Used to quick test the CD library and
+ to demonstrate the use of CD library functions.
+
+ This module uses only the CD library, there is another module to initialize the Window and its menus.
+
+*/
+
+
+#include "cd.h"
+#include "cdcgm.h"
+#include "cddgn.h"
+#include "cddxf.h"
+#include "cdclipbd.h"
+#include "cdemf.h"
+#include "cdimage.h"
+#include "cdirgb.h"
+#include "cdmf.h"
+#include "cdprint.h"
+#include "cdps.h"
+#include "cdpdf.h"
+#include "cdwmf.h"
+#include "cdiup.h"
+#include "cddbuf.h"
+#include "cddebug.h"
+#include "wd.h"
+#include "cdgdiplus.h"
+
+#include "simple.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+#include <string.h>
+
+/* Global variables */
+
+cdCanvas *winCanvas = NULL; /* The window drawing canvas */
+char* winData = NULL;
+cdCanvas *dbCanvas = NULL; /* The double buffer canvas */
+cdCanvas *curCanvas = NULL; /* The current canvas */
+
+int clipping = CD_CLIPOFF; /* Clipping flag, same as the CD */
+int write_mode = CD_REPLACE; /* Write Mode flag, same as the CD */
+int gdpiplus = 0;
+int simple_draw = 0;
+int use_transform = 0;
+int simulate = 0;
+
+enum {DRAW_ALL, DRAW_TEXTFONTS, DRAW_TEXTALIGN, DRAW_TEST};
+
+#define STYLE_SIZE 10 /* A small pattern and stipple size */
+long pattern[STYLE_SIZE*STYLE_SIZE]; /* Pattern buffer */
+unsigned char stipple[STYLE_SIZE*STYLE_SIZE]; /* Stipple buffer */
+
+#define IMAGE_SIZE 100
+unsigned char red[IMAGE_SIZE*IMAGE_SIZE]; /* Red image buffer */
+unsigned char green[IMAGE_SIZE*IMAGE_SIZE]; /* Green image buffer */
+unsigned char blue[IMAGE_SIZE*IMAGE_SIZE]; /* Blue image buffer */
+unsigned char alpha[IMAGE_SIZE*IMAGE_SIZE]; /* Alpha image buffer */
+
+
+/* Prototype of the function that makes the drawing independent of canvas. */
+void SimpleDraw(void);
+
+void SimpleInitAlpha(int width, int height, unsigned char* _alpha)
+{
+ int c, l;
+ /* initialize the alpha image buffer with a degrade from transparent to opaque */
+ for (l = 0; l < height; l++)
+ for (c = 0; c < width; c++)
+ _alpha[l*width + c] = (unsigned char)((c*255)/(width-1));
+}
+
+void SimpleCreateCanvasWindow(void)
+{
+ /* creates the canvas based in an existing window */
+ if (gdpiplus) cdUseContextPlus(1);
+ winCanvas = cdCreateCanvas(CD_IUP, winData);
+ if (gdpiplus) cdUseContextPlus(0);
+ curCanvas = winCanvas;
+}
+
+void SimpleCreateCanvas(char* data)
+{
+ int c, l;
+
+ memset(pattern, 0xFF, STYLE_SIZE*STYLE_SIZE*4);
+
+ pattern[11] = CD_RED; /*------------*/
+ pattern[21] = CD_RED; /* 0123456789*/
+ pattern[31] = CD_RED; /* */
+ pattern[41] = CD_RED; /*9 WWWWWWWWWW*/
+ pattern[51] = CD_RED; /*8 WWWWGGGGGW*/
+ pattern[12] = CD_RED; /*7 WWWGGGGGBW*/
+ pattern[22] = CD_RED; /*6 WWGGGGGBBW*/
+ pattern[32] = CD_RED; /*5 WrrrrrBBBW*/
+ pattern[42] = CD_RED; /*4 WrrrrrBBBW*/
+ pattern[52] = CD_RED; /*3 WrrrrrBBWW*/
+ pattern[13] = CD_RED; /*2 WrrrrrBWWW*/
+ pattern[23] = CD_RED; /*1 WrrrrrWWWW*/
+ pattern[33] = CD_RED; /*0 WWWWWWWWWW*/
+ pattern[43] = CD_RED; /*------------*/
+ pattern[53] = CD_RED;
+ pattern[14] = CD_RED; pattern[15] = CD_RED;
+ pattern[24] = CD_RED; pattern[25] = CD_RED;
+ pattern[34] = CD_RED; pattern[35] = CD_RED;
+ pattern[44] = CD_RED; pattern[45] = CD_RED;
+ pattern[54] = CD_RED; pattern[55] = CD_RED;
+
+ pattern[26] = CD_BLUE; pattern[37] = CD_BLUE;
+ pattern[36] = CD_BLUE; pattern[47] = CD_BLUE;
+ pattern[46] = CD_BLUE; pattern[57] = CD_BLUE;
+ pattern[56] = CD_BLUE; pattern[67] = CD_BLUE;
+
+ pattern[48] = CD_BLUE; pattern[62] = CD_GREEN;
+ pattern[58] = CD_BLUE; pattern[63] = CD_GREEN;
+ pattern[68] = CD_BLUE; pattern[64] = CD_GREEN;
+ pattern[78] = CD_BLUE; pattern[65] = CD_GREEN;
+ pattern[66] = CD_GREEN;
+
+ pattern[73] = CD_GREEN; pattern[84] = CD_GREEN;
+ pattern[74] = CD_GREEN; pattern[85] = CD_GREEN;
+ pattern[75] = CD_GREEN; pattern[86] = CD_GREEN;
+ pattern[76] = CD_GREEN; pattern[87] = CD_GREEN;
+ pattern[77] = CD_GREEN; pattern[88] = CD_GREEN;
+
+ /* initialize the stipple buffer with cross pattern */
+ for (l = 0; l < STYLE_SIZE; l++)
+ for (c = 0; c < STYLE_SIZE; c++)
+ stipple[l*STYLE_SIZE + c] = (c % 4) == 0? 1: 0;
+
+ SimpleInitAlpha(IMAGE_SIZE, IMAGE_SIZE, alpha);
+
+ winData = data;
+ SimpleCreateCanvasWindow();
+ SimpleDrawWindow();
+}
+
+int SimpleTransform(void)
+{
+ use_transform = !use_transform;
+ SimpleDrawRepaint();
+ return 0;
+}
+
+int SimpleContextPlus(void)
+{
+ gdpiplus = !gdpiplus;
+ SimpleKillCanvas();
+ SimpleCreateCanvasWindow();
+ SimpleDrawRepaint();
+ return 0;
+}
+
+void PlayCanvasDriver(cdContext* ctx, char* StrData)
+{
+ int w, h;
+ cdActivate(curCanvas);
+ cdBackground(CD_WHITE);
+ cdClear();
+ cdGetCanvasSize(&w, &h, 0, 0);
+ cdPlay(ctx, 100, w-100, 100, h-100, StrData);
+// cdPlay(ctx, 0, 0, 0, 0, StrData);
+}
+
+int SimplePlayClipboard(void)
+{
+ PlayCanvasDriver(CD_CLIPBOARD, NULL);
+ return 0;
+}
+
+int SimplePlayCGMBin(void)
+{
+ PlayCanvasDriver(CD_CGM, "simple_b.cgm");
+ return 0;
+}
+
+int SimplePlayCGMText(void)
+{
+ PlayCanvasDriver(CD_CGM, "simple_t.cgm");
+ return 0;
+}
+
+int SimplePlayMetafile(void)
+{
+ PlayCanvasDriver(CD_METAFILE, "simple.mf");
+ return 0;
+}
+
+int SimplePlayWMF(void)
+{
+ PlayCanvasDriver(CD_WMF, "simple.wmf");
+ return 0;
+}
+
+int SimplePlayEMF(void)
+{
+ PlayCanvasDriver(CD_EMF, "simple.emf");
+ return 0;
+}
+
+int SimpleDrawRepaint(void)
+{
+ cdActivate(curCanvas);
+ SimpleDraw();
+ cdFlush();
+ return 0;
+}
+
+int SimpleDrawWindow(void)
+{
+ curCanvas = winCanvas;
+ return SimpleDrawRepaint();
+}
+
+void DrawCanvasDriver(cdContext* ctx, char* StrData)
+{
+ cdCanvas* tmpCanvas = cdCreateCanvas(ctx, StrData);
+ if (tmpCanvas == NULL) return;
+ cdActivate(tmpCanvas);
+ SimpleDraw();
+ cdKillCanvas(tmpCanvas);
+ cdActivate(curCanvas);
+}
+
+void DrawCanvasDriverSize(cdContext* ctx, char* name, int pixels)
+{
+ char StrData[100];
+ int w, h;
+ double w_mm, h_mm;
+ cdActivate(curCanvas);
+ cdGetCanvasSize(&w, &h, &w_mm, &h_mm);
+ if (pixels)
+ sprintf(StrData, "%s %dx%d", name, w, h);
+ else
+ sprintf(StrData, "%s %gx%g", name, w_mm, h_mm);
+ DrawCanvasDriver(ctx, StrData);
+}
+
+void DrawCanvasDriverSizeParam(cdContext* ctx, char* param)
+{
+ char StrData[100];
+ int w, h;
+ cdActivate(curCanvas);
+ cdGetCanvasSize(&w, &h, 0, 0);
+ sprintf(StrData, "%dx%d %s", w, h, param);
+ DrawCanvasDriver(ctx, StrData);
+}
+
+int SimpleDrawDebug(void)
+{
+ DrawCanvasDriverSize(CD_DEBUG, "simple_debug.txt", 0);
+ return 0;
+}
+
+int SimpleDrawCGMText(void)
+{
+ DrawCanvasDriverSize(CD_CGM, "simple_t.cgm - t", 0);
+ return 0;
+}
+
+int SimpleDrawCGMBin(void)
+{
+ DrawCanvasDriverSize(CD_CGM, "simple_b.cgm", 0);
+ return 0;
+}
+
+int SimpleDrawDXF(void)
+{
+ DrawCanvasDriverSize(CD_DXF, "simple.dxf", 0);
+ return 0;
+}
+
+int SimpleDrawDGN(void)
+{
+ DrawCanvasDriverSize(CD_DGN, "simple.dgn", 0);
+ return 0;
+}
+
+int SimpleDrawEMF(void)
+{
+ if (gdpiplus) cdUseContextPlus(1);
+ DrawCanvasDriverSize(CD_EMF, "simple.emf", 1);
+ if (gdpiplus) cdUseContextPlus(0);
+ return 0;
+}
+
+int SimpleDrawMetafile(void)
+{
+ DrawCanvasDriverSize(CD_METAFILE, "simple.mf", 0);
+ return 0;
+}
+
+int SimpleDrawPS(void)
+{
+ DrawCanvasDriver(CD_PS, "simple.ps");
+ return 0;
+}
+
+int SimpleDrawPDF(void)
+{
+// DrawCanvasDriver(CD_PDF, "simple.pdf");
+ return 0;
+}
+
+int SimpleDrawEPS(void)
+{
+ DrawCanvasDriver(CD_PS, "simple.eps -e");
+ return 0;
+}
+
+int SimpleDrawWMF(void)
+{
+ DrawCanvasDriverSize(CD_WMF, "simple.wmf", 1);
+ return 0;
+}
+
+int SimpleDrawPrint(void)
+{
+ if (gdpiplus) cdUseContextPlus(1);
+ DrawCanvasDriver(CD_PRINTER, "simple print");
+ if (gdpiplus) cdUseContextPlus(0);
+ return 0;
+}
+
+int SimpleDrawPrintDialog(void)
+{
+ if (gdpiplus) cdUseContextPlus(1);
+ DrawCanvasDriver(CD_PRINTER, "simple -d");
+ if (gdpiplus) cdUseContextPlus(0);
+ return 0;
+}
+
+int SimpleDrawClipboardBitmap(void)
+{
+ if (gdpiplus) cdUseContextPlus(1);
+ DrawCanvasDriverSizeParam(CD_CLIPBOARD, "-b");
+ if (gdpiplus) cdUseContextPlus(0);
+ return 0;
+}
+
+int SimpleDrawClipboardMetafile(void)
+{
+ if (gdpiplus) cdUseContextPlus(1);
+ DrawCanvasDriverSizeParam(CD_CLIPBOARD, "-m");
+ if (gdpiplus) cdUseContextPlus(0);
+ return 0;
+}
+
+int SimpleDrawClipboardEMF(void)
+{
+ if (gdpiplus) cdUseContextPlus(1);
+ DrawCanvasDriverSizeParam(CD_CLIPBOARD, "");
+ if (gdpiplus) cdUseContextPlus(0);
+ return 0;
+}
+
+int SimpleReplace(void)
+{
+ write_mode = CD_REPLACE;
+ cdActivate(curCanvas);
+ SimpleDrawAll();
+ return 0;
+}
+
+int SimpleXor(void)
+{
+ write_mode = CD_XOR;
+ cdActivate(curCanvas);
+ SimpleDrawAll();
+ return 0;
+}
+
+int SimpleNotXor(void)
+{
+ write_mode = CD_NOT_XOR;
+ cdActivate(curCanvas);
+ SimpleDrawAll();
+ return 0;
+}
+
+int SimpleClippingOff(void)
+{
+ clipping = CD_CLIPOFF;
+ cdActivate(curCanvas);
+ SimpleDrawAll();
+ return 0;
+}
+
+int SimpleClippingArea(void)
+{
+ clipping = CD_CLIPAREA;
+ cdActivate(curCanvas);
+ SimpleDrawAll();
+ return 0;
+}
+
+int SimpleClippingPolygon(void)
+{
+ clipping = CD_CLIPPOLYGON;
+ cdActivate(curCanvas);
+ SimpleDrawAll();
+ return 0;
+}
+
+int SimpleClippingRegion(void)
+{
+ clipping = CD_CLIPREGION;
+ cdActivate(curCanvas);
+ SimpleDrawAll();
+ return 0;
+}
+
+void* CreateImageRGBA(int w, int h)
+{
+ void* myImage;
+ unsigned char * _alpha = malloc(w * h);
+ SimpleInitAlpha(w, h, _alpha);
+ cdSetAttribute("IMAGEALPHA", (char*)_alpha);
+ cdSetAttribute("IMAGEFORMAT", "32"); // afetara´ o proximo cdCreateImage
+ myImage = cdCreateImage(w, h);
+ cdSetAttribute("IMAGEFORMAT", NULL); // remove o atributo para nao afetar outros cdCreateImage
+ return myImage;
+}
+
+int SimpleDrawImage(void)
+{
+ if (dbCanvas) cdKillCanvas(dbCanvas);
+
+ if (gdpiplus) cdUseContextPlus(1);
+ dbCanvas = cdCreateCanvas(CD_DBUFFER, winCanvas);
+ if (gdpiplus) cdUseContextPlus(0);
+
+ curCanvas = dbCanvas;
+ SimpleDrawRepaint();
+
+ return 0;
+}
+
+int SimpleDrawImageRGB(void)
+{
+ if (dbCanvas) cdKillCanvas(dbCanvas);
+
+ if (gdpiplus) cdUseContextPlus(1);
+ dbCanvas = cdCreateCanvas(CD_DBUFFERRGB, winCanvas);
+ if (gdpiplus) cdUseContextPlus(0);
+
+ curCanvas = dbCanvas;
+ SimpleDrawRepaint();
+
+ return 0;
+}
+
+int SimpleDrawSimulate(void)
+{
+ cdActivate(curCanvas);
+
+ simulate = !simulate;
+
+ if (simulate)
+ cdSimulate(CD_SIM_ALL);
+ else
+ cdSimulate(CD_SIM_NONE);
+
+ SimpleDrawRepaint();
+
+ return 0;
+}
+
+void SimpleKillCanvas(void)
+{
+ if (dbCanvas)
+ {
+ cdKillCanvas(dbCanvas);
+ dbCanvas = NULL;
+ }
+ if (winCanvas)
+ {
+ cdKillCanvas(winCanvas);
+ winCanvas = NULL;
+ }
+}
+
+void SimpleDraw(void)
+{
+ if (simple_draw == DRAW_TEXTFONTS)
+ SimpleDrawTextFonts();
+ else if (simple_draw == DRAW_TEXTALIGN)
+ SimpleDrawTextAlign();
+ else if (simple_draw == DRAW_TEST)
+ SimpleDrawTest();
+ else
+ SimpleDrawAll();
+}
+
+int SimpleDrawAll(void)
+{
+ int w, h;
+ cdGetCanvasSize(&w, &h, 0, 0);
+
+ simple_draw = DRAW_ALL;
+
+ wdViewport(0,w-1,0,h-1);
+ if (w>h)
+ wdWindow(0,(double)w/(double)h,0,1);
+ else
+ wdWindow(0,1,0,(double)h/(double)w);
+
+ /* Clear the background to be white */
+// cdBackground(CD_WHITE);
+ cdBackground(CD_GREEN);
+ cdClear();
+
+ cdLineWidth(3);
+ cdForeground(cdEncodeAlpha(CD_DARK_MAGENTA, 128));
+ cdRect(100, 200, 100, 200);
+
+ cdBegin(CD_OPEN_LINES);
+ cdVertex(300, 250);
+ cdVertex(320, 270);
+ cdVertex(350, 260);
+ cdVertex(340, 200);
+ cdVertex(310, 210);
+ cdEnd();
+
+ cdInteriorStyle(CD_SOLID);
+
+ cdForeground(CD_RED);
+ cdLineWidth(3);
+ {
+ int dashes[] = {20, 15, 5, 5};
+ cdLineStyleDashes(dashes, 4);
+ }
+ cdLineStyle(CD_CUSTOM);
+ cdLine(0, 0, w-1, h-1);
+
+ cdForeground(CD_BLUE);
+ cdLineWidth(10);
+ cdLineStyle(CD_DOTTED);
+ //cdLine(0, 0, 500, 500);
+// wdLine(0, 1, 1, 0);
+ cdLine(0, h-1, w-1, 0);
+
+ switch(clipping)
+ {
+ case CD_CLIPOFF:
+ cdClip(CD_CLIPOFF);
+ break;
+ case CD_CLIPAREA:
+ /* Defines the clipping area equals the canvas area minus a 100 pixels margin. */
+ cdClipArea(100, w - 100, 100, h - 100);
+ cdClip(CD_CLIPAREA);
+ break;
+ case CD_CLIPPOLYGON:
+ cdBegin(CD_CLIP);
+ cdVertex(100, 100);
+ cdVertex(w - 100, 100);
+ cdVertex(w / 2, h - 100);
+ cdEnd();
+ cdClip(CD_CLIPPOLYGON);
+ break;
+ case CD_CLIPREGION:
+ cdTextAlignment(CD_CENTER);
+ cdFont(CD_TIMES_ROMAN, CD_BOLD, 50);
+
+ cdBegin(CD_REGION);
+ cdRegionCombineMode(CD_UNION);
+ cdBox(100, 200, 100, 200);
+ cdSector(w/2-50, h/2+50, 150, 150, 0, 360);
+ cdSector(w/2-50, h/2-50, 150, 150, 0, 360);
+ cdSector(w/2+50, h/2+50, 150, 150, 0, 360);
+ cdSector(w/2+50, h/2-50, 150, 150, 0, 360);
+ cdRegionCombineMode(CD_DIFFERENCE);
+ cdText(w/2, h/2, "TEXT");
+ cdEnd();
+// cdOffsetRegion(-50, 50);
+ cdClip(CD_CLIPREGION);
+
+ cdForeground(CD_DARK_RED);
+ cdBox(0,w,0,h);
+ break;
+ }
+
+ switch(write_mode)
+ {
+ case CD_REPLACE:
+ cdWriteMode(CD_REPLACE);
+ break;
+ case CD_XOR:
+ cdWriteMode(CD_XOR);
+ break;
+ case CD_NOT_XOR:
+ cdWriteMode(CD_NOT_XOR);
+ break;
+ }
+
+ if (use_transform)
+ {
+ cdCanvasTransform(cdActiveCanvas(), NULL);
+ cdCanvasTransformTranslate(cdActiveCanvas(), w/2, h/2);
+ cdCanvasTransformRotate(cdActiveCanvas(), 30);
+ cdCanvasTransformScale(cdActiveCanvas(), 0.5, 0.5);
+ cdCanvasTransformTranslate(cdActiveCanvas(), -w/2, -h/2);
+ }
+
+// cdSetfAttribute("ROTATE", "15 %d %d", w/2, h/2);
+
+ cdLineStyle(CD_CONTINUOUS);
+ cdLineWidth(1);
+ cdBackOpacity(CD_TRANSPARENT);
+
+ cdForeground(CD_MAGENTA);
+ cdSector(w-100, 100, 100, 100, 50, 180);
+ cdForeground(CD_RED);
+ cdArc(100, 100, 100, 100, 50, 180);
+
+ cdForeground(CD_YELLOW);
+ cdBox(w/2 - 100, w/2 + 100, h/2 - 100, h/2 + 100);
+
+ cdTextAlignment(CD_CENTER);
+ cdTextOrientation(70);
+ cdFont(CD_TIMES_ROMAN, CD_BOLD, 24);
+
+ {
+ int rect[8];
+ cdTextBounds(w/2, h/2, "cdMin Draw (çãí)", rect);
+ cdForeground(CD_RED);
+ cdBegin(CD_CLOSED_LINES);
+ cdVertex(rect[0], rect[1]);
+ cdVertex(rect[2], rect[3]);
+ cdVertex(rect[4], rect[5]);
+ cdVertex(rect[6], rect[7]);
+ cdEnd();
+ }
+ cdForeground(CD_BLUE);
+ cdText(w/2, h/2, "cdMin Draw (çãí)");
+ cdTextOrientation(0);
+
+ wdBox(0.20, 0.30, 0.40, 0.50);
+ cdForeground(CD_RED);
+ wdLine(0.20, 0.40, 0.30, 0.50);
+
+// wdVectorTextDirection(0, 0, 1, 1);
+ wdVectorCharSize(0.07);
+
+// wdVectorText(0.1, 0.4, "ñç áéíóú àèìòù âêîôû äëïöü");
+// wdVectorText(0.1, 0.2, "ÑÇ ÁÉÍÓÚ ÀÈÌÒÙ ÂÊÎÔÛ ÄËÏÖÜ");
+ //{
+ // int i;
+ // char t[2];
+ // char s[10];
+ // int x = 20;
+ // int y = 0;
+ // t[1] = 0;
+ // for (i = 0; i < 256; i++)
+ // {
+ // int dx = 90;
+ // t[0] = (char)i;
+ // sprintf(s, "%d", i);
+ // cdText(x, y, s);
+ // cdText(x+dx, y, t);
+ // cdVectorText(x+2*dx, y, t);
+ //
+ // x += 3*dx + 2*dx/3;
+ // if ((i+1) % 7 == 0)
+ // {
+ // x = 20;
+ // y += 90;
+ // }
+
+ // }
+ //}
+
+ {
+ double rect[8];
+ cdForeground(CD_RED);
+ if (gdpiplus)
+ wdGetVectorTextBounds("WDj-Plus", 0.25, 0.35, rect);
+ else
+ wdGetVectorTextBounds("WDj", 0.25, 0.35, rect);
+ cdBegin(CD_CLOSED_LINES);
+ wdVertex(rect[0], rect[1]);
+ wdVertex(rect[2], rect[3]);
+ wdVertex(rect[4], rect[5]);
+ wdVertex(rect[6], rect[7]);
+ cdEnd();
+ }
+
+ cdPixel(10, h/2+0, CD_RED);
+ cdPixel(11, h/2+1, CD_GREEN);
+ cdPixel(12, h/2+2, CD_BLUE);
+
+ /* draws all the mark type possibilities */
+ cdForeground(CD_RED);
+ cdMarkSize(30);
+ cdMarkType(CD_PLUS);
+ cdMark(200, 200);
+ cdMarkType(CD_CIRCLE);
+ cdMark(w - 200, 200);
+ cdMarkType(CD_HOLLOW_CIRCLE);
+ cdMark(200, h - 200);
+ cdMarkType(CD_DIAMOND);
+ cdMark(w - 200, h - 200);
+
+ /* draws all the line style possibilities */
+ cdLineWidth(1);
+ cdLineStyle(CD_CONTINUOUS);
+ cdLine(0, 10, w, 10);
+ cdLineStyle(CD_DASHED);
+ cdLine(0, 20, w, 20);
+ cdLineStyle(CD_DASH_DOT);
+ cdLine(0, 30, w, 30);
+ cdLineStyle(CD_DASH_DOT_DOT);
+ cdLine(0, 40, w, 40);
+
+ /* draws all the hatch style possibilities */
+ cdHatch(CD_VERTICAL);
+ cdBox(0, 50, h - 60, h);
+ cdHatch(CD_FDIAGONAL);
+ cdBox(50, 100, h - 60, h);
+ cdHatch(CD_BDIAGONAL);
+ cdBox(100, 150, h - 60, h);
+ cdHatch(CD_CROSS);
+ cdBox(150, 200, h - 60, h);
+ cdHatch(CD_HORIZONTAL);
+ cdBox(200, 250, h - 60, h);
+ cdHatch(CD_DIAGCROSS);
+ cdBox(250, 300, h - 60, h);
+
+ /* closed polygon */
+ cdBegin(CD_CLOSED_LINES);
+ cdVertex(w/2, h - 100);
+ cdVertex(w/2 + 50, h - 150);
+ cdVertex(w/2, h - 200);
+ cdVertex(w/2 - 50, h - 150);
+ cdEnd();
+
+ /* hatch filled polygon */
+ cdHatch(CD_DIAGCROSS);
+ cdBegin(CD_FILL);
+ cdVertex(100, h/2);
+ cdVertex(150, h/2 + 50);
+ cdVertex(200, h/2);
+ cdVertex(150, h/2 - 50);
+ cdEnd();
+
+ /* pattern filled polygon */
+ cdPattern(STYLE_SIZE, STYLE_SIZE, pattern);
+ cdBegin(CD_FILL);
+ cdVertex(w - 100, h/2);
+ cdVertex(w - 150, h/2 + 50);
+ cdVertex(w - 200, h/2);
+ cdVertex(w - 150, h/2 - 50);
+ cdEnd();
+
+ /* stipple filled polygon */
+ cdStipple(STYLE_SIZE, STYLE_SIZE, stipple);
+ cdBegin(CD_FILL);
+ cdVertex(w/2, 100);
+ cdVertex(w/2 + 50, 150);
+ cdVertex(w/2, 200);
+ cdVertex(w/2 - 50, 150);
+ cdEnd();
+
+ cdBegin(CD_BEZIER);
+ cdVertex(100, 100);
+ cdVertex(150, 200);
+ cdVertex(180, 250);
+ cdVertex(180, 200);
+ cdVertex(180, 150);
+ cdVertex(150, 100);
+ cdVertex(300, 100);
+ cdEnd();
+
+ cdLineWidth(2);
+ cdLineStyle(CD_CONTINUOUS);
+ if (gdpiplus)
+ wdVectorText(0.25, 0.35, "WDj-Plus");
+ else
+ wdVectorText(0.25, 0.35, "WDj");
+
+ /* always clear the image buffer contents */
+//#define IMAGE_SIZE 16
+ memset(red, 0xFF, IMAGE_SIZE*IMAGE_SIZE/2);
+ memset(green, 0x5F, IMAGE_SIZE*IMAGE_SIZE/2);
+ memset(blue, 0x5F, IMAGE_SIZE*IMAGE_SIZE/2);
+ memset(red+IMAGE_SIZE*IMAGE_SIZE/2, 0x5F, IMAGE_SIZE*IMAGE_SIZE/2);
+ memset(green+IMAGE_SIZE*IMAGE_SIZE/2, 0x8F, IMAGE_SIZE*IMAGE_SIZE/2);
+ memset(blue+IMAGE_SIZE*IMAGE_SIZE/2, 0x5F, IMAGE_SIZE*IMAGE_SIZE/2);
+ memset(red+IMAGE_SIZE*(IMAGE_SIZE-1), 0, IMAGE_SIZE);
+ memset(green+IMAGE_SIZE*(IMAGE_SIZE-1), 0, IMAGE_SIZE);
+ memset(blue+IMAGE_SIZE*(IMAGE_SIZE-1), 0, IMAGE_SIZE);
+ memset(red, 0, IMAGE_SIZE);
+ memset(green, 0, IMAGE_SIZE);
+ memset(blue, 0, IMAGE_SIZE);
+ {
+ int i, offset;
+ for (i = 0; i < IMAGE_SIZE; i++)
+ {
+ offset = i*IMAGE_SIZE;
+ red[offset] = 0;
+ green[offset] = 0;
+ blue[offset] = 0;
+ red[offset+IMAGE_SIZE-1] = 0;
+ green[offset+IMAGE_SIZE-1] = 0;
+ blue[offset+IMAGE_SIZE-1] = 0;
+ }
+ }
+
+ //cdSetAttribute("ANTIALIAS", "0");
+// cdGetImageRGB(red, green, blue, w/2 - 50, h/2-50, 100, 100);
+// cdPutImageRectRGB(14, 13, red, green, blue, -20, -15, 649, 603, 0, 13, 0, 12);
+// cdPutImageRectRGB(16, 16, red, green, blue, 10, 10, 608, 608, 5, 10, 5, 10);
+// cdPutImageRectRGB(16, 16, red, green, blue, 10, 10, 64, 64, 5, 10, 5, 10);
+
+// cdPutImageRGB(IMAGE_SIZE, IMAGE_SIZE, red, green, blue, 100, h - 200, IMAGE_SIZE, IMAGE_SIZE);
+// cdPutImageRGBA(IMAGE_SIZE, IMAGE_SIZE, red, green, blue, alpha, 100, h - 200, IMAGE_SIZE, IMAGE_SIZE);
+ cdPutImageRGB(IMAGE_SIZE, IMAGE_SIZE, red, green, blue, w - 400, h - 310, 3*IMAGE_SIZE, 3*IMAGE_SIZE);
+// cdPutImageRGBA(IMAGE_SIZE, IMAGE_SIZE, red, green, blue, alpha, w - 400, h - 310, 3*IMAGE_SIZE, 3*IMAGE_SIZE);
+
+ cdSetAttribute("ROTATE", NULL);
+ if (use_transform)
+ cdCanvasTransform(cdActiveCanvas(), NULL);
+ cdClip(CD_CLIPOFF);
+ cdFlush();
+
+ return 0;
+}
+
+void DrawTextBox(int x, int y, char* text)
+{
+ int xmin, xmax, ymin, ymax;
+
+ cdLineWidth(1);
+ cdLineStyle(CD_CONTINUOUS);
+
+ /* bounding box */
+ cdTextBox(x, y, text, &xmin, &xmax, &ymin, &ymax);
+ cdForeground(CD_GREEN);
+ cdRect(xmin, xmax, ymin, ymax);
+
+ /* baseline */
+ cdForeground(CD_RED);
+ cdLine(xmin, y, xmax, y);
+
+ /* reference point */
+ cdForeground(CD_BLUE);
+ cdMarkType(CD_PLUS);
+ cdMarkSize(30);
+ cdMark(x, y);
+
+ cdForeground(CD_BLACK);
+ cdText(x, y, text);
+}
+
+int SimpleDrawTextAlign(void)
+{
+ int w, h, i, xoff, yoff;
+
+ int text_aligment[] = {
+ CD_NORTH,
+ CD_SOUTH,
+ CD_EAST,
+ CD_WEST,
+ CD_NORTH_EAST,
+ CD_NORTH_WEST,
+ CD_SOUTH_EAST,
+ CD_SOUTH_WEST,
+ CD_CENTER,
+ CD_BASE_CENTER,
+ CD_BASE_RIGHT,
+ CD_BASE_LEFT
+ };
+
+ char* text_aligment_str[] = {
+ "jNorth (Ãy)",
+ "jSouth (Ãy)",
+ "jEast (Ãy)",
+ "jWest (Ãy)",
+ "jNorth East (Ãy)",
+ "jNorth West (Ãy)",
+ "jSouth East (Ãy)",
+ "jSouth West (Ãy)",
+ "jCenter (Ãy)",
+ "jBase Center (Ãy)",
+ "jBase Right (Ãy)",
+ "jBase Left (Ãy)"
+ };
+
+ cdGetCanvasSize(&w, &h, 0, 0);
+
+ cdBackground(CD_WHITE);
+ cdClear();
+
+ simple_draw = DRAW_TEXTALIGN;
+
+// cdTextOrientation(45);
+
+ xoff = w/4;
+ yoff = h/7;
+
+//cdFont(CD_TIMES_ROMAN, CD_PLAIN, 14);
+ cdFont(CD_HELVETICA, CD_PLAIN, 18);
+
+ for (i = 0; i < 12; i++)
+ {
+ cdTextAlignment(text_aligment[i]);
+ if (i < 6)
+ {
+ DrawTextBox(xoff, yoff*(i+1), text_aligment_str[i]);
+ }
+ else
+ {
+ DrawTextBox(3*xoff, yoff*(i-5), text_aligment_str[i]);
+ }
+ }
+ cdFlush();
+ return 0;
+}
+
+void DrawTextFont(int font, int size, int xoff, int yoff, char* text)
+{
+ cdFont(font, CD_PLAIN, size);
+ DrawTextBox(xoff, yoff, text);
+
+ cdFont(font, CD_BOLD, size);
+ DrawTextBox(2*xoff, yoff, text);
+
+ cdFont(font, CD_ITALIC, size);
+ DrawTextBox(3*xoff, yoff, text);
+
+ cdFont(font, CD_BOLD_ITALIC, size);
+ DrawTextBox(4*xoff, yoff, text);
+}
+
+int SimpleDrawTextFonts(void)
+{
+ int xoff, yoff, size;
+
+ cdBackground(CD_WHITE);
+ cdClear();
+
+ simple_draw = DRAW_TEXTFONTS;
+
+ xoff = 470;
+ yoff = 150;
+ size = -30;
+
+ cdTextAlignment(CD_CENTER);
+
+// DrawTextFont(CD_COURIER, size, xoff, yoff, "Courier");
+
+// DrawTextFont(CD_TIMES_ROMAN, size, xoff, 2*yoff, "Times Roman");
+
+// DrawTextFont(CD_HELVETICA, size, xoff, 3*yoff, "Helvetica");
+
+// DrawTextFont(CD_SYSTEM, size, xoff, 4*yoff, "System");
+
+ {
+// static char native[50] = "Tecmedia, -60";
+// static char native[50] = "-*-helvetica-medium-r-*-*-8-*";
+// static char native[50] = "Edwardian Script ITC, 24";
+// cdSetAttribute("ADDFONTMAP","Edwardian Script ITC=ITCEDSCR");
+
+// char native[50] = "Book Antiqua, 24";
+// cdSetAttribute("ADDFONTMAP", "Book Antiqua=BKANT");
+
+// cdNativeFont("-d");
+// cdNativeFont(native);
+// DrawTextBox(xoff, yoff, native);
+// DrawTextBox(xoff, yoff, "The quick brown fox.");
+ }
+
+ //cdNativeFont("Tecmedia, 36");
+
+ cdSetAttribute("ADDFONTMAP", "WingDings=WingDing");
+ cdNativeFont("WingDings, 36");
+
+ cdText(500, 50, "X");
+ //cdText(500, 50, "abcdefghijklmnopqrstuvwxyz");
+ //cdText(500, 150, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+ //cdText(500, 250, "1234567890");
+ //cdText(500, 350, "'\"!@#$%¨&*()_+-=[]^/;.,");
+
+ //cdFont(CD_COURIER, 0, 22);
+ //cdText(10, 60, "abcdefghijklmnopqrstuvwxyz");
+ //cdText(10, 160, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+ //cdText(10, 260, "1234567890");
+ //cdText(500, 360, "'\"!@#$%¨&*()_+-=[]^/;.,");
+
+ cdFlush();
+ return 0;
+}
+
+void SimpleDrawTest(void)
+//void SimpleDrawMainTest(void)
+{
+ long pattern[16]; /* 4x4 pattern */
+ int w, h;
+ int xmin, xmax, ymin, ymax;
+
+ simple_draw = DRAW_TEST;
+
+/* notice that if we are not using world coordinates
+ it is harder to position all the objetcs we want. */
+ cdGetCanvasSize(&w, &h, 0, 0);
+
+ cdBackground(CD_WHITE);
+ cdClear();
+
+/* pattern initialization */
+ pattern[0] = CD_RED; pattern[1] = CD_RED; /* first line */
+ pattern[2] = CD_YELLOW; pattern[3] = CD_YELLOW;
+ pattern[4] = CD_RED; pattern[5] = CD_RED; /* second line */
+ pattern[6] = CD_YELLOW; pattern[7] = CD_YELLOW;
+ pattern[8] = CD_YELLOW; pattern[9] = CD_YELLOW; /* third line */
+ pattern[10] = CD_YELLOW; pattern[11] = CD_YELLOW;
+ pattern[12] = CD_YELLOW; pattern[13] = CD_YELLOW; /* fourth line */
+ pattern[14] = CD_YELLOW; pattern[15] = CD_YELLOW;
+
+/* set the line attributes */
+ cdLineWidth(4);
+ cdLineStyle(CD_CONTINUOUS);
+
+/* in the center draw a pattern pizza
+ with a slice mising */
+ cdPattern(4, 4, pattern);
+ cdSector(w/2, h/2, w/2, h/2, 45, 0);
+/* draws a dark red border */
+ cdForeground(CD_DARK_RED);
+ cdInteriorStyle(CD_HOLLOW);
+ cdSector(w/2, h/2, w/2, h/2, 45, 0);
+
+/* on the left a red hash diamond */
+/* notice the the default back opacity is transparent
+ and the pattern of the sector will still be visible
+ inside the hatch where the two objects intersect */
+ cdForeground(CD_RED);
+ cdHatch(CD_DIAGCROSS);
+ cdBegin(CD_FILL);
+ cdVertex(w/4, h/4);
+ cdVertex(w/2-w/8, h/2);
+ cdVertex(w/4, 3*h/4);
+ cdVertex(w/8, h/2);
+ cdEnd();
+
+/* draws a blue roof.*/
+ cdForeground(CD_BLUE);
+ cdLine(w/8, h/2, w/4, 3*h/4);
+ cdLine(w/4, 3*h/4, w/2-w/8, h/2);
+
+/* draws a dashed ribbon on the right
+ with a custom color */
+ cdForeground(cdEncodeColor(100, 25, 200));
+ cdLineStyle(CD_DASH_DOT);
+ cdBegin(CD_BEZIER);
+ cdVertex(3*w/4-20, h/2-50);
+ cdVertex(3*w/4+150, 3*h/4-50);
+ cdVertex(3*w/4-150, 3*h/4-50);
+ cdVertex(3*w/4+20, h/2-50);
+ cdEnd();
+
+ cdFont(CD_HELVETICA, CD_BOLD, 40);
+ cdTextAlignment(CD_CENTER);
+ cdText(w/2, h/4-50, "Canvas Draw");
+ cdTextBox(w/2, h/4-50, "Canvas Draw", &xmin, &xmax, &ymin, &ymax);
+ cdRect(xmin, xmax, ymin, ymax);
+ cdFlush();
+}
+
+void draw_wd(void)
+{
+ cdBackground(CD_WHITE);
+ cdClear();
+ cdLineStyle(CD_CONTINUOUS);
+ cdLineWidth(1);
+
+ wdVectorTextDirection(0, 0, 1, 1);
+
+ wdVectorCharSize(0.1);
+ wdVectorText(0.25, 0.35, "Vector Text");
+
+ {
+ double rect[8];
+ cdForeground(CD_RED);
+ wdGetVectorTextBounds("Vector Text", 0.25, 0.35, rect);
+ cdBegin(CD_CLOSED_LINES);
+ wdVertex(rect[0], rect[1]);
+ wdVertex(rect[2], rect[3]);
+ wdVertex(rect[4], rect[5]);
+ wdVertex(rect[6], rect[7]);
+ cdEnd();
+ }
+ cdFlush();
+}
+
+void SimpleDrawTestHardCopy(void)
+{
+ int w, h;
+ cdGetCanvasSize(&w, &h, 0, 0);
+
+ simple_draw = DRAW_ALL;
+
+ wdViewport(0,w-1,0,h-1);
+ if (w>h)
+ wdWindow(0,(double)w/(double)h,0,1);
+ else
+ wdWindow(0,1,0,(double)h/(double)w);
+
+ draw_wd();
+
+ wdHardcopy(CD_CLIPBOARD, "800x600", cdActiveCanvas(), draw_wd );
+ cdFlush();
+}
+
+void SimpleDrawTestImageRGB(void)
+{
+ 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);
+ cdFlush();
+}
+
+//void SimpleDrawTest(void)
+void SimpleDrawVectorText(void)
+{
+ simple_draw = DRAW_TEST;
+ cdBackground(CD_WHITE);
+ cdClear();
+ cdLineStyle(CD_CONTINUOUS);
+ cdLineWidth(1);
+
+// wdVectorText(0.1, 0.4, "ãõñç áéíóú àèìòù âêîôû äëïöü");
+// wdVectorText(0.1, 0.2, "ÃÕÑÇ ÁÉÍÓÚ ÀÈÌÒÙ ÂÊÎÔÛ ÄËÏÖÜ ");
+ cdVectorFont("../../etc/vectorfont26.txt"); /* original Simplex II */
+ {
+ int i;
+ char t[2];
+ char s[10];
+ int x = 10;
+ int y = 600;
+ t[1] = 0;
+ cdFont(CD_COURIER, CD_BOLD, 14);
+ cdVectorCharSize(25);
+ for (i = 128; i < 256; i++)
+ {
+ int dx = 30;
+ t[0] = (char)i;
+ sprintf(s, "%3d", i);
+ cdForeground(CD_DARK_RED);
+ cdText(x, y, s);
+// cdText(x+dx, y, t);
+ cdForeground(CD_BLACK);
+ cdVectorText(x+2*dx-10, y, t);
+
+ x += 3*dx;
+ if ((i+1) % 8 == 0)
+ {
+ x = 10;
+ y -= 30;
+ }
+ }
+ //cdFont(CD_TIMES_ROMAN, CD_PLAIN, 24);
+ //cdVectorCharSize(24);
+ // for (i = 192; i < 256; i++)
+ // {
+ // int dx = 92;
+ // t[0] = (char)i;
+ // sprintf(s, "%d", i);
+ // cdText(x, y, s);
+ // cdText(x+dx, y, t);
+ // cdVectorText(x+2*dx, y, t);
+ //
+ // x += 3*dx + 2*dx/3;
+ // if ((i+1) % 4 == 0)
+ // {
+ // x = 30;
+ // y += 52;
+ // }
+ // }
+ }
+ cdFlush();
+}
+
+typedef struct _point
+{
+ double x, y;
+} point;
+
+point* load_point_file(const char* file_name, int *count)
+{
+ float x, y;
+ point* point_list;
+ int max_count = 100, dummy;
+ FILE* file = fopen(file_name, "rb");
+ if (!file)
+ return NULL;
+
+ point_list = malloc(max_count*sizeof(point));
+
+ /* read header */
+ fscanf(file, "##### %d\n", &dummy);
+
+ *count = 0;
+ while (!feof(file))
+ {
+ if (fscanf(file, "( %g | %g )\n", &x, &y) == 2)
+ {
+ if (*count == max_count)
+ {
+ max_count += 100;
+ point_list = realloc(point_list, max_count*sizeof(point));
+ }
+
+ point_list[*count].x = x;
+ point_list[*count].y = y;
+
+ (*count)++;
+ }
+ }
+
+ fclose(file);
+
+ return point_list;
+}
+
+point square[4] = {
+ {100,100},
+ {200,100},
+ {200,200},
+ {100,200},
+};
+
+point corner[6] = {
+ {100,100},
+ {200,100},
+ {200,200},
+ {150,200},
+ {150,300},
+ {100,300},
+};
+
+//void SimpleDrawTest(void)
+void SimpleDrawPolygon(void)
+{
+ int count, i;
+ point* point_list;
+ char* file_name;
+
+ simple_draw = DRAW_TEST;
+ cdBackground(CD_WHITE);
+ cdClear();
+ cdLineStyle(CD_CONTINUOUS);
+ cdLineWidth(1);
+ cdInteriorStyle(CD_SOLID);
+
+// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\continentes_geom_id_78_polygon_1_440x512.txt";
+// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\continentes_geom_id_78_polygon_1_558x650.txt";
+// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_2.txt";
+ file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_6.txt";
+// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_15.txt";
+// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_34.txt";
+// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_37.txt";
+// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_53.txt";
+// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_59.txt";
+
+// point_list = square;
+// count = 4;
+// point_list = corner;
+// count = 6;
+
+ point_list = load_point_file(file_name, &count);
+ if (!point_list)
+ return;
+
+ cdForeground(CD_BLACK);
+ cdBegin(CD_CLOSED_LINES);
+ for (i=0; i<count; i++)
+ {
+ cdVertex((int)point_list[i].x, (int)point_list[i].y);
+ }
+ cdEnd();
+
+ cdForeground(CD_RED);
+ cdBegin(CD_FILL);
+ for (i=0; i<count; i++)
+ {
+ cdVertex((int)point_list[i].x, (int)point_list[i].y);
+ }
+ cdEnd();
+
+ cdFlush();
+
+ free(point_list);
+}
diff --git a/test/simple/simple.dsp b/test/simple/simple.dsp
new file mode 100644
index 0000000..c69b8df
--- /dev/null
+++ b/test/simple/simple.dsp
@@ -0,0 +1,83 @@
+# Microsoft Developer Studio Project File - Name="simple" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=simple - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "simple.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "simple.mak" CFG="simple - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "simple - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "simple - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "..\bin"
+# PROP BASE Intermediate_Dir "..\obj\simple"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\bin"
+# PROP Intermediate_Dir "..\obj\simple"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /I "..\..\include" /I "..\..\..\iup\include" /Z7 /W4 /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "__CD__" /D "simple" /D "_CRT_SECURE_NO_DEPRECATE" /D "_MBCS" /Fp".\..\obj\simple/simple.pch" /Fo".\..\obj\simple/" /Fd".\..\obj\simple/" /GZ /c /GX
+# ADD CPP /nologo /MT /I "..\..\include" /I "..\..\..\iup\include" /Z7 /W4 /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "__CD__" /D "simple" /D "_CRT_SECURE_NO_DEPRECATE" /D "_MBCS" /Fp".\..\obj\simple/simple.pch" /Fo".\..\obj\simple/" /Fd".\..\obj\simple/" /GZ /c /GX
+# ADD BASE MTL /nologo /tlb".\..\bin\simple.tlb" /win32
+# ADD MTL /nologo /tlb".\..\bin\simple.tlb" /win32
+# ADD BASE RSC /l 1046 /d "_DEBUG"
+# ADD RSC /l 1046 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cd.lib cdiup.lib iup.lib comctl32.lib cdgdiplus.lib gdiplus.lib cdpdflib.lib iupcontrols.lib /nologo /out:"..\bin\simple.exe" /incremental:yes /libpath:"..\..\lib" /libpath:"..\..\..\iup\lib" /debug /pdb:".\..\bin\simple.pdb" /pdbtype:sept /subsystem:windows /MACHINE:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cd.lib cdiup.lib iup.lib comctl32.lib cdgdiplus.lib gdiplus.lib cdpdflib.lib iupcontrols.lib /nologo /out:"..\bin\simple.exe" /incremental:yes /libpath:"..\..\lib" /libpath:"..\..\..\iup\lib" /debug /pdb:".\..\bin\simple.pdb" /pdbtype:sept /subsystem:windows /MACHINE:I386
+
+!ENDIF
+
+# Begin Target
+
+# Name "simple - Win32 Debug"
+# Begin Source File
+
+SOURCE=iupmain.c
+# End Source File
+# Begin Source File
+
+SOURCE=simple.c
+# End Source File
+# Begin Source File
+
+SOURCE=simple.h
+# End Source File
+# Begin Source File
+
+SOURCE=simple.led
+# End Source File
+# Begin Source File
+
+SOURCE=simple_led.c
+# End Source File
+# End Target
+# End Project
+
diff --git a/test/simple/simple.h b/test/simple/simple.h
new file mode 100644
index 0000000..123b31c
--- /dev/null
+++ b/test/simple/simple.h
@@ -0,0 +1,54 @@
+
+#ifndef __Simple_H
+#define __Simple_H
+
+#include <cd.h>
+
+void SimpleCreateCanvas(char* data);
+void SimpleKillCanvas(void);
+
+int SimplePlayClipboard(void);
+int SimplePlayCGMBin(void);
+int SimplePlayCGMText(void);
+int SimplePlayMetafile(void);
+int SimplePlayWMF(void);
+int SimplePlayEMF(void);
+
+int SimpleDrawDebug(void);
+int SimpleDrawWindow(void);
+int SimpleDrawCGMText(void);
+int SimpleDrawCGMBin(void);
+int SimpleDrawDXF(void);
+int SimpleDrawDGN(void);
+int SimpleDrawEMF(void);
+int SimpleDrawMetafile(void);
+int SimpleDrawPDF(void);
+int SimpleDrawPS(void);
+int SimpleDrawEPS(void);
+int SimpleDrawWMF(void);
+int SimpleDrawPrint(void);
+int SimpleDrawPrintDialog(void);
+int SimpleDrawClipboardBitmap(void);
+int SimpleDrawClipboardMetafile(void);
+int SimpleDrawClipboardEMF(void);
+int SimpleDrawImage(void);
+int SimpleDrawImageRGB(void);
+int SimpleDrawSimulate(void);
+
+int SimpleNotXor(void);
+int SimpleXor(void);
+int SimpleReplace(void);
+int SimpleClippingOff(void);
+int SimpleClippingArea(void);
+int SimpleClippingPolygon(void);
+int SimpleClippingRegion(void);
+
+int SimpleTransform(void);
+int SimpleContextPlus(void);
+int SimpleDrawAll(void);
+int SimpleDrawTextAlign(void);
+int SimpleDrawTextFonts(void);
+void SimpleDrawTest(void);
+int SimpleDrawRepaint(void);
+
+#endif
diff --git a/test/simple/simple.led b/test/simple/simple.led
new file mode 100644
index 0000000..cdf4430
--- /dev/null
+++ b/test/simple/simple.led
@@ -0,0 +1,93 @@
+mnOpen = MENU
+(
+ ITEM("CGM - Binary", SimplePlayCGMBin),
+ ITEM("CGM - Text", SimplePlayCGMText),
+ ITEM("METAFILE", SimplePlayMetafile),
+ ITEM("WMF", SimplePlayWMF),
+ ITEM("EMF", SimplePlayEMF)
+)
+
+mnSaveAs = MENU
+(
+ ITEM("DEBUG", SimpleDrawDebug),
+ ITEM("CGM - Binary", SimpleDrawCGMBin),
+ ITEM("CGM - Text", SimpleDrawCGMText),
+ ITEM("DGN", SimpleDrawDGN),
+ ITEM("DXF", SimpleDrawDXF),
+ ITEM("EMF", SimpleDrawEMF),
+ ITEM("METAFILE", SimpleDrawMetafile),
+ ITEM("PDF", SimpleDrawPDF),
+ ITEM("PS", SimpleDrawPS),
+ ITEM("EPS", SimpleDrawEPS),
+ ITEM("WMF", SimpleDrawWMF)
+)
+
+mnFile = MENU
+(
+ SUBMENU("Open", mnOpen),
+ SUBMENU("Save As", mnSaveAs),
+ SEPARATOR(),
+ ITEM("Print", SimpleDrawPrint),
+ ITEM("Print Dialog...", SimpleDrawPrintDialog),
+ SEPARATOR(),
+ ITEM("Exit", cmdExit)
+)
+
+mnEdit = MENU
+(
+ ITEM("Copy as Metafile", SimpleDrawClipboardMetafile),
+ ITEM("Copy as EMF", SimpleDrawClipboardEMF),
+ ITEM("Copy as Bitmap", SimpleDrawClipboardBitmap),
+ ITEM("Paste", SimplePlayClipboard)
+)
+
+mnClipping = MENU
+(
+ ITEM("Off", SimpleClippingOff),
+ ITEM("Area", SimpleClippingArea),
+ ITEM("Polygon", SimpleClippingPolygon),
+ ITEM("Region", SimpleClippingRegion)
+)
+
+mnWriteMode = MENU
+(
+ ITEM("Replace", SimpleReplace),
+ ITEM("Xor", SimpleXor),
+ ITEM("Not Xor", SimpleNotXor)
+)
+
+mnOptions = MENU
+(
+ SUBMENU("Clipping", mnClipping),
+ SUBMENU("Write Mode", mnWriteMode),
+ ITEM("Simulate", SimpleDrawSimulate),
+ ITEM("Transform", SimpleTransform),
+ ITEM("Context Plus", SimpleContextPlus)
+)
+
+mnSurface = MENU
+(
+ ITEM("Window", SimpleDrawWindow),
+ ITEM("Server Image", SimpleDrawImage),
+ ITEM("Image RGB", SimpleDrawImageRGB)
+)
+
+mnPrimitives = MENU
+(
+ ITEM("All", SimpleDrawAll),
+ ITEM("Text Align", SimpleDrawTextAlign),
+ ITEM("Text Fonts", SimpleDrawTextFonts),
+ ITEM("Test", SimpleDrawTest)
+)
+
+mnSimpleMenu = MENU
+(
+ SUBMENU("File", mnFile),
+ SUBMENU("Edit", mnEdit),
+ SUBMENU("Options", mnOptions),
+ SUBMENU("Surface", mnSurface),
+ SUBMENU("Primitives", mnPrimitives)
+)
+
+SimpleCanvas = CANVAS[BORDER=0](SimpleRepaint)
+SimpleDialog = DIALOG [TITLE="Simple Draw", MENU=mnSimpleMenu](SimpleCanvas)
diff --git a/test/simple/simple.sln b/test/simple/simple.sln
new file mode 100644
index 0000000..fc2222e
--- /dev/null
+++ b/test/simple/simple.sln
@@ -0,0 +1,20 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simple", "simple.vcproj", "{82BC36B1-9F7A-41D4-A24F-DBE012378CE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ EndGlobalSection
+ GlobalSection(ProjectDependencies) = postSolution
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {82BC36B1-9F7A-41D4-A24F-DBE012378CE6}.Debug.ActiveCfg = Debug|Win32
+ {82BC36B1-9F7A-41D4-A24F-DBE012378CE6}.Debug.Build.0 = Debug|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/test/simple/simple.vcproj b/test/simple/simple.vcproj
new file mode 100644
index 0000000..87a199c
--- /dev/null
+++ b/test/simple/simple.vcproj
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="simple"
+ ProjectGUID="{82BC36B1-9F7A-41D4-A24F-DBE012378CE6}"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="..\bin"
+ IntermediateDirectory="..\obj\simple"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\..\bin/simple.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include,..\..\..\iup\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;__CD__;simple;_CRT_SECURE_NO_DEPRECATE"
+ RuntimeLibrary="0"
+ PrecompiledHeaderFile=".\..\obj\simple/simple.pch"
+ AssemblerListingLocation=".\..\obj\simple/"
+ ObjectFile=".\..\obj\simple/"
+ ProgramDataBaseFileName=".\..\obj\simple/"
+ WarningLevel="4"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1046"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="freetype6.lib cd.lib iupcd.lib iup.lib comctl32.lib cdgdiplus.lib gdiplus.lib cdpdflib.lib iupcontrols.lib"
+ OutputFile="..\bin/simple.exe"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ AdditionalLibraryDirectories="..\..\lib,..\..\..\iup\lib"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\..\bin/simple.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="iupmain.c"
+ >
+ </File>
+ <File
+ RelativePath="simple.c"
+ >
+ </File>
+ <File
+ RelativePath="simple.h"
+ >
+ </File>
+ <File
+ RelativePath="simple.led"
+ >
+ </File>
+ <File
+ RelativePath="simple_led.c"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/test/simple/simple_led.c b/test/simple/simple_led.c
new file mode 100644
index 0000000..07eebc8
--- /dev/null
+++ b/test/simple/simple_led.c
@@ -0,0 +1,125 @@
+/* Arquivo gerado automaticamente por ledc 2.5 */
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <iup.h>
+
+static Ihandle* named[ 13 ];
+
+static Ihandle* decl( char* name, Ihandle* elem, char* first, ...)
+{
+ char *attr, *val;
+ va_list arg;
+ va_start (arg, first);
+ attr = first;
+ while (attr)
+ {
+ val = va_arg(arg,char*);
+ IupSetAttribute( elem, attr, val );
+ attr = va_arg(arg,char*);
+ }
+ va_end (arg);
+ if(name) IupSetHandle( name, elem );
+ return elem;
+}
+
+
+void simple_loadled (void)
+{
+ named[0] = decl( "mnOpen", IupMenu(
+ IupItem( "CGM - Binary", "SimplePlayCGMBin" ),
+ IupItem( "CGM - Text", "SimplePlayCGMText" ),
+ IupItem( "METAFILE", "SimplePlayMetafile" ),
+ IupItem( "WMF", "SimplePlayWMF" ),
+ IupItem( "EMF", "SimplePlayEMF" ),
+ NULL), NULL );
+ named[1] = decl( "mnSaveAs", IupMenu(
+ IupItem( "DEBUG", "SimpleDrawDebug" ),
+ IupItem( "CGM - Binary", "SimpleDrawCGMBin" ),
+ IupItem( "CGM - Text", "SimpleDrawCGMText" ),
+ IupItem( "DGN", "SimpleDrawDGN" ),
+ IupItem( "DXF", "SimpleDrawDXF" ),
+ IupItem( "EMF", "SimpleDrawEMF" ),
+ IupItem( "METAFILE", "SimpleDrawMetafile" ),
+ IupItem( "PDF", "SimpleDrawPDF" ),
+ IupItem( "PS", "SimpleDrawPS" ),
+ IupItem( "EPS", "SimpleDrawEPS" ),
+ IupItem( "WMF", "SimpleDrawWMF" ),
+ NULL), NULL );
+ named[2] = decl( "mnFile", IupMenu(
+ IupSubmenu( "Open",
+ named[0] /* mnOpen */
+ ),
+ IupSubmenu( "Save As",
+ named[1] /* mnSaveAs */
+ ),
+ IupSeparator(),
+ IupItem( "Print", "SimpleDrawPrint" ),
+ IupItem( "Print Dialog...", "SimpleDrawPrintDialog" ),
+ IupSeparator(),
+ IupItem( "Exit", "cmdExit" ),
+ NULL), NULL );
+ named[3] = decl( "mnEdit", IupMenu(
+ IupItem( "Copy as Metafile", "SimpleDrawClipboardMetafile" ),
+ IupItem( "Copy as EMF", "SimpleDrawClipboardEMF" ),
+ IupItem( "Copy as Bitmap", "SimpleDrawClipboardBitmap" ),
+ IupItem( "Paste", "SimplePlayClipboard" ),
+ NULL), NULL );
+ named[4] = decl( "mnClipping", IupMenu(
+ IupItem( "Off", "SimpleClippingOff" ),
+ IupItem( "Area", "SimpleClippingArea" ),
+ IupItem( "Polygon", "SimpleClippingPolygon" ),
+ IupItem( "Region", "SimpleClippingRegion" ),
+ NULL), NULL );
+ named[5] = decl( "mnWriteMode", IupMenu(
+ IupItem( "Replace", "SimpleReplace" ),
+ IupItem( "Xor", "SimpleXor" ),
+ IupItem( "Not Xor", "SimpleNotXor" ),
+ NULL), NULL );
+ named[6] = decl( "mnOptions", IupMenu(
+ IupSubmenu( "Clipping",
+ named[4] /* mnClipping */
+ ),
+ IupSubmenu( "Write Mode",
+ named[5] /* mnWriteMode */
+ ),
+ IupItem( "Simulate", "SimpleDrawSimulate" ),
+ IupItem( "Transform", "SimpleTransform" ),
+ IupItem( "Context Plus", "SimpleContextPlus" ),
+ NULL), NULL );
+ named[7] = decl( "mnSurface", IupMenu(
+ IupItem( "Window", "SimpleDrawWindow" ),
+ IupItem( "Server Image", "SimpleDrawImage" ),
+ IupItem( "Image RGB", "SimpleDrawImageRGB" ),
+ NULL), NULL );
+ named[8] = decl( "mnPrimitives", IupMenu(
+ IupItem( "All", "SimpleDrawAll" ),
+ IupItem( "Text Align", "SimpleDrawTextAlign" ),
+ IupItem( "Text Fonts", "SimpleDrawTextFonts" ),
+ IupItem( "Test", "SimpleDrawTest" ),
+ NULL), NULL );
+ named[9] = decl( "mnSimpleMenu", IupMenu(
+ IupSubmenu( "File",
+ named[2] /* mnFile */
+ ),
+ IupSubmenu( "Edit",
+ named[3] /* mnEdit */
+ ),
+ IupSubmenu( "Options",
+ named[6] /* mnOptions */
+ ),
+ IupSubmenu( "Surface",
+ named[7] /* mnSurface */
+ ),
+ IupSubmenu( "Primitives",
+ named[8] /* mnPrimitives */
+ ),
+ NULL), NULL );
+ named[10] = decl( "SimpleCanvas", IupCanvas( "SimpleRepaint" ),
+ "BORDER", "0", NULL );
+ named[11] = decl( "SimpleDialog", IupDialog(
+ named[10] /* SimpleCanvas */
+ ),
+ "TITLE", "Simple Draw",
+ "MENU", "mnSimpleMenu", NULL );
+}
diff --git a/test/simple/teste.cpp b/test/simple/teste.cpp
new file mode 100644
index 0000000..83fbbac
--- /dev/null
+++ b/test/simple/teste.cpp
@@ -0,0 +1,219 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <io.h>
+
+#include "iup.h"
+#include "cd.h"
+#include "cdiup.h"
+#include "cdirgb.h"
+
+/***************************************************************************
+* callbacks do IUP *
+****************************************************************************/
+int Draw( Ihandle *dial )
+{
+ cdCanvas *cnv = (cdCanvas *) IupGetAttribute(dial, "CDCANVAS");
+ cdCanvas *imgCnv = (cdCanvas *) IupGetAttribute(dial, "IMGCNV");
+
+ if (cnv==NULL)
+ return IUP_DEFAULT;
+
+ int width, height;
+ cdCanvasGetSize(cnv, &width, &height, NULL, NULL);
+
+ cdCanvasInteriorStyle(cnv, CD_SOLID);
+ cdCanvasForeground(cnv, CD_WHITE);
+ cdCanvasBox(cnv, 0, width, 0, height);
+
+ if (imgCnv==NULL)
+ return IUP_DEFAULT;
+
+ int w, h;
+ cdCanvasGetSize(imgCnv, &w, &h, NULL, NULL);
+
+ unsigned char* red = cdRedImage(imgCnv);
+ unsigned char* green = cdGreenImage(imgCnv);
+ unsigned char* blue = cdBlueImage(imgCnv);
+
+ int dx = width - w;
+ int dy = height - h;
+
+ cdCanvasPutImageRectRGB(cnv, w, h, red, green, blue, (int)(dx / 2.0), (int)(dy / 2.0), 0, 0, 0, 0, 0, 0);
+
+ return IUP_DEFAULT;
+}
+
+int repaint (Ihandle *self, float x, float y)
+{
+ Ihandle *dial = (Ihandle *) IupGetDialog(self);
+
+ cdCanvas *cnv = (cdCanvas *) IupGetAttribute(dial, "CDCANVAS");
+
+ Draw(dial);
+
+ return IUP_DEFAULT;
+}
+
+static int Resize (Ihandle *self, int larg, int alt)
+{
+ Ihandle *dial = IupGetDialog(self);
+
+ if (dial==NULL) return IUP_DEFAULT;
+
+ cdCanvas *cnv = (cdCanvas *) IupGetAttribute(dial, "CDCANVAS");
+
+ if (cnv!=NULL)
+ cdCanvasActivate(cnv);
+
+ Draw(dial);
+
+ return IUP_DEFAULT;
+}
+
+static int doexit(Ihandle *self)
+{
+ return IUP_CLOSE;
+}
+
+cdCanvas* buildBackImage(Ihandle* dial)
+{
+ unsigned char* r = (unsigned char*) IupGetAttribute(dial, "BUFFRED");
+ unsigned char* g = (unsigned char*) IupGetAttribute(dial, "BUFFGREEN");
+ unsigned char* b = (unsigned char*) IupGetAttribute(dial, "BUFFBLUE");
+
+ cdCanvas* imgCnv = (cdCanvas*) IupGetAttribute(dial, "IMGCNV");
+
+ if (imgCnv!=NULL)
+ delete imgCnv;
+
+ if (r!=NULL)
+ delete r;
+ if (g!=NULL)
+ delete g;
+ if (b!=NULL)
+ delete b;
+
+ int w = 200;
+ int h = 200;
+
+ int size = w * h;
+
+ r = new unsigned char[size];
+ g = new unsigned char[size];
+ b = new unsigned char[size];
+
+ char data[100];
+ sprintf(data, "%dx%d %p %p %p", w, h, r, g, b);
+ imgCnv = cdCreateCanvas(CD_IMAGERGB, data);
+
+ IupSetAttribute(dial, "BUFFRED", (char*) r);
+ IupSetAttribute(dial, "BUFFGREEN", (char*) g);
+ IupSetAttribute(dial, "BUFFBLUE", (char*) b);
+
+ IupSetAttribute(dial, "IMGCNV", (char*) imgCnv);
+
+ return imgCnv;
+}
+
+void drawInImage(cdCanvas* cnv)
+{
+ int w, h;
+ cdCanvasGetSize(cnv, &w, &h, NULL, NULL);
+
+ cdCanvasBegin(cnv, CD_CLIP);
+#if 0
+ cdCanvasVertex(cnv, 0, 0);
+ cdCanvasVertex(cnv, w, 0);
+ cdCanvasVertex(cnv, w, h);
+ cdCanvasVertex(cnv, 0, h);
+#else
+ cdCanvasVertex(cnv, -100, -100);
+ cdCanvasVertex(cnv, w+100, -100);
+ cdCanvasVertex(cnv, w+100, h+100);
+ cdCanvasVertex(cnv, -100, h+100);
+#endif
+ cdCanvasEnd(cnv);
+
+ cdCanvasClip(cnv, CD_CLIPPOLYGON);
+
+ cdCanvasInteriorStyle(cnv, CD_SOLID);
+ cdCanvasForeground(cnv, CD_WHITE);
+ cdCanvasBox(cnv, 0, w, 0, h);
+
+ cdCanvasForeground(cnv, CD_RED);
+ cdCanvasTextAlignment(cnv, CD_CENTER);
+ cdCanvasText(cnv, w/2, h/2, "SCURI É BOIOLA!");
+}
+
+static int tofly(Ihandle *self)
+{
+ Ihandle *dial = IupGetDialog(self);
+
+ cdCanvas* back = buildBackImage(dial);
+
+ if (back!=NULL)
+ drawInImage(back);
+
+ Draw(dial);
+
+ return IUP_DEFAULT;
+}
+
+Ihandle *BuildDialog(void)
+{
+ Ihandle *saida = IupItem ("Saida", "acao_sai");
+ Ihandle *voe = IupItem ("Voe", "acao_voar");
+ Ihandle *main_menu = IupMenu ( saida, voe, NULL );
+
+ Ihandle *tela = IupCanvas("rpaint");
+ IupSetAttribute(tela, IUP_BUTTON_CB, "buttonCb");
+ IupSetAttribute(tela, IUP_MOTION_CB, "motionCb");
+
+ Ihandle *hbox = IupHbox ( tela, NULL );
+
+ Ihandle *dial = IupDialog ( hbox );
+
+ IupSetHandle( "main_menu", main_menu );
+ IupSetHandle( "tela", tela );
+ IupSetAttribute( dial, IUP_MENU, "main_menu" );
+ IupSetAttribute( dial, IUP_SIZE, "HALFxHALF" );
+ IupSetAttribute( tela, IUP_SIZE, "300x200" );
+ IupSetAttribute( tela, IUP_RESIZE_CB, "resize_cb");
+
+ IupSetFunction( "rpaint", (Icallback) repaint );
+ IupSetFunction( "acao_sai", (Icallback) doexit );
+ IupSetFunction( "acao_voar", (Icallback) tofly );
+ IupSetFunction( "resize_cb", (Icallback) Resize );
+
+ IupMap(dial);
+
+ return dial;
+}
+
+int main (void)
+{
+ Ihandle *dial;
+
+ /* Abre IUP */
+ IupOpen();
+
+ dial = BuildDialog();
+
+ cdCanvas *cnv = cdCreateCanvas( CD_IUP, IupGetHandle("tela") );
+
+ IupSetAttribute(dial, "CDCANVAS", (char *) cnv);
+
+ /* Exibe dialogo */
+ IupShow(dial);
+
+ /* Interage com o usuario */
+ IupMainLoop();
+
+ cdKillCanvas( cnv );
+
+ /* Fecha IUP */
+ IupClose();
+
+ return 1;
+}