comparison dwt/widgets/Display.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
150 //Callback windowCallback; 150 //Callback windowCallback;
151 //int windowProc_; 151 //int windowProc_;
152 int threadId; 152 int threadId;
153 TCHAR[] windowClass_, windowShadowClass; 153 TCHAR[] windowClass_, windowShadowClass;
154 static int WindowClassCount; 154 static int WindowClassCount;
155 static const char[] WindowName = "SWT_Window"; //$NON-NLS-1$ 155 static const String WindowName = "SWT_Window"; //$NON-NLS-1$
156 static const char[] WindowShadowName = "SWT_WindowShadow"; //$NON-NLS-1$ 156 static const String WindowShadowName = "SWT_WindowShadow"; //$NON-NLS-1$
157 EventTable eventTable, filterTable; 157 EventTable eventTable, filterTable;
158 158
159 /* Widget Table */ 159 /* Widget Table */
160 int [] indexTable; 160 int [] indexTable;
161 Control lastControl, lastGetControl; 161 Control lastControl, lastGetControl;
241 //Callback getMsgCallback, embeddedCallback; 241 //Callback getMsgCallback, embeddedCallback;
242 int getMsgProc_; 242 int getMsgProc_;
243 HHOOK msgHook; 243 HHOOK msgHook;
244 HWND embeddedHwnd; 244 HWND embeddedHwnd;
245 int embeddedProc_; 245 int embeddedProc_;
246 static const char[] AWT_WINDOW_CLASS = "SunAwtWindow"; 246 static const String AWT_WINDOW_CLASS = "SunAwtWindow";
247 static const short [] ACCENTS = [ cast(short) '~', '`', '\'', '^', '"']; 247 static const short [] ACCENTS = [ cast(short) '~', '`', '\'', '^', '"'];
248 248
249 /* Sync/Async Widget Communication */ 249 /* Sync/Async Widget Communication */
250 Synchronizer synchronizer; 250 Synchronizer synchronizer;
251 bool runMessages = true, runMessagesInIdle = false; 251 bool runMessages = true, runMessagesInIdle = false;
252 static const char[] RUN_MESSAGES_IN_IDLE_KEY = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$ 252 static const String RUN_MESSAGES_IN_IDLE_KEY = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$
253 Thread thread; 253 Thread thread;
254 254
255 /* Display Shutdown */ 255 /* Display Shutdown */
256 Runnable [] disposeList; 256 Runnable [] disposeList;
257 257
309 /* Table */ 309 /* Table */
310 char [] tableBuffer; 310 char [] tableBuffer;
311 311
312 /* Display Data */ 312 /* Display Data */
313 Object data; 313 Object data;
314 char[] [] keys; 314 String [] keys;
315 Object [] values; 315 Object [] values;
316 316
317 /* Key Mappings */ 317 /* Key Mappings */
318 static const int [] [] KeyTable = [ 318 static const int [] [] KeyTable = [
319 319
420 420
421 /* Workaround for Adobe Reader 7.0 */ 421 /* Workaround for Adobe Reader 7.0 */
422 int hitCount; 422 int hitCount;
423 423
424 /* Package Name */ 424 /* Package Name */
425 static const char[] PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$ 425 static const String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$
426 /* 426 /*
427 * This code is intentionally commented. In order 427 * This code is intentionally commented. In order
428 * to support CLDC, .class cannot be used because 428 * to support CLDC, .class cannot be used because
429 * it does not compile on some Java compilers when 429 * it does not compile on some Java compilers when
430 * they are targeted for CLDC. 430 * they are targeted for CLDC.
431 */ 431 */
432 // static { 432 // static {
433 // char[] name = Display.class.getName (); 433 // String name = Display.class.getName ();
434 // int index = name.lastIndexOf ('.'); 434 // int index = name.lastIndexOf ('.');
435 // PACKAGE_PREFIX = name.substring (0, index + 1); 435 // PACKAGE_PREFIX = name.substring (0, index + 1);
436 // } 436 // }
437 437
438 /* 438 /*
1578 return Default; 1578 return Default;
1579 } 1579 }
1580 1580
1581 //PORTING_TODO 1581 //PORTING_TODO
1582 /+static bool isValidClass (Class clazz) { 1582 /+static bool isValidClass (Class clazz) {
1583 char[] name = clazz.getName (); 1583 String name = clazz.getName ();
1584 int index = name.lastIndexOf ('.'); 1584 int index = name.lastIndexOf ('.');
1585 return name.substring (0, index + 1).equals (PACKAGE_PREFIX); 1585 return name.substring (0, index + 1).equals (PACKAGE_PREFIX);
1586 }+/ 1586 }+/
1587 1587
1588 /** 1588 /**
1608 * </ul> 1608 * </ul>
1609 * 1609 *
1610 * @see #setData(String, Object) 1610 * @see #setData(String, Object)
1611 * @see #disposeExec(Runnable) 1611 * @see #disposeExec(Runnable)
1612 */ 1612 */
1613 public Object getData (char[] key) { 1613 public Object getData (String key) {
1614 checkDevice (); 1614 checkDevice ();
1615 if (key is null) error (DWT.ERROR_NULL_ARGUMENT); 1615 if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
1616 if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) { 1616 if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) {
1617 return new ValueWrapperBool(runMessagesInIdle); 1617 return new ValueWrapperBool(runMessagesInIdle);
1618 } 1618 }
1710 return focusControl; 1710 return focusControl;
1711 } 1711 }
1712 return _getFocusControl (); 1712 return _getFocusControl ();
1713 } 1713 }
1714 1714
1715 char[] getFontName (LOGFONT* logFont) { 1715 String getFontName (LOGFONT* logFont) {
1716 wchar* chars; 1716 wchar* chars;
1717 static if (OS.IsUnicode) { 1717 static if (OS.IsUnicode) {
1718 chars = logFont.lfFaceName.ptr; 1718 chars = logFont.lfFaceName.ptr;
1719 } else { 1719 } else {
1720 chars = new char[OS.LF_FACESIZE]; 1720 chars = new char[OS.LF_FACESIZE];
1789 ubyte[] lpData = new ubyte[ lpcbData / TCHAR.sizeof ]; 1789 ubyte[] lpData = new ubyte[ lpcbData / TCHAR.sizeof ];
1790 lpData[] = 0; 1790 lpData[] = 0;
1791 result = OS.RegQueryValueEx (phkResult , buffer2, null, null, lpData.ptr, &lpcbData); 1791 result = OS.RegQueryValueEx (phkResult , buffer2, null, null, lpData.ptr, &lpcbData);
1792 if (result is 0) { 1792 if (result is 0) {
1793 try { 1793 try {
1794 depth = Integer.parseInt ( cast(char[]) lpData ); 1794 depth = Integer.parseInt ( cast(String) lpData );
1795 } catch (NumberFormatException e) {} 1795 } catch (NumberFormatException e) {}
1796 } 1796 }
1797 } 1797 }
1798 OS.RegCloseKey (phkResult ); 1798 OS.RegCloseKey (phkResult );
1799 return depth; 1799 return depth;
2499 2499
2500 /* Remember the current thread id */ 2500 /* Remember the current thread id */
2501 threadId = OS.GetCurrentThreadId (); 2501 threadId = OS.GetCurrentThreadId ();
2502 2502
2503 /* Use the character encoding for the default locale */ 2503 /* Use the character encoding for the default locale */
2504 windowClass_ = StrToTCHARs ( 0, WindowName ~ to!(char[])(WindowClassCount), true ); 2504 windowClass_ = StrToTCHARs ( 0, WindowName ~ to!(String)(WindowClassCount), true );
2505 windowShadowClass = StrToTCHARs ( 0, WindowShadowName ~ to!(char[])(WindowClassCount), true ); 2505 windowShadowClass = StrToTCHARs ( 0, WindowShadowName ~ to!(String)(WindowClassCount), true );
2506 WindowClassCount++; 2506 WindowClassCount++;
2507 2507
2508 /* Register the DWT window class */ 2508 /* Register the DWT window class */
2509 auto hHeap = OS.GetProcessHeap (); 2509 auto hHeap = OS.GetProcessHeap ();
2510 auto hInstance = OS.GetModuleHandle (null); 2510 auto hInstance = OS.GetModuleHandle (null);
3988 * </ul> 3988 * </ul>
3989 * 3989 *
3990 * @see #getData(String) 3990 * @see #getData(String)
3991 * @see #disposeExec(Runnable) 3991 * @see #disposeExec(Runnable)
3992 */ 3992 */
3993 public void setData (char[] key, Object value) { 3993 public void setData (String key, Object value) {
3994 checkDevice (); 3994 checkDevice ();
3995 if (key is null) error (DWT.ERROR_NULL_ARGUMENT); 3995 if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
3996 3996
3997 if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) { 3997 if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) {
3998 auto data = cast(ValueWrapperBool) value; 3998 auto data = cast(ValueWrapperBool) value;
4008 if (index is keys.length) return; 4008 if (index is keys.length) return;
4009 if (keys.length is 1) { 4009 if (keys.length is 1) {
4010 keys = null; 4010 keys = null;
4011 values = null; 4011 values = null;
4012 } else { 4012 } else {
4013 char[] [] newKeys = new char[] [keys.length - 1]; 4013 String [] newKeys = new String [keys.length - 1];
4014 Object [] newValues = new Object [values.length - 1]; 4014 Object [] newValues = new Object [values.length - 1];
4015 System.arraycopy (keys, 0, newKeys, 0, index); 4015 System.arraycopy (keys, 0, newKeys, 0, index);
4016 System.arraycopy (keys, index + 1, newKeys, index, newKeys.length - index); 4016 System.arraycopy (keys, index + 1, newKeys, index, newKeys.length - index);
4017 System.arraycopy (values, 0, newValues, 0, index); 4017 System.arraycopy (values, 0, newValues, 0, index);
4018 System.arraycopy (values, index + 1, newValues, index, newValues.length - index); 4018 System.arraycopy (values, index + 1, newValues, index, newValues.length - index);
4034 if (keys [i] ==/*eq*/key ) { 4034 if (keys [i] ==/*eq*/key ) {
4035 values [i] = value; 4035 values [i] = value;
4036 return; 4036 return;
4037 } 4037 }
4038 } 4038 }
4039 char[] [] newKeys = new char[] [keys.length + 1]; 4039 String [] newKeys = new String [keys.length + 1];
4040 Object [] newValues = new Object [values.length + 1]; 4040 Object [] newValues = new Object [values.length + 1];
4041 System.arraycopy (keys, 0, newKeys, 0, keys.length); 4041 System.arraycopy (keys, 0, newKeys, 0, keys.length);
4042 System.arraycopy (values, 0, newValues, 0, values.length); 4042 System.arraycopy (values, 0, newValues, 0, values.length);
4043 newKeys [keys.length] = key; 4043 newKeys [keys.length] = key;
4044 newValues [values.length] = value; 4044 newValues [values.length] = value;
4080 * to set the name used for resource lookup. Specifying 4080 * to set the name used for resource lookup. Specifying
4081 * <code>null</code> for the name clears it. 4081 * <code>null</code> for the name clears it.
4082 * 4082 *
4083 * @param name the new app name or <code>null</code> 4083 * @param name the new app name or <code>null</code>
4084 */ 4084 */
4085 public static void setAppName (char[] name) { 4085 public static void setAppName (String name) {
4086 /* Do nothing */ 4086 /* Do nothing */
4087 } 4087 }
4088 4088
4089 void setModalDialogShell (Shell modalDailog) { 4089 void setModalDialogShell (Shell modalDailog) {
4090 if (modalDialogShell !is null && modalDialogShell.isDisposed ()) modalDialogShell = null; 4090 if (modalDialogShell !is null && modalDialogShell.isDisposed ()) modalDialogShell = null;
4488 } 4488 }
4489 } 4489 }
4490 return OS.DefWindowProc (hwnd, msg, wParam, lParam); 4490 return OS.DefWindowProc (hwnd, msg, wParam, lParam);
4491 } 4491 }
4492 4492
4493 static char[] withCrLf (char[] string) { 4493 static String withCrLf (String string) {
4494 4494
4495 /* If the string is empty, return the string. */ 4495 /* If the string is empty, return the string. */
4496 int length_ = string.length; 4496 int length_ = string.length;
4497 if (length_ is 0) return string; 4497 if (length_ is 0) return string;
4498 4498
4533 } 4533 }
4534 } 4534 }
4535 return result.toString (); 4535 return result.toString ();
4536 } 4536 }
4537 4537
4538 char[] windowClass(){ 4538 String windowClass(){
4539 return TCHARsToStr( windowClass_ ); 4539 return TCHARsToStr( windowClass_ );
4540 } 4540 }
4541 4541
4542 } 4542 }