comparison org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/widgets/Text.d @ 39:0ecb2b338560

further work on phobosification
author Frank Benoit <benoit@tionex.de>
date Wed, 25 Mar 2009 13:20:43 +0100
parents 2e09b0e6857a
children 9f4c18c268b2
comparison
equal deleted inserted replaced
38:2e09b0e6857a 39:0ecb2b338560
354 if (hooks (SWT.Verify) || filters (SWT.Verify)) { 354 if (hooks (SWT.Verify) || filters (SWT.Verify)) {
355 string = verifyText (string, length, length, null); 355 string = verifyText (string, length, length, null);
356 if (string is null) return; 356 if (string is null) return;
357 } 357 }
358 OS.SendMessage (handle, OS.EM_SETSEL, length, length); 358 OS.SendMessage (handle, OS.EM_SETSEL, length, length);
359 TCHAR* buffer = StrToTCHARz (getCodePage (), string); 359 LPCTSTR buffer = StrToTCHARz (getCodePage (), string);
360 /* 360 /*
361 * Feature in Windows. When an edit control with ES_MULTILINE 361 * Feature in Windows. When an edit control with ES_MULTILINE
362 * style that does not have the WS_VSCROLL style is full (i.e. 362 * style that does not have the WS_VSCROLL style is full (i.e.
363 * there is no space at the end to draw any more characters), 363 * there is no space at the end to draw any more characters),
364 * EM_REPLACESEL sends a WM_CHAR with a backspace character 364 * EM_REPLACESEL sends a WM_CHAR with a backspace character
367 * and can cause endless recursion when EM_REPLACESEL is sent 367 * and can cause endless recursion when EM_REPLACESEL is sent
368 * from a WM_CHAR handler. The fix is to ignore calling the 368 * from a WM_CHAR handler. The fix is to ignore calling the
369 * handler from WM_CHAR. 369 * handler from WM_CHAR.
370 */ 370 */
371 ignoreCharacter = true; 371 ignoreCharacter = true;
372 OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer); 372 OS.SendMessage (handle, OS.EM_REPLACESEL, 0, cast(void*)buffer);
373 ignoreCharacter = false; 373 ignoreCharacter = false;
374 OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0); 374 OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
375 } 375 }
376 376
377 static int checkStyle (int style) { 377 static int checkStyle (int style) {
694 * and can cause endless recursion when EM_REPLACESEL is sent 694 * and can cause endless recursion when EM_REPLACESEL is sent
695 * from a WM_CHAR handler. The fix is to ignore calling the 695 * from a WM_CHAR handler. The fix is to ignore calling the
696 * handler from WM_CHAR. 696 * handler from WM_CHAR.
697 */ 697 */
698 ignoreCharacter = ignoreModify = true; 698 ignoreCharacter = ignoreModify = true;
699 OS.SendMessage (handle, OS.EM_REPLACESEL, 0, StrToTCHARz (cp, " ")); 699 OS.SendMessage (handle, OS.EM_REPLACESEL, 0, cast(void*)StrToTCHARz (cp, " "));
700 caretPos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, position, 0); 700 caretPos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, position, 0);
701 OS.SendMessage (handle, OS.EM_SETSEL, position, position + 1); 701 OS.SendMessage (handle, OS.EM_SETSEL, position, position + 1);
702 OS.SendMessage (handle, OS.EM_REPLACESEL, 0, StrToTCHARz (cp, "")); 702 OS.SendMessage (handle, OS.EM_REPLACESEL, 0, cast(void*)StrToTCHARz (cp, ""));
703 ignoreCharacter = ignoreModify = false; 703 ignoreCharacter = ignoreModify = false;
704 OS.SendMessage (handle, OS.EM_SETSEL, start , start ); 704 OS.SendMessage (handle, OS.EM_SETSEL, start , start );
705 OS.SendMessage (handle, OS.EM_SETSEL, start , end ); 705 OS.SendMessage (handle, OS.EM_SETSEL, start , end );
706 } 706 }
707 } 707 }
1225 int start, end; 1225 int start, end;
1226 OS.SendMessage (handle, OS.EM_GETSEL, &start, &end); 1226 OS.SendMessage (handle, OS.EM_GETSEL, &start, &end);
1227 string = verifyText (string, start, end, null); 1227 string = verifyText (string, start, end, null);
1228 if (string is null) return; 1228 if (string is null) return;
1229 } 1229 }
1230 TCHAR* buffer = StrToTCHARz (getCodePage (), string ); 1230 LPCTSTR buffer = StrToTCHARz (getCodePage (), string );
1231 /* 1231 /*
1232 * Feature in Windows. When an edit control with ES_MULTILINE 1232 * Feature in Windows. When an edit control with ES_MULTILINE
1233 * style that does not have the WS_VSCROLL style is full (i.e. 1233 * style that does not have the WS_VSCROLL style is full (i.e.
1234 * there is no space at the end to draw any more characters), 1234 * there is no space at the end to draw any more characters),
1235 * EM_REPLACESEL sends a WM_CHAR with a backspace character 1235 * EM_REPLACESEL sends a WM_CHAR with a backspace character
1238 * and can cause endless recursion when EM_REPLACESEL is sent 1238 * and can cause endless recursion when EM_REPLACESEL is sent
1239 * from a WM_CHAR handler. The fix is to ignore calling the 1239 * from a WM_CHAR handler. The fix is to ignore calling the
1240 * handler from WM_CHAR. 1240 * handler from WM_CHAR.
1241 */ 1241 */
1242 ignoreCharacter = true; 1242 ignoreCharacter = true;
1243 OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer); 1243 OS.SendMessage (handle, OS.EM_REPLACESEL, 0, cast(void*)buffer);
1244 ignoreCharacter = false; 1244 ignoreCharacter = false;
1245 } 1245 }
1246 1246
1247 int mbcsToWcsPos (int mbcsPos) { 1247 int mbcsToWcsPos (int mbcsPos) {
1248 if (mbcsPos <= 0) return 0; 1248 if (mbcsPos <= 0) return 0;
1487 } 1487 }
1488 String newText = verifyText (oldText, start, end, event); 1488 String newText = verifyText (oldText, start, end, event);
1489 if (newText is null) return false; 1489 if (newText is null) return false;
1490 if (newText is oldText) return true; 1490 if (newText is oldText) return true;
1491 newText = Display.withCrLf (newText); 1491 newText = Display.withCrLf (newText);
1492 TCHAR* buffer = StrToTCHARz (getCodePage (), newText); 1492 LPCTSTR buffer = StrToTCHARz (getCodePage (), newText);
1493 OS.SendMessage (handle, OS.EM_SETSEL, start, end); 1493 OS.SendMessage (handle, OS.EM_SETSEL, start, end);
1494 /* 1494 /*
1495 * Feature in Windows. When an edit control with ES_MULTILINE 1495 * Feature in Windows. When an edit control with ES_MULTILINE
1496 * style that does not have the WS_VSCROLL style is full (i.e. 1496 * style that does not have the WS_VSCROLL style is full (i.e.
1497 * there is no space at the end to draw any more characters), 1497 * there is no space at the end to draw any more characters),
1501 * and can cause endless recursion when EM_REPLACESEL is sent 1501 * and can cause endless recursion when EM_REPLACESEL is sent
1502 * from a WM_CHAR handler. The fix is to ignore calling the 1502 * from a WM_CHAR handler. The fix is to ignore calling the
1503 * handler from WM_CHAR. 1503 * handler from WM_CHAR.
1504 */ 1504 */
1505 ignoreCharacter = true; 1505 ignoreCharacter = true;
1506 OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer); 1506 OS.SendMessage (handle, OS.EM_REPLACESEL, 0, cast(void*)buffer);
1507 ignoreCharacter = false; 1507 ignoreCharacter = false;
1508 return false; 1508 return false;
1509 } 1509 }
1510 1510
1511 override void setBounds (int x, int y, int width, int height, int flags) { 1511 override void setBounds (int x, int y, int width, int height, int flags) {
1671 this.message = message; 1671 this.message = message;
1672 if (OS.COMCTL32_MAJOR >= 6) { 1672 if (OS.COMCTL32_MAJOR >= 6) {
1673 if ((style & SWT.SEARCH) !is 0) { 1673 if ((style & SWT.SEARCH) !is 0) {
1674 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 1674 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
1675 if ((bits & OS.ES_MULTILINE) is 0) { 1675 if ((bits & OS.ES_MULTILINE) is 0) {
1676 OS.SendMessage (handle, OS.EM_SETCUEBANNER, 0, StrToTCHARz( 0, message )); 1676 OS.SendMessage (handle, OS.EM_SETCUEBANNER, 0, cast(void*)StrToTCHARz( 0, message ));
1677 } 1677 }
1678 } 1678 }
1679 } 1679 }
1680 } 1680 }
1681 1681
1890 string = verifyText (string, 0, length, null); 1890 string = verifyText (string, 0, length, null);
1891 if (string is null) return; 1891 if (string is null) return;
1892 } 1892 }
1893 int limit = OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF; 1893 int limit = OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
1894 if (string.length > limit) string = string.substring (0, limit); 1894 if (string.length > limit) string = string.substring (0, limit);
1895 TCHAR* buffer = StrToTCHARz (getCodePage (), string); 1895 LPCTSTR buffer = StrToTCHARz (getCodePage (), string);
1896 OS.SetWindowText (handle, buffer); 1896 OS.SetWindowText (handle, buffer);
1897 /* 1897 /*
1898 * Bug in Windows. When the widget is multi line 1898 * Bug in Windows. When the widget is multi line
1899 * text widget, it does not send a WM_COMMAND with 1899 * text widget, it does not send a WM_COMMAND with
1900 * control code EN_CHANGE from SetWindowText () to 1900 * control code EN_CHANGE from SetWindowText () to
2393 if (newText !=/*eq*/oldText) { 2393 if (newText !=/*eq*/oldText) {
2394 if (call) { 2394 if (call) {
2395 callWindowProc (handle, msg, wParam, lParam); 2395 callWindowProc (handle, msg, wParam, lParam);
2396 } 2396 }
2397 newText = Display.withCrLf (newText); 2397 newText = Display.withCrLf (newText);
2398 TCHAR* buffer = StrToTCHARz(getCodePage (), newText); 2398 LPCTSTR buffer = StrToTCHARz(getCodePage (), newText);
2399 /* 2399 /*
2400 * Feature in Windows. When an edit control with ES_MULTILINE 2400 * Feature in Windows. When an edit control with ES_MULTILINE
2401 * style that does not have the WS_VSCROLL style is full (i.e. 2401 * style that does not have the WS_VSCROLL style is full (i.e.
2402 * there is no space at the end to draw any more characters), 2402 * there is no space at the end to draw any more characters),
2403 * EM_REPLACESEL sends a WM_CHAR with a backspace character 2403 * EM_REPLACESEL sends a WM_CHAR with a backspace character
2406 * and can cause endless recursion when EM_REPLACESEL is sent 2406 * and can cause endless recursion when EM_REPLACESEL is sent
2407 * from a WM_CHAR handler. The fix is to ignore calling the 2407 * from a WM_CHAR handler. The fix is to ignore calling the
2408 * handler from WM_CHAR. 2408 * handler from WM_CHAR.
2409 */ 2409 */
2410 ignoreCharacter = true; 2410 ignoreCharacter = true;
2411 OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer); 2411 OS.SendMessage (handle, OS.EM_REPLACESEL, 0, cast(void*)buffer);
2412 ignoreCharacter = false; 2412 ignoreCharacter = false;
2413 return LRESULT.ZERO; 2413 return LRESULT.ZERO;
2414 } 2414 }
2415 } 2415 }
2416 if (msg is OS.WM_UNDO) { 2416 if (msg is OS.WM_UNDO) {