Canola  0.8.D001
canola/calculator/gnome.cc
Go to the documentation of this file.
00001 //
00002 // canola - canon canola 1614p emulator
00003 // Copyright (C) 2011, 2012 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, version 3, as
00007 // published by the Free Software Foundation.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License along
00015 // with this program. If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #include <lib/config.h>
00019 #include <gtkmm.h>
00020 #include <gdkmm/window.h>
00021 #include <libexplain/output.h>
00022 
00023 #include <lib/sizeof.h>
00024 #include <lib/unicode.h>
00025 #include <lib/std_string_printf.h>
00026 
00027 #include <canola/calculator/gnome.h>
00028 #include <canola/debugger/gnome.h>
00029 #include <canola/dialog/preferences.h>
00030 #include <canola/dialog/prog_mode.h>
00031 #include <canola/dialog/special_key_symbol.h>
00032 #include <canola/load_image.h>
00033 #include <canola/message_dialog/error.h>
00034 #include <canola/window/card_reader.h>
00035 
00036 
00037 calculator_gnome::~calculator_gnome()
00038 {
00039     delete error_window;
00040 }
00041 
00042 
00043 static Gdk::RGBA black("#000000");
00044 static Gdk::RGBA white("#FFFFFF");
00045 static Gdk::RGBA red("#FF0000");
00046 
00047 
00048 calculator_gnome::calculator_gnome() :
00049     button_uj("UJ", "blue", white),
00050     button_mj("MJ", "blue", white),
00051     button_ej("EJ", "blue", white),
00052     button_sj("SJ", "blue", white),
00053     button_fj("FJ", "blue", white),
00054     button_rv("RV", "black", white),
00055     button_cm1("CM\n1", "cream", black),
00056     button_c("C", "cream", black),
00057     button_chg_sign("CHG\nSIGN", "black", red),
00058     button_right(UNICODE_RIGHT, "black", white),
00059     button_cm2("CM\n2", "cream", black),
00060     button_clear_indicator("CI", "cream", black),
00061     button_n7("7", "white", black),
00062     button_n4("4", "white", black),
00063     button_n1("1", "white", black),
00064     button_n0("0", "wide-white", black),
00065     button_n8("8", "white", black),
00066     button_n5("5", "white", black),
00067     button_n2("2", "white", black),
00068     button_n9("9", "white", black),
00069     button_n6("6", "white", black),
00070     button_n3("3", "white", black),
00071     button_dot(".", "white", black),
00072     button_mul(UNICODE_MUL, "white", black),
00073     button_ent("ENT", "blue", white),
00074     button_start("S\nT\nA\nR\nT", "tall-blue", white),
00075     button_k("K", "black", white, true),
00076     button_div(UNICODE_DIV, "white", black),
00077     button_sqrt(UNICODE_SQRT, "white", black),
00078     button_minus_equals("-\n=", "white", red),
00079     button_plus_equals("+\n=", "white", black),
00080     button_am1("AM\n1", "black", white, true),
00081     button_m3("M\n3~", "black", white),
00082     button_m2("M\n2", "black", white),
00083     button_m1("M\n1", "black", white),
00084     button_sm3("SM\n3~", "black", white),
00085     button_mm2("M\n2", "black", red),
00086     button_mm1("M\n1", "black", red),
00087     button_cm3("CM\n3~", "cream", black),
00088     button_rm3("RM\n3~", "black", white),
00089     button_rm2("RM\n2", "black", white),
00090     button_rm1("RM\n1", "black", white),
00091     keyboard(4, 16, true),
00092     printer_label("Printer"),
00093     printer_power("Power"),
00094     printer_manual_calculation("Man\nCalc"), // ("Manual\nCalculation"),
00095     printer_display_print("Disp\nPrint"), // ("Display\nPrint"),
00096     printer_program_print("Prog\nPrint"), // ("Program\nPrint"),
00097     printer_paper_feed("Paper\nFeed"),
00098     debugger_label("Debugger"),
00099     error_window(0),
00100     animate_card_reader(true)
00101 {
00102     set_icon(load_gui_image("canola"));
00103 
00104     // Build the menu bar across the top of the window.
00105     {
00106         menu_ui = Gtk::UIManager::create();
00107 
00108         Glib::RefPtr<Gtk::ActionGroup> file_menu =
00109             Gtk::ActionGroup::create();
00110         file_menu->add(Gtk::Action::create("MenuFile", "_File"));
00111         file_menu->add
00112         (
00113             Gtk::Action::create("LoadProg", "Load Program..."),
00114             sigc::mem_fun(*this, &calculator_gnome::on_load_program)
00115         );
00116 
00117         file_menu->add(Gtk::Action::create("SaveProg", "_Save Program..."),
00118             sigc::mem_fun(*this, &calculator_gnome::on_save_program));
00119         file_menu->add
00120         (
00121             Gtk::Action::create("SaveMemProg", "_Save Memories as Program..."),
00122             sigc::mem_fun(*this, &calculator_gnome::on_save_memories_as_program)
00123         );
00124         file_menu->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
00125             sigc::mem_fun(*this, &calculator_gnome::on_quit));
00126         menu_ui->insert_action_group(file_menu);
00127 
00128         Glib::RefPtr<Gtk::ActionGroup> edit_menu =
00129             Gtk::ActionGroup::create();
00130         edit_menu->add(Gtk::Action::create("MenuEdit", "_Edit"));
00131         edit_menu->add
00132         (
00133             Gtk::Action::create("SpecialKeySym", "Special Key Symbol..."),
00134             sigc::mem_fun(*this, &calculator_gnome::on_special_key_symbol)
00135         );
00136         edit_menu->add
00137         (
00138             Gtk::Action::create("EditPrefs", "Preferences..."),
00139             sigc::mem_fun(*this, &calculator_gnome::on_edit_preferences)
00140         );
00141         menu_ui->insert_action_group(edit_menu);
00142 
00143         // tell the parent window to respond to
00144         // the specified keyboard shortcuts
00145         add_accel_group(menu_ui->get_accel_group());
00146 
00147         menu_ui->add_ui_from_string
00148         (
00149             "<ui>"
00150             "  <menubar name='MenuBar'>"
00151             "    <menu action='MenuFile'>"
00152             "      <menuitem action='LoadProg'/>"
00153             "      <menuitem action='SaveProg'/>"
00154             "      <menuitem action='SaveMemProg'/>"
00155             "      <menuitem action='Quit'/>"
00156             "    </menu>"
00157             "    <menu action='MenuEdit'>"
00158 #if 0
00159             "      <menuitem action='Cut'/>"
00160             "      <menuitem action='Copy'/>"
00161             "      <menuitem action='Paste'/>"
00162 #endif
00163             "      <menuitem action='SpecialKeySym'/>"
00164             "      <menuitem action='EditPrefs'/>"
00165             "    </menu>"
00166             "  </menubar>"
00167             "</ui>"
00168         );
00169 
00170         menu_bar = menu_ui->get_widget("/MenuBar");
00171     }
00172 
00173     const int layout_spacing = 20;
00174 
00175     Gdk::RGBA blue_normal("#27a1a6");
00176     Gdk::RGBA blue_active("#3bf7ff");
00177     Gdk::RGBA white("#ffffff");
00178     Gdk::RGBA black("#000000");
00179     Gdk::RGBA cream_normal("#ddcd92");
00180     //Gdk::RGBA cream_active("#ffeca8");
00181     Gdk::RGBA cream_active("#fff800");
00182     Gdk::RGBA red("#ff0000");
00183     Gdk::RGBA gray_normal("#404040");
00184     Gdk::RGBA gray_active("#202020");
00185 
00186     // ---------- the first set are the keyboard ---------------------------
00187 
00188     // first column
00189     button_uj.signal_clicked().connect(sigc::mem_fun(*this,
00190         &calculator_gnome::on_uj));
00191     keyboard.attach(button_uj, 0, 1, 0, 1);
00192 
00193     button_mj.signal_clicked().connect(sigc::mem_fun(*this,
00194         &calculator_gnome::on_mj));
00195     keyboard.attach(button_mj, 0, 1, 1, 2);
00196 
00197     button_ej.signal_clicked().connect(sigc::mem_fun(*this,
00198         &calculator_gnome::on_ej));
00199     keyboard.attach(button_ej, 0, 1, 2, 3);
00200 
00201     button_sj.signal_clicked().connect(sigc::mem_fun(*this,
00202         &calculator_gnome::on_sj));
00203     keyboard.attach(button_sj, 0, 1, 3, 4);
00204 
00205     // second column
00206     button_fj.signal_clicked().connect(sigc::mem_fun(*this,
00207         &calculator_gnome::on_fj));
00208     keyboard.attach(button_fj, 2, 3, 0, 1);
00209 
00210     button_rv.signal_clicked().connect(sigc::mem_fun(*this,
00211         &calculator_gnome::on_rv));
00212     keyboard.attach(button_rv, 2, 3, 1, 2);
00213 
00214     button_cm1.signal_clicked().connect(sigc::mem_fun(*this,
00215         &calculator_gnome::on_cm1));
00216     keyboard.attach(button_cm1, 2, 3, 2, 3);
00217 
00218     button_c.signal_clicked().connect(sigc::mem_fun(*this,
00219         &calculator_gnome::on_c));
00220     keyboard.attach(button_c, 2, 3, 3, 4);
00221 
00222     // column 3
00223     button_chg_sign.signal_clicked().connect(sigc::mem_fun(*this,
00224         &calculator_gnome::on_chg_sign));
00225     keyboard.attach(button_chg_sign, 3, 4, 0, 1);
00226 
00227     button_right.signal_clicked().connect(sigc::mem_fun(*this,
00228         &calculator_gnome::on_right));
00229     keyboard.attach(button_right, 3, 4, 1, 2);
00230 
00231     button_cm2.signal_clicked().connect(sigc::mem_fun(*this,
00232         &calculator_gnome::on_cm2));
00233     keyboard.attach(button_cm2, 3, 4, 2, 3);
00234 
00235     button_clear_indicator.signal_clicked().connect(sigc::mem_fun(*this,
00236         &calculator_gnome::on_clear_indicator));
00237     keyboard.attach(button_clear_indicator, 3, 4, 3, 4);
00238 
00239     // column 4
00240     button_n7.signal_clicked().connect(sigc::mem_fun(*this,
00241         &calculator_gnome::on_n7));
00242     keyboard.attach(button_n7, 5, 6, 0, 1);
00243 
00244     button_n4.signal_clicked().connect(sigc::mem_fun(*this,
00245         &calculator_gnome::on_n4));
00246     keyboard.attach(button_n4, 5, 6, 1, 2);
00247 
00248     button_n1.signal_clicked().connect(sigc::mem_fun(*this,
00249         &calculator_gnome::on_n1));
00250     keyboard.attach(button_n1, 5, 6, 2, 3);
00251 
00252     button_n0.signal_clicked().connect(sigc::mem_fun(*this,
00253         &calculator_gnome::on_n0));
00254     keyboard.attach(button_n0, 5, 7, 3, 4);
00255 
00256     // column 5
00257     button_n8.signal_clicked().connect(sigc::mem_fun(*this,
00258         &calculator_gnome::on_n8));
00259     keyboard.attach(button_n8, 6, 7, 0, 1);
00260 
00261     button_n5.signal_clicked().connect(sigc::mem_fun(*this,
00262         &calculator_gnome::on_n5));
00263     keyboard.attach(button_n5, 6, 7, 1, 2);
00264 
00265     button_n2.signal_clicked().connect(sigc::mem_fun(*this,
00266         &calculator_gnome::on_n2));
00267     keyboard.attach(button_n2, 6, 7, 2, 3);
00268 
00269     // column 6
00270     button_n9.signal_clicked().connect(sigc::mem_fun(*this,
00271         &calculator_gnome::on_n9));
00272     keyboard.attach(button_n9, 7, 8, 0, 1);
00273 
00274     button_n6.signal_clicked().connect(sigc::mem_fun(*this,
00275         &calculator_gnome::on_n6));
00276     keyboard.attach(button_n6, 7, 8, 1, 2);
00277 
00278     button_n3.signal_clicked().connect(sigc::mem_fun(*this,
00279         &calculator_gnome::on_n3));
00280     keyboard.attach(button_n3, 7, 8, 2, 3);
00281 
00282     button_dot.signal_clicked().connect(sigc::mem_fun(*this,
00283         &calculator_gnome::on_dot));
00284     keyboard.attach(button_dot, 7, 8, 3, 4);
00285 
00286     // column 7
00287     button_mul.signal_clicked().connect(sigc::mem_fun(*this,
00288         &calculator_gnome::on_mul));
00289     keyboard.attach(button_mul, 9, 10, 0, 1);
00290 
00291     button_ent.signal_clicked().connect(sigc::mem_fun(*this,
00292         &calculator_gnome::on_ent));
00293     keyboard.attach(button_ent, 9, 10, 1, 2);
00294 
00295     button_start.signal_clicked().connect(sigc::mem_fun(*this,
00296         &calculator_gnome::on_start));
00297     keyboard.attach(button_start, 9, 10, 2, 4);
00298 
00299     // column 8
00300     button_k.signal_clicked().connect(sigc::mem_fun(*this,
00301         &calculator_gnome::on_k_down));
00302     button_k.signal_released().connect(sigc::mem_fun(*this,
00303         &calculator_gnome::on_k_up));
00304     keyboard.attach(button_k, 10, 11, 0, 1);
00305 
00306     // column 9
00307     button_div.signal_clicked().connect(sigc::mem_fun(*this,
00308         &calculator_gnome::on_div));
00309     keyboard.attach(button_div, 11, 12, 0, 1);
00310 
00311     button_sqrt.signal_clicked().connect(sigc::mem_fun(*this,
00312         &calculator_gnome::on_sqrt));
00313     keyboard.attach(button_sqrt, 11, 12, 1, 2);
00314 
00315     button_minus_equals.signal_clicked().connect(sigc::mem_fun(*this,
00316         &calculator_gnome::on_minus_equals));
00317     keyboard.attach(button_minus_equals, 11, 12, 2, 3);
00318 
00319     button_plus_equals.signal_clicked().connect(sigc::mem_fun(*this,
00320         &calculator_gnome::on_plus_equals));
00321     keyboard.attach(button_plus_equals, 11, 12, 3, 4);
00322 
00323     // column 10
00324     button_am1.signal_clicked().connect(sigc::mem_fun(*this,
00325         &calculator_gnome::on_am1_down));
00326     button_am1.signal_released().connect(sigc::mem_fun(*this,
00327         &calculator_gnome::on_am1_up));
00328     keyboard.attach(button_am1, 13, 14, 0, 1);
00329 
00330     button_m3.signal_clicked().connect(sigc::mem_fun(*this,
00331         &calculator_gnome::on_m3_tilde));
00332     keyboard.attach(button_m3, 13, 14, 1, 2);
00333 
00334     button_m2.signal_clicked().connect(sigc::mem_fun(*this,
00335         &calculator_gnome::on_m2));
00336     keyboard.attach(button_m2, 13, 14, 2, 3);
00337 
00338     button_m1.signal_clicked().connect(sigc::mem_fun(*this,
00339         &calculator_gnome::on_m1));
00340     keyboard.attach(button_m1, 13, 14, 3, 4);
00341 
00342     // column 11
00343     button_sm3.signal_clicked().connect(sigc::mem_fun(*this,
00344         &calculator_gnome::on_sm3_tilde));
00345     keyboard.attach(button_sm3, 14, 15, 1, 2);
00346 
00347     button_mm2.signal_clicked().connect(sigc::mem_fun(*this,
00348         &calculator_gnome::on_mm2));
00349     keyboard.attach(button_mm2, 14, 15, 2, 3);
00350 
00351     button_mm1.signal_clicked().connect(sigc::mem_fun(*this,
00352         &calculator_gnome::on_mm1));
00353     keyboard.attach(button_mm1, 14, 15, 3, 4);
00354 
00355     // column 12
00356     button_cm3.signal_clicked().connect(sigc::mem_fun(*this,
00357         &calculator_gnome::on_cm3_tilde));
00358     keyboard.attach(button_cm3, 15, 16, 0, 1);
00359 
00360     button_rm3.signal_clicked().connect(sigc::mem_fun(*this,
00361         &calculator_gnome::on_rm3_tilde));
00362     keyboard.attach(button_rm3, 15, 16, 1, 2);
00363 
00364     button_rm2.signal_clicked().connect(sigc::mem_fun(*this,
00365         &calculator_gnome::on_rm2));
00366     keyboard.attach(button_rm2, 15, 16, 2, 3);
00367 
00368     button_rm1.signal_clicked().connect(sigc::mem_fun(*this,
00369         &calculator_gnome::on_rm1));
00370     keyboard.attach(button_rm1, 15, 16, 3, 4);
00371 
00372     signal_key_press_event().connect(sigc::mem_fun(*this,
00373         &calculator_gnome::do_key_press_event));
00374 
00375     // ---------- the next set are the controls ----------------------------
00376     //
00377     power_switch.set_value(1);
00378     control_group.pack_start(power_switch);
00379     power_switch.value_changed_signal().connect(sigc::mem_fun(*this,
00380         &calculator_gnome::on_quit));
00381 
00382     program_mode_switch.set_value((int)program_mode_get());
00383     program_mode_switch.value_changed_signal().connect(sigc::mem_fun(*this,
00384         &calculator_gnome::on_program_mode_switch_changed));
00385     control_group.pack_start(program_mode_switch);
00386 
00387     program_selector_switch.set_value((int)program_selector_get());
00388     program_selector_switch.value_changed_signal().connect(sigc::mem_fun(*this,
00389         &calculator_gnome::on_program_selector_switch_changed));
00390     control_group.pack_start(program_selector_switch);
00391 
00392     rounding_switch.set_value((int)precision_and_rounding_get().get_rounding());
00393     rounding_switch.value_changed_signal().connect(sigc::mem_fun(*this,
00394         &calculator_gnome::on_rounding_switch_changed));
00395     control_group.pack_start(rounding_switch);
00396 
00397     decimal_point_selector_dial_tree_model =
00398         Gtk::ListStore::create(decimal_point_selector_dial_columns);
00399     decimal_point_selector_dial.set_model(
00400         decimal_point_selector_dial_tree_model);
00401     {
00402         struct table_t
00403         {
00404             int value;
00405             const char *name;
00406         };
00407 
00408         static const table_t table[] =
00409         {
00410             { 0, "Integer" },
00411             { 1, "1 Places" },
00412             { 2, "2 Places" },
00413             { 3, "3 Places" },
00414             { 4, "4 Places" },
00415             { 5, "5 Places" },
00416             { 6, "6 Places" },
00417             { 7, "7 Places" },
00418             { 8, "8 Places" },
00419             { 10, "10 Places" },
00420             { 12, "12 Places" },
00421             { -1, "Floating" },
00422         };
00423 
00424         for (const table_t *tp = table; tp < ENDOF(table); ++tp)
00425         {
00426             Gtk::TreeModel::Row row =
00427                 *(decimal_point_selector_dial_tree_model->append());
00428             row[decimal_point_selector_dial_columns.column_id] = tp->value;
00429             row[decimal_point_selector_dial_columns.column_name] = tp->name;
00430 
00431             if (tp->value == precision_and_rounding_get().get_precision())
00432                 decimal_point_selector_dial.set_active(tp - table);
00433         }
00434     }
00435     decimal_point_selector_dial.pack_start(
00436         decimal_point_selector_dial_columns.column_name);
00437     decimal_point_selector_dial.signal_changed().connect(sigc::mem_fun(*this,
00438         &calculator_gnome::on_decimal_point_selector_dial_changed));
00439     control_group.pack_start(decimal_point_selector_dial);
00440 
00441     control_group.set_spacing(layout_spacing);
00442 
00443     // ---------- bring all the calculator widgets together --------------------
00444     display_widget_aligner.add(display_widget);
00445     calculator_layout.pack_start(display_widget_aligner, Gtk::PACK_SHRINK);
00446     calculator_layout.pack_start(control_group, Gtk::PACK_SHRINK);
00447     calculator_layout.pack_start(keyboard, Gtk::PACK_SHRINK);
00448     calculator_layout.set_spacing(layout_spacing);
00449 
00450     // ---------- next are the printer widgets ---------------------------------
00451     right_hand_panel.append_page(printer_group, printer_label);
00452 
00453     printer_paper.set_size_request(100, 50);
00454     {
00455         Pango::FontDescription fdesc;
00456         fdesc.set_family("monospace");
00457         //fdesc.set_size(10 * PANGO_SCALE);
00458         printer_paper.override_font(fdesc);
00459     }
00460     {
00461         // create a "red" tag so that we can use it later
00462         Glib::RefPtr<Gtk::TextTag> tp =
00463             printer_paper.get_buffer()->create_tag("red");
00464         tp->property_foreground().set_value("red");
00465     }
00466     printer_paper.set_editable(false);
00467     printer_paper_scroller.add(printer_paper);
00468     printer_paper_scroller.set_policy(Gtk::POLICY_AUTOMATIC,
00469         Gtk::POLICY_AUTOMATIC);
00470     printer_group.pack_start(printer_paper_scroller);
00471     printer_group.set_border_width(layout_spacing / 2);
00472     printer_group.pack_start(printer_button_group, Gtk::PACK_SHRINK);
00473     printer_group.set_spacing(layout_spacing);
00474     printer_button_group.pack_start(printer_power);
00475     printer_power.signal_clicked().connect(sigc::mem_fun(*this,
00476         &calculator_gnome::on_printer_power));
00477     printer_button_group.pack_start(printer_manual_calculation);
00478     printer_button_group.pack_start(printer_display_print);
00479     printer_display_print.signal_clicked().connect(sigc::mem_fun(*this,
00480         &calculator_gnome::on_display_print));
00481     printer_button_group.pack_start(printer_program_print);
00482     printer_program_print.signal_clicked().connect(sigc::mem_fun(*this,
00483         &calculator_gnome::on_program_print));
00484     printer_button_group.pack_start(printer_paper_feed);
00485     printer_paper_feed.signal_clicked().connect(sigc::mem_fun(*this,
00486         &calculator_gnome::on_paper_feed));
00487     printer_button_group.set_homogeneous();
00488 
00489     // ---------- next are the debugger widgets --------------------------------
00490     right_hand_panel.append_page(debugger_content, debugger_label);
00491     debugger_content.address_value_changed_signal().connect(
00492         sigc::mem_fun(*this, &calculator_gnome::user_changed_debugger_address));
00493 
00494     // ---------- bring the two units (calculator and printer) together --------
00495     overall_layout.pack_start(calculator_layout, Gtk::PACK_SHRINK);
00496     overall_layout.pack_start(right_hand_panel);
00497     overall_layout.set_spacing(layout_spacing);
00498     overall_layout.set_border_width(layout_spacing);
00499 
00500     // ---------- pack the menu bar and everything else together ---------------
00501     menu_layout.pack_start(*menu_bar, Gtk::PACK_SHRINK);
00502     menu_layout.pack_start(overall_layout);
00503     add(menu_layout);
00504 
00505     override_background_color(custom_widget_background, Gtk::STATE_FLAG_NORMAL);
00506 
00507     load_preferences_file();
00508     update_display();
00509     show_all_children();
00510 }
00511 
00512 
00513 calculator::pointer
00514 calculator_gnome::create(void)
00515 {
00516     return pointer(new calculator_gnome());
00517 }
00518 
00519 
00520 void
00521 calculator_gnome::derived_update_display(const display &value)
00522 {
00523     display_widget.set_value(value);
00524     update_debugger(debugger_content);
00525 }
00526 
00527 
00528 void
00529 calculator_gnome::on_opcode(opcode_t op)
00530 {
00531     calculator::on_opcode(op, location::pointer());
00532 }
00533 
00534 
00535 void
00536 calculator_gnome::on_plus_equals(void)
00537 {
00538     on_opcode(opcode_plus_equals);
00539 }
00540 
00541 
00542 void
00543 calculator_gnome::on_minus_equals(void)
00544 {
00545     on_opcode(opcode_minus_equals);
00546 }
00547 
00548 
00549 void
00550 calculator_gnome::on_mul(void)
00551 {
00552     on_opcode(opcode_mul);
00553 }
00554 
00555 
00556 void
00557 calculator_gnome::on_div(void)
00558 {
00559     on_opcode(opcode_div);
00560 }
00561 
00562 
00563 void
00564 calculator_gnome::on_sqrt(void)
00565 {
00566     on_opcode(opcode_sqrt);
00567 }
00568 
00569 
00570 void
00571 calculator_gnome::on_ent(void)
00572 {
00573     on_opcode(opcode_ent);
00574 }
00575 
00576 
00577 void
00578 calculator_gnome::on_sj(void)
00579 {
00580     on_opcode(opcode_sj);
00581 }
00582 
00583 
00584 void
00585 calculator_gnome::on_ej(void)
00586 {
00587     on_opcode(opcode_ej);
00588 }
00589 
00590 
00591 void
00592 calculator_gnome::on_mj(void)
00593 {
00594     on_opcode(opcode_mj);
00595 }
00596 
00597 
00598 void
00599 calculator_gnome::on_uj(void)
00600 {
00601     on_opcode(opcode_uj);
00602 }
00603 
00604 
00605 void
00606 calculator_gnome::on_fj(void)
00607 {
00608     on_opcode(opcode_fj);
00609 }
00610 
00611 
00612 void
00613 calculator_gnome::on_m1(void)
00614 {
00615     on_opcode(opcode_m1);
00616 }
00617 
00618 
00619 void
00620 calculator_gnome::on_m2(void)
00621 {
00622     on_opcode(opcode_m2);
00623 }
00624 
00625 
00626 void
00627 calculator_gnome::on_mm1(void)
00628 {
00629     on_opcode(opcode_mm1);
00630 }
00631 
00632 
00633 void
00634 calculator_gnome::on_mm2(void)
00635 {
00636     on_opcode(opcode_mm2);
00637 }
00638 
00639 
00640 void
00641 calculator_gnome::on_rm1(void)
00642 {
00643     on_opcode(opcode_rm1);
00644 }
00645 
00646 
00647 void
00648 calculator_gnome::on_rm2(void)
00649 {
00650     on_opcode(opcode_rm2);
00651 }
00652 
00653 
00654 void
00655 calculator_gnome::on_clear_indicator(void)
00656 {
00657     on_opcode(opcode_clear_indicator);
00658 }
00659 
00660 
00661 void
00662 calculator_gnome::on_cm1(void)
00663 {
00664     on_opcode(opcode_cm1);
00665 }
00666 
00667 
00668 void
00669 calculator_gnome::on_cm2(void)
00670 {
00671     on_opcode(opcode_cm2);
00672 }
00673 
00674 
00675 void
00676 calculator_gnome::on_dot(void)
00677 {
00678     on_opcode(opcode_dot);
00679 }
00680 
00681 
00682 void
00683 calculator_gnome::on_rv(void)
00684 {
00685     on_opcode(opcode_rv);
00686 }
00687 
00688 
00689 void
00690 calculator_gnome::on_right(void)
00691 {
00692     on_opcode(opcode_right);
00693 }
00694 
00695 
00696 void
00697 calculator_gnome::on_chg_sign(void)
00698 {
00699     on_opcode(opcode_chg_sign);
00700 }
00701 
00702 
00703 void
00704 calculator_gnome::on_n0(void)
00705 {
00706     on_opcode(opcode_n0);
00707 }
00708 
00709 
00710 void
00711 calculator_gnome::on_n1(void)
00712 {
00713     on_opcode(opcode_n1);
00714 }
00715 
00716 
00717 void
00718 calculator_gnome::on_n2(void)
00719 {
00720     on_opcode(opcode_n2);
00721 }
00722 
00723 
00724 void
00725 calculator_gnome::on_n3(void)
00726 {
00727     on_opcode(opcode_n3);
00728 }
00729 
00730 
00731 void
00732 calculator_gnome::on_n4(void)
00733 {
00734     on_opcode(opcode_n4);
00735 }
00736 
00737 
00738 void
00739 calculator_gnome::on_n5(void)
00740 {
00741     on_opcode(opcode_n5);
00742 }
00743 
00744 
00745 void
00746 calculator_gnome::on_n6(void)
00747 {
00748     on_opcode(opcode_n6);
00749 }
00750 
00751 
00752 void
00753 calculator_gnome::on_n7(void)
00754 {
00755     on_opcode(opcode_n7);
00756 }
00757 
00758 
00759 void
00760 calculator_gnome::on_n8(void)
00761 {
00762     on_opcode(opcode_n8);
00763 }
00764 
00765 
00766 void
00767 calculator_gnome::on_n9(void)
00768 {
00769     on_opcode(opcode_n9);
00770 }
00771 
00772 
00773 void
00774 calculator_gnome::on_start(void)
00775 {
00776     on_opcode(opcode_extended_start);
00777     update_debugger(debugger_content);
00778 }
00779 
00780 
00781 void
00782 calculator_gnome::on_k_down(void)
00783 {
00784     constant_mode_set(true);
00785 }
00786 
00787 
00788 void
00789 calculator_gnome::on_k_up(void)
00790 {
00791     constant_mode_set(false);
00792 }
00793 
00794 
00795 void
00796 calculator_gnome::on_am1_down(void)
00797 {
00798     accumulate_mode_set(true);
00799 }
00800 
00801 
00802 void
00803 calculator_gnome::on_am1_up(void)
00804 {
00805     accumulate_mode_set(false);
00806 }
00807 
00808 
00809 void
00810 calculator_gnome::on_m3_tilde(void)
00811 {
00812     on_opcode(opcode_extended_m3_tilde);
00813 }
00814 
00815 
00816 void
00817 calculator_gnome::on_sm3_tilde(void)
00818 {
00819     on_opcode(opcode_extended_sm3_tilde);
00820 }
00821 
00822 
00823 void
00824 calculator_gnome::on_cm3_tilde(void)
00825 {
00826     on_opcode(opcode_extended_cm3_tilde);
00827 }
00828 
00829 
00830 void
00831 calculator_gnome::on_rm3_tilde(void)
00832 {
00833     on_opcode(opcode_extended_rm3_tilde);
00834 }
00835 
00836 
00837 void
00838 calculator_gnome::on_quit(void)
00839 {
00840     exit(0);
00841 }
00842 
00843 
00844 void
00845 calculator_gnome::on_error_v(const char *fmt, va_list ap)
00846 {
00847     std::string text = std_string_printf_v(fmt, ap);
00848     if (!error_window)
00849         error_window = new message_dialog_error(*this);
00850     error_window->add_text(text);
00851 }
00852 
00853 
00854 static void
00855 insert_at_end(Gtk::TextView &tv, const Glib::ustring &text)
00856 {
00857     tv.get_buffer()->insert(tv.get_buffer()->end(), text);
00858 }
00859 
00860 
00861 static void
00862 insert_at_end_red(Gtk::TextView &tv, const Glib::ustring &text)
00863 {
00864     tv.get_buffer()->insert_with_tag(tv.get_buffer()->end(), text, "red");
00865 }
00866 
00867 
00868 static void
00869 insert_space_until(Gtk::TextView &tv, int &column, int target)
00870 {
00871     if (column >= target)
00872         return;
00873     Glib::ustring buffer;
00874     while (column < target)
00875     {
00876         buffer += ' ';
00877         ++column;
00878     }
00879     insert_at_end(tv, buffer);
00880 }
00881 
00882 
00883 void
00884 calculator_gnome::derived_print(const display &value)
00885 {
00886     right_hand_panel.show();
00887     right_hand_panel.set_current_page(0);
00888     Glib::ustring buffer;
00889     for (int dignum = 15; dignum >= 0; --dignum)
00890     {
00891         const display::tube_t &tube = value.tubes[dignum];
00892         if (tube.digit >= 10)
00893             buffer += ' ';
00894         else
00895             buffer += (char)('0' + tube.digit);
00896         if (tube.dot)
00897             buffer += '.';
00898     }
00899     int column = 18;
00900     if (value.negative)
00901     {
00902         buffer += '-';
00903         ++column;
00904     }
00905     if (value.negative)
00906         insert_at_end_red(printer_paper, buffer);
00907     else
00908         insert_at_end(printer_paper, buffer);
00909 
00910     switch (value.column18)
00911     {
00912     case display::column18_blank:
00913         break;
00914 
00915     case display::column18_minus:
00916         if (!value.negative)
00917         {
00918             insert_space_until(printer_paper, column, 18);
00919             insert_at_end_red(printer_paper, "-");
00920             ++column;
00921         }
00922         break;
00923 
00924     case display::column18_ce:
00925         insert_space_until(printer_paper, column, 18);
00926         insert_at_end(printer_paper, "CE");
00927         column += 2;
00928         break;
00929 
00930     case display::column18_cm:
00931         insert_space_until(printer_paper, column, 18);
00932         insert_at_end(printer_paper, "CM");
00933         column += 2;
00934         break;
00935 
00936     case display::column18_e:
00937         insert_space_until(printer_paper, column, 18);
00938         insert_at_end(printer_paper, "E");
00939         ++column;
00940         break;
00941 
00942     case display::column18_fj:
00943         insert_space_until(printer_paper, column, 18);
00944         insert_at_end(printer_paper, "FJ");
00945         column += 2;
00946         break;
00947 
00948     case display::column18_ej:
00949         insert_space_until(printer_paper, column, 18);
00950         insert_at_end(printer_paper, "EJ");
00951         column += 2;
00952         break;
00953 
00954     case display::column18_uj:
00955         insert_space_until(printer_paper, column, 18);
00956         insert_at_end(printer_paper, "UJ");
00957         column += 2;
00958         break;
00959 
00960     case display::column18_mj:
00961         insert_space_until(printer_paper, column, 18);
00962         insert_at_end(printer_paper, "MJ");
00963         column += 2;
00964         break;
00965 
00966     case display::column18_sj:
00967         insert_space_until(printer_paper, column, 18);
00968         insert_at_end(printer_paper, "SJ");
00969         column += 2;
00970         break;
00971 
00972     case display::column18_rv:
00973         // Question: in which column is RV printed?
00974         insert_space_until(printer_paper, column, 18);
00975         insert_at_end(printer_paper, "RV");
00976         column += 2;
00977         break;
00978 
00979     case display::column18_sfj:
00980         // Question: in which column is SFJ printed?
00981         insert_space_until(printer_paper, column, 18);
00982         insert_at_end(printer_paper, "SFJ");
00983         column += 3;
00984         break;
00985 
00986     case display::column18_suj:
00987         // Question: in which column is SUJ printed?
00988         insert_space_until(printer_paper, column, 18);
00989         insert_at_end(printer_paper, "SUJ");
00990         column += 3;
00991         break;
00992 
00993     case display::column18_srj:
00994         // Question: in which column is SRJ printed?
00995         insert_space_until(printer_paper, column, 18);
00996         insert_at_end(printer_paper, "SRJ");
00997         column += 3;
00998         break;
00999 
01000     case display::column18_right:
01001         // Question: in which column is [->] printed?
01002         insert_space_until(printer_paper, column, 18);
01003         insert_at_end(printer_paper, UNICODE_RIGHT);
01004         ++column;
01005         break;
01006 
01007     case display::column18_cs:
01008         // Question: in which column is CHG_SIGN printed?
01009         insert_space_until(printer_paper, column, 18);
01010         insert_at_end_red(printer_paper, "CS");
01011         column += 2;
01012         break;
01013 
01014     default:
01015         break;
01016     }
01017     switch (value.column19)
01018     {
01019     case display::column19_blank:
01020         break;
01021 
01022     case display::column19_plus_equals:
01023         insert_space_until(printer_paper, column, 19);
01024         insert_at_end(printer_paper, "+=");
01025         column += 2;
01026         break;
01027 
01028     case display::column19_minus_equals:
01029         insert_space_until(printer_paper, column, 19);
01030         insert_at_end_red(printer_paper, "-=");
01031         column += 2;
01032         break;
01033 
01034     case display::column19_times:
01035         insert_space_until(printer_paper, column, 19);
01036         insert_at_end(printer_paper, UNICODE_MUL);
01037         ++column;
01038         break;
01039 
01040     case display::column19_divide:
01041         insert_space_until(printer_paper, column, 19);
01042         insert_at_end(printer_paper, UNICODE_DIV);
01043         ++column;
01044         break;
01045 
01046     case display::column19_sqrt:
01047         insert_space_until(printer_paper, column, 19);
01048         insert_at_end(printer_paper, UNICODE_SQRT);
01049         ++column;
01050         break;
01051 
01052     case display::column19_m_plus:
01053         insert_space_until(printer_paper, column, 19);
01054         insert_at_end(printer_paper, "M+");
01055         column += 2;
01056         break;
01057 
01058     case display::column19_m_minus:
01059         insert_space_until(printer_paper, column, 19);
01060         insert_at_end_red(printer_paper, "M-");
01061         column += 2;
01062         break;
01063 
01064     case display::column19_rm:
01065         insert_space_until(printer_paper, column, 19);
01066         insert_at_end(printer_paper, "RM");
01067         column += 2;
01068         break;
01069 
01070     case display::column19_sm:
01071         // Question: in which column is SM printed?
01072         insert_space_until(printer_paper, column, 19);
01073         insert_at_end(printer_paper, "SM");
01074         column += 2;
01075         break;
01076 
01077     case display::column19_print:
01078         insert_space_until(printer_paper, column, 19);
01079         insert_at_end(printer_paper, UNICODE_PRINT);
01080         ++column;
01081         break;
01082 
01083     default:
01084         break;
01085     }
01086     switch (value.column20)
01087     {
01088     case display::column20_blank:
01089         break;
01090 
01091     case display::column20_n1:
01092         insert_space_until(printer_paper, column, 20);
01093         insert_at_end(printer_paper, "1");
01094         ++column;
01095         break;
01096 
01097     case display::column20_fd:
01098         insert_space_until(printer_paper, column, 20);
01099         insert_at_end(printer_paper, "FD");
01100         column += 2;
01101         break;
01102 
01103     case display::column20_round_up:
01104         insert_space_until(printer_paper, column, 20);
01105         insert_at_end(printer_paper, UNICODE_UP);
01106         ++column;
01107         break;
01108 
01109     case display::column20_round_off:
01110         insert_space_until(printer_paper, column, 20);
01111         insert_at_end(printer_paper, "5/4");
01112         column += 3;
01113         break;
01114 
01115     case display::column20_round_down:
01116         insert_space_until(printer_paper, column, 20);
01117         insert_at_end(printer_paper, UNICODE_DOWN);
01118         ++column;
01119         break;
01120 
01121     case display::column20_dot:
01122         insert_space_until(printer_paper, column, 20);
01123         insert_at_end(printer_paper, ".");
01124         ++column;
01125         break;
01126 
01127     default:
01128         break;
01129     }
01130     switch (value.column21)
01131     {
01132     case display::column21_blank:
01133         break;
01134 
01135     case display::column21_n0:
01136     case display::column21_n1:
01137     case display::column21_n2:
01138     case display::column21_n3:
01139     case display::column21_n4:
01140     case display::column21_n5:
01141     case display::column21_n6:
01142     case display::column21_n7:
01143     case display::column21_n8:
01144     case display::column21_n9:
01145         {
01146             insert_space_until(printer_paper, column, 21);
01147             Glib::ustring buffer;
01148             buffer += (char)('0' + value.column21 - display::column21_n0);
01149             insert_at_end(printer_paper, buffer);
01150             ++column;
01151         }
01152         break;
01153 
01154     default:
01155         break;
01156     }
01157     insert_at_end(printer_paper, "\n");
01158     Gtk::TextBuffer::iterator end = printer_paper.get_buffer()->end();
01159     printer_paper.scroll_to(end, 0.);
01160 }
01161 
01162 
01163 void
01164 calculator_gnome::derived_feed(void)
01165 {
01166     right_hand_panel.show();
01167     right_hand_panel.set_current_page(0);
01168     insert_at_end(printer_paper, "\n");
01169     Gtk::TextBuffer::iterator end = printer_paper.get_buffer()->end();
01170     printer_paper.scroll_to(end, 0.);
01171 }
01172 
01173 
01174 void
01175 calculator_gnome::run(void)
01176 {
01177     Gtk::Main::run(*this);
01178 }
01179 
01180 
01181 void
01182 calculator_gnome::on_c(void)
01183 {
01184     on_opcode(opcode_extended_c);
01185 }
01186 
01187 
01188 void
01189 calculator_gnome::derived_off(void)
01190 {
01191     hide();
01192 }
01193 
01194 
01195 void
01196 calculator_gnome::on_display_print(void)
01197 {
01198     on_opcode(opcode_extended_display_print);
01199 }
01200 
01201 
01202 void
01203 calculator_gnome::on_paper_feed(void)
01204 {
01205     on_opcode(opcode_extended_paper_feed);
01206 }
01207 
01208 
01209 void
01210 calculator_gnome::on_program_print(void)
01211 {
01212     on_opcode(opcode_extended_program_print);
01213 }
01214 
01215 
01216 void
01217 calculator_gnome::on_printer_power(void)
01218 {
01219     right_hand_panel.hide();
01220     resize(400, 100);
01221 }
01222 
01223 
01224 static std::string
01225 getcwd(void)
01226 {
01227     char buffer[2000];
01228     if (!getcwd(buffer, sizeof(buffer)))
01229         return ".";
01230     return buffer;
01231 }
01232 
01233 
01234 void
01235 calculator_gnome::on_load_program(void)
01236 {
01237     if (animate_card_reader && crp && crp->is_busy())
01238     {
01239         on_error
01240         (
01241             "The card reader is busy at the present time.  "
01242             "Try again when the card reader is not in use."
01243         );
01244         return;
01245     }
01246 
01247     Gtk::FileChooserDialog dialog("Load Program",
01248         Gtk::FILE_CHOOSER_ACTION_OPEN);
01249     dialog.set_transient_for(*this);
01250     dialog.set_current_folder(getcwd());
01251 
01252     Gtk::CheckButton binary("Binary");
01253     binary.show();
01254     dialog.get_action_area()->pack_start(binary);
01255 
01256     // Add response buttons the the dialog:
01257     dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
01258     dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
01259 
01260     if (dialog.run() == Gtk::RESPONSE_OK)
01261     {
01262         dialog.hide();
01263         if (program_mode_get() != program_mode_learn)
01264             dialog_prog_mode(this).run();
01265 
01266         if (animate_card_reader)
01267         {
01268             right_hand_panel.show();
01269 
01270             // get window-relative coordinates of right hand panel
01271             int rhs_x = 0;
01272             int rhs_y = 0;
01273             right_hand_panel.translate_coordinates(*this, 0, 0, rhs_x, rhs_y);
01274 
01275             // get root coordinates of right hand panel
01276             int move_x = 0;
01277             int move_y = 0;
01278             Glib::RefPtr<Gdk::Window> window = get_window();
01279             window->get_root_coords(rhs_x, rhs_y, move_x, move_y);
01280 
01281             if (!crp)
01282                 crp = window_card_reader::create(this);
01283             crp->start(dialog.get_filename(), binary.get_active());
01284             crp->move(move_x, move_y);
01285             crp->show();
01286         }
01287         else
01288         {
01289             load_program(dialog.get_filename().c_str(), binary.get_active());
01290         }
01291 
01292     }
01293 }
01294 
01295 
01296 void
01297 calculator_gnome::on_save_program(void)
01298 {
01299     Gtk::FileChooserDialog dialog("Save Program As",
01300         Gtk::FILE_CHOOSER_ACTION_SAVE);
01301     dialog.set_transient_for(*this);
01302     dialog.set_current_folder(getcwd());
01303 
01304     Gtk::CheckButton binary("Binary");
01305     binary.show();
01306     dialog.get_action_area()->pack_start(binary);
01307 
01308     // Add response buttons the the dialog:
01309     dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
01310     dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
01311 
01312     if (dialog.run() == Gtk::RESPONSE_OK)
01313     {
01314         save_program_as(dialog.get_filename().c_str(), binary.get_active());
01315     }
01316 }
01317 
01318 
01319 void
01320 calculator_gnome::on_save_memories_as_program(void)
01321 {
01322     Gtk::FileChooserDialog dialog("Save Memories as Program",
01323         Gtk::FILE_CHOOSER_ACTION_SAVE);
01324     dialog.set_transient_for(*this);
01325     dialog.set_current_folder(getcwd());
01326 
01327     // Add response buttons the the dialog:
01328     dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
01329     dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
01330 
01331     if (dialog.run() == Gtk::RESPONSE_OK)
01332     {
01333         save_memories_as_program(dialog.get_filename());
01334     }
01335 }
01336 
01337 
01338 bool
01339 calculator_gnome::do_key_press_event(GdkEventKey *event)
01340 {
01341 #if 0
01342     fprintf(stderr, "%s: %d: press:\n", __FILE__, __LINE__);
01343     fprintf(stderr, "  state = %d\n", event->state);
01344     fprintf(stderr, "  keyval = %d\n", event->keyval);
01345     fprintf(stderr, "  length = %d\n", event->length);
01346     fprintf(stderr, "  string = \"%.*s\"\n", event->length, event->string);
01347     fprintf(stderr, "  hardware_keycode = %d\n", event->hardware_keycode);
01348     fprintf(stderr, "  group = %d\n", event->group);
01349     fprintf(stderr, "  is_modifier = %d\n", event->is_modifier);
01350 #endif
01351     switch (event->keyval)
01352     {
01353     case '0': case '1': case '2': case '3': case '4':
01354     case '5': case '6': case '7': case '8': case '9':
01355         on_opcode(opcode_t(opcode_n0 + (int)event->keyval - '0'));
01356         return false;
01357 
01358     case '.':
01359         on_opcode(opcode_dot);
01360         return false;
01361 
01362     case '-':
01363         on_opcode(opcode_minus_equals);
01364         return false;
01365 
01366     case '+':
01367     case '=':
01368         on_opcode(opcode_plus_equals);
01369         return false;
01370 
01371     case '*':
01372         on_opcode(opcode_mul);
01373         return false;
01374 
01375     case '/':
01376         on_opcode(opcode_div);
01377         return false;
01378 
01379     default:
01380         break;
01381     }
01382     return true;
01383 }
01384 
01385 
01386 void
01387 calculator_gnome::on_program_mode_switch_changed(void)
01388 {
01389     program_mode_t id = (program_mode_t)program_mode_switch.get_value();
01390     program_mode_set(id);
01391     if (id == calculator::program_mode_operation_check)
01392     {
01393         right_hand_panel.show();
01394         right_hand_panel.set_current_page(1);
01395         update_debugger(debugger_content);
01396     }
01397 }
01398 
01399 
01400 void
01401 calculator_gnome::on_program_selector_switch_changed(void)
01402 {
01403     program_selector_t id =
01404         (program_selector_t)program_selector_switch.get_value();
01405     program_selector_set(id);
01406 }
01407 
01408 
01409 void
01410 calculator_gnome::program_mode_set_from_dialog(int id)
01411 {
01412     program_mode_set((program_mode_t)id);
01413     program_mode_switch.set_value((int)program_mode_get());
01414 }
01415 
01416 
01417 void
01418 calculator_gnome::on_rounding_switch_changed(void)
01419 {
01420     precision_and_rounding_set
01421     (
01422         precision_and_rounding
01423         (
01424             precision_and_rounding_get().get_precision(),
01425             (precision_and_rounding::round_t)rounding_switch.get_value()
01426         )
01427     );
01428 }
01429 
01430 
01431 void
01432 calculator_gnome::on_decimal_point_selector_dial_changed(void)
01433 {
01434     Gtk::TreeModel::iterator iter = decimal_point_selector_dial.get_active();
01435     if (iter)
01436     {
01437         Gtk::TreeModel::Row row = *iter;
01438         if (row)
01439         {
01440             int id = row[decimal_point_selector_dial_columns.column_id];
01441             precision_and_rounding_set
01442             (
01443                 precision_and_rounding
01444                 (
01445                     id,
01446                     precision_and_rounding_get().get_rounding()
01447                 )
01448             );
01449         }
01450     }
01451 }
01452 
01453 
01454 bool
01455 calculator_gnome::on_clock_tick(void)
01456 {
01457     clock_tick_event();
01458     if (clock_tick_expected())
01459         return true;
01460     clock_tick_timer.disconnect();
01461     return false;
01462 }
01463 
01464 
01465 void
01466 calculator_gnome::clock_tick_start_running(void)
01467 {
01468     if (!clock_tick_timer.connected())
01469     {
01470         // FIXME: make this configurable
01471         clock_tick_timer =
01472             Glib::signal_timeout().connect
01473             (
01474                 sigc::mem_fun(*this, &calculator_gnome::on_clock_tick),
01475                 100 // milliseconds
01476             );
01477     }
01478 }
01479 
01480 
01481 bool
01482 calculator_gnome::on_printer_finished(void)
01483 {
01484     printer_timer.disconnect();
01485     printer_finished_event();
01486     return false;
01487 }
01488 
01489 
01490 void
01491 calculator_gnome::printer_timer_start_running(void)
01492 {
01493     if (!printer_timer.connected())
01494     {
01495         printer_timer =
01496             Glib::signal_timeout().connect
01497             (
01498                 sigc::mem_fun(*this, &calculator_gnome::on_printer_finished),
01499                 420 // milliseconds
01500             );
01501     }
01502 }
01503 
01504 
01505 void
01506 calculator_gnome::on_special_key_symbol(void)
01507 {
01508     int n = dialog_special_key_symbol(this).run();
01509     if (n >= 0 && n < 128)
01510         on_opcode(opcode_t(n));
01511 }
01512 
01513 
01514 void
01515 calculator_gnome::on_edit_preferences(void)
01516 {
01517     dialog_preferences pref(this);
01518     pref.set_animate_card_reader(animate_card_reader);
01519     pref.set_strict_memory_numbers(strict_memory_number_checking_required());
01520     if (pref.run() == Gtk::RESPONSE_OK)
01521     {
01522         animate_card_reader = pref.get_animate_card_reader();
01523         strict_memory_number_checking_set(pref.get_strict_memory_numbers());
01524         save_preferences_file();
01525     }
01526 }
01527 
01528 
01529 void
01530 calculator_gnome::load_preferences_file(void)
01531 {
01532 }
01533 
01534 
01535 void
01536 calculator_gnome::save_preferences_file(void)
01537 {
01538 }
01539 
01540 
01541 void
01542 calculator_gnome::user_changed_debugger_address(int n)
01543 {
01544     set_address(n);
01545     update_debugger(debugger_content);
01546 }
01547 
01548 
01549 // vim: set ts=8 sw=4 et :