com.jogamp.newt
Class Window

java.lang.Object
  extended by com.jogamp.newt.Window
All Implemented Interfaces:
NativeWindow, SurfaceUpdatedListener
Direct Known Subclasses:
GLWindow, OffscreenWindow

public abstract class Window
extends Object
implements NativeWindow


Field Summary
static int ClickTimeout
           
protected  AbstractGraphicsConfiguration config
           
static boolean DEBUG_IMPLEMENTATION
           
static boolean DEBUG_KEY_EVENT
           
static boolean DEBUG_MOUSE_EVENT
           
static boolean DEBUG_WINDOW_EVENT
           
protected  int eventMask
           
protected  boolean fullscreen
           
protected  int height
           
protected  Screen screen
           
protected  String title
           
protected  boolean undecorated
           
protected  boolean visible
           
protected  int width
           
protected  long windowHandle
           
protected  int x
           
protected  int y
           
 
Fields inherited from interface javax.media.nativewindow.NativeWindow
LOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY
 
Constructor Summary
Window()
           
 
Method Summary
 void addKeyListener(KeyListener l)
           
 void addMouseListener(MouseListener l)
           
 void addPaintListener(PaintListener l)
           
 void addSurfaceUpdatedListener(SurfaceUpdatedListener l)
           
 void addWindowListener(WindowListener l)
           
protected  void clearEventMask()
           
protected abstract  void closeNative()
           
protected static Window create(String type, long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated)
           
protected static Window create(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated)
           
protected abstract  void createNative(long parentWindowHandle, Capabilities caps)
          Create native windowHandle, ie creates a new native invisible window.
 void destroy()
          destroys the window and releases windowing related resources.
 void destroy(boolean deep)
           
 long getDisplayHandle()
          Convenience: Get display handle from AbstractGraphicsConfiguration .
 AbstractGraphicsConfiguration getGraphicsConfiguration()
          Returns the graphics configuration corresponding to this window.
 int getHeight()
          Returns the height of the client area of this window
 Insets getInsets()
          Returns the insets for this native window (the difference between the size of the toplevel window with the decorations and the client area).
 KeyListener[] getKeyListeners()
           
 Exception getLockedStack()
          Return the lock-exception, or null if not locked.
 MouseListener[] getMouseListeners()
           
 Screen getScreen()
           
 int getScreenIndex()
          Convenience: Get display handle from AbstractGraphicsConfiguration .
 long getSurfaceHandle()
          Returns the handle to the surface for this NativeWindow.
 Thread getSurfaceLockOwner()
           
 SurfaceUpdatedListener[] getSurfaceUpdatedListener()
           
 String getTitle()
           
 int getWidth()
          Returns the width of the client area of this window
 long getWindowHandle()
          Returns the window handle for this NativeWindow.
 WindowListener[] getWindowListeners()
           
 Object getWrappedWindow()
          If this Window actually wraps one from another toolkit such as the AWT, this will return a non-null value.
 int getX()
           
 int getY()
           
 boolean hasDeviceChanged()
          If the implementation is capable of detecting a device change return true and clear the status/reason of the change.
 void invalidate()
          render all native window information invalid, as if the native window was destroyed
 boolean isFullscreen()
           
 boolean isSurfaceLocked()
          Return if surface is locked
 boolean isUndecorated()
           
 boolean isVisible()
           
 int lockSurface()
          Recursive and blocking lockSurface() implementation
 void removeAllSurfaceUpdatedListener()
           
 void removeKeyListener(KeyListener l)
           
 void removeMouseListener(MouseListener l)
           
 void removePaintListener(PaintListener l)
           
 void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
           
 void removeWindowListener(WindowListener l)
           
 void requestFocus()
           
 void sendEvent(NEWTEvent e)
           
protected  void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar)
           
protected  void sendKeyEvent(KeyEvent e)
           
protected  void sendMouseEvent(int eventType, int modifiers, int x, int y, int button, int rotation)
          Be aware that this method synthesizes the events: MouseClicked and MouseDragged
protected  void sendMouseEvent(MouseEvent e)
           
