X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2175898cf686a5d160fceae3509756050afd9fda..c616c2e834192db06bbef18b9404824f563e335f:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 5785d69d6e..08567e34a4 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -220,7 +220,7 @@ static void EnsureParentHasControlParentStyle(wxWindow *parent) get back to the initial (focused) window: as we do have this style, GetNextDlgTabItem() will leave this window and continue in its parent, but if the parent doesn't have it, it wouldn't recurse inside it later - on and so wouldn't have a chance of getting back to this window neither. + on and so wouldn't have a chance of getting back to this window either. */ while ( parent && !parent->IsTopLevel() ) { @@ -394,7 +394,7 @@ wxWindow *wxWindowMSW::FindItem(long id) const wxControl *item = wxDynamicCastThis(wxControl); if ( item ) { - // is it we or one of our "internal" children? + // is it us or one of our "internal" children? if ( item->GetId() == id #ifndef __WXUNIVERSAL__ || (item->GetSubcontrols().Index(id) != wxNOT_FOUND) @@ -513,7 +513,7 @@ wxWindowMSW::~wxWindowMSW() #endif // __WXUNIVERSAL__ // VS: destroy children first and _then_ detach *this from its parent. - // If we'd do it the other way around, children wouldn't be able + // If we did it the other way around, children wouldn't be able // find their parent frame (see above). DestroyChildren(); @@ -665,7 +665,7 @@ bool wxWindowMSW::Enable(bool enable) if ( enable ) { - // enable the child back unless it had been disabled before us + // re-enable the child unless it had been disabled before us if ( !m_childrenDisabled || !m_childrenDisabled->Find(child) ) child->Enable(); } @@ -848,15 +848,10 @@ inline int GetScrollPosition(HWND hWnd, int wOrient) WinStruct scrollInfo; scrollInfo.cbSize = sizeof(SCROLLINFO); scrollInfo.fMask = SIF_POS; - if ( !::GetScrollInfo(hWnd, - wOrient, - &scrollInfo) ) - { - // Not necessarily an error, if there are no scrollbars yet. - // wxLogLastError(_T("GetScrollInfo")); - } + ::GetScrollInfo(hWnd, wOrient, &scrollInfo ); + return scrollInfo.nPos; -// return ::GetScrollPos(hWnd, wOrient); + #endif } @@ -943,11 +938,13 @@ void wxWindowMSW::SetScrollbar(int orient, HWND hWnd = GetHwnd(); if ( hWnd ) { + // We have to set the variables here to make them valid in events + // triggered by ::SetScrollInfo() + *(orient == wxHORIZONTAL ? &m_xThumbSize : &m_yThumbSize) = pageSize; + ::SetScrollInfo(hWnd, orient == wxHORIZONTAL ? SB_HORZ : SB_VERT, &info, refresh); } - - *(orient == wxHORIZONTAL ? &m_xThumbSize : &m_yThumbSize) = pageSize; } void wxWindowMSW::ScrollWindow(int dx, int dy, const wxRect *prect) @@ -1039,7 +1036,7 @@ void wxWindowMSW::SubclassWin(WXHWND hWnd) } else { - // don't bother restoring it neither: this also makes it easy to + // don't bother restoring it either: this also makes it easy to // implement IsOfStandardClass() method which returns true for the // standard controls and false for the wxWidgets own windows as it can // simply check m_oldWndProc @@ -1203,7 +1200,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const // using this flag results in very significant reduction in flicker, // especially with controls inside the static boxes (as the interior of the - // box is not redrawn twice).but sometimes results in redraw problems, so + // box is not redrawn twice), but sometimes results in redraw problems, so // optionally allow the old code to continue to use it provided a special // system option is turned on if ( !wxSystemOptions::GetOptionInt(wxT("msw.window.no-clip-children")) @@ -1447,7 +1444,7 @@ void wxWindowMSW::SetDropTarget(wxDropTarget *pDropTarget) } #endif // wxUSE_DRAG_AND_DROP -// old style file-manager drag&drop support: we retain the old-style +// old-style file manager drag&drop support: we retain the old-style // DragAcceptFiles in parallel with SetDropTarget. void wxWindowMSW::DragAcceptFiles(bool WXUNUSED_IN_WINCE(accept)) { @@ -1516,14 +1513,24 @@ void wxWindowMSW::DoGetSize(int *x, int *y) const // Get size *available for subwindows* i.e. excluding menu bar etc. void wxWindowMSW::DoGetClientSize(int *x, int *y) const { - // this is only for top level windows whose resizing is never deferred, so - // we can safely use the current size here - RECT rect = wxGetClientRect(GetHwnd()); + if ( IsTopLevel() || m_pendingSize == wxDefaultSize ) + { + // top level windows resizing is never deferred, so we can safely use + // the current size here + RECT rect = wxGetClientRect(GetHwnd()); - if ( x ) - *x = rect.right; - if ( y ) - *y = rect.bottom; + if ( x ) + *x = rect.right; + if ( y ) + *y = rect.bottom; + } + else // non top level + { + // size is the same as client size for non top level windows, so + // forward to GetSize() to take into account deferred sizing (which + // wxGetClientRect() doesn't) + DoGetSize(x, y); + } } void wxWindowMSW::DoGetPosition(int *x, int *y) const @@ -1618,7 +1625,7 @@ wxWindowMSW::DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height) if ( hdwp ) { hdwp = ::DeferWindowPos(hdwp, (HWND)hwnd, NULL, x, y, width, height, - SWP_NOZORDER); + SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); if ( !hdwp ) { wxLogLastError(_T("DeferWindowPos")); @@ -1740,7 +1747,7 @@ void wxWindowMSW::DoSetSize(int x, int y, int width, int height, int sizeFlags) void wxWindowMSW::DoSetClientSize(int width, int height) { - // setting the client size is less obvious than it it could have been + // setting the client size is less obvious than it could have been // because in the result of changing the total size the window scrollbar // may [dis]appear and/or its menubar may [un]wrap and so the client size // will not be correct as the difference between the total and client size @@ -1908,7 +1915,7 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y) #endif ::TrackPopupMenu(hMenu, flags, point.x, point.y, 0, hWnd, NULL); - // we need to do it righ now as otherwise the events are never going to be + // we need to do it right now as otherwise the events are never going to be // sent to wxCurrentPopupMenu from HandleCommand() // // note that even eliminating (ugly) wxCurrentPopupMenu global wouldn't @@ -2111,7 +2118,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) { // ::IsDialogMessage() is broken and may sometimes hang the // application by going into an infinite loop, so we try to detect - // [some of] the situatations when this may happen and not call it + // [some of] the situations when this may happen and not call it // then // assume we can call it by default @@ -2132,7 +2139,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) #if !defined(__WXWINCE__) if ( ::GetWindowLong(hwndFocus, GWL_EXSTYLE) & WS_EX_CONTROLPARENT ) { - // passimistic by default + // pessimistic by default canSafelyCallIsDlgMsg = false; for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; @@ -2399,28 +2406,6 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l break; #endif // !__WXWINCE__ -#if !(defined(_WIN32_WCE) && _WIN32_WCE < 400) - case WM_WINDOWPOSCHANGED: - { - WINDOWPOS *lpPos = (WINDOWPOS *)lParam; - - if ( !(lpPos->flags & SWP_NOSIZE) ) - { - RECT rc; - ::GetClientRect(GetHwnd(), &rc); - - AutoHRGN hrgnClient(::CreateRectRgnIndirect(&rc)); - AutoHRGN hrgnNew(::CreateRectRgn(lpPos->x, lpPos->y, - lpPos->cx, lpPos->cy)); - - // we need to invalidate any new exposed areas here - // to force them to repaint - if ( ::CombineRgn(hrgnNew, hrgnNew, hrgnClient, RGN_DIFF) != NULLREGION ) - ::InvalidateRgn(GetHwnd(), hrgnNew, TRUE); - } - } - break; -#endif #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) case WM_ACTIVATEAPP: // This implicitly sends a wxEVT_ACTIVATE_APP event @@ -2682,7 +2667,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l { switch ( wParam ) { - // we consider these message "not interesting" to OnChar, so + // we consider these messages "not interesting" to OnChar, so // just don't do anything more with them case VK_SHIFT: case VK_CONTROL: @@ -3202,8 +3187,6 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass, // WM_NOTIFY // --------------------------------------------------------------------------- -#ifdef __WIN95__ - bool wxWindowMSW::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { #ifndef __WXMICROWIN__ @@ -3347,8 +3330,6 @@ bool wxWindowMSW::MSWOnNotify(int WXUNUSED(idCtrl), return false; } -#endif // __WIN95__ - // --------------------------------------------------------------------------- // end session messages // --------------------------------------------------------------------------- @@ -4924,12 +4905,20 @@ int wxWindowMSW::HandleMenuChar(int WXUNUSED_IN_WINCE(chAccel), MENUITEMINFO mii; wxZeroMemory(mii); mii.cbSize = sizeof(MENUITEMINFO); + + // we could use MIIM_FTYPE here as we only need to know if the item is + // ownerdrawn or not and not dwTypeData which MIIM_TYPE also returns, but + // MIIM_FTYPE is not supported under Win95 mii.fMask = MIIM_TYPE | MIIM_DATA; // find if we have this letter in any owner drawn item const int count = ::GetMenuItemCount(hmenu); for ( int i = 0; i < count; i++ ) { + // previous loop iteration could modify it, reset it back before + // calling GetMenuItemInfo() to prevent it from overflowing dwTypeData + mii.cch = 0; + if ( ::GetMenuItemInfo(hmenu, i, TRUE, &mii) ) { if ( mii.fType == MFT_OWNERDRAW ) @@ -4967,8 +4956,7 @@ int wxWindowMSW::HandleMenuChar(int WXUNUSED_IN_WINCE(chAccel), } else // failed to get the menu text? { - // it's not fatal, so don't show error, but still log - // it + // it's not fatal, so don't show error, but still log it wxLogLastError(_T("GetMenuItemInfo")); } } @@ -5399,6 +5387,28 @@ bool wxGetKeyState(wxKeyCode key) #endif } + +wxMouseState wxGetMouseState() +{ + wxMouseState ms; + POINT pt; + GetCursorPos( &pt ); + + ms.SetX(pt.x); + ms.SetY(pt.y); + ms.SetLeftDown( (GetAsyncKeyState(VK_LBUTTON) & (1<<15)) != 0 ); + ms.SetMiddleDown( (GetAsyncKeyState(VK_MBUTTON) & (1<<15)) != 0 ); + ms.SetRightDown( (GetAsyncKeyState(VK_RBUTTON) & (1<<15)) != 0 ); + + ms.SetControlDown( (GetAsyncKeyState(VK_CONTROL) & (1<<15)) != 0 ); + ms.SetShiftDown( (GetAsyncKeyState(VK_SHIFT) & (1<<15)) != 0 ); + ms.SetAltDown( (GetAsyncKeyState(VK_MENU) & (1<<15)) != 0 ); +// ms.SetMetaDown(); + + return ms; +} + + wxWindow *wxGetActiveWindow() { HWND hWnd = GetActiveWindow();