SciGUIConsole.java

Go to the documentation of this file.
00001 import org.eclipse.swt.SWT;
00002 import org.eclipse.swt.events.*;
00003 import org.eclipse.swt.graphics.Image;
00004 import org.eclipse.swt.widgets.*;
00005 
00006 
00007 class SciGUIConsole
00008 {  
00009         private Display display;
00010   private Shell shell;
00011   private Text textouput;
00012   private Text textinput;
00013   private boolean IsEnabled;
00014 /*---------------------------------------------------------------------------------------------*/    
00015         SciGUIConsole()
00016         {
00017                 IsEnabled=false;
00018         }
00019 /*---------------------------------------------------------------------------------------------*/    
00020 public void Initialize()
00021 {
00022         display = new Display( );
00023   shell = new Shell(display);
00024   shell.pack ();
00025   shell.setSize(620,520);
00026   shell.setText("Scilab 5.0");
00027   
00028   textouput = new Text(shell, SWT.MULTI | SWT.V_SCROLL |   SWT.H_SCROLL | SWT.BORDER | SWT.WRAP |SWT.READ_ONLY);
00029   textouput.setBounds(10,10,600,230);
00030   
00031   textinput = new Text(shell, SWT.MULTI | SWT.V_SCROLL |   SWT.H_SCROLL | SWT.BORDER);
00032   textinput.setBounds(10,275,600,200);
00033   
00034   textinput.addTraverseListener(new TraverseListener() {
00035                 public void keyTraversed(TraverseEvent e) {
00036                         if (e.detail == SWT.TRAVERSE_RETURN ) 
00037                         {
00038                                 System.out.println (textinput.getText());
00039                                 textinput.setText("");
00040                                 System.out.println ("number lines: "+textinput.getLineCount());
00041                                 
00042                         }
00043                 }
00044         });
00045   
00046         shell.open( );
00047         IsEnabled=true;
00048                 
00049 
00050         
00051 }
00052 /*---------------------------------------------------------------------------------------------*/  
00053 public void EventsLoop()
00054 {
00055         while(!shell.isDisposed( ))
00056   {
00057         if(!display.readAndDispatch( )) display.sleep( );
00058   }
00059   dispose();
00060 }
00061 /*---------------------------------------------------------------------------------------------*/
00062 public void dispose()
00063 {
00064         display.dispose( );
00065 }
00066 /*---------------------------------------------------------------------------------------------*/
00067 public boolean IsEnabled()
00068 {
00069         return IsEnabled;
00070 }
00071 /*---------------------------------------------------------------------------------------------*/
00072 public void PutString(final String Str)
00073 {
00074         display.syncExec (new Runnable () 
00075         {
00076                 public void run ()
00077                 {
00078                         textouput.append(Str);
00079                 }
00080         }); 
00081 }
00082 /*---------------------------------------------------------------------------------------------*/
00083 
00084 }

Generated on Sun Mar 4 15:03:54 2007 for Scilab [trunk] by  doxygen 1.5.1