X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bec9bf3e20e07cfb3874069acce98aa2e898b8dc..8220f2f145758e44e84380767eb77723ab4ac5ef:/src/msw/toolbar.cpp diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 5dd2f917ff..44f08bffb8 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -405,11 +405,7 @@ void wxToolBar::Recreate() m_hBitmap = 0; } - if ( m_disabledImgList ) - { - delete m_disabledImgList; - m_disabledImgList = NULL; - } + wxDELETE(m_disabledImgList); Realize(); } @@ -610,11 +606,7 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) void wxToolBar::CreateDisabledImageList() { - if (m_disabledImgList != NULL) - { - delete m_disabledImgList; - m_disabledImgList = NULL; - } + wxDELETE(m_disabledImgList); // as we can't use disabled image list with older versions of comctl32.dll, // don't even bother creating it @@ -1219,13 +1211,13 @@ void wxToolBar::UpdateStretchableSpacersSize() // reduce their size if there is not enough place for all tools const int totalSize = IsVertical() ? GetClientSize().y : GetClientSize().x; const int extraSize = totalSize - m_totalFixedSize; - const int sizeSpacer = extraSize > 0 ? extraSize / numSpaces : 0; + const int sizeSpacer = extraSize > 0 ? extraSize / numSpaces : 1; // the last spacer should consume all remaining space if we have too much // of it (which can be greater than sizeSpacer because of the rounding) const int sizeLastSpacer = extraSize > 0 ? extraSize - (numSpaces - 1)*sizeSpacer - : 0; + : 1; // cumulated offset by which we need to move all the following controls to // the right: while the toolbar takes care of the normal items, we must @@ -1744,18 +1736,15 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) } } - if ( !rgnDummySeps.IsOk() ) + if ( rgnDummySeps.IsOk() ) { - // don't interfere with toolbar default painting at all if we don't - // need to -- and we don't if we have no dummy separators at all - return false; - } - - // exclude the area occupied by the controls and stretchable spaces from - // the update region to prevent the toolbar from drawing separators in it - if ( !::ValidateRgn(GetHwnd(), GetHrgnOf(rgnDummySeps)) ) - { - wxLogLastError(wxT("ValidateRgn()")); + // exclude the area occupied by the controls and stretchable spaces + // from the update region to prevent the toolbar from drawing + // separators in it + if ( !::ValidateRgn(GetHwnd(), GetHrgnOf(rgnDummySeps)) ) + { + wxLogLastError(wxT("ValidateRgn()")); + } } // still let the native control draw everything else normally but set up a @@ -1779,11 +1768,14 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) GetParent()->MSWSetEraseBgHook(NULL); - // erase the dummy separators region ourselves now as nobody painted over - // them - WindowHDC hdc(GetHwnd()); - ::SelectClipRgn(hdc, GetHrgnOf(rgnDummySeps)); - MSWDoEraseBackground(hdc); + if ( rgnDummySeps.IsOk() ) + { + // erase the dummy separators region ourselves now as nobody painted + // over them + WindowHDC hdc(GetHwnd()); + ::SelectClipRgn(hdc, GetHrgnOf(rgnDummySeps)); + MSWDoEraseBackground(hdc); + } return true; } @@ -1807,7 +1799,7 @@ WXHBRUSH wxToolBar::MSWGetToolbarBgBrush() wxBrush * const brush = wxTheBrushList->FindOrCreateBrush(colBg); - return brush ? brush->GetResourceHandle() : 0; + return brush ? static_cast(brush->GetResourceHandle()) : 0; } WXHBRUSH wxToolBar::MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child)