ewe.ui
Class Gui

java.lang.Object
  extended byewe.ui.Gui
All Implemented Interfaces:
CellConstants, ControlConstants, UIConstants

public class Gui
extends Object
implements UIConstants


Field Summary
static int BIG_SCREEN
          A possible flag for screenIs.
static int CENTER_FRAME
           
static int DESKTOP_HEIGHT
          A possible flag for screenIs.
static int DESKTOP_SCREEN
          A possible flag for screenIs.
static int DESKTOP_WIDTH
          A possible flag for screenIs.
static boolean dontPaintNextFrame
           
static int FILL_FRAME
           
static int FILL_HEIGHT
          This should not be OR'ed with FILL_WIDTH.
static int FILL_WIDTH
          This should not be OR'ed with FILL_HEIGHT.
static int FLASH_BEEP
          An option for flashMessage.
static Rect fullScreen
           
static boolean hasKeyboard
           
static boolean hasMousePointer
           
static boolean hasPen
           
protected static Vector inFocus
           
static boolean isPDA
           
static boolean isSmartPhone
           
static int LONG_SCREEN
          A possible flag for screenIs.
static int NEW_WINDOW
           
static boolean noHotLabels
          By default, this is set to: !hasKeyboard || isSmartPhone || isPDA
static boolean NullParentFrameToMainApp
          If you show/exec a Frame with a null parent frame then if NullParentFrameToMainApp is true, it will use the main frame of the mApp of the program.
static int PDA_SCREEN
          A possible flag for screenIs.
static int PUTTING_POPUP
           
static Rect rp
           
static Rect screenSize
          This is the size of the user's screen, but will not be set until the screenIs() method is called.
static boolean sendFrameOnTopEvents
          Set this true if you wish to send FrameEvent.NOT_ON_TOP and FrameEvent.NOW_ON_TOP events.
static int STYLE_3D
          Used with setStyle.
static int STYLE_ETCHED
          Used with setStyle.
static int STYLE_PALM
          Used with setStyle.
static int STYLE_SOFT
          Used with setStyle.
static int WIDE_SCREEN
          A possible flag for screenIs.
 
Fields inherited from interface ewe.ui.UIConstants
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_BOTTOM, BF_BOTTOMLEFT, BF_BOTTOMRIGHT, BF_BUTTON, BF_DIAGONAL, BF_DIAGONAL_ENDBOTTOMLEFT, BF_DIAGONAL_ENDBOTTOMRIGHT, BF_DIAGONAL_ENDTOPLEFT, BF_DIAGONAL_ENDTOPRIGHT, BF_EXACT, BF_FLAT, BF_LEFT, BF_MIDDLE, BF_MONO, BF_PALM, BF_RECT, BF_RIGHT, BF_SOFT, BF_SQUARE, BF_TOP, BF_TOPLEFT, BF_TOPRIGHT, EDGE_BUMP, EDGE_ETCHED, EDGE_RAISED, EDGE_SUNKEN
 
Fields inherited from interface ewe.ui.CellConstants
BORDER, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, FIXEDSIZE, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
 
Fields inherited from interface ewe.ui.ControlConstants
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, Disabled, DisablePopupMenu, DisplayOnly, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpKeyEvents, SendUpPenEvents, ShowSIP, ShrinkToNothing, SmallControl, SpecialBackground, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown
 
Constructor Summary
Gui()
           
 
Method Summary
static void captureControl(Control ct, Graphics dest, Rect dim)
           
static Point centerText(FontMetrics fm, String st, int width, int height)
           
protected static Container checkParent(Container parent, int options)
           
static boolean closePopups(Control window)
          Close all Frames denoted as popup frames in the Window containing the control.
static boolean closePopups(Control window, int why, int flags)
           
static int decodeAlignment(String specs)
           
static int decodeAnchor(String specs)
           
protected static void doExecFrame(Frame f, Container parent, int options)
           
static void execFrame(Frame f, Container parent)
           
static void execFrame(Frame f, Container parent, int options)
          This will add the frame to the container and call a make() on it.
static int fixShowOptions(Container parent, int options)
           
static void flashMessage(String message, Control parent)
           
static void flashMessage(String message, int timeInMillis, Control parent, int flash_options)
           
static void flashMessageOff(Object message)
          Remove the short message as displayed by flashMessageOn().
static Object flashMessageOn(String message, Control parent)
          Display a short message on the screen, and keep it on the screen until flashMessageOff() is called.
static Control focusedControl()
           
static void frameOnTop(Control c)
           
static Rect getAppRect(Control ct)
           
static Rect getAppRect(Control ct, Rect dest)
          This gets the rect of the control relative to the top left of the controls containing window.
