m_hBitmap = 0;
}
- if ( m_disabledImgList )
- {
- delete m_disabledImgList;
- m_disabledImgList = NULL;
- }
+ wxDELETE(m_disabledImgList);
Realize();
}
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
{
wxToolBarToolBase *tool = node->GetData();
wxBitmap bmpDisabled = tool->GetDisabledBitmap();
- if ( bmpDisabled.Ok() )
+ if ( bmpDisabled.IsOk() )
{
+ const wxSize sizeBitmap = bmpDisabled.GetSize();
m_disabledImgList = new wxImageList
(
- m_defaultWidth,
- m_defaultHeight,
+ sizeBitmap.x,
+ sizeBitmap.y,
bmpDisabled.GetMask() != NULL,
GetToolsCount()
);
const int w = bmp.GetWidth();
const int h = bmp.GetHeight();
- if ( bmp.Ok() )
+ if ( bmp.IsOk() )
{
int xOffset = wxMax(0, (m_defaultWidth - w)/2);
int yOffset = wxMax(0, (m_defaultHeight - h)/2);
{
wxBitmap bmpDisabled = tool->GetDisabledBitmap();
#if wxUSE_IMAGE && wxUSE_WXDIB
- if ( !bmpDisabled.Ok() )
+ if ( !bmpDisabled.IsOk() )
{
// no disabled bitmap specified but we still need to
// fill the space in the image list with something, so
// 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
// Without the two lines of code below, if the toolbar was repainted during
// OnLeftClick(), then it could end up without the tool bitmap temporarily
// (see http://lists.nongnu.org/archive/html/lmi/2008-10/msg00014.html).
- // The Update() call bellow ensures that this won't happen, by repainting
+ // The Update() call below ensures that this won't happen, by repainting
// invalidated areas of the toolbar immediately.
//
// To complicate matters, the tool would be drawn in depressed state (this
::SendMessage(GetHwnd(), TB_SETSTATE, id, MAKELONG(state, 0));
// OnLeftClick() can veto the button state change - for buttons which
- // may be toggled only, of couse
+ // may be toggled only, of course.
if ( !allowLeftClick && tool->CanBeToggled() )
{
// revert back
{
// for some reason TB_GETITEMRECT returns a rectangle 1 pixel
// shorter than the full window size (at least under Windows 7)
- // but we need to erase the full height below
+ // but we need to erase the full width/height below
RECT rcItem = wxGetTBItemRect(GetHwnd(), toolIndex);
- rcItem.top = 0;
- rcItem.bottom = rectTotal.height;
+ if ( IsVertical() )
+ {
+ rcItem.left = 0;
+ rcItem.right = rectTotal.width;
+ }
+ else
+ {
+ rcItem.top = 0;
+ rcItem.bottom = rectTotal.height;
+ }
rgnDummySeps.Union(wxRectFromRECT(rcItem));
}
}
}
- 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)) )
+ if ( rgnDummySeps.IsOk() )
{
- 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
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;
}
wxBrush * const
brush = wxTheBrushList->FindOrCreateBrush(colBg);
- return brush ? brush->GetResourceHandle() : 0;
+ return brush ? static_cast<WXHBRUSH>(brush->GetResourceHandle()) : 0;
}
WXHBRUSH wxToolBar::MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child)