| 8 | Simple example on WinXp [[br]] |
---|
| 9 | [[Image(http://downloads.dsource.org/projects/dwt/screenshots/win/jface/JFace.Text.SourceViewerTest.png)]] |
---|
| 10 | |
---|
| 11 | Source: |
---|
| 12 | {{{ |
---|
| 13 | #!d |
---|
| 14 | import dwt.std; |
---|
| 15 | import dwtx.jface.text.Document; |
---|
| 16 | import dwtx.jface.text.source.CompositeRuler; |
---|
| 17 | import dwtx.jface.text.source.LineNumberRulerColumn; |
---|
| 18 | import dwtx.jface.text.source.AnnotationRulerColumn; |
---|
| 19 | import dwtx.jface.text.source.SourceViewer; |
---|
| 20 | import dwtx.jface.window.ApplicationWindow; |
---|
| 21 | |
---|
| 22 | version(JIVE) import jive.stacktrace; |
---|
| 23 | |
---|
| 24 | const char[] startText = `void main() |
---|
| 25 | { |
---|
| 26 | ApplicationWindow w = new SourceViewerTest(); |
---|
| 27 | w.setBlockOnOpen( true ); |
---|
| 28 | w.open(); |
---|
| 29 | Display.getCurrent.dispose(); |
---|
| 30 | } |
---|
| 31 | `; |
---|
| 32 | |
---|
| 33 | class SourceViewerTest : ApplicationWindow { |
---|
| 34 | this() { |
---|
| 35 | super( null ); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | protected Control createContents( Composite parent ) { |
---|
| 39 | getShell.setText( "SourceViewerTest" ); |
---|
| 40 | getShell.setSize( 350, 400 ); |
---|
| 41 | Display disp = getShell.getDisplay(); |
---|
| 42 | Composite container = new Composite( parent, DWT.NONE ); |
---|
| 43 | container.setLayout( new FillLayout() ); |
---|
| 44 | |
---|
| 45 | CompositeRuler ruler = new CompositeRuler(); |
---|
| 46 | |
---|
| 47 | LineNumberRulerColumn lineCol = new LineNumberRulerColumn(); |
---|
| 48 | lineCol.setBackground( disp.getSystemColor( DWT.COLOR_GRAY ) ); |
---|
| 49 | lineCol.setForeground( disp.getSystemColor( DWT.COLOR_BLUE ) ); |
---|
| 50 | ruler.addDecorator( 0, lineCol ); |
---|
| 51 | |
---|
| 52 | Document doc = new Document( startText ); |
---|
| 53 | |
---|
| 54 | SourceViewer sv = new SourceViewer( container, ruler, DWT.BORDER | DWT.H_SCROLL | DWT.V_SCROLL ); |
---|
| 55 | sv.setDocument( doc ); |
---|
| 56 | |
---|
| 57 | return container; |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | void main() { |
---|
| 62 | ApplicationWindow w = new SourceViewerTest(); |
---|
| 63 | w.setBlockOnOpen( true ); |
---|
| 64 | w.open(); |
---|
| 65 | Display.getCurrent.dispose(); |
---|
| 66 | } |
---|
| 67 | }}} |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | |