Added INativeWindow.CreateKeyboardDriver()

Added INativeWindow.KeyPress event (KeyPressEventArgs).
Removed INativeWindow.Icon property.
This commit is contained in:
the_fiddler 2009-07-19 17:49:51 +00:00
parent a9352e441b
commit 67bdd39d08
11 changed files with 123 additions and 49 deletions

View file

@ -1052,31 +1052,6 @@ namespace OpenTK
#region --- INativeWindow Members ---
#region Icon
/// <summary>
/// Gets or sets the System.Drawing.Icon for this GameWindow.
/// </summary>
public Icon Icon
{
get
{
if (disposed)
throw new ObjectDisposedException(this.GetType().Name);
return glWindow.Icon;
}
set
{
if (disposed)
throw new ObjectDisposedException(this.GetType().Name);
glWindow.Icon = value;
}
}
#endregion
#region Focused
/// <summary>
@ -1456,11 +1431,6 @@ namespace OpenTK
/// </summary>
public event EventHandler<EventArgs> Disposed = delegate { };
/// <summary>
/// Occurs when the <see cref="Icon"/> property of the window changes.
/// </summary>
public event EventHandler<EventArgs> IconChanged = delegate { };
/// <summary>
/// Occurs when the <see cref="Title"/> property of the window changes.
/// </summary>
@ -1476,6 +1446,11 @@ namespace OpenTK
/// </summary>
public event EventHandler<EventArgs> FocusedChanged = delegate { };
/// <summary>
/// Occurs whenever a character is typed.
/// </summary>
public event EventHandler<KeyPressEventArgs> KeyPress = delegate { };
#endregion
#endregion

View file

@ -39,11 +39,6 @@ namespace OpenTK
/// </summary>
public interface INativeWindow : IDisposable
{
/// <summary>
/// Gets or sets the <see cref="System.Drawing.Icon"/> of the window.
/// </summary>
Icon Icon { get; set; }
/// <summary>
/// Gets or sets the title of the window.
/// </summary>
@ -186,11 +181,6 @@ namespace OpenTK
/// </summary>
event EventHandler<EventArgs> Disposed;
/// <summary>
/// Occurs when the <see cref="Icon"/> property of the window changes.
/// </summary>
event EventHandler<EventArgs> IconChanged;
/// <summary>
/// Occurs when the <see cref="Title"/> property of the window changes.
/// </summary>
@ -206,6 +196,11 @@ namespace OpenTK
/// </summary>
event EventHandler<EventArgs> FocusedChanged;
/// <summary>
/// Occurs whenever a character is typed.
/// </summary>
event EventHandler<KeyPressEventArgs> KeyPress;
//event EventHandler<EventArgs> MouseEnter;
//event EventHandler<MouseEventArgs> MouseMove;
//event EventHandler<MouseEventArgs> MouseWheel;
@ -216,7 +211,7 @@ namespace OpenTK
//event EventHandler<KeyEventArgs> KeyDown;
//event EventHandler<KeyEventArgs> KeyUp;
//event EventHandler<KeyEventArgs> KeyPress;
//event EventHandler<DragEventArgs> DragDrop;
//event EventHandler<DragEventArgs> DragEnter;

View file

@ -0,0 +1,58 @@
// #region License
// //
// // The Open Toolkit Library License
// //
// // Copyright (c) 2006 - 2009 the Open Toolkit library.
// //
// // Permission is hereby granted, free of charge, to any person obtaining a copy
// // of this software and associated documentation files (the "Software"), to deal
// // in the Software without restriction, including without limitation the rights to
// // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// // the Software, and to permit persons to whom the Software is furnished to do
// // so, subject to the following conditions:
// //
// // The above copyright notice and this permission notice shall be included in all
// // copies or substantial portions of the Software.
// //
// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// // OTHER DEALINGS IN THE SOFTWARE.
// //
// #endregion
using System;
namespace OpenTK
{
/// <summary>
/// Defines the event arguments for KeyPress events. Instances of this class are cached:
/// KeyPressEventArgs should only be used inside the relevant event, unless manually cloned.
/// </summary>
public class KeyPressEventArgs : EventArgs
{
char key_char;
/// <summary>
/// Constructs a new instance.
/// </summary>
/// <param name="keyChar">The ASCII character that was typed.</param>
public KeyPressEventArgs(char keyChar)
{
KeyChar = keyChar;
}
/// <summary>
/// Gets a <see cref="System.Char"/> that defines the ASCII character that was typed.
/// </summary>
public char KeyChar
{
get { return key_char; }
private set { key_char = value; }
}
}
}

View file

@ -95,39 +95,54 @@ namespace OpenTK.Platform
return implementation.CreateGraphicsMode();
}
public OpenTK.Input.IKeyboardDriver CreateKeyboardDriver()
{
return implementation.CreateKeyboardDriver();
}
class UnsupportedPlatform : IPlatformFactory
{
#region Fields
static readonly string error_string = "Please, refer to http://www.opentk.com for more information.";
#endregion
#region IPlatformFactory Members
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
{
throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information.");
throw new PlatformNotSupportedException(error_string);
}
public IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
{
throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information.");
throw new PlatformNotSupportedException(error_string);
}
public IDisplayDeviceDriver CreateDisplayDeviceDriver()
{
throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information.");
throw new PlatformNotSupportedException(error_string);
}
public IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool DirectRendering, int major, int minor, GraphicsContextFlags flags)
{
throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information.");
throw new PlatformNotSupportedException(error_string);
}
public GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext()
{
throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information.");
throw new PlatformNotSupportedException(error_string);
}
public IGraphicsMode CreateGraphicsMode()
{
throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information.");
throw new PlatformNotSupportedException(error_string);
}
public OpenTK.Input.IKeyboardDriver CreateKeyboardDriver()
{
throw new PlatformNotSupportedException(error_string);
}
#endregion

