decouple wxTLW,Frame::ShowFullScreen in wxMSW

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12003 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2001-10-14 22:54:06 +00:00
parent 065f27fe3a
commit c641b1d20d
2 changed files with 81 additions and 62 deletions

View File

@@ -109,14 +109,10 @@ void wxFrameMSW::Init()
#endif
// Data to save/restore when calling ShowFullScreen
m_fsStyle = 0;
m_fsOldWindowStyle = 0;
m_fsStatusBarFields = 0;
m_fsStatusBarHeight = 0;
m_fsToolBarHeight = 0;
// m_fsMenu = 0;
m_fsIsMaximized = FALSE;
m_fsIsShowing = FALSE;
m_winLastFocused = (wxWindow *)NULL;
}
@@ -320,14 +316,11 @@ void wxFrameMSW::OnSysColourChanged(wxSysColourChangedEvent& event)
// Pass TRUE to show full screen, FALSE to restore.
bool wxFrameMSW::ShowFullScreen(bool show, long style)
{
if ( IsFullScreen() == show )
return FALSE;
if (show)
{
if (IsFullScreen())
return FALSE;
m_fsIsShowing = TRUE;
m_fsStyle = style;
#if wxUSE_TOOLBAR
wxToolBar *theToolBar = GetToolBar();
if (theToolBar)
@@ -363,54 +356,9 @@ bool wxFrameMSW::ShowFullScreen(bool show, long style)
else
m_fsStatusBarFields = 0;
#endif // wxUSE_STATUSBAR
// zap the frame borders
// save the 'normal' window style
m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
// save the old position, width & height, maximize state
m_fsOldSize = GetRect();
m_fsIsMaximized = IsMaximized();
// decide which window style flags to turn off
LONG newStyle = m_fsOldWindowStyle;
LONG offFlags = 0;
if (style & wxFULLSCREEN_NOBORDER)
offFlags |= WS_BORDER | WS_THICKFRAME;
if (style & wxFULLSCREEN_NOCAPTION)
offFlags |= (WS_CAPTION | WS_SYSMENU);
newStyle &= (~offFlags);
// change our window style to be compatible with full-screen mode
::SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
// resize to the size of the desktop
int width, height;
RECT rect = wxGetWindowRect(::GetDesktopWindow());
width = rect.right - rect.left;
height = rect.bottom - rect.top;
SetSize(width, height);
// now flush the window style cache and actually go full-screen
SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
wxSizeEvent event(wxSize(width, height), GetId());
GetEventHandler()->ProcessEvent(event);
return TRUE;
}
else
{
if (!IsFullScreen())
return FALSE;
m_fsIsShowing = FALSE;
#if wxUSE_TOOLBAR
wxToolBar *theToolBar = GetToolBar();
@@ -438,14 +386,9 @@ bool wxFrameMSW::ShowFullScreen(bool show, long style)
if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
#endif
Maximize(m_fsIsMaximized);
SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
return TRUE;
}
return wxFrameBase::ShowFullScreen(show, style);
}
// Default activation behaviour - set the focus for the first child

View File

@@ -93,6 +93,12 @@ void wxTopLevelWindowMSW::Init()
// unlike (almost?) all other windows, frames are created hidden
m_isShown = FALSE;
// Data to save/restore when calling ShowFullScreen
m_fsStyle = 0;
m_fsOldWindowStyle = 0;
m_fsIsMaximized = FALSE;
m_fsIsShowing = FALSE;
}
long wxTopLevelWindowMSW::MSWGetCreateWindowFlags(long *exflags) const
@@ -477,6 +483,76 @@ void wxTopLevelWindowMSW::Restore()
DoShowWindow(SW_RESTORE);
}
// ----------------------------------------------------------------------------
// wxTopLevelWindowMSW fullscreen
// ----------------------------------------------------------------------------
bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
{
if (show)
{
if (IsFullScreen())
return FALSE;
m_fsIsShowing = TRUE;
m_fsStyle = style;
// zap the frame borders
// save the 'normal' window style
m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
// save the old position, width & height, maximize state
m_fsOldSize = GetRect();
m_fsIsMaximized = IsMaximized();
// decide which window style flags to turn off
LONG newStyle = m_fsOldWindowStyle;
LONG offFlags = 0;
if (style & wxFULLSCREEN_NOBORDER)
offFlags |= WS_BORDER | WS_THICKFRAME;
if (style & wxFULLSCREEN_NOCAPTION)
offFlags |= (WS_CAPTION | WS_SYSMENU);
newStyle &= (~offFlags);
// change our window style to be compatible with full-screen mode
::SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
// resize to the size of the desktop
int width, height;
RECT rect = wxGetWindowRect(::GetDesktopWindow());
width = rect.right - rect.left;
height = rect.bottom - rect.top;
SetSize(width, height);
// now flush the window style cache and actually go full-screen
SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
wxSizeEvent event(wxSize(width, height), GetId());
GetEventHandler()->ProcessEvent(event);
return TRUE;
}
else
{
if (!IsFullScreen())
return FALSE;
m_fsIsShowing = FALSE;
Maximize(m_fsIsMaximized);
SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
return TRUE;
}
}
// ----------------------------------------------------------------------------
// wxTopLevelWindowMSW misc
// ----------------------------------------------------------------------------