4 Website: http://www.vultaire.net/software/jben/
5 License: GNU General Public License (GPL) version 2
6 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt)
8 File: coveredtextbox.cpp
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>
24 #include "coveredtextbox.h"
26 BEGIN_EVENT_TABLE(CoveredTextBox
, wxTextCtrl
)
28 EVT_KEY_UP(CoveredTextBox::OnKeyUp
)
29 EVT_LEFT_UP(CoveredTextBox::OnMouseLeftUp
)
32 CoveredTextBox::CoveredTextBox(wxWindow
*parent
, int id
, const wxString
& coverString
, const wxString
& hiddenString
, bool isCovered
)
33 : wxTextCtrl(parent
, id
, _T(""), wxDefaultPosition
, wxDefaultSize
, wxTE_READONLY
) {
34 normalbg
= this->GetBackgroundColour();
35 hidden
= hiddenString
;
40 void CoveredTextBox::UpdateValue() {
42 this->SetValue(cover
);
44 this->SetValue(hidden
);
46 this->SetSelection(0,0);
49 void CoveredTextBox::Uncover() {
51 this->SetBackgroundColour(normalbg
);
55 void CoveredTextBox::Cover() {
57 this->SetBackgroundColour(*wxLIGHT_GREY
);
61 void CoveredTextBox::Cover(bool state
) {
66 void CoveredTextBox::OnKeyUp(wxKeyEvent
& event
) {
67 if(covered
&& event
.GetKeyCode()==WXK_SPACE
) Uncover();
69 void CoveredTextBox::OnMouseLeftUp(wxMouseEvent
& event
) {
70 if(covered
) Uncover();
74 void CoveredTextBox::SetHiddenStr(const wxString
& s
) {hidden
=s
;}
75 void CoveredTextBox::SetCoverStr(const wxString
& s
) {cover
=s
;}