fix for creating radio items in a toolbar with non zero margin

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17026 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-09-06 18:28:58 +00:00
parent 8f262dc567
commit 6a1359c0a5
2 changed files with 16 additions and 12 deletions

View File

@@ -374,8 +374,9 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
{ {
wxToolBarTool *tool = (wxToolBarTool *)toolBase; wxToolBarTool *tool = (wxToolBarTool *)toolBase;
// we have inserted a space before all the tools // if we have inserted a space before all the tools we must change the GTK
if (m_xMargin > 1) pos++; // index by 1
size_t posGtk = m_xMargin > 1 ? pos + 1 : pos;
if ( tool->IsButton() ) if ( tool->IsButton() )
{ {
@@ -454,7 +455,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
tool->m_pixmap, tool->m_pixmap,
(GtkSignalFunc)gtk_toolbar_callback, (GtkSignalFunc)gtk_toolbar_callback,
(gpointer)tool, (gpointer)tool,
pos posGtk
); );
if ( !tool->m_item ) if ( !tool->m_item )
@@ -476,7 +477,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
break; break;
case wxTOOL_STYLE_SEPARATOR: case wxTOOL_STYLE_SEPARATOR:
gtk_toolbar_insert_space( m_toolbar, pos ); gtk_toolbar_insert_space( m_toolbar, posGtk );
// skip the rest // skip the rest
return TRUE; return TRUE;
@@ -487,7 +488,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
tool->GetControl()->m_widget, tool->GetControl()->m_widget,
(const char *) NULL, (const char *) NULL,
(const char *) NULL, (const char *) NULL,
pos posGtk
); );
break; break;
} }
@@ -586,7 +587,8 @@ void wxToolBar::SetMargins( int x, int y )
wxCHECK_RET( GetToolsCount() == 0, wxCHECK_RET( GetToolsCount() == 0,
wxT("wxToolBar::SetMargins must be called before adding tools.") ); wxT("wxToolBar::SetMargins must be called before adding tools.") );
if (x > 1) gtk_toolbar_append_space( m_toolbar ); // oh well if (x > 1)
gtk_toolbar_append_space( m_toolbar ); // oh well
m_xMargin = x; m_xMargin = x;
m_yMargin = y; m_yMargin = y;

View File

@@ -374,8 +374,9 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
{ {
wxToolBarTool *tool = (wxToolBarTool *)toolBase; wxToolBarTool *tool = (wxToolBarTool *)toolBase;
// we have inserted a space before all the tools // if we have inserted a space before all the tools we must change the GTK
if (m_xMargin > 1) pos++; // index by 1
size_t posGtk = m_xMargin > 1 ? pos + 1 : pos;
if ( tool->IsButton() ) if ( tool->IsButton() )
{ {
@@ -454,7 +455,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
tool->m_pixmap, tool->m_pixmap,
(GtkSignalFunc)gtk_toolbar_callback, (GtkSignalFunc)gtk_toolbar_callback,
(gpointer)tool, (gpointer)tool,
pos posGtk
); );
if ( !tool->m_item ) if ( !tool->m_item )
@@ -476,7 +477,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
break; break;
case wxTOOL_STYLE_SEPARATOR: case wxTOOL_STYLE_SEPARATOR:
gtk_toolbar_insert_space( m_toolbar, pos ); gtk_toolbar_insert_space( m_toolbar, posGtk );
// skip the rest // skip the rest
return TRUE; return TRUE;
@@ -487,7 +488,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
tool->GetControl()->m_widget, tool->GetControl()->m_widget,
(const char *) NULL, (const char *) NULL,
(const char *) NULL, (const char *) NULL,
pos posGtk
); );
break; break;
} }
@@ -586,7 +587,8 @@ void wxToolBar::SetMargins( int x, int y )
wxCHECK_RET( GetToolsCount() == 0, wxCHECK_RET( GetToolsCount() == 0,
wxT("wxToolBar::SetMargins must be called before adding tools.") ); wxT("wxToolBar::SetMargins must be called before adding tools.") );
if (x > 1) gtk_toolbar_append_space( m_toolbar ); // oh well if (x > 1)
gtk_toolbar_append_space( m_toolbar ); // oh well
m_xMargin = x; m_xMargin = x;
m_yMargin = y; m_yMargin = y;