| [25392] | 1 | /* Copyright (C) 2021 Wildfire Games.
|
|---|
| [27965] | 2 | * This file is part of 0 A.D.
|
|---|
| [6830] | 3 | *
|
|---|
| [27965] | 4 | * 0 A.D. is free software: you can redistribute it and/or modify
|
|---|
| [6830] | 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 | *
|
|---|
| [27965] | 9 | * 0 A.D. is distributed in the hope that it will be useful,
|
|---|
| [6830] | 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
|
|---|
| [27965] | 15 | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| [6830] | 16 | */
|
|---|
| 17 |
|
|---|
| [16931] | 18 | #include "precompiled.h"
|
|---|
| [290] | 19 |
|
|---|
| 20 | #include "CRadioButton.h"
|
|---|
| 21 |
|
|---|
| [22741] | 22 | CRadioButton::CRadioButton(CGUI& pGUI)
|
|---|
| [23020] | 23 | : CCheckBox(pGUI)
|
|---|
| [22587] | 24 | {
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| [16931] | 27 | void CRadioButton::HandleMessage(SGUIMessage& Message)
|
|---|
| [290] | 28 | {
|
|---|
| 29 | IGUIButtonBehavior::HandleMessage(Message);
|
|---|
| 30 | switch (Message.type)
|
|---|
| 31 | {
|
|---|
| 32 | case GUIM_PRESSED:
|
|---|
| [22744] | 33 | for (IGUIObject* const& obj : GetParent()->GetChildren())
|
|---|
| [290] | 34 | {
|
|---|
| [16931] | 35 | // Notice, if you use other objects within the parent object that has got
|
|---|
| 36 | // the setting "checked", it too will change. Hence NO OTHER OBJECTS THAN
|
|---|
| 37 | // RADIO BUTTONS SHOULD BE WITHIN IT!
|
|---|
| [25392] | 38 | // TODO: this should be enforced in the engine, and then we could cast IGUIObject* to CRadioButton*.
|
|---|
| 39 | obj->SetSettingFromString("checked", L"false", true);
|
|---|
| [290] | 40 | }
|
|---|
| 41 |
|
|---|
| [25392] | 42 | m_Checked.Set(true, true);
|
|---|
| [16931] | 43 | break;
|
|---|
| 44 |
|
|---|
| [290] | 45 | default:
|
|---|
| 46 | break;
|
|---|
| 47 | }
|
|---|
| [473] | 48 | }
|
|---|