diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-04-30 10:19:19 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-09-28 08:48:18 +0100 |
commit | 8f256819b14044afce7e8cf44fbecbe1cb8cb4cf (patch) | |
tree | ad2e593ff37101618789bf9eca4b08e1b4e1d253 /vcl/source/control/button.cxx | |
parent | d3f29153feb273e2e14375045323356bd550abb7 (diff) |
implement RadioButton groups
Diffstat (limited to 'vcl/source/control/button.cxx')
-rw-r--r-- | vcl/source/control/button.cxx | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index ea1900142e0a..93b4065a3e5e 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -2291,13 +2291,51 @@ void RadioButton::ImplDrawRadioButton( bool bLayout ) } } -// ----------------------------------------------------------------------- +void RadioButton::group(RadioButton &rOther) +{ + if (!m_xGroup) + { + m_xGroup.reset(new std::set<RadioButton*>); + m_xGroup->insert(this); + } + + if (rOther.m_xGroup) + { + for (std::set<RadioButton*>::iterator aI = rOther.m_xGroup->begin(), aEnd = rOther.m_xGroup->end(); aI != aEnd; ++aI) + m_xGroup->insert(*aI); + } + + m_xGroup->insert(&rOther); + + rOther.m_xGroup = m_xGroup; + + //if this one is checked, uncheck all the others + if (mbChecked) + ImplUncheckAllOther(); +} + +// .----------------------------------------------------------------------- void RadioButton::GetRadioButtonGroup( std::vector< RadioButton* >& io_rGroup, bool bIncludeThis ) const { // empty the list io_rGroup.clear(); + if (m_xGroup) + { + for (std::set<RadioButton*>::iterator aI = m_xGroup->begin(), aEnd = m_xGroup->end(); aI != aEnd; ++aI) + { + RadioButton *pRadioButton = *aI; + if (pRadioButton == this) + continue; + io_rGroup.push_back(pRadioButton); + } + return; + } + + //old-school + SAL_WARN("vcl", "No group set on radiobutton"); + // go back to first in group; Window* pFirst = const_cast<RadioButton*>(this); while( ( pFirst->GetStyle() & WB_GROUP ) == 0 ) @@ -2416,6 +2454,8 @@ void RadioButton::ImplLoadRes( const ResId& rResId ) RadioButton::~RadioButton() { + if (m_xGroup) + m_xGroup->erase(this); } // ----------------------------------------------------------------------- |