Mercurial > projects > dwt-mac
comparison dwt/printing/Printer.d @ 7:e831403a80a9
Add 'cast' to casts
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 14:30:35 +0200 |
parents | 1a8b3cb347e0 |
children | db5a898b2119 |
comparison
equal
deleted
inserted
replaced
6:b903c16b6f48 | 7:e831403a80a9 |
---|---|
89 if (printers.length > 0) return printers[0]; | 89 if (printers.length > 0) return printers[0]; |
90 return null; | 90 return null; |
91 } | 91 } |
92 //static int packData(int handle, byte[] buffer, int offset) { | 92 //static int packData(int handle, byte[] buffer, int offset) { |
93 // int length = OS.GetHandleSize (handle); | 93 // int length = OS.GetHandleSize (handle); |
94 // buffer[offset++] = (byte)((length & 0xFF) >> 0); | 94 // buffer[offset++] = cast(byte)((length & 0xFF) >> 0); |
95 // buffer[offset++] = (byte)((length & 0xFF00) >> 8); | 95 // buffer[offset++] = cast(byte)((length & 0xFF00) >> 8); |
96 // buffer[offset++] = (byte)((length & 0xFF0000) >> 16); | 96 // buffer[offset++] = cast(byte)((length & 0xFF0000) >> 16); |
97 // buffer[offset++] = (byte)((length & 0xFF000000) >> 24); | 97 // buffer[offset++] = cast(byte)((length & 0xFF000000) >> 24); |
98 // int [] ptr = new int [1]; | 98 // int [] ptr = new int [1]; |
99 // OS.HLock(handle); | 99 // OS.HLock(handle); |
100 // OS.memmove(ptr, handle, 4); | 100 // OS.memmove(ptr, handle, 4); |
101 // byte[] buffer1 = new byte[length]; | 101 // byte[] buffer1 = new byte[length]; |
102 // OS.memmove(buffer1, ptr [0], length); | 102 // OS.memmove(buffer1, ptr [0], length); |
195 checkDevice(); | 195 checkDevice(); |
196 // PMRect pageRect = new PMRect(); | 196 // PMRect pageRect = new PMRect(); |
197 // PMRect paperRect = new PMRect(); | 197 // PMRect paperRect = new PMRect(); |
198 // OS.PMGetAdjustedPageRect(pageFormat, pageRect); | 198 // OS.PMGetAdjustedPageRect(pageFormat, pageRect); |
199 // OS.PMGetAdjustedPaperRect(pageFormat, paperRect); | 199 // OS.PMGetAdjustedPaperRect(pageFormat, paperRect); |
200 // return new Rectangle(x+(int)paperRect.left, y+(int)paperRect.top, width+(int)(paperRect.right-pageRect.right), height+(int)(paperRect.bottom-pageRect.bottom)); | 200 // return new Rectangle(x+cast(int)paperRect.left, y+cast(int)paperRect.top, width+cast(int)(paperRect.right-pageRect.right), height+cast(int)(paperRect.bottom-pageRect.bottom)); |
201 return null; | 201 return null; |
202 } | 202 } |
203 | 203 |
204 /** | 204 /** |
205 * Creates the printer handle. | 205 * Creates the printer handle. |
206 * This method is called internally by the instance creation | 206 * This method is called internally by the instance creation |
207 * mechanism of the <code>Device</code> class. | 207 * mechanism of the <code>Device</code> class. |
208 * @param deviceData the device data | 208 * @param deviceData the device data |
209 */ | 209 */ |
210 protected void create(DeviceData deviceData) { | 210 protected void create(DeviceData deviceData) { |
211 data = (PrinterData)deviceData; | 211 data = cast(PrinterData)deviceData; |
212 | 212 |
213 printer = NSPrinter.static_printerWithName_(NSString.stringWith(data.name)); | 213 printer = NSPrinter.static_printerWithName_(NSString.stringWith(data.name)); |
214 printer.retain(); | 214 printer.retain(); |
215 | 215 |
216 // int[] buffer = new int[1]; | 216 // int[] buffer = new int[1]; |
245 // if (pageFormat is 0) DWT.error(DWT.ERROR_NO_HANDLES); | 245 // if (pageFormat is 0) DWT.error(DWT.ERROR_NO_HANDLES); |
246 // OS.PMSessionDefaultPageFormat(printSession, pageFormat); | 246 // OS.PMSessionDefaultPageFormat(printSession, pageFormat); |
247 // } | 247 // } |
248 // | 248 // |
249 // if (PREVIEW_DRIVER.equals(data.driver)) { | 249 // if (PREVIEW_DRIVER.equals(data.driver)) { |
250 // OS.PMSessionSetDestination(printSession, printSettings, (short) OS.kPMDestinationPreview, 0, 0); | 250 // OS.PMSessionSetDestination(printSession, printSettings, cast(short) OS.kPMDestinationPreview, 0, 0); |
251 // } | 251 // } |
252 // String name = data.name; | 252 // String name = data.name; |
253 // char[] buffer1 = new char[name.length ()]; | 253 // char[] buffer1 = new char[name.length ()]; |
254 // name.getChars(0, buffer1.length, buffer1, 0); | 254 // name.getChars(0, buffer1.length, buffer1, 0); |
255 // int ptr = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, buffer1, buffer1.length); | 255 // int ptr = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, buffer1, buffer1.length); |
302 // data.foreground = getSystemColor(DWT.COLOR_BLACK).handle; | 302 // data.foreground = getSystemColor(DWT.COLOR_BLACK).handle; |
303 // data.font = getSystemFont (); | 303 // data.font = getSystemFont (); |
304 // PMRect paperRect= new PMRect(); | 304 // PMRect paperRect= new PMRect(); |
305 // OS.PMGetAdjustedPaperRect(pageFormat, paperRect); | 305 // OS.PMGetAdjustedPaperRect(pageFormat, paperRect); |
306 // Rect portRect = new Rect(); | 306 // Rect portRect = new Rect(); |
307 // portRect.left = (short)paperRect.left; | 307 // portRect.left = cast(short)paperRect.left; |
308 // portRect.right = (short)paperRect.right; | 308 // portRect.right = cast(short)paperRect.right; |
309 // portRect.top = (short)paperRect.top; | 309 // portRect.top = cast(short)paperRect.top; |
310 // portRect.bottom = (short)paperRect.bottom; | 310 // portRect.bottom = cast(short)paperRect.bottom; |
311 // data.portRect = portRect; | 311 // data.portRect = portRect; |
312 // isGCCreated = true; | 312 // isGCCreated = true; |
313 // } | 313 // } |
314 // return context; | 314 // return context; |
315 return 0; | 315 return 0; |
489 */ | 489 */ |
490 public Point getDPI() { | 490 public Point getDPI() { |
491 checkDevice(); | 491 checkDevice(); |
492 // PMResolution resolution = new PMResolution(); | 492 // PMResolution resolution = new PMResolution(); |
493 // OS.PMGetResolution(pageFormat, resolution); | 493 // OS.PMGetResolution(pageFormat, resolution); |
494 // return new Point((int)resolution.hRes, (int)resolution.vRes); | 494 // return new Point(cast(int)resolution.hRes, cast(int)resolution.vRes); |
495 return null; | 495 return null; |
496 } | 496 } |
497 | 497 |
498 /** | 498 /** |
499 * Returns a rectangle describing the receiver's size and location. | 499 * Returns a rectangle describing the receiver's size and location. |
510 */ | 510 */ |
511 public Rectangle getBounds() { | 511 public Rectangle getBounds() { |
512 checkDevice(); | 512 checkDevice(); |
513 // PMRect paperRect = new PMRect(); | 513 // PMRect paperRect = new PMRect(); |
514 // OS.PMGetAdjustedPaperRect(pageFormat, paperRect); | 514 // OS.PMGetAdjustedPaperRect(pageFormat, paperRect); |
515 // return new Rectangle(0, 0, (int)(paperRect.right-paperRect.left), (int)(paperRect.bottom-paperRect.top)); | 515 // return new Rectangle(0, 0, cast(int)(paperRect.right-paperRect.left), cast(int)(paperRect.bottom-paperRect.top)); |
516 return null; | 516 return null; |
517 } | 517 } |
518 | 518 |
519 /** | 519 /** |
520 * Returns a rectangle which describes the area of the | 520 * Returns a rectangle which describes the area of the |
533 */ | 533 */ |
534 public Rectangle getClientArea() { | 534 public Rectangle getClientArea() { |
535 checkDevice(); | 535 checkDevice(); |
536 // PMRect pageRect = new PMRect(); | 536 // PMRect pageRect = new PMRect(); |
537 // OS.PMGetAdjustedPageRect(pageFormat, pageRect); | 537 // OS.PMGetAdjustedPageRect(pageFormat, pageRect); |
538 // return new Rectangle(0, 0, (int)(pageRect.right-pageRect.left), (int)(pageRect.bottom-pageRect.top)); | 538 // return new Rectangle(0, 0, cast(int)(pageRect.right-pageRect.left), cast(int)(pageRect.bottom-pageRect.top)); |
539 return null; | 539 return null; |
540 } | 540 } |
541 | 541 |
542 /** | 542 /** |
543 * Returns a <code>PrinterData</code> object representing the | 543 * Returns a <code>PrinterData</code> object representing the |
598 // if (context !is buffer[0]) DWT.error(DWT.ERROR_UNSPECIFIED); | 598 // if (context !is buffer[0]) DWT.error(DWT.ERROR_UNSPECIFIED); |
599 // } | 599 // } |
600 // PMRect paperRect= new PMRect(); | 600 // PMRect paperRect= new PMRect(); |
601 // OS.PMGetAdjustedPaperRect(pageFormat, paperRect); | 601 // OS.PMGetAdjustedPaperRect(pageFormat, paperRect); |
602 // OS.CGContextScaleCTM(context, 1, -1); | 602 // OS.CGContextScaleCTM(context, 1, -1); |
603 // OS.CGContextTranslateCTM(context, 0, -(float)(paperRect.bottom-paperRect.top)); | 603 // OS.CGContextTranslateCTM(context, 0, -cast(float)(paperRect.bottom-paperRect.top)); |
604 // OS.CGContextSetStrokeColorSpace(context, colorspace); | 604 // OS.CGContextSetStrokeColorSpace(context, colorspace); |
605 // OS.CGContextSetFillColorSpace(context, colorspace); | 605 // OS.CGContextSetFillColorSpace(context, colorspace); |
606 // } | 606 // } |
607 } | 607 } |
608 | 608 |