#include "wx/toolbar.h"
#ifndef WX_PRECOMP
+ #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
#include "wx/dynarray.h"
#include "wx/frame.h"
#include "wx/log.h"
#include "wx/msw/uxtheme.h"
#endif
-// include <commctrl.h> "properly"
-#include "wx/msw/wrapcctl.h"
-
// this define controls whether the code for button colours remapping (only
// useful for 16 or 256 colour images) is active at all, it's always turned off
// for CE where it doesn't compile (and is probably not needed anyhow) and may
DECLARE_NO_COPY_CLASS(wxToolBarTool)
};
-
// ============================================================================
// implementation
// ============================================================================
if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
return false;
+ FixupStyle();
+
// MSW-specific initialisation
if ( !MSWCreateToolbar(pos, size) )
return false;
#if wxUSE_UXTHEME
if ( style & wxTB_FLAT )
{
- LRESULT style = ::SendMessage(GetHwnd(), TB_GETSTYLE, 0, 0L);
+ LRESULT style = GetMSWToolbarStyle();
if ( !(style & TBSTYLE_FLAT) )
::SendMessage(GetHwnd(), TB_SETSTYLE, 0, style | TBSTYLE_FLAT);
sizeBest.x *= GetToolsCount();
// reverse horz and vertical components if necessary
- if ( HasFlag(wxTB_VERTICAL) )
+ if ( IsVertical() )
{
int t = sizeBest.x;
sizeBest.x = sizeBest.y;
if ( style & wxTB_VERTICAL )
msStyle |= CCS_VERT;
+ if( style & wxTB_BOTTOM )
+ msStyle |= CCS_BOTTOM;
+
+ if ( style & wxTB_RIGHT )
+ msStyle |= CCS_RIGHT;
+
return msStyle;
}
// nothing to do
return true;
- const bool isVertical = HasFlag(wxTB_VERTICAL);
-
#ifdef wxREMAP_BUTTON_COLOURS
// don't change the values of these constants, they can be set from the
// user code via wxSystemOptions
}
}
- if ( m_disabledImgList )
+ // disable image lists are only supported in comctl32.dll 4.70+
+ if ( wxApp::GetComCtl32Version() >= 470 )
{
+ HIMAGELIST hil = m_disabledImgList
+ ? GetHimagelistOf(m_disabledImgList)
+ : 0;
+
+ // notice that we set the image list even if don't have one right
+ // now as we could have it before and need to reset it in this case
HIMAGELIST oldImageList = (HIMAGELIST)
- ::SendMessage(GetHwnd(),
- TB_SETDISABLEDIMAGELIST,
- 0,
- (LPARAM)GetHimagelistOf(m_disabledImgList));
+ ::SendMessage(GetHwnd(), TB_SETDISABLEDIMAGELIST, 0, (LPARAM)hil);
// delete previous image list if any
if ( oldImageList )
- ::DeleteObject( oldImageList );
+ ::DeleteObject(oldImageList);
}
}
// don't add separators to the vertical toolbar with old comctl32.dll
// versions as they didn't handle this properly
- if ( isVertical && tool->IsSeparator() &&
+ if ( IsVertical() && tool->IsSeparator() &&
wxApp::GetComCtl32Version() <= 472 )
{
continue;
// get the items size for all items but for the horizontal ones we
// don't need to deal with the non controls
bool isControl = tool->IsControl();
- if ( !isControl && !isVertical )
+ if ( !isControl && !IsVertical() )
continue;
// note that we use TB_GETITEMRECT and not TB_GETRECT because the
}
int top;
- if ( isVertical )
+ if ( IsVertical() )
{
left = 0;
top = y;
// separators which we added just for aligning the controls
m_nButtons = index;
- if ( !isVertical )
+ if ( !IsVertical() )
{
if ( m_maxRows == 0 )
// if not set yet, only one row
// 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)
{
// the style bits whose changes force us to recreate the toolbar
RECT rect = wxGetClientRect(GetHwnd());
HDC hdc = GetHdcOf((*event.GetDC()));
- if ( UseBgCol() )
+#if wxUSE_UXTHEME
+ // 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
+ // draws themed background itself
+ if ( !UseBgCol() && !GetParent()->UseBgCol() )
+ {
+ wxUxThemeEngine *theme = wxUxThemeEngine::GetIfActive();
+ if ( theme )
+ {
+ HRESULT
+ hr = theme->DrawThemeParentBackground(GetHwnd(), hdc, &rect);
+ if ( hr == S_OK )
+ return;
+
+ // it can also return S_FALSE which seems to simply say that it
+ // didn't draw anything but no error really occurred
+ if ( FAILED(hr) )
+ wxLogApiError(_T("DrawThemeParentBackground(toolbar)"), hr);
+ }
+ }
+#endif // wxUSE_UXTHEME
+
+ if ( UseBgCol() || (GetMSWToolbarStyle() & TBSTYLE_TRANSPARENT) )
{
// do draw our background
//
}
else // we have no non default background colour
{
-#if wxUSE_UXTHEME
- // 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
- // draws themed background itself
- if ( !GetParent()->UseBgCol() )
- {
- wxUxThemeEngine *theme = wxUxThemeEngine::GetIfActive();
- if ( theme )
- {
- HRESULT
- hr = theme->DrawThemeParentBackground(GetHwnd(), hdc, &rect);
- if ( hr == S_OK )
- return;
-
- // it can also return S_FALSE which seems to simply say that it
- // didn't draw anything but no error really occurred
- if ( FAILED(hr) )
- wxLogApiError(_T("DrawThemeParentBackground(toolbar)"), hr);
- }
- }
-#endif // wxUSE_UXTHEME
-
- // if we are transparent then paint our background ourselves
- LRESULT style = ::SendMessage(GetHwnd(), TB_GETSTYLE, 0, 0L);
- if ( style & TBSTYLE_TRANSPARENT )
- {
- ::FillRect(hdc, &rect, ::GetSysColorBrush(COLOR_BTNFACE));
- }
- else
- {
- // let the system do it for us
- event.Skip();
- }
+ // let the system do it for us
+ event.Skip();
}
}
{
int w, h;
- if ( GetWindowStyle() & wxTB_VERTICAL )
+ if ( IsVertical() )
{
w = r.right - r.left;
if ( m_maxRows )