minor refactoring of OnEraseBackground()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40275 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -118,6 +118,9 @@ protected:
|
|||||||
// unneeded
|
// unneeded
|
||||||
void CreateDisabledImageList();
|
void CreateDisabledImageList();
|
||||||
|
|
||||||
|
// get the Windows toolbar style of this control
|
||||||
|
long GetMSWToolbarStyle() const;
|
||||||
|
|
||||||
|
|
||||||
// the big bitmap containing all bitmaps of the toolbar buttons
|
// the big bitmap containing all bitmaps of the toolbar buttons
|
||||||
WXHBITMAP m_hBitmap;
|
WXHBITMAP m_hBitmap;
|
||||||
|
@@ -182,7 +182,6 @@ private:
|
|||||||
DECLARE_NO_COPY_CLASS(wxToolBarTool)
|
DECLARE_NO_COPY_CLASS(wxToolBarTool)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -248,7 +247,7 @@ bool wxToolBar::Create(wxWindow *parent,
|
|||||||
#if wxUSE_UXTHEME
|
#if wxUSE_UXTHEME
|
||||||
if ( style & wxTB_FLAT )
|
if ( style & wxTB_FLAT )
|
||||||
{
|
{
|
||||||
LRESULT style = ::SendMessage(GetHwnd(), TB_GETSTYLE, 0, 0L);
|
LRESULT style = GetMSWToolbarStyle();
|
||||||
|
|
||||||
if ( !(style & TBSTYLE_FLAT) )
|
if ( !(style & TBSTYLE_FLAT) )
|
||||||
::SendMessage(GetHwnd(), TB_SETSTYLE, 0, style | TBSTYLE_FLAT);
|
::SendMessage(GetHwnd(), TB_SETSTYLE, 0, style | TBSTYLE_FLAT);
|
||||||
@@ -1273,6 +1272,12 @@ void wxToolBar::UpdateSize()
|
|||||||
// toolbar styles
|
// toolbar styles
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// get the TBSTYLE of the given toolbar window
|
||||||
|
long wxToolBar::GetMSWToolbarStyle() const
|
||||||
|
{
|
||||||
|
return ::SendMessage(GetHwnd(), TB_GETSTYLE, 0, 0L);
|
||||||
|
}
|
||||||
|
|
||||||
void wxToolBar::SetWindowStyleFlag(long style)
|
void wxToolBar::SetWindowStyleFlag(long style)
|
||||||
{
|
{
|
||||||
// the style bits whose changes force us to recreate the toolbar
|
// the style bits whose changes force us to recreate the toolbar
|
||||||
@@ -1372,25 +1377,11 @@ void wxToolBar::OnEraseBackground(wxEraseEvent& event)
|
|||||||
RECT rect = wxGetClientRect(GetHwnd());
|
RECT rect = wxGetClientRect(GetHwnd());
|
||||||
HDC hdc = GetHdcOf((*event.GetDC()));
|
HDC hdc = GetHdcOf((*event.GetDC()));
|
||||||
|
|
||||||
if ( UseBgCol() )
|
|
||||||
{
|
|
||||||
// do draw our background
|
|
||||||
//
|
|
||||||
// notice that this 'dumb' implementation may cause flicker for some of
|
|
||||||
// the controls in which case they should intercept wxEraseEvent and
|
|
||||||
// process it themselves somehow
|
|
||||||
AutoHBRUSH hBrush(wxColourToRGB(GetBackgroundColour()));
|
|
||||||
|
|
||||||
wxCHANGE_HDC_MAP_MODE(hdc, MM_TEXT);
|
|
||||||
::FillRect(hdc, &rect, hBrush);
|
|
||||||
}
|
|
||||||
else // we have no non default background colour
|
|
||||||
{
|
|
||||||
#if wxUSE_UXTHEME
|
#if wxUSE_UXTHEME
|
||||||
// we may need to draw themed colour so that we appear correctly on
|
// we may need to draw themed colour so that we appear correctly on
|
||||||
// e.g. notebook page under XP with themes but only do it if the parent
|
// e.g. notebook page under XP with themes but only do it if the parent
|
||||||
// draws themed background itself
|
// draws themed background itself
|
||||||
if ( !GetParent()->UseBgCol() )
|
if ( !UseBgCol() && !GetParent()->UseBgCol() )
|
||||||
{
|
{
|
||||||
wxUxThemeEngine *theme = wxUxThemeEngine::GetIfActive();
|
wxUxThemeEngine *theme = wxUxThemeEngine::GetIfActive();
|
||||||
if ( theme )
|
if ( theme )
|
||||||
@@ -1408,18 +1399,23 @@ void wxToolBar::OnEraseBackground(wxEraseEvent& event)
|
|||||||
}
|
}
|
||||||
#endif // wxUSE_UXTHEME
|
#endif // wxUSE_UXTHEME
|
||||||
|
|
||||||
// if we are transparent then paint our background ourselves
|
if ( UseBgCol() || (GetMSWToolbarStyle() & TBSTYLE_TRANSPARENT) )
|
||||||
LRESULT style = ::SendMessage(GetHwnd(), TB_GETSTYLE, 0, 0L);
|
|
||||||
if ( style & TBSTYLE_TRANSPARENT )
|
|
||||||
{
|
{
|
||||||
::FillRect(hdc, &rect, ::GetSysColorBrush(COLOR_BTNFACE));
|
// do draw our background
|
||||||
|
//
|
||||||
|
// notice that this 'dumb' implementation may cause flicker for some of
|
||||||
|
// the controls in which case they should intercept wxEraseEvent and
|
||||||
|
// process it themselves somehow
|
||||||
|
AutoHBRUSH hBrush(wxColourToRGB(GetBackgroundColour()));
|
||||||
|
|
||||||
|
wxCHANGE_HDC_MAP_MODE(hdc, MM_TEXT);
|
||||||
|
::FillRect(hdc, &rect, hBrush);
|
||||||
}
|
}
|
||||||
else
|
else // we have no non default background colour
|
||||||
{
|
{
|
||||||
// let the system do it for us
|
// let the system do it for us
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)
|
bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)
|
||||||
|
Reference in New Issue
Block a user