#include "wx/stattext.h"
#endif
+#include "wx/artprov.h"
#include "wx/sysopt.h"
#include "wx/dcclient.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
// ----------------------------------------------------------------------------
m_nButtons = 0;
- m_defaultWidth = DEFAULTBITMAPX;
- m_defaultHeight = DEFAULTBITMAPY;
+ const wxSize size = wxArtProvider::GetNativeSizeHint(wxART_TOOLBAR);
+ m_defaultWidth = size.x;
+ m_defaultHeight = size.y;
m_pInTool = NULL;
}
}
}
+void wxToolBar::AdjustToolBitmapSize()
+{
+ wxSize s(m_defaultWidth, m_defaultHeight);
+ const wxSize orig_s(s);
+
+ for ( wxToolBarToolsList::const_iterator i = m_tools.begin();
+ i != m_tools.end();
+ ++i )
+ {
+ const wxBitmap& bmp = (*i)->GetNormalBitmap();
+ s.IncTo(bmp.GetSize());
+ }
+
+ if ( s != orig_s )
+ SetToolBitmapSize(s);
+}
+
bool wxToolBar::Realize()
{
const size_t nTools = GetToolsCount();
// nothing to do
return true;
+ // make sure tool size is larger enough for all all bitmaps to fit in
+ // (this is consistent with what other ports do):
+ AdjustToolBitmapSize();
+
#ifdef wxREMAP_BUTTON_COLOURS
// don't change the values of these constants, they can be set from the
// user code via wxSystemOptions
bool allowLeftClick = OnLeftClick(id, toggled);
- // restore the unpressed state
+ // Restore the unpressed state. Enabled/toggled state might have been
+ // changed since so take care of it.
+ if (tool->IsEnabled())
+ state |= TBSTATE_ENABLED;
+ else
+ state &= ~TBSTATE_ENABLED;
+ if (tool->IsToggled())
+ state |= TBSTATE_CHECKED;
+ else
+ state &= ~TBSTATE_CHECKED;
::SendMessage(GetHwnd(), TB_SETSTATE, id, MAKELONG(state, 0));
// OnLeftClick() can veto the button state change - for buttons which
// TB_HITTEST returns m_nButtons ( not -1 )
if ( index < 0 || (size_t)index >= m_nButtons )
// it's a separator or there is no tool at all there
- return (wxToolBarToolBase *)NULL;
+ return NULL;
// when TB_SETBUTTONINFO is available (both during compile- and run-time),
// we don't use the dummy separators hack