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:
@@ -109,14 +109,10 @@ void wxFrameMSW::Init()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Data to save/restore when calling ShowFullScreen
|
// Data to save/restore when calling ShowFullScreen
|
||||||
m_fsStyle = 0;
|
|
||||||
m_fsOldWindowStyle = 0;
|
|
||||||
m_fsStatusBarFields = 0;
|
m_fsStatusBarFields = 0;
|
||||||
m_fsStatusBarHeight = 0;
|
m_fsStatusBarHeight = 0;
|
||||||
m_fsToolBarHeight = 0;
|
m_fsToolBarHeight = 0;
|
||||||
// m_fsMenu = 0;
|
// m_fsMenu = 0;
|
||||||
m_fsIsMaximized = FALSE;
|
|
||||||
m_fsIsShowing = FALSE;
|
|
||||||
|
|
||||||
m_winLastFocused = (wxWindow *)NULL;
|
m_winLastFocused = (wxWindow *)NULL;
|
||||||
}
|
}
|
||||||
@@ -320,14 +316,11 @@ void wxFrameMSW::OnSysColourChanged(wxSysColourChangedEvent& event)
|
|||||||
// Pass TRUE to show full screen, FALSE to restore.
|
// Pass TRUE to show full screen, FALSE to restore.
|
||||||
bool wxFrameMSW::ShowFullScreen(bool show, long style)
|
bool wxFrameMSW::ShowFullScreen(bool show, long style)
|
||||||
{
|
{
|
||||||
|
if ( IsFullScreen() == show )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
if (IsFullScreen())
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
m_fsIsShowing = TRUE;
|
|
||||||
m_fsStyle = style;
|
|
||||||
|
|
||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
wxToolBar *theToolBar = GetToolBar();
|
wxToolBar *theToolBar = GetToolBar();
|
||||||
if (theToolBar)
|
if (theToolBar)
|
||||||
@@ -363,54 +356,9 @@ bool wxFrameMSW::ShowFullScreen(bool show, long style)
|
|||||||
else
|
else
|
||||||
m_fsStatusBarFields = 0;
|
m_fsStatusBarFields = 0;
|
||||||
#endif // wxUSE_STATUSBAR
|
#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
|
else
|
||||||
{
|
{
|
||||||
if (!IsFullScreen())
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
m_fsIsShowing = FALSE;
|
|
||||||
|
|
||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
wxToolBar *theToolBar = GetToolBar();
|
wxToolBar *theToolBar = GetToolBar();
|
||||||
|
|
||||||
@@ -438,14 +386,9 @@ bool wxFrameMSW::ShowFullScreen(bool show, long style)
|
|||||||
if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
|
if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
|
||||||
SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
|
SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
|
||||||
#endif
|
#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
|
// Default activation behaviour - set the focus for the first child
|
||||||
|
@@ -93,6 +93,12 @@ void wxTopLevelWindowMSW::Init()
|
|||||||
|
|
||||||
// unlike (almost?) all other windows, frames are created hidden
|
// unlike (almost?) all other windows, frames are created hidden
|
||||||
m_isShown = FALSE;
|
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
|
long wxTopLevelWindowMSW::MSWGetCreateWindowFlags(long *exflags) const
|
||||||
@@ -477,6 +483,76 @@ void wxTopLevelWindowMSW::Restore()
|
|||||||
DoShowWindow(SW_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
|
// wxTopLevelWindowMSW misc
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user