View file

@ -46,5 +46,7 @@ namespace OpenTK.Platform
OpenTK.Graphics.GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext();
OpenTK.Graphics.IGraphicsMode CreateGraphicsMode();
OpenTK.Input.IKeyboardDriver CreateKeyboardDriver();
}
}

View file

@ -949,6 +949,8 @@ namespace OpenTK.Platform.MacOS
public event EventHandler<EventArgs> FocusedChanged;
public event EventHandler<KeyPressEventArgs> KeyPress;
#endregion
}
}

View file

@ -70,6 +70,11 @@ namespace OpenTK.Platform.MacOS
return new MacOSGraphicsMode();
}
public OpenTK.Input.IKeyboardDriver CreateKeyboardDriver()
{
throw new NotImplementedException();
}
#endregion
}
}

View file

@ -71,6 +71,11 @@ using OpenTK.Input;
return new WinGraphicsMode();
}
public OpenTK.Input.IKeyboardDriver CreateKeyboardDriver()
{
throw new NotImplementedException();
}
#endregion
}
}

View file

@ -907,6 +907,8 @@ namespace OpenTK.Platform.Windows
public event EventHandler<EventArgs> FocusedChanged;
public event EventHandler<KeyPressEventArgs> KeyPress;
#endregion
#endregion

View file

@ -43,6 +43,11 @@ namespace OpenTK.Platform.X11
return new X11GraphicsMode();
}
public OpenTK.Input.IKeyboardDriver CreateKeyboardDriver()
{
throw new NotImplementedException();
}
#endregion
}
}

View file

@ -609,11 +609,19 @@ namespace OpenTK.Platform.X11
break;
case XEventName.KeyPress:
driver.ProcessEvent(ref e);
break;
case XEventName.KeyRelease:
// Todo: raise KeyPress event. Use code from
// http://anonsvn.mono-project.com/viewvc/trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Keyboard.cs?view=markup
driver.ProcessEvent(ref e);
break;
case XEventName.MotionNotify:
case XEventName.ButtonPress:
case XEventName.ButtonRelease:
//Functions.XPutBackEvent(window.Display, ref e);
driver.ProcessEvent(ref e);
break;
@ -852,6 +860,8 @@ namespace OpenTK.Platform.X11
public event EventHandler<EventArgs> FocusedChanged;
public event EventHandler<KeyPressEventArgs> KeyPress;
#endregion
#endregion