// must be called after all buttons have been created to finish toolbar
// initialisation
+ //
+ // derived class versions should call the base one first, before doing
+ // platform-specific stuff
virtual bool Realize();
// tools state
// un-toggle all buttons in the same radio group
void UnToggleRadioGroup(wxToolBarToolBase *tool);
+ // make the size of the buttons big enough to fit the largest bitmap size
+ void AdjustToolBitmapSize();
+
+
// the list of all our tools
wxToolBarToolsList m_tools;
}
}
+void wxToolBarBase::AdjustToolBitmapSize()
+{
+ const wxSize sizeOrig(m_defaultWidth, m_defaultHeight);
+
+ wxSize sizeActual(sizeOrig);
+
+ for ( wxToolBarToolsList::const_iterator i = m_tools.begin();
+ i != m_tools.end();
+ ++i )
+ {
+ const wxBitmap& bmp = (*i)->GetNormalBitmap();
+ if ( bmp.IsOk() )
+ sizeActual.IncTo(bmp.GetSize());
+ }
+
+ if ( sizeActual != sizeOrig )
+ SetToolBitmapSize(sizeActual);
+}
+
bool wxToolBarBase::Realize()
{
+ // check if we have anything to do
+ if ( m_tools.empty() )
+ 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();
+
return true;
}
// 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
- // AdjustToolBitmapSize()
+ // wxToolBarBase::AdjustToolBitmapSize()
m_defaultWidth = 16;
m_defaultHeight = 15;
}
}
-void wxToolBar::AdjustToolBitmapSize()
-{
- const wxSize sizeOrig(m_defaultWidth, m_defaultHeight);
-
- wxSize sizeActual(sizeOrig);
-
- for ( wxToolBarToolsList::const_iterator i = m_tools.begin();
- i != m_tools.end();
- ++i )
- {
- const wxBitmap& bmp = (*i)->GetNormalBitmap();
- sizeActual.IncTo(bmp.GetSize());
- }
-
- if ( sizeActual != sizeOrig )
- SetToolBitmapSize(sizeActual);
-}
-
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
{
if ( wxToolBarToolBase::Toggle( toggle ) == false )
return false;
-
+
UpdateToggleImage(toggle);
return true;
}
-
+
void UpdateHelpStrings()
{
-#if wxOSX_USE_NATIVE_TOOLBAR
+#if wxOSX_USE_NATIVE_TOOLBAR
if ( m_toolbarItemRef )
{
wxFontEncoding enc = GetToolBarFontEncoding();
}
#endif
}
-
+
virtual bool SetShortHelp(const wxString& help)
{
if ( wxToolBarToolBase::SetShortHelp( help ) == false )
return false;
-
- UpdateHelpStrings();
+
+ UpdateHelpStrings();
return true;
}
-
+
virtual bool SetLongHelp(const wxString& help)
{
if ( wxToolBarToolBase::SetLongHelp( help ) == false )
return true;
}
- virtual void SetNormalBitmap(const wxBitmap& bmp)
+ virtual void SetNormalBitmap(const wxBitmap& bmp)
{
wxToolBarToolBase::SetNormalBitmap(bmp);
UpdateToggleImage(CanBeToggled() && IsToggled());
}
-
+
virtual void SetLabel(const wxString& label)
{
wxToolBarToolBase::SetLabel(label);
{
if ( wxToolBarToolBase::Enable( enable ) == false )
return false;
-
+
if ( IsControl() )
{
GetControl()->Enable( enable );
bResult = true;
SetWindowToolbar( tlw, (HIToolbarRef) m_macToolbar );
-
+
// ShowHideWindowToolbar will make the wxFrame grow
// which we don't want in this case
wxSize sz = GetParent()->GetSize();
ShowHideWindowToolbar( tlw, true, false );
// Restore the orginal size
GetParent()->SetSize( sz );
-
+
ChangeWindowAttributes( tlw, kWindowToolbarButtonAttribute, 0 );
-
+
SetAutomaticControlDragTrackingEnabledForWindow( tlw, true );
-
+
m_peer->Move(0,0,0,0 );
SetSize( wxSIZE_AUTO_WIDTH, 0 );
m_peer->SetVisibility( false );
bool wxToolBar::Realize()
{
- if (m_tools.GetCount() == 0)
+ if ( !wxToolBarBase::Realize() )
return false;
-
+
wxSize tlw_sz = GetParent()->GetSize();
int maxWidth = 0;
if (m_macUsesNativeToolbar)
GetParent()->SetSize( tlw_sz );
-
+
if ( GetWindowStyleFlag() & (wxTB_TOP|wxTB_BOTTOM) )
{
// if not set yet, only one row
bool wxToolBar::Realize()
{
- if (m_tools.GetCount() == 0)
+ if ( !wxToolBarBase::Realize() )
return false;
int maxWidth = 0;