- 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 = buffer->text->real_current_font;
- LyXFont defaultfont = textclasslist.TextClass(buffer->
- params.textclass).defaultfont();
- font.reduce(defaultfont);
- state = _("Font: ") + font.stateText();
-
- int depth = buffer->text->GetDepth();
- if (depth>0)
- state += string(_(", Depth: ")) + tostr(depth);
- }
- return state;
-}
-#endif
-
-// candidate for move to BufferView
-/* -------> Does the actual toggle job of the XxxCB() calls above.
- * Also shows the current font state.
- */
-static
-void ToggleAndShow(LyXFont const & font)
-{
- if (current_view->available()) {
- current_view->getScreen()->HideCursor();
-#ifdef MOVE_TEXT
- current_view->update(-2);
- current_view->text->ToggleFree(font, toggleall);
- current_view->update(1);
-#else
- current_view->buffer()->update(-2);
- current_view->buffer()->text->ToggleFree(font, toggleall);
- current_view->buffer()->update(1);
-#endif
- }
- // removed since it overrides the ToggleFree Message about the style
- // Since Styles are more "High Level" than raw fonts I think the user
- // prefers it like this Matthias
- // FontStateShowCB( 0, 0 );
-}
-
-
-// candidate for move to BufferView
-extern "C" void MarginCB(FL_OBJECT *, long)
-{
- if (current_view->available()) {
- minibuffer->Set(_("Inserting margin note..."));
- current_view->getScreen()->HideCursor();
-#ifdef MOVE_TEXT
- current_view->update(-2);
- current_view->text->InsertFootnoteEnvironment(LyXParagraph::MARGIN);
- current_view->update(1);
-#else
- current_view->buffer()->update(-2);
- current_view->buffer()->text->InsertFootnoteEnvironment(LyXParagraph::MARGIN);
- current_view->buffer()->update(1);
-#endif
- }
-}
-
-
-extern "C" void FigureCB(FL_OBJECT *, long)
-{
- 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"));
- }
-}
-
-
-extern "C" void TableCB(FL_OBJECT *, long)
-{
- 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 CopyEnvironmentCB()
-{
- if (current_view->available()) {
-#ifdef MOVE_TEXT
- current_view->text->copyEnvironmentType();
- /* clear the selection, even if mark_set */
- current_view->getScreen()->ToggleSelection();
- current_view->text->ClearSelection();
- current_view->update(-2);
- minibuffer->Set(_("Paragraph environment type copied"));
-#else
- current_view->buffer()->text->copyEnvironmentType();
- /* clear the selection, even if mark_set */
- current_view->getScreen()->ToggleSelection();
- current_view->buffer()->text->ClearSelection();
- current_view->buffer()->update(-2);
- minibuffer->Set(_("Paragraph environment type copied"));
-#endif
- }
-}
-
-
-// candidate for move to BufferView
-void PasteEnvironmentCB()
-{
- if (current_view->available()) {
-#ifdef MOVE_TEXT
- current_view->text->pasteEnvironmentType();
- minibuffer->Set(_("Paragraph environment type set"));
- current_view->update(1);
-#else
- current_view->buffer()->text->pasteEnvironmentType();
- minibuffer->Set(_("Paragraph environment type set"));
- current_view->buffer()->update(1);
-#endif
- }
-}
-
-
-// candidate for move to BufferView
-void CopyCB()
-{
- if (current_view->available()) {
-#ifdef MOVE_TEXT
- current_view->text->CopySelection();
- /* clear the selection, even if mark_set */
- current_view->getScreen()->ToggleSelection();
- current_view->text->ClearSelection();
- current_view->update(-2);
- minibuffer->Set(_("Copy"));
-#else
- current_view->buffer()->text->CopySelection();
- /* clear the selection, even if mark_set */
- current_view->getScreen()->ToggleSelection();
- current_view->buffer()->text->ClearSelection();
- current_view->buffer()->update(-2);
- minibuffer->Set(_("Copy"));
-#endif
- }
-}
-
-
-// candidate for move to BufferView
-void CutCB()
-{
- if (current_view->available()) {
- current_view->getScreen()->HideCursor();
-#ifdef MOVE_TEXT
- current_view->update(-2);
- current_view->text->CutSelection();
- current_view->update(1);
-#else
- current_view->buffer()->update(-2);
- current_view->buffer()->text->CutSelection();
- current_view->buffer()->update(1);
-#endif
- minibuffer->Set(_("Cut"));
- }
-}
-
-
-// candidate for move to BufferView
-void PasteCB()
-{
- if (!current_view->available()) return;
-
- minibuffer->Set(_("Paste"));
- current_view->getScreen()->HideCursor();
- /* clear the selection */
-#ifdef MOVE_TEXT
- current_view->getScreen()->ToggleSelection();
- current_view->text->ClearSelection();
- current_view->update(-2);
-
- /* paste */
- current_view->text->PasteSelection();
- current_view->update(1);
-
- /* clear the selection */
- current_view->getScreen()->ToggleSelection();
- current_view->text->ClearSelection();
- current_view->update(-2);
-#else
- current_view->getScreen()->ToggleSelection();
- current_view->buffer()->text->ClearSelection();
- current_view->buffer()->update(-2);
-
- /* paste */
- current_view->buffer()->text->PasteSelection();
- current_view->buffer()->update(1);
-
- /* clear the selection */
- current_view->getScreen()->ToggleSelection();
- current_view->buffer()->text->ClearSelection();
- current_view->buffer()->update(-2);
-#endif
-}
-
-
-// candidate for move to BufferView
-extern "C" void MeltCB(FL_OBJECT *, long)
-{
- if (!current_view->available()) return;
-
- minibuffer->Set(_("Melt"));
- current_view->getScreen()->HideCursor();
- BeforeChange();
-#ifdef MOVE_TEXT
- current_view->update(-2);
- current_view->text->MeltFootnoteEnvironment();
- current_view->update(1);
-#else
- current_view->buffer()->update(-2);
- current_view->buffer()->text->MeltFootnoteEnvironment();
- current_view->buffer()->update(1);
-#endif
-}
-
-
-// candidate for move to BufferView
-// Change environment depth.
-// if decInc == 0, depth change taking mouse button number into account
-// if decInc == 1, increment depth
-// if decInc == -1, decrement depth
-extern "C" void DepthCB(FL_OBJECT * ob, long decInc)
-{
- int button = 1;
-
- /* When decInc != 0, fake a mouse button. This allows us to
- implement depth-plus and depth-min commands. RVDK_PATCH_5. */
- /* check out wether ob is defined, too (Matthias) */
- if ( decInc < 0 )
- button = 0;
- else if (!decInc && ob) {
- button = fl_get_button_numb(ob);
- }
-
- if (current_view->available()) {
- current_view->getScreen()->HideCursor();
-#ifdef MOVE_TEXT
- current_view->update(-2);
- if (button == 1)
- current_view->text->IncDepth();
- else
- current_view->text->DecDepth();
- current_view->update(1);
-#else
- current_view->buffer()->update(-2);
- if (button == 1)
- current_view->buffer()->text->IncDepth();
- else
- current_view->buffer()->text->DecDepth();
- current_view->buffer()->update(1);
-#endif
- minibuffer->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(LyXFont::IGNORE_COLOR); break;
- case 2: font.setColor(LyXFont::NONE); break;
- case 3: font.setColor(LyXFont::BLACK); break;
- case 4: font.setColor(LyXFont::WHITE); break;
- case 5: font.setColor(LyXFont::RED); break;
- case 6: font.setColor(LyXFont::GREEN); break;
- case 7: font.setColor(LyXFont::BLUE); break;
- case 8: font.setColor(LyXFont::CYAN); break;
- case 9: font.setColor(LyXFont::MAGENTA); break;
- case 10: font.setColor(LyXFont::YELLOW); break;
- case 11: font.setColor(LyXFont::INHERIT_COLOR); break;
- }
-
- return font;
-}
-
-
-void FreeCB()
-{
- ToggleAndShow(UserFreeFont());
-}
-
-
-/* callbacks for form form_title */
-extern "C" void TimerCB(FL_OBJECT *, long)
-{
- // only if the form still exists
- if (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);
-
-#ifdef MOVE_TEXT
- current_view->text->SetParagraph(line_top,
- line_bottom,
- pagebreak_top,
- pagebreak_bottom,
- space_top,
- space_bottom,
- align,
- labelwidthstring,
- noindent);
- current_view->update(1);
-#else
- current_view->buffer()->text->SetParagraph(line_top,
- line_bottom,
- pagebreak_top,
- pagebreak_bottom,
- space_top,
- space_bottom,
- align,
- labelwidthstring,
- noindent);
- current_view->buffer()->update(1);
-#endif
- minibuffer->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( UserFreeFont());
- 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);
-
- if (params.sides == 2)
- fl_set_button(fd_form_document->radio_sides_two, 1);
- else
- fl_set_button(fd_form_document->radio_sides_one, 1);
-
- 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();
- 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,
- GetCurrentTextClass() + 1);
- }
- AllowInput();
-}
-
-
-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);
- }
- }
-}
-
-
-extern "C" void DocumentApplyCB(FL_OBJECT *, long)
-{
- bool redo = false;
- BufferParams *params = &(current_view->buffer()->params);
- current_view->buffer()->params.language =
- combo_language->getline();
-
- // If default skip is a "Length" but there's no text in the
- // input field, reset the kind to "Medskip", which is the default.
- if (fl_get_choice (fd_form_document->choice_default_skip) == 4
- && !*(fl_get_input (fd_form_document->input_default_skip))) {
- fl_set_choice (fd_form_document->choice_default_skip, 2);
- }
-
- /* this shouldn't be done automatically IMO. For example I write german
- * documents with an american keyboard very often. Matthias */
-
- /* ChangeKeymap(buffer->parameters.language, TRUE, false,
- fl_get_choice(fd_form_document->choice_language)); */
- params->fonts =
- fl_get_choice_text(fd_form_document->choice_fonts);
- params->inputenc =
- fl_get_choice_text(fd_form_document->choice_inputenc);
- params->fontsize =
- fl_get_choice_text(fd_form_document->choice_fontsize);
- params->pagestyle =
- fl_get_choice_text(fd_form_document->choice_pagestyle);
- params->graphicsDriver =
- fl_get_choice_text(fd_form_document->choice_postscript_driver);
- params->use_amsmath =
- fl_get_button(fd_form_document->check_use_amsmath);
-
- if (!current_view->available())
- return;
-
- LyXTextClassList::ClassList::size_type new_class = fl_get_choice(fd_form_document->choice_class) - 1;
- if (params->textclass != new_class) {
- // try to load new_class
- if (textclasslist.Load(new_class)) {
- // successfully loaded
- redo = true;
- minibuffer->Set(_("Converting document to new document class..."));
-#ifdef MOVE_TEXT
- int ret = current_view->text->
- SwitchLayoutsBetweenClasses(current_view->buffer()->
- params.textclass,
- new_class,
- current_view->buffer()->
- paragraph);
-#else
- int ret = current_view->buffer()->
- text->
- SwitchLayoutsBetweenClasses(current_view->buffer()->
- params.textclass,
- new_class,
- current_view->buffer()->
- paragraph);
-#endif
-
- if (ret){
- string s;
- if (ret == 1)
- s = _("One paragraph couldn't be converted");
- else {
- s += tostr(ret);
- s += _(" paragraphs couldn't be converted");
- }
- WriteAlert(_("Conversion Errors!"), s,
- _("into chosen document class"));
- }
-
- params->textclass = new_class;
- } else {
- // problem changing class -- warn user and retain old style
- WriteAlert(_("Conversion Errors!"),
- _("Unable to switch to new document class."),
- _("Reverting to original document class."));
- fl_set_choice(fd_form_document->choice_class, params->textclass + 1);
- }
- }
-
- char tmpsep = params->paragraph_separation;
- if (fl_get_button(fd_form_document->radio_indent))
- params->paragraph_separation = BufferParams::PARSEP_INDENT;
- else
- params->paragraph_separation = BufferParams::PARSEP_SKIP;
- if (tmpsep != params->paragraph_separation)
- redo = true;
-
- VSpace tmpdefskip = params->getDefSkip();
- switch (fl_get_choice (fd_form_document->choice_default_skip)) {
- case 1: params->setDefSkip(VSpace(VSpace::SMALLSKIP)); break;
- case 2: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
- case 3: params->setDefSkip(VSpace(VSpace::BIGSKIP)); break;
- case 4: params->setDefSkip(
- VSpace (LyXGlueLength (fl_get_input
- (fd_form_document->input_default_skip))));
- break;
- // DocumentDefskipCB assures that this never happens
- default: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
- }
- if (!(tmpdefskip == params->getDefSkip()))
- redo = true;
-
- if (fl_get_button(fd_form_document->radio_columns_two))
- params->columns = 2;
- else
- params->columns = 1;
- if (fl_get_button(fd_form_document->radio_sides_two))
- params->sides = LyXTextClass::TwoSides;
- else
- params->sides = LyXTextClass::OneSide;
-
- Spacing tmpSpacing = params->spacing;
- switch(fl_get_choice(fd_form_document->choice_spacing)) {
- case 1:
- lyxerr.debug() << "Spacing: SINGLE" << endl;
- params->spacing.set(Spacing::Single);
- break;
- case 2:
- lyxerr.debug() << "Spacing: ONEHALF" << endl;
- params->spacing.set(Spacing::Onehalf);
- break;
- case 3:
- lyxerr.debug() << "Spacing: DOUBLE" << endl;
- params->spacing.set(Spacing::Double);
- break;
- case 4:
- lyxerr.debug() << "Spacing: OTHER" << endl;
- params->spacing.set(Spacing::Other,
- fl_get_input(fd_form_document->input_spacing));
- break;
- }
- if (tmpSpacing != params->spacing)
- redo = true;
-
- signed char tmpchar =
- static_cast<signed char>(fl_get_counter_value(fd_form_document->slider_secnumdepth));
- if (params->secnumdepth != tmpchar)
- redo = true;
- params->secnumdepth = tmpchar;
-
- params->tocdepth =
- static_cast<int>(fl_get_counter_value(fd_form_document->slider_tocdepth));
-
- params->float_placement =
- fl_get_input(fd_form_document->input_float_placement);
-
- // More checking should be done to ensure the string doesn't have
- // spaces or illegal placement characters in it. (thornley)
-
- if (redo)
- current_view->redoCurrentBuffer();
-
- minibuffer->Set(_("Document layout set"));
- current_view->buffer()->markDirty();
-
- params->options =
- fl_get_input(fd_form_document->input_extra);
-
-}
-
-
-extern "C" void DocumentCancelCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_document->form_document);
-}
-
-
-extern "C" void DocumentOKCB(FL_OBJECT * ob, long data)
-{
- DocumentCancelCB(ob, data);
- DocumentApplyCB(ob, data);
-}
-
-
-extern "C" void DocumentBulletsCB(FL_OBJECT *, long)
-{
- bulletForm();
- // bullet callbacks etc. in bullet_panel.C -- ARRae
-}
-
-
-// candidate for move to BufferView
-#ifdef MOVE_TEXT
-void GotoNote()
-{
- if (!current_view->getScreen())
- return;
-
- current_view->getScreen()->HideCursor();
- BeforeChange();
- current_view->update(-2);
- LyXCursor tmp;
-
- if (!current_view->text->GotoNextNote()) {
- if (current_view->text->cursor.pos
- || current_view->text->cursor.par !=
- current_view->text->FirstParagraph())
- {
- tmp = current_view->text->cursor;
- current_view->text->cursor.par =
- current_view->text->FirstParagraph();
- current_view->text->cursor.pos = 0;
- if (!current_view->text->GotoNextNote()) {
- current_view->text->cursor = tmp;
- minibuffer->Set(_("No more notes"));
- LyXBell();
- }
- } else {
- minibuffer->Set(_("No more notes"));
- LyXBell();
- }
- }
- current_view->update(0);
- current_view->text->sel_cursor =
- current_view->text->cursor;
-}
-#else
-void GotoNote()
-{
- if (!current_view->getScreen())
- return;
-
- current_view->getScreen()->HideCursor();
- BeforeChange();
- current_view->buffer()->update(-2);
- LyXCursor tmp;
-
- if (!current_view->buffer()->text->GotoNextNote()) {
- if (current_view->buffer()->text->cursor.pos
- || current_view->buffer()->text->cursor.par !=
- current_view->buffer()->text->FirstParagraph())
- {
- tmp = current_view->buffer()->text->cursor;
- current_view->buffer()->text->cursor.par =
- current_view->buffer()->text->FirstParagraph();
- current_view->buffer()->text->cursor.pos = 0;
- if (!current_view->buffer()->text->GotoNextNote()) {
- current_view->buffer()->text->cursor = tmp;
- minibuffer->Set(_("No more notes"));
- LyXBell();
- }
- } else {
- minibuffer->Set(_("No more notes"));
- LyXBell();
- }
- }
- current_view->buffer()->update(0);
- current_view->buffer()->text->sel_cursor =
- current_view->buffer()->text->cursor;
-}
-#endif
-
-// candidate for move to BufferView
-void InsertCorrectQuote()
-{
- Buffer * cbuffer = current_view->buffer();
- char c;
-
-#ifdef MOVE_TEXT
- if (current_view->text->cursor.pos )
- c = current_view->text->cursor.par->GetChar(current_view->text->cursor.pos - 1);
- else
- c = ' ';
-#else
- if (cbuffer->text->cursor.pos )
- c = cbuffer->text->cursor.par->GetChar(cbuffer->text->cursor.pos - 1);
- else
- c = ' ';
-#endif
-
- cbuffer->insertInset(new InsetQuotes(c, cbuffer->params));
-}
-
-
-/* callbacks for form form_quotes */
-
-extern "C" void QuotesApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->available())
- return;
-
- minibuffer->Set(_("Quotes type set"));
- //current_view->buffer()->params.quotes_language =
- // fl_get_choice(fd_form_quotes->choice_quotes_language) - 1;
- InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
- switch(fl_get_choice(fd_form_quotes->choice_quotes_language) - 1) {
- case 0:
- lga = InsetQuotes::EnglishQ;
- break;
- case 1:
- lga = InsetQuotes::SwedishQ;
- break;
- case 2:
- lga = InsetQuotes::GermanQ;
- break;
- case 3:
- lga = InsetQuotes::PolishQ;
- break;
- case 4:
- lga = InsetQuotes::FrenchQ;
- break;
- case 5:
- lga = InsetQuotes::DanishQ;
- break;
- }
- current_view->buffer()->params.quotes_language = lga;
- if (fl_get_button(fd_form_quotes->radio_single))
- current_view->buffer()->
- params.quotes_times = InsetQuotes::SingleQ;
- else
- current_view->buffer()->
- params.quotes_times = InsetQuotes::DoubleQ;
-}
-
-
-extern "C" void QuotesCancelCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_quotes->form_quotes);
-}
-
-
-extern "C" void QuotesOKCB(FL_OBJECT * ob, long data)
-{
- QuotesApplyCB(ob, data);
- QuotesCancelCB(ob, data);
-}
-
-
-
-/* callbacks for form form_preamble */
-
-extern "C" void PreambleCancelCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_preamble->form_preamble);
-}
-
-
-extern "C" void PreambleApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->available())
- return;
-
- current_view->buffer()->params.preamble =
- fl_get_input(fd_form_preamble->input_preamble);
- current_view->buffer()->markDirty();
- minibuffer->Set(_("LaTeX preamble set"));
-}
-
-
-extern "C" void PreambleOKCB(FL_OBJECT * ob, long data)
-{
- PreambleApplyCB(ob, data);
- PreambleCancelCB(ob, data);
-}
-
-
-/* callbacks for form form_table */
-
-#ifdef MOVE_TEXT
-extern "C" void TableApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->getScreen())
- return;
-
- // check for tables in tables
- if (current_view->text->cursor.par->table){
- WriteAlert(_("Impossible Operation!"),
- _("Cannot insert table in table."),
- _("Sorry."));
- return;
- }
-
- minibuffer->Set(_("Inserting table..."));
-
- int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
- int xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5);
-
-
- current_view->getScreen()->HideCursor();
- BeforeChange();
- current_view->update(-2);
-
- current_view->text->SetCursorParUndo();
- current_view->text->FreezeUndo();
-
- current_view->text->BreakParagraph();
- current_view->update(-1);
-
- if (current_view->text->cursor.par->Last()) {
- current_view->text->CursorLeft();
-
- current_view->text->BreakParagraph();
- current_view->update(-1);
- }
-
- current_view->text->current_font.setLatex(LyXFont::OFF);
- //if (!fl_get_button(fd_form_table->check_latex)){
- // insert the new wysiwy table
- current_view->text->SetLayout(0); // standard layout
- if (current_view->text->cursor.par->footnoteflag ==
- LyXParagraph::NO_FOOTNOTE) {
- current_view->text
- ->SetParagraph(0, 0,
- 0, 0,
- VSpace (0.3 * current_view->buffer()->
- params.spacing.getValue(),
- LyXLength::CM),
- VSpace (0.3 * current_view->buffer()->
- params.spacing.getValue(),
- LyXLength::CM),
- LYX_ALIGN_CENTER,
- string(),
- 0);
- }
- else
- current_view->text
- ->SetParagraph(0, 0,
- 0, 0,
- VSpace(VSpace::NONE),
- VSpace(VSpace::NONE),
- LYX_ALIGN_CENTER,
- string(),
- 0);
-
- current_view->text->cursor.par->table =
- new LyXTable(xsize, ysize);
-
- for (int i = 0; i < xsize * ysize - 1; ++i)
- current_view->text->cursor.par->InsertChar(0, LyXParagraph::META_NEWLINE);
- current_view->text->RedoParagraph();
-
- current_view->text->UnFreezeUndo();
-
- current_view->update(1);
- minibuffer->Set(_("Table inserted"));
-}
-#else
-extern "C" void TableApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->getScreen())
- return;
-
- // check for tables in tables
- if (current_view->buffer()->text->cursor.par->table){
- WriteAlert(_("Impossible Operation!"),
- _("Cannot insert table in table."),
- _("Sorry."));
- return;
- }
-
- minibuffer->Set(_("Inserting table..."));
-
- int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
- int xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5);
-
-
- current_view->getScreen()->HideCursor();
- BeforeChange();
- current_view->buffer()->update(-2);
-
- current_view->buffer()->text->SetCursorParUndo();
- current_view->buffer()->text->FreezeUndo();
-
- current_view->buffer()->text->BreakParagraph();
- current_view->buffer()->update(-1);
-
- if (current_view->buffer()->text->cursor.par->Last()) {
- current_view->buffer()->text->CursorLeft();
-
- current_view->buffer()->text->BreakParagraph();
- current_view->buffer()->update(-1);
- }
-
- current_view->buffer()->text->current_font.setLatex(LyXFont::OFF);
- //if (!fl_get_button(fd_form_table->check_latex)){
- // insert the new wysiwy table
- current_view->buffer()->text->SetLayout(0); // standard layout
- if (current_view->buffer()->text->cursor.par->footnoteflag ==
- LyXParagraph::NO_FOOTNOTE) {
- current_view->buffer()->
- text->SetParagraph(0, 0,
- 0, 0,
- VSpace (0.3 * current_view->buffer()->
- params.spacing.getValue(),
- LyXLength::CM),
- VSpace (0.3 * current_view->buffer()->
- params.spacing.getValue(),
- LyXLength::CM),
- LYX_ALIGN_CENTER,
- string(),
- 0);
- }
- else
- current_view->buffer()->
- text->SetParagraph(0, 0,
- 0, 0,
- VSpace(VSpace::NONE),
- VSpace(VSpace::NONE),
- LYX_ALIGN_CENTER,
- string(),
- 0);
-
- current_view->buffer()->text->cursor.par->table =
- new LyXTable(xsize, ysize);
-
- for (int i = 0; i < xsize * ysize - 1; ++i)
- current_view->buffer()->text->cursor.par->InsertChar(0, LyXParagraph::META_NEWLINE);
- current_view->buffer()->text->RedoParagraph();
-
- current_view->buffer()->text->UnFreezeUndo();
-
- current_view->buffer()->update(1);
- minibuffer->Set(_("Table inserted"));
-}
-#endif
-
-extern "C" void TableCancelCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_table->form_table);
-}
-
-
-extern "C" void TableOKCB(FL_OBJECT * ob, long data)
-{
- TableApplyCB(ob, data);
- TableCancelCB(ob, data);
-}
-
-
-/* callbacks for form form_print */
-
-extern "C" void PrintCancelCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_print->form_print);
-}
-
-static bool stringOnlyContains (string const & LStr, char const * cset)
-{
- char const * cstr = LStr.c_str() ;
-
- return strspn(cstr, cset) == strlen(cstr) ;
-}
-
-extern "C" void PrintApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->available())
- return;
- Buffer * buffer = current_view->buffer();
- string path = OnlyPath(buffer->fileName());
-
- string pageflag;
- if (fl_get_button(fd_form_print->radio_even_pages))
- pageflag = lyxrc->print_evenpage_flag + ' ';
- else if (fl_get_button(fd_form_print->radio_odd_pages))
- pageflag = lyxrc->print_oddpage_flag + ' ';
-
-// Changes by Stephan Witt (stephan.witt@beusen.de), 19-Jan-99
-// User may give a page (range) list
-// User may print multiple (unsorted) copies
- string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
- pages = subst(pages, '+',',');
- pages = frontStrip(strip(pages)) ;
- while (!pages.empty()) { // a page range was given
- string piece ;
- pages = split (pages, piece, ',') ;
- piece = strip(piece) ;
- piece = frontStrip(piece) ;
- if ( !stringOnlyContains (piece, "0123456789-") ) {
- WriteAlert(_("ERROR! Unable to print!"),
- _("Check 'range of pages'!"));
- return;
- }
- if (piece.find('-') == string::npos) { // not found
- pageflag += lyxrc->print_pagerange_flag + piece + '-' + piece + ' ' ;
- } else if (suffixIs(piece, "-") ) { // missing last page
- pageflag += lyxrc->print_pagerange_flag + piece + "1000 ";
- } else if (prefixIs(piece, "-") ) { // missing first page
- pageflag += lyxrc->print_pagerange_flag + '1' + piece + ' ' ;
- } else {
- pageflag += lyxrc->print_pagerange_flag + piece + ' ' ;
- }
- }
-
- string copies = frontStrip(strip(fl_get_input(fd_form_print->input_copies)));
- if (!copies.empty()) { // a number of copies was given
- if ( !stringOnlyContains (copies, "0123456789") ) {
- WriteAlert(_("ERROR! Unable to print!"),
- _("Check 'number of copies'!"));
- return;
- }
- if (fl_get_button(fd_form_print->do_unsorted))
- pageflag += lyxrc->print_copies_flag;
- else
- pageflag += lyxrc->print_collcopies_flag;
- pageflag += " " + copies + ' ' ;
- }
-
- string reverseflag;
- if (fl_get_button(fd_form_print->radio_order_reverse))
- reverseflag = lyxrc->print_reverse_flag + ' ';
-
- string orientationflag;
- if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
- orientationflag = lyxrc->print_landscape_flag + ' ';
-
- string ps_file = fl_get_input(fd_form_print->input_file);
- string printer = strip(fl_get_input(fd_form_print->input_printer));
-
- string printerflag;
- if (lyxrc->print_adapt_output // printer name should be passed to dvips
- && ! printer.empty()) // a printer name has been given
- printerflag = lyxrc->print_to_printer + printer + ' ';
-
- string extraflags;
- if (!lyxrc->print_extra_options.empty())
- extraflags = lyxrc->print_extra_options + ' ';
-
- string command = lyxrc->print_command + ' '
- + printerflag + pageflag + reverseflag
- + orientationflag + extraflags;
-
- char real_papersize = buffer->params.papersize;
- if (real_papersize == BufferParams::PAPER_DEFAULT)
- real_papersize = lyxrc->default_papersize;
-
- string paper;
- switch (real_papersize) {
- case BufferParams::PAPER_USLETTER:
- paper = "letter";
- break;
- case BufferParams::PAPER_A3PAPER:
- paper = "a3";
- break;
- case BufferParams::PAPER_A4PAPER:
- paper = "a4";
- break;
- case BufferParams::PAPER_A5PAPER:
- paper = "a5";
- break;
- case BufferParams::PAPER_B5PAPER:
- paper = "b5";
- break;
- case BufferParams::PAPER_EXECUTIVEPAPER:
- paper = "foolscap";
- break;
- case BufferParams::PAPER_LEGALPAPER:
- paper = "legal";
- break;
- default: /* If nothing else fits, keep an empty value... */
- break;
- }
-
- if (buffer->params.use_geometry
- && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
- && !lyxrc->print_paper_dimension_flag.empty()
- && !buffer->params.paperwidth.empty()
- && !buffer->params.paperheight.empty()) {
- // using a custom papersize
- command += ' ';
- command += lyxrc->print_paper_dimension_flag + ' ';
- command += buffer->params.paperwidth + ',';
- command += buffer->params.paperheight + ' ';
- } else if (!lyxrc->print_paper_flag.empty()
- && !paper.empty()
- && (real_papersize != BufferParams::PAPER_USLETTER ||
- buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) {
- command += " " + lyxrc->print_paper_flag + " " + paper + " ";
- }
- if (fl_get_button(fd_form_print->radio_file))
- command += lyxrc->print_to_file
- + QuoteName(MakeAbsPath(ps_file, path));
- else if (!lyxrc->print_spool_command.empty())
- command += lyxrc->print_to_file
- + QuoteName(ps_file);
-
- // push directorypath, if necessary
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
- path = buffer->tmppath;
- }
- Path p(path);
-
- bool result;
- if (!lyxrc->print_spool_command.empty() &&
- !fl_get_button(fd_form_print->radio_file)) {
- string command2 = lyxrc->print_spool_command + ' ';
- if (!printer.empty())
- command2 += lyxrc->print_spool_printerprefix
- + printer;
- // First run dvips and, if succesful, then spool command
- if ((result = RunScript(buffer, true, command))) {
- result = RunScript(buffer, false, command2, ps_file);