static Rect getAverageSize(FontMetrics fm, int rows, int columns, int xGap, int yGap)
           
static Graphics getGraphics(Window window)
          This gets a Graphics object for a window.
static int getGuiFlags()
           
static char getHotKeyFrom(String text)
          Given text in the format "Text$hotkey" this returns the hotkey character.
static Frame getPopupMenuParentFrame(Control c)
          This returns the parent frame for a control's popup menu.
static Point getPosInParent(Control c, Container parent)
           
static Dimension getPreferredDialogSize()
           
static Rect getRectInWindow(Control ct, Rect dest, boolean onlyIfVisible)
          This gets the rect of the control relative to the top left of the controls containing window.
static Rect getRectInWindow(Control ct, Rect dest, boolean onlyIfVisible, Point actualPosition)
          This gets the rect of the control relative to the top left of the controls containing window.
static Rect getSize(FontMetrics fm, String[] lines, int xGap, int yGap)
           
static Rect getSize(FontMetrics fm, String st, int xGap, int yGap)
           
static StyleManager getStyleManager()
          Return the current pluggable look and feel style manager.
static String getTextFrom(String text)
          Given text in the format "Text$hotkey" this returns the text string without the hotkey character.
static void hideFrame(Frame f)
           
static boolean iconize(Control c, IImage image, boolean leaveText, FontMetrics fm)
          This will iconize a button/control that has its text already set.
static boolean iconize(Control c, String image, Object maskOrColor, boolean leaveText, FontMetrics fm)
          This will iconize a button/control that has its text already set.
static boolean isWindowFrame(Frame f)
          This returns true if the Frame is the main frame of a window.
static String makeHot(String label)
          Convert a '$' formatted hotkey into a "true" hotkey encoded String.
static String makeHot(String label, int hotKey)
          Convert a string with a hotkey to be a "true" hotkey encoded String which, when displayed by a Graphics object, will have its hotkey underlined.
static void moveFrameTo(Frame f, Rect where)
           
static boolean pressedOutsideTopFrame(Control onWho, Point whereOnWho)
           
static void refreshScreen(Control c)
           
static void refreshScreen(Window w)
           
static void refreshScreen(Window w, Rect area)
           
static void refreshTopFrame(Control who)
           
static void relayoutFrameAndWindow(Frame f, boolean overrideMaximize)
          This method does a relayout and resize on a Frame and its containing Window (if the Frame contained within a native Window).
static void removeFrom(Container c, Control ctrl)
           
static boolean requestPaint(Control who)
           
static SavedScreen saveScreen(Window w, Rect area, boolean doCapture)
           
static boolean screenIs(int flags)
          Check if the user screen is of a certain type.
static void screenResized(int width, int height)
           
static void setAllParentFrame(Frame f)
          Set the system to believe that multiple windows are not possible and that all new Frames should be shown in the specified Frame.
static void setAppFormTitle(Form form, String title)
          This will setup an the title bar on a Form if the main ewe window does not have a title and a close button.
static void setFormTitle(Window w, Form form, String title)
          This will setup an the title bar on a Form if the main ewe window does not have a title and a close button.
static void setNoMultipleWindows()
          This forces the system to act as if multiple windows are not supported.
static void setOKCancel(Form f)
          This will set the OK/Cancel of a form to be either in the title bar (for mobile devices) or on the bottom for desktop devices.
static void setStyle(int style)
          Set the style of Controls within an application.
static boolean setStyleManager(StyleManager manager)
          Set a pluggable look and feel style manager for the GUI components.
protected static Container setupNewWindow(Frame f, Container parent, boolean modal)
           
static void showFrame(Frame f, Container parent)
           
static void showFrame(Frame f, Container parent, int options)
          This will add the frame to the container and call a make() on it.
static void takeFocus(Control c, int how)
          This tells the Gui to assign focus to a particular control.
static Frame topFrame(Control who)
           
static Rect visibleWindowClientArea(Control who)
          This returns the area on the Window of the control that is not obscured by the SIP.
static Frame windowFrame(Control who)
          This returns the very top frame in a window.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

NullParentFrameToMainApp

public static boolean NullParentFrameToMainApp
If you show/exec a Frame with a null parent frame then if NullParentFrameToMainApp is true, it will use the main frame of the mApp of the program. Otherwise it will show the Frame in a new window. By default it is true.


fullScreen

public static Rect fullScreen

sendFrameOnTopEvents

public static boolean sendFrameOnTopEvents
Set this true if you wish to send FrameEvent.NOT_ON_TOP and FrameEvent.NOW_ON_TOP events.


