2007-09-09 18:07:39 +02:00
|
|
|
|
#region --- License ---
|
|
|
|
|
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
|
|
|
|
* See license.txt for license info
|
|
|
|
|
*/
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
using System;
|
2007-09-09 13:53:25 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace OpenTK.Platform
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Describes a Windows.Form.Control, Windows.Forms.NativeWindow or OpenTK.GameWindow.
|
|
|
|
|
/// </summary>
|
2007-09-09 17:10:21 +02:00
|
|
|
|
public sealed class WindowInfo : IMutableWindowInfo
|
2007-09-09 13:53:25 +02:00
|
|
|
|
{
|
2007-09-09 17:10:21 +02:00
|
|
|
|
IMutableWindowInfo implementation;
|
2007-09-09 13:53:25 +02:00
|
|
|
|
|
|
|
|
|
#region --- Constructors ---
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Detects the underlying platform and constructs a new WindowInfo class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <exception cref="PlatformNotSupportedException">Raised when the underlying platform is not supported.</exception>
|
|
|
|
|
public WindowInfo()
|
|
|
|
|
{
|
|
|
|
|
switch (Environment.OSVersion.Platform)
|
|
|
|
|
{
|
|
|
|
|
case PlatformID.Unix:
|
|
|
|
|
case (PlatformID)128:
|
|
|
|
|
implementation = new X11.WindowInfo();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PlatformID.Win32NT:
|
|
|
|
|
case PlatformID.Win32S:
|
|
|
|
|
case PlatformID.Win32Windows:
|
|
|
|
|
case PlatformID.WinCE:
|
|
|
|
|
implementation = new Windows.WindowInfo();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
throw new PlatformNotSupportedException("Your Operating System is not supported. Please refer to http://opentk.sourceforge.net for more information.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Detects the underlying platform and constructs a new WindowInfo class describing the specified Control.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="control">The System.Windows.Forms.Control to get info from.</param>
|
|
|
|
|
public WindowInfo(Control control) : this()
|
|
|
|
|
{
|
2007-09-09 17:10:21 +02:00
|
|
|
|
implementation.CopyInfoFrom(implementation.GetInfoFrom(control));
|
2007-09-09 13:53:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Detects the underlying platform and constructs a new WindowInfo class describing the specified NativeWindow.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="window">The System.Windows.Forms.NativeWindow to get info from.</param>
|
|
|
|
|
public WindowInfo(NativeWindow window) : this()
|
|
|
|
|
{
|
2007-09-21 22:07:30 +02:00
|
|
|
|
implementation.CopyInfoFrom(implementation.GetInfoFrom(window));
|
2007-09-09 13:53:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Detects the underlying platform and constructs a new WindowInfo class describing the specified GameWindow.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="window">The OpenTK.GameWindow to get info from.</param>
|
|
|
|
|
public WindowInfo(GameWindow window) : this()
|
|
|
|
|
{
|
2007-09-21 22:07:30 +02:00
|
|
|
|
implementation.CopyInfoFrom(implementation.GetInfoFrom(window));
|
2007-09-09 13:53:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region --- IWindowInfo Members ---
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the platform specific handle of the window described by the WindowInfo class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IntPtr Handle
|
|
|
|
|
{
|
|
|
|
|
get { return implementation.Handle; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the parent of the window described by the WindowInfo class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IWindowInfo Parent
|
|
|
|
|
{
|
|
|
|
|
get { return implementation.Parent; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates the WindowInfo to describe the specified Control.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="control">The System.Windows.Forms.Control to describe.</param>
|
2007-09-09 17:10:21 +02:00
|
|
|
|
public IWindowInfo GetInfoFrom(Control control)
|
2007-09-09 13:53:25 +02:00
|
|
|
|
{
|
2007-09-09 17:10:21 +02:00
|
|
|
|
return implementation.GetInfoFrom(control);
|
2007-09-09 13:53:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates the WindowInfo to describe the specified NativeWindow.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="window">The System.Windows.Forms.NativeWindow to describe.</param>
|
2007-09-09 17:10:21 +02:00
|
|
|
|
public IWindowInfo GetInfoFrom(NativeWindow window)
|
2007-09-09 13:53:25 +02:00
|
|
|
|
{
|
2007-09-09 17:10:21 +02:00
|
|
|
|
return implementation.GetInfoFrom(window);
|
2007-09-09 13:53:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates the WindowInfo to describe the specified GameWindow.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="window">The OpenTK.GameWindow to describe.</param>
|
2007-09-09 17:10:21 +02:00
|
|
|
|
public IWindowInfo GetInfoFrom(GameWindow window)
|
2007-09-09 13:53:25 +02:00
|
|
|
|
{
|
2007-09-09 17:10:21 +02:00
|
|
|
|
return implementation.GetInfoFrom(window);
|
2007-09-09 13:53:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2008-01-11 21:21:32 +01:00
|
|
|
|
/// Updates the WindowInfo using the specified IWindowInfo.
|
2007-09-09 13:53:25 +02:00
|
|
|
|
/// </summary>
|
2008-01-11 21:21:32 +01:00
|
|
|
|
/// <param name="window">The OpenTK.Platform.IWindowInfo to get information from.</param>
|
2007-09-09 17:10:21 +02:00
|
|
|
|
public IWindowInfo GetInfoFrom(IWindowInfo info)
|
|
|
|
|
{
|
|
|
|
|
return implementation.GetInfoFrom(info);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-21 22:07:30 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region --- IMutableWindowInfo Members ---
|
|
|
|
|
|
2007-09-09 17:10:21 +02:00
|
|
|
|
public void CopyInfoFrom(IWindowInfo info)
|
2007-09-09 13:53:25 +02:00
|
|
|
|
{
|
2007-09-09 17:10:21 +02:00
|
|
|
|
implementation.CopyInfoFrom(info);
|
2007-09-09 13:53:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-01-24 22:18:23 +01:00
|
|
|
|
//public static explicit operator Windows.WindowInfo(WindowInfo info)
|
|
|
|
|
//{
|
|
|
|
|
// return (Windows.WindowInfo)info.implementation;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//public static explicit operator X11.WindowInfo(WindowInfo info)
|
|
|
|
|
//{
|
|
|
|
|
// return (X11.WindowInfo)info.implementation;
|
|
|
|
|
//}
|
2007-09-21 22:07:30 +02:00
|
|
|
|
|
2007-09-09 13:53:25 +02:00
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|