EDEFont fl_font_dialog(EDEFont current_font) { EDEFont return_font; create_the_forms(); int numfonts = fl_list_fonts(all_fonts); // populate list of fonts Fl_String currentname = current_font.font->name(); for(int i = 0; i < numfonts; i++) { Fl_String fontname = all_fonts[i]->name(); fontobj->add(fontname); if (currentname.lower_case().pos(fontname.lower_case())==0) // it's a substring fontobj->value(i); } // set bold, italic if (currentname.pos(" bold italic") == currentname.length()-12) { bold_button->value(true); italic_button->value(true); } else if (currentname.pos(" italic") == currentname.length()-7) { italic_button->value(true); } else if (currentname.pos(" bold") == currentname.length()-5) { bold_button->value(true); } // populate other lists textobj->encoding = current_font.encoding; // TODO: what if we're using XFT? font_cb(fontobj,0); for (int i=0; i < sizeobj->children(); i++) { if (atoi(sizeobj->text(i)) == current_font.size) { sizeobj->value(i); size_cb(sizeobj,0); } } form->exec(); form->show(); // we have to construct a proper EDEFont to return return_font.defined = false; if (return_value) { return_font.font = fl_find_font(fontobj->text(fontobj->value())); if (bold_button->value()) return_font.font = return_font.font->bold(); if (italic_button->value()) return_font.font = return_font.font->italic(); int size = atoi(sizeobj->text(sizeobj->value())); return_font.size = find_best_size(return_font.font, size); // on XFT encoding is always Unicode, so this field can be blank if (encobj->children() > 0) return_font.encoding = encobj->text(encobj->value()); else return_font.encoding = ""; return_font.defined = true; } return return_font; }
EDEFont font_chooser(EDEFont current_font) { EDEFont return_font; create_the_forms(); if(!numfonts) numfonts = fltk::list_fonts(all_fonts); // populate list of fonts fontobj->clear(); for(int i = 0; i < numfonts; i++) { fontobj->add(all_fonts[i]->name()); if (current_font.font && (strcasecmp(current_font.font->name(),all_fonts[i]->name())==0)) // it's a substring fontobj->value(i); } /*char* currentname = strdup(current_font.font->name()); fsor(int i = 0; i < numfonts; i++) { char* fontname = strdup(all_fonts[i]->name()); fontobj->add(fontname); if (currentname.lower_case().pos(fontname.lower_case())==0) // it's a substring fontobj->value(i); }*/ // set bold, italic /*if (currentname.pos(" bold italic") == currentname.length()-12) { bold_button->value(true); italic_button->value(true); } else if (currentname.pos(" italic") == currentname.length()-7) { italic_button->value(true); } else if (currentname.pos(" bold") == currentname.length()-5) { bold_button->value(true); }*/ // populate other lists textobj->encoding = current_font.encoding; // TODO: what if we're using XFT? font_cb(fontobj,0); for (int i=0; i < sizeobj->children(); i++) { if (atoi(sizeobj->child(i)->label()) == current_font.size) { sizeobj->value(i); size_cb(sizeobj,0); } } // form->show(); form->exec(); // we have to construct a proper EDEFont to return return_font.defined = false; if (return_value) { return_font.font = fltk::font(fontobj->child(fontobj->value())->label()); //Style.h if (bold_button->value()) return_font.font = return_font.font->bold(); if (italic_button->value()) return_font.font = return_font.font->italic(); int size = atoi(sizeobj->child(sizeobj->value())->label()); return_font.size = find_best_size(return_font.font, size); // on XFT encoding is always Unicode, so this field can be blank if (encobj->children() > 1) return_font.encoding = strdup(encobj->child(encobj->value())->label()); else return_font.encoding = 0; return_font.defined = true; } return return_font; }