Mercurial > projects > dwt-samples
comparison jface.text/Simple.d @ 173:33d9146198b2
minor edits in jface text example
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 26 Oct 2008 14:53:07 +0100 |
parents | 9a850c264e3b |
children |
comparison
equal
deleted
inserted
replaced
172:d36bf485a753 | 173:33d9146198b2 |
---|---|
1 module test; | 1 module test; |
2 | 2 |
3 import dwt.DWT; | 3 import dwt.std; |
4 import dwt.layout.FillLayout; | |
5 import dwt.widgets.Composite; | |
6 import dwt.widgets.Control; | |
7 import dwt.widgets.Display; | |
8 import dwt.widgets.Shell; | |
9 import dwtx.jface.text.Document; | 4 import dwtx.jface.text.Document; |
10 import dwtx.jface.text.source.CompositeRuler; | 5 import dwtx.jface.text.source.CompositeRuler; |
11 import dwtx.jface.text.source.LineNumberRulerColumn; | 6 import dwtx.jface.text.source.LineNumberRulerColumn; |
12 import dwtx.jface.text.source.AnnotationRulerColumn; | 7 import dwtx.jface.text.source.AnnotationRulerColumn; |
13 import dwtx.jface.text.source.SourceViewer; | 8 import dwtx.jface.text.source.SourceViewer; |
14 import dwtx.jface.window.ApplicationWindow; | 9 import dwtx.jface.window.ApplicationWindow; |
15 | 10 |
16 version(JIVE) import jive.stacktrace; | 11 version(JIVE) import jive.stacktrace; |
17 | 12 |
18 class SourceViewerTest : ApplicationWindow | 13 const char[] startText = `void main() |
19 { | 14 { |
20 this() | 15 ApplicationWindow w = new SourceViewerTest(); |
21 { | 16 w.setBlockOnOpen( true ); |
17 w.open(); | |
18 Display.getCurrent.dispose(); | |
19 } | |
20 `; | |
21 | |
22 class SourceViewerTest : ApplicationWindow { | |
23 this() { | |
22 super( null ); | 24 super( null ); |
23 } | 25 } |
24 | 26 |
25 protected Control createContents( Composite parent ) | 27 protected Control createContents( Composite parent ) { |
26 { | |
27 getShell.setText( "SourceViewerTest" ); | 28 getShell.setText( "SourceViewerTest" ); |
28 getShell.setSize( 350, 400 ); | 29 getShell.setSize( 350, 400 ); |
29 Display disp = getShell.getDisplay(); | 30 Display disp = getShell.getDisplay(); |
30 Composite container = new Composite( parent, DWT.NONE ); | 31 Composite container = new Composite( parent, DWT.NONE ); |
31 container.setLayout( new FillLayout() ); | 32 container.setLayout( new FillLayout() ); |
35 LineNumberRulerColumn lineCol = new LineNumberRulerColumn(); | 36 LineNumberRulerColumn lineCol = new LineNumberRulerColumn(); |
36 lineCol.setBackground( disp.getSystemColor( DWT.COLOR_GRAY ) ); | 37 lineCol.setBackground( disp.getSystemColor( DWT.COLOR_GRAY ) ); |
37 lineCol.setForeground( disp.getSystemColor( DWT.COLOR_BLUE ) ); | 38 lineCol.setForeground( disp.getSystemColor( DWT.COLOR_BLUE ) ); |
38 ruler.addDecorator( 0, lineCol ); | 39 ruler.addDecorator( 0, lineCol ); |
39 | 40 |
40 Document doc = new Document( `void main() | 41 Document doc = new Document( startText ); |
41 { | |
42 ApplicationWindow w = new SourceViewerTest(); | |
43 w.setBlockOnOpen( true ); | |
44 w.open(); | |
45 Display.getCurrent.dispose(); | |
46 } | |
47 ` ); | |
48 | 42 |
49 SourceViewer sv = new SourceViewer( container, ruler, DWT.BORDER | DWT.H_SCROLL | DWT.V_SCROLL ); | 43 SourceViewer sv = new SourceViewer( container, ruler, DWT.BORDER | DWT.H_SCROLL | DWT.V_SCROLL ); |
50 sv.setDocument( doc ); | 44 sv.setDocument( doc ); |
51 | 45 |
52 return container; | 46 return container; |
53 } | 47 } |
54 } | 48 } |
55 | 49 |
56 void main() | 50 void main() { |
57 { | |
58 ApplicationWindow w = new SourceViewerTest(); | 51 ApplicationWindow w = new SourceViewerTest(); |
59 w.setBlockOnOpen( true ); | 52 w.setBlockOnOpen( true ); |
60 w.open(); | 53 w.open(); |
61 Display.getCurrent.dispose(); | 54 Display.getCurrent.dispose(); |
62 } | 55 } |
65 | 58 |
66 | 59 |
67 | 60 |
68 | 61 |
69 | 62 |
70 |