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: panel_kanjilisteditor.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 "panel_kanjilisteditor.h"
33 BEGIN_EVENT_TABLE(PanelKanjiListEditor
, wxPanel
)
34 EVT_BUTTON(ID_btnRevert
, PanelKanjiListEditor::OnRevert
)
35 EVT_BUTTON(ID_btnCommit
, PanelKanjiListEditor::OnCommit
)
36 EVT_TEXT(ID_textKanjiList
, PanelKanjiListEditor::OnTextChanged
)
39 PanelKanjiListEditor::PanelKanjiListEditor(wxWindow
*owner
) : RedrawablePanel(owner
) {
40 textKanjiList
= new wxTextCtrl(this, ID_textKanjiList
, wxEmptyString
,
41 wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
);
42 wxButton
*btnRevert
= new wxButton(this, ID_btnRevert
, _T("Revert"));
43 wxButton
*btnCommit
= new wxButton(this, ID_btnCommit
, _T("Commit"));
45 wxBoxSizer
*panelSizer
= new wxBoxSizer(wxVERTICAL
);
46 wxBoxSizer
*buttonSizer
= new wxBoxSizer(wxHORIZONTAL
);
48 buttonSizer
->AddStretchSpacer(1);
49 buttonSizer
->Add(btnRevert
);
50 buttonSizer
->AddStretchSpacer(1);
51 /*buttonSizer->AddStretchSpacer(1);*/
52 buttonSizer
->Add(btnCommit
);
53 buttonSizer
->AddStretchSpacer(1);
54 panelSizer
->Add(textKanjiList
, 1, wxEXPAND
| wxALL
, 10);
55 panelSizer
->Add(buttonSizer
, 0, wxEXPAND
| wxALIGN_CENTER
| wxLEFT
| wxRIGHT
| wxBOTTOM
, 10);
57 changeDetected
= false;
58 this->SetSizerAndFit(panelSizer
);
61 void PanelKanjiListEditor::Commit() {
62 changeDetected
= false;
63 jben
->kanjiList
->Clear();
64 int result
= jben
->kanjiList
->AddFromString(
65 textKanjiList
->GetValue().c_str());
69 Redraw(); /* Might be redundant now with the above Redraw() call... */
70 wxMessageBox(wxString::Format(_T("Changes Saved.\nTotal kanji in list: %d"), result
),
71 _T("Kanji List Editor"), wxOK
| wxICON_INFORMATION
, this);
74 void PanelKanjiListEditor::Revert() {
75 changeDetected
= false;
79 void PanelKanjiListEditor::OnRevert(wxCommandEvent
& ev
) {Revert();}
80 void PanelKanjiListEditor::OnCommit(wxCommandEvent
& ev
) {Commit();}
82 void PanelKanjiListEditor::OnTextChanged(wxCommandEvent
& ev
) {
83 changeDetected
= true;
86 bool PanelKanjiListEditor::ChangeDetected() {return changeDetected
;}
88 void PanelKanjiListEditor::Redraw() {
89 textKanjiList
->ChangeValue(jben
->kanjiList
->ToString(20));