Implemented icon support.

This commit is contained in:
the_fiddler 2009-10-18 16:52:07 +00:00
parent 42acbbf492
commit 951ad35596
4 changed files with 63 additions and 23 deletions

View file

@ -39,6 +39,11 @@ 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>
@ -184,6 +189,11 @@ 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>

View file

@ -287,6 +287,27 @@ namespace OpenTK
#endregion
#region Icon
/// <summary>
/// Gets or sets the System.Drawing.Icon for this GameWindow.
/// </summary>
public Icon Icon
{
get
{
EnsureUndisposed();
return implementation.Icon;
}
set
{
EnsureUndisposed();
implementation.Icon = value;
}
}
#endregion
#region InputDriver
/// <summary>
@ -529,6 +550,11 @@ namespace OpenTK
/// </summary>
public event EventHandler<EventArgs> FocusedChanged;
/// <summary>
/// Occurs when the <see cref="Icon"/> property of the window changes.
/// </summary>
public event EventHandler<EventArgs> IconChanged;
/// <summary>
/// Occurs whenever a character is typed.
/// </summary>
@ -682,6 +708,19 @@ namespace OpenTK
#endregion
#region OnIconChanged
/// <summary>
/// Called when the <see cref="OpenTK.INativeWindow.Icon"/> property of the NativeWindow has changed.
/// </summary>
/// <param name="e">Not used.</param>
protected virtual void OnIconChanged(EventArgs e)
{
if (IconChanged != null) IconChanged(this, e);
}
#endregion
#region OnKeyPress
/// <summary>
@ -824,6 +863,12 @@ namespace OpenTK
#endregion
#region OnIconChangedInternal
private void OnIconChangedInternal(object sender, EventArgs e) { OnIconChanged(e); }
#endregion
#region OnKeyPressInternal
private void OnKeyPressInternal(object sender, KeyPressEventArgs e) { OnKeyPress(e); }
@ -886,6 +931,7 @@ namespace OpenTK
implementation.Closing += OnClosingInternal;
implementation.Disposed += OnDisposedInternal;
implementation.FocusedChanged += OnFocusedChangedInternal;
implementation.IconChanged += OnIconChangedInternal;
implementation.KeyPress += OnKeyPressInternal;
implementation.Move += OnMoveInternal;
implementation.Resize += OnResizeInternal;
@ -901,6 +947,7 @@ namespace OpenTK
implementation.Closing -= OnClosingInternal;
implementation.Disposed -= OnDisposedInternal;
implementation.FocusedChanged -= OnFocusedChangedInternal;
implementation.IconChanged -= OnIconChangedInternal;
implementation.KeyPress -= OnKeyPressInternal;
implementation.Move -= OnMoveInternal;
implementation.Resize -= OnResizeInternal;

View file

@ -680,6 +680,12 @@ namespace OpenTK.Platform.MacOS
#region INativeWindow Members
public System.Drawing.Icon Icon
{
get { return null; }
set { }
}
public string Title
{
get

View file

@ -130,8 +130,6 @@ namespace OpenTK.Platform.Windows
keyboards.Add(keyboard);
mice.Add(mouse);
Icon = GetApplicationIcon();
}
#endregion
@ -455,27 +453,6 @@ namespace OpenTK.Platform.Windows
}
break;
case WindowMessage.GETICON:
if (icon != null)
{
icon.Dispose();
icon = null;
}
if (lParam != IntPtr.Zero)
{
icon = Icon.FromHandle(lParam);
}
else
{
IntPtr icon_handle = Functions.DefWindowProc(handle, message, wParam, lParam);
if (icon_handle != IntPtr.Zero)
icon = Icon.FromHandle(icon_handle);
return icon_handle;
}
break;
case WindowMessage.CLOSE:
System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs();