#if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && !defined(__SMARTPHONE__)
+#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/dcmemory.h"
#include "wx/control.h"
#include "wx/app.h" // for GetComCtl32Version
+ #include "wx/image.h"
#endif
-#include "wx/toolbar.h"
#include "wx/sysopt.h"
-#include "wx/image.h"
#include "wx/msw/private.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;
(style & ~wxBORDER_MASK) | wxBORDER_NONE, exstyle
);
- // always include this one, it never hurts and setting it later
- // only if we do have tooltips wouldn't work
- msStyle |= TBSTYLE_TOOLTIPS;
+ if ( !(style & wxTB_NO_TOOLTIPS) )
+ msStyle |= TBSTYLE_TOOLTIPS;
if ( style & (wxTB_FLAT | wxTB_HORZ_LAYOUT) )
{
// static as it doesn't change during the program lifetime
- static int s_verComCtl = wxApp::GetComCtl32Version();
+ static const 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 ( style & wxTB_VERTICAL )
msStyle |= CCS_VERT;
+ if( style & wxTB_BOTTOM )
+ msStyle |= CCS_BOTTOM;
+
+ if ( style & wxTB_RIGHT )
+ msStyle |= CCS_RIGHT;
+
return msStyle;
}
// as we can't use disabled image list with older versions of comctl32.dll,
// don't even bother creating it
- if ( wxTheApp->GetComCtl32Version() >= 470 )
+ if ( wxApp::GetComCtl32Version() >= 470 )
{
// search for the first disabled button img in the toolbar, if any
for ( wxToolBarToolsList::compatibility_iterator
// 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
WXLPARAM lParam,
WXLPARAM *WXUNUSED(result))
{
+ if( !HasFlag(wxTB_NO_TOOLTIPS) )
+ {
#if wxUSE_TOOLTIPS
- // First check if this applies to us
- NMHDR *hdr = (NMHDR *)lParam;
+ // First check if this applies to us
+ NMHDR *hdr = (NMHDR *)lParam;
- // the tooltips control created by the toolbar is sometimes Unicode, even
- // in an ANSI application - this seems to be a bug in comctl32.dll v5
- UINT code = hdr->code;
- if ( (code != (UINT) TTN_NEEDTEXTA) && (code != (UINT) TTN_NEEDTEXTW) )
- return false;
-
- HWND toolTipWnd = (HWND)::SendMessage((HWND)GetHWND(), TB_GETTOOLTIPS, 0, 0);
- if ( toolTipWnd != hdr->hwndFrom )
- return false;
+ // the tooltips control created by the toolbar is sometimes Unicode, even
+ // in an ANSI application - this seems to be a bug in comctl32.dll v5
+ UINT code = hdr->code;
+ if ( (code != (UINT) TTN_NEEDTEXTA) && (code != (UINT) TTN_NEEDTEXTW) )
+ return false;
- LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT)lParam;
- int id = (int)ttText->hdr.idFrom;
+ HWND toolTipWnd = (HWND)::SendMessage(GetHwnd(), TB_GETTOOLTIPS, 0, 0);
+ if ( toolTipWnd != hdr->hwndFrom )
+ return false;
- wxToolBarToolBase *tool = FindById(id);
- if ( !tool )
- return false;
+ LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT)lParam;
+ int id = (int)ttText->hdr.idFrom;
- return HandleTooltipNotify(code, lParam, tool->GetShortHelp());
+ wxToolBarToolBase *tool = FindById(id);
+ if ( tool )
+ return HandleTooltipNotify(code, lParam, tool->GetShortHelp());
#else
- wxUnusedVar(lParam);
+ wxUnusedVar(lParam);
+#endif
+ }
return false;
-#endif
}
// ----------------------------------------------------------------------------
// 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
-
+ // let the system do it for us
event.Skip();
- return;
}
}
{
int w, h;
- if ( GetWindowStyle() & wxTB_VERTICAL )
+ if ( IsVertical() )
{
w = r.right - r.left;
if ( m_maxRows )