CENTER_FRAME

public static final int CENTER_FRAME
See Also:
Constant Field Values

FILL_FRAME

public static final int FILL_FRAME
See Also:
Constant Field Values

FILL_WIDTH

public static final int FILL_WIDTH
This should not be OR'ed with FILL_HEIGHT. Use FILL_FRAME instead.

See Also:
Constant Field Values

FILL_HEIGHT

public static final int FILL_HEIGHT
This should not be OR'ed with FILL_WIDTH. Use FILL_FRAME instead.

See Also:
Constant Field Values

NEW_WINDOW

public static final int NEW_WINDOW
See Also:
Constant Field Values

PUTTING_POPUP

public static final int PUTTING_POPUP
See Also:
Constant Field Values

dontPaintNextFrame

public static boolean dontPaintNextFrame

inFocus

protected static Vector inFocus

screenSize

public static Rect screenSize
This is the size of the user's screen, but will not be set until the screenIs() method is called. You can always get the size of the screen by doing:
 Rect s = (Rect)Window.getGuiInfo(Window.INFO_SCREEN_RECT,null,new Rect(),0);
 


BIG_SCREEN

public static final int BIG_SCREEN
A possible flag for screenIs.

See Also:
Constant Field Values

WIDE_SCREEN

public static final int WIDE_SCREEN
A possible flag for screenIs.

See Also:
Constant Field Values

LONG_SCREEN

public static final int LONG_SCREEN
A possible flag for screenIs.

See Also:
Constant Field Values

DESKTOP_SCREEN

public static final int DESKTOP_SCREEN
A possible flag for screenIs.

See Also:
Constant Field Values

DESKTOP_WIDTH

public static final int DESKTOP_WIDTH
A possible flag for screenIs.

See Also:
Constant Field Values

DESKTOP_HEIGHT

public static final int DESKTOP_HEIGHT
A possible flag for screenIs.

See Also:
Constant Field Values

PDA_SCREEN

public static final int PDA_SCREEN
A possible flag for screenIs.

See Also:
Constant Field Values

rp

public static Rect rp

STYLE_ETCHED

public static final int STYLE_ETCHED
Used with setStyle.

See Also:
Constant Field Values

STYLE_3D

public static final int STYLE_3D
Used with setStyle.

See Also:
Constant Field Values

STYLE_SOFT

public static final int STYLE_SOFT
Used with setStyle.

See Also:
Constant Field Values

STYLE_PALM

public static final int STYLE_PALM
Used with setStyle.

See Also:
Constant Field Values

hasMousePointer

public static boolean hasMousePointer

hasPen

public static boolean hasPen

hasKeyboard

public static boolean hasKeyboard

isSmartPhone

public static boolean isSmartPhone

isPDA

public static boolean isPDA

noHotLabels

public static boolean noHotLabels
By default, this is set to: !hasKeyboard || isSmartPhone || isPDA

but you can change it as you wish.


FLASH_BEEP

public static final int FLASH_BEEP
An option for flashMessage. Will also beep when the message is shown.

See Also:
Constant Field Values
Constructor Detail

Gui

public Gui()
Method Detail

getSize

public static Rect getSize(FontMetrics fm,
                           String st,
                           int xGap,
                           int yGap)

getSize

public static Rect getSize(FontMetrics fm,
                           String[] lines,
                           int xGap,
                           int yGap)

getAverageSize

public static Rect getAverageSize(FontMetrics fm,
                                  int rows,
                                  int columns,
                                  int xGap,
                                  int yGap)

centerText

public static Point centerText(FontMetrics fm,
                               String st,
                               int width,
                               int height)

topFrame

public static Frame topFrame(Control who)

windowFrame

public static Frame windowFrame(Control who)
This returns the very top frame in a window.


visibleWindowClientArea

public static Rect visibleWindowClientArea(Control who)
This returns the area on the Window of the control that is not obscured by the SIP. This is relative to the client area of the Window. If no area is visible it will return null;


frameOnTop

public static void frameOnTop(Control c)

focusedControl

public static Control focusedControl()

doExecFrame

protected static void doExecFrame(Frame f,
                                  Container parent,
                                  int options)

hideFrame

public static void hideFrame(Frame f)

saveScreen

public static SavedScreen saveScreen(Window w,
                                     Rect area,
                                     boolean doCapture)

getRectInWindow

public static Rect getRectInWindow(Control ct,
                                   Rect dest,
                                   boolean onlyIfVisible)
This gets the rect of the control relative to the top left of the controls containing window. If it is not displayabled, then null will be returned. The rect returned may not be the full size of the control as it may be cut off by its parents.


