X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e306597309a120f2ae91385c731a5cb2722c52aa..e27ce4e910f99ab572a609b7d560abf56440f81d:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index ff224f8492..1aff70f753 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -49,7 +49,13 @@ #include "wx/menuitem.h" #include "wx/log.h" + +#if wxUSE_TOOLTIPS #include "wx/tooltip.h" +#endif + +#include "wx/intl.h" +#include "wx/log.h" #include "wx/msw/private.h" @@ -189,6 +195,7 @@ bool wxWindow::MSWNotify(WXWPARAM WXUNUSED(wParam), WXLPARAM* WXUNUSED(result)) { #ifdef __WIN95__ +#if wxUSE_TOOLTIPS NMHDR* hdr = (NMHDR *)lParam; if ( hdr->code == TTN_NEEDTEXT && m_tooltip ) { @@ -198,6 +205,7 @@ bool wxWindow::MSWNotify(WXWPARAM WXUNUSED(wParam), // processed return TRUE; } +#endif #endif return FALSE; @@ -287,7 +295,9 @@ void wxWindow::Init() m_pDropTarget = NULL; #endif +#if wxUSE_TOOLTIPS m_tooltip = NULL; +#endif } wxWindow::wxWindow() @@ -298,11 +308,21 @@ wxWindow::wxWindow() // Destructor wxWindow::~wxWindow() { + // Remove potential dangling pointer + if (GetParent() && GetParent()->IsKindOf(CLASSINFO(wxPanel))) + { + wxPanel* panel = (wxPanel*) GetParent(); + if (panel->GetLastFocus() == this) + panel->SetLastFocus((wxWindow*) NULL); + } + m_isBeingDeleted = TRUE; // first of all, delete the things on which nothing else depends +#if wxUSE_TOOLTIPS wxDELETE(m_tooltip); +#endif // JACS - if behaviour is odd, restore this // to the start of ~wxWindow. Vadim has changed @@ -542,6 +562,8 @@ void wxWindow::DragAcceptFiles(bool accept) // tooltips // ---------------------------------------------------------------------------- +#if wxUSE_TOOLTIPS + void wxWindow::SetToolTip(const wxString &tip) { SetToolTip(new wxToolTip(tip)); @@ -556,6 +578,8 @@ void wxWindow::SetToolTip(wxToolTip *tooltip) m_tooltip->SetWindow(this); } +#endif // wxUSE_TOOLTIPS + // Get total size void wxWindow::GetSize(int *x, int *y) const { @@ -746,13 +770,14 @@ void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) bool wxWindow::Show(bool show) { + m_isShown = show; HWND hWnd = (HWND) GetHWND(); int cshow; if (show) cshow = SW_SHOW; else cshow = SW_HIDE; - ShowWindow(hWnd, (BOOL)cshow); + ShowWindow(hWnd, cshow); if (show) { BringWindowToTop(hWnd); @@ -764,7 +789,11 @@ bool wxWindow::Show(bool show) bool wxWindow::IsShown(void) const { - return (::IsWindowVisible((HWND) GetHWND()) != 0); + // Can't rely on IsWindowVisible, since it will return FALSE + // if the parent is not visible. + return m_isShown; +// int ret = ::IsWindowVisible((HWND) GetHWND()) ; +// return (ret != 0); } int wxWindow::GetCharHeight(void) const @@ -1205,10 +1234,19 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) } case WM_KEYDOWN: - MSWOnKeyDown((WORD) wParam, lParam); - // we consider these message "not interesting" + { + // If this has been processed by an event handler, + // return 0 now (we've handled it). + if (MSWOnKeyDown((WORD) wParam, lParam)) + { + return 0; + } + + // we consider these message "not interesting" to OnChar if ( wParam == VK_SHIFT || wParam == VK_CONTROL ) + { return Default(); + } // Avoid duplicate messages to OnChar for these special keys switch ( wParam ) @@ -1222,27 +1260,36 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) case VK_RIGHT: case VK_DOWN: case VK_UP: - if ( ::GetKeyState(VK_CONTROL) & 0x100 ) - MSWOnChar((WORD)wParam, lParam); +/* +// if ( ::GetKeyState(VK_CONTROL) & 0x100 ) // Don't understand purpose of this test + if (!MSWOnChar((WORD)wParam, lParam)) + return Default(); break; - +*/ default: - MSWOnChar((WORD)wParam, lParam); + if (!MSWOnChar((WORD)wParam, lParam)) + { + return Default(); + } +/* if ( ::GetKeyState(VK_CONTROL) & 0x100 ) return Default(); +*/ break; } break; - + } case WM_KEYUP: { - MSWOnKeyUp((WORD) wParam, lParam); + if (!MSWOnKeyUp((WORD) wParam, lParam)) + return Default(); break; } case WM_CHAR: // Always an ASCII character { - MSWOnChar((WORD)wParam, lParam, TRUE); + if (!MSWOnChar((WORD)wParam, lParam, TRUE)) + return Default(); break; } @@ -1999,7 +2046,7 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg) // it return FALSE; } - +#ifndef __WIN16__ wxButton *btnDefault = GetDefaultItem(); if ( btnDefault && !bCtrlDown ) { @@ -2012,6 +2059,7 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg) // else: but if there is not it makes sense to make it // work like a TAB - and that's what we do. // Note that Ctrl-Enter always works this way. +#endif } break; @@ -2438,7 +2486,7 @@ void wxWindow::MSWOnMouseLeave(int x, int y, WXUINT flags) GetEventHandler()->ProcessEvent(event); } -void wxWindow::MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII) +bool wxWindow::MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII) { int id; bool tempControlDown = FALSE; @@ -2500,12 +2548,16 @@ void wxWindow::MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII) event.m_x = pt.x; event.m_y = pt.y; - if (!GetEventHandler()->ProcessEvent(event)) - Default(); + if (GetEventHandler()->ProcessEvent(event)) + return TRUE; + else + return FALSE; } + else + return FALSE; } -void wxWindow::MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII) +bool wxWindow::MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII) { int id; @@ -2534,12 +2586,19 @@ void wxWindow::MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII) event.m_x = pt.x; event.m_y = pt.y; - if (!GetEventHandler()->ProcessEvent(event)) - Default(); + if (GetEventHandler()->ProcessEvent(event)) + { + return TRUE; + } + else return FALSE; + } + else + { + return FALSE; } } -void wxWindow::MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII) +bool wxWindow::MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII) { int id; @@ -2568,9 +2627,13 @@ void wxWindow::MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII) event.m_x = pt.x; event.m_y = pt.y; - if (!GetEventHandler()->ProcessEvent(event)) - Default(); + if (GetEventHandler()->ProcessEvent(event)) + return TRUE; + else + return FALSE; } + else + return FALSE; } void wxWindow::MSWOnJoyDown(int joystick, int x, int y, WXUINT flags) @@ -3648,7 +3711,7 @@ void wxWindow::OnChar(wxKeyEvent& event) if ( id == -1 ) id= m_lastWParam; - if ( !event.ControlDown() ) + if ( !event.ControlDown() ) // Why this test? (void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam); }