From 22b3e42f503d0900f333c7813c1ced0c1b8a6ef1 Mon Sep 17 00:00:00 2001 From: scuri Date: Fri, 25 Jun 2010 19:34:31 +0000 Subject: *** empty log message *** --- test/simple/gdiplustest.cpp | 116 -------------------------------------------- test/simple/simple.c | 41 ++++++++-------- test/simple/simple.led | 2 +- test/simple/simple_led.c | 43 +++++----------- 4 files changed, 35 insertions(+), 167 deletions(-) delete mode 100644 test/simple/gdiplustest.cpp (limited to 'test') diff --git a/test/simple/gdiplustest.cpp b/test/simple/gdiplustest.cpp deleted file mode 100644 index af7b643..0000000 --- a/test/simple/gdiplustest.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include -#include -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 - -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/simple.c b/test/simple/simple.c index e9e3429..c47812e 100644 --- a/test/simple/simple.c +++ b/test/simple/simple.c @@ -559,6 +559,9 @@ void SimpleDraw(cdCanvas* canvas) SimpleUpdateSize(canvas); #endif + /* refresh CD canvas size, when window size has changed */ + cdCanvasActivate(canvas); + if (simple_draw == DRAW_TEXTFONTS) SimpleDrawTextFonts(canvas); else if (simple_draw == DRAW_TEXTALIGN) @@ -568,6 +571,10 @@ void SimpleDraw(cdCanvas* canvas) else SimpleDrawAll(canvas); + /* Adds a new page, or + flushes the file, or + flushes the screen, or + swap the double buffer. */ cdCanvasFlush(canvas); #ifdef USE_OPENGL @@ -712,7 +719,7 @@ void SimpleDrawAll(cdCanvas* canvas) Notice that in some drivers the bounding box is not precise. */ { int rect[8]; - cdCanvasGetTextBounds(canvas, w/2, h/2, "cdMin Draw (çãí)", rect); + cdCanvasGetTextBounds(canvas, w/2, h/2, "Simple Draw (pçãí)", rect); cdCanvasForeground(canvas, CD_RED); cdCanvasBegin(canvas, CD_CLOSED_LINES); cdCanvasVertex(canvas, rect[0], rect[1]); @@ -722,7 +729,7 @@ void SimpleDrawAll(cdCanvas* canvas) cdCanvasEnd(canvas); } cdCanvasForeground(canvas, CD_BLUE); - cdCanvasText(canvas, w/2, h/2, "cdMin Draw (çãí)"); + cdCanvasText(canvas, w/2, h/2, "Simple Draw (pçãí)"); cdCanvasTextOrientation(canvas, 0); /* Prepare World Coordinates */ @@ -965,12 +972,6 @@ void SimpleDrawAll(cdCanvas* canvas) if (use_transform) cdCanvasTransform(canvas, NULL); cdCanvasClip(canvas, CD_CLIPOFF); - - /* Adds a new page, or - flushes the file, or - flushes the screen, or - swap the double buffer. */ - cdCanvasFlush(canvas); } void DrawVectorTextBox(cdCanvas* canvas, int x, int y, char* text) @@ -1081,18 +1082,18 @@ void SimpleDrawTextAlign(cdCanvas* canvas) #if 1 char* text_aligment_str[] = { - "North (Ãyj)\nSecond Line (Ãyj)", - "South (Ãyj)\nSecond Line (Ãyj)", - "East (Ãyj)\nSecond Line (Ãyj)", - "West (Ãyj)\nSecond Line (Ãyj)", - "North East (Ãyj)\nSecond Line (Ãyj)", - "North West (Ãyj)\nSecond Line (Ãyj)", - "South East (Ãyj)\nSecond Line (Ãyj)", - "South West (Ãyj)\nSecond Line (Ãyj)", - "Center (Ãyj)\nSecond Line (Ãyj)", - "Base Center (Ãyj)\nSecond Line (Ãyj)", - "Base Right (Ãyj)\nSecond Line (Ãyj)", - "Base Left (Ãyj)\nSecond Line (Ãyj)" + "North (Ãyj)\nSecond Line (Ãyj)\nThird Line", + "South (Ãyj)\nSecond Line (Ãyj)\nThird Line", + "East (Ãyj)\nSecond Line (Ãyj)\nThird Line", + "West (Ãyj)\nSecond Line (Ãyj)\nThird Line", + "North East (Ãyj)\nSecond Line (Ãyj)\nThird Line", + "North West (Ãyj)\nSecond Line (Ãyj)\nThird Line", + "South East (Ãyj)\nSecond Line (Ãyj)\nThird Line", + "South West (Ãyj)\nSecond Line (Ãyj)\nThird Line", + "Center (Ãyj)\nSecond Line (Ãyj)\nThird Line", + "Base Center (Ãyj)\nSecond Line (Ãyj)\nThird Line", + "Base Right (Ãyj)\nSecond Line (Ãyj)\nThird Line", + "Base Left (Ãyj)\nSecond Line (Ãyj)\nThird Line" }; #else char* text_aligment_str[] = { diff --git a/test/simple/simple.led b/test/simple/simple.led index a431079..d7ec30d 100644 --- a/test/simple/simple.led +++ b/test/simple/simple.led @@ -70,7 +70,7 @@ mnSurface = MENU ( ITEM("Window", SimpleDrawWindow), ITEM("Server Image", SimpleDrawImage), - ITEM("Image RGB", SimpleDrawImageRGB) + ITEM("Image RGB", SimpleDrawImageRGB), ITEM("OpenGL", SimpleDrawGL) ) diff --git a/test/simple/simple_led.c b/test/simple/simple_led.c index dbfb37b..db06a72 100644 --- a/test/simple/simple_led.c +++ b/test/simple/simple_led.c @@ -1,4 +1,4 @@ -/* Automatically generated by Iup ledc 2.6 */ +/* Automatically generated by Iup 3.0 LED Compiler to C. */ #include #include @@ -6,34 +6,17 @@ 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( + named[0] = IupSetAtt( "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( + named[1] = IupSetAtt( "mnSaveAs", IupMenu( IupItem( "DEBUG", "SimpleDrawDebug" ), IupItem( "CGM - Binary", "SimpleDrawCGMBin" ), IupItem( "CGM - Text", "SimpleDrawCGMText" ), @@ -47,7 +30,7 @@ void simple_loadled (void) IupItem( "SVG", "SimpleDrawSVG" ), IupItem( "WMF", "SimpleDrawWMF" ), NULL), NULL ); - named[2] = decl( "mnFile", IupMenu( + named[2] = IupSetAtt( "mnFile", IupMenu( IupSubmenu( "Open", named[0] /* mnOpen */ ), @@ -60,24 +43,24 @@ void simple_loadled (void) IupSeparator(), IupItem( "Exit", "cmdExit" ), NULL), NULL ); - named[3] = decl( "mnEdit", IupMenu( + named[3] = IupSetAtt( "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( + named[4] = IupSetAtt( "mnClipping", IupMenu( IupItem( "Off", "SimpleClippingOff" ), IupItem( "Area", "SimpleClippingArea" ), IupItem( "Polygon", "SimpleClippingPolygon" ), IupItem( "Region", "SimpleClippingRegion" ), NULL), NULL ); - named[5] = decl( "mnWriteMode", IupMenu( + named[5] = IupSetAtt( "mnWriteMode", IupMenu( IupItem( "Replace", "SimpleReplace" ), IupItem( "Xor", "SimpleXor" ), IupItem( "Not Xor", "SimpleNotXor" ), NULL), NULL ); - named[6] = decl( "mnOptions", IupMenu( + named[6] = IupSetAtt( "mnOptions", IupMenu( IupSubmenu( "Clipping", named[4] /* mnClipping */ ), @@ -88,19 +71,19 @@ void simple_loadled (void) IupItem( "Transform", "SimpleTransform" ), IupItem( "Context Plus", "SimpleContextPlus" ), NULL), NULL ); - named[7] = decl( "mnSurface", IupMenu( + named[7] = IupSetAtt( "mnSurface", IupMenu( IupItem( "Window", "SimpleDrawWindow" ), IupItem( "Server Image", "SimpleDrawImage" ), IupItem( "Image RGB", "SimpleDrawImageRGB" ), IupItem( "OpenGL", "SimpleDrawGL" ), NULL), NULL ); - named[8] = decl( "mnPrimitives", IupMenu( + named[8] = IupSetAtt( "mnPrimitives", IupMenu( IupItem( "All", "SimpleAll" ), IupItem( "Text Align", "SimpleTextAlign" ), IupItem( "Text Fonts", "SimpleTextFonts" ), IupItem( "Test", "SimpleTest" ), NULL), NULL ); - named[9] = decl( "mnSimpleMenu", IupMenu( + named[9] = IupSetAtt( "mnSimpleMenu", IupMenu( IupSubmenu( "File", named[2] /* mnFile */ ), @@ -117,9 +100,9 @@ void simple_loadled (void) named[8] /* mnPrimitives */ ), NULL), NULL ); - named[10] = decl( "SimpleCanvas", IupCanvas( "SimpleRepaint" ), + named[10] = IupSetAtt( "SimpleCanvas", IupCanvas( "SimpleRepaint" ), "BORDER", "0", NULL ); - named[11] = decl( "SimpleDialog", IupDialog( + named[11] = IupSetAtt( "SimpleDialog", IupDialog( named[10] /* SimpleCanvas */ ), "TITLE", "Simple Draw", -- cgit v1.2.3