getRectInWindow

public static Rect getRectInWindow(Control ct,
                                   Rect dest,
                                   boolean onlyIfVisible,
                                   Point actualPosition)
This gets the rect of the control relative to the top left of the controls containing window. If it is not displayabled, then null will be returned. The rect returned may not be the full size of the control as it may be cut off by its parents.


getAppRect

public static Rect getAppRect(Control ct,
                              Rect dest)
This gets the rect of the control relative to the top left of the controls containing window.


getAppRect

public static Rect getAppRect(Control ct)

captureControl

public static void captureControl(Control ct,
                                  Graphics dest,
                                  Rect dim)

removeFrom

public static void removeFrom(Container c,
                              Control ctrl)

pressedOutsideTopFrame

public static boolean pressedOutsideTopFrame(Control onWho,
                                             Point whereOnWho)

setupNewWindow

protected static Container setupNewWindow(Frame f,
                                          Container parent,
                                          boolean modal)

setNoMultipleWindows

public static void setNoMultipleWindows()
This forces the system to act as if multiple windows are not supported. This cannot be undone.


getPopupMenuParentFrame

public static Frame getPopupMenuParentFrame(Control c)
This returns the parent frame for a control's popup menu.


setAllParentFrame

public static void setAllParentFrame(Frame f)
Set the system to believe that multiple windows are not possible and that all new Frames should be shown in the specified Frame. If the specified Frame is null then the system will revert back to the normal operation.


closePopups

public static boolean closePopups(Control window)
Close all Frames denoted as popup frames in the Window containing the control.

Parameters:
window - Either the window or a Control within the window.
Returns:
true if all popups were closed successfully, false if not.

closePopups

public static boolean closePopups(Control window,
                                  int why,
                                  int flags)

checkParent

protected static Container checkParent(Container parent,
                                       int options)

execFrame

public static void execFrame(Frame f,
                             Container parent,
                             int options)
This will add the frame to the container and call a make() on it. This also sets the frame to be modal. If you specify an option of FILL_FRAME, CENTER_FRAME or FILL_WIDTH or FILL_HEIGHT, then the frame will be positioned and displayed on screen. If not you will have to call setRect()/repaintNow() on the frame to cause it to be positioned and painted.


fixShowOptions

public static int fixShowOptions(Container parent,
                                 int options)

showFrame

public static void showFrame(Frame f,
                             Container parent,
                             int options)
This will add the frame to the container and call a make() on it. This does not set the frame to be modal. If you specify an option of FILL_FRAME or CENTER_FRAME or FILL_WIDTH or FILL_HEIGHT, then the frame will be positioned and displayed on screen. If not you will have to call setRect()/repaintNow() on the frame to cause it to be positioned and painted.


execFrame

public static void execFrame(Frame f,
                             Container parent)

showFrame

public static void showFrame(Frame f,
                             Container parent)

getPosInParent

public static Point getPosInParent(Control c,
                                   Container parent)

takeFocus

public static void takeFocus(Control c,
                             int how)
This tells the Gui to assign focus to a particular control. This will also handle removing the focus from any previously focused control. You can also use a null control to remove focus altogether.

Parameters:
c - The control to receive the focus, or null to remove the focus altogether.
how - Should be Control.ByRequest for a programmatic focus change. But it can also be: Control.ByKeyboard, Control.ByMouse, Control.ByPen (same as ByMouse), Control.ByFrameChange.

moveFrameTo

public static void moveFrameTo(Frame f,
                               Rect where)

refreshScreen

public static void refreshScreen(Window w)

refreshScreen

public static void refreshScreen(Window w,
                                 Rect area)

refreshScreen

public static void refreshScreen(Control c)

screenResized

public static void screenResized(int width,
                                 int height)

setAppFormTitle

public static void setAppFormTitle(Form form,
                                   String title)
This will setup an the title bar on a Form if the main ewe window does not have a title and a close button.


setFormTitle

public static void setFormTitle(Window w,
                                Form form,
                                String title)
This will setup an the title bar on a Form if the main ewe window does not have a title and a close button.


setOKCancel

public static void setOKCancel(Form f)
This will set the OK/Cancel of a form to be either in the title bar (for mobile devices) or on the bottom for desktop devices.


iconize

public static boolean iconize(Control c,
                              String image,
                              Object maskOrColor,
                              boolean leaveText,
                              FontMetrics fm)
This will iconize a button/control that has its text already set. If an icon is found successfully it will be displayed. If leaveText is true then the text is displayed with the icon, otherwise only the icon is displayed.


iconize

public static boolean iconize(Control c,
                              IImage image,
                              boolean leaveText,
                              FontMetrics fm)
