Completed WindowBorder and WindowState implementation.

This commit is contained in:
the_fiddler 2008-04-21 18:36:16 +00:00
parent 8000c46892
commit c5731cb986

View file

@ -450,6 +450,9 @@ namespace OpenTK.Platform.Windows
} }
set set
{ {
if (WindowState == value)
return;
IntPtr style = Functions.GetWindowLong(Handle, GetWindowLongOffsets.STYLE); IntPtr style = Functions.GetWindowLong(Handle, GetWindowLongOffsets.STYLE);
ShowWindowCommand command = (ShowWindowCommand)0; ShowWindowCommand command = (ShowWindowCommand)0;
SetWindowPosFlags flags = SetWindowPosFlags.NOREPOSITION; SetWindowPosFlags flags = SetWindowPosFlags.NOREPOSITION;
@ -460,6 +463,10 @@ namespace OpenTK.Platform.Windows
case WindowState.Normal: case WindowState.Normal:
command = ShowWindowCommand.RESTORE; command = ShowWindowCommand.RESTORE;
flags |= SetWindowPosFlags.SHOWWINDOW | SetWindowPosFlags.FRAMECHANGED; flags |= SetWindowPosFlags.SHOWWINDOW | SetWindowPosFlags.FRAMECHANGED;
if (WindowState == WindowState.Fullscreen || WindowState == WindowState.Maximized)
WindowBorder = previous_window_border;
new_width = previous_client_area.Width; new_width = previous_client_area.Width;
new_height = previous_client_area.Height; new_height = previous_client_area.Height;
break; break;
@ -471,21 +478,20 @@ namespace OpenTK.Platform.Windows
case WindowState.Maximized: case WindowState.Maximized:
case WindowState.Fullscreen: case WindowState.Fullscreen:
if (windowState == WindowState.Normal || windowState == WindowState.Minimized) if (WindowState == WindowState.Normal || WindowState == WindowState.Minimized)
{ {
// Get the normal size of the window, so we can set it when reverting from fullscreen/maximized to normal. // Get the normal size of the window, so we can set it when reverting from fullscreen/maximized to normal.
previous_client_area = new Rectangle(width, height); previous_client_area = new Rectangle(window_size.Width, window_size.Height);
previous_window_border = windowBorder; previous_window_border = WindowBorder;
//Functions.AdjustWindowRect(ref previous_client_area, WindowStyle.OverlappedWindow, false);
} }
command = ShowWindowCommand.SHOWMAXIMIZED; command = ShowWindowCommand.SHOWMAXIMIZED;
flags |= SetWindowPosFlags.SHOWWINDOW | SetWindowPosFlags.DRAWFRAME | SetWindowPosFlags.NOSIZE; flags |= SetWindowPosFlags.SHOWWINDOW | SetWindowPosFlags.DRAWFRAME | SetWindowPosFlags.NOSIZE;
if (value == WindowState.Fullscreen) if (value == WindowState.Fullscreen)
windowBorder = WindowBorder.Hidden; this.WindowBorder = WindowBorder.Hidden;
else else
windowBorder = previous_window_border; this.WindowBorder = previous_window_border;
break; break;
} }
@ -525,12 +531,13 @@ namespace OpenTK.Platform.Windows
break; break;
case WindowBorder.Hidden: case WindowBorder.Hidden:
style &= WindowStyle.Popup; style |= WindowStyle.Popup;
break; break;
} }
Functions.SetWindowLong(Handle, GetWindowLongOffsets.STYLE, (IntPtr)(int)style); Functions.SetWindowLong(Handle, GetWindowLongOffsets.STYLE, (IntPtr)(int)style);
windowBorder = value;
} }
} }