// Created: 24.09.01
// RCS-ID: $Id$
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
-// License: wxWindows license
+// License: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
#include "wx/msw/private.h"
-#include "wx/popupwin.h"
+#include "wx/display.h"
#ifndef ICON_BIG
#define ICON_BIG 1
WXDWORD msflags = wxWindow::MSWGetStyle
(
(style & ~wxBORDER_MASK) | wxBORDER_NONE, exflags
- ) & ~WS_CHILD;
+ ) & ~WS_CHILD & ~WS_VISIBLE;
// first select the kind of window being created
//
if ( exflags )
{
-#if !defined(__WIN16__) && !defined(__SC__)
+#if !defined(__WIN16__)
if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) )
{
if ( style & wxFRAME_TOOL_WINDOW )
long style,
const wxString& name)
{
+ bool ret = false;
+
// init our fields
Init();
if ( style & (wxRESIZE_BORDER | wxCAPTION) )
dlgTemplate->style |= DS_MODALFRAME;
- bool ret = CreateDialog(dlgTemplate, title, pos, size);
+ ret = CreateDialog(dlgTemplate, title, pos, size);
free(dlgTemplate);
-
- return ret;
}
else // !dialog
{
- return CreateFrame(title, pos, size);
+ ret = CreateFrame(title, pos, size);
}
+
+ if ( ret && !(GetWindowStyleFlag() & wxCLOSE_BOX) )
+ {
+ EnableCloseButton(false);
+ }
+
+ return ret;
}
wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
{
// we can't maximize the hidden frame because it shows it as well, so
// just remember that we should do it later in this case
- m_maximizeOnShow = TRUE;
+ m_maximizeOnShow = maximize;
}
}
bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
{
- if (show)
+ if ( show == IsFullScreen() )
{
- if (IsFullScreen())
- return FALSE;
+ // nothing to do
+ return TRUE;
+ }
+
+ m_fsIsShowing = show;
- m_fsIsShowing = TRUE;
+ if ( show )
+ {
m_fsStyle = style;
// zap the frame borders
// save the 'normal' window style
- m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
+ m_fsOldWindowStyle = GetWindowLong(GetHwnd(), GWL_STYLE);
// save the old position, width & height, maximize state
m_fsOldSize = GetRect();
if (style & wxFULLSCREEN_NOBORDER)
offFlags |= WS_BORDER | WS_THICKFRAME;
if (style & wxFULLSCREEN_NOCAPTION)
- offFlags |= (WS_CAPTION | WS_SYSMENU);
+ offFlags |= WS_CAPTION | WS_SYSMENU;
- newStyle &= (~offFlags);
+ 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;
+ ::SetWindowLong(GetHwnd(), GWL_STYLE, newStyle);
- RECT rect = wxGetWindowRect(::GetDesktopWindow());
- width = rect.right - rect.left;
- height = rect.bottom - rect.top;
+ wxRect rect;
+#if wxUSE_DISPLAY
+ // resize to the size of the display containing us
+ int dpy = wxDisplay::GetFromWindow(this);
+ if ( dpy != wxNOT_FOUND )
+ {
+ rect = wxDisplay(dpy).GetGeometry();
+ }
+ else // fall back to the main desktop
+#else // wxUSE_DISPLAY
+ {
+ // resize to the size of the desktop
+ wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect);
+ }
+#endif // wxUSE_DISPLAY
- SetSize(width, height);
+ SetSize(rect);
// now flush the window style cache and actually go full-screen
- SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
+ long flags = SWP_FRAMECHANGED;
- wxSizeEvent event(wxSize(width, height), GetId());
- GetEventHandler()->ProcessEvent(event);
+ // showing the frame full screen should also show it if it's still
+ // hidden
+ if ( !IsShown() )
+ {
+ // don't call wxWindow version to avoid flicker from calling
+ // ::ShowWindow() -- we're going to show the window at the correct
+ // location directly below -- but do call the wxWindowBase version
+ // to sync the internal m_isShown flag
+ wxWindowBase::Show();
- return TRUE;
- }
- else
- {
- if (!IsFullScreen())
- return FALSE;
+ flags |= SWP_SHOWWINDOW;
+ }
- m_fsIsShowing = FALSE;
+ SetWindowPos(GetHwnd(), HWND_TOP,
+ rect.x, rect.y, rect.width, rect.height,
+ flags);
+ // finally send an event allowing the window to relayout itself &c
+ wxSizeEvent event(rect.GetSize(), GetId());
+ GetEventHandler()->ProcessEvent(event);
+ }
+ else // stop showing full screen
+ {
Maximize(m_fsIsMaximized);
- SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
- SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
+ SetWindowLong(GetHwnd(),GWL_STYLE, m_fsOldWindowStyle);
+ SetWindowPos(GetHwnd(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
-
- return TRUE;
}
+
+ return TRUE;
}
// ----------------------------------------------------------------------------
HMENU hmenu = ::GetSystemMenu(GetHwnd(), FALSE /* get it */);
if ( !hmenu )
{
- wxLogLastError(_T("GetSystemMenu"));
-
- return FALSE;
+ // no system menu at all -- ok if we want to remove the close button
+ // anyhow, but bad if we want to show it
+ return !enable;
}
// enabling/disabling the close item from it also automatically
return TRUE;
}
+bool wxTopLevelWindowMSW::SetShape(const wxRegion& region)
+{
+ wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), FALSE,
+ _T("Shaped windows must be created with the wxFRAME_SHAPED style."));
+
+ // The empty region signifies that the shape should be removed from the
+ // window.
+ if ( region.IsEmpty() )
+ {
+ if (::SetWindowRgn(GetHwnd(), NULL, TRUE) == 0)
+ {
+ wxLogLastError(_T("SetWindowRgn"));
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ // Windows takes ownership of the region, so
+ // we'll have to make a copy of the region to give to it.
+ DWORD noBytes = ::GetRegionData(GetHrgnOf(region), 0, NULL);
+ RGNDATA *rgnData = (RGNDATA*) new char[noBytes];
+ ::GetRegionData(GetHrgnOf(region), noBytes, rgnData);
+ HRGN hrgn = ::ExtCreateRegion(NULL, noBytes, rgnData);
+ delete[] (char*) rgnData;
+
+ // SetWindowRgn expects the region to be in coordinants
+ // relative to the window, not the client area. Figure
+ // out the offset, if any.
+ RECT rect;
+ DWORD dwStyle = ::GetWindowLong(GetHwnd(), GWL_STYLE);
+ DWORD dwExStyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
+ ::GetClientRect(GetHwnd(), &rect);
+ ::AdjustWindowRectEx(&rect, dwStyle, FALSE, dwExStyle);
+ ::OffsetRgn(hrgn, -rect.left, -rect.top);
+
+ // Now call the shape API with the new region.
+ if (::SetWindowRgn(GetHwnd(), hrgn, TRUE) == 0)
+ {
+ wxLogLastError(_T("SetWindowRgn"));
+ return FALSE;
+ }
+ return TRUE;
+}
+
// ----------------------------------------------------------------------------
// wxTopLevelWindow event handling
// ----------------------------------------------------------------------------
}
}
- ms_hwnd = ::CreateWindow(ms_className, _T(""), 0, 0, 0, 0, 0, NULL,
+ ms_hwnd = ::CreateWindow(ms_className, wxEmptyString, 0, 0, 0, 0, 0, NULL,
(HMENU)NULL, wxGetInstance(), NULL);
if ( !ms_hwnd )
{
return ms_hwnd;
}
+