X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f3ba93c1f025870aeda36082acecc87ab277ab7d..15c3723c6092669f91c9251382f4a1521deeceeb:/src/msw/tbar95.cpp diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 9c0ec13209..3748168d9e 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -262,6 +262,10 @@ bool wxToolBar::Create(wxWindow *parent, msflags |= TBSTYLE_FLAT | TBSTYLE_TRANSPARENT; } } + if (style & wxTB_NODIVIDER) + msflags |= CCS_NODIVIDER; + if (style & wxTB_NOALIGN) + msflags |= CCS_NOPARENTALIGN; // MSW-specific initialisation if ( !wxControl::MSWCreateControl(TOOLBARCLASSNAME, msflags) ) @@ -833,20 +837,18 @@ bool wxToolBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id) // avoid sending the event when a radio button is released, this is not // interesting - if ( tool->CanBeToggled() && tool->GetKind() == wxITEM_RADIO && !toggled ) + if ( !tool->CanBeToggled() || tool->GetKind() != wxITEM_RADIO || toggled ) { - return; - } - - // OnLeftClick() can veto the button state change - for buttons which may - // be toggled only, of couse - if ( !OnLeftClick((int)id, toggled) && tool->CanBeToggled() ) - { - // revert back - toggled = !toggled; - tool->SetToggle(toggled); + // OnLeftClick() can veto the button state change - for buttons which + // may be toggled only, of couse + if ( !OnLeftClick((int)id, toggled) && tool->CanBeToggled() ) + { + // revert back + toggled = !toggled; + tool->SetToggle(toggled); - ::SendMessage(GetHwnd(), TB_CHECKBUTTON, id, MAKELONG(toggled, 0)); + ::SendMessage(GetHwnd(), TB_CHECKBUTTON, id, MAKELONG(toggled, 0)); + } } return TRUE; @@ -861,7 +863,7 @@ bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl), // the tooltips control created by the toolbar is sometimes Unicode, even // in an ANSI application - this seems to be a bug in comctl32.dll v5 - int code = (int)hdr->code; + UINT code = hdr->code; if ( (code != TTN_NEEDTEXTA) && (code != TTN_NEEDTEXTW) ) return FALSE; @@ -876,51 +878,7 @@ bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl), if ( !tool ) return FALSE; - const wxString& help = tool->GetShortHelp(); - - if ( !help.IsEmpty() ) - { - if ( code == TTN_NEEDTEXTA ) - { - ttText->lpszText = (wxChar *)help.c_str(); - } - else - { -#if wxUSE_UNICODE - ttText->lpszText = (wxChar *)help.c_str(); -#else - // VZ: I don't know why it happens, but the versions of - // comctl32.dll starting from 4.70 sometimes send TTN_NEEDTEXTW - // even to ANSI programs (normally, this message is supposed - // to be sent to Unicode programs only) - hence we need to - // handle it as well, otherwise no tooltips will be shown in - // this case - - size_t lenAnsi = help.Len(); - #if defined( __MWERKS__ ) || defined( __CYGWIN__ ) - // MetroWerks doesn't like calling mbstowcs with NULL argument - // neither Cygwin does - size_t lenUnicode = 2*lenAnsi; - #else - size_t lenUnicode = mbstowcs(NULL, help, lenAnsi); - #endif - - // using the pointer of right type avoids us doing all sorts of - // pointer arithmetics ourselves - wchar_t *dst = (wchar_t *)ttText->szText, - *pwz = new wchar_t[lenUnicode + 1]; - mbstowcs(pwz, help, lenAnsi + 1); - memcpy(dst, pwz, lenUnicode*sizeof(wchar_t)); - - // put the terminating _wide_ NUL - dst[lenUnicode] = 0; - - delete [] pwz; -#endif - } - } - - return TRUE; + return HandleTooltipNotify(code, lParam, tool->GetShortHelp()); } // ---------------------------------------------------------------------------- @@ -1146,6 +1104,13 @@ void wxToolBar::OnSysColourChanged(wxSysColourChangedEvent& event) void wxToolBar::OnMouseEvent(wxMouseEvent& event) { + if (event.Leaving() && m_pInTool) + { + OnMouseEnter( -1 ); + event.Skip(); + return; + } + if (event.RightDown()) { // For now, we don't have an id. Later we could @@ -1179,11 +1144,18 @@ bool wxToolBar::HandleSize(WXWPARAM wParam, WXLPARAM lParam) else { w = LOWORD(lParam); - h = r.bottom - r.top; + if (HasFlag( wxTB_FLAT )) + h = r.bottom - r.top - 3; + else + h = r.bottom - r.top; if ( m_maxRows ) { // FIXME: 6 is hardcoded separator line height... - h += 6; + //h += 6; + if (HasFlag(wxTB_NODIVIDER)) + h += 3; + else + h += 6; h *= m_maxRows; } }