comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Widget.d @ 120:536e43f63c81

Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661 ===D2=== * added [Try]Immutable/Const/Shared templates to work with differenses in D1/D2 instead of version statements used these templates to work with strict type storage rules of dmd-2.053 * com.ibm.icu now also compilable with D2, but not tested yet * small fixes Snippet288 - shared data is in TLS ===Phobos=== * fixed critical bugs in Phobos implemention completely incorrect segfault prone fromStringz (Linux's port ruthless killer) terrible, incorrect StringBuffer realization (StyledText killer) * fixed small bugs as well Snippet72 - misprint in the snippet * implemented missed functionality for Phobos ByteArrayOutputStream implemented (image loading available) formatting correctly works for all DWT's cases As a result, folowing snippets now works with Phobos (Snippet### - what is fixed): Snippet24, 42, 111, 115, 130, 235, 276 - bad string formatting Snippet48, 282 - crash on image loading Snippet163, 189, 211, 213, 217, 218, 222 - crash on copy/cut in StyledText Snippet244 - hang-up ===Tango=== * few changes for the latest Tango trunc-r5661 * few small performance improvments ===General=== * implMissing-s for only one version changed to implMissingInTango/InPhobos * incorrect calls to Format in toString-s fixed * fixed loading \uXXXX characters in ResourceBundle * added good UTF-8 support for StyledText, TextLayout (Win32) and friends UTF functions revised and tested. It is now in java.nonstandard.*Utf modules StyledText and TextLayout (Win32) modules revised for UTF-8 support * removed small diferences in most identical files in *.swt.* folders *.swt.internal.image, *.swt.events and *.swt.custom are identical in Win32/Linux32 now 179 of 576 (~31%) files in *.swt.* folders are fully identical * Win32: snippets now have right subsystem, pretty icons and native system style controls * small fixes in snippets Snippet44 - it's not Snippet44 Snippet212 - functions work with different images and offsets arrays Win32: Snippet282 - crash on close if the button has an image Snippet293 - setGrayed is commented and others Win32: As a result, folowing snippets now works Snippet68 - color doesn't change Snippet163, 189, 211, 213, 217, 218, 222 - UTF-8 issues (see above) Snippet193 - no tabel headers
author Denis Shelomovskij <verylonglogin.reg@gmail.com>
date Sat, 09 Jul 2011 15:50:20 +0300
parents fb3aa8075988
children
comparison
equal deleted inserted replaced
119:d00e8db0a568 120:536e43f63c81
12 *******************************************************************************/ 12 *******************************************************************************/
13 module org.eclipse.swt.widgets.Widget; 13 module org.eclipse.swt.widgets.Widget;
14 14
15 import org.eclipse.swt.SWT; 15 import org.eclipse.swt.SWT;
16 import java.lang.all; 16 import java.lang.all;
17 import java.nonstandard.UnsafeUtf;
17 18
18 import org.eclipse.swt.events.DisposeListener; 19 import org.eclipse.swt.events.DisposeListener;
19 import org.eclipse.swt.internal.Converter; 20 import org.eclipse.swt.internal.Converter;
20 import org.eclipse.swt.internal.SWTEventListener; 21 import org.eclipse.swt.internal.SWTEventListener;
21 import org.eclipse.swt.internal.gtk.OS; 22 import org.eclipse.swt.internal.gtk.OS;
24 import org.eclipse.swt.widgets.EventTable; 25 import org.eclipse.swt.widgets.EventTable;
25 import org.eclipse.swt.widgets.Listener; 26 import org.eclipse.swt.widgets.Listener;
26 import org.eclipse.swt.widgets.TypedListener; 27 import org.eclipse.swt.widgets.TypedListener;
27 28
28 import java.lang.Thread; 29 import java.lang.Thread;
29 version(Tango){
30 import tango.stdc.string;
31 } else { // Phobos
32 }
33 30
34 31
35 /** 32 /**
36 * This class is the abstract superclass of all user interface objects. 33 * This class is the abstract superclass of all user interface objects.
37 * Widgets are created, disposed and issue notification to listeners 34 * Widgets are created, disposed and issue notification to listeners
959 char [] fixMnemonic (String str) { 956 char [] fixMnemonic (String str) {
960 return fixMnemonic (str, true); 957 return fixMnemonic (str, true);
961 } 958 }
962 959
963 char [] fixMnemonic (String str, bool replace) { 960 char [] fixMnemonic (String str, bool replace) {
964 int len = str.length; 961 char[] text = str.dup;
965 auto text = str[0 .. len].dup;
966 int i = 0, j = 0; 962 int i = 0, j = 0;
967 char [] result = new char [len * 2]; 963 char [] result = new char [str.length * 2];
968 while (i < len) { 964 while (i < str.length) {
969 switch (text [i]) { 965 switch (text [i]) {
970 case '&': 966 case '&':
971 if (i + 1 < len && text [i + 1] is '&') { 967 if (i + 1 < str.length && text [i + 1] == '&') {
972 i++; 968 result [j++] = text [i++];
973 } else { 969 } else {
974 if (replace) { 970 if (replace) result [j++] = '_';
975 text [i] = '_';
976 } else {
977 i++;
978 }
979 } 971 }
972 i++;
980 break; 973 break;
981 case '_': 974 case '_':
982 if (replace) result [j++] = '_'; 975 if (replace) result [j++] = '_';
983 break; 976 //FALL THROUGH
984 default: 977 default:
978 result [j++] = text [i++];
985 } 979 }
986 result [j++] = text [i++]; 980 }
987 } 981 if (j < result.length) result [j++] = 0;
988 return result[0..j]; 982 return result[0 .. j];
989 } 983 }
990 984
991 /** 985 /**
992 * Returns <code>true</code> if the widget has been disposed, 986 * Returns <code>true</code> if the widget has been disposed,
993 * and <code>false</code> otherwise. 987 * and <code>false</code> otherwise.
1343 state = buffer; 1337 state = buffer;
1344 } 1338 }
1345 while (index < chars.length) { 1339 while (index < chars.length) {
1346 Event event = new Event (); 1340 Event event = new Event ();
1347 //PORTING take care of utf8 1341 //PORTING take care of utf8
1348 if (keyEvent !is null && chars.codepointCount() <= 1) { 1342 if (keyEvent !is null && chars.UCScount() <= 1) {
1349 setKeyState (event, keyEvent); 1343 setKeyState (event, keyEvent);
1350 } else { 1344 } else {
1351 setInputState (event, state); 1345 setInputState (event, state);
1352 } 1346 }
1353 //PORTING take care of utf8 1347 //PORTING take care of utf8
1354 int incr; 1348 int incr;
1355 event.character = cast(wchar) firstCodePoint( chars [index..$], incr ); 1349 event.character = cast(wchar) chars.dcharAt(index, incr);
1356 sendEvent (type, event); 1350 sendEvent (type, event);
1357 1351
1358 /* 1352 /*
1359 * It is possible (but unlikely), that application 1353 * It is possible (but unlikely), that application
1360 * code could have disposed the widget in the key 1354 * code could have disposed the widget in the key