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"
26 #include <glibmm/i18n.h>
27 #include <gtkmm/stock.h>
28 #include <gtkmm/messagedialog.h>
30 DialogAddKanjiByFreq::DialogAddKanjiByFreq(Gtk::Window
& parent
)
31 : StoredDialog(_("Add Kanji By Freq"), parent
, "gui.dlg.addkanjibyfreq.size"),
32 btnOK(Gtk::Stock::OK
),
33 btnCancel(Gtk::Stock::CANCEL
)
35 spinLowFreq
.set_numeric();
36 spinHighFreq
.set_numeric();
37 spinLowFreq
.set_digits(0);
38 spinHighFreq
.set_digits(0);
39 spinLowFreq
.set_range(1,2501);
40 spinHighFreq
.set_range(1,2501);
41 spinLowFreq
.set_value(1);
42 spinHighFreq
.set_value(2501);
43 spinLowFreq
.set_width_chars(4);
44 spinHighFreq
.set_width_chars(4);
45 spinLowFreq
.set_increments(1,10);
46 spinHighFreq
.set_increments(1,10);
48 spinLowFreq
.signal_value_changed()
49 .connect(sigc::mem_fun(*this, &DialogAddKanjiByFreq::OnLowValChange
));
50 spinHighFreq
.signal_value_changed()
51 .connect(sigc::mem_fun(*this, &DialogAddKanjiByFreq::OnHighValChange
));
52 btnOK
.signal_clicked()
53 .connect(sigc::mem_fun(*this, &DialogAddKanjiByFreq::OnOK
));
54 btnCancel
.signal_clicked()
55 .connect(sigc::mem_fun(*this, &DialogAddKanjiByFreq::OnCancel
));
59 Gtk::VBox
* pvb
= get_vbox();
61 pvb
->pack_start(spinLowFreq
);
62 pvb
->pack_start(spinHighFreq
);
64 Gtk::ButtonBox
* phbb
= get_action_area();
65 phbb
->pack_start(btnCancel
);
66 phbb
->pack_start(btnOK
);
71 int DialogAddKanjiByFreq::GetLowFreq() {
72 return (int)(spinLowFreq
.get_value());
75 int DialogAddKanjiByFreq::GetHighFreq() {
76 return (int)(spinHighFreq
.get_value());
79 void DialogAddKanjiByFreq::OnOK() {
83 void DialogAddKanjiByFreq::OnCancel() {
87 void DialogAddKanjiByFreq::OnLowValChange() {
89 low
= spinLowFreq
.get_value();
90 high
= spinHighFreq
.get_value();
92 spinHighFreq
.set_value(low
);
95 void DialogAddKanjiByFreq::OnHighValChange() {
97 low
= spinLowFreq
.get_value();
98 high
= spinHighFreq
.get_value();
100 spinLowFreq
.set_value(high
);
103 void DialogAddKanjiByFreq::OKProc() {
104 int l
= GetLowFreq();
105 int h
= GetHighFreq();
107 Gtk::MessageDialog md
108 (*this, _("Your high frequency rank cannot be less "
109 "than your low frequency rank."));
110 md
.set_title(_("Bad frequency range"));
113 response(Gtk::RESPONSE_OK
);
116 void DialogAddKanjiByFreq::CancelProc() {
117 response(Gtk::RESPONSE_CANCEL
);