X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f801d19a746e3b36a89742ccc0009b0e5de31aba..e3276230de335908f70232b2a5ede43665bd8d9d:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index f0baae9521..7dfd87df99 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -732,8 +732,7 @@ bool wxWindowMSW::Show(bool show) bool wxWindowMSW::MSWShowWithEffect(bool show, wxShowEffect effect, - unsigned timeout, - wxDirection dir) + unsigned timeout) { if ( !wxWindowBase::Show(show) ) return false; @@ -762,16 +761,39 @@ wxWindowMSW::MSWShowWithEffect(bool show, timeout = 200; // this is the default animation timeout, per MSDN DWORD dwFlags = show ? 0 : AW_HIDE; - bool needsDir = false; + switch ( effect ) { - case wxSHOW_EFFECT_ROLL: - needsDir = true; + case wxSHOW_EFFECT_ROLL_TO_LEFT: + dwFlags |= AW_HOR_NEGATIVE; + break; + + case wxSHOW_EFFECT_ROLL_TO_RIGHT: + dwFlags |= AW_HOR_POSITIVE; + break; + + case wxSHOW_EFFECT_ROLL_TO_TOP: + dwFlags |= AW_VER_NEGATIVE; + break; + + case wxSHOW_EFFECT_ROLL_TO_BOTTOM: + dwFlags |= AW_VER_POSITIVE; + break; + + case wxSHOW_EFFECT_SLIDE_TO_LEFT: + dwFlags |= AW_SLIDE | AW_HOR_NEGATIVE; + break; + + case wxSHOW_EFFECT_SLIDE_TO_RIGHT: + dwFlags |= AW_SLIDE | AW_HOR_POSITIVE; break; - case wxSHOW_EFFECT_SLIDE: - needsDir = true; - dwFlags |= AW_SLIDE; + case wxSHOW_EFFECT_SLIDE_TO_TOP: + dwFlags |= AW_SLIDE | AW_VER_NEGATIVE; + break; + + case wxSHOW_EFFECT_SLIDE_TO_BOTTOM: + dwFlags |= AW_SLIDE | AW_VER_POSITIVE; break; case wxSHOW_EFFECT_BLEND: @@ -792,38 +814,6 @@ wxWindowMSW::MSWShowWithEffect(bool show, return false; } - if ( needsDir ) - { - switch ( dir ) - { - case wxTOP: - dwFlags |= AW_VER_NEGATIVE; - break; - - case wxBOTTOM: - dwFlags |= AW_VER_POSITIVE; - break; - - case wxLEFT: - dwFlags |= AW_HOR_NEGATIVE; - break; - - case wxRIGHT: - dwFlags |= AW_HOR_POSITIVE; - break; - - default: - wxFAIL_MSG( _T("unknown window effect direction") ); - return false; - } - } - else // animation effect which doesn't need the direction - { - wxASSERT_MSG( dir == wxBOTTOM, - _T("non-default direction used unnecessarily") ); - } - - if ( !(*s_pfnAnimateWindow)(GetHwnd(), timeout, dwFlags) ) { wxLogLastError(_T("AnimateWindow")); @@ -881,7 +871,11 @@ bool wxWindowMSW::SetFont(const wxFont& font) HWND hWnd = GetHwnd(); if ( hWnd != 0 ) { - WXHANDLE hFont = m_font.GetResourceHandle(); + // note the use of GetFont() instead of m_font: our own font could have + // just been reset and in this case we need to change the font used by + // the native window to the default for this class, i.e. exactly what + // GetFont() returns + WXHANDLE hFont = GetFont().GetResourceHandle(); wxASSERT_MSG( hFont, wxT("should have valid font") ); @@ -3679,6 +3673,12 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass, WXDWORD style, WXDWORD extendedStyle) { + // check a common bug in the user code: if the window is created with a + // non-default ctor and Create() is called too, we'd create 2 HWND for a + // single wxWindow object and this results in all sorts of trouble, + // especially for wxTLWs + wxCHECK_MSG( !m_hWnd, true, "window can't be recreated" ); + // choose the position/size for the new window int x, y, w, h; (void)MSWGetCreateWindowCoords(pos, size, x, y, w, h); @@ -4261,17 +4261,32 @@ bool wxWindowMSW::HandlePower(WXWPARAM WXUNUSED_IN_WINCE(wParam), bool wxWindowMSW::IsDoubleBuffered() const { - for ( const wxWindowMSW *wnd = this; - wnd && !wnd->IsTopLevel(); wnd = - wnd->GetParent() ) - { - if ( ::GetWindowLong(GetHwndOf(wnd), GWL_EXSTYLE) & WS_EX_COMPOSITED ) + const wxWindowMSW *wnd = this; + do { + long style = ::GetWindowLong(GetHwndOf(wnd), GWL_EXSTYLE); + if ( (style & WS_EX_COMPOSITED) != 0 ) return true; - } - + wnd = wnd->GetParent(); + } while ( wnd && !wnd->IsTopLevel() ); + return false; } +void wxWindowMSW::SetDoubleBuffered(bool on) +{ + // Get the current extended style bits + long exstyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE); + + // Twiddle the bit as needed + if ( on ) + exstyle |= WS_EX_COMPOSITED; + else + exstyle &= ~WS_EX_COMPOSITED; + + // put it back + ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyle); +} + // --------------------------------------------------------------------------- // owner drawn stuff // --------------------------------------------------------------------------- @@ -5082,12 +5097,8 @@ bool wxWindowMSW::HandleCommand(WXWORD id_, WXWORD cmd, WXHWND control) // coming from a control to wxEVT_COMMAND_MENU_SELECTED if ( !control ) { - // If no child window, it may be an accelerator, e.g. for a popup menu - // command - - wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED); + wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id); event.SetEventObject(this); - event.SetId(id); event.SetInt(id); return HandleWindowEvent(event); @@ -5624,18 +5635,19 @@ int wxWindowMSW::HandleMenuChar(int WXUNUSED_IN_WINCE(chAccel), return wxNOT_FOUND; } -bool wxWindowMSW::HandleClipboardEvent( WXUINT nMsg ) +#endif // wxUSE_MENUS + +bool wxWindowMSW::HandleClipboardEvent(WXUINT nMsg) { - const wxEventType type = ( nMsg == WM_CUT ) ? wxEVT_COMMAND_TEXT_CUT : - ( nMsg == WM_COPY ) ? wxEVT_COMMAND_TEXT_COPY : - /*( nMsg == WM_PASTE ) ? */ wxEVT_COMMAND_TEXT_PASTE; + const wxEventType type = nMsg == WM_CUT ? wxEVT_COMMAND_TEXT_CUT + : nMsg == WM_COPY ? wxEVT_COMMAND_TEXT_COPY + : /* nMsg == WM_PASTE */ wxEVT_COMMAND_TEXT_PASTE; wxClipboardTextEvent evt(type, GetId()); evt.SetEventObject(this); return HandleWindowEvent(evt); } -#endif // wxUSE_MENUS // --------------------------------------------------------------------------- // joystick