comparison org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet62.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 9f4c18c268b2
children
comparison
equal deleted inserted replaced
119:d00e8db0a568 120:536e43f63c81
27 import org.eclipse.swt.widgets.Event; 27 import org.eclipse.swt.widgets.Event;
28 import java.lang.all; 28 import java.lang.all;
29 29
30 version(Tango){ 30 version(Tango){
31 import tango.io.Stdout; 31 import tango.io.Stdout;
32 void writeln(in char[] line) {
33 Stdout(line)("\n").flush();
34 }
32 import tango.util.Convert; 35 import tango.util.Convert;
33 } else { // Phobos 36 } else { // Phobos
34 import std.stdio; 37 import std.stdio;
35 import std.conv; 38 import std.conv;
36 } 39 }
37 40
38 static String stateMask (int stateMask) { 41 String stateMask (int stateMask) {
39 String str = ""; 42 String str = "";
40 if ((stateMask & SWT.CTRL) != 0) str ~= " CTRL"; 43 if ((stateMask & SWT.CTRL) != 0) str ~= " CTRL";
41 if ((stateMask & SWT.ALT) != 0) str ~= " ALT"; 44 if ((stateMask & SWT.ALT) != 0) str ~= " ALT";
42 if ((stateMask & SWT.SHIFT) != 0) str ~= " SHIFT"; 45 if ((stateMask & SWT.SHIFT) != 0) str ~= " SHIFT";
43 if ((stateMask & SWT.COMMAND) != 0) str ~= " COMMAND"; 46 if ((stateMask & SWT.COMMAND) != 0) str ~= " COMMAND";
52 String str = "Unknown"; 55 String str = "Unknown";
53 switch (e.type) { 56 switch (e.type) {
54 case SWT.MouseDown: str = "DOWN"; break; 57 case SWT.MouseDown: str = "DOWN"; break;
55 case SWT.MouseMove: str = "MOVE"; break; 58 case SWT.MouseMove: str = "MOVE"; break;
56 case SWT.MouseUp: str = "UP"; break; 59 case SWT.MouseUp: str = "UP"; break;
60 default:
57 } 61 }
58 str ~=": button: " ~ to!(String)(e.button) ~ ", "; 62 str ~= Format(": button: {}, stateMask=0x{:x}{}, x={}, y={}",
59 str ~= "stateMask=0x" ~ to!(String)(e.stateMask) 63 e.button, e.stateMask, stateMask (e.stateMask), e.x, e.y);
60 ~ stateMask (e.stateMask)
61 ~ ", x=" ~ to!(String)(e.x) ~ ", y=" ~ to!(String)(e.y);
62 if ((e.stateMask & SWT.BUTTON1) != 0) str ~= " BUTTON1"; 64 if ((e.stateMask & SWT.BUTTON1) != 0) str ~= " BUTTON1";
63 if ((e.stateMask & SWT.BUTTON2) != 0) str ~= " BUTTON2"; 65 if ((e.stateMask & SWT.BUTTON2) != 0) str ~= " BUTTON2";
64 if ((e.stateMask & SWT.BUTTON3) != 0) str ~= " BUTTON3"; 66 if ((e.stateMask & SWT.BUTTON3) != 0) str ~= " BUTTON3";
65 if ((e.stateMask & SWT.BUTTON4) != 0) str ~= " BUTTON4"; 67 if ((e.stateMask & SWT.BUTTON4) != 0) str ~= " BUTTON4";
66 if ((e.stateMask & SWT.BUTTON5) != 0) str ~= " BUTTON5"; 68 if ((e.stateMask & SWT.BUTTON5) != 0) str ~= " BUTTON5";
67 version(Tango){ 69 writeln(str);
68 Stdout.formatln (str);
69 } else { // Phobos
70 writeln(str);
71 }
72 } 70 }
73 }; 71 };
74 shell.addListener (SWT.MouseDown, listener); 72 shell.addListener (SWT.MouseDown, listener);
75 shell.addListener (SWT.MouseMove, listener); 73 shell.addListener (SWT.MouseMove, listener);
76 shell.addListener (SWT.MouseUp, listener); 74 shell.addListener (SWT.MouseUp, listener);