28
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * D Port:
|
|
11 * Thomas Demmer <t_demmer AT web DOT de>
|
|
12 *******************************************************************************/
|
|
13 module org.eclipse.swt.snippets.Snippet250;
|
|
14
|
|
15 /*
|
|
16 * DateTime example snippet: create a DateTime calendar and a DateTime time.
|
|
17 *
|
|
18 * For a list of all SWT example snippets see
|
|
19 * http://www.eclipse.org/swt/snippets/
|
|
20 */
|
|
21 import org.eclipse.swt.SWT;
|
|
22 import org.eclipse.swt.events.SelectionAdapter;
|
|
23 import org.eclipse.swt.events.SelectionEvent;
|
|
24 import org.eclipse.swt.layout.RowLayout;
|
|
25 import org.eclipse.swt.widgets.DateTime;
|
|
26 import org.eclipse.swt.widgets.Display;
|
|
27 import org.eclipse.swt.widgets.Shell;
|
|
28
|
|
29 import java.lang.all;
|
|
30
|
112
|
31 version(Tango){
|
|
32 import tango.io.Stdout;
|
|
33 } else { // Phobos
|
|
34 import std.stdio;
|
|
35 }
|
28
|
36
|
|
37 void main (String [] args) {
|
|
38 Display display = new Display ();
|
|
39 Shell shell = new Shell (display);
|
|
40 shell.setLayout (new RowLayout ());
|
|
41
|
|
42 DateTime calendar = new DateTime (shell, SWT.CALENDAR);
|
|
43 calendar.addSelectionListener (new class() SelectionAdapter{
|
|
44 void widgetSelected (SelectionEvent e) {
|
112
|
45 version(Tango){
|
|
46 Stdout("calendar date changed\n");
|
|
47 Stdout.flush();
|
|
48 } else { // Phobos
|
|
49 writeln("calendar date changed");
|
|
50 }
|
28
|
51 }
|
|
52 });
|
|
53
|
|
54 DateTime time = new DateTime (shell, SWT.TIME);
|
|
55 time.addSelectionListener (new class() SelectionAdapter{
|
|
56 void widgetSelected (SelectionEvent e) {
|
112
|
57 version(Tango){
|
|
58 Stdout("time changed\n");
|
|
59 Stdout.flush();
|
|
60 } else { // Phobos
|
|
61 writeln("time changed");
|
|
62 }
|
28
|
63 }
|
|
64 });
|
|
65
|
|
66 shell.pack ();
|
|
67 shell.open ();
|
|
68 while (!shell.isDisposed ()) {
|
|
69 if (!display.readAndDispatch ()) display.sleep ();
|
|
70 }
|
|
71 display.dispose ();
|
|
72 }
|
|
73
|