X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9ca4dd06de4376340efca369e65ee1181375d484..1e52188741389278cd99abf79218162c87024ba3:/src/msw/toplevel.cpp?ds=inline diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 7e827494bd..7772899d1b 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -6,7 +6,7 @@ // Created: 24.09.01 // RCS-ID: $Id$ // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) -// License: wxWindows license +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "toplevel.h" #endif @@ -41,6 +41,7 @@ #include "wx/module.h" #include "wx/msw/private.h" +#include "wx/msw/winundef.h" #include "wx/display.h" @@ -141,7 +142,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 +152,33 @@ 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 ( !(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 +187,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,7 +207,7 @@ 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 ) @@ -212,11 +228,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 +341,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 +600,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 +614,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 +661,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 +686,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 +763,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 +794,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 // ---------------------------------------------------------------------------- @@ -820,7 +904,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 +988,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 +999,4 @@ HWND wxTLWHiddenParentModule::GetHWND() return ms_hwnd; } +