- fl_set_form_minsize(fd_form_preamble->form_preamble,
- ow, oh);
- }
- }
-}
-
-
-void MenuLayoutSave()
-{
- if (!current_view->available())
- return;
-
- if (AskQuestion(_("Do you want to save the current settings"),
- _("for Character, Document, Paper and Quotes"),
- _("as default for new documents?")))
- current_view->buffer()->saveParamsAsDefaults();
-}
-
-
-// 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(BufferParams const & params)
-{
- 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;
- }
-
- int choice = combo_language2->get();
- if (choice == 1)
- font.setLanguage(ignore_language);
- else if (choice == 2)
- font.setLanguage(params.language_info);
- else
- font.setLanguage(&languages[combo_language2->getline()]);
-
- return font;
-}
-
-
-/* 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;
- }
-}
-
-
-/* callbacks for form form_paragraph */
-
-extern "C" void ParagraphVSpaceCB(FL_OBJECT * obj, long )
-{
- // "Synchronize" the choices and input fields, making it
- // impossible to commit senseless data.
-
- FD_form_paragraph const * fp = fd_form_paragraph;
-
- if (obj == fp->choice_space_above) {
- if (fl_get_choice (fp->choice_space_above) != 7) {
- fl_set_input (fp->input_space_above, "");
- ActivateParagraphButtons();
- }
- } else if (obj == fp->choice_space_below) {
- if (fl_get_choice (fp->choice_space_below) != 7) {
- fl_set_input (fp->input_space_below, "");
- ActivateParagraphButtons();
- }
- } else if (obj == fp->input_space_above) {
- string input = fl_get_input (fp->input_space_above);
-
- if (input.empty()) {
- fl_set_choice (fp->choice_space_above, 1);
- ActivateParagraphButtons();
- }
- else if (isValidGlueLength (input)) {
- fl_set_choice (fp->choice_space_above, 7);
- ActivateParagraphButtons();
- }
- else {
- fl_set_choice (fp->choice_space_above, 7);
- DeactivateParagraphButtons();
- }
- } else if (obj == fp->input_space_below) {
- string input = fl_get_input (fp->input_space_below);
-
- if (input.empty()) {
- fl_set_choice (fp->choice_space_below, 1);
- ActivateParagraphButtons();
- }
- else if (isValidGlueLength (input)) {
- fl_set_choice (fp->choice_space_below, 7);
- ActivateParagraphButtons();
- }
- else {
- fl_set_choice (fp->choice_space_below, 7);
- DeactivateParagraphButtons();
- }
- }
-}
-
-
-extern "C" void ParagraphApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->available())
- return;
-
- VSpace space_top, space_bottom;
- LyXAlignment align;
- string labelwidthstring;
- bool noindent;
-
- // If a vspace kind is "Length" but there's no text in
- // the input field, reset the kind to "None".
- if (fl_get_choice (fd_form_paragraph->choice_space_above) == 7
- && !*(fl_get_input (fd_form_paragraph->input_space_above))) {
- fl_set_choice (fd_form_paragraph->choice_space_above, 1);
- }
- if (fl_get_choice (fd_form_paragraph->choice_space_below) == 7
- && !*(fl_get_input (fd_form_paragraph->input_space_below))) {
- fl_set_choice (fd_form_paragraph->choice_space_below, 1);
- }
-
- bool line_top = fl_get_button(fd_form_paragraph->check_lines_top);
- bool line_bottom = fl_get_button(fd_form_paragraph->check_lines_bottom);
- bool pagebreak_top = fl_get_button(fd_form_paragraph->check_pagebreaks_top);
- bool pagebreak_bottom = fl_get_button(fd_form_paragraph->check_pagebreaks_bottom);
- switch (fl_get_choice (fd_form_paragraph->choice_space_above)) {
- case 1: space_top = VSpace(VSpace::NONE); break;
- case 2: space_top = VSpace(VSpace::DEFSKIP); break;
- case 3: space_top = VSpace(VSpace::SMALLSKIP); break;
- case 4: space_top = VSpace(VSpace::MEDSKIP); break;
- case 5: space_top = VSpace(VSpace::BIGSKIP); break;
- case 6: space_top = VSpace(VSpace::VFILL); break;
- case 7: space_top = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_above))); break;
- }
- if (fl_get_button (fd_form_paragraph->check_space_above))
- space_top.setKeep (true);
- switch (fl_get_choice (fd_form_paragraph->choice_space_below)) {
- case 1: space_bottom = VSpace(VSpace::NONE); break;
- case 2: space_bottom = VSpace(VSpace::DEFSKIP); break;
- case 3: space_bottom = VSpace(VSpace::SMALLSKIP); break;
- case 4: space_bottom = VSpace(VSpace::MEDSKIP); break;
- case 5: space_bottom = VSpace(VSpace::BIGSKIP); break;
- case 6: space_bottom = VSpace(VSpace::VFILL); break;
- case 7: space_bottom = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_below))); break;
- }
- if (fl_get_button (fd_form_paragraph->check_space_below))
- space_bottom.setKeep (true);
-
- if (fl_get_button(fd_form_paragraph->radio_align_left))
- align = LYX_ALIGN_LEFT;
- else if (fl_get_button(fd_form_paragraph->radio_align_right))
- align = LYX_ALIGN_RIGHT;
- else if (fl_get_button(fd_form_paragraph->radio_align_center))
- align = LYX_ALIGN_CENTER;
- else
- align = LYX_ALIGN_BLOCK;
-
- labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth);
- noindent = fl_get_button(fd_form_paragraph->check_noindent);
-
- current_view->text->SetParagraph(current_view,
- line_top,
- line_bottom,
- pagebreak_top,
- pagebreak_bottom,
- space_top,
- space_bottom,
- align,
- labelwidthstring,
- noindent);
- current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- current_view->owner()->getMiniBuffer()->Set(_("Paragraph layout set"));
-}
-
-
-extern "C" void ParagraphCancelCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_paragraph->form_paragraph);
-}
-
-
-extern "C" void ParagraphOKCB(FL_OBJECT *ob, long data)
-{
- ParagraphApplyCB(ob, data);
- ParagraphCancelCB(ob, data);
-}
-
-
-/* callbacks for form form_character */
-
-extern "C" void CharacterApplyCB(FL_OBJECT *, long)
-{
- // we set toggleall locally here, since it should be true for
- // all other uses of ToggleAndShow() (JMarc)
- toggleall = fl_get_button(fd_form_character->check_toggle_all);
- ToggleAndShow(current_view, UserFreeFont(current_view->buffer()->params));
- current_view->setState();
- toggleall = true;
-}
-
-
-extern "C" void CharacterCloseCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_character->form_character);
-}
-
-
-extern "C" void CharacterOKCB(FL_OBJECT *ob, long data)
-{
- CharacterApplyCB(ob, data);
- CharacterCloseCB(ob, data);
-}
-
-
-/* callbacks for form form_document */
-
-void UpdateDocumentButtons(BufferParams const & params)
-{
- fl_set_choice(fd_form_document->choice_pagestyle, 1);
-
- switch (params.sides) {
- case LyXTextClass::OneSide:
- fl_set_button(fd_form_document->radio_sides_one, 1);
- break;
- case LyXTextClass::TwoSides:
- fl_set_button(fd_form_document->radio_sides_two, 1);
- break;
- }
-
- if (params.columns == 2)
- fl_set_button(fd_form_document->radio_columns_two, 1);
- else
- fl_set_button(fd_form_document->radio_columns_one, 1);
-
- fl_set_input(fd_form_document->input_extra, params.options.c_str());
- fl_set_counter_value(fd_form_document->slider_secnumdepth,
- params.secnumdepth);
- fl_set_counter_value(fd_form_document->slider_tocdepth,
- params.tocdepth);
-
-}
-
-extern "C" void ChoiceClassCB(FL_OBJECT * ob, long)
-{
- ProhibitInput(current_view);
- if (textclasslist.Load(fl_get_choice(ob)-1)) {
- if (AskQuestion(_("Should I set some parameters to"),
- fl_get_choice_text(ob),
- _("the defaults of this document class?"))) {
- BufferParams params = BufferParams();
- params.textclass = fl_get_choice(ob)-1;
- params.useClassDefaults();
- UpdateLayoutDocument(¶ms);
- UpdateDocumentButtons(params);
- }
- } else {
- // unable to load new style
- WriteAlert(_("Conversion Errors!"),
- _("Unable to switch to new document class."),
- _("Reverting to original document class."));
- fl_set_choice(fd_form_document->choice_class,
- current_view->buffer()->params.textclass + 1);
- }
- AllowInput(current_view);
-}
-
-
-extern "C" void DocumentDefskipCB(FL_OBJECT * obj, long)
-{
- // "Synchronize" the choice and the input field, so that it
- // is impossible to commit senseless data.
- FD_form_document const * fd = fd_form_document;
-
- if (obj == fd->choice_default_skip) {
- if (fl_get_choice (fd->choice_default_skip) != 4) {
- fl_set_input (fd->input_default_skip, "");
- ActivateDocumentButtons();
- }
- } else if (obj == fd->input_default_skip) {
-
- char const * input = fl_get_input (fd->input_default_skip);
-
- if (!*input) {
- fl_set_choice (fd->choice_default_skip, 2);
- ActivateDocumentButtons();
- } else if (isValidGlueLength (input)) {
- fl_set_choice (fd->choice_default_skip, 4);
- ActivateDocumentButtons();
- } else {
- fl_set_choice (fd->choice_default_skip, 4);
- DeactivateDocumentButtons();
- }
- }
-}
-
-
-extern "C" void DocumentSpacingCB(FL_OBJECT * obj, long)
-{
- // "Synchronize" the choice and the input field, so that it
- // is impossible to commit senseless data.
- FD_form_document const * fd = fd_form_document;
-
- if (obj == fd->choice_spacing
- && fl_get_choice (fd->choice_spacing) != 4) {
- fl_set_input(fd->input_spacing, "");
- } else if (obj == fd->input_spacing) {
-
- const char* input = fl_get_input (fd->input_spacing);
-
- if (!*input) {
- fl_set_choice (fd->choice_spacing, 1);
- } else {
- fl_set_choice (fd->choice_spacing, 4);