Package totalcross.ui
Class Window
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Container
-
- totalcross.ui.Window
-
- Direct Known Subclasses:
CalculatorBox,CalendarBox,ColorChooserBox,ComboBoxDropDown,CompareBox,ControlBox,FileChooserBox,InputBox,KeyboardBox,MainWindow,MenuBar,MenuBarDropDown,MessageBox,PopupMenu,SlidingWindow,TimeBox,TopMenu,VirtualKeyboard
public class Window extends Container
Window is a floating top-level window.A window cannot be added to a container; use popup or popupNonBlocking to show it on screen. Trying to add it to a container will raise a RuntimeException.
The following example creates a popup window class:
class TestWindow extends Window { Button btnHi; public TestWindow() { super("Test",RECT_BORDER); // with caption and borders setRect(CENTER,CENTER,Settings.screenWidth/2,Settings.screenHeight/4); add(btnHi=new Button("Hi!"),CENTER,CENTER); } public void onEvent(Event event) { if (event.type == ControlEvent.PRESSED && event.target == btnHi) unpop(); // a WINDOW_CLOSED event will be posted to this PARENT window. } }To use it in the normal way (blocking):public class Launcher extends MainWindow { Button btn; public void onEvent(Event e) { if (e.target == btn) { TestWindow tw = new TestWindow(); tw.popup(); // this line is only executed after the window is closed. } } }To use it non-blocking (the execution continues right after the popup command, even with the window still open):public class Launcher extends MainWindow { TestWindow tw; public void initUI() { tw = new TestWindow(); tw.popupNonBlocking(); // this line is executed immediately } public void onEvent(Event event) { if (event.target == tw && event.type == ControlEvent.WINDOW_CLOSED) { // any stuff break; } } }Blocking popup may be use in InputBox/MessageBox classes, while non-blocking popup is used in MenuBar and other classes.Important note: you can't use popup with a delay to unpop it. In this case, the correct would be to use popupNonBlocking:
mb = new MessageBox(...); mb.popupNonBlocking(); Vm.sleep(5000); // or do something else mb.unpop;
If you use popup in this specific case, the Vm will hang.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description protected ControlEvent_controlEventprotected DragEvent_dragEventprotected Control_focusprotected KeyEvent_keyEventprotected MouseEvent_mouseEventprotected MultiTouchEvent_multiEventprotected PenEvent_penEventprotected static intandroidBorderThicknessprotected booleanbeepIfOutWhen this window is the top most and the user clicks outside, a beep is thrown.protected booleanblockingTrue if the last popup mode was blocking.protected byteborderStyleThe window's border stylestatic booleancancelPenUpIf true, the next pen_up event will be ignored.protected booleancanDragIf true (default), the user can drag this window aroundstatic intdragThresholdbooleanfadeOtherWindowsSet to true to make the other windows be faded when this window appears.static intfadeValueThe value used to fade the other windows.ControlfirstFocusthe control that should get focus when a focus traversal key is pressed and none have focusstatic booleanflickEnabledDeprecated.Flick is now enabled by default; just remove the reference to it.protected ControlfocusOnPenUpintfooterColorSet the header and the footer colors when in Android style and border type is ROUND_BORDER.protected intfooterHintgradientTitleEndColorThe starting and ending colors used to fill the gradient title.intgradientTitleStartColorThe starting and ending colors used to fill the gradient title.intheaderColorSet the header and the footer colors when in Android style and border type is ROUND_BORDER.protected Controlhighlightedprotected booleanhighResPreparedDeprecated.static byteHORIZONTAL_GRADIENTTo be used in setBorderStyle.static intignoreEventOfTypeUsed internally.static KeyListenerkeyHookA key listener that have priority over all other listeners.static intlastShiftYprotected ContainerlastSwappedContainerUsed in the swap methodprotected ContainermainSwapContainerUsed in the swap methodprotected ControlmenubarThe window's menu barprotected booleanmultiTouchingstatic booleanneedsPaintTrue if some area of any window is invalidatedstatic byteNO_BORDERTo be used in setBorderStylestatic intORIENTATION_INVERTEDstatic intORIENTATION_LANDSCAPEstatic intORIENTATION_PORTRAITForce the orientation during runtime.protected booleanpoppedUsed in popupstatic byteRECT_BORDERTo be used in setBorderStylestatic booleanrepaintOnSwapDuring a swap, the container is repainted.static UIRobotrobotThe UIRobot instance that is being used to record or play events.static byteROUND_BORDERTo be used in setBorderStyle.protected RectrTitlebooleansameBackgroundColorUse the same color in border and in bodystatic intshiftHstatic intshiftYstatic intSIP_BOTTOMUsed to place the virtual keyboard on bottom of screen.static intSIP_HIDEUsed to hide the virtual keyboardstatic intSIP_SHOWUsed to show the virtual keyboard, without changing the positionstatic intSIP_TOPUsed to place the virtual keyboard on top of screen.static byteTAB_BORDERTo be used in setBorderStylestatic byteTAB_ONLY_BORDERTo be used in setBorderStylejava.lang.StringtempTitleA temporary title that will be displayed when this Windows pops up.protected java.lang.StringtitleWindow's titleinttitleAlignThe title horizontal alignment in the Window's title area.inttitleColorThe title color.protected FonttitleFontFont for the title.inttitleGapA vertical gap used to increase the title area.protected static WindowtopMostThe last poped up window.static byteVERTICAL_GRADIENTTo be used in setBorderStyle.static VectorzStackStack of poped up windows.-
Fields inherited from class totalcross.ui.Container
alwaysEraseBackground, BACKGROUND_CYLINDRIC_SHADED, BACKGROUND_SHADED, BACKGROUND_SHADED_INV, BACKGROUND_SOLID, backgroundStyle, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_ROUNDED, BORDER_SIMPLE, BORDER_TOP, borderColor, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, npback, numChildren, started, tabOrder, tail, TRANSITION_CLOSE, TRANSITION_FADE, TRANSITION_NONE, TRANSITION_OPEN, TRANSITION_TIME, transitionEffect
-
Fields inherited from class totalcross.ui.Control
AFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void_doPaint()Called by the VM to repaint an area.void_postEvent(int type, int key, int x, int y, int modifiers, int timeStamp)Called by the VM to post key and pen events.static voiddestroyZStack()This method is for internal use only.voiddrawHighlight()Avoid drawing the highlight on a WindowbytegetBorderStyle()Returns the border style of this window.RectgetClientRect()Returns the client rect, ie, the rect minus the border and title area, in relative coordsprotected voidgetClientRect(Rect r)Returns the client rect, ie, the rect minus the border and title area, in relative coords In this version, you provide the created Rect to be filled with the coords.static intgetDefaultDragThreshold()ControlgetFocus()Returns the focus control for this window.ControlgetHighlighted()Gets the currently highlighted control.static intgetPopupCount()Returns the number of windows that are popped up.intgetPreferredHeight()Returns the size of the title if any plus the size of the border.intgetPreferredWidth()Returns the size of the title if any plus the size of the border.static InsetsgetSafeAreaInsets()FontgetTitleFont()Gets the title fontstatic WindowgetTopMost()Returns the topmost windowprotected booleanhandleFocusChangeKeys(KeyEvent ke)Called by the main event handler to handle the focus change keys.static booleanisScreenShifted()static booleanisSipShown()static booleanisSipShown4D()booleanisTopMost()Returns true if this window is the top-level windowbooleanisVisible()True if this is the topmost windowprotected voidloadBehind()This method repaints all windows from bottom to top.voidmakeUnmovable()Makes this window static, i.e., the user will not be able to move it around the screen by dragging the title area.protected booleanonClickedOutside(PenEvent event)called when the user clicks outside the bounds of this window.protected voidonPopup()Placeholder called imediatly before the popup began.static voidonRobotKey()Called when a robot key is pressed.protected voidonUnpop()Placeholder called imediatly before the unpop began.protected voidpaintTitle(java.lang.String title, Graphics gg)Paints the title and border.voidpaintWindowBackground(Graphics gg)voidpopup()Pops up this window, blocking the execution until the window closes.voidpopupMenuBar()Open the menu bar that is associated with this windowvoidpopupNonBlocking()Pops up this window, but the program execution continues right after, before the window is dismissed.protected voidpostPopup()Placeholder called after the popup is done and after the repaint of this window.voidpostPressedEvent()Posts a ControlEvent.PRESSED event on the focused control.protected voidpostUnpop()Placeholder called after the unpop is done and after the repaint of the other window.static voidpumpEvents()Let the VM handle all the events in the event queue.voidremoveFocus()Calling this method will cause a FOCUS_OUT control event to be posted to the window's current focus control (if one exists)static voidrepaintActiveWindows()Repaints the window stack from 0 to zStack.size().voidresize()This method resizes the Window to the needed bounds, based on added childs.voidresizeHeight()This method resizes the Container's width to the needed bounds, based on added childs.voidresizeWidth()This method resizes the Container's width to the needed bounds, based on added childs.voidscreenResized()Called when the screen is resized, probably caused by a rotation.voidsetBorderStyle(byte borderStyle)Sets the border borderStyle.static voidsetDeviceTitle(java.lang.String title)Sets the title text in the task bar for non-Palm OS operating systems.voidsetFocus(Control c)Sets focus to the given control.voidsetGrabPenEvents(Control c)Set to a control to redirect all pen events directly to it.voidsetHighlighted(Control c)Sets the currently highlighted control which will gain focus if the ACTION button is pressed.voidsetMenuBar(Control menubar)Sets the menu bar for this windowstatic voidsetOrientation(int orientation)static voidsetSIP(int sipOption, Control edit, boolean numeric)Used to set the position of the Soft Input Panel.voidsetTitle(java.lang.String title)Sets the title and call repaint.voidsetTitleFont(Font titleFont)Sets the title fontvoidshiftScreen(Control c, int deltaY)voidswap(Container newContainer)Used to swap containers from the Window.protected voidswapFocus(Control c)Changes the focus to the desired control, without posting FOCUS_IN and FOCUS_OUT eventsvoidunpop()Hides this window.voidvalidate()Calls _doPaint if the window needs painting.-
Methods inherited from class totalcross.ui.Container
add, add, add, add, add, applyTransitionEffect, broadcastEvent, clear, fillBackground, fillBackground, findChild, findNearestChild, findNextFocusControl, getChildren, getChildrenCount, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onColorsChanged, onPaint, onRemove, onSwapFinished, paintChildren, remove, removeAll, setEnabled, setFocusTraversable, setHighlighting, setInsets, setNextTransitionEffect, setPressColor, setPressed, swapToTopmostWindow
-
Methods inherited from class totalcross.ui.Control
_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isVisibleAndInside, onBoundsChanged, onEvent, onFontChanged, onWindowPaintFinished, post, postEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
-
-
-
-
Field Detail
-
needsPaint
public static boolean needsPaint
True if some area of any window is invalidated
-
title
protected java.lang.String title
Window's title
-
beepIfOut
protected boolean beepIfOut
When this window is the top most and the user clicks outside, a beep is thrown. Set this to false do disable the beep.
-
topMost
protected static Window topMost
The last poped up window.
-
titleFont
protected Font titleFont
Font for the title. Usually, MainWindow.defaultFont bolded
-
borderStyle
protected byte borderStyle
The window's border style
-
menubar
protected Control menubar
The window's menu bar
-
canDrag
protected boolean canDrag
If true (default), the user can drag this window around
-
highResPrepared
@Deprecated protected boolean highResPrepared
Deprecated.
-
tempTitle
public java.lang.String tempTitle
A temporary title that will be displayed when this Windows pops up. It will be replaced by the original title when it is closed.- Since:
- TotalCross 1.53
-
flickEnabled
@Deprecated public static boolean flickEnabled
Deprecated.Flick is now enabled by default; just remove the reference to it.
-
_focus
protected Control _focus
-
focusOnPenUp
protected Control focusOnPenUp
-
firstFocus
public Control firstFocus
the control that should get focus when a focus traversal key is pressed and none have focus
-
rTitle
protected Rect rTitle
-
highlighted
protected Control highlighted
-
footerH
protected int footerH
-
sameBackgroundColor
public boolean sameBackgroundColor
Use the same color in border and in body
-
cancelPenUp
public static boolean cancelPenUp
If true, the next pen_up event will be ignored. This is used when a pen_down cancels a flick, or if a drag-scrollable control needs to cancel the next pen_up during a drag-scrolling interaction.
-
blocking
protected boolean blocking
True if the last popup mode was blocking.
-
gradientTitleStartColor
public int gradientTitleStartColor
The starting and ending colors used to fill the gradient title.- See Also:
HORIZONTAL_GRADIENT,VERTICAL_GRADIENT
-
gradientTitleEndColor
public int gradientTitleEndColor
The starting and ending colors used to fill the gradient title.- See Also:
HORIZONTAL_GRADIENT,VERTICAL_GRADIENT
-
titleColor
public int titleColor
The title color. The title color depends on the border type: it will be the foreground color if NO_BORDER is set, otherwise will be the background color.
-
titleGap
public int titleGap
A vertical gap used to increase the title area. Defaults to fmH/2 in Android, 0 on other user interface styles.- Since:
- TotalCross 1.3.4
-
titleAlign
public int titleAlign
The title horizontal alignment in the Window's title area. It can be LEFT, CENTER or RIGHT, and you can use an adjustment on the value (E.G.: LEFT+5).- Since:
- TotalCross 1.3
-
headerColor
public int headerColor
Set the header and the footer colors when in Android style and border type is ROUND_BORDER. Not used in other styles.- Since:
- TotalCross 1.3
-
footerColor
public int footerColor
Set the header and the footer colors when in Android style and border type is ROUND_BORDER. Not used in other styles.- Since:
- TotalCross 1.3
-
fadeOtherWindows
public boolean fadeOtherWindows
Set to true to make the other windows be faded when this window appears.- Since:
- TotalCross 1.2
-
fadeValue
public static int fadeValue
The value used to fade the other windows. Defaults to 128.- Since:
- TotalCross 1.2
-
robot
public static UIRobot robot
The UIRobot instance that is being used to record or play events.
-
repaintOnSwap
public static boolean repaintOnSwap
During a swap, the container is repainted. If the swap is being done under the presence of a (wait) Window, the container will be drawn but the window dont. To fix this, set this flag to false.
-
androidBorderThickness
protected static int androidBorderThickness
-
popped
protected boolean popped
Used in popup
-
mainSwapContainer
protected Container mainSwapContainer
Used in the swap method
-
lastSwappedContainer
protected Container lastSwappedContainer
Used in the swap method
-
NO_BORDER
public static final byte NO_BORDER
To be used in setBorderStyle- See Also:
- Constant Field Values
-
RECT_BORDER
public static final byte RECT_BORDER
To be used in setBorderStyle- See Also:
- Constant Field Values
-
ROUND_BORDER
public static final byte ROUND_BORDER
To be used in setBorderStyle.- See Also:
- Constant Field Values
-
TAB_BORDER
public static final byte TAB_BORDER
To be used in setBorderStyle- See Also:
- Constant Field Values
-
TAB_ONLY_BORDER
public static final byte TAB_ONLY_BORDER
To be used in setBorderStyle- See Also:
- Constant Field Values
-
HORIZONTAL_GRADIENT
public static final byte HORIZONTAL_GRADIENT
To be used in setBorderStyle.
-
VERTICAL_GRADIENT
public static final byte VERTICAL_GRADIENT
To be used in setBorderStyle.
-
SIP_HIDE
public static final int SIP_HIDE
Used to hide the virtual keyboard- See Also:
- Constant Field Values
-
SIP_TOP
public static final int SIP_TOP
Used to place the virtual keyboard on top of screen.- See Also:
- Constant Field Values
-
SIP_BOTTOM
public static final int SIP_BOTTOM
Used to place the virtual keyboard on bottom of screen.- See Also:
- Constant Field Values
-
SIP_SHOW
public static final int SIP_SHOW
Used to show the virtual keyboard, without changing the position- See Also:
- Constant Field Values
-
zStack
public static Vector zStack
Stack of poped up windows. Dont mess with this, unless you want to crash the VM!
-
ignoreEventOfType
public static int ignoreEventOfType
Used internally.- See Also:
Event.clearQueue(int)
-
_keyEvent
protected KeyEvent _keyEvent
-
_penEvent
protected PenEvent _penEvent
-
_controlEvent
protected ControlEvent _controlEvent
-
_dragEvent
protected DragEvent _dragEvent
-
_mouseEvent
protected MouseEvent _mouseEvent
-
_multiEvent
protected MultiTouchEvent _multiEvent
-
multiTouching
protected boolean multiTouching
-
shiftY
public static int shiftY
-
shiftH
public static int shiftH
-
lastShiftY
public static int lastShiftY
-
dragThreshold
public static int dragThreshold
-
keyHook
public static KeyListener keyHook
A key listener that have priority over all other listeners.
-
ORIENTATION_PORTRAIT
public static final int ORIENTATION_PORTRAIT
Force the orientation during runtime. Use one of ORIENTATION_PORTRAIT / ORIENTATION_LANDSCAPE. Can be ored with ORIENTATION_INVERTED flag.- See Also:
- Constant Field Values
-
ORIENTATION_LANDSCAPE
public static final int ORIENTATION_LANDSCAPE
- See Also:
- Constant Field Values
-
ORIENTATION_INVERTED
public static final int ORIENTATION_INVERTED
- See Also:
- Constant Field Values
-
-
Method Detail
-
setGrabPenEvents
public void setGrabPenEvents(Control c)
Set to a control to redirect all pen events directly to it. This speeds up pen event processing. Used in Whiteboard class.- Since:
- TotalCross 1.0
-
setTitleFont
public void setTitleFont(Font titleFont)
Sets the title font
-
getTitleFont
public Font getTitleFont()
Gets the title font
-
setTitle
public void setTitle(java.lang.String title)
Sets the title and call repaint.
-
setDeviceTitle
public static final void setDeviceTitle(java.lang.String title)
Sets the title text in the task bar for non-Palm OS operating systems. Does not work in full-screen mode.- Since:
- TotalCross 1.0
-
setOrientation
public static final void setOrientation(int orientation)
-
setBorderStyle
public void setBorderStyle(byte borderStyle)
Sets the border borderStyle.- Overrides:
setBorderStylein classContainer- See Also:
NO_BORDER,RECT_BORDER,ROUND_BORDER,TAB_BORDER,TAB_ONLY_BORDER,HORIZONTAL_GRADIENT,VERTICAL_GRADIENT
-
getBorderStyle
public byte getBorderStyle()
Returns the border style of this window.- Overrides:
getBorderStylein classContainer
-
makeUnmovable
public void makeUnmovable()
Makes this window static, i.e., the user will not be able to move it around the screen by dragging the title area. It just set the canDrag member to false.
-
setFocus
public void setFocus(Control c)
Sets focus to the given control. When a user types a key, the control with focus get the key event. At any given time, only one control in a window can have focus. Calling this method will cause a FOCUS_OUT control event to be posted to the window's current focus control (if one exists) and will cause a FOCUS_IN control event to be posted to the new focus control.
-
removeFocus
public void removeFocus()
Calling this method will cause a FOCUS_OUT control event to be posted to the window's current focus control (if one exists)
-
swapFocus
protected void swapFocus(Control c)
Changes the focus to the desired control, without posting FOCUS_IN and FOCUS_OUT events- Since:
- SuperWaba 4.01
-
getFocus
public Control getFocus()
Returns the focus control for this window. This will be the same offocusedControl , unless the last one has been changed manually.- See Also:
setFocus(totalcross.ui.Control)
-
onClickedOutside
protected boolean onClickedOutside(PenEvent event)
called when the user clicks outside the bounds of this window. must return true if the event was handled, false otherwise. If false is returned andbeepIfOutis true, then a beep is played and nothing more happens.- Since:
- SuperWaba 1.2
-
validate
public void validate()
Calls _doPaint if the window needs painting.- Since:
- SuperWaba 4.0
-
_postEvent
public final void _postEvent(int type, int key, int x, int y, int modifiers, int timeStamp)Called by the VM to post key and pen events.
-
getSafeAreaInsets
public static Insets getSafeAreaInsets()
-
getClientRect
protected void getClientRect(Rect r)
Returns the client rect, ie, the rect minus the border and title area, in relative coords In this version, you provide the created Rect to be filled with the coords.- Overrides:
getClientRectin classContainer
-
getClientRect
public Rect getClientRect()
Returns the client rect, ie, the rect minus the border and title area, in relative coords- Overrides:
getClientRectin classContainer- See Also:
Container.getClientRect(Rect)
-
paintTitle
protected void paintTitle(java.lang.String title, Graphics gg)Paints the title and border.
-
paintWindowBackground
public void paintWindowBackground(Graphics gg)
-
_doPaint
public void _doPaint()
Called by the VM to repaint an area.
-
unpop
public void unpop()
Hides this window. Calling unpop when only the MainWindow is active does nothing.
-
pumpEvents
public static void pumpEvents()
Let the VM handle all the events in the event queue. This method is used to implement a blocking Window. Here is an example:while(someCondition) { Event.pumpEvents(); }
-
isTopMost
public boolean isTopMost()
Returns true if this window is the top-level window
-
getTopMost
public static Window getTopMost()
Returns the topmost window
-
onPopup
protected void onPopup()
Placeholder called imediatly before the popup began. The default implementation does nothing.
-
postPopup
protected void postPopup()
Placeholder called after the popup is done and after the repaint of this window. The default implementation does nothing.
-
onUnpop
protected void onUnpop()
Placeholder called imediatly before the unpop began. The default implementation does nothing.
-
postUnpop
protected void postUnpop()
Placeholder called after the unpop is done and after the repaint of the other window. The default implementation does nothing.
-
isVisible
public boolean isVisible()
True if this is the topmost window
-
setSIP
public static final void setSIP(int sipOption, Control edit, boolean numeric)Used to set the position of the Soft Input Panel.- Parameters:
sipOption- One of the SIP_xxx values.edit- control (Edit or MultiEdit) (iPhone only)numeric- enable numeric keyboard (Android only)- See Also:
SIP_HIDE,SIP_SHOW,SIP_TOP,SIP_BOTTOM,Edit.mapKeys(java.lang.String, java.lang.String)
-
setMenuBar
public void setMenuBar(Control menubar)
Sets the menu bar for this window
-
popupMenuBar
public void popupMenuBar()
Open the menu bar that is associated with this window
-
loadBehind
protected void loadBehind()
This method repaints all windows from bottom to top. It is automaticaly used in the unpop method.- Since:
- SuperWaba 2.0 beta 4
-
destroyZStack
public static void destroyZStack()
This method is for internal use only. calling it directly will cause the VM to crash.
-
swap
public void swap(Container newContainer)
Used to swap containers from the Window. To restore the first container, pass null as parameter. Note that null cannot be used for the first swap. See samples/ui/ContainerSwitch. This method correctly handles screen rotation for containers that were already swapped.
-
getPreferredWidth
public int getPreferredWidth()
Returns the size of the title if any plus the size of the border. Note that the value returned here does not handle the controls inside the window.- Overrides:
getPreferredWidthin classControl
-
getPreferredHeight
public int getPreferredHeight()
Returns the size of the title if any plus the size of the border. Note that the value returned here does not handle the controls inside the window.- Overrides:
getPreferredHeightin classControl
-
repaintActiveWindows
public static void repaintActiveWindows()
Repaints the window stack from 0 to zStack.size().
-
handleFocusChangeKeys
protected boolean handleFocusChangeKeys(KeyEvent ke)
Called by the main event handler to handle the focus change keys. Only called when Settings.keyboardFocusNavigation is true.- Since:
- SuperWaba 5.5
-
setHighlighted
public void setHighlighted(Control c)
Sets the currently highlighted control which will gain focus if the ACTION button is pressed. It may be the same of the one that holds focus.- Since:
- SuperWaba 5.5
-
getHighlighted
public Control getHighlighted()
Gets the currently highlighted control.- Since:
- SuperWaba 5.5
-
drawHighlight
public void drawHighlight()
Avoid drawing the highlight on a Window
-
popupNonBlocking
public void popupNonBlocking()
Pops up this window, but the program execution continues right after, before the window is dismissed.- Since:
- SuperWaba 5.5
-
popup
public void popup()
Pops up this window, blocking the execution until the window closes.- Since:
- SuperWaba 5.5
-
postPressedEvent
public void postPressedEvent()
Posts a ControlEvent.PRESSED event on the focused control.- Overrides:
postPressedEventin classControl- Since:
- SuperWaba 5.8
-
screenResized
public void screenResized()
Called when the screen is resized, probably caused by a rotation. ATTENTION: THIS CALL CANNOT BE BLOCKED OR THE SYSTEM WILL LOCK!
-
resize
public void resize()
This method resizes the Window to the needed bounds, based on added childs. It changes only the size, keeping the x,y coordinates passed on setRect. You can add spaces at right and bottom using the insets.right/bottom properties. Sample:public class TestWindow extends Window { public TestWindow() { ... call constructor setRect(CENTER,CENTER,Screen.width-40,1000); // height will be resized later } public void initUI() { setInsets(5,5,5,5); ... add controls resize(); } }In this sample, since the height is variable, you can't use BOTTOM onynor FILL onheight, otherwise resize will not work as expected. Same counts if you have a variable width.- Overrides:
resizein classContainer- Since:
- TotalCross 1.14
- See Also:
Container.resizeWidth(),Container.resizeHeight()
-
resizeWidth
public void resizeWidth()
Description copied from class:ContainerThis method resizes the Container's width to the needed bounds, based on added childs. You can add spaces at right using the insets.right property. Sample:// this sample will center two buttons of different sizes on screen Container c = new Container(); add(c, CENTER,BOTTOM,1000,1000); c.add(new Button("Ok"),LEFT,TOP); c.add(new Button("Cancel"),AFTER+5,SAME); c.resize();Note: differently of Window.resize, this method does not call setRect again, it only changes the width by direct assignment.- Overrides:
resizeWidthin classContainer- See Also:
Container.resize(),Container.resizeHeight()
-
resizeHeight
public void resizeHeight()
Description copied from class:ContainerThis method resizes the Container's width to the needed bounds, based on added childs. You can add spaces at bottom using the insets.bottom property. Sample:// this sample will center two buttons of different sizes on screen Container c = new Container(); add(c, CENTER,BOTTOM,1000,1000); c.add(new Button("Ok"),LEFT,TOP); c.add(new Button("Cancel"),AFTER+5,SAME); c.resize();Note: differently of Window.resize, this method does not call setRect again, it only changes the height by direct assignment.- Overrides:
resizeHeightin classContainer- See Also:
Container.resizeWidth(),Container.resize()
-
getDefaultDragThreshold
public static int getDefaultDragThreshold()
-
getPopupCount
public static int getPopupCount()
Returns the number of windows that are popped up. If there's only a MainWindow, returns 0.- Since:
- TotalCross 1.27
-
onRobotKey
public static void onRobotKey()
Called when a robot key is pressed. Don't call this method directly, use Settings.deviceRobotSpecialKey instead.- See Also:
Settings.deviceRobotSpecialKey
-
shiftScreen
public void shiftScreen(Control c, int deltaY)
-
isScreenShifted
public static boolean isScreenShifted()
-
isSipShown
public static boolean isSipShown()
-
isSipShown4D
public static boolean isSipShown4D()
-
-