Line data Source code
1 : /* Copyright (C) 2021 Wildfire Games. 2 : * This file is part of 0 A.D. 3 : * 4 : * 0 A.D. 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 : * 0 A.D. 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 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 : */ 17 : 18 : #include "precompiled.h" 19 : 20 : #include "CRadioButton.h" 21 : 22 : #include "gui/CGUISetting.h" 23 : #include "gui/ObjectBases/IGUIButtonBehavior.h" 24 : #include "gui/SGUIMessage.h" 25 : #include "ps/CStr.h" 26 : 27 : #include <vector> 28 : 29 : class CGUI; 30 : 31 0 : CRadioButton::CRadioButton(CGUI& pGUI) 32 0 : : CCheckBox(pGUI) 33 : { 34 0 : } 35 : 36 0 : void CRadioButton::HandleMessage(SGUIMessage& Message) 37 : { 38 0 : IGUIButtonBehavior::HandleMessage(Message); 39 0 : switch (Message.type) 40 : { 41 0 : case GUIM_PRESSED: 42 0 : for (IGUIObject* const& obj : GetParent()->GetChildren()) 43 : { 44 : // Notice, if you use other objects within the parent object that has got 45 : // the setting "checked", it too will change. Hence NO OTHER OBJECTS THAN 46 : // RADIO BUTTONS SHOULD BE WITHIN IT! 47 : // TODO: this should be enforced in the engine, and then we could cast IGUIObject* to CRadioButton*. 48 0 : obj->SetSettingFromString("checked", L"false", true); 49 : } 50 : 51 0 : m_Checked.Set(true, true); 52 : break; 53 : 54 : default: 55 : break; 56 : } 57 0 : }