fixes to radio button handling (patch 803360)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23941 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -69,6 +69,7 @@ All (GUI):
|
|||||||
- added some support for C++ exceptions in the library (do read the manual!)
|
- added some support for C++ exceptions in the library (do read the manual!)
|
||||||
- added wxListCtrl::GetViewRect()
|
- added wxListCtrl::GetViewRect()
|
||||||
- added wxTextCtrl::MarkDirty()
|
- added wxTextCtrl::MarkDirty()
|
||||||
|
- wxToolBar::ToggleTool() now works for radio buttons (Dag <20>gren)
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
|
@@ -575,6 +575,9 @@ protected:
|
|||||||
// find the tool by id
|
// find the tool by id
|
||||||
wxToolBarToolBase *FindById(int toolid) const;
|
wxToolBarToolBase *FindById(int toolid) const;
|
||||||
|
|
||||||
|
// un-toggle all buttons in the same radio group
|
||||||
|
void UnToggleRadioGroup(wxToolBarToolBase *tool);
|
||||||
|
|
||||||
// the list of all our tools
|
// the list of all our tools
|
||||||
wxToolBarToolsList m_tools;
|
wxToolBarToolsList m_tools;
|
||||||
|
|
||||||
|
@@ -184,7 +184,22 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tbar->OnLeftClick( tool->GetId(), tool->IsToggled() );
|
if( !tbar->OnLeftClick( tool->GetId(), tool->IsToggled() ) && tool->CanBeToggled() )
|
||||||
|
{
|
||||||
|
// revert back
|
||||||
|
tool->Toggle();
|
||||||
|
|
||||||
|
wxBitmap bitmap = tool->GetBitmap();
|
||||||
|
if ( bitmap.Ok() )
|
||||||
|
{
|
||||||
|
GtkPixmap *pixmap = GTK_PIXMAP( tool->m_pixmap );
|
||||||
|
|
||||||
|
GdkBitmap *mask = bitmap.GetMask() ? bitmap.GetMask()->GetBitmap()
|
||||||
|
: (GdkBitmap *)NULL;
|
||||||
|
|
||||||
|
gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -184,7 +184,22 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tbar->OnLeftClick( tool->GetId(), tool->IsToggled() );
|
if( !tbar->OnLeftClick( tool->GetId(), tool->IsToggled() ) && tool->CanBeToggled() )
|
||||||
|
{
|
||||||
|
// revert back
|
||||||
|
tool->Toggle();
|
||||||
|
|
||||||
|
wxBitmap bitmap = tool->GetBitmap();
|
||||||
|
if ( bitmap.Ok() )
|
||||||
|
{
|
||||||
|
GtkPixmap *pixmap = GTK_PIXMAP( tool->m_pixmap );
|
||||||
|
|
||||||
|
GdkBitmap *mask = bitmap.GetMask() ? bitmap.GetMask()->GetBitmap()
|
||||||
|
: (GdkBitmap *)NULL;
|
||||||
|
|
||||||
|
gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -915,29 +915,31 @@ bool wxToolBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id)
|
|||||||
if ( !tool )
|
if ( !tool )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
bool toggled;
|
||||||
|
|
||||||
if ( tool->CanBeToggled() )
|
if ( tool->CanBeToggled() )
|
||||||
{
|
{
|
||||||
LRESULT state = ::SendMessage(GetHwnd(), TB_GETSTATE, id, 0);
|
LRESULT state = ::SendMessage(GetHwnd(), TB_GETSTATE, id, 0);
|
||||||
tool->Toggle((state & TBSTATE_CHECKED) != 0);
|
toggled = (state & TBSTATE_CHECKED) != 0;
|
||||||
|
|
||||||
|
// ignore the event when a radio button is released, as this doesn't seem to
|
||||||
|
// happen at all, and is handled otherwise
|
||||||
|
if ( tool->GetKind() == wxITEM_RADIO && !toggled )
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
tool->Toggle(toggled);
|
||||||
|
UnToggleRadioGroup(tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool toggled = tool->IsToggled();
|
|
||||||
|
|
||||||
// avoid sending the event when a radio button is released, this is not
|
|
||||||
// interesting
|
|
||||||
if ( !tool->CanBeToggled() || tool->GetKind() != wxITEM_RADIO || toggled )
|
|
||||||
{
|
|
||||||
// OnLeftClick() can veto the button state change - for buttons which
|
// OnLeftClick() can veto the button state change - for buttons which
|
||||||
// may be toggled only, of couse
|
// may be toggled only, of couse
|
||||||
if ( !OnLeftClick((int)id, toggled) && tool->CanBeToggled() )
|
if ( !OnLeftClick((int)id, toggled) && tool->CanBeToggled() )
|
||||||
{
|
{
|
||||||
// revert back
|
// revert back
|
||||||
toggled = !toggled;
|
tool->Toggle(!toggled);
|
||||||
tool->SetToggle(toggled);
|
|
||||||
|
|
||||||
::SendMessage(GetHwnd(), TB_CHECKBUTTON, id, MAKELONG(toggled, 0));
|
::SendMessage(GetHwnd(), TB_CHECKBUTTON, id, MAKELONG(toggled, 0));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user