X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8e92ccef9ce18df8c67d6105ac553dba93cf0e43..f538710f0b798b21365fd614ba531055b225b115:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 45e349fff9..d414c9dc3d 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -303,9 +303,6 @@ void wxWindowMSW::Init() m_hWnd = 0; - // pass WM_GETDLGCODE to DefWindowProc() - m_lDlgCode = 0; - m_xThumbSize = 0; m_yThumbSize = 0; m_backgroundTransparent = FALSE; @@ -415,14 +412,6 @@ bool wxWindowMSW::Create(wxWindow *parent, { msflags |= WS_BORDER; } - - // calculate the value to return from WM_GETDLGCODE handler - if ( GetWindowStyleFlag() & wxWANTS_CHARS ) - { - // want everything: i.e. all keys and WM_CHAR message - m_lDlgCode = DLGC_WANTARROWS | DLGC_WANTCHARS | - DLGC_WANTTAB | DLGC_WANTMESSAGE; - } #endif // wxUniversal/!wxUniversal if ( style & wxPOPUP_WINDOW ) @@ -546,7 +535,7 @@ wxString wxWindowMSW::GetTitle() const return wxGetWindowText(GetHWND()); } -void wxWindowMSW::CaptureMouse() +void wxWindowMSW::DoCaptureMouse() { HWND hWnd = GetHwnd(); if ( hWnd ) @@ -555,7 +544,7 @@ void wxWindowMSW::CaptureMouse() } } -void wxWindowMSW::ReleaseMouse() +void wxWindowMSW::DoReleaseMouse() { if ( !::ReleaseCapture() ) { @@ -902,15 +891,21 @@ void wxWindowMSW::SetScrollbar(int orient, int pos, int thumbVisible, void wxWindowMSW::ScrollWindow(int dx, int dy, const wxRect *prect) { RECT rect; + RECT *pr; if ( prect ) { rect.left = prect->x; rect.top = prect->y; rect.right = prect->x + prect->width; rect.bottom = prect->y + prect->height; + pr = ▭ + } + else + { + pr = NULL; } - ::ScrollWindow(GetHwnd(), dx, dy, prect ? &rect : NULL, NULL); + ::ScrollWindow(GetHwnd(), dx, dy, pr, pr); } static bool ScrollVertically(HWND hwnd, int kind, int count) @@ -1180,7 +1175,7 @@ void wxWindowMSW::OnIdle(wxIdleEvent& WXUNUSED(event)) // Check if we need to send a LEAVE event if ( m_mouseInWindow ) { - if ( !IsMouseInWindow() ) + if ( !IsMouseInWindow() && !HasCapture()) { // Generate a LEAVE event m_mouseInWindow = FALSE; @@ -1543,7 +1538,8 @@ void wxWindowMSW::DoSetClientSize(int width, int height) ::GetClientRect(GetHwnd(), &rectClient); // if the size is already ok, stop here (rectClient.left = top = 0) - if ( rectClient.right == width && rectClient.bottom == height ) + if ( (rectClient.right == width || width == -1) && + (rectClient.bottom == height || height == -1) ) { break; } @@ -1955,11 +1951,12 @@ bool wxWindowMSW::MSWTranslateMessage(WXMSG* pMsg) #if wxUSE_ACCEL && !defined(__WXUNIVERSAL__) return m_acceleratorTable.Translate(this, pMsg); #else + (void) pMsg; return FALSE; #endif // wxUSE_ACCEL } -bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* pMsg) +bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* WXUNUSED(pMsg)) { // preprocess all messages by default return TRUE; @@ -2362,9 +2359,11 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam #endif // defined(WM_DRAWITEM) case WM_GETDLGCODE: - if ( m_lDlgCode ) + if ( GetWindowStyleFlag() & wxWANTS_CHARS ) { - rc.result = m_lDlgCode; + // want everything: i.e. all keys and WM_CHAR message + rc.result = DLGC_WANTARROWS | DLGC_WANTCHARS | + DLGC_WANTTAB | DLGC_WANTMESSAGE; processed = TRUE; } //else: get the dlg code from the DefWindowProc() @@ -2503,6 +2502,10 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam processed = HandleSysColorChange(); break; + case WM_DISPLAYCHANGE: + processed = HandleDisplayChange(); + break; + case WM_PALETTECHANGED: processed = HandlePaletteChanged((WXHWND) (HWND) wParam); break; @@ -3291,6 +3294,14 @@ bool wxWindowMSW::HandleSysColorChange() return FALSE; } +bool wxWindowMSW::HandleDisplayChange() +{ + wxDisplayChangedEvent event; + event.SetEventObject(this); + + return GetEventHandler()->ProcessEvent(event); +} + bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush, WXHDC pDC, WXHWND pWnd, @@ -3337,6 +3348,40 @@ WXHBRUSH wxWindowMSW::OnCtlColor(WXHDC WXUNUSED(hDC), bool wxWindowMSW::HandlePaletteChanged(WXHWND hWndPalChange) { +#if wxUSE_PALETTE + // same as below except we don't respond to our own messages + if ( hWndPalChange != GetHWND() ) + { + // check to see if we our our parents have a custom palette + wxWindow *win = this; + while ( win && !win->HasCustomPalette() ) + { + win = win->GetParent(); + } + + if ( win && win->HasCustomPalette() ) + { + // realize the palette to see whether redrawing is needed + HDC hdc = ::GetDC((HWND) hWndPalChange); + win->m_palette.SetHPALETTE((WXHPALETTE) + ::SelectPalette(hdc, GetHpaletteOf(win->m_palette), FALSE)); + + int result = ::RealizePalette(hdc); + + // restore the palette (before releasing the DC) + win->m_palette.SetHPALETTE((WXHPALETTE) + ::SelectPalette(hdc, GetHpaletteOf(win->m_palette), FALSE)); + ::RealizePalette(hdc); + ::ReleaseDC((HWND) hWndPalChange, hdc); + + // now check for the need to redraw + if (result > 0) + InvalidateRect((HWND) hWndPalChange, NULL, TRUE); + } + + } +#endif // wxUSE_PALETTE + wxPaletteChangedEvent event(GetId()); event.SetEventObject(this); event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange)); @@ -3346,6 +3391,29 @@ bool wxWindowMSW::HandlePaletteChanged(WXHWND hWndPalChange) bool wxWindowMSW::HandleQueryNewPalette() { + +#if wxUSE_PALETTE + // check to see if we our our parents have a custom palette + wxWindow *win = this; + while (!win->HasCustomPalette() && win->GetParent()) win = win->GetParent(); + if (win->HasCustomPalette()) { + /* realize the palette to see whether redrawing is needed */ + HDC hdc = GetDC((HWND) GetHWND()); + win->m_palette.SetHPALETTE( (WXHPALETTE) + ::SelectPalette(hdc, (HPALETTE) win->m_palette.GetHPALETTE(), FALSE) ); + + int result = ::RealizePalette(hdc); + /* restore the palette (before releasing the DC) */ + win->m_palette.SetHPALETTE( (WXHPALETTE) + ::SelectPalette(hdc, (HPALETTE) win->m_palette.GetHPALETTE(), TRUE) ); + ::RealizePalette(hdc); + ::ReleaseDC((HWND) GetHWND(), hdc); + /* now check for the need to redraw */ + if (result > 0) + ::InvalidateRect((HWND) GetHWND(), NULL, TRUE); + } +#endif // wxUSE_PALETTE + wxQueryNewPaletteEvent event(GetId()); event.SetEventObject(this); @@ -3353,7 +3421,7 @@ bool wxWindowMSW::HandleQueryNewPalette() } // Responds to colour changes: passes event on to children. -void wxWindowMSW::OnSysColourChanged(wxSysColourChangedEvent& event) +void wxWindowMSW::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) { // the top level window also reset the standard colour map as it might have // changed (there is no need to do it for the non top level windows as we @@ -3599,28 +3667,33 @@ bool wxWindowMSW::HandleGetMinMaxInfo(void *mmInfo) MINMAXINFO *info = (MINMAXINFO *)mmInfo; bool rc = FALSE; + + int minWidth = GetMinWidth(), + minHeight = GetMinHeight(), + maxWidth = GetMaxWidth(), + maxHeight = GetMaxHeight(); - if ( m_minWidth != -1 ) + if ( minWidth != -1 ) { - info->ptMinTrackSize.x = m_minWidth; + info->ptMinTrackSize.x = minWidth; rc = TRUE; } - if ( m_minHeight != -1 ) + if ( minHeight != -1 ) { - info->ptMinTrackSize.y = m_minHeight; + info->ptMinTrackSize.y = minHeight; rc = TRUE; } - if ( m_maxWidth != -1 ) + if ( maxWidth != -1 ) { - info->ptMaxTrackSize.x = m_maxWidth; + info->ptMaxTrackSize.x = maxWidth; rc = TRUE; } - if ( m_maxHeight != -1 ) + if ( maxHeight != -1 ) { - info->ptMaxTrackSize.y = m_maxHeight; + info->ptMaxTrackSize.y = maxHeight; rc = TRUE; }