Mercurial > projects > dwt-samples
diff jface.text/Simple.d @ 169:9a850c264e3b
Add JFace Text example
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 26 Oct 2008 14:00:52 +0100 |
parents | |
children | 33d9146198b2 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jface.text/Simple.d Sun Oct 26 14:00:52 2008 +0100 @@ -0,0 +1,70 @@ +module test; + +import dwt.DWT; +import dwt.layout.FillLayout; +import dwt.widgets.Composite; +import dwt.widgets.Control; +import dwt.widgets.Display; +import dwt.widgets.Shell; +import dwtx.jface.text.Document; +import dwtx.jface.text.source.CompositeRuler; +import dwtx.jface.text.source.LineNumberRulerColumn; +import dwtx.jface.text.source.AnnotationRulerColumn; +import dwtx.jface.text.source.SourceViewer; +import dwtx.jface.window.ApplicationWindow; + +version(JIVE) import jive.stacktrace; + +class SourceViewerTest : ApplicationWindow +{ + this() + { + super( null ); + } + + protected Control createContents( Composite parent ) + { + getShell.setText( "SourceViewerTest" ); + getShell.setSize( 350, 400 ); + Display disp = getShell.getDisplay(); + Composite container = new Composite( parent, DWT.NONE ); + container.setLayout( new FillLayout() ); + + CompositeRuler ruler = new CompositeRuler(); + + LineNumberRulerColumn lineCol = new LineNumberRulerColumn(); + lineCol.setBackground( disp.getSystemColor( DWT.COLOR_GRAY ) ); + lineCol.setForeground( disp.getSystemColor( DWT.COLOR_BLUE ) ); + ruler.addDecorator( 0, lineCol ); + + Document doc = new Document( `void main() +{ + ApplicationWindow w = new SourceViewerTest(); + w.setBlockOnOpen( true ); + w.open(); + Display.getCurrent.dispose(); +} +` ); + + SourceViewer sv = new SourceViewer( container, ruler, DWT.BORDER | DWT.H_SCROLL | DWT.V_SCROLL ); + sv.setDocument( doc ); + + return container; + } +} + +void main() +{ + ApplicationWindow w = new SourceViewerTest(); + w.setBlockOnOpen( true ); + w.open(); + Display.getCurrent.dispose(); +} + + + + + + + +