Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/custom/CLabel.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 | c01d033c633a |
children |
comparison
equal
deleted
inserted
replaced
119:d00e8db0a568 | 120:536e43f63c81 |
---|---|
36 import org.eclipse.swt.graphics.TextLayout; | 36 import org.eclipse.swt.graphics.TextLayout; |
37 import org.eclipse.swt.widgets.Canvas; | 37 import org.eclipse.swt.widgets.Canvas; |
38 import org.eclipse.swt.widgets.Composite; | 38 import org.eclipse.swt.widgets.Composite; |
39 import org.eclipse.swt.widgets.Control; | 39 import org.eclipse.swt.widgets.Control; |
40 import org.eclipse.swt.widgets.Display; | 40 import org.eclipse.swt.widgets.Display; |
41 | |
41 import java.lang.all; | 42 import java.lang.all; |
42 | 43 import java.nonstandard.UnsafeUtf; |
43 version(Tango){ | |
44 static import tango.text.Unicode; | |
45 static import tango.text.convert.Utf; | |
46 } else { // Phobos | |
47 } | |
48 | 44 |
49 /** | 45 /** |
50 * A Label which supports aligned text and/or an image and different border styles. | 46 * A Label which supports aligned text and/or an image and different border styles. |
51 * <p> | 47 * <p> |
52 * If there is not enough space a CLabel uses the following strategy to fit the | 48 * If there is not enough space a CLabel uses the following strategy to fit the |
177 } | 173 } |
178 | 174 |
179 //protected void checkSubclass () { | 175 //protected void checkSubclass () { |
180 // String name = getClass().getName (); | 176 // String name = getClass().getName (); |
181 // String validName = CLabel.class.getName(); | 177 // String validName = CLabel.class.getName(); |
182 // if (!validName.equals(name)) { | 178 // if (validName != (name)) { |
183 // SWT.error (SWT.ERROR_INVALID_SUBCLASS); | 179 // SWT.error (SWT.ERROR_INVALID_SUBCLASS); |
184 // } | 180 // } |
185 //} | 181 //} |
186 | 182 |
187 public override Point computeSize(int wHint, int hHint, bool changed) { | 183 public override Point computeSize(int wHint, int hHint, bool changed) { |
214 /* | 210 /* |
215 * Return the lowercase of the first non-'&' character following | 211 * Return the lowercase of the first non-'&' character following |
216 * an '&' character in the given string. If there are no '&' | 212 * an '&' character in the given string. If there are no '&' |
217 * characters in the given string, return '\0'. | 213 * characters in the given string, return '\0'. |
218 */ | 214 */ |
219 dchar _findMnemonic (String string) { | 215 dchar _findMnemonic (String str) { |
220 if (string is null) return '\0'; | 216 if (str is null) return '\0'; |
221 int index = 0; | 217 int index = 0; |
222 int length = string.length; | 218 int length = str.length; |
223 do { | 219 do { |
224 while (index < length && string[index] !is '&') index++; | 220 while (index < length && str[index] !is '&') index++; |
225 if (++index >= length) return '\0'; | 221 if (++index >= length) return '\0'; |
226 if (string[index] !is '&') return Character.toLowerCase (string.dcharAt (index)); | 222 if (str[index] !is '&') return Character.toLowerCase( str.dcharAt(index) ); |
227 index++; | 223 index++; |
228 } while (index < length); | 224 } while (index < length); |
229 return '\0'; | 225 return '\0'; |
230 } | 226 } |
231 /** | 227 /** |
308 } | 304 } |
309 | 305 |
310 public void getKeyboardShortcut(AccessibleEvent e) { | 306 public void getKeyboardShortcut(AccessibleEvent e) { |
311 dchar mnemonic = _findMnemonic(this.outer.text); | 307 dchar mnemonic = _findMnemonic(this.outer.text); |
312 if (mnemonic !is '\0') { | 308 if (mnemonic !is '\0') { |
313 dchar[1] d; | 309 e.result = "Alt+" ~ dcharToString(mnemonic); //$NON-NLS-1$ |
314 d[0] = mnemonic; | |
315 e.result = Format("Alt+{}", d); //$NON-NLS-1$ | |
316 } | 310 } |
317 } | 311 } |
318 }); | 312 }); |
319 | 313 |
320 accessible.addAccessibleControlListener(new class() AccessibleControlAdapter { | 314 accessible.addAccessibleControlListener(new class() AccessibleControlAdapter { |
826 } | 820 } |
827 private String[] splitString(String text) { | 821 private String[] splitString(String text) { |
828 String[] lines = new String[1]; | 822 String[] lines = new String[1]; |
829 int start = 0, pos; | 823 int start = 0, pos; |
830 do { | 824 do { |
831 pos = text.indexOf( '\n', start); | 825 pos = text.indexOf('\n', start); |
832 if (pos is -1 ) { | 826 if (pos is -1) { |
833 lines[lines.length - 1] = text[start .. $ ]; | 827 lines[lines.length - 1] = text[start .. $ ]; |
834 } else { | 828 } else { |
835 bool crlf = (pos > 0) && (text[ pos - 1 ] is '\r'); | 829 bool crlf = (pos > 0) && (text[ pos - 1 ] is '\r'); |
836 lines[lines.length - 1] = text[ start .. pos - (crlf ? 1 : 0)]; | 830 lines[lines.length - 1] = text[ start .. pos - (crlf ? 1 : 0)]; |
837 start = pos + 1; | 831 start = pos + 1; |
838 String[] newLines = new String[lines.length+1]; | 832 String[] newLines = new String[lines.length+1]; |
839 System.arraycopy(lines, 0, newLines, 0, lines.length); | 833 System.arraycopy(lines, 0, newLines, 0, lines.length); |
840 lines = newLines; | 834 lines = newLines; |
841 } | 835 } |
842 } while (pos !is text.length); | 836 } while (pos !is -1); |
843 return lines; | 837 return lines; |
844 } | 838 } |
845 } | 839 } |