Interface IWindowComponent
Interface for abstraction layer drivers which implement the window component.
Inherited Members
Namespace: OpenTK.Core.Platform
Assembly: OpenTK.Core.dll
Syntax
public interface IWindowComponent : IPalComponent
Properties
CanCaptureCursor
True when the driver supports capturing the cursor in a window.
Declaration
bool CanCaptureCursor { get; }
Property Value
Type | Description |
---|---|
bool |
CanGetDisplay
True when the driver can provide the display the window is in.
Declaration
bool CanGetDisplay { get; }
Property Value
Type | Description |
---|---|
bool |
CanSetCursor
True when the driver supports setting the cursor of the window.
Declaration
bool CanSetCursor { get; }
Property Value
Type | Description |
---|---|
bool |
CanSetIcon
True when the driver supports setting the window icon.
Declaration
bool CanSetIcon { get; }
Property Value
Type | Description |
---|---|
bool |
SupportedEvents
Read-only list of event types the driver supports.
Declaration
IReadOnlyList<PlatformEventType> SupportedEvents { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<PlatformEventType> |
SupportedModes
Read-only list of window modes the driver supports.
Declaration
IReadOnlyList<WindowMode> SupportedModes { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<WindowMode> |
SupportedStyles
Read-only list of window styles the driver supports.
Declaration
IReadOnlyList<WindowBorderStyle> SupportedStyles { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<WindowBorderStyle> |
Methods
ClientToScreen(WindowHandle, int, int, out int, out int)
Converts window relative coordinates to screen coordinates.
Declaration
void ClientToScreen(WindowHandle handle, int clientX, int clientY, out int x, out int y)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window handle. |
int | clientX | The client x coordinate. |
int | clientY | The client y coordinate. |
int | x | The screen x coordinate. |
int | y | The screen y coordinate. |
Create(GraphicsApiHints)
Create a window object.
Declaration
WindowHandle Create(GraphicsApiHints hints)
Parameters
Type | Name | Description |
---|---|---|
GraphicsApiHints | hints | Graphics API hints to be passed to the operating system. |
Returns
Type | Description |
---|---|
WindowHandle | Handle to the new window object. |
Destroy(WindowHandle)
Destroy a window object.
Declaration
void Destroy(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window object. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
FocusWindow(WindowHandle)
Gives the window input focus.
Declaration
void FocusWindow(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to the window to focus. |
GetBorderStyle(WindowHandle)
Get the border style of a window.
Declaration
WindowBorderStyle GetBorderStyle(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to window. |
Returns
Type | Description |
---|---|
WindowBorderStyle | The border style of the window. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GetBounds(WindowHandle, out int, out int, out int, out int)
Get the bounds of the window.
Declaration
void GetBounds(WindowHandle handle, out int x, out int y, out int width, out int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | x | X coordinate of the window. |
int | y | Y coordinate of the window. |
int | width | Width of the window in pixels. |
int | height | Height of the window in pixels. |
GetClientBounds(WindowHandle, out int, out int, out int, out int)
Get the client area bounds (drawing area) of a window.
Declaration
void GetClientBounds(WindowHandle handle, out int x, out int y, out int width, out int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | x | X coordinate of the client area. |
int | y | Y coordinate of the client area. |
int | width | Width of the client area in pixels. |
int | height | Height of the client area in pixels. |
GetClientPosition(WindowHandle, out int, out int)
Get the position of the client area (drawing area) of a window.
Declaration
void GetClientPosition(WindowHandle handle, out int x, out int y)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | x | X coordinate of the client area. |
int | y | Y coordinate of the client area. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GetClientSize(WindowHandle, out int, out int)
Get the size of the client area (drawing area) of a window.
Declaration
void GetClientSize(WindowHandle handle, out int width, out int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | width | Width of the client area in pixels. |
int | height | Height of the client area in pixels. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GetCursorCaptureMode(WindowHandle)
Gets the current cursor capture mode. See SetCursorCaptureMode(WindowHandle, CursorCaptureMode) for more details.
Declaration
CursorCaptureMode GetCursorCaptureMode(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Returns
Type | Description |
---|---|
CursorCaptureMode | The current cursor capture mode. |
GetDisplay(WindowHandle)
Get the display handle a window is in.
Declaration
DisplayHandle GetDisplay(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Returns
Type | Description |
---|---|
DisplayHandle | The display handle the window is in. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
PalNotImplementedException | Driver does not support finding the window display. CanGetDisplay. |
GetFramebufferSize(WindowHandle, out int, out int)
Get the size of the window framebuffer in pixels. Use this value when calls to graphics APIs that want pixels, e.g. GL.Viewport().
Declaration
void GetFramebufferSize(WindowHandle handle, out int width, out int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | width | Width in pixels of the window framebuffer. |
int | height | Height in pixels of the window framebuffer. |
GetFullscreenDisplay(WindowHandle, out DisplayHandle?)
Gets the display that the specified window is fullscreen on, if the window is fullscreen.
Declaration
bool GetFullscreenDisplay(WindowHandle handle, out DisplayHandle? display)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window handle. |
DisplayHandle | display | The display where the window is fullscreen or null if the window is not fullscreen. |
Returns
Type | Description |
---|---|
bool |
|
GetIcon(WindowHandle)
Get a handle to the window icon object.
Declaration
IconHandle? GetIcon(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Returns
Type | Description |
---|---|
IconHandle | Handle to the windows icon object, or null if none is set. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
PalNotImplementedException | Driver does not support getting the window icon. See CanSetIcon. |
GetMaxClientSize(WindowHandle, out int?, out int?)
Gets the maximum size of the client area.
Declaration
void GetMaxClientSize(WindowHandle handle, out int? width, out int? height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int? | width | The maximum width of the client area of the window, or null if no limit is set. |
int? | height | The maximum height of the client area of the window, or null if no limit is set. |
GetMinClientSize(WindowHandle, out int?, out int?)
Gets the minimum size of the client area.
Declaration
void GetMinClientSize(WindowHandle handle, out int? width, out int? height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int? | width | The minimum width of the client area of the window, or null if no limit is set. |
int? | height | The minimum height of the client area of the window, or null if no limit is set. |
GetMode(WindowHandle)
Get the mode of a window.
Declaration
WindowMode GetMode(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Returns
Type | Description |
---|---|
WindowMode | The mode of the window. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GetPosition(WindowHandle, out int, out int)
Get the window position in display coordinates (top left origin).
Declaration
void GetPosition(WindowHandle handle, out int x, out int y)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | x | X coordinate of the window. |
int | y | Y coordinate of the window. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GetScaleFactor(WindowHandle, out float, out float)
Returns the current scale factor of this window.
Declaration
void GetScaleFactor(WindowHandle handle, out float scaleX, out float scaleY)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window handle. |
float | scaleX | The x scale factor of the window. |
float | scaleY | The y scale factor of the window. |
See Also
GetSize(WindowHandle, out int, out int)
Get the size of the window.
Declaration
void GetSize(WindowHandle handle, out int width, out int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | width | Width of the window in pixels. |
int | height | Height of the window in pixels. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GetTitle(WindowHandle)
Get the title of a window.
Declaration
string GetTitle(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Returns
Type | Description |
---|---|
string | The title of the window. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
IsAlwaysOnTop(WindowHandle)
Gets if the current window is always on top or not.
Declaration
bool IsAlwaysOnTop(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | A handle to the window to get whether or not is always on top. |
Returns
Type | Description |
---|---|
bool | Whether the window is always on top or not. |
IsFocused(WindowHandle)
Returns true if the given window has input focus.
Declaration
bool IsFocused(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Returns
Type | Description |
---|---|
bool | If the window has input focus. |
IsWindowDestroyed(WindowHandle)
Checks if Destroy(WindowHandle) has been called on this handle.
Declaration
bool IsWindowDestroyed(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window handle to check if it's destroyed or not. |
Returns
Type | Description |
---|---|
bool | If Destroy(WindowHandle) was called with the window handle. |
ProcessEvents(bool)
Processes platform events and sends them to the EventQueue.
Declaration
void ProcessEvents(bool waitForEvents = false)
Parameters
Type | Name | Description |
---|---|---|
bool | waitForEvents | Specifies if this function should wait for events or return immediately if there are no events. |
RequestAttention(WindowHandle)
Requests that the user pay attention to the window.
Declaration
void RequestAttention(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | A handle to the window that requests attention. |
ScreenToClient(WindowHandle, int, int, out int, out int)
Converts screen coordinates to window relative coordinates.
Declaration
void ScreenToClient(WindowHandle handle, int x, int y, out int clientX, out int clientY)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window handle. |
int | x | The screen x coordinate. |
int | y | The screen y coordinate. |
int | clientX | The client x coordinate. |
int | clientY | The client y coordinate. |
SetAlwaysOnTop(WindowHandle, bool)
Set if the window is an always on top window or not.
Declaration
void SetAlwaysOnTop(WindowHandle handle, bool floating)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | A handle to the window to make always on top. |
bool | floating | Whether the window should be always on top or not. |
SetBorderStyle(WindowHandle, WindowBorderStyle)
Set the border style of a window.
Declaration
void SetBorderStyle(WindowHandle handle, WindowBorderStyle style)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
WindowBorderStyle | style | The new border style of the window. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
PalNotImplementedException | Driver does not support the value set by |
SetBounds(WindowHandle, int, int, int, int)
Set the bounds of the window.
Declaration
void SetBounds(WindowHandle handle, int x, int y, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | x | New X coordinate of the window. |
int | y | New Y coordinate of the window. |
int | width | New width of the window in pixels. |
int | height | New height of the window in pixels. |
SetClientBounds(WindowHandle, int, int, int, int)
Set the client area bounds (drawing area) of a window.
Declaration
void SetClientBounds(WindowHandle handle, int x, int y, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | x | New X coordinate of the client area. |
int | y | New Y coordinate of the client area. |
int | width | New width of the client area in pixels. |
int | height | New height of the client area in pixels. |
SetClientPosition(WindowHandle, int, int)
Set the position of the client area (drawing area) of a window.
Declaration
void SetClientPosition(WindowHandle handle, int x, int y)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | x | New X coordinate of the client area. |
int | y | New Y coordinate of the client area. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SetClientSize(WindowHandle, int, int)
Set the size of the client area (drawing area) of a window.
Declaration
void SetClientSize(WindowHandle handle, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | width | New width of the client area in pixels. |
int | height | New height of the client area in pixels. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SetCursor(WindowHandle, CursorHandle?)
Set the cursor object for a window.
Declaration
void SetCursor(WindowHandle handle, CursorHandle? cursor)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
CursorHandle | cursor | Handle to a cursor object, or null for hidden cursor. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
PalNotImplementedException | Driver does not support setting the window mouse cursor. See CanSetCursor. |
SetCursorCaptureMode(WindowHandle, CursorCaptureMode)
Sets the cursor capture mode of the window. A cursor can be confined to the bounds of the window, or locked to the center of the window.
Declaration
void SetCursorCaptureMode(WindowHandle handle, CursorCaptureMode mode)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
CursorCaptureMode | mode | The cursor capture mode. |
SetFullscreenDisplay(WindowHandle, DisplayHandle?)
Put a window into 'windowed fullscreen' on a specified display or the display the window is displayed on.
If display
is null
then the window will be made fullscreen on the 'nearest' display.
Declaration
void SetFullscreenDisplay(WindowHandle handle, DisplayHandle? display)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window to make fullscreen. |
DisplayHandle | display | The display to make the window fullscreen on. |
Remarks
To make an 'exclusive fullscreen' window see SetFullscreenDisplay(WindowHandle, DisplayHandle, VideoMode).
SetFullscreenDisplay(WindowHandle, DisplayHandle, VideoMode)
Put a window into 'exclusive fullscreen' on a specified display and change the video mode to the specified video mode. Only video modes accuired using GetSupportedVideoModes(DisplayHandle) are expected to work.
Declaration
void SetFullscreenDisplay(WindowHandle handle, DisplayHandle display, VideoMode videoMode)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window to make fullscreen. |
DisplayHandle | display | The display to make the window fullscreen on. |
VideoMode | videoMode | The video mode to use when making the window fullscreen. |
Remarks
To make an 'windowed fullscreen' window see SetFullscreenDisplay(WindowHandle, DisplayHandle?).
SetHitTestCallback(WindowHandle, HitTest?)
Sets a delegate that is used for hit testing. Hit testing allows the user to specify if a click should start a drag or resize operation on the window.
Hit testing is not always done in respone to the user clicking the mouse. The operating system can do hit testing for any reason and doesn't need to be in respose to some user action. It is recommended to keep this code efficient as it will be called often.
Declaration
void SetHitTestCallback(WindowHandle handle, HitTest? test)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window for which this hit test delegate should be used for. |
HitTest | test | The hit test delegate. |
SetIcon(WindowHandle, IconHandle)
Set window icon object handle.
Declaration
void SetIcon(WindowHandle handle, IconHandle icon)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
IconHandle | icon | Handle to an icon object, or null to revert to default. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
PalNotImplementedException | Driver does not support setting the window icon. See CanSetIcon. |
SetMaxClientSize(WindowHandle, int?, int?)
Sets the maximum size of the client area.
Declaration
void SetMaxClientSize(WindowHandle handle, int? width, int? height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int? | width | New maximum width of the client area of the window, or null to remove limit. |
int? | height | New maximum height of the client area of the window, or null to remove limit. |
SetMinClientSize(WindowHandle, int?, int?)
Sets the minimum size of the client area.
Declaration
void SetMinClientSize(WindowHandle handle, int? width, int? height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int? | width | New minimum width of the client area of the window, or null to remove limit. |
int? | height | New minimum height of the client area of the window, or null to remove limit. |
SetMode(WindowHandle, WindowMode)
Set the mode of a window.
Declaration
void SetMode(WindowHandle handle, WindowMode mode)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
WindowMode | mode | The new mode of the window. |
Remarks
Setting WindowedFullscreen or ExclusiveFullscreen will make the window fullscreen in the nearest monitor to the window location. Use SetFullscreenDisplay(WindowHandle, DisplayHandle?) or SetFullscreenDisplay(WindowHandle, DisplayHandle, VideoMode) to explicitly set the monitor.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
PalNotImplementedException | Driver does not support the value set by |
SetPosition(WindowHandle, int, int)
Set the window position in display coordinates (top left origin).
Declaration
void SetPosition(WindowHandle handle, int x, int y)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | x | New X coordinate of the window. |
int | y | New Y coordinate of the window. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SetSize(WindowHandle, int, int)
Set the size of the window.
Declaration
void SetSize(WindowHandle handle, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | width | New width of the window in pixels. |
int | height | New height of the window in pixels. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SetTitle(WindowHandle, string)
Set the title of a window.
Declaration
void SetTitle(WindowHandle handle, string title)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
string | title | New window title string. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|