1 /* 2 * This file is part of Dune Legacy. 3 * 4 * Dune Legacy is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * Dune Legacy is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with Dune Legacy. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include <GUI/RadioButtonManager.h> 19 #include <GUI/RadioButton.h> 20 registerRadioButton(RadioButton * pRadioButton)21void RadioButtonManager::registerRadioButton(RadioButton* pRadioButton) { 22 if(isRegistered(pRadioButton) == false) { 23 radioButtonList.push_back(pRadioButton); 24 } 25 pRadioButton->registerRadioButtonManager(this); 26 } 27 unregisterRadioButton(RadioButton * pRadioButton)28void RadioButtonManager::unregisterRadioButton(RadioButton* pRadioButton) { 29 std::vector<RadioButton*>::iterator iter = radioButtonList.begin(); 30 while(iter != radioButtonList.end()) { 31 if(*iter == pRadioButton) { 32 radioButtonList.erase(iter); 33 break; 34 } 35 ++iter; 36 } 37 38 pRadioButton->unregisterFromRadioButtonManager(); 39 } 40 setChecked(RadioButton * pRadioButton) const41void RadioButtonManager::setChecked(RadioButton* pRadioButton) const { 42 for(RadioButton* pTmpRadioButton : radioButtonList) { 43 if(pTmpRadioButton == pRadioButton) { 44 pTmpRadioButton->Button::setToggleState(true); 45 } else { 46 pTmpRadioButton->Button::setToggleState(false); 47 } 48 } 49 } 50