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: dialog_addkanjibyfreq.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 "dialog_addkanjibyfreq.h"
28 ID_buttonCancel
=wxID_CANCEL
,
33 BEGIN_EVENT_TABLE(DialogAddKanjiByFreq
, wxDialog
)
34 EVT_BUTTON(ID_buttonOK
, DialogAddKanjiByFreq::OnOK
)
35 EVT_BUTTON(ID_buttonCancel
, DialogAddKanjiByFreq::OnCancel
)
36 EVT_KEY_DOWN(DialogAddKanjiByFreq::OnKeyDown
)
37 EVT_SPINCTRL(ID_spinLow
, DialogAddKanjiByFreq::OnLowValChange
)
38 EVT_SPINCTRL(ID_spinHigh
, DialogAddKanjiByFreq::OnHighValChange
)
41 DialogAddKanjiByFreq::DialogAddKanjiByFreq(wxWindow
*parent
)
42 : wxDialog(parent
, wxID_ANY
, wxString(_T("Add Kanji By Grade"))) {
43 spinLowFreq
= new wxSpinCtrl(this, ID_spinLow
, wxEmptyString
,
44 wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 1, 2501, 1);
45 spinHighFreq
= new wxSpinCtrl(this, ID_spinHigh
, wxEmptyString
,
46 wxDefaultPosition
, wxDefaultSize
, wxSP_ARROW_KEYS
, 1, 2501, 2501);
48 btnOK
= new wxButton(this, ID_buttonOK
, _T("OK"));
49 btnCancel
= new wxButton(this, ID_buttonCancel
, _T("Cancel"));
50 wxBoxSizer
*mainSizer
= new wxBoxSizer(wxVERTICAL
);
51 mainSizer
->Add(spinLowFreq
, 0, wxALL
, 10);
52 mainSizer
->Add(spinHighFreq
, 0, wxLEFT
| wxRIGHT
| wxBOTTOM
, 10);
53 wxBoxSizer
*buttonSizer
= new wxBoxSizer(wxHORIZONTAL
);
54 buttonSizer
->Add(btnOK
, 0, wxRIGHT
, 10);
55 buttonSizer
->Add(btnCancel
, 0);
56 mainSizer
->Add(buttonSizer
, 0, wxLEFT
| wxRIGHT
| wxBOTTOM
, 10);
57 this->SetSizerAndFit(mainSizer
);
58 spinLowFreq
->SetFocus();
61 int DialogAddKanjiByFreq::GetLowFreq() {
62 return spinLowFreq
->GetValue();
65 int DialogAddKanjiByFreq::GetHighFreq() {
66 return spinHighFreq
->GetValue();
69 void DialogAddKanjiByFreq::OKProc() {
71 int h
= GetHighFreq();
73 wxMessageBox(_T("Your high frequency rank cannot be less than your low frequency rank."), _T("Bad frequency range"), wxOK
| wxICON_WARNING
, this);
75 EndModal(ID_buttonOK
);
78 void DialogAddKanjiByFreq::CancelProc() {
79 EndModal(ID_buttonCancel
);
82 void DialogAddKanjiByFreq::OnOK(wxCommandEvent
& ev
) {OKProc();}
83 void DialogAddKanjiByFreq::OnCancel(wxCommandEvent
& ev
) {CancelProc();}
85 void DialogAddKanjiByFreq::OnKeyDown(wxKeyEvent
& ev
) {
86 int i
= ev
.GetKeyCode();
99 void DialogAddKanjiByFreq::OnLowValChange(wxSpinEvent
& ev
) {
101 low
= spinLowFreq
->GetValue();
102 high
= spinHighFreq
->GetValue();
104 spinHighFreq
->SetValue(low
);
107 void DialogAddKanjiByFreq::OnHighValChange(wxSpinEvent
& ev
) {
109 low
= spinLowFreq
->GetValue();
110 high
= spinHighFreq
->GetValue();
112 spinLowFreq
->SetValue(high
);