This will iconize a button/control that has its text already set. If an icon is found successfully it will be displayed. If leaveText is true then the text is displayed with the icon, otherwise only the icon is displayed.


isWindowFrame

public static boolean isWindowFrame(Frame f)
This returns true if the Frame is the main frame of a window.


getPreferredDialogSize

public static Dimension getPreferredDialogSize()

screenIs

public static boolean screenIs(int flags)
Check if the user screen is of a certain type.

Parameters:
flags - One of the XXX_SCREEN or DESKTOP_XXX constants.
Returns:
true if the screen is considered to be of the type specified by the flag.

requestPaint

public static boolean requestPaint(Control who)

refreshTopFrame

public static void refreshTopFrame(Control who)

setStyle

public static final void setStyle(int style)
Set the style of Controls within an application. This sets the look of the Controls within an application to be either a Windows style 3D look or a Java style etched look. To make all of your controls look flat set the "Control.globalDrawFlat" variable true. You should also call Color.setMonochrome(true) if you want high-contrast flat controls.

Parameters:
style - STYLE_ETCHED or STYLE_3D

getHotKeyFrom

public static final char getHotKeyFrom(String text)
Given text in the format "Text$hotkey" this returns the hotkey character.

Parameters:
text - The text for the control with the included hotkey.
Returns:
The hotkey character.

getTextFrom

public static final String getTextFrom(String text)
Given text in the format "Text$hotkey" this returns the text string without the hotkey character.

Parameters:
text - The text for the control with the included hotkey.
Returns:
The text without the hotkey character.

makeHot

public static final String makeHot(String label,
                                   int hotKey)
Convert a string with a hotkey to be a "true" hotkey encoded String which, when displayed by a Graphics object, will have its hotkey underlined. Note that this is very different to the human readable hotkey encoding where a $ is placed as the second to last character and the hotkey is the last character. A hotkey encoded String is one where the last character is a null character. The character immediately before the null is then taken to be the hot key.

Parameters:
label - The pure String.
hotKey - The hotkey (if any) to apply to the String.
Returns:
The displayable String which will be displayed with it's hotkey underlined by a Graphics object.

makeHot

public static final String makeHot(String label)
Convert a '$' formatted hotkey into a "true" hotkey encoded String. A hotkey encoded String is one where the last character is a null character. The character immediately before the null is then taken to be the hot key.

Parameters:
label - The '$' formatted hotkey.
Returns:
The displayable String which will be displayed with it's hotkey underlined by a Graphics object.

getGraphics

public static Graphics getGraphics(Window window)
This gets a Graphics object for a window. If the Window is rotated it will return a RotatedGraphics object.


setStyleManager

public static boolean setStyleManager(StyleManager manager)
Set a pluggable look and feel style manager for the GUI components. As of version 1.2 this is not supported by any Ewe VM but eventually desktop versions will support this feature.

Parameters:
manager - The StyleManager to use.
Returns:
true if the manager was set, false if style managers are not supported on this platform.
Throws:
UnsupportedOperationException - if a pluggable look and feel style manager is not supported on this VM.

getStyleManager

public static StyleManager getStyleManager()
Return the current pluggable look and feel style manager. On VMs that do not support pluggable look and feel style managers, this will always return null.

Returns:
the current pluggable look and feel style manager.

decodeAnchor

public static int decodeAnchor(String specs)

decodeAlignment

public static int decodeAlignment(String specs)

getGuiFlags

public static int getGuiFlags()

relayoutFrameAndWindow

public static void relayoutFrameAndWindow(Frame f,
                                          boolean overrideMaximize)
This method does a relayout and resize on a Frame and its containing Window (if the Frame contained within a native Window). The Frame will be resized to its new preferred size.

Parameters:
f - The Frame to relayout - which usually is obtained by calling getFrame() on a Form or other control.
overrideMaximize - if this is true then the relayout will occur even if the Window is in a maximized or minimized state.

flashMessageOn

public static Object flashMessageOn(String message,
                                    Control parent)
Display a short message on the screen, and keep it on the screen until flashMessageOff() is called.

Parameters:
message - A single-line message to display.
parent - The parent Control.
Returns:
an Object that you should use with flashMessageOff() when you want to remove the message.

flashMessageOff

public static void flashMessageOff(Object message)
Remove the short message as displayed by flashMessageOn().

Parameters:
message - The object returned by flashMessageOn().

flashMessage

public static void flashMessage(String message,
                                Control parent)

flashMessage

public static void flashMessage(String message,
                                int timeInMillis,
                                Control parent,
                                int flash_options)