protected  void sendPaintEvent(int eventType, int x, int y, int w, int h)
           
protected  void sendPaintEvent(PaintEvent e)
           
protected  void sendWindowEvent(int eventType)
           
protected  void sendWindowEvent(WindowEvent e)
           
 void setAutoDrawableClient(boolean b)
          If set to true, certain action will be performed by the owning AutoDrawable, ie the destroy() call within windowDestroyNotify()
abstract  boolean setFullscreen(boolean fullscreen)
           
abstract  void setPosition(int x, int y)
          Sets the location of the top left corner of the window, including decorations (so the client area will be placed at x+insets.left,y+insets.top.
This call is ignored if in fullscreen mode.
abstract  void setSize(int width, int height)
          Sets the size of the client area of the window, excluding decorations Total size of the window will be width+insets.left+insets.right, height+insets.top+insets.bottom
This call is ignored if in fullscreen mode.
 void setTitle(String title)
           
 void setUndecorated(boolean value)
           
abstract  void setVisible(boolean visible)
           
 boolean surfaceSwap()
          Provide a mechanism to utilize custom (pre-) swap surface code.
 void surfaceUpdated(Object updater, NativeWindow window, long when)
          Notification of a surface update event.
static String toHexString(int hex)
           
static String toHexString(long hex)
           
 String toString()
           
 void unlockSurface()
          Recursive and unblocking unlockSurface() implementation
protected  void windowDestroyed()
           
protected  void windowDestroyNotify()
           
protected static Window wrapHandle(String type, Screen screen, AbstractGraphicsConfiguration config, long windowHandle, boolean fullscreen, boolean visible, int x, int y, int width, int height)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG_MOUSE_EVENT

public static final boolean DEBUG_MOUSE_EVENT

DEBUG_KEY_EVENT

public static final boolean DEBUG_KEY_EVENT

DEBUG_WINDOW_EVENT

public static final boolean DEBUG_WINDOW_EVENT

DEBUG_IMPLEMENTATION

public static final boolean DEBUG_IMPLEMENTATION

screen

protected Screen screen

config

protected AbstractGraphicsConfiguration config

windowHandle

protected long windowHandle

fullscreen

protected boolean fullscreen

visible

protected boolean visible

width

protected int width

height

protected int height

x

protected int x

y

protected int y

eventMask

protected int eventMask

title

protected String title

undecorated

protected boolean undecorated

ClickTimeout

public static final int ClickTimeout
See Also:
Constant Field Values
Constructor Detail

Window

public Window()
Method Detail

create

protected static Window create(String type,
                               long parentWindowHandle,
                               Screen screen,
                               Capabilities caps,
                               boolean undecorated)

create

protected static Window create(String type,
                               Object[] cstrArguments,
                               Screen screen,
                               Capabilities caps,
                               boolean undecorated)

wrapHandle

protected static Window wrapHandle(String type,
                                   Screen screen,
                                   AbstractGraphicsConfiguration config,
                                   long windowHandle,
                                   boolean fullscreen,
                                   boolean visible,
                                   int x,
                                   int y,
                                   int width,
                                   int height)

toHexString

public static String toHexString(int hex)

toHexString

public static String toHexString(long hex)

createNative

protected abstract void createNative(long parentWindowHandle,
                                     Capabilities caps)
Create native windowHandle, ie creates a new native invisible window. The parentWindowHandle may be null, in which case no window parenting is requested. Shall use the capabilities to determine the graphics configuration and shall set the chosen capabilities.


closeNative

protected abstract void closeNative()

getScreen

public Screen getScreen()

toString

public String toString()
Overrides:
toString in class Object

getTitle

public String getTitle()

setTitle

public void setTitle(String title)

setUndecorated

public void setUndecorated(boolean value)

isUndecorated

public boolean isUndecorated()

requestFocus

public void requestFocus()

lockSurface

public int lockSurface()
Recursive and blocking lockSurface() implementation

Specified by:
lockSurface in interface NativeWindow
Returns:
NativeWindow.LOCK_SUCCESS, NativeWindow.LOCK_SURFACE_CHANGED or NativeWindow.LOCK_SURFACE_NOT_READY.
See Also:
ToolkitLock

unlockSurface

public void unlockSurface()
                   throws NativeWindowException
Recursive and unblocking unlockSurface() implementation

Specified by:
unlockSurface in interface NativeWindow
Throws:
NativeWindowException - if surface is not locked
See Also:
NativeWindow.lockSurface(), ToolkitLock

isSurfaceLocked

public boolean isSurfaceLocked()
Description copied from interface: NativeWindow
Return if surface is locked

Specified by:
isSurfaceLocked in interface NativeWindow

getSurfaceLockOwner

public Thread getSurfaceLockOwner()

getLockedStack

public Exception getLockedStack()
Description copied from interface: NativeWindow
Return the lock-exception, or null if not locked. The lock-exception is created at NativeWindow.lockSurface() and hence holds the locker's call stack.

Specified by:
getLockedStack in interface NativeWindow

destroy

public void destroy()
Description copied from interface: NativeWindow
destroys the window and releases windowing related resources.

Specified by:
destroy in interface NativeWindow

destroy

public void destroy(boolean deep)
Parameters:
deep - If true, the linked Screen and Display will be destroyed as well.

invalidate

public void invalidate()
Description copied from interface: NativeWindow
render all native window information invalid, as if the native window was destroyed

Specified by:
invalidate in interface NativeWindow
See Also:
NativeWindow.destroy()

surfaceSwap

public boolean surfaceSwap()
Description copied from interface: NativeWindow
Provide a mechanism to utilize custom (pre-) swap surface code. This method is called before the render toolkit (e.g. JOGL) swaps the buffer/surface. The implementation may itself apply the swapping, in which case true shall be returned.

Specified by:
surfaceSwap in interface NativeWindow
Returns:
true if this method completed swapping the surface, otherwise false, in which case eg the GLDrawable implementation has to swap the code.

clearEventMask

protected void clearEventMask()

getDisplayHandle

public long getDisplayHandle()
Description copied from interface: NativeWindow
Convenience: Get display handle from AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice

Specified by:
getDisplayHandle in interface NativeWindow

getScreenIndex

public int getScreenIndex()
Description copied from interface: NativeWindow
Convenience: Get display handle from AbstractGraphicsConfiguration . AbstractGraphicsScreen

Specified by:
getScreenIndex in interface NativeWindow

getWindowHandle

public long getWindowHandle()
Description copied from interface: NativeWindow
Returns the window handle for this NativeWindow.

The window handle should be set/update by NativeWindow.lockSurface(), where NativeWindow.unlockSurface() is not allowed to modify it.
After NativeWindow.unlockSurface() it is no more guaranteed that the window handle is still valid.

The window handle shall reflect the platform one for all window related operations, e.g. open, close, resize.

On X11 this returns an entity of type Window.
On Microsoft Windows this returns an entity of type HWND.

Specified by:
getWindowHandle in interface NativeWindow

getSurfaceHandle

public long getSurfaceHandle()
Description copied from interface: NativeWindow
Returns the handle to the surface for this NativeWindow.

The surface handle should be set/update by NativeWindow.lockSurface(), where NativeWindow.unlockSurface() is not allowed to modify it. After NativeWindow.unlockSurface() it is no more guaranteed that the surface handle is still valid. The surface handle shall reflect the platform one for all drawable surface operations, e.g. opengl, swap-buffer.

On X11 this returns an entity of type Window, since there is no differentiation of surface and window there.
On Microsoft Windows this returns an entity of type HDC.

Specified by:
getSurfaceHandle in interface NativeWindow

getGraphicsConfiguration

public AbstractGraphicsConfiguration getGraphicsConfiguration()
Description copied from interface: NativeWindow
Returns the graphics configuration corresponding to this window.

Specified by:
getGraphicsConfiguration in interface NativeWindow
See Also:
GraphicsConfigurationFactory.chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)

