X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0580ddb24f546753d4c758f7f2f686db80f515e6..f0f03f324281e2a2eb137f532295dc2bcaa120d3:/src/msw/toolbar.cpp?ds=sidebyside diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 140831106f..ba4638e445 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -46,7 +46,7 @@ #include "wx/artprov.h" #include "wx/sysopt.h" #include "wx/dcclient.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedarray.h" #include "wx/msw/private.h" #include "wx/msw/dc.h" @@ -200,7 +200,7 @@ public: wxStaticText* GetStaticText() { wxASSERT_MSG( IsControl(), - _T("only makes sense for embedded control tools") ); + wxT("only makes sense for embedded control tools") ); return m_staticText; } @@ -214,7 +214,7 @@ private: size_t m_nSepCount; wxStaticText *m_staticText; - DECLARE_NO_COPY_CLASS(wxToolBarTool) + wxDECLARE_NO_COPY_CLASS(wxToolBarTool); }; // ---------------------------------------------------------------------------- @@ -282,9 +282,13 @@ void wxToolBar::Init() m_nButtons = 0; - const wxSize size = wxArtProvider::GetNativeSizeHint(wxART_TOOLBAR); - m_defaultWidth = size.x; - m_defaultHeight = size.y; + // even though modern Windows applications typically use 24*24 (or even + // 32*32) size for their bitmaps, the native control itself still uses the + // old 16*15 default size (see TB_SETBITMAPSIZE documentation in MSDN), so + // default to it so that we don't call SetToolBitmapSize() unnecessarily in + // wxToolBarBase::AdjustToolBitmapSize() + m_defaultWidth = 16; + m_defaultHeight = 15; m_pInTool = NULL; } @@ -357,7 +361,7 @@ void wxToolBar::Recreate() if ( !MSWCreateToolbar(pos, size) ) { // what can we do? - wxFAIL_MSG( _T("recreating the toolbar failed") ); + wxFAIL_MSG( wxT("recreating the toolbar failed") ); return; } @@ -630,41 +634,12 @@ void wxToolBar::CreateDisabledImageList() } } -void wxToolBar::MSWSetBitmapSize(const wxSize& size) -{ - ::SendMessage(GetHwnd(), TB_SETBITMAPSIZE, 0, MAKELONG(size.x, size.y)); -} - -void wxToolBar::AdjustToolBitmapSize() -{ - // this is the default bitmap size, we only need to call TB_SETBITMAPSIZE - // if we use something different - static const wxSize sizeStd(16, 15); - - wxSize s(m_defaultWidth, m_defaultHeight); - - for ( wxToolBarToolsList::const_iterator i = m_tools.begin(); - i != m_tools.end(); - ++i ) - { - const wxBitmap& bmp = (*i)->GetNormalBitmap(); - s.IncTo(bmp.GetSize()); - } - - if ( s != sizeStd ) - MSWSetBitmapSize(s); -} - bool wxToolBar::Realize() { - const size_t nTools = GetToolsCount(); - if ( nTools == 0 ) - // nothing to do - return true; + if ( !wxToolBarBase::Realize() ) + return false; - // make sure tool size is larger enough for all all bitmaps to fit in - // (this is consistent with what other ports do): - AdjustToolBitmapSize(); + const size_t nTools = GetToolsCount(); #ifdef wxREMAP_BUTTON_COLOURS // don't change the values of these constants, they can be set from the @@ -777,7 +752,7 @@ bool wxToolBar::Realize() } else { - wxFAIL_MSG( _T("invalid tool button bitmap") ); + wxFAIL_MSG( wxT("invalid tool button bitmap") ); } // also deal with disabled bitmap if we want to use them @@ -1022,7 +997,7 @@ bool wxToolBar::Realize() break; default: - wxFAIL_MSG( _T("unexpected toolbar button kind") ); + wxFAIL_MSG( wxT("unexpected toolbar button kind") ); button.fsStyle = TBSTYLE_BUTTON; break; } @@ -1302,7 +1277,7 @@ bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl), } const wxToolBarToolBase * const tool = FindById(tbhdr->iItem); - wxCHECK_MSG( tool, false, _T("drop down message for unknown tool") ); + wxCHECK_MSG( tool, false, wxT("drop down message for unknown tool") ); wxMenu * const menu = tool->GetDropdownMenu(); if ( !menu ) @@ -1354,7 +1329,7 @@ void wxToolBar::SetToolBitmapSize(const wxSize& size) { wxToolBarBase::SetToolBitmapSize(size); - MSWSetBitmapSize(size); + ::SendMessage(GetHwnd(), TB_SETBITMAPSIZE, 0, MAKELONG(size.x, size.y)); } void wxToolBar::SetRows(int nRows) @@ -1515,7 +1490,7 @@ void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(tog { // VZ: AFAIK, the button has to be created either with TBSTYLE_CHECK or // without, so we really need to delete the button and recreate it here - wxFAIL_MSG( _T("not implemented") ); + wxFAIL_MSG( wxT("not implemented") ); } void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap ) @@ -1599,7 +1574,7 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event) void wxToolBar::OnEraseBackground(wxEraseEvent& event) { RECT rect = wxGetClientRect(GetHwnd()); - + wxDC *dc = event.GetDC(); if (!dc) return; wxMSWDCImpl *impl = (wxMSWDCImpl*) dc->GetImpl(); @@ -1625,7 +1600,9 @@ void wxToolBar::OnEraseBackground(wxEraseEvent& event) // 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); + { + wxLogApiError(wxT("DrawThemeParentBackground(toolbar)"), hr); + } } } @@ -1648,7 +1625,9 @@ void wxToolBar::OnEraseBackground(wxEraseEvent& event) // 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); + { + wxLogApiError(wxT("DrawThemeParentBackground(toolbar)"), hr); + } } } @@ -1724,6 +1703,7 @@ bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam) return true; } +#ifndef __WXWINCE__ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) { // erase any dummy separators which were used @@ -1793,7 +1773,7 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) if ( !::SendMessage(GetHwnd(), TB_GETBUTTON, n, (LPARAM)&tbb) ) { - wxLogDebug(_T("TB_GETBUTTON failed?")); + wxLogDebug(wxT("TB_GETBUTTON failed?")); continue; } @@ -1835,14 +1815,14 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) r.right = clientSize.x; r.top = 0; r.bottom = clientSize.y; - + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); HRESULT hr = theme->DrawThemeBackground(hTheme, GetHdcOf(*impl), 0, 0, & r, & clipRect); if ( hr == S_OK ) haveRefreshed = true; } } -#endif +#endif // wxUSE_UXTHEME if (!haveRefreshed) dc.DrawRectangle(rectItem); @@ -1867,6 +1847,7 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) return true; } +#endif // __WXWINCE__ void wxToolBar::HandleMouseMove(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam) { @@ -1924,7 +1905,7 @@ WXHBITMAP wxToolBar::MapBitmap(WXHBITMAP bitmap, int width, int height) if ( !hdcMem ) { - wxLogLastError(_T("CreateCompatibleDC")); + wxLogLastError(wxT("CreateCompatibleDC")); return bitmap; } @@ -1933,7 +1914,7 @@ WXHBITMAP wxToolBar::MapBitmap(WXHBITMAP bitmap, int width, int height) if ( !bmpInHDC ) { - wxLogLastError(_T("SelectObject")); + wxLogLastError(wxT("SelectObject")); return bitmap; }