radio toolbar buttons finally work
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14795 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -93,6 +93,11 @@ public:
|
|||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// is this a radio button?
|
||||||
|
//
|
||||||
|
// unlike GetKind(), can be called for any kind of tools, not just buttons
|
||||||
|
bool IsRadio() const { return IsButton() && GetKind() == wxITEM_RADIO; }
|
||||||
|
|
||||||
// this is only called for the normal buttons, i.e. not separators nor
|
// this is only called for the normal buttons, i.e. not separators nor
|
||||||
// controls
|
// controls
|
||||||
GtkToolbarChildType GetGtkChildType() const
|
GtkToolbarChildType GetGtkChildType() const
|
||||||
@@ -162,6 +167,12 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
|
|
||||||
gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
|
gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( tool->IsRadio() && !tool->IsToggled() )
|
||||||
|
{
|
||||||
|
// radio button went up, don't report this as a wxWin event
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tbar->OnLeftClick( tool->GetId(), tool->IsToggled() );
|
tbar->OnLeftClick( tool->GetId(), tool->IsToggled() );
|
||||||
@@ -397,13 +408,47 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
|
|||||||
switch ( tool->GetStyle() )
|
switch ( tool->GetStyle() )
|
||||||
{
|
{
|
||||||
case wxTOOL_STYLE_BUTTON:
|
case wxTOOL_STYLE_BUTTON:
|
||||||
|
// for a radio button we need the widget which starts the radio
|
||||||
|
// group it belongs to, i.e. the first radio button immediately
|
||||||
|
// preceding this one
|
||||||
|
{
|
||||||
|
GtkWidget *widget = NULL;
|
||||||
|
|
||||||
|
if ( tool->IsRadio() )
|
||||||
|
{
|
||||||
|
wxToolBarToolsList::Node *node = pos ? m_tools.Item(pos - 1)
|
||||||
|
: NULL;
|
||||||
|
while ( node )
|
||||||
|
{
|
||||||
|
wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
|
||||||
|
if ( !tool->IsRadio() )
|
||||||
|
break;
|
||||||
|
|
||||||
|
widget = tool->m_item;
|
||||||
|
|
||||||
|
node = node->GetPrevious();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !widget )
|
||||||
|
{
|
||||||
|
// this is the first button in the radio button group,
|
||||||
|
// it will be toggled automatically by GTK so bring the
|
||||||
|
// internal flag in sync
|
||||||
|
tool->Toggle(TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tool->m_item = gtk_toolbar_insert_element
|
tool->m_item = gtk_toolbar_insert_element
|
||||||
(
|
(
|
||||||
m_toolbar,
|
m_toolbar,
|
||||||
tool->GetGtkChildType(),
|
tool->GetGtkChildType(),
|
||||||
(GtkWidget *)NULL,
|
widget,
|
||||||
tool->GetLabel().mbc_str(),
|
tool->GetLabel().empty()
|
||||||
tool->GetShortHelp().mbc_str(),
|
? NULL
|
||||||
|
: tool->GetLabel().mbc_str(),
|
||||||
|
tool->GetShortHelp().empty()
|
||||||
|
? NULL
|
||||||
|
: tool->GetShortHelp().mbc_str(),
|
||||||
"", // tooltip_private_text (?)
|
"", // tooltip_private_text (?)
|
||||||
tool->m_pixmap,
|
tool->m_pixmap,
|
||||||
(GtkSignalFunc)gtk_toolbar_callback,
|
(GtkSignalFunc)gtk_toolbar_callback,
|
||||||
@@ -426,6 +471,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
|
|||||||
"leave_notify_event",
|
"leave_notify_event",
|
||||||
GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
|
GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
|
||||||
(gpointer)tool );
|
(gpointer)tool );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxTOOL_STYLE_SEPARATOR:
|
case wxTOOL_STYLE_SEPARATOR:
|
||||||
|
@@ -93,6 +93,11 @@ public:
|
|||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// is this a radio button?
|
||||||
|
//
|
||||||
|
// unlike GetKind(), can be called for any kind of tools, not just buttons
|
||||||
|
bool IsRadio() const { return IsButton() && GetKind() == wxITEM_RADIO; }
|
||||||
|
|
||||||
// this is only called for the normal buttons, i.e. not separators nor
|
// this is only called for the normal buttons, i.e. not separators nor
|
||||||
// controls
|
// controls
|
||||||
GtkToolbarChildType GetGtkChildType() const
|
GtkToolbarChildType GetGtkChildType() const
|
||||||
@@ -162,6 +167,12 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
|
|
||||||
gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
|
gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( tool->IsRadio() && !tool->IsToggled() )
|
||||||
|
{
|
||||||
|
// radio button went up, don't report this as a wxWin event
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tbar->OnLeftClick( tool->GetId(), tool->IsToggled() );
|
tbar->OnLeftClick( tool->GetId(), tool->IsToggled() );
|
||||||
@@ -397,13 +408,47 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
|
|||||||
switch ( tool->GetStyle() )
|
switch ( tool->GetStyle() )
|
||||||
{
|
{
|
||||||
case wxTOOL_STYLE_BUTTON:
|
case wxTOOL_STYLE_BUTTON:
|
||||||
|
// for a radio button we need the widget which starts the radio
|
||||||
|
// group it belongs to, i.e. the first radio button immediately
|
||||||
|
// preceding this one
|
||||||
|
{
|
||||||
|
GtkWidget *widget = NULL;
|
||||||
|
|
||||||
|
if ( tool->IsRadio() )
|
||||||
|
{
|
||||||
|
wxToolBarToolsList::Node *node = pos ? m_tools.Item(pos - 1)
|
||||||
|
: NULL;
|
||||||
|
while ( node )
|
||||||
|
{
|
||||||
|
wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
|
||||||
|
if ( !tool->IsRadio() )
|
||||||
|
break;
|
||||||
|
|
||||||
|
widget = tool->m_item;
|
||||||
|
|
||||||
|
node = node->GetPrevious();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !widget )
|
||||||
|
{
|
||||||
|
// this is the first button in the radio button group,
|
||||||
|
// it will be toggled automatically by GTK so bring the
|
||||||
|
// internal flag in sync
|
||||||
|
tool->Toggle(TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tool->m_item = gtk_toolbar_insert_element
|
tool->m_item = gtk_toolbar_insert_element
|
||||||
(
|
(
|
||||||
m_toolbar,
|
m_toolbar,
|
||||||
tool->GetGtkChildType(),
|
tool->GetGtkChildType(),
|
||||||
(GtkWidget *)NULL,
|
widget,
|
||||||
tool->GetLabel().mbc_str(),
|
tool->GetLabel().empty()
|
||||||
tool->GetShortHelp().mbc_str(),
|
? NULL
|
||||||
|
: tool->GetLabel().mbc_str(),
|
||||||
|
tool->GetShortHelp().empty()
|
||||||
|
? NULL
|
||||||
|
: tool->GetShortHelp().mbc_str(),
|
||||||
"", // tooltip_private_text (?)
|
"", // tooltip_private_text (?)
|
||||||
tool->m_pixmap,
|
tool->m_pixmap,
|
||||||
(GtkSignalFunc)gtk_toolbar_callback,
|
(GtkSignalFunc)gtk_toolbar_callback,
|
||||||
@@ -426,6 +471,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
|
|||||||
"leave_notify_event",
|
"leave_notify_event",
|
||||||
GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
|
GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
|
||||||
(gpointer)tool );
|
(gpointer)tool );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxTOOL_STYLE_SEPARATOR:
|
case wxTOOL_STYLE_SEPARATOR:
|
||||||
|
Reference in New Issue
Block a user