- LyXFont font(LyXFont::ALL_IGNORE);
- font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
- ToggleAndShow(current_view, font);
-}
-
-
-void Sans()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setFamily(LyXFont::SANS_FAMILY);
- ToggleAndShow(current_view, font);
-}
-
-
-void Roman()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setFamily(LyXFont::ROMAN_FAMILY);
- ToggleAndShow(current_view, font);
-}
-
-
-void Tex()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setLatex (LyXFont::TOGGLE);
- ToggleAndShow(current_view, font);
-}
-
-void LangCB(string const & l)
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- Languages::iterator lit = languages.find(l);
- if (lit != languages.end()) {
- font.setLanguage(&(*lit).second);
- ToggleAndShow(current_view, font);
- } else
- WriteAlert(_("Error! unknown language"),l);
-}
-
-
-void StyleReset()
-{
- LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
- ToggleAndShow(current_view, font);
-}
-
-
-/* -------> Returns the current font and depth by printing a message. In the
- * future perhaps we could try to implement a callback to the button-bar.
- * That is, `light' the bold button when the font is currently bold, etc.
- */
-string CurrentState()
-{
- string state;
- if (current_view->available()) {
- // I think we should only show changes from the default
- // font. (Asger)
- Buffer * buffer = current_view->buffer();
- LyXFont font = current_view->text->real_current_font;
- LyXFont defaultfont = textclasslist.TextClass(buffer->
- params.textclass).defaultfont();
- font.reduce(defaultfont);
- state = _("Font: ") + font.stateText();
-
- int depth = current_view->text->GetDepth();
- if (depth > 0)
- state += string(_(", Depth: ")) + tostr(depth);
- }
- return state;
-}
-
-
-// candidate for move to BufferView
-/* -------> Does the actual toggle job of the XxxCB() calls above.
- * Also shows the current font state.
- */
-static
-void ToggleAndShow(BufferView * bv, LyXFont const & font)
-{
- if (bv->available()) {
- bv->hideCursor();
- bv->update(-2);
- if (bv->the_locking_inset)
- bv->the_locking_inset->SetFont(bv, font, toggleall);
- else
- bv->text->ToggleFree(font, toggleall);
- bv->update(1);
- }
-}
-
-
-// candidate for move to BufferView
-void Margin(BufferView * bv)
-{
- if (bv->available()) {
- bv->owner()->getMiniBuffer()->Set(_("Inserting margin note..."));
- bv->hideCursor();
- bv->update(-2);
- bv->text->InsertFootnoteEnvironment(LyXParagraph::MARGIN);
- bv->update(1);
- }
-}
-
-
-void Figure()
-{
- if (fd_form_figure->form_figure->visible) {
- fl_raise_form(fd_form_figure->form_figure);
- } else {
- fl_show_form(fd_form_figure->form_figure,
- FL_PLACE_MOUSE, FL_FULLBORDER,
- _("Insert Figure"));
- }
-}
-
-
-void Table()
-{
- if (fd_form_table->form_table->visible) {
- fl_raise_form(fd_form_table->form_table);
- } else {
- fl_show_form(fd_form_table->form_table,
- FL_PLACE_MOUSE, FL_FULLBORDER,
- _("Insert Table"));
- }
-}
-
-
-// candidate for move to BufferView
-void Melt(BufferView * bv)
-{
- if (!bv->available()) return;
-
- bv->owner()->getMiniBuffer()->Set(_("Melt"));
- bv->hideCursor();
- bv->beforeChange();
- bv->update(-2);
- bv->text->MeltFootnoteEnvironment();
- bv->update(1);
-}
-
-
-// candidate for move to BufferView
-// Change environment depth.
-// if decInc >= 0, increment depth
-// if decInc < 0, decrement depth
-void changeDepth(BufferView * bv, int decInc)
-{
- if (!bv->available()) return;
-
- bv->hideCursor();
- bv->update(-2);
- if (decInc >= 0)
- bv->text->IncDepth();
- else
- bv->text->DecDepth();
- bv->update(1);
- bv->owner()->getMiniBuffer()
- ->Set(_("Changed environment depth"
- " (in possible range, maybe not)"));
-}
-
-
-// This is both GUI and LyXFont dependent. Don't know where to put it. (Asger)
-// Well, it's mostly GUI dependent, so I guess it will stay here. (Asger)
-LyXFont UserFreeFont()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
-
- int pos = fl_get_choice(fd_form_character->choice_family);
- switch(pos) {
- case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break;
- case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break;
- case 3: font.setFamily(LyXFont::SANS_FAMILY); break;
- case 4: font.setFamily(LyXFont::TYPEWRITER_FAMILY); break;
- case 5: font.setFamily(LyXFont::INHERIT_FAMILY); break;
- }
-
- pos = fl_get_choice(fd_form_character->choice_series);
- switch(pos) {
- case 1: font.setSeries(LyXFont::IGNORE_SERIES); break;
- case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break;
- case 3: font.setSeries(LyXFont::BOLD_SERIES); break;
- case 4: font.setSeries(LyXFont::INHERIT_SERIES); break;
- }
-
- pos = fl_get_choice(fd_form_character->choice_shape);
- switch(pos) {
- case 1: font.setShape(LyXFont::IGNORE_SHAPE); break;
- case 2: font.setShape(LyXFont::UP_SHAPE); break;
- case 3: font.setShape(LyXFont::ITALIC_SHAPE); break;
- case 4: font.setShape(LyXFont::SLANTED_SHAPE); break;
- case 5: font.setShape(LyXFont::SMALLCAPS_SHAPE); break;
- case 6: font.setShape(LyXFont::INHERIT_SHAPE); break;
- }
-
- pos = fl_get_choice(fd_form_character->choice_size);
- switch(pos) {
- case 1: font.setSize(LyXFont::IGNORE_SIZE); break;
- case 2: font.setSize(LyXFont::SIZE_TINY); break;
- case 3: font.setSize(LyXFont::SIZE_SCRIPT); break;
- case 4: font.setSize(LyXFont::SIZE_FOOTNOTE); break;
- case 5: font.setSize(LyXFont::SIZE_SMALL); break;
- case 6: font.setSize(LyXFont::SIZE_NORMAL); break;
- case 7: font.setSize(LyXFont::SIZE_LARGE); break;
- case 8: font.setSize(LyXFont::SIZE_LARGER); break;
- case 9: font.setSize(LyXFont::SIZE_LARGEST); break;
- case 10: font.setSize(LyXFont::SIZE_HUGE); break;
- case 11: font.setSize(LyXFont::SIZE_HUGER); break;
- case 12: font.setSize(LyXFont::INCREASE_SIZE); break;
- case 13: font.setSize(LyXFont::DECREASE_SIZE); break;
- case 14: font.setSize(LyXFont::INHERIT_SIZE); break;
- }
-
- pos = fl_get_choice(fd_form_character->choice_bar);
- switch(pos) {
- case 1: font.setEmph(LyXFont::IGNORE);
- font.setUnderbar(LyXFont::IGNORE);
- font.setNoun(LyXFont::IGNORE);
- font.setLatex(LyXFont::IGNORE);
- break;
- case 2: font.setEmph(LyXFont::TOGGLE); break;
- case 3: font.setUnderbar(LyXFont::TOGGLE); break;
- case 4: font.setNoun(LyXFont::TOGGLE); break;
- case 5: font.setLatex(LyXFont::TOGGLE); break;
- case 6: font.setEmph(LyXFont::INHERIT);
- font.setUnderbar(LyXFont::INHERIT);
- font.setNoun(LyXFont::INHERIT);
- font.setLatex(LyXFont::INHERIT);
- break;
- }
-
- pos = fl_get_choice(fd_form_character->choice_color);
- switch(pos) {
- case 1: font.setColor(LColor::ignore); break;
- case 2: font.setColor(LColor::none); break;
- case 3: font.setColor(LColor::black); break;
- case 4: font.setColor(LColor::white); break;
- case 5: font.setColor(LColor::red); break;
- case 6: font.setColor(LColor::green); break;
- case 7: font.setColor(LColor::blue); break;
- case 8: font.setColor(LColor::cyan); break;
- case 9: font.setColor(LColor::magenta); break;
- case 10: font.setColor(LColor::yellow); break;
- case 11: font.setColor(LColor::inherit); break;
- }
-
- return font;
-}
-
-
-void Free()
-{
- ToggleAndShow(current_view, UserFreeFont());
-}
-
-
-/* callbacks for form form_title */
-extern "C" void TimerCB(FL_OBJECT *, long)
-{
- // only if the form still exists
- if (lyxrc.show_banner && fd_form_title->form_title != 0) {
- if (fd_form_title->form_title->visible) {
- fl_hide_form(fd_form_title->form_title);
- }
- fl_free_form(fd_form_title->form_title);
- fd_form_title->form_title = 0;
- }