gnu.jemacs.swt
Class SwtHelper

java.lang.Object
  extended by gnu.jemacs.swt.SwtHelper

public class SwtHelper
extends java.lang.Object

A Class to act as a layer between SwtJemacs and SWT. SWT requires that (almost) all calls to widget methods and constructors happen in the GUI event loop thread. On the other hand it should be possible in JEmacs/Kawa to create new threads and call functions that may, in turn, call SwtJemacs. Therefore we must have this layer between SwtJemacs and SWT. Each method in this class will make sure it is executed in the GUI loop thread.


Nested Class Summary
static class SwtHelper.Resultable
          A variant of Runnable to be used in Display.syncExec when the caller wants to retrive the result.
 
Constructor Summary
SwtHelper()
           
 
Method Summary
static void dispose(org.eclipse.swt.widgets.Menu menubar)
          Calls menubar.dispose()
static org.eclipse.swt.graphics.Rectangle getArea(org.eclipse.swt.custom.StyledText styledText)
           
static int getCaretOffset(org.eclipse.swt.custom.StyledText styledText)
           
static org.eclipse.swt.widgets.Display getDisplay()
           
static int getLineHeight(org.eclipse.swt.custom.StyledText styledText)
           
static org.eclipse.swt.widgets.Composite getParent(org.eclipse.swt.widgets.Control control)
           
static int getTopIndex(org.eclipse.swt.custom.StyledText styledText)
           
static void injectSashFormAsParent(org.eclipse.swt.widgets.Control child, int style)
           
static void layout(org.eclipse.swt.widgets.Composite composite)
           
static org.eclipse.swt.widgets.Menu newMenu(org.eclipse.swt.widgets.MenuItem menuItem)
          Creates a new Menu inside a MenuItem.
static org.eclipse.swt.widgets.Menu newMenu(org.eclipse.swt.widgets.Shell shell, int bar)
          Creates a new menu bar for a shelln
static org.eclipse.swt.widgets.MenuItem newMenuItem(org.eclipse.swt.widgets.Menu parent, int style, java.lang.String text, org.eclipse.swt.events.SelectionListener selectionListener)
          Creates a new MenuItem.
static org.eclipse.swt.custom.SashForm newSashForm(org.eclipse.swt.widgets.Composite parent, int style)
           
static org.eclipse.swt.widgets.Shell newShell(org.eclipse.swt.widgets.Display display, org.eclipse.swt.layout.FillLayout layout)
           
static org.eclipse.swt.custom.StyledText newStyledText(org.eclipse.swt.widgets.Composite parent, int style, org.eclipse.swt.custom.StyledTextContent styledTextContent, SwtWindow swtWindow, int firstVisibleLine)
          Creates a StyledText instance with a given content, and an SwtWindow which will be installed as VerifyKeylistener, FocusListener, KeyListener and Mouselistener
static void redraw(org.eclipse.swt.widgets.Control control)
           
static void setCaretOffset(org.eclipse.swt.custom.StyledText styledText, int offset)
           
static void setContent(org.eclipse.swt.custom.StyledText styledText, org.eclipse.swt.custom.StyledTextContent bufferContent)
           
static void setMenu(org.eclipse.swt.widgets.MenuItem menuItem, org.eclipse.swt.widgets.Menu subMenu)
           
static void setMenuBar(org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.widgets.Menu menubar)
          Sets a menu bar for a shell.
static void setParent(org.eclipse.swt.widgets.Control control, org.eclipse.swt.widgets.Composite parent)
           
static void setWeights(org.eclipse.swt.custom.SashForm form, int[] weights)
           
static void showSelection(org.eclipse.swt.custom.StyledText styledText)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwtHelper

public SwtHelper()
Method Detail

dispose

public static void dispose(org.eclipse.swt.widgets.Menu menubar)
Calls menubar.dispose()

Parameters:
menubar - The menu to dispose

newMenu

public static org.eclipse.swt.widgets.Menu newMenu(org.eclipse.swt.widgets.Shell shell,
                                                   int bar)
Creates a new menu bar for a shelln


newMenu

public static org.eclipse.swt.widgets.Menu newMenu(org.eclipse.swt.widgets.MenuItem menuItem)
Creates a new Menu inside a MenuItem.


newMenuItem

public static org.eclipse.swt.widgets.MenuItem newMenuItem(org.eclipse.swt.widgets.Menu parent,
                                                           int style,
                                                           java.lang.String text,
                                                           org.eclipse.swt.events.SelectionListener selectionListener)
Creates a new MenuItem.


setMenuBar

public static void setMenuBar(org.eclipse.swt.widgets.Shell shell,
                              org.eclipse.swt.widgets.Menu menubar)
Sets a menu bar for a shell. The menu must have been created with the shell as parent


setMenu

public static void setMenu(org.eclipse.swt.widgets.MenuItem menuItem,
                           org.eclipse.swt.widgets.Menu subMenu)

newShell

public static org.eclipse.swt.widgets.Shell newShell(org.eclipse.swt.widgets.Display display,
                                                     org.eclipse.swt.layout.FillLayout layout)

newStyledText

public static org.eclipse.swt.custom.StyledText newStyledText(org.eclipse.swt.widgets.Composite parent,
                                                              int style,
                                                              org.eclipse.swt.custom.StyledTextContent styledTextContent,
                                                              SwtWindow swtWindow,
                                                              int firstVisibleLine)
Creates a StyledText instance with a given content, and an SwtWindow which will be installed as VerifyKeylistener, FocusListener, KeyListener and Mouselistener


getTopIndex

public static int getTopIndex(org.eclipse.swt.custom.StyledText styledText)

getCaretOffset

public static int getCaretOffset(org.eclipse.swt.custom.StyledText styledText)

getParent

public static org.eclipse.swt.widgets.Composite getParent(org.eclipse.swt.widgets.Control control)

getArea

public static org.eclipse.swt.graphics.Rectangle getArea(org.eclipse.swt.custom.StyledText styledText)

getLineHeight

public static int getLineHeight(org.eclipse.swt.custom.StyledText styledText)

setCaretOffset

public static void setCaretOffset(org.eclipse.swt.custom.StyledText styledText,
                                  int offset)

setContent

public static void setContent(org.eclipse.swt.custom.StyledText styledText,
                              org.eclipse.swt.custom.StyledTextContent bufferContent)

showSelection

public static void showSelection(org.eclipse.swt.custom.StyledText styledText)

redraw

public static void redraw(org.eclipse.swt.widgets.Control control)

newSashForm

public static org.eclipse.swt.custom.SashForm newSashForm(org.eclipse.swt.widgets.Composite parent,
                                                          int style)

setParent

public static void setParent(org.eclipse.swt.widgets.Control control,
                             org.eclipse.swt.widgets.Composite parent)

injectSashFormAsParent

public static void injectSashFormAsParent(org.eclipse.swt.widgets.Control child,
                                          int style)

setWeights

public static void setWeights(org.eclipse.swt.custom.SashForm form,
                              int[] weights)

layout

public static void layout(org.eclipse.swt.widgets.Composite composite)

getDisplay

public static org.eclipse.swt.widgets.Display getDisplay()