getWidth

public int getWidth()
Returns the width of the client area of this window

Specified by:
getWidth in interface NativeWindow
Returns:
width of the client area

getHeight

public int getHeight()
Returns the height of the client area of this window

Specified by:
getHeight in interface NativeWindow
Returns:
height of the client area

getInsets

public Insets getInsets()
Returns the insets for this native window (the difference between the size of the toplevel window with the decorations and the client area).

Returns:
insets for this platform window

getWrappedWindow

public Object getWrappedWindow()
If this Window actually wraps one from another toolkit such as the AWT, this will return a non-null value.


getX

public int getX()

getY

public int getY()

isVisible

public boolean isVisible()

isFullscreen

public boolean isFullscreen()

hasDeviceChanged

public boolean hasDeviceChanged()
If the implementation is capable of detecting a device change return true and clear the status/reason of the change.


setAutoDrawableClient

public void setAutoDrawableClient(boolean b)
If set to true, certain action will be performed by the owning AutoDrawable, ie the destroy() call within windowDestroyNotify()


windowDestroyNotify

protected void windowDestroyNotify()

windowDestroyed

protected void windowDestroyed()

setVisible

public abstract void setVisible(boolean visible)

setSize

public abstract void setSize(int width,
                             int height)
Sets the size of the client area of the window, excluding decorations Total size of the window will be width+insets.left+insets.right, height+insets.top+insets.bottom
This call is ignored if in fullscreen mode.

