diff dwt/graphics/TextLayout.d @ 53:0405e18fec7f

Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
author John Reimer <terminal.node@gmail.com
date Sun, 03 Feb 2008 15:48:14 -0800
parents 9a64a7781bab
children dc7db4338dbe
line wrap: on
line diff
--- a/dwt/graphics/TextLayout.d	Sun Feb 03 05:06:44 2008 +0100
+++ b/dwt/graphics/TextLayout.d	Sun Feb 03 15:48:14 2008 -0800
@@ -583,7 +583,7 @@
         Gdip.Matrix_delete(identity_);
         if (!Gdip.Matrix_IsIdentity(matrix)) {
             lpXform = new float[6];
-            Gdip.Matrix_GetElements(matrix, lpXform.ptr);
+            Gdip.Matrix_GetElements(matrix, lpXform);
         }
         Gdip.Matrix_delete(matrix);
         if ((data.style & DWT.MIRRORED) !is 0 && lpXform !is null) {
@@ -601,7 +601,7 @@
             hdc = Gdip.Graphics_GetHDC(gdipGraphics);
         }
     }
-    Gdip.Brush* foregroundBrush;
+    Gdip.Brush foregroundBrush;
     int state = 0;
     if (gdip) {
         gc.checkGC(GC.FOREGROUND);
@@ -645,7 +645,7 @@
             argb = ((alpha & 0xFF) << 24) | ((fg >> 16) & 0xFF) | (fg & 0xFF00) | ((fg & 0xFF) << 16);
             color = Gdip.Color_new(argb);
             selBrushFg = Gdip.SolidBrush_new(color);
-            selPen = Gdip.Pen_new( cast(Gdip.Brush*)selBrushFg, 1);
+            selPen = Gdip.Pen_new( cast(Gdip.Brush)selBrushFg, 1);
             Gdip.Color_delete(color);
         } else {
             selBrush = OS.CreateSolidBrush(selectionBackground.handle);
@@ -682,7 +682,7 @@
                     width = (lineHeight - lineSpacing) / 3;
                 }
                 if (gdip) {
-                    Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush*)selBrush, drawX + lineWidth[line], drawY, width, lineHeight - lineSpacing);
+                    Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)selBrush, drawX + lineWidth[line], drawY, width, lineHeight - lineSpacing);
                 } else {
                     OS.SelectObject(hdc, selBrush);
                     OS.PatBlt(hdc, drawX + lineWidth[line], drawY, width, lineHeight - lineSpacing, OS.PATCOPY);
@@ -706,7 +706,7 @@
                     bool fullSelection = hasSelection && selectionStart <= run.start && selectionEnd >= end;
                     if (fullSelection) {
                         if (gdip) {
-                            Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush*)selBrush, drawX, drawY, run.width, lineHeight - lineSpacing);
+                            Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)selBrush, drawX, drawY, run.width, lineHeight - lineSpacing);
                         } else {
                             OS.SelectObject(hdc, selBrush);
                             OS.PatBlt(hdc, drawX, drawY, run.width, lineHeight - lineSpacing, OS.PATCOPY);
@@ -719,7 +719,7 @@
                                 int argb = ((alpha & 0xFF) << 24) | ((bg >> 16) & 0xFF) | (bg & 0xFF00) | ((bg & 0xFF) << 16);
                                 auto color = Gdip.Color_new(argb);
                                 auto brush = Gdip.SolidBrush_new(color);
-                                Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush*)brush, drawX, drawRunY, run.width, run.ascent + run.descent);
+                                Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)brush, drawX, drawRunY, run.width, run.ascent + run.descent);
                                 Gdip.Color_delete(color);
                                 Gdip.SolidBrush_delete(brush);
                             } else {
@@ -747,7 +747,7 @@
                             rect.right = drawX + runX;
                             rect.bottom = drawY + lineHeight - lineSpacing;
                             if (gdip) {
-                                Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush*)selBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+                                Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)selBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
                             } else {
                                 OS.SelectObject(hdc, selBrush);
                                 OS.PatBlt(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY);
@@ -806,17 +806,17 @@
                             if ((type & OS.PT_CLOSEFIGURE) !is 0) newType |= Gdip.PathPointTypeCloseSubpath;
                             types[typeIndex] = cast(byte)newType;
                         }
-                        auto path = Gdip.GraphicsPath_new(cast(Gdip.Point*)points.ptr, cast(byte*)types.ptr, count, Gdip.FillModeAlternate);
+                        auto path = Gdip.GraphicsPath_new(cast(Gdip.Point[])points, types, count, Gdip.FillModeAlternate);
                         if (path is null) DWT.error(DWT.ERROR_NO_HANDLES);
                         auto brush = foregroundBrush;
                         if (fullSelection) {
-                            brush = cast(Gdip.Brush*)selBrushFg;
+                            brush = cast(Gdip.Brush)selBrushFg;
                         } else {
                             if (run.style !is null && run.style.foreground !is null) {
                                 auto fg = run.style.foreground.handle;
                                 int argb = ((alpha & 0xFF) << 24) | ((fg >> 16) & 0xFF) | (fg & 0xFF00) | ((fg & 0xFF) << 16);
                                 auto color = Gdip.Color_new(argb);
-                                brush = cast(Gdip.Brush*)Gdip.SolidBrush_new(color);
+                                brush = cast(Gdip.Brush)Gdip.SolidBrush_new(color);
                                 Gdip.Color_delete(color);
                             }
                         }
