Interface Window
-
- All Superinterfaces:
NativeSurface,NativeSurfaceHolder,NativeWindow,ScalableSurface,SurfaceUpdatedListener,WindowClosingProtocol
- All Known Implementing Classes:
GLWindow
public interface Window extends NativeWindow, WindowClosingProtocol, ScalableSurface
Specifying NEWT's Window functionality:- On- and offscreen windows
- Keyboard and multi-pointer input
- Native reparenting
- Toggable fullscreen and decoration mode
- Transparency
- ... and more
One use case is
GLWindow, which delegates window operation to an instance of this interface while providing OpenGL functionality.All values of this interface are represented in window units, if not stated otherwise.
Coordinate System
- Screen space has it's origin in the top-left corner, and may not be at 0/0.
- Window origin is in it's top-left corner, see
NativeWindow.getX()andNativeWindow.getY(). - Window client-area excludes
insets, i.e. window decoration. - Window origin is relative to it's parent window if exist, or the screen position (top-level).
NativeWindowandScreen.Custom Window Icons
Custom window icons can be defined via system property
newt.window.icons, which shall contain a list of PNG icon locations from low- to high-resolution, separated by one whitespace or one comma character. The location must be resolvable via classpath, i.e. shall reference a location within the jar file. Example (our default):-Dnewt.window.icons="jogamp/newt/assets/jogamp-16x16.png,jogamp/newt/assets/jogamp-32x32.png" -Djnlp.newt.window.icons="jogamp/newt/assets/jogamp-16x16.png,jogamp/newt/assets/jogamp-32x32.png"
The property can also be set programmatically, which must happen before any NEWT classes are touched:System.setProperty("newt.window.icons", "jogamp/newt/assets/jogamp-16x16.png,jogamp/newt/assets/jogamp-32x32.png");To disable even Jogamp's own window icons in favor of system icons, simply set a non-existing location, e.g.:-Dnewt.window.icons="null,null"
Use of Lifecycle Heavy functions
Some of the methods specified here are lifecycle-heavy. That is, they are able to destroy and/or reattach resources to/from the window. Because of this, the methods are not safe to be called from EDT related threads. For example, it is not safe for a method in an attached
KeyListenerto callsetFullscreen(boolean)on aWindowdirectly. It is safe, however, for that method to spawn a background worker thread which calls the method directly. The documentation for individual methods indicates whether or not they are lifecycle-heavy.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceWindow.FocusRunnablestatic classWindow.ReparentOperationReparenting operation types-
Nested classes/interfaces inherited from interface com.jogamp.nativewindow.WindowClosingProtocol
WindowClosingProtocol.WindowClosingMode
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEBUG_IMPLEMENTATIONstatic booleanDEBUG_KEY_EVENTstatic booleanDEBUG_MOUSE_EVENTstatic intREPARENT_HINT_BECOMES_VISIBLEReparenting hint (bitfield value): Claim window becomes visible after reparenting, which is important for e.g.static intREPARENT_HINT_FORCE_RECREATIONReparenting hint (bitfield value): Force destroy and hencere-creatingthe window.static intSTATE_BIT_ALWAYSONBOTTOMSet if window is always on bottom, otherwise cleared.static intSTATE_BIT_ALWAYSONTOPSet if window is always on top, otherwise cleared.static intSTATE_BIT_AUTOPOSITIONHinting that no custom position has been set before firstvisibilityof this instance.static intSTATE_BIT_CHILDWINSet if window is a child window, i.e.static intSTATE_BIT_FOCUSEDSet if window has the input focus, otherwise cleared.static intSTATE_BIT_FULLSCREENSet if window is in fullscreen mode, otherwise cleared.static intSTATE_BIT_MAXIMIZED_HORZSet if window is maximized horizontally, otherwise cleared.static intSTATE_BIT_MAXIMIZED_VERTSet if window is maximized vertically, otherwise cleared.static intSTATE_BIT_POINTERCONFINEDSet if the pointer is confined to the window, otherwise cleared.static intSTATE_BIT_POINTERVISIBLESet if the pointer is visible when inside the window, otherwise cleared.static intSTATE_BIT_REPOSITIONABLESet if window is repositionable after creation, otherwise cleared.static intSTATE_BIT_RESIZABLESet if window is resizable after creation, otherwise cleared.static intSTATE_BIT_STICKYSet if window is sticky, i.e.static intSTATE_BIT_UNDECORATEDSet if window has window decorations, otherwise cleared.static intSTATE_BIT_VISIBLEVisibility of this instance.static intSTATE_MASK_ALWAYSONBOTTOMBitmask forSTATE_BIT_ALWAYSONBOTTOM, 64.static intSTATE_MASK_ALWAYSONTOPBitmask forSTATE_BIT_ALWAYSONTOP, 32.static intSTATE_MASK_AUTOPOSITIONBitmask forSTATE_BIT_AUTOPOSITION, 2.static intSTATE_MASK_CHILDWINBitmask forSTATE_BIT_CHILDWIN, 4.static intSTATE_MASK_FOCUSEDBitmask forSTATE_BIT_FOCUSED, 8.static intSTATE_MASK_FULLSCREENBitmask forSTATE_BIT_FULLSCREEN, 2048.static intSTATE_MASK_MAXIMIZED_HORZBitmask forSTATE_BIT_MAXIMIZED_HORZ, 1024.static intSTATE_MASK_MAXIMIZED_VERTBitmask forSTATE_BIT_MAXIMIZED_VERT, 512.static intSTATE_MASK_POINTERCONFINEDBitmask forSTATE_BIT_POINTERCONFINED, 8192.static intSTATE_MASK_POINTERVISIBLEBitmask forSTATE_BIT_POINTERVISIBLE, 4096.static intSTATE_MASK_REPOSITIONABLEBitmask forSTATE_BIT_REPOSITIONABLE, 16384.static intSTATE_MASK_RESIZABLEBitmask forSTATE_BIT_RESIZABLE, 256.static intSTATE_MASK_STICKYBitmask forSTATE_BIT_STICKY, 128.static intSTATE_MASK_UNDECORATEDBitmask forSTATE_BIT_UNDECORATED, 16.static intSTATE_MASK_VISIBLEBitmask forSTATE_BIT_VISIBLE, 1.static longTIMEOUT_NATIVEWINDOWA 1s timeout while waiting for a native action response, iesetVisible(boolean).-
Fields inherited from interface com.jogamp.nativewindow.NativeSurface
LOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY, LOCK_SURFACE_UNLOCKED
-
Fields inherited from interface com.jogamp.nativewindow.ScalableSurface
AUTOMAX_PIXELSCALE, IDENTITY_PIXELSCALE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaddChild(NativeWindow win)voidaddGestureHandler(int index, GestureHandler gh)Inserts the givenGestureHandlerat the specified position in the list.voidaddGestureHandler(GestureHandler gh)Appends the givenGestureHandlerto the end of the list.voidaddGestureListener(int index, GestureHandler.GestureListener gl)Inserts the givenGestureHandler.GestureListenerat the specified position in the list.voidaddGestureListener(GestureHandler.GestureListener gl)Appends the givenGestureHandler.GestureListenerto the end of the list.voidaddKeyListener(int index, KeyListener l)Inserts the givenKeyListenerat the specified position in the list.voidaddKeyListener(KeyListener l)Appends the givenKeyListenerto the end of the list.voidaddMouseListener(int index, MouseListener l)Inserts the givenMouseListenerat the specified position in the list.voidaddMouseListener(MouseListener l)Appends the givenMouseListenerto the end of the list.voidaddWindowListener(int index, WindowListener l)Inserts the givenWindowListenerat the specified position in the list.voidaddWindowListener(WindowListener l)Appends the givenWindowListenerto the end of the list.booleanareDefaultGesturesEnabled()Return true if defaultGestureHandlerare enabled.voidconfinePointer(boolean confine)Confine the pointer to this window, ie.voiddestroy()Destroys this window incl.voidenqueueEvent(boolean wait, NEWTEvent event)Enqueues aNEWT event.CapabilitiesImmutablegetChosenCapabilities()Gets an immutable set of chosen capabilities.WindowgetDelegatedWindow()If the implementation uses delegation, return the delegatedWindowinstance, otherwise returnthisinstance.KeyListenergetKeyListener(int index)KeyListener[]getKeyListeners()MonitorDevicegetMainMonitor()MouseListenergetMouseListener(int index)Returns theMouseListenerfrom the list at the given index.MouseListener[]getMouseListeners()Returns allMouseListenerfloat[]getPixelsPerMM(float[] ppmmStore)Returns the pixels per millimeter of this window'sNativeSurfaceaccording to themain monitor's currentmode'ssurface resolution.Display.PointerIcongetPointerIcon()Returns the currentDisplay.PointerIcon, which maybenullfor the default.CapabilitiesImmutablegetRequestedCapabilities()Gets an immutable set of requested capabilities.ScreengetScreen()intgetStateMask()Returns the current status mask of this instance.StringgetStateMaskString()Returns a string representation of thecurrent state mask.intgetStatePublicBitCount()Number of all public state bits.intgetStatePublicBitmask()Bitmask covering all public state bits.intgetSupportedStateMask()Returns the supportedstate maskof the implementation.StringgetSupportedStateMaskString()Returns a string representation of thesupported state mask.StringgetTitle()WindowListenergetWindowListener(int index)WindowListener[]getWindowListeners()booleanisAlwaysOnBottom()booleanisAlwaysOnTop()booleanisChildWindow()Returnstrueif this window is a child window, i.e.booleanisFullscreen()booleanisKeyboardVisible()Returntrueif the virtual on-screen keyboard is visible, otherwisefalse.booleanisMaximizedHorz()booleanisMaximizedVert()booleanisNativeValid()booleanisPointerConfined()booleanisPointerVisible()booleanisResizable()booleanisSticky()booleanisUndecorated()booleanisVisible()booleanremoveChild(NativeWindow win)voidremoveGestureHandler(GestureHandler gh)Removes the givenGestureHandlerfrom the list.voidremoveGestureListener(GestureHandler.GestureListener gl)Removes the givenGestureHandler.GestureListenerfrom the list.voidremoveKeyListener(KeyListener l)voidremoveMouseListener(MouseListener l)Removes the givenMouseListenerfrom the list.voidremoveWindowListener(WindowListener l)Window.ReparentOperationreparentWindow(NativeWindow newParent, int x, int y, int hints)Change this window's parent window.voidrequestFocus()Request focus for this native windowvoidrequestFocus(boolean wait)Request focus for this native windowvoidrunOnEDTIfAvail(boolean wait, Runnable task)voidsendWindowEvent(int eventType)Send aWindowEventto allWindowListener.voidsetAlwaysOnBottom(boolean value)Operation is ignored if this instanceis a child window.voidsetAlwaysOnTop(boolean value)Operation is ignored if this instanceis a child window.CapabilitiesChoosersetCapabilitiesChooser(CapabilitiesChooser chooser)Set the CapabilitiesChooser to help determine the native visual type.voidsetDefaultGesturesEnabled(boolean enable)Enable or disable defaultGestureHandler.voidsetFocusAction(Window.FocusRunnable focusAction)Sets aWindow.FocusRunnable, whichWindow.FocusRunnable.run()method is executed before the native focus is requested.booleansetFullscreen(boolean fullscreen)Enable or disable fullscreen mode for this window.booleansetFullscreen(List<MonitorDevice> monitors)Enable fullscreen mode for this window spanning across the givenMonitorDevices or across allMonitorDevices.voidsetKeyboardFocusHandler(KeyListener l)Sets aKeyListenerallowing focus traversal with a covered window toolkit like AWT.voidsetKeyboardVisible(boolean visible)In case the platform supports or even requires a virtual on-screen keyboard, this method shows or hide it depending on whethervisibleistrueorfalse.voidsetMaximized(boolean horz, boolean vert)Operation is ignored if this instanceis a child window.voidsetPointerIcon(Display.PointerIcon pi)voidsetPointerVisible(boolean pointerVisible)Makes the pointer visible or invisible.voidsetPosition(int x, int y)Sets the location of the window's client area excluding insets (window decorations) in window units.
This call is ignored if in fullscreen mode.voidsetResizable(boolean value)Operation is ignored if this instanceis a child window.voidsetSize(int width, int height)Sets the size of the window's client area in window units, excluding decorations.voidsetSticky(boolean value)Operation is ignored if this instanceis a child window.voidsetSurfaceSize(int pixelWidth, int pixelHeight)Sets the size of the window's surface in pixel units which claims the window's client area excluding decorations.voidsetTitle(String title)voidsetTopLevelPosition(int x, int y)Sets the location of the top-level window inclusive insets (window decorations) in window units.voidsetTopLevelSize(int width, int height)Sets the size of the top-level window including insets (window decorations) in window units.voidsetUndecorated(boolean value)voidsetVisible(boolean visible)CallssetVisible(true, visible), i.e.voidsetVisible(boolean wait, boolean visible)setVisible(..)makes the window and children visible ifvisibleis true, otherwise the window and children becomes invisible.voidsetWindowDestroyNotifyAction(Runnable r)Set a custom action handling destruction issued by atoolkit triggered window destroyreplacing the defaultdestroy()action.StringtoSimpleString()Returns a simple string one-line representation of this instance usingtoSimpleString(StringBuilder).StringBuildertoSimpleString(StringBuilder sb)Appends this class simple string one-line representation to the givenStringBuilderinstanceStringtoString()Returns a full string multi-line representation of this instance usingtoString(StringBuilder).StringBuildertoString(StringBuilder sb)Appends this class full string multi-line representation to the givenStringBuilderinstancevoidwarpPointer(int x, int y)Moves the pointer to x/y relative to this window's origin in pixel units.booleanwindowRepaint(int x, int y, int width, int height)Trigger window repaint while passing the dirty region in pixel units.-
Methods inherited from interface com.jogamp.nativewindow.NativeSurface
addSurfaceUpdatedListener, addSurfaceUpdatedListener, convertToPixelUnits, convertToWindowUnits, getDisplayHandle, getGraphicsConfiguration, getLock, getScreenIndex, getSurfaceHandle, getSurfaceHeight, getSurfaceLockOwner, getSurfaceWidth, isSurfaceLockedByOtherThread, lockSurface, removeSurfaceUpdatedListener, surfaceSwap, unlockSurface
-
Methods inherited from interface com.jogamp.nativewindow.NativeWindow
getBounds, getHeight, getInsets, getLocationOnScreen, getNativeSurface, getParent, getSurfaceBounds, getWidth, getWindowHandle, getX, getY, hasFocus
-
Methods inherited from interface com.jogamp.nativewindow.ScalableSurface
canSetSurfaceScale, getCurrentSurfaceScale, getMaximumSurfaceScale, getMinimumSurfaceScale, getRequestedSurfaceScale, setSurfaceScale
-
Methods inherited from interface com.jogamp.nativewindow.SurfaceUpdatedListener
surfaceUpdated
-
Methods inherited from interface com.jogamp.nativewindow.WindowClosingProtocol
getDefaultCloseOperation, setDefaultCloseOperation
-
-
-
-
Field Detail
-
DEBUG_MOUSE_EVENT
static final boolean DEBUG_MOUSE_EVENT
-
DEBUG_KEY_EVENT
static final boolean DEBUG_KEY_EVENT
-
DEBUG_IMPLEMENTATION
static final boolean DEBUG_IMPLEMENTATION
-
TIMEOUT_NATIVEWINDOW
static final long TIMEOUT_NATIVEWINDOW
A 1s timeout while waiting for a native action response, iesetVisible(boolean).- See Also:
- Constant Field Values
-
STATE_BIT_VISIBLE
static final int STATE_BIT_VISIBLE
Visibility of this instance.Native instance gets created at first visibility, following NEWT's lazy creation pattern.
Changing this state is lifecycle heavy.
Bit number 0.
Defaults to
false.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_AUTOPOSITION
static final int STATE_BIT_AUTOPOSITION
Hinting that no custom position has been set before firstvisibilityof this instance.If kept
falseat creation, this allows the WM to choose the top-level window position, otherwise the custom position is being enforced.Bit number 1.
Defaults to
true.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_CHILDWIN
static final int STATE_BIT_CHILDWIN
Set if window is a child window, i.e. has beenreparented.Otherwise bit is cleared, i.e. window is top-level.
Changing this state is lifecycle heavy.
Bit number 2.
Defaults to
false.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_FOCUSED
static final int STATE_BIT_FOCUSED
Set if window has the input focus, otherwise cleared.Bit number 3.
Defaults to
false.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_UNDECORATED
static final int STATE_BIT_UNDECORATED
Set if window has window decorations, otherwise cleared.Bit number 4.
Defaults to
false.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_ALWAYSONTOP
static final int STATE_BIT_ALWAYSONTOP
Set if window is always on top, otherwise cleared.Bit number 5.
Defaults to
false.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_ALWAYSONBOTTOM
static final int STATE_BIT_ALWAYSONBOTTOM
Set if window is always on bottom, otherwise cleared.Bit number 6.
Defaults to
false.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_STICKY
static final int STATE_BIT_STICKY
Set if window is sticky, i.e. visible on all virtual desktop, otherwise cleared.Bit number 7.
Defaults to
false.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_RESIZABLE
static final int STATE_BIT_RESIZABLE
Set if window is resizable after creation, otherwise cleared.Bit number 8.
Defaults to
true.- Since:
- 2.3.2
- See Also:
getStateMask(), Constant Field Values
-
STATE_BIT_MAXIMIZED_VERT
static final int STATE_BIT_MAXIMIZED_VERT
Set if window is maximized vertically, otherwise cleared.Bit number 9.
Defaults to
false.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_MAXIMIZED_HORZ
static final int STATE_BIT_MAXIMIZED_HORZ
Set if window is maximized horizontally, otherwise cleared.Bit number 10.
Defaults to
false.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_FULLSCREEN
static final int STATE_BIT_FULLSCREEN
Set if window is in fullscreen mode, otherwise cleared.Usually fullscreen mode implies
STATE_BIT_UNDECORATED, however, an implementation is allowed to ignore this if unavailable.Bit number 11.
Defaults to
false.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_POINTERVISIBLE
static final int STATE_BIT_POINTERVISIBLE
Set if the pointer is visible when inside the window, otherwise cleared.Bit number 12.
Defaults to
true.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_POINTERCONFINED
static final int STATE_BIT_POINTERCONFINED
Set if the pointer is confined to the window, otherwise cleared.Bit number 13.
Defaults to
false.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_BIT_REPOSITIONABLE
static final int STATE_BIT_REPOSITIONABLE
Set if window is repositionable after creation, otherwise cleared.Bit number 14.
Defaults to
true.- Since:
- 2.4.0
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_VISIBLE
static final int STATE_MASK_VISIBLE
Bitmask forSTATE_BIT_VISIBLE, 1.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_AUTOPOSITION
static final int STATE_MASK_AUTOPOSITION
Bitmask forSTATE_BIT_AUTOPOSITION, 2.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_CHILDWIN
static final int STATE_MASK_CHILDWIN
Bitmask forSTATE_BIT_CHILDWIN, 4.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_FOCUSED
static final int STATE_MASK_FOCUSED
Bitmask forSTATE_BIT_FOCUSED, 8.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_UNDECORATED
static final int STATE_MASK_UNDECORATED
Bitmask forSTATE_BIT_UNDECORATED, 16.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_ALWAYSONTOP
static final int STATE_MASK_ALWAYSONTOP
Bitmask forSTATE_BIT_ALWAYSONTOP, 32.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_ALWAYSONBOTTOM
static final int STATE_MASK_ALWAYSONBOTTOM
Bitmask forSTATE_BIT_ALWAYSONBOTTOM, 64.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_STICKY
static final int STATE_MASK_STICKY
Bitmask forSTATE_BIT_STICKY, 128.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_RESIZABLE
static final int STATE_MASK_RESIZABLE
Bitmask forSTATE_BIT_RESIZABLE, 256.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_MAXIMIZED_VERT
static final int STATE_MASK_MAXIMIZED_VERT
Bitmask forSTATE_BIT_MAXIMIZED_VERT, 512.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_MAXIMIZED_HORZ
static final int STATE_MASK_MAXIMIZED_HORZ
Bitmask forSTATE_BIT_MAXIMIZED_HORZ, 1024.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_FULLSCREEN
static final int STATE_MASK_FULLSCREEN
Bitmask forSTATE_BIT_FULLSCREEN, 2048.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_POINTERVISIBLE
static final int STATE_MASK_POINTERVISIBLE
Bitmask forSTATE_BIT_POINTERVISIBLE, 4096.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_POINTERCONFINED
static final int STATE_MASK_POINTERCONFINED
Bitmask forSTATE_BIT_POINTERCONFINED, 8192.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
STATE_MASK_REPOSITIONABLE
static final int STATE_MASK_REPOSITIONABLE
Bitmask forSTATE_BIT_REPOSITIONABLE, 16384.- Since:
- 2.4.0
- See Also:
getSupportedStateMask(),getStateMask(), Constant Field Values
-
REPARENT_HINT_FORCE_RECREATION
static final int REPARENT_HINT_FORCE_RECREATION
Reparenting hint (bitfield value): Force destroy and hencere-creatingthe window.- See Also:
- Constant Field Values
-
REPARENT_HINT_BECOMES_VISIBLE
static final int REPARENT_HINT_BECOMES_VISIBLE
Reparenting hint (bitfield value): Claim window becomes visible after reparenting, which is important for e.g. preserving the GL-states in case window is invisible while reparenting.- See Also:
- Constant Field Values
-
-
Method Detail
-
getStatePublicBitCount
int getStatePublicBitCount()
Number of all public state bits.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask()
-
getStatePublicBitmask
int getStatePublicBitmask()
Bitmask covering all public state bits.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),getStateMask()
-
getStateMask
int getStateMask()
Returns the current status mask of this instance.- Since:
- 2.3.2
- See Also:
getSupportedStateMask(),STATE_MASK_VISIBLE,STATE_MASK_AUTOPOSITION,STATE_MASK_CHILDWIN,STATE_MASK_FOCUSED,STATE_MASK_UNDECORATED,STATE_MASK_ALWAYSONTOP,STATE_MASK_ALWAYSONBOTTOM,STATE_MASK_STICKY,STATE_MASK_RESIZABLE,STATE_MASK_MAXIMIZED_VERT,STATE_MASK_MAXIMIZED_HORZ,STATE_MASK_FULLSCREEN,STATE_MASK_POINTERVISIBLE,STATE_MASK_POINTERCONFINED,STATE_MASK_REPOSITIONABLE
-
getStateMaskString
String getStateMaskString()
Returns a string representation of thecurrent state mask.- Since:
- 2.3.2
-
getSupportedStateMask
int getSupportedStateMask()
Returns the supportedstate maskof the implementation.Implementation provides supported
state maskvalues at runtime after native window creation, i.e. first visibility.Please note that a window's size shall also be allowed to change, i.e.
setSize(int, int).Default minimum value is
STATE_MASK_VISIBLE|STATE_MASK_FOCUSED, i.e. the minimum requirement for all implementations.Usual desktop minimum value is
STATE_MASK_VISIBLE|STATE_MASK_FOCUSED|STATE_MASK_FULLSCREEN|STATE_MASK_RESIZABLE|STATE_MASK_REPOSITIONABLE.Before native window creation
getStatePublicBitmask()is returned, i.e. it is assumed all features are supported.Semantic of the supported state-mask bits (after native creation, i.e. 1st visibility):
STATE_MASK_VISIBLE:Visibilitycan be toggled. Minimum requirement.STATE_MASK_CHILDWIN:Native window parentingis supported.STATE_MASK_FOCUSED: Windowfocus managementis supported. Minimum requirement.STATE_MASK_UNDECORATED:Window decorationcan be toggled.STATE_MASK_ALWAYSONTOP: Window can be setalways-on-top.STATE_MASK_ALWAYSONBOTTOM: Window can be setalways-on-bottom.STATE_MASK_STICKY: Window can be setsticky.STATE_MASK_RESIZABLE: Windowresizabilitycan be toggled and it'ssizecan be changed.STATE_MASK_MAXIMIZED_VERT: Window can bemaximized-vertically.STATE_MASK_MAXIMIZED_HORZ: Window can bemaximized-horizontally.STATE_MASK_FULLSCREEN: Windowfullscreencan be toggled.STATE_MASK_POINTERVISIBLE: Windowpointer visibilitycan be toggled.STATE_MASK_POINTERCONFINED: Windowpointer can be confined.STATE_MASK_REPOSITIONABLE: Windowpositioncan be changed.
- Since:
- 2.3.2
- See Also:
getStateMask()
-
getSupportedStateMaskString
String getSupportedStateMaskString()
Returns a string representation of thesupported state mask.- Since:
- 2.3.2
-
isNativeValid
boolean isNativeValid()
- Returns:
- true if the native window handle is valid and ready to operate, ie
if the native window has been created via
setVisible(true), otherwise false. - See Also:
setVisible(boolean),#destroy(boolean)
-
getMainMonitor
MonitorDevice getMainMonitor()
Returns theMonitorDevicewith the highestviewportcoverageof this window.If no coverage is detected the first
MonitorDeviceis returned.
-
setCapabilitiesChooser
CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser)
Set the CapabilitiesChooser to help determine the native visual type.- Parameters:
chooser- the new CapabilitiesChooser- Returns:
- the previous CapabilitiesChooser
-
getRequestedCapabilities
CapabilitiesImmutable getRequestedCapabilities()
Gets an immutable set of requested capabilities.- Returns:
- the requested capabilities
-
getChosenCapabilities
CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.- Returns:
- the chosen capabilities
-
destroy
void destroy()
Destroys this window incl. releasing all related resources.Also iterates through this window's children and destroys them.
Visibility is set to false.
Method sends out
pre-andpost-destruction events to all of it'sWindowListener.This method invokes
Screen.removeReference()after it's own destruction,
which will issueScreen.destroy()if the reference count becomes 0.
This destruction sequence shall end up inDisplay.destroy(), if all reference counts become 0.The Window can be recreate via
setVisible(true).This method is lifecycle heavy.
- Specified by:
destroyin interfaceNativeWindow- See Also:
destroy(),setVisible(boolean)
-
setWindowDestroyNotifyAction
void setWindowDestroyNotifyAction(Runnable r)
-
setVisible
void setVisible(boolean visible)
CallssetVisible(true, visible), i.e. blocks until the window becomes visible.This method is lifecycle heavy.
- See Also:
setVisible(boolean, boolean),STATE_BIT_VISIBLE
-
setVisible
void setVisible(boolean wait, boolean visible)setVisible(..)makes the window and children visible ifvisibleis true, otherwise the window and children becomes invisible.Native instance gets created at first visibility, following NEWT's lazy creation pattern.
If
waitis true, method blocks until window isvisibleandvalid, otherwise method returns immediately.Zero size semantics are respected, see
setSize(int,int):
if ( 0 == windowHandle && visible ) { this.visible = visible; if( 0 < width && 0 < height ) { createNative(); } } else if ( this.visible != visible ) { this.visible = visible; setNativeSizeImpl(); }In case this window is
a child windowand has aNativeWindowparent,
setVisible(wait, true)has no effect as long the parent's is not valid yet, i.e.NativeWindow.getWindowHandle()returnsnull.
setVisible(wait, true)shall be repeated when the parent becomes valid.This method is lifecycle heavy.
- See Also:
STATE_BIT_VISIBLE
-
isVisible
boolean isVisible()
- See Also:
STATE_BIT_VISIBLE,setVisible(boolean, boolean)
-
getDelegatedWindow
Window getDelegatedWindow()
If the implementation uses delegation, return the delegatedWindowinstance, otherwise returnthisinstance.
-
addChild
boolean addChild(NativeWindow win)
-
removeChild
boolean removeChild(NativeWindow win)
-
getPixelsPerMM
float[] getPixelsPerMM(float[] ppmmStore)
Returns the pixels per millimeter of this window'sNativeSurfaceaccording to themain monitor's currentmode'ssurface resolution.Method takes the
current surface-scaleandnative surface-scaleinto account, i.e.:surfacePpMM = monitorPpMM * currentSurfaceScale / nativeSurfaceScale, with PpMM == pixel per millimeterTo convert the result to dpi, i.e. dots-per-inch, multiply both components with
25.4f.- Parameters:
ppmmStore- float[2] storage for the ppmm result- Returns:
- the passed storage containing the ppmm for chaining
-
setSize
void setSize(int width, int height)Sets the size of the window's client area in window units, excluding decorations.Zero size semantics are respected, see
setVisible(boolean):
if ( visible && 0 != windowHandle && ( 0 ≥ width || 0 ≥ height ) ) { setVisible(false); } else if ( visible && 0 == windowHandle && 0 < width && 0 < height ) { setVisible(true); } else { // as expected .. }This call is ignored if in fullscreen mode.
- Parameters:
width- of the window's client area in window unitsheight- of the window's client area in window units- See Also:
setSurfaceSize(int, int),setTopLevelSize(int, int),NativeWindow.getInsets()
-
setSurfaceSize
void setSurfaceSize(int pixelWidth, int pixelHeight)Sets the size of the window's surface in pixel units which claims the window's client area excluding decorations.In multiple monitor mode, setting the window's surface size in pixel units might not be possible due to unknown scale values of the target display. Hence re-setting the pixel unit size after window creation is recommended.
Zero size semantics are respected, see
setVisible(boolean):
if ( visible && 0 != windowHandle && ( 0 ≥ width || 0 ≥ height ) ) { setVisible(false); } else if ( visible && 0 == windowHandle && 0 < width && 0 < height ) { setVisible(true); } else { // as expected .. }This call is ignored if in fullscreen mode.
- Parameters:
pixelWidth- of the window's client area in pixel unitspixelHeight- of the window's client area in pixel units- See Also:
setSize(int, int),NativeWindow.getInsets()
-
setTopLevelSize
void setTopLevelSize(int width, int height)Sets the size of the top-level window including insets (window decorations) in window units.Note: Insets (if supported) are available only after the window is set visible and hence has been created.
- Parameters:
width- of the top-level window area in window unitsheight- of the top-level window area in window units- See Also:
setSize(int, int),NativeWindow.getInsets()
-
setPosition
void setPosition(int x, int y)Sets the location of the window's client area excluding insets (window decorations) in window units.
This call is ignored if in fullscreen mode.- Parameters:
x- coord of the client-area's top left corner in window unitsy- coord of the client-area's top left corner in window units- See Also:
NativeWindow.getInsets()
-
setTopLevelPosition
void setTopLevelPosition(int x, int y)Sets the location of the top-level window inclusive insets (window decorations) in window units.
Note: Insets (if supported) are available only after the window is set visible and hence has been created.
This call is ignored if in fullscreen mode.- Parameters:
x- coord of the top-level left corner in window unitsy- coord of the top-level left corner in window units- See Also:
setPosition(int, int),NativeWindow.getInsets()
-
setUndecorated
void setUndecorated(boolean value)
-
isUndecorated
boolean isUndecorated()
-
setAlwaysOnTop
void setAlwaysOnTop(boolean value)
Operation is ignored if this instance
is a child window.
-
isAlwaysOnTop
boolean isAlwaysOnTop()
-
setAlwaysOnBottom
void setAlwaysOnBottom(boolean value)
Operation is ignored if this instance
is a child window.- Since:
- 2.3.2
-
isAlwaysOnBottom
boolean isAlwaysOnBottom()
- Since:
- 2.3.2
-
setResizable
void setResizable(boolean value)
Operation is ignored if this instance
is a child window.- Since:
- 2.3.2
-
isResizable
boolean isResizable()
- Since:
- 2.3.2
-
setSticky
void setSticky(boolean value)
Operation is ignored if this instance
is a child window.- Since:
- 2.3.2
-
isSticky
boolean isSticky()
- Since:
- 2.3.2
-
setMaximized
void setMaximized(boolean horz, boolean vert)Operation is ignored if this instance
is a child window.- Since:
- 2.3.2
-
isMaximizedVert
boolean isMaximizedVert()
- Since:
- 2.3.2
-
isMaximizedHorz
boolean isMaximizedHorz()
- Since:
- 2.3.2
-
setTitle
void setTitle(String title)
-
getTitle
String getTitle()
-
isPointerVisible
boolean isPointerVisible()
- See Also:
setPointerVisible(boolean)
-
setPointerVisible
void setPointerVisible(boolean pointerVisible)
Makes the pointer visible or invisible.- Parameters:
pointerVisible- defaults totruefor platforms w/ visible pointer, otherwise defaults totrue, eg. Android.- See Also:
confinePointer(boolean)
-
getPointerIcon
Display.PointerIcon getPointerIcon()
Returns the currentDisplay.PointerIcon, which maybenullfor the default.- See Also:
setPointerIcon(PointerIcon)
-
setPointerIcon
void setPointerIcon(Display.PointerIcon pi)
- Parameters:
pi- ValidDisplay.PointerIconreference ornullto reset the pointer icon to default.- See Also:
Display.PointerIcon,Display.createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int)
-
isPointerConfined
boolean isPointerConfined()
- See Also:
confinePointer(boolean)
-
confinePointer
void confinePointer(boolean confine)
Confine the pointer to this window, ie. pointer jail.Before jailing the mouse pointer, the window request the focus and the pointer is centered in the window.
In combination w/
warpPointer(int, int)and maybesetPointerVisible(boolean)a simple mouse navigation can be realized.- Parameters:
confine- defaults tofalse.
-
warpPointer
void warpPointer(int x, int y)Moves the pointer to x/y relative to this window's origin in pixel units.- Parameters:
x- relative pointer x position within this window in pixel unitsy- relative pointer y position within this window in pixel units- See Also:
confinePointer(boolean)
-
reparentWindow
Window.ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints)
Change this window's parent window.
In case the old parent is not null and a Window, this window is removed from it's list of children.
In case the new parent is not null and a Window, this window is added to it's list of children.This method is lifecycle heavy.
- Parameters:
newParent- The new parent NativeWindow. If null, this Window becomes a top level window.x- new top-level position in window units, use -1 for default position.y- new top-level position in window units, use -1 for default position.hints- May contain hints (bitfield values) likeREPARENT_HINT_FORCE_RECREATIONorREPARENT_HINT_BECOMES_VISIBLE.- Returns:
- The issued reparent action type (strategy) as defined in Window.ReparentAction
-
isChildWindow
boolean isChildWindow()
Returnstrueif this window is a child window, i.e. has beenreparented.Otherwise return
false, i.e. this window is a top-level window.
-
setFullscreen
boolean setFullscreen(boolean fullscreen)
Enable or disable fullscreen mode for this window.Fullscreen mode is established on the
main monitor.This method is lifecycle heavy.
- Parameters:
fullscreen- enable or disable fullscreen mode- Returns:
- success
- See Also:
setFullscreen(List),isFullscreen()
-
setFullscreen
boolean setFullscreen(List<MonitorDevice> monitors)
Enable fullscreen mode for this window spanning across the givenMonitorDevices or across allMonitorDevices.Disable fullscreen via
setFullscreen(boolean).This method is lifecycle heavy.
- Parameters:
monitors- ifnullfullscreen will be spanned across allMonitorDevices, otherwise across the given list ofMonitorDevice.- Returns:
- success
- See Also:
setFullscreen(boolean),isFullscreen()
-
isFullscreen
boolean isFullscreen()
-
setFocusAction
void setFocusAction(Window.FocusRunnable focusAction)
Sets aWindow.FocusRunnable, whichWindow.FocusRunnable.run()method is executed before the native focus is requested.This allows notifying a covered window toolkit like AWT that the focus is requested, hence focus traversal can be made transparent.
-
setKeyboardFocusHandler
void setKeyboardFocusHandler(KeyListener l)
Sets aKeyListenerallowing focus traversal with a covered window toolkit like AWT.The
KeyListenermethods are invoked prior to all otherKeyListener's allowing to suppress theKeyEventvia theNEWTEvent.consumedTagand to perform focus traversal with a 3rd party toolkit.The
KeyListenermethods are not invoked forauto-repeatevents.- Parameters:
l-
-
requestFocus
void requestFocus()
Request focus for this native windowThe request is handled on this Window EDT and blocked until finished.
- See Also:
requestFocus(boolean)
-
requestFocus
void requestFocus(boolean wait)
Request focus for this native windowThe request is handled on this Window EDT.
- Parameters:
wait- true if waiting until the request is executed, otherwise false- See Also:
requestFocus()
-
windowRepaint
boolean windowRepaint(int x, int y, int width, int height)Trigger window repaint while passing the dirty region in pixel units.- Parameters:
x- dirty-region y-pos in pixel unitsy- dirty-region x-pos in pixel unitswidth- dirty-region width in pixel unitsheight- dirty-region height in pixel units- Returns:
- true if window
isNativeValid()
-
enqueueEvent
void enqueueEvent(boolean wait, NEWTEvent event)Enqueues aNEWT event.- Parameters:
wait- Passingtruewill block until the event has been processed, otherwise method returns immediately.event- Theeventto enqueue.
-
runOnEDTIfAvail
void runOnEDTIfAvail(boolean wait, Runnable task)
-
toSimpleString
StringBuilder toSimpleString(StringBuilder sb)
Appends this class simple string one-line representation to the givenStringBuilderinstance- Parameters:
sb- given instance where this class simple string representation is added to- Returns:
- the given
StringBuilderfor chaining
-
toSimpleString
String toSimpleString()
Returns a simple string one-line representation of this instance usingtoSimpleString(StringBuilder).
-
toString
StringBuilder toString(StringBuilder sb)
Appends this class full string multi-line representation to the givenStringBuilderinstance- Parameters:
sb- given instance where this class full string representation is added to- Returns:
- the given
StringBuilderfor chaining
-
toString
String toString()
Returns a full string multi-line representation of this instance usingtoString(StringBuilder).
-
sendWindowEvent
void sendWindowEvent(int eventType)
Send aWindowEventto allWindowListener.- Parameters:
eventType- aWindowEventtype, e.g.WindowEvent.EVENT_WINDOW_REPAINT.
-
addWindowListener
void addWindowListener(WindowListener l)
Appends the givenWindowListenerto the end of the list.
-
addWindowListener
void addWindowListener(int index, WindowListener l) throws IndexOutOfBoundsExceptionInserts the givenWindowListenerat the specified position in the list.- Parameters:
index- Position where the listener will be inserted. Should be within (0 <= index && index <= size()). An index value of -1 is interpreted as the end of the list, size().l- The listener object to be inserted- Throws:
IndexOutOfBoundsException- If the index is not within (0 <= index && index <= size()), or -1
-
removeWindowListener
void removeWindowListener(WindowListener l)
-
getWindowListener
WindowListener getWindowListener(int index)
-
getWindowListeners
WindowListener[] getWindowListeners()
-
setKeyboardVisible
void setKeyboardVisible(boolean visible)
In case the platform supports or even requires a virtual on-screen keyboard, this method shows or hide it depending on whethervisibleistrueorfalse.One known platform where NEWT supports this feature is
Android.
-
isKeyboardVisible
boolean isKeyboardVisible()
Returntrueif the virtual on-screen keyboard is visible, otherwisefalse.Currently on
Android, the only supported platform right now, there is no way to reliably be notified of the current keyboard state.
It would be best, if your code does not rely on this information.- See Also:
setKeyboardVisible(boolean)
-
addKeyListener
void addKeyListener(KeyListener l)
Appends the givenKeyListenerto the end of the list.
-
addKeyListener
void addKeyListener(int index, KeyListener l)Inserts the givenKeyListenerat the specified position in the list.- Parameters:
index- Position where the listener will be inserted. Should be within (0 <= index && index <= size()). An index value of -1 is interpreted as the end of the list, size().l- The listener object to be inserted- Throws:
IndexOutOfBoundsException- If the index is not within (0 <= index && index <= size()), or -1
-
removeKeyListener
void removeKeyListener(KeyListener l)
-
getKeyListener
KeyListener getKeyListener(int index)
-
getKeyListeners
KeyListener[] getKeyListeners()
-
addMouseListener
void addMouseListener(MouseListener l)
Appends the givenMouseListenerto the end of the list.
-
addMouseListener
void addMouseListener(int index, MouseListener l)Inserts the givenMouseListenerat the specified position in the list.- Parameters:
index- Position where the listener will be inserted. Should be within (0 <= index && index <= size()). An index value of -1 is interpreted as the end of the list, size().l- The listener object to be inserted- Throws:
IndexOutOfBoundsException- If the index is not within (0 <= index && index <= size()), or -1
-
removeMouseListener
void removeMouseListener(MouseListener l)
Removes the givenMouseListenerfrom the list.
-
getMouseListener
MouseListener getMouseListener(int index)
Returns theMouseListenerfrom the list at the given index.
-
getMouseListeners
MouseListener[] getMouseListeners()
Returns allMouseListener
-
setDefaultGesturesEnabled
void setDefaultGesturesEnabled(boolean enable)
Enable or disable defaultGestureHandler. Default is enabled.
-
areDefaultGesturesEnabled
boolean areDefaultGesturesEnabled()
Return true if defaultGestureHandlerare enabled.
-
addGestureHandler
void addGestureHandler(GestureHandler gh)
Appends the givenGestureHandlerto the end of the list.
-
addGestureHandler
void addGestureHandler(int index, GestureHandler gh)Inserts the givenGestureHandlerat the specified position in the list.- Parameters:
index- Position where the listener will be inserted. Should be within (0 <= index && index <= size()). An index value of -1 is interpreted as the end of the list, size().l- The listener object to be inserted- Throws:
IndexOutOfBoundsException- If the index is not within (0 <= index && index <= size()), or -1
-
removeGestureHandler
void removeGestureHandler(GestureHandler gh)
Removes the givenGestureHandlerfrom the list.
-
addGestureListener
void addGestureListener(GestureHandler.GestureListener gl)
Appends the givenGestureHandler.GestureListenerto the end of the list.
-
addGestureListener
void addGestureListener(int index, GestureHandler.GestureListener gl)Inserts the givenGestureHandler.GestureListenerat the specified position in the list.- Parameters:
index- Position where the listener will be inserted. Should be within (0 <= index && index <= size()). An index value of -1 is interpreted as the end of the list, size().l- The listener object to be inserted- Throws:
IndexOutOfBoundsException- If the index is not within (0 <= index && index <= size()), or -1
-
removeGestureListener
void removeGestureListener(GestureHandler.GestureListener gl)
Removes the givenGestureHandler.GestureListenerfrom the list.
-
-