if ( style & (wxTB_FLAT | wxTB_HORZ_LAYOUT) )
{
// static as it doesn't change during the program lifetime
- static int s_verComCtl = wxTheApp->GetComCtl32Version();
+ static int s_verComCtl = wxApp::GetComCtl32Version();
// comctl32.dll 4.00 doesn't support the flat toolbars and using this
// style with 6.00 (part of Windows XP) leads to the toolbar with
if ( tool->IsButton() )
{
const wxBitmap& bmp = tool->GetNormalBitmap();
+
+ const int w = bmp.GetWidth();
+ const int h = bmp.GetHeight();
+
if ( bmp.Ok() )
{
- int xOffset = wxMax(0, (m_defaultWidth - bmp.GetWidth())/2);
- int yOffset = wxMax(0, (m_defaultHeight - bmp.GetHeight())/2);
+ int xOffset = wxMax(0, (m_defaultWidth - w)/2);
+ int yOffset = wxMax(0, (m_defaultHeight - h)/2);
+
// notice the last parameter: do use mask
- dcAllButtons.DrawBitmap(bmp, x+xOffset, yOffset, true);
+ dcAllButtons.DrawBitmap(bmp, x + xOffset, yOffset, true);
}
else
{
if ( m_disabledImgList )
{
wxBitmap bmpDisabled = tool->GetDisabledBitmap();
+#if wxUSE_IMAGE
if ( !bmpDisabled.Ok() )
{
-#if wxUSE_IMAGE
// no disabled bitmap specified but we still need to
// fill the space in the image list with something, so
// we grey out the normal bitmap
- wxImage img = bmp.ConvertToImage();
-#if 0
- img.SetMaskColour(wxLIGHT_GREY->Red(),
- wxLIGHT_GREY->Green(),
- wxLIGHT_GREY->Blue());
-#endif
wxImage imgGreyed;
- wxCreateGreyedImage(img, imgGreyed);
+ wxCreateGreyedImage(bmp.ConvertToImage(), imgGreyed);
- bmpDisabled = wxBitmap(imgGreyed);
-#if 0
- bmpDisabled.SetMask(new wxMask(bmpDisabled, *wxLIGHT_GREY));
+ // we need to have light grey background colour for
+ // MapBitmap() to work correctly
+ for ( int y = 0; y < h; y++ )
+ {
+ for ( int x = 0; x < w; x++ )
+ {
+ if ( imgGreyed.IsTransparent(x, y) )
+ imgGreyed.SetRGB(x, y,
+ wxLIGHT_GREY->Red(),
+ wxLIGHT_GREY->Green(),
+ wxLIGHT_GREY->Blue());
+ }
+ }
- MapBitmap(bmpDisabled.GetHBITMAP(),
- bmpDisabled.GetWidth(),
- bmpDisabled.GetHeight());
-#endif // 0
-#endif // wxUSE_IMAGE
+ bmpDisabled = wxBitmap(imgGreyed);
}
+#endif // wxUSE_IMAGE
+
+ MapBitmap(bmpDisabled.GetHBITMAP(), w, h);
m_disabledImgList->Add(bmpDisabled);
}
if ( oldToolBarBitmap )
{
#ifdef TB_REPLACEBITMAP
- if ( wxTheApp->GetComCtl32Version() >= 400 )
+ if ( wxApp::GetComCtl32Version() >= 400 )
{
TBREPLACEBITMAP replaceBitmap;
replaceBitmap.hInstOld = NULL;
// don't add separators to the vertical toolbar with old comctl32.dll
// versions as they didn't handle this properly
if ( isVertical && tool->IsSeparator() &&
- wxTheApp->GetComCtl32Version() <= 472 )
+ wxApp::GetComCtl32Version() <= 472 )
{
continue;
}
// radio items
button.fsState |= TBSTATE_CHECKED;
- tool->Toggle(true);
+ if (tool->Toggle(true))
+ {
+ DoToggleTool(tool, true);
+ }
+ }
+ else if (tool->IsToggled())
+ {
+ wxToolBarToolsList::compatibility_iterator nodePrev = node->GetPrevious();
+ int prevIndex = i - 1;
+ while ( nodePrev )
+ {
+ TBBUTTON& prevButton = buttons[prevIndex];
+ wxToolBarToolBase *tool = nodePrev->GetData();
+ if ( !tool->IsButton() || tool->GetKind() != wxITEM_RADIO )
+ break;
+
+ if ( tool->Toggle(false) )
+ {
+ DoToggleTool(tool, false);
+ }
+ prevButton.fsState = TBSTATE_ENABLED;
+ nodePrev = nodePrev->GetPrevious();
+ prevIndex--;
+ }
}
isRadio = true;
#ifdef TB_SETBUTTONINFO
// available in headers, now check whether it is available now
// (during run-time)
- if ( wxTheApp->GetComCtl32Version() >= 471 )
+ if ( wxApp::GetComCtl32Version() >= 471 )
{
// set the (underlying) separators width to be that of the
// control
#if defined(_WIN32_IE) && (_WIN32_IE >= 0x300 ) \
&& !( defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 1, 0 ) ) \
&& !defined (__DIGITALMARS__)
- if ( wxTheApp->GetComCtl32Version() >= 470 )
+ if ( wxApp::GetComCtl32Version() >= 470 )
{
DWORD dw = ::SendMessage(GetHwnd(), TB_GETBUTTONSIZE, 0, 0);
// if comctl32 version < 4.71 wxToolBar95 adds dummy spacers
#if defined(_WIN32_IE) && (_WIN32_IE >= 0x400 )
- if ( wxTheApp->GetComCtl32Version() >= 471 )
+ if ( wxApp::GetComCtl32Version() >= 471 )
{
return m_tools.Item((size_t)index)->GetData();
}