X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bf9b6266faaa6534b75e5282aab58f1476eecbaa..496beb3fc0244c36bdb0e37055aa868012b52a23:/src/msw/tbar95.cpp diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index f1ed7ca012..3c1a1b6532 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -196,6 +196,8 @@ void wxToolBar::Init() m_defaultWidth = DEFAULTBITMAPX; m_defaultHeight = DEFAULTBITMAPY; + + m_pInTool = 0; } bool wxToolBar::Create(wxWindow *parent, @@ -264,11 +266,8 @@ wxToolBar::~wxToolBar() { // we must refresh the frame size when the toolbar is deleted but the frame // is not - otherwise toolbar leaves a hole in the place it used to occupy - // - // NB: a frame is being deleted only if it is not any longer in - // wxTopLevelWindows list wxFrame *frame = wxDynamicCast(GetParent(), wxFrame); - if ( frame && wxTopLevelWindows.Find(frame) ) + if ( frame && !frame->IsBeingDeleted() ) { frame->SendSizeEvent(); } @@ -815,9 +814,6 @@ bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl), } } - // For backward compatibility... - OnMouseEnter(tool->GetId()); - return TRUE; } @@ -872,19 +868,54 @@ wxSize wxToolBar::GetToolSize() const } } +static +wxToolBarToolBase *GetItemSkippingDummySpacers(const wxToolBarToolsList& tools, + size_t index ) +{ + wxToolBarToolsList::Node* current = tools.GetFirst(); + + for ( ; current != 0; current = current->GetNext() ) + { + if ( index == 0 ) + return current->GetData(); + + wxToolBarTool *tool = (wxToolBarTool *)current->GetData(); + size_t separators = tool->GetSeparatorsCount(); + + // if it is a normal button, sepcount == 0, so skip 1 item (the button) + // otherwise, skip as many items as the separator count, plus the + // control itself + index -= separators ? separators + 1 : 1; + } + + return 0; +} + wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const { POINT pt; pt.x = x; pt.y = y; int index = (int)::SendMessage(GetHwnd(), TB_HITTEST, 0, (LPARAM)&pt); - if ( index < 0 ) + // MBN: when the point ( x, y ) is close to the toolbar border + // TB_HITTEST returns m_nButtons ( not -1 ) + if ( index < 0 || (size_t)index >= m_nButtons ) { // it's a separator or there is no tool at all there return (wxToolBarToolBase *)NULL; } - return m_tools.Item((size_t)index)->GetData(); + // if comctl32 version < 4.71 wxToolBar95 adds dummy spacers +#if defined(_WIN32_IE) && (_WIN32_IE >= 0x400 ) + if ( wxTheApp->GetComCtl32Version() >= 471 ) + { + return m_tools.Item((size_t)index)->GetData(); + } + else +#endif + { + return GetItemSkippingDummySpacers( m_tools, (size_t) index ); + } } void wxToolBar::UpdateSize() @@ -1002,6 +1033,28 @@ long wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) return 0; } } + else if ( nMsg == WM_MOUSEMOVE ) + { + wxCoord x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam); + wxToolBarToolBase* tool = FindToolForPosition( x, y ); + + // cursor left current tool + if( tool != m_pInTool && !tool ) + { + m_pInTool = 0; + OnMouseEnter( -1 ); + } + + // cursor entered a tool + if( tool != m_pInTool && tool ) + { + m_pInTool = tool; + OnMouseEnter( tool->GetId() ); + } + + // we don't handle mouse moves, so fall through + // to wxControl::MSWWindowProc + } return wxControl::MSWWindowProc(nMsg, wParam, lParam); }