X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2a1f999fafa4312ccd47b7be65c672c2220fea36..4f433feff9251ded00bba26b633f93e660cd44c4:/src/msw/tbar95.cpp?ds=sidebyside diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 9cf966b5af..5744077dfa 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -249,8 +249,14 @@ bool wxToolBar::Create(wxWindow *parent, #if wxUSE_UXTHEME if ( style & wxTB_FLAT ) { + // Testing for an active theme appears to be unnecessary (see comments in patch 1204217). + // Disabling the test brings back separator lines. + // However, the separators can look ugly and distracting, especially between controls, + // so I'm restoring the test and removing the separators again - JACS +#if 1 wxUxThemeEngine *p = wxUxThemeEngine::Get(); if ( !p || !p->IsThemeActive() ) +#endif { DWORD dwToolbarStyle; @@ -378,6 +384,7 @@ wxSize wxToolBar::DoGetBestSize() const sizeBest.y = size.cy; } + CacheBestSize(sizeBest); return sizeBest; } @@ -659,12 +666,17 @@ bool wxToolBar::Realize() 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 { @@ -675,31 +687,34 @@ bool wxToolBar::Realize() 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); } @@ -867,7 +882,30 @@ bool wxToolBar::Realize() // 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;