?? dialogs.cpp
字號(hào):
log_error(ERROR_PARSE_ERROR,"parse_stats_dialog: cur_pc=NULL",NULL); display_grid_fill = false; grid_fill_check.signal_toggled().connect(sigc::mem_fun(*this, &parse_stats_dialog::on_check_toggle)); prev_button.signal_clicked().connect(sigc::mem_fun(*this, &parse_stats_dialog::on_prev_button_click)); next_button.signal_clicked().connect(sigc::mem_fun(*this, &parse_stats_dialog::on_next_button_click)); // start packing the widgets: get_vbox()->pack_start(grid_da, Gtk::PACK_SHRINK); // fill the combo_box: prs_combo_box.append_text("Letter Matches:"); char cur_pr_string[64]; vector<const char *> number_letters; number_letters.push_back("st"); number_letters.push_back("nd"); number_letters.push_back("rd"); number_letters.push_back("th"); number_letters.push_back("th"); for(int i = 0; i < parse_dialog_num_matches; i++) { if(i >= number_letters.size()) break; sprintf(cur_pr_string, "(%d%s) %s: %05e", i + 1, number_letters[i], cur_pc->self_node.char_matches[i].character.c_str(), cur_pc->self_node.char_matches[i].probability); prs_combo_box.append_text(cur_pr_string); } prs_combo_box.set_active(0); middle_hbox.pack_start(prs_combo_box); middle_hbox.pack_start(grid_fill_check); get_vbox()->pack_start(middle_hbox, Gtk::PACK_SHRINK); get_vbox()->pack_start(sep_line, Gtk::PACK_SHRINK); arrows_buttonbox.pack_start(prev_button); arrows_buttonbox.pack_end(next_button); get_vbox()->pack_start(arrows_buttonbox, Gtk::PACK_SHRINK); grid_da.set_grid_params(trcfg_grid_size_x, trcfg_grid_size_y, trcfg_gridcell_size_x, trcfg_gridcell_size_y); signals.do_grid_cfg_new_letter(cur_pc->self_node.self_box); show_all_children();}void parse_stats_dialog::on_check_toggle() { display_grid_fill = !display_grid_fill; grid_da.set_grid_draw_fill(display_grid_fill); grid_da.refresh();}void parse_stats_dialog::on_prev_button_click() { if((cur_pl == pf->plist->pl_begin) && (cur_pc == pf->plist->pl_begin->pc_begin)) { cur_pl = pf->plist->pl_end; cur_pc = cur_pl->pc_end; } else if(cur_pc == cur_pl->pc_begin) { cur_pl = cur_pl->prev; cur_pc = cur_pl->pc_end; } else cur_pc = cur_pc->prev; signals.do_grid_cfg_new_letter(cur_pc->self_node.self_box); grid_da.refresh();}void parse_stats_dialog::on_next_button_click() { if((cur_pl == pf->plist->pl_end) && (cur_pc == pf->plist->pl_end->pc_end)) { cur_pl = pf->plist->pl_begin; cur_pc = cur_pl->pc_begin; } else if(cur_pc == cur_pl->pc_end) { cur_pl = cur_pl->next; cur_pc = cur_pl->pc_begin; } else cur_pc = cur_pc->next; signals.do_grid_cfg_new_letter(cur_pc->self_node.self_box); grid_da.refresh();}/////// profile stats:profile_stats_dialog::profile_stats_dialog(profile *p) : close_button("Close") { set_title("Profile Stats"); // add labels: num_chars_label.set_label("Number of characters recognized: "); num_chars_num_label.set_label(int_to_string(NUM_TRAINED_CHARS)); num_insts_label.set_label("Total number of character instances: "); num_insts_num_label.set_label(int_to_string(p->total_instances)); avg_insts_label.set_label("Average number of instances per character: "); avg_insts_num_label.set_label(double_to_string((double)(p->total_instances) / NUM_TRAINED_CHARS)); insts_label.set_text("Number of instances per character: "); // setup the combobox (sort by num_instances): vector<profile_sort_token> insts_v; vector<profile_sort_token>::iterator iter; profile_sort_token token; for(int k = 0; k < (p->character_nodes.size()); k++) { token.character = p->character_nodes[k].character; token.num_instances = p->character_nodes[k].num_instances; if(insts_v.size() == 0) insts_v.push_back(token); else { iter = insts_v.begin(); for(int l = 0; l < insts_v.size(); l++) { if((l == 0) && (token.num_instances > insts_v[l].num_instances)) { insts_v.insert(iter, token); break; } else if((l != 0) && (token.num_instances <= insts_v[l - 1].num_instances) && (token.num_instances >= insts_v[l].num_instances)) { insts_v.insert(iter, token); break; } else if(l == (insts_v.size() - 1)) { insts_v.push_back(token); break; } iter++; } // for l } // else } // for k for(int i = 0; i < insts_v.size(); i++) { insts_combobox.append_text(insts_v[i].character + " (" + int_to_string(insts_v[i].num_instances) + " insts)"); } insts_combobox.set_active(0); num_chars_label_hbox.pack_start(num_chars_label, Gtk::PACK_SHRINK); num_insts_label_hbox.pack_start(num_insts_label, Gtk::PACK_SHRINK); avg_insts_label_hbox.pack_start(avg_insts_label, Gtk::PACK_SHRINK); insts_label_hbox.pack_start(insts_label, Gtk::PACK_SHRINK); num_chars_num_label_hbox.pack_start(num_chars_num_label, Gtk::PACK_SHRINK); num_insts_num_label_hbox.pack_start(num_insts_num_label, Gtk::PACK_SHRINK); avg_insts_num_label_hbox.pack_start(avg_insts_num_label, Gtk::PACK_SHRINK); insts_combobox_hbox.pack_start(insts_combobox, Gtk::PACK_SHRINK); labels_vbox.set_spacing(10); labels_vbox.pack_start(num_chars_label_hbox, Gtk::PACK_SHRINK); labels_vbox.pack_start(num_insts_label_hbox, Gtk::PACK_SHRINK); labels_vbox.pack_start(avg_insts_label_hbox, Gtk::PACK_SHRINK); labels_vbox.pack_start(insts_label_hbox, Gtk::PACK_SHRINK); numbers_vbox.set_spacing(10); numbers_vbox.pack_start(num_chars_num_label_hbox, Gtk::PACK_SHRINK); numbers_vbox.pack_start(num_insts_num_label_hbox, Gtk::PACK_SHRINK); numbers_vbox.pack_start(avg_insts_num_label_hbox, Gtk::PACK_SHRINK); numbers_vbox.pack_start(insts_combobox_hbox, Gtk::PACK_SHRINK); main_hbox.set_spacing(10); main_hbox.pack_start(labels_vbox, Gtk::PACK_SHRINK); main_hbox.pack_start(numbers_vbox, Gtk::PACK_SHRINK); get_vbox()->set_spacing(10); get_vbox()->pack_start(main_hbox, Gtk::PACK_SHRINK); get_vbox()->pack_start(separator, Gtk::PACK_SHRINK); // close button: close_button.signal_clicked().connect(sigc::mem_fun(*this, &profile_stats_dialog::on_close_button_click)); //close_buttonbox.set_layout(Gtk::BUTTONBOX_END); close_buttonbox.pack_end(close_button, Gtk::PACK_SHRINK); get_vbox()->pack_start(close_buttonbox, Gtk::PACK_SHRINK); show_all_children();}void profile_stats_dialog::on_close_button_click() { hide();}profile_name_dialog::profile_name_dialog() : use_new_name_button("Use New Name"), use_cfg_button("Use Default Config Name"), profile_dir_label(cfg_profile_dir), profile_suffix_label(".profile") { set_title("Choose New Profile Name"); get_vbox()->set_spacing(10); new_name_text.set_text("default_profile"); new_name_text.set_width_chars(15); name_hbox.pack_start(profile_dir_label, Gtk::PACK_SHRINK); name_hbox.pack_start(new_name_text, Gtk::PACK_SHRINK); name_hbox.pack_start(profile_suffix_label, Gtk::PACK_SHRINK); choose_buttons.set_layout(Gtk::BUTTONBOX_DEFAULT_STYLE); choose_buttons.pack_start(use_new_name_button, Gtk::PACK_SHRINK); choose_buttons.pack_start(use_cfg_button); use_new_name_button.signal_clicked().connect(sigc::mem_fun(*this, &profile_name_dialog::on_new_name_button_click)); use_cfg_button.signal_clicked().connect(sigc::mem_fun(*this, &profile_name_dialog::on_use_cfg_button_click)); get_vbox()->pack_start(name_hbox, Gtk::PACK_SHRINK); get_vbox()->pack_start(choose_buttons, Gtk::PACK_SHRINK); show_all_children();} void profile_name_dialog::on_new_name_button_click() { new_profile_name = cfg_profile_dir + new_name_text.get_text() + ".profile"; hide();}void profile_name_dialog::on_use_cfg_button_click() { new_profile_name = cfg_profile; hide();}log_file_text::log_file_text() { set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); //set_size_request(x, y); set_shadow_type(Gtk::SHADOW_ETCHED_IN); add(text_view); setup_buffer(); show_all_children();}void log_file_text::append_string(string str) { string cur_text = buffer_ref->get_text(); cur_text = cur_text + str; buffer_ref->set_text(cur_text);}void log_file_text::setup_buffer() { buffer_ref = Gtk::TextBuffer::create(); text_view.set_wrap_mode(Gtk::WRAP_WORD); text_view.set_buffer(buffer_ref);}log_file_dialog::log_file_dialog() : close_button("Close") { set_title("View Logs"); log_text.set_size_request(LOG_TEXT_SIZE_X, LOG_TEXT_SIZE_Y); get_vbox()->pack_start(log_text, Gtk::PACK_SHRINK); close_buttonbox.set_layout(Gtk::BUTTONBOX_END); close_buttonbox.pack_end(close_button, Gtk::PACK_SHRINK); get_vbox()->pack_start(close_buttonbox, Gtk::PACK_SHRINK); close_button.signal_clicked().connect(sigc::mem_fun(*this, &log_file_dialog::on_close_click)); FILE *log_fp = fopen(cfg_log_file.c_str(), "r"); if(log_fp == NULL) { popup_message(*this, "Error opening the log file!"); hide(); return; } char line_str[256]; string line; long last_stamp_pos = 0; while(!feof(log_fp)) { fgets(line_str, 256, log_fp); line = line_str; if(line == CLASSNOTES_LOG_STAMP) last_stamp_pos = ftell(log_fp); } fseek(log_fp, last_stamp_pos, SEEK_SET); while(!feof(log_fp)) { fgets(line_str, 256, log_fp); line = line_str; if(line == "\n") continue; else log_text.append_string(line + "\n"); } // while fclose(log_fp); show_all_children();}void log_file_dialog::on_close_click() { hide();}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -