Mercurial > projects > dwt-samples
annotate snippets/spinner/Snippet190.d @ 120:1f0a7a472680
fix rm snippets from module statements.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 20 Jul 2008 19:17:23 +0200 |
parents | 4a04b6759f98 |
children |
rev | line source |
---|---|
78 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2005 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 * Port to the D programming language: | |
11 * Bill Baxter <bill@billbaxter.com> | |
12 *******************************************************************************/ | |
120
1f0a7a472680
fix rm snippets from module statements.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
13 module spinner.Snippet190; |
78 | 14 |
15 import dwt.DWT; | |
16 import dwt.widgets.Display; | |
17 import dwt.widgets.Shell; | |
18 import dwt.widgets.Spinner; | |
19 import dwt.events.SelectionAdapter; | |
20 import dwt.events.SelectionEvent; | |
21 import dwt.layout.GridLayout; | |
22 | |
23 import Math = tango.math.Math; | |
24 import tango.io.Stdout; | |
25 | |
26 /* | |
27 * Floating point values in Spinner | |
28 * | |
29 * For a list of all DWT example snippets see | |
30 * http://www.eclipse.org/swt/snippets/ | |
31 * | |
32 * @since 3.1 | |
33 */ | |
34 | |
35 void main () { | |
36 Display display = new Display (); | |
37 Shell shell = new Shell (display); | |
38 shell.setText("Spinner with float values"); | |
39 shell.setLayout(new GridLayout()); | |
40 final Spinner spinner = new Spinner(shell, DWT.NONE); | |
41 // allow 3 decimal places | |
42 spinner.setDigits(3); | |
43 // set the minimum value to 0.001 | |
44 spinner.setMinimum(1); | |
45 // set the maximum value to 20 | |
46 spinner.setMaximum(20000); | |
47 // set the increment value to 0.010 | |
48 spinner.setIncrement(10); | |
49 // set the seletion to 3.456 | |
50 spinner.setSelection(3456); | |
51 spinner.addSelectionListener(new class() SelectionAdapter { | |
52 public void widgetSelected(SelectionEvent e) { | |
53 int selection = spinner.getSelection(); | |
54 float digits = spinner.getDigits(); | |
55 Stdout.formatln("Selection is {}", selection / Math.pow(10.f, digits)); | |
56 } | |
57 }); | |
58 shell.setSize(200, 200); | |
59 shell.open(); | |
60 while (!shell.isDisposed ()) { | |
61 if (!display.readAndDispatch ()) display.sleep (); | |
62 } | |
63 display.dispose (); | |
64 } |