Mercurial > projects > dwt-win
comparison dwt/graphics/GC.d @ 212:ab60f3309436
reverted the char[] to String and use the an alias.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:12:38 +0200 |
parents | 184ab53b7785 |
children | 36f5cb12e1a2 |
comparison
equal
deleted
inserted
replaced
211:ff59aeb96cac | 212:ab60f3309436 |
---|---|
579 wchar[] chars; | 579 wchar[] chars; |
580 static if (OS.IsUnicode) { | 580 static if (OS.IsUnicode) { |
581 chars = logFont.lfFaceName; | 581 chars = logFont.lfFaceName; |
582 } else { | 582 } else { |
583 chars = new wchar[OS.LF_FACESIZE]; | 583 chars = new wchar[OS.LF_FACESIZE]; |
584 char[] bytes = logFont.lfFaceName; | 584 String bytes = logFont.lfFaceName; |
585 OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, bytes.ptr, bytes.length, chars, chars.length); | 585 OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, bytes.ptr, bytes.length, chars, chars.length); |
586 } | 586 } |
587 int index = 0; | 587 int index = 0; |
588 while (index < chars.length) { | 588 while (index < chars.length) { |
589 if (chars [index] is 0) break; | 589 if (chars [index] is 0) break; |
590 index++; | 590 index++; |
591 } | 591 } |
592 char[] name = WCHARsToStr( chars[ 0 .. index ] ); | 592 String name = WCHARsToStr( chars[ 0 .. index ] ); |
593 if (Compatibility.equalsIgnoreCase(name, "Courier")) { //$NON-NLS-1$ | 593 if (Compatibility.equalsIgnoreCase(name, "Courier")) { //$NON-NLS-1$ |
594 name = "Courier New"; //$NON-NLS-1$ | 594 name = "Courier New"; //$NON-NLS-1$ |
595 } | 595 } |
596 font = Gdip.Font_new( StrToWCHARz(name), size, style, Gdip.UnitPixel, null); | 596 font = Gdip.Font_new( StrToWCHARz(name), size, style, Gdip.UnitPixel, null); |
597 } | 597 } |
2078 * </ul> | 2078 * </ul> |
2079 * @exception DWTException <ul> | 2079 * @exception DWTException <ul> |
2080 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | 2080 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
2081 * </ul> | 2081 * </ul> |
2082 */ | 2082 */ |
2083 public void drawString (char[] string, int x, int y) { | 2083 public void drawString (String string, int x, int y) { |
2084 drawString(string, x, y, false); | 2084 drawString(string, x, y, false); |
2085 } | 2085 } |
2086 | 2086 |
2087 /** | 2087 /** |
2088 * Draws the given string, using the receiver's current font and | 2088 * Draws the given string, using the receiver's current font and |
2102 * </ul> | 2102 * </ul> |
2103 * @exception DWTException <ul> | 2103 * @exception DWTException <ul> |
2104 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | 2104 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
2105 * </ul> | 2105 * </ul> |
2106 */ | 2106 */ |
2107 public void drawString (char[] string, int x, int y, bool isTransparent) { | 2107 public void drawString (String string, int x, int y, bool isTransparent) { |
2108 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | 2108 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
2109 if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 2109 if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
2110 // TCHAR buffer = new TCHAR (getCodePage(), string, false); | 2110 // TCHAR buffer = new TCHAR (getCodePage(), string, false); |
2111 wchar[] wstr = StrToWCHARs( string ); | 2111 wchar[] wstr = StrToWCHARs( string ); |
2112 int length_ = wstr.length; | 2112 int length_ = wstr.length; |
2234 * </ul> | 2234 * </ul> |
2235 * @exception DWTException <ul> | 2235 * @exception DWTException <ul> |
2236 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | 2236 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
2237 * </ul> | 2237 * </ul> |
2238 */ | 2238 */ |
2239 public void drawText (char[] string, int x, int y) { | 2239 public void drawText (String string, int x, int y) { |
2240 drawText(string, x, y, DWT.DRAW_DELIMITER | DWT.DRAW_TAB); | 2240 drawText(string, x, y, DWT.DRAW_DELIMITER | DWT.DRAW_TAB); |
2241 } | 2241 } |
2242 | 2242 |
2243 /** | 2243 /** |
2244 * Draws the given string, using the receiver's current font and | 2244 * Draws the given string, using the receiver's current font and |
2258 * </ul> | 2258 * </ul> |
2259 * @exception DWTException <ul> | 2259 * @exception DWTException <ul> |
2260 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | 2260 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
2261 * </ul> | 2261 * </ul> |
2262 */ | 2262 */ |
2263 public void drawText (char[] string, int x, int y, bool isTransparent) { | 2263 public void drawText (String string, int x, int y, bool isTransparent) { |
2264 int flags = DWT.DRAW_DELIMITER | DWT.DRAW_TAB; | 2264 int flags = DWT.DRAW_DELIMITER | DWT.DRAW_TAB; |
2265 if (isTransparent) flags |= DWT.DRAW_TRANSPARENT; | 2265 if (isTransparent) flags |= DWT.DRAW_TRANSPARENT; |
2266 drawText(string, x, y, flags); | 2266 drawText(string, x, y, flags); |
2267 } | 2267 } |
2268 | 2268 |
2298 * </ul> | 2298 * </ul> |
2299 * @exception DWTException <ul> | 2299 * @exception DWTException <ul> |
2300 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | 2300 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
2301 * </ul> | 2301 * </ul> |
2302 */ | 2302 */ |
2303 public void drawText (char[] string, int x, int y, int flags) { | 2303 public void drawText (String string, int x, int y, int flags) { |
2304 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | 2304 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
2305 if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 2305 if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
2306 if (string.length is 0) return; | 2306 if (string.length is 0) return; |
2307 auto gdipGraphics = data.gdipGraphics; | 2307 auto gdipGraphics = data.gdipGraphics; |
2308 if (gdipGraphics !is null) { | 2308 if (gdipGraphics !is null) { |
4684 * </ul> | 4684 * </ul> |
4685 * @exception DWTException <ul> | 4685 * @exception DWTException <ul> |
4686 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | 4686 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
4687 * </ul> | 4687 * </ul> |
4688 */ | 4688 */ |
4689 public Point stringExtent(char[] string) { | 4689 public Point stringExtent(String string) { |
4690 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | 4690 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
4691 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 4691 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
4692 checkGC(FONT); | 4692 checkGC(FONT); |
4693 int length_ = string.length; | 4693 int length_ = string.length; |
4694 if (data.gdipGraphics !is null) { | 4694 if (data.gdipGraphics !is null) { |
4742 * </ul> | 4742 * </ul> |
4743 * @exception DWTException <ul> | 4743 * @exception DWTException <ul> |
4744 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | 4744 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
4745 * </ul> | 4745 * </ul> |
4746 */ | 4746 */ |
4747 public Point textExtent(char[] string) { | 4747 public Point textExtent(String string) { |
4748 return textExtent(string, DWT.DRAW_DELIMITER | DWT.DRAW_TAB); | 4748 return textExtent(string, DWT.DRAW_DELIMITER | DWT.DRAW_TAB); |
4749 } | 4749 } |
4750 | 4750 |
4751 /** | 4751 /** |
4752 * Returns the extent of the given string. Tab expansion, line | 4752 * Returns the extent of the given string. Tab expansion, line |
4777 * </ul> | 4777 * </ul> |
4778 * @exception DWTException <ul> | 4778 * @exception DWTException <ul> |
4779 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | 4779 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
4780 * </ul> | 4780 * </ul> |
4781 */ | 4781 */ |
4782 public Point textExtent(char[] string, int flags) { | 4782 public Point textExtent(String string, int flags) { |
4783 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | 4783 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
4784 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 4784 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
4785 checkGC(FONT); | 4785 checkGC(FONT); |
4786 if (data.gdipGraphics !is null) { | 4786 if (data.gdipGraphics !is null) { |
4787 Gdip.PointF pt; | 4787 Gdip.PointF pt; |
4828 * Returns a string containing a concise, human-readable | 4828 * Returns a string containing a concise, human-readable |
4829 * description of the receiver. | 4829 * description of the receiver. |
4830 * | 4830 * |
4831 * @return a string representation of the receiver | 4831 * @return a string representation of the receiver |
4832 */ | 4832 */ |
4833 override public char[] toString () { | 4833 override public String toString () { |
4834 if (isDisposed()) return "GC {*DISPOSED*}"; | 4834 if (isDisposed()) return "GC {*DISPOSED*}"; |
4835 return Format( "GC {{{}}", handle ); | 4835 return Format( "GC {{{}}", handle ); |
4836 } | 4836 } |
4837 | 4837 |
4838 /** | 4838 /** |