|
|
1.1 ! root 1: /* ! 2: Copyright (c) 2008 TrueCrypt Foundation. All rights reserved. ! 3: ! 4: Governed by the TrueCrypt License 2.4 the full text of which is contained ! 5: in the file License.txt included in TrueCrypt binary and source code ! 6: distribution packages. ! 7: */ ! 8: ! 9: #include "System.h" ! 10: #include "Main/GraphicUserInterface.h" ! 11: #include "SingleChoiceWizardPage.h" ! 12: ! 13: namespace TrueCrypt ! 14: { ! 15: SingleChoiceWizardPage::SingleChoiceWizardPage (wxPanel* parent, const wxString &groupBoxText) ! 16: : SingleChoiceWizardPageBase (parent) ! 17: { ! 18: if (!groupBoxText.empty()) ! 19: { ! 20: OuterChoicesSizer->Remove (ChoicesSizer); ! 21: ChoicesSizer = new wxStaticBoxSizer (wxVERTICAL, this, groupBoxText); ! 22: OuterChoicesSizer->Add (ChoicesSizer, 0, wxEXPAND, 5); ! 23: } ! 24: } ! 25: ! 26: void SingleChoiceWizardPage::AddChoice (int id, const wxString &text) ! 27: { ! 28: assert (RadioButtonMap.find (id) == RadioButtonMap.end()); ! 29: wxRadioButton *radioButton = new wxRadioButton (this, wxID_ANY, text); ! 30: if (RadioButtonMap.empty()) ! 31: radioButton->SetValue (1); ! 32: ! 33: RadioButtonMap[id] = radioButton; ! 34: ChoicesSizer->Add (radioButton, 0, wxALL, 5); ! 35: } ! 36: ! 37: int SingleChoiceWizardPage::GetSelection () const ! 38: { ! 39: typedef pair <int, wxRadioButton*> MapPair; ! 40: foreach (MapPair p, RadioButtonMap) ! 41: { ! 42: if (p.second->GetValue()) ! 43: return p.first; ! 44: } ! 45: ! 46: return -1; ! 47: } ! 48: ! 49: void SingleChoiceWizardPage::SetSelection (int id) ! 50: { ! 51: typedef pair <int, wxRadioButton*> MapPair; ! 52: foreach (MapPair p, RadioButtonMap) ! 53: { ! 54: if (p.first == id) ! 55: { ! 56: p.second->SetValue (true); ! 57: return; ! 58: } ! 59: } ! 60: throw ParameterIncorrect (SRC_POS); ! 61: } ! 62: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.