comparison snippets/styledtext/Snippet163.d @ 78:4a04b6759f98

Clean up directory names
author John Reimer <terminal.node@gmail.com>
date Sat, 10 May 2008 13:32:45 -0700
parents
children 1f0a7a472680
comparison
equal deleted inserted replaced
76:04f122e90b0a 78:4a04b6759f98
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 * Port to the D programming language:
11 * Jesse Phillips <Jesse.K.Phillips+D> gmail.com
12 *******************************************************************************/
13
14 module snippets.styledtext.Snippet163;
15
16 /*
17 * Setting the font style, foreground and background colors of StyledText
18 *
19 * For a list of all SWT example snippets see
20 * http://www.eclipse.org/swt/snippets/
21 */
22 import dwt.DWT;
23 import dwt.custom.StyledText;
24 import dwt.custom.StyleRange;
25 import dwt.layout.FillLayout;
26 import dwt.widgets.Display;
27 import dwt.widgets.Shell;
28
29 version(JIVE){
30 import jive.stacktrace;
31 }
32
33 void main() {
34 auto display = new Display();
35 auto shell = new Shell(display);
36 shell.setLayout(new FillLayout());
37 auto text = new StyledText (shell, DWT.BORDER);
38 text.setText("0123456789 ABCDEFGHIJKLM NOPQRSTUVWXYZ");
39 // make 0123456789 appear bold
40 auto style1 = new StyleRange();
41 style1.start = 0;
42 style1.length = 10;
43 style1.fontStyle = DWT.BOLD;
44 text.setStyleRange(style1);
45 // make ABCDEFGHIJKLM have a red font
46 auto style2 = new StyleRange();
47 style2.start = 11;
48 style2.length = 13;
49 style2.foreground = display.getSystemColor(DWT.COLOR_RED);
50 text.setStyleRange(style2);
51 // make NOPQRSTUVWXYZ have a blue background
52 auto style3 = new StyleRange();
53 style3.start = 25;
54 style3.length = 13;
55 style3.background = display.getSystemColor(DWT.COLOR_BLUE);
56 text.setStyleRange(style3);
57
58 shell.pack();
59 shell.open();
60 while (!shell.isDisposed()) {
61 if (!display.readAndDispatch())
62 display.sleep();
63 }
64 display.dispose();
65 }