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 * D Port:
|
|
11 * Jesse Phillips <Jesse.K.Phillips+D> gmail.com
|
|
12 *******************************************************************************/
|
|
13
|
|
14 module snippets.styledtext.Snippet189;
|
|
15
|
|
16 /*
|
|
17 * Text with underline and strike through
|
|
18 *
|
|
19 * For a list of all SWT example snippets see
|
|
20 * http://www.eclipse.org/swt/snippets/
|
|
21 *
|
|
22 * @since 3.1
|
|
23 */
|
|
24
|
|
25 import dwt.DWT;
|
|
26 import dwt.custom.StyledText;
|
|
27 import dwt.custom.StyleRange;
|
|
28 import dwt.layout.FillLayout;
|
|
29 import dwt.widgets.Display;
|
|
30 import dwt.widgets.Shell;
|
|
31
|
|
32 void main () {
|
|
33 auto display = new Display ();
|
|
34 auto shell = new Shell (display);
|
|
35 shell.setText("StyledText with underline and strike through");
|
|
36 shell.setLayout(new FillLayout());
|
|
37 auto text = new StyledText (shell, DWT.BORDER);
|
|
38 text.setText("0123456789 ABCDEFGHIJKLM NOPQRSTUVWXYZ");
|
|
39 // make 0123456789 appear underlined
|
|
40 auto style1 = new StyleRange();
|
|
41 style1.start = 0;
|
|
42 style1.length = 10;
|
|
43 style1.underline = true;
|
|
44 text.setStyleRange(style1);
|
|
45 // make ABCDEFGHIJKLM have a strike through
|
|
46 auto style2 = new StyleRange();
|
|
47 style2.start = 11;
|
|
48 style2.length = 13;
|
|
49 style2.strikeout = true;
|
|
50 text.setStyleRange(style2);
|
|
51 // make NOPQRSTUVWXYZ appear underlined and have a strike through
|
|
52 auto style3 = new StyleRange();
|
|
53 style3.start = 25;
|
|
54 style3.length = 13;
|
|
55 style3.underline = true;
|
|
56 style3.strikeout = true;
|
|
57 text.setStyleRange(style3);
|
|
58 shell.pack();
|
|
59 shell.open();
|
|
60 while (!shell.isDisposed ()) {
|
|
61 if (!display.readAndDispatch ()) display.sleep ();
|
|
62 }
|
|
63 display.dispose ();
|
|
64 }
|