/**
* \file QDocument.C
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * \author Kalle Dalheimer <kalle@klaralvdalens-datakonsult.se>
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS
*/
#include <config.h>
-#ifdef __GNUG_
+#ifdef __GNUG__
#pragma implementation
#endif
+#include "gettext.h"
+
+#include "ControlDocument.h"
#include "QDocument.h"
#include "QDocumentDialog.h"
+#include "Qt2BC.h"
-#include "lyx_gui_misc.h"
-
-#include "Dialogs.h"
-#include "layout.h"
-#include "tex-strings.h"
-#include "bufferparams.h"
+#include "language.h"
+#include "helper_funcs.h" // getSecond()
#include "insets/insetquotes.h"
+#include "frnt_lang.h"
+#include "tex-strings.h" // tex_graphics
+#include "support/lstrings.h" // tostr()
+#include "support/filetools.h" // LibFileSearch()
+#include "lyxtextclasslist.h"
#include "vspace.h"
-#include "support/filetools.h"
-#include "language.h"
-#include "BufferView.h"
-#include "buffer.h"
-#include "Liason.h"
-#include "CutAndPaste.h"
-#include "bufferview_funcs.h"
+#include "bufferparams.h"
-#include <qcombobox.h>
-#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qmultilineedit.h>
#include <qradiobutton.h>
+#include <qcombobox.h>
+#include <qcheckbox.h>
#include <qspinbox.h>
+#include <qlineedit.h>
+#include <qstringlist.h>
+#include "lengthcombo.h"
+
+#include "QBrowseBox.h"
-using Liason::setMinibuffer;
-using SigC::slot;
+#include <vector>
+
+using std::vector;
typedef Qt2CB<ControlDocument, Qt2DB<QDocumentDialog> > base_class;
-#if 0
-QDocument::QDocument(ControlDocument & c)
- : base_class(c, _("Document Settings"))
-{
-}
-#else
-QDocument::QDocument(LyXView *, Dialogs *)
+QDocument::QDocument()
+ : base_class(_("Document Settings"))
{
+ vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
+ lang_ = getSecond(langs);
}
-#endif
void QDocument::build_dialog()
{
- // the tabbed folder
- //dialog_.reset(new QDocumentDialog());
-
-#if 0
- // Manage the restore, ok, apply, restore and cancel/close buttons
- bc().setOK(dialog_->okPB);
- bc().setApply(dialog_->applyPB);
- bc().setCancel(dialog_->cancelPB);
- bc().setRestore(dialog_->restorePB);
- bc().refresh();
-
- // the document paper page
- QDocumentDialog * dialog = dialog_.get();
- dialog->papersize2CO->insertItem( _( "Default" ) );
- dialog->papersize2CO->insertItem( _( "Custom" ) );
- dialog->papersize2CO->insertItem( _( "USletter" ) );
- dialog->papersize2CO->insertItem( _( "USlegal" ) );
- dialog->papersize2CO->insertItem( _( "USexecutive" ) );
- dialog->papersize2CO->insertItem( _( "A3" ) );
- dialog->papersize2CO->insertItem( _( "A4" ) );
- dialog->papersize2CO->insertItem( _( "A5" ) );
- dialog->papersize2CO->insertItem( _( "B3" ) );
- dialog->papersize2CO->insertItem( _( "B4" ) );
- dialog->papersize2CO->insertItem( _( "B5" ) );
-
- dialog->paperPackageCO->insertItem( _( "None" ) );
- dialog->paperPackageCO->insertItem( _( "A4 small Margins (only portrait)" ) );
- dialog->paperPackageCO->insertItem( _( "A4 very small Margins (only portrait)" ) );
- dialog->paperPackageCO->insertItem( _( "A4 very wide margins (only portrait)" ) );
-
- bc().addReadOnly (dialog->paperPackageCO);
- bc().addReadOnly (dialog->orientationBG);
- bc().addReadOnly (dialog->portraitRB);
- bc().addReadOnly (dialog->landscapeRB);
- bc().addReadOnly (dialog->papersize2CO);
- bc().addReadOnly (dialog->useGeometryCB);
- bc().addReadOnly (dialog->customWidthED);
- bc().addReadOnly (dialog->customHeightED);
- bc().addReadOnly (dialog->topMarginED);
- bc().addReadOnly (dialog->bottomMarginED);
- bc().addReadOnly (dialog->leftMarginED);
- bc().addReadOnly (dialog->rightMarginED);
- bc().addReadOnly (dialog->headHeightED);
- bc().addReadOnly (dialog->headSepED);
- bc().addReadOnly (dialog->footSkipED);
-
- // the document page
- for (LyXTextClassList::const_iterator cit = textclasslist.begin();
- cit != textclasslist.end(); ++cit) {
- docClassCO->insertItem( (*cit).description().c_str() );
+ dialog_.reset(new QDocumentDialog(this));
+
+ // biblio
+ dialog_->biblioModule->citeStyleCO->insertItem(_("Author-year"));
+ dialog_->biblioModule->citeStyleCO->insertItem(_("Numerical"));
+ dialog_->biblioModule->citeStyleCO->setCurrentItem(0);
+
+ // language & quotes
+ vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
+ vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
+ vector<frnt::LanguagePair>::const_iterator lend = langs.end();
+ for (; lit != lend; ++lit) {
+ dialog_->langModule->languageCO->insertItem(
+ lit->first.c_str());
}
- dialog->docSpacingCO->insertItem( _( "Single" ) );
- dialog->docSpacingCO->insertItem( _( "OneHalf" ) );
- dialog->docSpacingCO->insertItem( _( "Double" ) );
- dialog->docSpacingCO->insertItem( _( "Other" ) );
-
- dialog->docFontSizeCO->insertItem( _( "default" ) );
- dialog->docFontSizeCO->insertItem( _( "10" ) );
- dialog->docFontSizeCO->insertItem( _( "11" ) );
- dialog->docFontSizeCO->insertItem( _( "12" ) );
- for (int n=0; tex_fonts[n][0]; ++n) {
- dialog->docFontsCO->insertItem( tex_fonts[n] );
+ dialog_->langModule->quoteStyleCO->insertItem(_("``text''"));
+ dialog_->langModule->quoteStyleCO->insertItem(_("''text''"));
+ dialog_->langModule->quoteStyleCO->insertItem(_(",,text``"));
+ dialog_->langModule->quoteStyleCO->insertItem(_(",,text''"));
+ dialog_->langModule->quoteStyleCO->insertItem(_("«text»"));
+ dialog_->langModule->quoteStyleCO->insertItem(_("»text«"));
+
+ // packages
+ char const * items[] = {"default", "auto", "latin1", "latin2",
+ "latin3", "latin4", "latin5", "latin9",
+ "koi8-r", "koi8-u", "cp866", "cp1251",
+ "iso88595", "pt154", 0};
+ dialog_->packagesModule->encodingCO->insertStrList(items);
+
+ dialog_->packagesModule->lspacingCO->insertItem(
+ _("Single"), Spacing::Single);
+ dialog_->packagesModule->lspacingCO->insertItem(
+ _("OneHalf"), Spacing::Onehalf);
+ dialog_->packagesModule->lspacingCO->insertItem(
+ _("Double"), Spacing::Double);
+ dialog_->packagesModule->lspacingCO->insertItem(
+ _("Custom"), Spacing::Other);
+
+ for (int n = 0; tex_graphics[n][0]; ++n) {
+ QString enc = tex_graphics[n];
+ dialog_->packagesModule->psdriverCO->insertItem(enc);
}
- dialog->docPagestyleCO->insertItem( _( "default" ) );
- dialog->docPagestyleCO->insertItem( _( "empty" ) );
- dialog->docPagestyleCO->insertItem( _( "plain" ) );
- dialog->docPagestyleCO->insertItem( _( "headings" ) );
- dialog->docPagestyleCO->insertItem( _( "fancy" ) );
-
- dialog->docSkipCO->insertItem( _( "Smallskip" ) );
- dialog->docSkipCO->insertItem( _( "Medskip" ) );
- dialog->docSkipCO->insertItem( _( "Bigskip" ) );
- dialog->docSkipCO->insertItem( _( "Length" ) );
-
- bc().addReadOnly (dialog->docIndentRB);
- bc().addReadOnly (dialog->docSkipRB);
-
- bc().addReadOnly (dialog->docPagestyleCO);
- bc().addReadOnly (dialog->docFontsCO);
- bc().addReadOnly (dialog->docFontsizeCO);
- bc().addReadOnly (dialog->docSidesOneRB);
- bc().addReadOnly (dialog->docSidesTwoRB);
- bc().addReadOnly (dialog->docColumnsOneRB);
- bc().addReadOnly (dialog->docColumnsTwoRB);
- bc().addReadOnly (dialog->docExtraED);
- bc().addReadOnly (dialog->docSkipED);
- bc().addReadOnly (dialog->docSkipCO);
- bc().addReadOnly (dialog->docSpacingCO);
- bc().addReadOnly (dialog->docSpacingED);
-
- // the document language page
- dialog->inputEncCO->insertItem( _( "default" ) );
- dialog->inputEncCO->insertItem( _( "auto" ) );
- dialog->inputEncCO->insertItem( _( "latin1" ) );
- dialog->inputEncCO->insertItem( _( "latin2" ) );
- dialog->inputEncCO->insertItem( _( "latin3" ) );
- dialog->inputEncCO->insertItem( _( "latin4" ) );
- dialog->inputEncCO->insertItem( _( "latin5" ) );
- dialog->inputEncCO->insertItem( _( "latin9" ) );
- dialog->inputEncCO->insertItem( _( "koi8-r" ) );
- dialog->inputEncCO->insertItem( _( "koi8-u" ) );
- dialog->inputEncCO->insertItem( _( "cp866" ) );
- dialog->inputEncCO->insertItem( _( "cp1251" ) );
- dialog->inputEncCO->insertItem( _( "iso88595" ) );
-
- for (Languages::const_iterator cit = languages.begin();
- cit != languages.end(); ++cit) {
- dialog->languageCO->insertItem( (*cit).second.lang() );
+ // paper
+ char const * sizes[] = {
+ _("Default") , _("Custom") , _("US letter") , _("US legal")
+ , _("US executive") , _("A3") , _("A4") , _("A5")
+ , _("B3") , _("B4") , _("B5"), 0 };
+ dialog_->paperModule->papersizeCO->insertStrList(sizes);
+
+ // layout
+ for (LyXTextClassList::const_iterator cit = textclasslist.begin();
+ cit != textclasslist.end(); ++cit) {
+ dialog_->layoutModule->classCO->insertItem(cit->description().c_str());
}
- dialog->quotesLanguageCO->insertItem( _( "``text''" ) );
- dialog->quotesLanguageCO->insertItem( _( "''text''" ) );
- dialog->quotesLanguageCO->insertItem( _( ",,text``" ) );
- dialog->quotesLanguageCO->insertItem( _( ",,text''" ) );
- dialog->quotesLanguageCO->insertItem( _( "«text»" ) );
- dialog->quotesLanguageCO->insertItem( _( "»text«" ) );
-
- bc().addReadOnly (dialog->inputEncCO);
-
- // the document options page
- dialog->secNumDepthSB->setRange( -2, 5 );
- dialog->tocDepthSB->setRange( -1, 5 );
- dialog->secNumDepthSB->setSteps( 1, 1 );
- dialog->tocDepthSB->setRange( 1, 1 );
- for (int n=0; tex_graphics[n][0]; ++n) {
- dialog->postscriptDriverCO->insertItem( tex_graphics[n] );
+ for (int n = 0; tex_fonts[n][0]; ++n) {
+ QString font = tex_fonts[n];
+ dialog_->layoutModule->fontsCO->insertItem(font);
}
- bc().addReadOnly (dialog->secNumDepthSB);
- bc().addReadOnly (dialog->tocDepthSB);
- bc().addReadOnly (dialog->useAmsMathCB);
- bc().addReadOnly (dialog->floatPlacementED);
- bc().addReadOnly (dialog->postscriptDriverCO);
-
- // the document bullets page
- dialog->bulletSizeCO->insertItem( _( "default" ) );
- dialog->bulletSizeCO->insertItem( _( "tiny" ) );
- dialog->bulletSizeCO->insertItem( _( "script" ) );
- dialog->bulletSizeCO->insertItem( _( "footnote" ) );
- dialog->bulletSizeCO->insertItem( _( "small" ) );
- dialog->bulletSizeCO->insertItem( _( "normal" ) );
- dialog->bulletSizeCO->insertItem( _( "large" ) );
- dialog->bulletSizeCO->insertItem( _( "Large" ) );
- dialog->bulletSizeCO->insertItem( _( "LARGE" ) );
- dialog->bulletSizeCO->insertItem( _( "huge" ) );
- dialog->bulletSizeCO->insertItem( _( "Huge" ) );
-
- dialog->bulletSizeCO->setCurrentItem( 0 );
- dialog->bulletLatexED->setMaxLength( 80 );
-
- bc().addReadOnly (dialog->bulletPanelBG);
- bc().addReadOnly (dialog->bulletSizeCO);
- bc().addReadOnly (dialog->bulletLatexED);
-#endif
-}
+ dialog_->layoutModule->fontsizeCO->insertItem(_("default"));
+ dialog_->layoutModule->fontsizeCO->insertItem(_("10"));
+ dialog_->layoutModule->fontsizeCO->insertItem(_("11"));
+ dialog_->layoutModule->fontsizeCO->insertItem(_("12"));
+ dialog_->layoutModule->skipCO->insertItem(_("Smallskip"));
+ dialog_->layoutModule->skipCO->insertItem(_("Medskip"));
+ dialog_->layoutModule->skipCO->insertItem(_("Bigskip"));
+ dialog_->layoutModule->skipCO->insertItem(_("Length"));
-void QDocument::apply()
-{
- //if (!lv_->view()->available() || !dialog_.get())
- // return;
-
-#if 0
- bool redo = class_apply();
- paper_apply();
- redo = language_apply() || redo;
- redo = options_apply() || redo;
- bullets_apply();
-
- if (redo) {
- lv_->view()->redoCurrentBuffer();
- }
- lv_->buffer()->markDirty();
- setMinibuffer(lv_, _("Document layout set"));
-#endif
-}
+ dialog_->layoutModule->pagestyleCO->insertItem(_("default"));
+ dialog_->layoutModule->pagestyleCO->insertItem(_("empty"));
+ dialog_->layoutModule->pagestyleCO->insertItem(_("plain"));
+ dialog_->layoutModule->pagestyleCO->insertItem(_("headings"));
+ dialog_->layoutModule->pagestyleCO->insertItem(_("fancy"));
+ // margins
+ dialog_->setMargins(0);
-void QDocument::cancel()
-{
-#if 0
- // this avoids confusion when reopening
- BufferParams & param = lv_->buffer()->params;
- param.temp_bullets[0] = param.user_defined_bullets[0];
- param.temp_bullets[1] = param.user_defined_bullets[1];
- param.temp_bullets[2] = param.user_defined_bullets[2];
- param.temp_bullets[3] = param.user_defined_bullets[3];
- hide();
-#endif
+ // Manage the restore, ok, apply, restore and cancel/close buttons
+ bc().setOK(dialog_->okPB);
+ bc().setApply(dialog_->applyPB);
+ bc().setCancel(dialog_->closePB);
+ bc().setRestore(dialog_->restorePB);
}
-void QDocument::update_contents()
+void QDocument::apply()
{
- if (!dialog_.get())
- return;
+ BufferParams & params = controller().params();
-#if 0
- checkReadOnly();
+ // preamble
+ params.preamble =
+ dialog_->preambleModule->preambleMLE->text().latin1();
- BufferParams const & params = lv_->buffer()->params;
-
- class_update(params);
- paper_update(params);
- language_update(params);
- options_update(params);
- bullets_update(params);
-#endif
-}
+ // biblio
+ params.use_natbib =
+ dialog_->biblioModule->natbibCB->isChecked();
+ params.use_numerical_citations =
+ dialog_->biblioModule->citeStyleCO->currentItem();
+ // language & quotes
+ if (dialog_->langModule->singleQuoteRB->isChecked())
+ params.quotes_times = InsetQuotes::SingleQ;
+ else
+ params.quotes_times = InsetQuotes::DoubleQ;
-#if 0
-bool QDocument::input( FL_OBJECT * ob, long data )
-{
- State cb = static_cast<State>( data );
- switch (cb) {
- case CHECKCHOICECLASS:
- CheckChoiceClass(ob, 0);
- break;
- case CHOICEBULLETSIZE:
- ChoiceBulletSize(ob, 0);
- break;
- case INPUTBULLETLATEX:
- InputBulletLaTeX(ob, 0);
- break;
- case BULLETDEPTH1:
- case BULLETDEPTH2:
- case BULLETDEPTH3:
- case BULLETDEPTH4:
- BulletDepth(ob, cb);
- break;
- case BULLETPANEL1:
- case BULLETPANEL2:
- case BULLETPANEL3:
- case BULLETPANEL4:
- case BULLETPANEL5:
- case BULLETPANEL6:
- BulletPanel(ob, cb);
- break;
- case BULLETBMTABLE:
- BulletBMTable(ob, 0);
- break;
- default:
- break;
+ InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
+ switch (dialog_->langModule->quoteStyleCO->currentItem()) {
+ 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;
}
+ params.quotes_language = lga;
- switch (data) {
- case INPUT:
- case CHECKCHOICECLASS:
- case CHOICEBULLETSIZE:
- case INPUTBULLETLATEX:
- case BULLETBMTABLE:
- return CheckDocumentInput(ob, 0);
- default:
- break;
+ int const pos = dialog_->langModule->languageCO->currentItem();
+ params.language = languages.getLanguage(lang_[pos]);
+
+ // numbering
+ params.secnumdepth =
+ dialog_->numberingModule->tocDepthSB->value();
+ params.tocdepth =
+ dialog_->numberingModule->sectionnrDepthSB->value();
+
+ // bullets
+ params.user_defined_bullets[0].setText(dialog_->bulletsModule->bullet1LE->text().latin1());
+ params.user_defined_bullets[1].setText(dialog_->bulletsModule->bullet2LE->text().latin1());
+ params.user_defined_bullets[2].setText(dialog_->bulletsModule->bullet3LE->text().latin1());
+ params.user_defined_bullets[3].setText(dialog_->bulletsModule->bullet4LE->text().latin1());
+
+ params.user_defined_bullets[0].setSize(dialog_->bulletsModule->bulletsize1CO->currentItem()-1);
+ params.user_defined_bullets[1].setSize(dialog_->bulletsModule->bulletsize2CO->currentItem()-1);
+ params.user_defined_bullets[2].setSize(dialog_->bulletsModule->bulletsize3CO->currentItem()-1);
+ params.user_defined_bullets[3].setSize(dialog_->bulletsModule->bulletsize4CO->currentItem()-1);
+
+ // packages
+ switch (dialog_->packagesModule->lspacingCO->currentItem()) {
+ case 0:
+ params.spacing.set(Spacing::Single);
+ break;
+ case 1:
+ params.spacing.set(Spacing::Onehalf);
+ break;
+ case 2:
+ params.spacing.set(Spacing::Double);
+ break;
+ case 3:
+ params.spacing.set(Spacing::Other,
+ dialog_->packagesModule->
+ lspacingLE->text().toFloat()
+ );
+ break;
}
- return true;
-}
+ params.graphicsDriver =
+ dialog_->packagesModule->psdriverCO->currentText().latin1();
+ params.use_amsmath =
+ dialog_->packagesModule->amsCB->isChecked();
-void QDocument::ComboInputCB(int, void * v, Combox * combox)
-{
- QDocument * pre = static_cast<QDocument*>(v);
- if (combox == pre->combo_doc_class.get())
- pre->CheckChoiceClass(0, 0);
- pre->bc().valid(pre->CheckDocumentInput(0,0));
-}
+ params.inputenc =
+ dialog_->packagesModule->encodingCO->currentText().latin1();
-bool QDocument::class_apply()
-{
- bool redo = false;
- BufferParams ¶ms = lv_->buffer()->params;
-
- // 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( ( dialog_->docSkipCO->currentItem() == 3 ) &&
- dialog_->docSkipED->text().isEmpty() )
- dialog_->docSkipCO->setCurrentItem( 1 );
-
- params.fonts = dialog_->docFontsCO->currentText();
- params.fontsize = dialog_->docFontSizeCO->currentText();
- params.pagestyle = dialog->docPagestyleCO->currentText();
-
- unsigned int const new_class = dialog_->docClassCO->currentItem();
-
- if (params.textclass != new_class) {
- // try to load new_class
- if (textclasslist.Load(new_class)) {
- // successfully loaded
- redo = true;
- setMinibuffer(lv_, _("Converting document to new document class..."));
- CutAndPaste cap;
- int ret = cap.SwitchLayoutsBetweenClasses(params.textclass, new_class,
- lv_->buffer()->paragraph,
- lv_->buffer()->params);
- if (ret) {
- string s;
- if (ret==1) {
- s = _("One paragraph couldn't be converted");
- } else {
- s += tostr(ret);
- s += _(" paragraphs couldn't be converted");
- }
- Alert::alert(_("Conversion Errors!"),s,
- _("into chosen document class"));
- }
-
- params.textclass = new_class;
- } else {
- // problem changing class -- warn user and retain old style
- Alert::alert(_("Conversion Errors!"),
- _("Errors loading new document class."),
- _("Reverting to original document class."));
- dialog_->docClassCO->setCurrentItem( params.textclass );
- }
- }
- BufferParams::PARSEP tmpsep = params.paragraph_separation;
- if( dialog_->_docIndentRB->isChecked() )
+ // layout
+ params.textclass =
+ dialog_->layoutModule->classCO->currentItem();
+
+ //bool succes = controller().classApply();
+
+ params.fonts =
+ dialog_->layoutModule->fontsCO->currentText().latin1();
+
+ params.fontsize =
+ dialog_->layoutModule->fontsizeCO->currentText().latin1();
+
+ params.pagestyle =
+ dialog_->layoutModule->pagestyleCO->currentText().latin1();
+
+ if (dialog_->layoutModule->indentRB->isChecked())
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( dialog_->docSkipCO->currentItem() ) {
- case 0:
- params.setDefSkip(VSpace(VSpace::SMALLSKIP));
- break;
- case 1:
- params.setDefSkip(VSpace(VSpace::MEDSKIP));
- break;
- case 2:
- params.setDefSkip(VSpace(VSpace::BIGSKIP));
- break;
- case 3:
- params.setDefSkip
- (VSpace(LyXGlueLength(dialog_->docSkipED->text())));
- break;
+ switch (dialog_->layoutModule->skipCO->currentItem()) {
+ case 0:
+ params.setDefSkip(VSpace(VSpace::SMALLSKIP));
+ break;
+ case 1:
+ params.setDefSkip(VSpace(VSpace::MEDSKIP));
+ break;
+ case 2:
+ params.setDefSkip(VSpace(VSpace::BIGSKIP));
+ break;
+ case 3:
+ {
+ LyXLength::UNIT unit =
+ dialog_->layoutModule->skipLengthCO->
+ currentLengthItem();
+ double length =
+ dialog_->layoutModule->skipLE->text().toDouble();
+ VSpace vs = VSpace(LyXGlueLength(LyXLength(length,unit)));
+ params.setDefSkip(vs);
+ break;
+ }
+ default:
// DocumentDefskipCB assures that this never happens
- // ... so why is there code for it ?
- default:
- params.setDefSkip(VSpace(VSpace::MEDSKIP));
+ // so Assert then !!! - jbl
+ params.setDefSkip(VSpace(VSpace::MEDSKIP));
break;
}
- if (!(tmpdefskip == params.getDefSkip()))
- redo = true;
- if( dialog_->docColumnsTwo->isChecked() )
+ params.options =
+ dialog_->layoutModule->optionsLE->text().latin1();
+
+ params.float_placement =
+ dialog_->layoutModule->floatPlacementLE->text().latin1();
+
+ // paper
+ params.papersize2 =
+ dialog_->paperModule->papersizeCO->currentItem();
+
+ params.paperwidth =
+ LyXLength(dialog_->paperModule->paperwidthLE->text().toDouble(),
+ dialog_->paperModule->paperwidthUnitCO->currentLengthItem()
+ ).asString();
+
+ params.paperheight =
+ LyXLength(dialog_->paperModule->paperheightLE->text().toDouble(),
+ dialog_->paperModule->paperheightUnitCO->currentLengthItem()
+ ).asString();
+
+ if (dialog_->paperModule->twoColumnCB->isChecked())
params.columns = 2;
else
params.columns = 1;
- if( dialog_->docSidesTwo->isChecked() )
+
+ if (dialog_->paperModule->facingPagesCB->isChecked())
params.sides = LyXTextClass::TwoSides;
else
params.sides = LyXTextClass::OneSide;
- Spacing tmpSpacing = params.spacing;
- switch( dialog_->docSpacingCO->currentItem() ) {
- case 0:
- lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
- params.spacing.set(Spacing::Single);
- break;
- case 1:
- lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
- params.spacing.set(Spacing::Onehalf);
- break;
- case 2:
- lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
- params.spacing.set(Spacing::Double);
- break;
- case 3:
- lyxerr[Debug::INFO] << "Spacing: OTHER\n";
- params.spacing.set(Spacing::Other,
- dialog_->docSpacingED->text() );
- break;
- }
- if (tmpSpacing != params.spacing)
- redo = true;
-
- params.options = docExtraED->text();
-
- return redo;
-}
-
-
-void QDocument::paper_apply()
-{
- BufferParams & params = lv_->buffer()->params;
-
- params.papersize2 =
- static_cast<char>(dialog_->papersize2CO->currentItem());
- params.paperpackage =
- static_cast<char>(dialog_->paperPackageCO->currentItem() );
- params.use_geometry = dialog_->useGeometryCB->isChecked();
- if (dialog_->landscapeRB->isChecked() )
+ if (dialog_->paperModule->landscapeRB->isChecked())
params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
else
params.orientation = BufferParams::ORIENTATION_PORTRAIT;
- params.paperwidth = dialog_->customWidthED->text();
- params.paperheight = dialog_->customHeightED->text();
- params.leftmargin = dialog_->leftMarginED->text();
- params.topmargin = dialog_->topMarginED->text();
- params.rightmargin = dialog_->rightMarginED->text();
- params.bottommargin = dialog_->bottomMarginED->text();
- params.headheight = dialog_->headHeightED->text();
- params.headsep = dialog_->headSepED->text();
- params.footskip = dialog_->footSkipED->text();
- lv_->buffer()->setPaperStuff();
-}
-
-bool QDocument::language_apply()
-{
- BufferParams & params = lv_->buffer()->params;
- InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
- bool redo = false;
+ // margins
+ params.use_geometry =
+ (dialog_->marginsModule->marginCO->currentItem() == 1);
- switch (dialog_->quotesLanguageCO->currentItem() ) {
- 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;
+ int margin = dialog_->marginsModule->marginCO->currentItem();
+ if (margin > 0) {
+ margin = margin - 1;
}
- params.quotes_language = lga;
- if (dialog_->singleRB->isChecked() )
- params.quotes_times = InsetQuotes::SingleQ;
- else
- params.quotes_times = InsetQuotes::DoubleQ;
-
- Language const * old_language = params.language;
- Language const * new_language =
- languages.getLanguage(dialog_->languageCO->currentItem() );
- if (!new_language)
- new_language = default_language;
-
- if (old_language != new_language
- && old_language->RightToLeft() == new_language->RightToLeft()
- && !lv_->buffer()->isMultiLingual())
- lv_->buffer()->ChangeLanguage(old_language, new_language);
-
- if (old_language != new_language)
- redo = true;
-
- params.language = new_language;
- params.inputenc = dialog_->inputEncCO->currentText();
-
- return redo;
+ params.paperpackage = char(margin);
+
+ MarginsModuleBase const * m(dialog_->marginsModule);
+
+ params.leftmargin =
+ LyXLength(m->innerLE->text().toDouble(),
+ m->innerUnit->currentLengthItem()
+ ).asString();
+
+ params.topmargin =
+ LyXLength(m->topLE->text().toDouble(),
+ m->topUnit->currentLengthItem()
+ ).asString();
+
+ params.rightmargin =
+ LyXLength(m->outerLE->text().toDouble(),
+ m->outerUnit->currentLengthItem()
+ ).asString();
+
+ params.bottommargin =
+ LyXLength(m->bottomLE->text().toDouble(),
+ m->bottomUnit->currentLengthItem()
+ ).asString();
+
+ params.headheight =
+ LyXLength(m->headheightLE->text().toDouble(),
+ m->headheightUnit->currentLengthItem()
+ ).asString();
+
+ params.headsep =
+ LyXLength(m->headsepLE->text().toDouble(),
+ m->headsepUnit->currentLengthItem()
+ ).asString();
+
+ params.footskip =
+ LyXLength(m->footskipLE->text().toDouble(),
+ m->footskipUnit->currentLengthItem()
+ ).asString();
}
-bool QDocument::options_apply()
-{
- BufferParams & params = lv_->buffer()->params;
- bool redo = false;
-
- params.graphicsDriver =
- dialog_->postscriptDriverCO->currentText();
- params.use_amsmath = dialog_->useAmsMathCB->isChecked();
+namespace {
- int tmpchar = int(dialog_->secNumDepth->value() );
- if (params.secnumdepth != tmpchar)
- redo = true;
- params.secnumdepth = tmpchar;
-
- params.tocdepth = int(dialog_->tocDepth->value() );
-
- params.float_placement =
- dialog_->floatPlacementED->text();
-
- return redo;
-}
-
-
-void QDocument::bullets_apply()
+/** Return the position of val in the vector if found.
+ If not found, return 0.
+ */
+template<class A>
+typename std::vector<A>::size_type
+findPos(std::vector<A> const & vec, A const & val)
{
- /* update the bullet settings */
- BufferParams & param = lv_->buffer()->params;
-
- // a little bit of loop unrolling
- param.user_defined_bullets[0] = param.temp_bullets[0];
- param.user_defined_bullets[1] = param.temp_bullets[1];
- param.user_defined_bullets[2] = param.temp_bullets[2];
- param.user_defined_bullets[3] = param.temp_bullets[3];
+ typename std::vector<A>::const_iterator it =
+ std::find(vec.begin(), vec.end(), val);
+ if (it == vec.end())
+ return 0;
+ return std::distance(vec.begin(), it);
}
+} // namespace anom
+
-void QDocument::class_update(BufferParams const & params)
+void QDocument::update_contents()
{
- if (!class_.get())
+ if (!dialog_.get())
return;
- LyXTextClass const & tclass = textclasslist[params.textclass];
-
- combo_doc_class->select_text(
- textclasslist.DescOfClass(params.textclass));
- Qt2Helper::setCurrentComboItem( dialog_->docFonts, params.fonts.c_str() );
- dialog_->docFontSizeCO->clear();
- dialog_->docFontSizeCO->insertItem( _( "default" ) );
- dialog_->docFontSizeCO->insertItem( tclass.opt_fontsize().c_str());
- dialog_->docFontSizeCO->setCurrentItem( tokenPos(tclass.opt_fontsize(), '|', params.fontsize)+1);
- dialog_->docPagestyleCO->clear();
- dialog_->docPagestyleCO->insertItem( _( "default" ) );
- dialog_->docPagestyleCO->insertItem( tclass.opt_pagestyle().c_str());
- dialog_->docPagestyleCO->setCurrentItem( tokenPos(tclass.opt_pagestyle(), '|', params.pagestyle)+1);
- dialog_->docIndentRB->setChecked( false );
- dialog_->docSkipRB->setChecked( false );
- if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
- dialog_->docIndentRB->setChecked( true );
- else
- dialog_->docSkipRB->setChecked( true );
- switch (params.getDefSkip().kind()) {
- case VSpace::SMALLSKIP:
- dialog_->docSkipCO->setCurrentItem( 0 );
- break;
- case VSpace::MEDSKIP:
- dialog_->docSkipCO->setCurrentItem( 1 );
- break;
- case VSpace::BIGSKIP:
- dialog_->docSkipCO->setCurrentItem( 2 );
- break;
- case VSpace::LENGTH:
- dialog_->docSkipCO->setCurrentItem( 3 );
- dialog_->docSkipED->setText( params.getDefSkip().asLyXCommand().c_str());
- break;
- default:
- dialog_->docSkipCO->setCurrentItem( 1 );
- break;
+ BufferParams const & params = controller().params();
+
+ // preamble
+ QString preamble = params.preamble.c_str();
+ dialog_->preambleModule->preambleMLE->setText(preamble);
+
+ // biblio
+ dialog_->biblioModule->natbibCB->setChecked(
+ params.use_natbib);
+ dialog_->biblioModule->citeStyleCO->setCurrentItem(
+ params.use_numerical_citations ? 1 : 0);
+
+ // language & quotes
+ dialog_->langModule->singleQuoteRB->setChecked(
+ params.quotes_times == InsetQuotes::SingleQ);
+ dialog_->langModule->doubleQuoteRB->setChecked(
+ params.quotes_times == InsetQuotes::DoubleQ);
+
+ int const pos = int(findPos(lang_,
+ params.language->lang()));
+ dialog_->langModule->languageCO->setCurrentItem(pos);
+
+ dialog_->langModule->quoteStyleCO->setCurrentItem(
+ params.quotes_language);
+
+ // numbering
+ dialog_->numberingModule->tocDepthSB->setValue(
+ params.secnumdepth);
+ dialog_->numberingModule->sectionnrDepthSB->setValue(
+ params.tocdepth);
+
+ // bullets
+ QString s;
+ s = params.user_defined_bullets[0].getText().c_str();
+ dialog_->bulletsModule->bullet1LE->setText(s);
+ s = params.user_defined_bullets[1].getText().c_str();
+ dialog_->bulletsModule->bullet2LE->setText(s);
+ s = params.user_defined_bullets[2].getText().c_str();
+ dialog_->bulletsModule->bullet3LE->setText(s);
+ s = params.user_defined_bullets[3].getText().c_str();
+ dialog_->bulletsModule->bullet4LE->setText(s);
+
+ dialog_->bulletsModule->bulletsize1CO->setCurrentItem(
+ params.user_defined_bullets[0].getSize() + 1);
+ dialog_->bulletsModule->bulletsize2CO->setCurrentItem(
+ params.user_defined_bullets[1].getSize() + 1);
+ dialog_->bulletsModule->bulletsize3CO->setCurrentItem(
+ params.user_defined_bullets[2].getSize() + 1);
+ dialog_->bulletsModule->bulletsize4CO->setCurrentItem(
+ params.user_defined_bullets[3].getSize() + 1);
+
+ // packages
+ char const * enc[] = {
+ "default" , "auto" , "latin1" , "latin2" , "latin3" ,
+ "latin4" , "latin5" , "latin9" , "koi8-r" , "koi8-u" ,
+ "cp866" , "cp1251" , "iso88595" , "pt154" };
+ for (size_t i = 0; i < sizeof(enc)/sizeof(char *); ++i) {
+ if (params.inputenc == enc[i])
+ dialog_->packagesModule->encodingCO->setCurrentItem(i);
}
- dialog_->docSidesOneRB->setChecked( false );
- dialog_->docSidesTwoRB->setChecked( false );
- if (params.sides == LyXTextClass::TwoSides)
- dialog_->docSidesTwo->setChecked( true );
- else
- dialog_->docSidesOne->setChecked( true );
- dialog_->docColumnsOneRB->setChecked( false );
- dialog_->docColumnsTwoRB->setChecked( false );
- if (params.columns == 2)
- dialog_->docColumnsTwoRB->setChecked( true );
- else
- dialog_->docColumnsOneRB->setChecked( true );
- dialog_->docSpacingED->setText( "" );
- switch (params.spacing.getSpace()) {
- case Spacing::Default: // nothing bad should happen with this
- case Spacing::Single:
- // \singlespacing
- dialog_->docSpacingCO->setCurrentItem( 0 );
- break;
- case Spacing::Onehalf:
- // \onehalfspacing
- dialog_->docSpacingCO->setCurrentItem( 1 );
- break;
- case Spacing::Double:
- // \doublespacing
- dialog_->docSpacingCO->setCurrentItem( 2 );
- break;
- case Spacing::Other:
- {
- dialog_->docSpacingCO->setCurrentItem( 3 );
- QString sval;
- sval.sprintf("%g",params.spacing.getValue());
- dialog_->docSpacingED->setText( sval );
- break;
+
+ QString text = params.graphicsDriver.c_str();
+ int nitem = dialog_->packagesModule->psdriverCO->count();
+ for (int n = 0; n < nitem ; ++n) {
+ QString enc = tex_graphics[n];
+ if (enc == text) {
+ dialog_->packagesModule->psdriverCO->setCurrentItem(n);
}
}
- if (!params.options.empty())
- dialog_->docExtraED->setText(, params.options.c_str());
- else
- dialog_->docExtraED->setText( "" );
-}
-void QDocument::language_update(BufferParams const & params)
-{
- if (!language_.get())
- return;
-
- Qt2Helper::setCurrentItemText( dialog_->languageCO, params.language->lang() );
- Qt2Helper::setCurrentItemText( dialog_->inputEncCO, params.inputenc.c_str() );
- dialog_->quotesLanguageCO->setCurrentItem( params.quotes_language );
- dialog_->singleRB->setChecked( false );
- dialog_->doubleRB->setChecked( false );
- if (params.quotes_times == InsetQuotes::SingleQ)
- dialog_->singleRB->setChecked( true );
- else
- dialog_->doubleRB->setChecked( true );
-}
-
-
-void QDocument::options_update(BufferParams const & params)
-{
- if (!options_.get())
- return;
-
- Qt2Helper::setCurrentItemText( dialog_->postscriptDriverCO,
- params.graphicsDriver.c_str());
- dialog_->useAmsMathCB->setChecked( params.use_amsmath );
- dialog_->secNumDepthSB->setValue( params.secnumdepth );
- dialog_->setTocDepthSB->setValue( params.tocdepth );
- if (!params.float_placement.empty())
- dialog_->floatPlacementED->setText( params.float_placement.c_str());
- else
- dialog_->floatPlacementED->setText( "" );
-}
+ dialog_->packagesModule->amsCB->setChecked(
+ params.use_amsmath);
+ switch (params.spacing.getSpace()) {
+ case Spacing::Other: nitem = 3; break;
+ case Spacing::Double: nitem = 2; break;
+ case Spacing::Onehalf: nitem = 1; break;
+ case Spacing::Default: case Spacing::Single: nitem = 0; break;
+ }
-void QDocument::paper_update(BufferParams const & params)
-{
- if (!paper_.get())
- return;
+ dialog_->packagesModule->lspacingCO->setCurrentItem(nitem);
+ if (params.spacing.getSpace() == Spacing::Other) {
+ dialog_->packagesModule->lspacingLE->setText(
+ tostr(params.spacing.getValue()).c_str());
+ dialog_->setLSpacing(3);
+ }
- dialog_->papersize2CO->setCurrentItem( params.papersize2 );
- dialog_->paperPackageCO->setCurrentItem( params.paperpackage );
- dialog_->useGeometryCB->setChecked( params.use_geometry );
- dialog_->portraitRB->setChecked( false );
- dialog_->landscapeRB->setChecked( false );
- if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
- dialog_->landscapeRB->setChecked( true );
- else
- dialog_->portraitRB->setChecked( true );
- dialog_->customWidthED->setText( params.paperwidth.c_str());
- dialog_->customHeightED->setText( params.paperheight.c_str());
- dialog_->leftMarginED->setText( params.leftmargin.c_str());
- dialog_->topMarginED->setText( params.topmargin.c_str());
- dialog_->rightMarginED->setText( params.rightmargin.c_str());
- dialog_->bottomMarginED->setText( params.bottommargin.c_str());
- dialog_->headHeightED->setText( params.headheight.c_str());
- dialog_->headSepED->setText( params.headsep.c_str());
- dialog_->footSkipED->setText( params.footskip.c_str());
- dialog_->papersize2CO->setFocus();
-}
+ // layout
+ for (int n = 0; n<dialog_->layoutModule->classCO->count(); ++n) {
+ if (dialog_->layoutModule->classCO->text(n) ==
+ controller().textClass().description().c_str()) {
+ dialog_->layoutModule->classCO->setCurrentItem(n);
+ break;
+ }
+ }
+ dialog_->updateFontsize(controller().textClass().opt_fontsize(),
+ params.fontsize);
-void QDocument::bullets_update(BufferParams const & params)
-{
- bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
- setEnabled(fbullet, !isLinuxDoc);
+ dialog_->updatePagestyle(controller().textClass().opt_pagestyle(),
+ params.pagestyle);
- if (isLinuxDoc) return;
+ for (int n = 0; tex_fonts[n][0]; ++n) {
+ if (tex_fonts[n] == params.fonts) {
+ dialog_->layoutModule->fontsCO->setCurrentItem(n);
+ break;
+ }
+ }
- dialog_->bulletDepth1RB->setChecked( true );
- dialog_->bulletLatexED->setText( params.user_defined_bullets[0].getText().c_str());
- dialog_->bulletSizeCO->setCurrentItem( params.user_defined_bullets[0].getSize() + 1);
-}
+ if (params.paragraph_separation
+ == BufferParams::PARSEP_INDENT) {
+ dialog_->layoutModule->indentRB->setChecked(true);
+ } else {
+ dialog_->layoutModule->skipRB->setChecked(true);
+ }
+ int skip = 0;
+ switch (params.getDefSkip().kind()) {
+ case VSpace::SMALLSKIP:
+ skip = 0;
+ break;
+ case VSpace::MEDSKIP:
+ skip = 1;
+ break;
+ case VSpace::BIGSKIP:
+ skip = 2;
+ break;
+ case VSpace::LENGTH:
+ {
+ skip = 3;
+ string const length = params.getDefSkip().asLyXCommand();
+ dialog_->layoutModule->skipLengthCO->setCurrentItem(LyXLength(length).unit());
+ dialog_->layoutModule->skipLE->setText(tostr(LyXLength(length).value()).c_str());
+ break;
+ }
+ default:
+ skip = 0;
+ break;
+ }
+ dialog_->layoutModule->skipCO->setCurrentItem(skip);
+ dialog_->setSkip(skip);
-void QDocument::checkReadOnly()
-{
- if (bc().readOnly(lv_->buffer()->isReadonly())) {
- dialog_->docClassCO->setEnabled( false );
- dialog_->languageCO->setEnabled( false );
- dialog_->warningLA->setText( _("Document is read-only."
- " No changes to layout permitted."));
- dialog_->warningLA->show();
+ if (!params.options.empty()) {
+ dialog_->layoutModule->optionsLE->setText(
+ params.options.c_str());
} else {
- dialog_->docClassCO->setEnabled( true );
- dialog_->languageCO->setEnabled( true );
- dialog_->warningLA->hide();
+ dialog_->layoutModule->optionsLE->setText("");
}
-}
+ // paper
+ int const psize = params.papersize2;
+ dialog_->paperModule->papersizeCO->setCurrentItem(psize);
+ dialog_->setMargins(psize);
+ dialog_->setCustomPapersize(psize);
-void QDocument::checkMarginValues()
-{
- bool const not_empty =
- !dialog_->topMarginED->text().isEmpty() ||
- !dialog_->bottomMarginED->text().isEmpty() ||
- !dialog_->leftMarginED->text().isEmpty() ||
- !dialog_->rightMarginED->text().isEmpty() ||
- !dialog_->headHeightED->text().isEmpty() ||
- !dialog_->headSepED->text().isEmpty() ||
- !dialog_->footSkipED->text().isEmpty() ||
- !dialog_->customWidthED->text().isEmpty() ||
- !dialog_->customHeightED->text().isEmpty();
- if (not_empty)
- dialog_->useGeometryCB->setChecked( true );
-}
+ bool const landscape =
+ params.orientation == BufferParams::ORIENTATION_LANDSCAPE;
+ dialog_->paperModule->landscapeRB->setChecked(landscape);
+ dialog_->paperModule->portraitRB->setChecked(!landscape);
-#ifdef I_SUPPOSE_THIS_NEEDS_TO_FIXED
-bool QDocument::CheckDocumentInput(FL_OBJECT * ob, long)
-{
- string str;
- int val;
- bool ok = true;
- char const * input;
-
- checkMarginValues();
- if (ob == paper_->choice_papersize2) {
- val = fl_get_choice(paper_->choice_papersize2)-1;
- if (val == BufferParams::VM_PAPER_DEFAULT) {
- fl_set_button(paper_->push_use_geometry, 0);
- checkMarginValues();
- } else {
- if ((val != BufferParams::VM_PAPER_USLETTER) &&
- (val != BufferParams::VM_PAPER_USLEGAL) &&
- (val != BufferParams::VM_PAPER_USEXECUTIVE) &&
- (val != BufferParams::VM_PAPER_A4) &&
- (val != BufferParams::VM_PAPER_A5) &&
- (val != BufferParams::VM_PAPER_B5)) {
- fl_set_button(paper_->push_use_geometry, 1);
- }
- fl_set_choice(paper_->choice_paperpackage,
- BufferParams::PACKAGE_NONE + 1);
- }
- } else if (ob == paper_->choice_paperpackage) {
- val = fl_get_choice(paper_->choice_paperpackage)-1;
- if (val != BufferParams::PACKAGE_NONE) {
- fl_set_choice(paper_->choice_papersize2,
- BufferParams::VM_PAPER_DEFAULT + 1);
- fl_set_button(paper_->push_use_geometry, 0);
- }
- } else if (ob == class_->input_doc_spacing) {
- input = fl_get_input(class_->input_doc_spacing);
- if (!*input) {
- fl_set_choice (class_->choice_doc_spacing, 1);
- } else {
- fl_set_choice(class_->choice_doc_spacing, 4);
- }
- }
- // this has to be all out of if/elseif because it has to deactivate
- // the document buttons and so the whole stuff has to be tested again.
- str = fl_get_input(paper_->input_custom_width);
- ok = ok && (str.empty() || isValidLength(str));
- str = fl_get_input(paper_->input_custom_height);
- ok = ok && (str.empty() || isValidLength(str));
- str = fl_get_input(paper_->input_left_margin);
- ok = ok && (str.empty() || isValidLength(str));
- str = fl_get_input(paper_->input_right_margin);
- ok = ok && (str.empty() || isValidLength(str));
- str = fl_get_input(paper_->input_top_margin);
- ok = ok && (str.empty() || isValidLength(str));
- str = fl_get_input(paper_->input_bottom_margin);
- ok = ok && (str.empty() || isValidLength(str));
- str = fl_get_input(paper_->input_head_height);
- ok = ok && (str.empty() || isValidLength(str));
- str = fl_get_input(paper_->input_head_sep);
- ok = ok && (str.empty() || isValidLength(str));
- str = fl_get_input(paper_->input_foot_skip);
- ok = ok && (str.empty() || isValidLength(str));
- // "Synchronize" the choice and the input field, so that it
- // is impossible to commit senseless data.
- input = fl_get_input (class_->input_doc_skip);
- if (ob == class_->input_doc_skip) {
- if (!*input) {
- fl_set_choice (class_->choice_doc_skip, 2);
- } else if (isValidGlueLength (input)) {
- fl_set_choice (class_->choice_doc_skip, 4);
- } else {
- fl_set_choice(class_->choice_doc_skip, 4);
- ok = false;
- }
- } else {
- if (*input && !isValidGlueLength(input))
- ok = false;
- }
- if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
- ok = false;
- else if (fl_get_choice(class_->choice_doc_skip) != 4)
- fl_set_input (class_->input_doc_skip, "");
-
- input = fl_get_input(class_->input_doc_spacing);
- if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
- ok = false;
- else if (fl_get_choice(class_->choice_doc_spacing) != 4)
- fl_set_input (class_->input_doc_spacing, "");
- return ok;
-}
+ dialog_->paperModule->facingPagesCB->setChecked(
+ params.sides == LyXTextClass::TwoSides);
+ dialog_->paperModule->twoColumnCB->setChecked(
+ params.columns == 2);
-void QDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/ )
-{
- BufferParams & param = lv_->buffer()->params;
+ dialog_->paperModule->paperwidthUnitCO->setCurrentItem(
+ LyXLength(params.paperwidth).unit());
- // convert from 1-6 range to -1-4
- param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
- fl_set_input(bullets_->input_bullet_latex,
- param.temp_bullets[current_bullet_depth].getText().c_str());
-}
+ dialog_->paperModule->paperwidthLE->setText(
+ tostr(LyXLength(params.paperwidth).value()).c_str());
+ dialog_->paperModule->paperheightUnitCO->setCurrentItem(
+ LyXLength(params.paperheight).unit());
-void QDocument::InputBulletLaTeX(FL_OBJECT *, long)
-{
- BufferParams & param = lv_->buffer()->params;
+ dialog_->paperModule->paperheightLE->setText(
+ tostr(LyXLength(params.paperheight).value()).c_str());
- param.temp_bullets[current_bullet_depth].
- setText(fl_get_input(bullets_->input_bullet_latex));
-}
+ // margins
+ MarginsModuleBase * m(dialog_->marginsModule);
-void QDocument::BulletDepth(FL_OBJECT * ob, State cb)
-{
- /* Should I do the following:
- * 1. change to the panel that the current bullet belongs in
- * 2. show that bullet as selected
- * 3. change the size setting to the size of the bullet in Q.
- * 4. display the latex equivalent in the latex box
- *
- * I'm inclined to just go with 3 and 4 at the moment and
- * maybe try to support the others later
- */
- BufferParams & param = lv_->buffer()->params;
-
- int data = 0;
- if (cb == BULLETDEPTH1 )
- data = 0;
- else if (cb == BULLETDEPTH2 )
- data = 1;
- else if (cb == BULLETDEPTH3 )
- data = 2;
- else if (cb == BULLETDEPTH4 )
- data = 3;
-
- switch (fl_get_button_numb(ob)) {
- case 3:
- // right mouse button resets to default
- param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
- default:
- current_bullet_depth = data;
- fl_set_input(bullets_->input_bullet_latex,
- param.temp_bullets[data].getText().c_str());
- fl_set_choice(bullets_->choice_bullet_size,
- param.temp_bullets[data].getSize() + 2);
+ int item = params.paperpackage;
+ if (params.use_geometry) {
+ item = 1;
+ } else if (item > 0) {
+ item = item + 1;
}
-}
+ m->marginCO->setCurrentItem(item);
+ dialog_->setCustomMargins(item);
+ m->topUnit->setCurrentItem(LyXLength(params.topmargin).unit());
+ m->topLE->setText(tostr(LyXLength(params.topmargin).value()).c_str());
-void QDocument::BulletPanel(FL_OBJECT * /*ob*/, State cb)
-{
- /* Here we have to change the background pixmap to that selected */
- /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
-
- int data = 0;
- if (cb == BULLETPANEL1 )
- data = 0;
- else if (cb == BULLETPANEL2 )
- data = 1;
- else if (cb == BULLETPANEL3 )
- data = 2;
- else if (cb == BULLETPANEL4 )
- data = 3;
- else if (cb == BULLETPANEL5 )
- data = 4;
- else if (cb == BULLETPANEL6 )
- data = 5;
-
- if (data != current_bullet_panel) {
- fl_freeze_form(bullets_->form);
- current_bullet_panel = data;
-
- /* free the current pixmap */
- fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
- string new_panel;
- switch (cb) {
- /* display the new one */
- case BULLETPANEL1 :
- new_panel = "standard";
- break;
- case BULLETPANEL2 :
- new_panel = "amssymb";
- break;
- case BULLETPANEL3 :
- new_panel = "psnfss1";
- break;
- case BULLETPANEL4 :
- new_panel = "psnfss2";
- break;
- case BULLETPANEL5 :
- new_panel = "psnfss3";
- break;
- case BULLETPANEL6 :
- new_panel = "psnfss4";
- break;
- default :
- /* something very wrong happened */
- // play it safe for now but should be an exception
- current_bullet_panel = 0; // standard panel
- new_panel = "standard";
- break;
- }
- new_panel += ".xpm";
- fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
- LibFileSearch("images", new_panel).c_str());
- fl_redraw_object(bullets_->bmtable_bullet_panel);
- fl_unfreeze_form(bullets_->form);
- }
-}
+ m->bottomUnit->setCurrentItem(LyXLength(params.bottommargin).unit());
+ m->bottomLE->setText(tostr(LyXLength(params.bottommargin).value()).c_str());
+ m->innerUnit->setCurrentItem(LyXLength(params.leftmargin).unit());
+ m->innerLE->setText(tostr(LyXLength(params.leftmargin).value()).c_str());
-void QDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/ )
-{
- /* handle the user input by setting the current bullet depth's pixmap */
- /* to that extracted from the current chosen position of the BMTable */
- /* Don't forget to free the button's old pixmap first. */
-
- BufferParams & param = lv_->buffer()->params;
- int bmtable_button = fl_get_bmtable(ob);
-
- /* try to keep the button held down till another is pushed */
- /* fl_set_bmtable(ob, 1, bmtable_button); */
- param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
- param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
- fl_set_input(bullets_->input_bullet_latex,
- param.temp_bullets[current_bullet_depth].getText().c_str());
+ m->outerUnit->setCurrentItem(LyXLength(params.rightmargin).unit());
+ m->outerLE->setText(tostr(LyXLength(params.rightmargin).value()).c_str());
+
+ m->headheightUnit->setCurrentItem(LyXLength(params.headheight).unit());
+ m->headheightLE->setText(tostr(LyXLength(params.headheight).value()).c_str());
+
+ m->headsepUnit->setCurrentItem(LyXLength(params.headsep).unit());
+ m->headsepLE->setText(tostr(LyXLength(params.headsep).value()).c_str());
+
+ m->footskipUnit->setCurrentItem(LyXLength(params.footskip).unit());
+ m->footskipLE->setText(tostr(LyXLength(params.footskip).value()).c_str());
}
-void QDocument::CheckChoiceClass(FL_OBJECT * ob, long)
+void QDocument::saveDocDefault()
{
- if (!ob)
- ob = class_->choice_doc_class;
-
- ProhibitInput(lv_->view());
-
- unsigned int tc = combo_doc_class->get() - 1;
- if (textclasslist.Load(tc)) {
- // we use a copy of the bufferparams because we do not
- // want to modify them yet.
- BufferParams params = lv_->buffer()->params;
-
- if (params.textclass != tc
- && Alert::askQuestion(_("Should I set some parameters to"),
- _("the defaults of this document class?"))) {
- params.textclass = tc;
- params.useClassDefaults();
- UpdateLayoutDocument(params);
- }
- } else {
- // unable to load new style
- Alert::alert(_("Conversion Errors!"),
- _("Unable to switch to new document class."),
- _("Reverting to original document class."));
- combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
- }
- AllowInput(lv_->view());
+ // we have to apply the params first
+ apply();
+ controller().saveAsDefault();
}
-#endif
-void QDocument::UpdateLayoutDocument(BufferParams const & params)
+
+void QDocument::useClassDefaults()
{
- if (!dialog_.get())
- return;
+ BufferParams & params = controller().params();
- checkReadOnly();
- class_update(params);
- paper_update(params);
- language_update(params);
- options_update(params);
- bullets_update(params);
+ params.textclass = dialog_->layoutModule->classCO->currentItem();
+ params.useClassDefaults();
+ update_contents();
}
-#endif // 0