From 24f3b5230cc1ea7e6fb084294f04df10ede17e2f Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 13 Sep 2015 23:49:08 +0200 Subject: Linux/MacOSX: Mask/unmask PIM value in GUI the same way as the password --- src/Main/Forms/VolumePimWizardPage.cpp | 46 +++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) (limited to 'src/Main/Forms/VolumePimWizardPage.cpp') diff --git a/src/Main/Forms/VolumePimWizardPage.cpp b/src/Main/Forms/VolumePimWizardPage.cpp index 36dc4c7f..8f98cb54 100644 --- a/src/Main/Forms/VolumePimWizardPage.cpp +++ b/src/Main/Forms/VolumePimWizardPage.cpp @@ -23,10 +23,7 @@ namespace VeraCrypt VolumePimWizardPage::VolumePimWizardPage (wxPanel* parent) : VolumePimWizardPageBase (parent) { - wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); // wxFILTER_NUMERIC does not exclude - . , etc. - const wxChar *valArr[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" }; - validator.SetIncludes (wxArrayString (array_capacity (valArr), (const wxChar **) &valArr)); - VolumePimTextCtrl->SetValidator (validator); + SetPimValidator (); } VolumePimWizardPage::~VolumePimWizardPage () @@ -85,6 +82,43 @@ namespace VeraCrypt { VolumePimHelpStaticText->SetForegroundColour(*wxBLACK); VolumePimHelpStaticText->SetLabel(LangString["IDC_PIM_HELP"]); - } + } + Fit(); + Layout(); + } + + void VolumePimWizardPage::SetPimValidator () + { + wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); // wxFILTER_NUMERIC does not exclude - . , etc. + const wxChar *valArr[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" }; + validator.SetIncludes (wxArrayString (array_capacity (valArr), (const wxChar **) &valArr)); + VolumePimTextCtrl->SetValidator (validator); + } + + void VolumePimWizardPage::OnDisplayPimCheckBoxClick( wxCommandEvent& event ) + { + FreezeScope freeze (this); + + bool display = event.IsChecked (); + + wxTextCtrl *newTextCtrl = new wxTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, display ? 0 : wxTE_PASSWORD); + newTextCtrl->SetMaxLength (10); + newTextCtrl->SetValue (VolumePimTextCtrl->GetValue()); + newTextCtrl->SetMinSize (VolumePimTextCtrl->GetSize()); + + PimSizer->Replace (VolumePimTextCtrl, newTextCtrl); + VolumePimTextCtrl->Show (false); + VolumePimTextCtrl->SetValue (wxString (L'X', VolumePimTextCtrl->GetLineLength(0))); + GetVolumePim (); + + Fit(); + Layout(); + newTextCtrl->SetMinSize (VolumePimTextCtrl->GetMinSize()); + + newTextCtrl->Connect (wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (VolumePimWizardPage::OnPimChanged), nullptr, this); + delete VolumePimTextCtrl; + VolumePimTextCtrl = newTextCtrl; + SetPimValidator (); + OnPimChanged (GetVolumePim ()); } -} +} \ No newline at end of file -- cgit v1.2.3