SWT
For general information about SWT see http://www.eclipse.org/swt/.
The TioPort repository has this directory structure beneath http://svn.dsource.org/projects/tioport/trunk:
- swt-3.2.1-linux-gtk/
- swt-3.2.1-win32/
- swt-3.2.1-macosx/
Building the examples
- In the moment i suggest to check out the whole repository trunk.
svn co http://svn.dsource.org/projects/tioport/trunk tioport
or any other SubVersion? client: TortoiseSVN, RapidSvn?, KSvn, ...
- See the README for build instructions and dependencies
Simple Examples
Minimum HelloWorld
There are 3 differences between this D version and the Java version:
module minimumhelloworld; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.StaticCtorsSwt; import dejavu.lang.String; // (1) dummy function to access compiled-in resources (here we do not use this feature) extern(C) ubyte[] resources_getDataById( char[] aId ){ return null; } void main(char[][] args) { // (2) initialize SWT org.eclipse.swt.StaticCtorsSwt.callAllStaticCtors(); Display display = new Display(); Shell shell = new Shell(display); shell.setText(String.fromUtf8("Hello, world!")); // (3) shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
- To simulate Java resources, the port has a special mechanism. At least this dummy function has to exist to make the linker happy.
- A manual call to initialize the SWT is required. This does also trigger the initialization of dejavu.
- String literal need to be converted to the Java equivalent String class.
Wizard
This is simple wizard dialog. The application is not a automatic ported. This sample was taken from http://snippets.dzone.com and converted to D manually.
The official SWT examples
The following examples are the official SWT examples from http://www.eclipse.org/swt/examples.php.
Paint
The paint example is a little painting program. All icons are build into the executable.
Addressbook
There are implementation in dejavu missing to have the full function of this example.
e.g. storing the addressbook to a file and loading it.
see #5
Drag and Drop
Clipboard
Controls Example
The controls example is compilable, but it is not working. This is because this example makes use of dynamic invocation of reflected methods. At the moment I don't know how to implement these invocation mechanism in dejavu.
- Screenshot Controls example - Page Button (linux-gtk)
- Screenshot Controls example - Page Canvas (linux-gtk)
- Screenshot Controls example - Page Combo (linux-gtk)
Hoverhelp
Show various controls, each with a tooltip.
In the Screenshot the hover help is shrinked to the window border, since I did not know how to make the screenshot :). #7
Graphics
The Graphics example shows 4 different graphics.
- two diagonals crossed
- a star pattern with the option to fill the polygons (choose background)
- animated dot increasing size
- the intro, showing a "SWT" going animated over a picture:
Screenshot Graphics (linux-gtk)
Poseidon
in the moment, there is an effort of porting poseidon to tango/SWT. See this page poseidon