Parameters:
width - of the client area of the window
height - of the client area of the window

setPosition

public abstract void setPosition(int x,
                                 int y)
Sets the location of the top left corner of the window, including decorations (so the client area will be placed at x+insets.left,y+insets.top.
This call is ignored if in fullscreen mode.

Parameters:
x - coord of the top left corner
y - coord of the top left corner

setFullscreen

public abstract boolean setFullscreen(boolean fullscreen)

addSurfaceUpdatedListener

public void addSurfaceUpdatedListener(SurfaceUpdatedListener l)

removeSurfaceUpdatedListener

public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)

removeAllSurfaceUpdatedListener

public void removeAllSurfaceUpdatedListener()

getSurfaceUpdatedListener

public SurfaceUpdatedListener[] getSurfaceUpdatedListener()

surfaceUpdated

public void surfaceUpdated(Object updater,
                           NativeWindow window,
                           long when)
Description copied from interface: SurfaceUpdatedListener
Notification of a surface update event.

Specified by:
surfaceUpdated in interface SurfaceUpdatedListener
Parameters:
updater - is the caller object who updated the surface, e.g. a JOGL GLDrawable.
window - the NativeWindow, which surface is updated
when - the time in ms, when the surface was updated

sendEvent

public void sendEvent(NEWTEvent e)

addMouseListener

public void addMouseListener(MouseListener l)

removeMouseListener

public void removeMouseListener(MouseListener l)

getMouseListeners

public MouseListener[] getMouseListeners()

sendMouseEvent

protected void sendMouseEvent(int eventType,
                              int modifiers,
                              int x,
                              int y,
                              int button,
                              int rotation)
Be aware that this method synthesizes the events: MouseClicked and MouseDragged


sendMouseEvent

protected void sendMouseEvent(MouseEvent e)

addKeyListener

public void addKeyListener(KeyListener l)

removeKeyListener

public void removeKeyListener(KeyListener l)

getKeyListeners

public KeyListener[] getKeyListeners()

sendKeyEvent

protected void sendKeyEvent(int eventType,
                            int modifiers,
                            int keyCode,
                            char keyChar)

sendKeyEvent

protected void sendKeyEvent(KeyEvent e)

addWindowListener

public void addWindowListener(WindowListener l)

removeWindowListener

public void removeWindowListener(WindowListener l)

getWindowListeners

public WindowListener[] getWindowListeners()

sendWindowEvent

protected void sendWindowEvent(int eventType)

sendWindowEvent

protected void sendWindowEvent(WindowEvent e)

addPaintListener

public void addPaintListener(PaintListener l)

removePaintListener

public void removePaintListener(PaintListener l)

sendPaintEvent

protected void sendPaintEvent(int eventType,
                              int x,
                              int y,
                              int w,
                              int h)

sendPaintEvent

protected void sendPaintEvent(PaintEvent e)


Copyright 2010 JogAmp Community.