comparison dwt/graphics/GC.d @ 144:476f8d5c0b07

Fixes #39
author Jacob Carlborg <doob@me.com>
date Sat, 06 Jun 2009 17:16:51 +0200
parents ad4e1fe71a5a
children 0ba75290f8ce
comparison
equal deleted inserted replaced
143:c41e13089a3c 144:476f8d5c0b07
313 } 313 }
314 data.state &= ~FOREGROUND_FILL; 314 data.state &= ~FOREGROUND_FILL;
315 } 315 }
316 NSBezierPath path = data.path; 316 NSBezierPath path = data.path;
317 if ((state & LINE_WIDTH) !is 0) { 317 if ((state & LINE_WIDTH) !is 0) {
318 path.setLineWidth((data.lineWidth is 0 ? 1 : data.lineWidth)); 318 path.setLineWidth(data.lineWidth is 0 ? 1 : data.lineWidth);
319 switch (data.lineStyle) { 319 switch (data.lineStyle) {
320 case DWT.LINE_DOT: 320 case DWT.LINE_DOT:
321 case DWT.LINE_DASH: 321 case DWT.LINE_DASH:
322 case DWT.LINE_DASHDOT: 322 case DWT.LINE_DASHDOT:
323 case DWT.LINE_DASHDOTDOT: 323 case DWT.LINE_DASHDOTDOT:
324 state |= LINE_STYLE; 324 state |= LINE_STYLE;
325 default: assert(false); 325 default:
326 } 326 }
327 } 327 }
328 if ((state & LINE_STYLE) !is 0) { 328 if ((state & LINE_STYLE) !is 0) {
329 Carbon.CGFloat[] dashes = null; 329 Carbon.CGFloat[] dashes = null;
330 Carbon.CGFloat width = data.lineWidth; 330 Carbon.CGFloat width = data.lineWidth;
333 case DWT.LINE_DASH: dashes = width !is 0 ? LINE_DASH : LINE_DASH_ZERO; break; 333 case DWT.LINE_DASH: dashes = width !is 0 ? LINE_DASH : LINE_DASH_ZERO; break;
334 case DWT.LINE_DOT: dashes = width !is 0 ? LINE_DOT : LINE_DOT_ZERO; break; 334 case DWT.LINE_DOT: dashes = width !is 0 ? LINE_DOT : LINE_DOT_ZERO; break;
335 case DWT.LINE_DASHDOT: dashes = width !is 0 ? LINE_DASHDOT : LINE_DASHDOT_ZERO; break; 335 case DWT.LINE_DASHDOT: dashes = width !is 0 ? LINE_DASHDOT : LINE_DASHDOT_ZERO; break;
336 case DWT.LINE_DASHDOTDOT: dashes = width !is 0 ? LINE_DASHDOTDOT : LINE_DASHDOTDOT_ZERO; break; 336 case DWT.LINE_DASHDOTDOT: dashes = width !is 0 ? LINE_DASHDOTDOT : LINE_DASHDOTDOT_ZERO; break;
337 case DWT.LINE_CUSTOM: dashes = data.lineDashes; break; 337 case DWT.LINE_CUSTOM: dashes = data.lineDashes; break;
338 default: assert(false); 338 default:
339 } 339 }
340 if (dashes !is null) { 340 if (dashes !is null) {
341 Carbon.CGFloat[] lengths = new Carbon.CGFloat[dashes.length]; 341 Carbon.CGFloat[] lengths = new Carbon.CGFloat[dashes.length];
342 for (int i = 0; i < lengths.length; i++) { 342 for (int i = 0; i < lengths.length; i++) {
343 lengths[i] = width is 0 || data.lineStyle is DWT.LINE_CUSTOM ? dashes[i] : dashes[i] * width; 343 lengths[i] = width is 0 || data.lineStyle is DWT.LINE_CUSTOM ? dashes[i] : dashes[i] * width;
354 NSLineJoinStyle joinStyle; 354 NSLineJoinStyle joinStyle;
355 switch (data.lineJoin) { 355 switch (data.lineJoin) {
356 case DWT.JOIN_MITER: joinStyle = OS.NSMiterLineJoinStyle; break; 356 case DWT.JOIN_MITER: joinStyle = OS.NSMiterLineJoinStyle; break;
357 case DWT.JOIN_ROUND: joinStyle = OS.NSRoundLineJoinStyle; break; 357 case DWT.JOIN_ROUND: joinStyle = OS.NSRoundLineJoinStyle; break;
358 case DWT.JOIN_BEVEL: joinStyle = OS.NSBevelLineJoinStyle; break; 358 case DWT.JOIN_BEVEL: joinStyle = OS.NSBevelLineJoinStyle; break;
359 default: assert(false); 359 default:
360 } 360 }
361 path.setLineJoinStyle(joinStyle); 361 path.setLineJoinStyle(joinStyle);
362 } 362 }
363 if ((state & LINE_CAP) !is 0) { 363 if ((state & LINE_CAP) !is 0) {
364 NSLineCapStyle capStyle; 364 NSLineCapStyle capStyle;
365 switch (data.lineCap) { 365 switch (data.lineCap) {
366 case DWT.CAP_ROUND: capStyle = OS.NSRoundLineCapStyle; break; 366 case DWT.CAP_ROUND: capStyle = OS.NSRoundLineCapStyle; break;
367 case DWT.CAP_FLAT: capStyle = OS.NSButtLineCapStyle; break; 367 case DWT.CAP_FLAT: capStyle = OS.NSButtLineCapStyle; break;
368 case DWT.CAP_SQUARE: capStyle = OS.NSSquareLineCapStyle; break; 368 case DWT.CAP_SQUARE: capStyle = OS.NSSquareLineCapStyle; break;
369 default: assert(false); 369 default:
370 } 370 }
371 path.setLineCapStyle(capStyle); 371 path.setLineCapStyle(capStyle);
372 } 372 }
373 if ((state & DRAW_OFFSET) !is 0) { 373 if ((state & DRAW_OFFSET) !is 0) {
374 data.drawXOffset = data.drawYOffset = 0; 374 data.drawXOffset = data.drawYOffset = 0;
680 paragraph.setLineBreakMode(OS.NSLineBreakByClipping); 680 paragraph.setLineBreakMode(OS.NSLineBreakByClipping);
681 paragraph.setTabStops(NSArray.array()); 681 paragraph.setTabStops(NSArray.array());
682 dict.setObject(paragraph, OS.NSParagraphStyleAttributeName); 682 dict.setObject(paragraph, OS.NSParagraphStyleAttributeName);
683 paragraph.release(); 683 paragraph.release();
684 } 684 }
685 size_t length = string.length(); 685 size_t length_ = string.length();
686 char[] chars = new char[length]; 686 wchar[] chars = string.toString16();
687 string.getChars(0, length, chars, 0);
688 int breakCount = 0; 687 int breakCount = 0;
689 int[] breaks = null; 688 int[] breaks = null;
690 if ((flags & DWT.DRAW_MNEMONIC) !is 0 || (flags & DWT.DRAW_DELIMITER) is 0) { 689 if ((flags & DWT.DRAW_MNEMONIC) !is 0 || (flags & DWT.DRAW_DELIMITER) is 0) {
691 int i=0, j=0; 690 int i=0, j=0;
692 while (i < chars.length) { 691 while (i < chars.length) {
717 break; 716 break;
718 } 717 }
719 default: 718 default:
720 } 719 }
721 } 720 }
722 length = j; 721 length_ = j;
723 } 722 }
724 NSString str = NSString.stringWithCharacters(chars.toCharArray().ptr, length); 723 NSString str = NSString.stringWithCharacters(chars.ptr, chars.length);
725 return (cast(NSAttributedString)(new NSAttributedString()).alloc()).initWithString(str, dict); 724 return (cast(NSAttributedString)(new NSAttributedString()).alloc()).initWithString(str, dict);
726 } 725 }
727 726
728 void destroy() { 727 void destroy() {
729 /* Free resources */ 728 /* Free resources */
973 public void drawLine(int x1, int y1, int x2, int y2) { 972 public void drawLine(int x1, int y1, int x2, int y2) {
974 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); 973 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
975 NSAutoreleasePool pool = checkGC(DRAW); 974 NSAutoreleasePool pool = checkGC(DRAW);
976 try { 975 try {
977 NSBezierPath path = data.path; 976 NSBezierPath path = data.path;
978 NSPoint pt = NSPoint(); 977 NSPoint pt = NSPoint();
979 pt.x = x1 + data.drawXOffset; 978 pt.x = x1 + data.drawXOffset;
980 pt.y = y1 + data.drawYOffset; 979 pt.y = y1 + data.drawYOffset;
981 path.moveToPoint(pt); 980 path.moveToPoint(pt);
982 pt.x = x2 + data.drawXOffset; 981 pt.x = x2 + data.drawXOffset;
983 pt.y = y2 + data.drawYOffset; 982 pt.y = y2 + data.drawYOffset;
1021 if (height < 0) { 1020 if (height < 0) {
1022 y = y + height; 1021 y = y + height;
1023 height = -height; 1022 height = -height;
1024 } 1023 }
1025 NSBezierPath path = data.path; 1024 NSBezierPath path = data.path;
1026 NSRect rect = NSRect(); 1025 NSRect rect = NSRect();
1027 rect.x = x + data.drawXOffset; 1026 rect.x = x + data.drawXOffset;
1028 rect.y = y + data.drawXOffset; 1027 rect.y = y + data.drawXOffset;
1029 rect.width = width; 1028 rect.width = width;
1030 rect.height = height; 1029 rect.height = height;
1031 path.appendBezierPathWithOvalInRect(rect); 1030 path.appendBezierPathWithOvalInRect(rect);
1098 */ 1097 */
1099 public void drawPoint(int x, int y) { 1098 public void drawPoint(int x, int y) {
1100 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); 1099 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
1101 NSAutoreleasePool pool = checkGC(FOREGROUND_FILL | CLIPPING | TRANSFORM); 1100 NSAutoreleasePool pool = checkGC(FOREGROUND_FILL | CLIPPING | TRANSFORM);
1102 try { 1101 try {
1103 NSRect rect = NSRect(); 1102 NSRect rect = NSRect();
1104 rect.x = x; 1103 rect.x = x;
1105 rect.y = y; 1104 rect.y = y;
1106 rect.width = 1; 1105 rect.width = 1;
1107 rect.height = 1; 1106 rect.height = 1;
1108 NSBezierPath path = data.path; 1107 NSBezierPath path = data.path;
1135 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); 1134 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
1136 if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 1135 if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
1137 if (pointArray.length < 4) return; 1136 if (pointArray.length < 4) return;
1138 NSAutoreleasePool pool = checkGC(DRAW); 1137 NSAutoreleasePool pool = checkGC(DRAW);
1139 try { 1138 try {
1140 float /*double*/ xOffset = data.drawXOffset, yOffset = data.drawYOffset; 1139 Carbon.CGFloat xOffset = data.drawXOffset, yOffset = data.drawYOffset;
1141 NSBezierPath path = data.path; 1140 NSBezierPath path = data.path;
1142 NSPoint pt = NSPoint(); 1141 NSPoint pt = NSPoint();
1143 pt.x = pointArray[0] + xOffset; 1142 pt.x = pointArray[0] + xOffset;
1144 pt.y = pointArray[1] + yOffset; 1143 pt.y = pointArray[1] + yOffset;
1145 path.moveToPoint(pt); 1144 path.moveToPoint(pt);
1146 int end = pointArray.length / 2 * 2; 1145 int end = pointArray.length / 2 * 2;
1147 for (int i = 2; i < end; i+=2) { 1146 for (int i = 2; i < end; i+=2) {
1178 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); 1177 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
1179 if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 1178 if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
1180 if (pointArray.length < 4) return; 1179 if (pointArray.length < 4) return;
1181 NSAutoreleasePool pool = checkGC(DRAW); 1180 NSAutoreleasePool pool = checkGC(DRAW);
1182 try { 1181 try {
1183 float /*double*/ xOffset = data.drawXOffset, yOffset = data.drawYOffset; 1182 Carbon.CGFloat xOffset = data.drawXOffset, yOffset = data.drawYOffset;
1184 NSBezierPath path = data.path; 1183 NSBezierPath path = data.path;
1185 NSPoint pt = NSPoint(); 1184 NSPoint pt = NSPoint();
1186 pt.x = pointArray[0] + xOffset; 1185 pt.x = pointArray[0] + xOffset;
1187 pt.y = pointArray[1] + yOffset; 1186 pt.y = pointArray[1] + yOffset;
1188 path.moveToPoint(pt); 1187 path.moveToPoint(pt);
1189 int end = pointArray.length / 2 * 2; 1188 int end = pointArray.length / 2 * 2;
1190 for (int i = 2; i < end; i+=2) { 1189 for (int i = 2; i < end; i+=2) {
1224 } 1223 }
1225 if (height < 0) { 1224 if (height < 0) {
1226 y = y + height; 1225 y = y + height;
1227 height = -height; 1226 height = -height;
1228 } 1227 }
1229 NSRect rect = NSRect(); 1228 NSRect rect = NSRect();
1230 rect.x = x + data.drawXOffset; 1229 rect.x = x + data.drawXOffset;
1231 rect.y = y + data.drawYOffset; 1230 rect.y = y + data.drawYOffset;
1232 rect.width = width; 1231 rect.width = width;
1233 rect.height = height; 1232 rect.height = height;
1234 NSBezierPath path = data.path; 1233 NSBezierPath path = data.path;
1290 return; 1289 return;
1291 } 1290 }
1292 NSAutoreleasePool pool = checkGC(DRAW); 1291 NSAutoreleasePool pool = checkGC(DRAW);
1293 try { 1292 try {
1294 NSBezierPath path = data.path; 1293 NSBezierPath path = data.path;
1295 NSRect rect = NSRect(); 1294 NSRect rect = NSRect();
1296 rect.x = x + data.drawXOffset; 1295 rect.x = x + data.drawXOffset;
1297 rect.y = y + data.drawYOffset; 1296 rect.y = y + data.drawYOffset;
1298 rect.width = width; 1297 rect.width = width;
1299 rect.height = height; 1298 rect.height = height;
1300 path.appendBezierPathWithRoundedRect(rect, arcWidth, arcHeight); 1299 path.appendBezierPathWithRoundedRect(rect, arcWidth, arcHeight);
1444 NSAffineTransform transform = NSAffineTransform.transform(); 1443 NSAffineTransform transform = NSAffineTransform.transform();
1445 transform.scaleXBy(1, -1); 1444 transform.scaleXBy(1, -1);
1446 transform.translateXBy(0, -(str.size().height + 2 * y)); 1445 transform.translateXBy(0, -(str.size().height + 2 * y));
1447 transform.concat(); 1446 transform.concat();
1448 } 1447 }
1449 NSPoint pt = NSPoint(); 1448 NSPoint pt = NSPoint();
1450 pt.x = x; 1449 pt.x = x;
1451 pt.y = y; 1450 pt.y = y;
1452 str.drawAtPoint(pt); 1451 str.drawAtPoint(pt);
1453 str.release(); 1452 str.release();
1454 if (data.paintRect is null) { 1453 if (data.paintRect is null) {
1522 if (width is 0 || height is 0 || arcAngle is 0) return; 1521 if (width is 0 || height is 0 || arcAngle is 0) return;
1523 NSAutoreleasePool pool = checkGC(FILL); 1522 NSAutoreleasePool pool = checkGC(FILL);
1524 try { 1523 try {
1525 handle.saveGraphicsState(); 1524 handle.saveGraphicsState();
1526 NSAffineTransform transform = NSAffineTransform.transform(); 1525 NSAffineTransform transform = NSAffineTransform.transform();
1527 Carbon.CGFloat xOffset = data.drawXOffset, yOffset = data.drawYOffset; 1526 Carbon.CGFloat xOffset = data.drawXOffset, yOffset = data.drawYOffset;
1528 transform.translateXBy(x + xOffset + width / 2f, y + yOffset + height / 2f); 1527 transform.translateXBy(x + xOffset + width / 2f, y + yOffset + height / 2f);
1529 transform.scaleXBy(width / 2f, height / 2f); 1528 transform.scaleXBy(width / 2f, height / 2f);
1530 NSBezierPath path = data.path; 1529 NSBezierPath path = data.path;
1531 NSPoint center = NSPoint(); 1530 NSPoint center = NSPoint();
1532 path.moveToPoint(center); 1531 path.moveToPoint(center);
1533 Carbon.CGFloat sAngle = -startAngle; 1532 Carbon.CGFloat sAngle = -startAngle;
1534 Carbon.CGFloat eAngle = -(startAngle + arcAngle); 1533 Carbon.CGFloat eAngle = -(startAngle + arcAngle);
1535 path.appendBezierPathWithArcWithCenter(center, 1, sAngle, eAngle, arcAngle>0); 1534 path.appendBezierPathWithArcWithCenter(center, 1, sAngle, eAngle, arcAngle>0);
1536 path.closePath(); 1535 path.closePath();
1537 path.transformUsingAffineTransform(transform); 1536 path.transformUsingAffineTransform(transform);
1538 path.fill(); 1537 path.fill();
1539 path.removeAllPoints(); 1538 path.removeAllPoints();
1591 if (fromRGB.equals(toRGB)) { 1590 if (fromRGB.equals(toRGB)) {
1592 fillRectangle(x, y, width, height); 1591 fillRectangle(x, y, width, height);
1593 } else { 1592 } else {
1594 NSColor startingColor = NSColor.colorWithDeviceRed(fromRGB.red / 255f, fromRGB.green / 255f, fromRGB.blue / 255f, data.alpha / 255f); 1593 NSColor startingColor = NSColor.colorWithDeviceRed(fromRGB.red / 255f, fromRGB.green / 255f, fromRGB.blue / 255f, data.alpha / 255f);
1595 NSColor endingColor = NSColor.colorWithDeviceRed(toRGB.red / 255f, toRGB.green / 255f, toRGB.blue / 255f, data.alpha / 255f); 1594 NSColor endingColor = NSColor.colorWithDeviceRed(toRGB.red / 255f, toRGB.green / 255f, toRGB.blue / 255f, data.alpha / 255f);
1596 NSGradient gradient = (cast(NSGradient)(new NSGradient()).alloc()).initWithStartingColor(startingColor, endingColor); 1595 NSGradient gradient = (cast(NSGradient)(new NSGradient()).alloc()).initWithStartingColor(startingColor, endingColor);
1597 NSRect rect = NSRect(); 1596 NSRect rect = NSRect();
1598 rect.x = x; 1597 rect.x = x;
1599 rect.y = y; 1598 rect.y = y;
1600 rect.width = width; 1599 rect.width = width;
1601 rect.height = height; 1600 rect.height = height;
1602 gradient.drawInRect(rect, vertical ? 90 : 0); 1601 gradient.drawInRect(rect, vertical ? 90 : 0);
1634 if (height < 0) { 1633 if (height < 0) {
1635 y = y + height; 1634 y = y + height;
1636 height = -height; 1635 height = -height;
1637 } 1636 }
1638 NSBezierPath path = data.path; 1637 NSBezierPath path = data.path;
1639 NSRect rect = NSRect(); 1638 NSRect rect = NSRect();
1640 rect.x = x; 1639 rect.x = x;
1641 rect.y = y; 1640 rect.y = y;
1642 rect.width = width; 1641 rect.width = width;
1643 rect.height = height; 1642 rect.height = height;
1644 path.appendBezierPathWithOvalInRect(rect); 1643 path.appendBezierPathWithOvalInRect(rect);
1728 if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 1727 if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
1729 if (pointArray.length < 4) return; 1728 if (pointArray.length < 4) return;
1730 NSAutoreleasePool pool = checkGC(FILL); 1729 NSAutoreleasePool pool = checkGC(FILL);
1731 try { 1730 try {
1732 NSBezierPath path = data.path; 1731 NSBezierPath path = data.path;
1733 NSPoint pt = NSPoint(); 1732 NSPoint pt = NSPoint();
1734 pt.x = pointArray[0]; 1733 pt.x = pointArray[0];
1735 pt.y = pointArray[1]; 1734 pt.y = pointArray[1];
1736 path.moveToPoint(pt); 1735 path.moveToPoint(pt);
1737 int end = pointArray.length / 2 * 2; 1736 int end = pointArray.length / 2 * 2;
1738 for (int i = 2; i < end; i+=2) { 1737 for (int i = 2; i < end; i+=2) {
1778 } 1777 }
1779 if (height < 0) { 1778 if (height < 0) {
1780 y = y + height; 1779 y = y + height;
1781 height = -height; 1780 height = -height;
1782 } 1781 }
1783 NSRect rect = NSRect(); 1782 NSRect rect = NSRect();
1784 rect.x = x; 1783 rect.x = x;
1785 rect.y = y; 1784 rect.y = y;
1786 rect.width = width; 1785 rect.width = width;
1787 rect.height = height; 1786 rect.height = height;
1788 NSBezierPath path = data.path; 1787 NSBezierPath path = data.path;
1844 return; 1843 return;
1845 } 1844 }
1846 NSAutoreleasePool pool = checkGC(FILL); 1845 NSAutoreleasePool pool = checkGC(FILL);
1847 try { 1846 try {
1848 NSBezierPath path = data.path; 1847 NSBezierPath path = data.path;
1849 NSRect rect = NSRect(); 1848 NSRect rect = NSRect();
1850 rect.x = x; 1849 rect.x = x;
1851 rect.y = y; 1850 rect.y = y;
1852 rect.width = width; 1851 rect.width = width;
1853 rect.height = height; 1852 rect.height = height;
1854 path.appendBezierPathWithRoundedRect(rect, arcWidth, arcHeight); 1853 path.appendBezierPathWithRoundedRect(rect, arcWidth, arcHeight);
2190 public FontMetrics getFontMetrics() { 2189 public FontMetrics getFontMetrics() {
2191 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); 2190 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
2192 NSAutoreleasePool pool = checkGC(FONT); 2191 NSAutoreleasePool pool = checkGC(FONT);
2193 try { 2192 try {
2194 NSFont font = data.font.handle; 2193 NSFont font = data.font.handle;
2195 int ascent = cast(int)(0.5f + font.ascender()); 2194 int ascent = cast(int)(0.5f + font.ascender());
2196 int descent = cast(int)(0.5f + (-font.descender() + font.leading())); 2195 int descent = cast(int)(0.5f + (-font.descender() + font.leading()));
2197 String s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 2196 String s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
2198 int averageCharWidth = stringExtent(s).x / s.length(); 2197 int averageCharWidth = stringExtent(s).x / s.length();
2199 return FontMetrics.cocoa_new(ascent, descent, averageCharWidth, 0, ascent + descent); 2198 return FontMetrics.cocoa_new(ascent, descent, averageCharWidth, 0, ascent + descent);
2200 } finally { 2199 } finally {
2201 uncheckGC(pool); 2200 uncheckGC(pool);
2464 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); 2463 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
2465 if (transform is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 2464 if (transform is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
2466 if (transform.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 2465 if (transform.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
2467 NSAffineTransform cmt = data.transform; 2466 NSAffineTransform cmt = data.transform;
2468 if (cmt !is null) { 2467 if (cmt !is null) {
2469 NSAffineTransformStruct structt = cmt.transformStruct(); 2468 NSAffineTransformStruct struct_ = cmt.transformStruct();
2470 transform.handle.setTransformStruct(structt); 2469 transform.handle.setTransformStruct(struct_);
2471 } else { 2470 } else {
2472 transform.setElements(1, 0, 0, 1, 0, 0); 2471 transform.setElements(1, 0, 0, 1, 0, 0);
2473 } 2472 }
2474 } 2473 }
2475 2474
2750 if (pattern !is null && pattern.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 2749 if (pattern !is null && pattern.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
2751 if (data.backgroundPattern is pattern) return; 2750 if (data.backgroundPattern is pattern) return;
2752 data.backgroundPattern = pattern; 2751 data.backgroundPattern = pattern;
2753 data.state &= ~BACKGROUND; 2752 data.state &= ~BACKGROUND;
2754 } 2753 }
2755 2754
2756 /** 2755 /**
2757 * Sets the area of the receiver which can be changed 2756 * Sets the area of the receiver which can be changed
2758 * by drawing operations to the rectangular area specified 2757 * by drawing operations to the rectangular area specified
2759 * by the arguments. 2758 * by the arguments.
2760 * 2759 *
3399 if (transform !is null) { 3398 if (transform !is null) {
3400 if (data.transform !is null) data.transform.release(); 3399 if (data.transform !is null) data.transform.release();
3401 if (data.inverseTransform !is null) data.inverseTransform.release(); 3400 if (data.inverseTransform !is null) data.inverseTransform.release();
3402 data.transform = (cast(NSAffineTransform)(new NSAffineTransform()).alloc()).initWithTransform(transform.handle); 3401 data.transform = (cast(NSAffineTransform)(new NSAffineTransform()).alloc()).initWithTransform(transform.handle);
3403 data.inverseTransform = (cast(NSAffineTransform)(new NSAffineTransform()).alloc()).initWithTransform(transform.handle); 3402 data.inverseTransform = (cast(NSAffineTransform)(new NSAffineTransform()).alloc()).initWithTransform(transform.handle);
3404 NSAffineTransformStruct structt = data.inverseTransform.transformStruct(); 3403 NSAffineTransformStruct struct_ = data.inverseTransform.transformStruct();
3405 if ((structt.m11 * structt.m22 - structt.m12 * structt.m21) !is 0) { 3404 if ((struct_.m11 * struct_.m22 - struct_.m12 * struct_.m21) !is 0) {
3406 data.inverseTransform.invert(); 3405 data.inverseTransform.invert();
3407 } 3406 }
3408 } else { 3407 } else {
3409 data.transform = data.inverseTransform = null; 3408 data.transform = data.inverseTransform = null;
3410 } 3409 }
3493 if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 3492 if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
3494 NSAutoreleasePool pool = checkGC(FONT); 3493 NSAutoreleasePool pool = checkGC(FONT);
3495 try { 3494 try {
3496 NSAttributedString str = createString(string, flags); 3495 NSAttributedString str = createString(string, flags);
3497 NSSize size = str.size(); 3496 NSSize size = str.size();
3498 return new Point(cast(int)size.width, cast(int)size.height); 3497 return new Point(cast(int)size.width, cast(int)size.height);
3499 } finally { 3498 } finally {
3500 uncheckGC(pool); 3499 uncheckGC(pool);
3501 } 3500 }
3502 } 3501 }
3503 3502