X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6c9a19aabab3a878b565e6c2a5f2a3824277c4dc..3684ade82ec6f5fb7ff72341e26060b6ea0793c8:/src/msw/toplevel.cpp diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 82ed98594b..41d5a0d46a 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "toplevel.h" #endif @@ -41,6 +41,13 @@ #include "wx/module.h" #include "wx/msw/private.h" +#include "wx/msw/winundef.h" + +// This can't be undefed in winundef.h or +// there are further errors +#if defined(__WXWINCE__) && defined(CreateDialog) +#undef CreateDialog +#endif #include "wx/display.h" @@ -141,7 +148,7 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const WXDWORD msflags = wxWindow::MSWGetStyle ( (style & ~wxBORDER_MASK) | wxBORDER_NONE, exflags - ) & ~WS_CHILD; + ) & ~WS_CHILD & ~WS_VISIBLE; // first select the kind of window being created // @@ -151,20 +158,35 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const if ( style & wxFRAME_TOOL_WINDOW ) msflags |= WS_POPUP; else - msflags |= WS_OVERLAPPED; + { +#ifdef __WXWINCE__ + if (msflags & WS_BORDER) +#endif + msflags |= WS_OVERLAPPED; + } // border and caption styles if ( style & wxRESIZE_BORDER ) + { +#ifndef __WXWINCE__ msflags |= WS_THICKFRAME; +#endif + } + else if ( exflags && ((style & wxBORDER_DOUBLE) || (style & wxBORDER_RAISED)) ) + *exflags |= WS_EX_DLGMODALFRAME; else if ( !(style & wxBORDER_NONE) ) msflags |= WS_BORDER; +#ifndef __WXWINCE__ else msflags |= WS_POPUP; +#endif if ( style & wxCAPTION ) msflags |= WS_CAPTION; +#ifndef __WXWINCE__ else msflags |= WS_POPUP; +#endif // next translate the individual flags if ( style & wxMINIMIZE_BOX ) @@ -173,10 +195,12 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const msflags |= WS_MAXIMIZEBOX; if ( style & wxSYSTEM_MENU ) msflags |= WS_SYSMENU; +#ifndef __WXWINCE__ if ( style & wxMINIMIZE ) msflags |= WS_MINIMIZE; if ( style & wxMAXIMIZE ) msflags |= WS_MAXIMIZE; +#endif // Keep this here because it saves recoding this function in wxTinyFrame #if wxUSE_ITSY_BITSY && !defined(__WIN32__) @@ -191,13 +215,16 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const if ( exflags ) { -#if !defined(__WIN16__) && !defined(__SC__) +#if !defined(__WIN16__) if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) ) { if ( style & wxFRAME_TOOL_WINDOW ) { // create the palette-like window *exflags |= WS_EX_TOOLWINDOW; + + // tool windows shouldn't appear on the taskbar (as documented) + style |= wxFRAME_NO_TASKBAR; } // We have to solve 2 different problems here: @@ -212,11 +239,13 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const // The second one is solved here by using WS_EX_APPWINDOW flag, the // first one is dealt with in our MSWGetParent() method // implementation +#ifndef __WXWINCE__ if ( !(style & wxFRAME_NO_TASKBAR) && GetParent() ) { // need to force the frame to appear in the taskbar *exflags |= WS_EX_APPWINDOW; } +#endif //else: nothing to do [here] } #endif // !Win16 @@ -323,10 +352,12 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate, if ( exflags ) { ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, exflags); - ::SetWindowPos(GetHwnd(), NULL, 0, 0, 0, 0, + ::SetWindowPos(GetHwnd(), + exflags & WS_EX_TOPMOST ? HWND_TOPMOST : 0, + 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | - SWP_NOZORDER | + (exflags & WS_EX_TOPMOST ? 0 : SWP_NOZORDER) | SWP_NOACTIVATE); } @@ -580,7 +611,11 @@ void wxTopLevelWindowMSW::Maximize(bool maximize) bool wxTopLevelWindowMSW::IsMaximized() const { +#ifdef __WXWINCE__ + return FALSE; +#else return ::IsZoomed(GetHwnd()) != 0; +#endif } void wxTopLevelWindowMSW::Iconize(bool iconize) @@ -590,10 +625,14 @@ void wxTopLevelWindowMSW::Iconize(bool iconize) bool wxTopLevelWindowMSW::IsIconized() const { +#ifdef __WXWINCE__ + return FALSE; +#else // also update the current state ((wxTopLevelWindowMSW *)this)->m_iconized = ::IsIconic(GetHwnd()) != 0; return m_iconized; +#endif } void wxTopLevelWindowMSW::Restore() @@ -633,7 +672,12 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) LONG offFlags = 0; if (style & wxFULLSCREEN_NOBORDER) - offFlags |= WS_BORDER | WS_THICKFRAME; + { + offFlags |= WS_BORDER; +#ifndef __WXWINCE__ + offFlags |= WS_THICKFRAME; +#endif + } if (style & wxFULLSCREEN_NOCAPTION) offFlags |= WS_CAPTION | WS_SYSMENU; @@ -653,8 +697,11 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) else // fall back to the main desktop #else // wxUSE_DISPLAY { + // FIXME: implement for WinCE +#ifndef __WXWINCE__ // resize to the size of the desktop wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect); +#endif } #endif // wxUSE_DISPLAY @@ -727,14 +774,14 @@ void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons) bool wxTopLevelWindowMSW::EnableCloseButton(bool enable) { -#ifndef __WXMICROWIN__ +#if !defined(__WXMICROWIN__) // get system (a.k.a. window) menu - HMENU hmenu = ::GetSystemMenu(GetHwnd(), FALSE /* get it */); + 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 @@ -758,6 +805,54 @@ bool wxTopLevelWindowMSW::EnableCloseButton(bool enable) return TRUE; } +bool wxTopLevelWindowMSW::SetShape(const wxRegion& region) +{ +#ifdef __WXWINCE__ + return FALSE; +#else + 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; +#endif +} + // ---------------------------------------------------------------------------- // wxTopLevelWindow event handling // ---------------------------------------------------------------------------- @@ -769,7 +864,7 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event) if ( event.GetActive() ) { // restore focus to the child which was last focused - wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), (int) m_hWnd); +// wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), (int) m_hWnd); wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent() : NULL; @@ -820,7 +915,10 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event) // the DialogProc for all wxWindows dialogs LONG APIENTRY _EXPORT -wxDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +wxDlgProc(HWND WXUNUSED(hDlg), + UINT message, + WPARAM WXUNUSED(wParam), + LPARAM WXUNUSED(lParam)) { switch ( message ) { @@ -901,7 +999,7 @@ HWND wxTLWHiddenParentModule::GetHWND() } } - 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 ) { @@ -912,3 +1010,4 @@ HWND wxTLWHiddenParentModule::GetHWND() return ms_hwnd; } +