@@ -852,7 +852,7 @@
                         }
                         Gdip.Graphics_SetSmoothingMode(gdipGraphics, antialias);
                         if (run.style !is null && (run.style.underline || run.style.strikeout)) {
-                            auto newPen = hasSelection ? cast(Gdip.Pen*)selPen : Gdip.Pen_new(brush, 1);
+                            auto newPen = hasSelection ? cast(Gdip.Pen)selPen : Gdip.Pen_new(brush, 1);
                             Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone);
                             if (run.style.underline) {
                                 int underlineY = drawY + baseline + 1 - run.style.rise;
@@ -862,7 +862,7 @@
                                 int strikeoutY = drawRunY + run.leading + (run.ascent - run.style.rise) / 2;
                                 Gdip.Graphics_DrawLine(gdipGraphics, newPen, drawX, strikeoutY, drawX + run.width, strikeoutY);
                             }
-                            if (newPen !is selPen) Gdip.Pen_delete(newPen);
+                            if (cast(void*)newPen !is selPen) Gdip.Pen_delete(newPen);
                             Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf);
                         }
                         if (partialSelection) {
@@ -870,30 +870,31 @@
                             gstate = Gdip.Graphics_Save(gdipGraphics);
                             Gdip.Graphics_SetClip(gdipGraphics, &gdipRect, Gdip.CombineModeIntersect);
                             Gdip.Graphics_SetSmoothingMode(gdipGraphics, textAntialias);
-                            Gdip.Graphics_FillPath(gdipGraphics, cast(Gdip.Brush*)selBrushFg, path);
+                            Gdip.Graphics_FillPath(gdipGraphics, cast(Gdip.Brush)selBrushFg, path);
                             Gdip.Graphics_SetSmoothingMode(gdipGraphics, antialias);
                             if (run.style !is null && (run.style.underline || run.style.strikeout)) {
                                 Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone);
                                 if (run.style.underline) {
                                     int underlineY = drawY + baseline + 1 - run.style.rise;
-                                    Gdip.Graphics_DrawLine(gdipGraphics, cast(Gdip.Pen*)selPen, rect.left, underlineY, rect.right, underlineY);
+                                    Gdip.Graphics_DrawLine(gdipGraphics, cast(Gdip.Pen)selPen, rect.left, underlineY, rect.right, underlineY);
                                 }
                                 if (run.style.strikeout) {
                                     int strikeoutY = drawRunY + run.leading + (run.ascent - run.style.rise) / 2;
-                                    Gdip.Graphics_DrawLine(gdipGraphics, cast(Gdip.Pen*)selPen, rect.left, strikeoutY, rect.right, strikeoutY);
+                                    Gdip.Graphics_DrawLine(gdipGraphics, cast(Gdip.Pen)selPen, rect.left, strikeoutY, rect.right, strikeoutY);
                                 }
                                 Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf);
                             }
                             Gdip.Graphics_Restore(gdipGraphics, gstate);
                         }
                         Gdip.GraphicsPath_delete(path);
-                        if (brush !is selBrushFg && brush !is foregroundBrush) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush*)brush);
-                    }  else {
-                        int fg = foreground;
-                        if (fullSelection) {
-                            fg = selectionForeground.handle;
-                        } else {
-                            if (run.style !is null && run.style.foreground !is null) fg = run.style.foreground.handle;
+                        if ( brush !is cast(Gdip.Brush)selBrushFg && brush !is cast(Gdip.Brush)foregroundBrush)
+                            Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)brush);
+                    }   else {
+                            int fg = foreground;
+                            if (fullSelection) {
+                                fg = selectionForeground.handle;
+                            } else {
+                                if (run.style !is null && run.style.foreground !is null) fg = run.style.foreground.handle;
                         }
                         OS.SetTextColor(hdc, fg);
                         OS.ScriptTextOut(hdc, run.psc, drawX + offset, drawRunY, 0, null, &run.analysis , null, 0, run.glyphs, run.glyphCount, run.advances, run.justify, run.goffsets);
@@ -938,9 +939,9 @@
         }
     }
     if (gdip) {
-        if (selBrush !is null) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush*)selBrush);
-        if (selBrushFg !is null) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush*)selBrushFg);
-        if (selPen !is null) Gdip.Pen_delete(cast(Gdip.Pen*)selPen);
+        if (selBrush !is null) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)selBrush);
+        if (selBrushFg !is null) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)selBrushFg);
+        if (selPen !is null) Gdip.Pen_delete(cast(Gdip.Pen)selPen);
     } else {
         OS.RestoreDC(hdc, state);
         if (gdipGraphics !is null) Gdip.Graphics_ReleaseHDC(gdipGraphics, hdc);