comparison org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/graphics/GC.d @ 39:0ecb2b338560

further work on phobosification
author Frank Benoit <benoit@tionex.de>
date Wed, 25 Mar 2009 13:20:43 +0100
parents d46287db17ed
children 536e43f63c81
comparison
equal deleted inserted replaced
38:2e09b0e6857a 39:0ecb2b338560
2121 public void drawString (String string, int x, int y, bool isTransparent) { 2121 public void drawString (String string, int x, int y, bool isTransparent) {
2122 if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); 2122 if (handle is null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
2123 // SWT extension: allow null string 2123 // SWT extension: allow null string
2124 //if (string is null) SWT.error(SWT.ERROR_NULL_ARGUMENT); 2124 //if (string is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
2125 // TCHAR buffer = new TCHAR (getCodePage(), string, false); 2125 // TCHAR buffer = new TCHAR (getCodePage(), string, false);
2126 wchar[] wstr = StrToWCHARs( string ); 2126 String16 wstr = StrToWCHARs( string );
2127 int length_ = wstr.length; 2127 int length_ = wstr.length;
2128 if (length_ is 0) return; 2128 if (length_ is 0) return;
2129 wchar* buffer = wstr.ptr; 2129 auto buffer = wstr.ptr;
2130 auto gdipGraphics = data.gdipGraphics; 2130 auto gdipGraphics = data.gdipGraphics;
2131 if (gdipGraphics !is null) { 2131 if (gdipGraphics !is null) {
2132 checkGC(FONT | FOREGROUND | (isTransparent ? 0 : BACKGROUND)); 2132 checkGC(FONT | FOREGROUND | (isTransparent ? 0 : BACKGROUND));
2133 Gdip.PointF pt; 2133 Gdip.PointF pt;
2134 auto format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic()); 2134 auto format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic());
2312 //if (string is null) SWT.error(SWT.ERROR_NULL_ARGUMENT); 2312 //if (string is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
2313 if (string.length is 0) return; 2313 if (string.length is 0) return;
2314 auto gdipGraphics = data.gdipGraphics; 2314 auto gdipGraphics = data.gdipGraphics;
2315 if (gdipGraphics !is null) { 2315 if (gdipGraphics !is null) {
2316 checkGC(FONT | FOREGROUND | ((flags & SWT.DRAW_TRANSPARENT) !is 0 ? 0 : BACKGROUND)); 2316 checkGC(FONT | FOREGROUND | ((flags & SWT.DRAW_TRANSPARENT) !is 0 ? 0 : BACKGROUND));
2317 wchar[] wstr = StrToWCHARs( string ); 2317 String16 wstr = StrToWCHARs( string );
2318 int length_ = wstr.length; 2318 int length_ = wstr.length;
2319 wchar* buffer = wstr.ptr; 2319 auto buffer = wstr.ptr;
2320 Gdip.PointF pt; 2320 Gdip.PointF pt;
2321 auto format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic()); 2321 auto format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic());
2322 int formatFlags = Gdip.StringFormat_GetFormatFlags(format) | Gdip.StringFormatFlagsMeasureTrailingSpaces; 2322 int formatFlags = Gdip.StringFormat_GetFormatFlags(format) | Gdip.StringFormatFlagsMeasureTrailingSpaces;
2323 if ((data.style & SWT.MIRRORED) !is 0) formatFlags |= Gdip.StringFormatFlagsDirectionRightToLeft; 2323 if ((data.style & SWT.MIRRORED) !is 0) formatFlags |= Gdip.StringFormatFlagsDirectionRightToLeft;
2324 Gdip.StringFormat_SetFormatFlags(format, formatFlags); 2324 Gdip.StringFormat_SetFormatFlags(format, formatFlags);
2366 Gdip.Graphics_Restore(gdipGraphics, gstate); 2366 Gdip.Graphics_Restore(gdipGraphics, gstate);
2367 } 2367 }
2368 Gdip.StringFormat_delete(format); 2368 Gdip.StringFormat_delete(format);
2369 return; 2369 return;
2370 } 2370 }
2371 TCHAR[] wstr = StrToTCHARs( string ); 2371 StringT wstr = StrToTCHARs( string );
2372 TCHAR* buffer = wstr.ptr; 2372 auto buffer = wstr.ptr;
2373 int length_ = wstr.length; 2373 int length_ = wstr.length;
2374 if (length_ is 0) return; 2374 if (length_ is 0) return;
2375 RECT rect; 2375 RECT rect;
2376 /* 2376 /*
2377 * Feature in Windows. For some reason DrawText(), the maximum 2377 * Feature in Windows. For some reason DrawText(), the maximum
2966 } 2966 }
2967 int tch = ch; 2967 int tch = ch;
2968 if (ch > 0x7F) { 2968 if (ch > 0x7F) {
2969 char[1] str; 2969 char[1] str;
2970 str[0] = ch; 2970 str[0] = ch;
2971 TCHAR[] buffer = StrToTCHARs( str ); 2971 StringT buffer = StrToTCHARs( str );
2972 tch = buffer[0]; 2972 tch = buffer[0];
2973 } 2973 }
2974 int width; 2974 int width;
2975 OS.GetCharWidth(handle, tch, tch, &width); 2975 OS.GetCharWidth(handle, tch, tch, &width);
2976 return width; 2976 return width;
3112 static if (!OS.IsWinCE) { 3112 static if (!OS.IsWinCE) {
3113 int tch = ch; 3113 int tch = ch;
3114 if (ch > 0x7F) { 3114 if (ch > 0x7F) {
3115 char[1] str; 3115 char[1] str;
3116 str[0] = ch; 3116 str[0] = ch;
3117 TCHAR[] buffer = StrToTCHARs( str ); 3117 StringT buffer = StrToTCHARs( str );
3118 tch = buffer[0]; 3118 tch = buffer[0];
3119 } 3119 }
3120 ABC abc; 3120 ABC abc;
3121 if (OS.GetCharABCWidths(handle, tch, tch, &abc)) { 3121 if (OS.GetCharABCWidths(handle, tch, tch, &abc)) {
3122 return abc.abcA; 3122 return abc.abcA;
4736 checkGC(FONT); 4736 checkGC(FONT);
4737 int length_ = string.length; 4737 int length_ = string.length;
4738 if (data.gdipGraphics !is null) { 4738 if (data.gdipGraphics !is null) {
4739 Gdip.PointF pt; 4739 Gdip.PointF pt;
4740 Gdip.RectF bounds; 4740 Gdip.RectF bounds;
4741 wchar* buffer; 4741 LPCWSTR buffer;
4742 if (length_ !is 0) { 4742 if (length_ !is 0) {
4743 wchar[] wstr = StrToWCHARs( string ); 4743 String16 wstr = StrToWCHARs( string );
4744 buffer = wstr.ptr; 4744 buffer = wstr.ptr;
4745 length_ = wstr.length; 4745 length_ = wstr.length;
4746 } else { 4746 } else {
4747 buffer = (" "w).ptr; 4747 buffer = (" "w).ptr;
4748 } 4748 }
4759 // OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size); 4759 // OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size);
4760 OS.GetTextExtentPoint32W(handle, (" "w).ptr, 1, &size); 4760 OS.GetTextExtentPoint32W(handle, (" "w).ptr, 1, &size);
4761 return new Point(0, size.cy); 4761 return new Point(0, size.cy);
4762 } else { 4762 } else {
4763 // TCHAR buffer = new TCHAR (getCodePage(), string, false); 4763 // TCHAR buffer = new TCHAR (getCodePage(), string, false);
4764 wchar[] wstr = StrToWCHARs( string ); 4764 String16 wstr = StrToWCHARs( string );
4765 wchar* buffer = wstr.ptr; 4765 LPCWSTR buffer = wstr.ptr;
4766 length_ = wstr.length; 4766 length_ = wstr.length;
4767 OS.GetTextExtentPoint32W(handle, buffer, length_, &size); 4767 OS.GetTextExtentPoint32W(handle, buffer, length_, &size);
4768 return new Point(size.cx, size.cy); 4768 return new Point(size.cx, size.cy);
4769 } 4769 }
4770 } 4770 }
4823 //if (string is null) SWT.error (SWT.ERROR_NULL_ARGUMENT); 4823 //if (string is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
4824 checkGC(FONT); 4824 checkGC(FONT);
4825 if (data.gdipGraphics !is null) { 4825 if (data.gdipGraphics !is null) {
4826 Gdip.PointF pt; 4826 Gdip.PointF pt;
4827 Gdip.RectF bounds; 4827 Gdip.RectF bounds;
4828 wchar* buffer; 4828 LPCWSTR buffer;
4829 int length_ = string.length; 4829 int length_ = string.length;
4830 if (length_ !is 0) { 4830 if (length_ !is 0) {
4831 wchar[] wstr = StrToWCHARs( string ); 4831 String16 wstr = StrToWCHARs( string );
4832 buffer = wstr.ptr; 4832 buffer = wstr.ptr;
4833 length_ = wstr.length; 4833 length_ = wstr.length;
4834 } else { 4834 } else {
4835 buffer = (" "w).ptr; 4835 buffer = (" "w).ptr;
4836 } 4836 }
4851 OS.GetTextExtentPoint32W(handle, (" "w).ptr, 1, &size); 4851 OS.GetTextExtentPoint32W(handle, (" "w).ptr, 1, &size);
4852 return new Point(0, size.cy); 4852 return new Point(0, size.cy);
4853 } 4853 }
4854 RECT rect; 4854 RECT rect;
4855 auto wstr = StrToTCHARs( string ); 4855 auto wstr = StrToTCHARs( string );
4856 TCHAR* buffer = wstr.ptr; 4856 LPCWSTR buffer = wstr.ptr;
4857 int length_ = wstr.length; 4857 int length_ = wstr.length;
4858 int uFormat = OS.DT_LEFT | OS.DT_CALCRECT; 4858 int uFormat = OS.DT_LEFT | OS.DT_CALCRECT;
4859 if ((flags & SWT.DRAW_DELIMITER) is 0) uFormat |= OS.DT_SINGLELINE; 4859 if ((flags & SWT.DRAW_DELIMITER) is 0) uFormat |= OS.DT_SINGLELINE;
4860 if ((flags & SWT.DRAW_TAB) !is 0) uFormat |= OS.DT_EXPANDTABS; 4860 if ((flags & SWT.DRAW_TAB) !is 0) uFormat |= OS.DT_EXPANDTABS;
4861 if ((flags & SWT.DRAW_MNEMONIC) is 0) uFormat |= OS.DT_NOPREFIX; 4861 if ((flags & SWT.DRAW_MNEMONIC) is 0) uFormat |= OS.DT_NOPREFIX;