comparison org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet282.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 4e5843b771cc
children
comparison
equal deleted inserted replaced
119:d00e8db0a568 120:536e43f63c81
36 import org.eclipse.swt.widgets.Listener; 36 import org.eclipse.swt.widgets.Listener;
37 import org.eclipse.swt.widgets.Shell; 37 import org.eclipse.swt.widgets.Shell;
38 38
39 import java.lang.all; 39 import java.lang.all;
40 40
41 public static void main(String[] args) { 41 void main() {
42 //An org.eclipse.swt.graphics.Resource in DWT Windows (as against SWT) checks
43 //in destructor if it has been disposed, so we are to watch imageButton's
44 //image and dispose it after shell.isDisposed() or just disable this check
45 version(Windows)
46 Image.globalDisposeChecking = false;
47
42 Display display = new Display(); 48 Display display = new Display();
43 Clipboard clipboard = new Clipboard(display); 49 Clipboard clipboard = new Clipboard(display);
44 Shell shell = new Shell(display, SWT.SHELL_TRIM); 50 Shell shell = new Shell(display, SWT.SHELL_TRIM);
45 shell.setLayout(new GridLayout()); 51 shell.setLayout(new GridLayout());
46 shell.setText("Clipboard ImageTransfer"); 52 shell.setText("Clipboard ImageTransfer");
53 59
54 Composite buttons = new Composite(shell, SWT.NONE); 60 Composite buttons = new Composite(shell, SWT.NONE);
55 buttons.setLayout(new GridLayout(4, true)); 61 buttons.setLayout(new GridLayout(4, true));
56 Button button = new Button(buttons, SWT.PUSH); 62 Button button = new Button(buttons, SWT.PUSH);
57 button.setText("Open"); 63 button.setText("Open");
58 button.addListener(SWT.Selection, new class() Listener { 64 button.addListener(SWT.Selection, new class Listener {
59 public void handleEvent(Event event) { 65 public void handleEvent(Event event) {
60 FileDialog dialog = new FileDialog (shell, SWT.OPEN); 66 FileDialog dialog = new FileDialog (shell, SWT.OPEN);
61 dialog.setText("Open an image file or cancel"); 67 dialog.setText("Open an image file or cancel");
62 String string = dialog.open (); 68 String string = dialog.open ();
63 if (string !is null) { 69 if (string !is null) {
69 } 75 }
70 }); 76 });
71 77
72 button = new Button(buttons, SWT.PUSH); 78 button = new Button(buttons, SWT.PUSH);
73 button.setText("Copy"); 79 button.setText("Copy");
74 button.addListener(SWT.Selection, new class() Listener { 80 button.addListener(SWT.Selection, new class Listener {
75 public void handleEvent(Event event) { 81 public void handleEvent(Event event) {
76 Image image = imageButton.getImage(); 82 Image image = imageButton.getImage();
77 if (image !is null) { 83 if (image !is null) {
78 ImageTransfer transfer = ImageTransfer.getInstance(); 84 ImageTransfer transfer = ImageTransfer.getInstance();
79 85
84 } 90 }
85 } 91 }
86 }); 92 });
87 button = new Button(buttons, SWT.PUSH); 93 button = new Button(buttons, SWT.PUSH);
88 button.setText("Paste"); 94 button.setText("Paste");
89 button.addListener(SWT.Selection, new class() Listener { 95 button.addListener(SWT.Selection, new class Listener {
90 public void handleEvent(Event event) { 96 public void handleEvent(Event event) {
91 ImageTransfer transfer = ImageTransfer.getInstance(); 97 ImageTransfer transfer = ImageTransfer.getInstance();
92 ImageData imageData = cast(ImageData)clipboard.getContents(transfer); 98 ImageData imageData = cast(ImageData)clipboard.getContents(transfer);
93 if (imageData !is null) { 99 if (imageData !is null) {
94 imageButton.setText(""); 100 imageButton.setText("");
102 } 108 }
103 }); 109 });
104 110
105 button = new Button(buttons, SWT.PUSH); 111 button = new Button(buttons, SWT.PUSH);
106 button.setText("Clear"); 112 button.setText("Clear");
107 button.addListener(SWT.Selection, new class() Listener { 113 button.addListener(SWT.Selection, new class Listener {
108 public void handleEvent(Event event) { 114 public void handleEvent(Event event) {
109 imageButton.setText(""); 115 imageButton.setText("");
110 Image image = imageButton.getImage(); 116 Image image = imageButton.getImage();
111 if (image !is null) image.dispose(); 117 if (image !is null) image.dispose();
112 imageButton.setImage(null); 118 imageButton.setImage(null);