#include "wx/stattext.h"
#endif
+#include "wx/artprov.h"
#include "wx/sysopt.h"
#include "wx/dcclient.h"
+#include "wx/scopedarray.h"
#include "wx/msw/private.h"
#include "wx/msw/dc.h"
#define TB_GETMAXSIZE (WM_USER + 83)
#endif
-// these values correspond to those used by comctl32.dll
-#define DEFAULTBITMAPX 16
-#define DEFAULTBITMAPY 15
-
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
wxStaticText* GetStaticText()
{
wxASSERT_MSG( IsControl(),
- _T("only makes sense for embedded control tools") );
+ wxT("only makes sense for embedded control tools") );
return m_staticText;
}
size_t m_nSepCount;
wxStaticText *m_staticText;
- DECLARE_NO_COPY_CLASS(wxToolBarTool)
+ wxDECLARE_NO_COPY_CLASS(wxToolBarTool);
};
// ----------------------------------------------------------------------------
m_nButtons = 0;
- m_defaultWidth = DEFAULTBITMAPX;
- m_defaultHeight = DEFAULTBITMAPY;
+ // 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;
}
if ( !MSWCreateToolbar(pos, size) )
{
// what can we do?
- wxFAIL_MSG( _T("recreating the toolbar failed") );
+ wxFAIL_MSG( wxT("recreating the toolbar failed") );
return;
}
bool wxToolBar::Realize()
{
+ if ( !wxToolBarBase::Realize() )
+ return false;
+
const size_t nTools = GetToolsCount();
- if ( nTools == 0 )
- // nothing to do
- return true;
#ifdef wxREMAP_BUTTON_COLOURS
// don't change the values of these constants, they can be set from the
wxToolBarToolsList::compatibility_iterator node;
int bitmapId = 0;
- wxSize sizeBmp;
- if ( HasFlag(wxTB_NOICONS) )
- {
- // no icons, don't leave space for them
- sizeBmp.x =
- sizeBmp.y = 0;
- }
- else // do show icons
+ if ( !HasFlag(wxTB_NOICONS) )
{
// if we already have a bitmap, we'll replace the existing one --
// otherwise we'll install a new one
HBITMAP oldToolBarBitmap = (HBITMAP)m_hBitmap;
- sizeBmp.x = m_defaultWidth;
- sizeBmp.y = m_defaultHeight;
-
const wxCoord totalBitmapWidth = m_defaultWidth *
wx_truncate_cast(wxCoord, nTools),
totalBitmapHeight = m_defaultHeight;
}
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
}
}
- // don't call SetToolBitmapSize() as we don't want to change the values of
- // m_defaultWidth/Height
- if ( !::SendMessage(GetHwnd(), TB_SETBITMAPSIZE, 0,
- MAKELONG(sizeBmp.x, sizeBmp.y)) )
- {
- wxLogLastError(_T("TB_SETBITMAPSIZE"));
- }
// Next add the buttons and separators
// -----------------------------------
- TBBUTTON *buttons = new TBBUTTON[nTools];
+ wxScopedArray<TBBUTTON> buttons(new TBBUTTON[nTools]);
// this array will hold the indices of all controls in the toolbar
wxArrayInt controlIds;
break;
default:
- wxFAIL_MSG( _T("unexpected toolbar button kind") );
+ wxFAIL_MSG( wxT("unexpected toolbar button kind") );
button.fsStyle = TBSTYLE_BUTTON;
break;
}
i++;
}
- if ( !::SendMessage(GetHwnd(), TB_ADDBUTTONS, (WPARAM)i, (LPARAM)buttons) )
+ if ( !::SendMessage(GetHwnd(), TB_ADDBUTTONS, i, (LPARAM)buttons.get()) )
{
wxLogLastError(wxT("TB_ADDBUTTONS"));
}
- delete [] buttons;
// Deal with the controls finally
// ------------------------------
}
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 )
{
// 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 )
void wxToolBar::OnEraseBackground(wxEraseEvent& event)
{
RECT rect = wxGetClientRect(GetHwnd());
-
+
wxDC *dc = event.GetDC();
if (!dc) return;
wxMSWDCImpl *impl = (wxMSWDCImpl*) dc->GetImpl();
// 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);
+ }
}
}
// 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);
+ }
}
}
return true;
}
+#ifndef __WXWINCE__
bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam)
{
// erase any dummy separators which were used
if ( !::SendMessage(GetHwnd(), TB_GETBUTTON,
n, (LPARAM)&tbb) )
{
- wxLogDebug(_T("TB_GETBUTTON failed?"));
+ wxLogDebug(wxT("TB_GETBUTTON failed?"));
continue;
}
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);
return true;
}
+#endif // __WXWINCE__
void wxToolBar::HandleMouseMove(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)
{
if ( !hdcMem )
{
- wxLogLastError(_T("CreateCompatibleDC"));
+ wxLogLastError(wxT("CreateCompatibleDC"));
return bitmap;
}
if ( !bmpInHDC )
{
- wxLogLastError(_T("SelectObject"));
+ wxLogLastError(wxT("SelectObject"));
return bitmap;
}