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(Menu menubar)
          Calls menubar.dispose()
static Rectangle getArea(StyledText styledText)
           
static int getCaretOffset(StyledText styledText)
           
static Display getDisplay()
           
static int getLineHeight(StyledText styledText)
           
static Composite getParent(Control control)
           
static int getTopIndex(StyledText styledText)
           
static void injectSashFormAsParent(Control child, int style)
           
static void layout(Composite composite)
           
static Menu newMenu(MenuItem menuItem)
          Creates a new Menu inside a MenuItem.
static Menu newMenu(Shell shell, int bar)
          Creates a new menu bar for a shelln
static MenuItem newMenuItem(Menu parent, int style, java.lang.String text, SelectionListener selectionListener)
          Creates a new MenuItem.
static SashForm newSashForm(Composite parent, int style)
           
static Shell newShell(Display display, FillLayout layout)
           
static StyledText newStyledText(Composite parent, int style, 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(Control control)
           
static void setCaretOffset(StyledText styledText, int offset)
           
static void setContent(StyledText styledText, StyledTextContent bufferContent)
           
static void setMenu(MenuItem menuItem, Menu subMenu)
           
static void setMenuBar(Shell shell, Menu menubar)
          Sets a menu bar for a shell.
static void setParent(Control control, Composite parent)
           
static void setWeights(SashForm form, int[] weights)
           
static void showSelection(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(Menu menubar)
Calls menubar.dispose()

Parameters:
menubar - The menu to dispose

newMenu

public static Menu newMenu(Shell shell,
                           int bar)
Creates a new menu bar for a shelln


newMenu

public static Menu newMenu(MenuItem menuItem)
Creates a new Menu inside a MenuItem.


newMenuItem

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


setMenuBar

public static void setMenuBar(Shell shell,
                              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(MenuItem menuItem,
                           Menu subMenu)

newShell

public static Shell newShell(Display display,
                             FillLayout layout)

newStyledText

public static StyledText newStyledText(Composite parent,
                                       int style,
                                       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(StyledText styledText)

getCaretOffset

public static int getCaretOffset(StyledText styledText)

getParent

public static Composite getParent(Control control)

getArea

public static Rectangle getArea(StyledText styledText)

getLineHeight

public static int getLineHeight(StyledText styledText)

setCaretOffset

public static void setCaretOffset(StyledText styledText,
                                  int offset)

setContent

public static void setContent(StyledText styledText,
                              StyledTextContent bufferContent)

showSelection

public static void showSelection(StyledText styledText)

redraw

public static void redraw(Control control)

newSashForm

public static SashForm newSashForm(Composite parent,
                                   int style)

setParent

public static void setParent(Control control,
                             Composite parent)

injectSashFormAsParent

public static void injectSashFormAsParent(Control child,
                                          int style)

setWeights

public static void setWeights(SashForm form,
                              int[] weights)

layout

public static void layout(Composite composite)

getDisplay

public static Display getDisplay()