3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
6 * \author Kalle Dalheimer <kalle@klaralvdalens-datakonsult.se>
12 #pragma implementation
15 #include "QDocument.h"
16 #include "QDocumentDialog.h"
18 #include "lyx_gui_misc.h"
21 #include "tex-strings.h"
22 #include "bufferparams.h"
23 #include "insets/insetquotes.h"
25 #include "support/filetools.h"
27 #include "BufferView.h"
30 #include "CutAndPaste.h"
31 #include "bufferview_funcs.h"
33 #include <qcombobox.h>
34 #include <qlineedit.h>
35 #include <qradiobutton.h>
38 using Liason::setMinibuffer;
41 typedef Qt2CB<ControlDocument, Qt2DB<QDocumentDialog> > base_class;
44 QDocument::QDocument(ControlDocument & c)
45 : base_class(c, _("Document Settings"))
50 QDocument::QDocument(LyXView *, Dialogs *)
56 void QDocument::build_dialog()
59 //dialog_.reset(new QDocumentDialog());
62 // Manage the restore, ok, apply, restore and cancel/close buttons
63 bc().setOK(dialog_->okPB);
64 bc().setApply(dialog_->applyPB);
65 bc().setCancel(dialog_->cancelPB);
66 bc().setRestore(dialog_->restorePB);
69 // the document paper page
70 QDocumentDialog * dialog = dialog_.get();
71 dialog->papersize2CO->insertItem( _( "Default" ) );
72 dialog->papersize2CO->insertItem( _( "Custom" ) );
73 dialog->papersize2CO->insertItem( _( "USletter" ) );
74 dialog->papersize2CO->insertItem( _( "USlegal" ) );
75 dialog->papersize2CO->insertItem( _( "USexecutive" ) );
76 dialog->papersize2CO->insertItem( _( "A3" ) );
77 dialog->papersize2CO->insertItem( _( "A4" ) );
78 dialog->papersize2CO->insertItem( _( "A5" ) );
79 dialog->papersize2CO->insertItem( _( "B3" ) );
80 dialog->papersize2CO->insertItem( _( "B4" ) );
81 dialog->papersize2CO->insertItem( _( "B5" ) );
83 dialog->paperPackageCO->insertItem( _( "None" ) );
84 dialog->paperPackageCO->insertItem( _( "A4 small Margins (only portrait)" ) );
85 dialog->paperPackageCO->insertItem( _( "A4 very small Margins (only portrait)" ) );
86 dialog->paperPackageCO->insertItem( _( "A4 very wide margins (only portrait)" ) );
88 bc().addReadOnly (dialog->paperPackageCO);
89 bc().addReadOnly (dialog->orientationBG);
90 bc().addReadOnly (dialog->portraitRB);
91 bc().addReadOnly (dialog->landscapeRB);
92 bc().addReadOnly (dialog->papersize2CO);
93 bc().addReadOnly (dialog->useGeometryCB);
94 bc().addReadOnly (dialog->customWidthED);
95 bc().addReadOnly (dialog->customHeightED);
96 bc().addReadOnly (dialog->topMarginED);
97 bc().addReadOnly (dialog->bottomMarginED);
98 bc().addReadOnly (dialog->leftMarginED);
99 bc().addReadOnly (dialog->rightMarginED);
100 bc().addReadOnly (dialog->headHeightED);
101 bc().addReadOnly (dialog->headSepED);
102 bc().addReadOnly (dialog->footSkipED);
105 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
106 cit != textclasslist.end(); ++cit) {
107 docClassCO->insertItem( (*cit).description().c_str() );
110 dialog->docSpacingCO->insertItem( _( "Single" ) );
111 dialog->docSpacingCO->insertItem( _( "OneHalf" ) );
112 dialog->docSpacingCO->insertItem( _( "Double" ) );
113 dialog->docSpacingCO->insertItem( _( "Other" ) );
115 dialog->docFontSizeCO->insertItem( _( "default" ) );
116 dialog->docFontSizeCO->insertItem( _( "10" ) );
117 dialog->docFontSizeCO->insertItem( _( "11" ) );
118 dialog->docFontSizeCO->insertItem( _( "12" ) );
119 for (int n=0; tex_fonts[n][0]; ++n) {
120 dialog->docFontsCO->insertItem( tex_fonts[n] );
123 dialog->docPagestyleCO->insertItem( _( "default" ) );
124 dialog->docPagestyleCO->insertItem( _( "empty" ) );
125 dialog->docPagestyleCO->insertItem( _( "plain" ) );
126 dialog->docPagestyleCO->insertItem( _( "headings" ) );
127 dialog->docPagestyleCO->insertItem( _( "fancy" ) );
129 dialog->docSkipCO->insertItem( _( "Smallskip" ) );
130 dialog->docSkipCO->insertItem( _( "Medskip" ) );
131 dialog->docSkipCO->insertItem( _( "Bigskip" ) );
132 dialog->docSkipCO->insertItem( _( "Length" ) );
134 bc().addReadOnly (dialog->docIndentRB);
135 bc().addReadOnly (dialog->docSkipRB);
137 bc().addReadOnly (dialog->docPagestyleCO);
138 bc().addReadOnly (dialog->docFontsCO);
139 bc().addReadOnly (dialog->docFontsizeCO);
140 bc().addReadOnly (dialog->docSidesOneRB);
141 bc().addReadOnly (dialog->docSidesTwoRB);
142 bc().addReadOnly (dialog->docColumnsOneRB);
143 bc().addReadOnly (dialog->docColumnsTwoRB);
144 bc().addReadOnly (dialog->docExtraED);
145 bc().addReadOnly (dialog->docSkipED);
146 bc().addReadOnly (dialog->docSkipCO);
147 bc().addReadOnly (dialog->docSpacingCO);
148 bc().addReadOnly (dialog->docSpacingED);
150 // the document language page
151 dialog->inputEncCO->insertItem( _( "default" ) );
152 dialog->inputEncCO->insertItem( _( "auto" ) );
153 dialog->inputEncCO->insertItem( _( "latin1" ) );
154 dialog->inputEncCO->insertItem( _( "latin2" ) );
155 dialog->inputEncCO->insertItem( _( "latin3" ) );
156 dialog->inputEncCO->insertItem( _( "latin4" ) );
157 dialog->inputEncCO->insertItem( _( "latin5" ) );
158 dialog->inputEncCO->insertItem( _( "latin9" ) );
159 dialog->inputEncCO->insertItem( _( "koi8-r" ) );
160 dialog->inputEncCO->insertItem( _( "koi8-u" ) );
161 dialog->inputEncCO->insertItem( _( "cp866" ) );
162 dialog->inputEncCO->insertItem( _( "cp1251" ) );
163 dialog->inputEncCO->insertItem( _( "iso88595" ) );
165 for (Languages::const_iterator cit = languages.begin();
166 cit != languages.end(); ++cit) {
167 dialog->languageCO->insertItem( (*cit).second.lang() );
170 dialog->quotesLanguageCO->insertItem( _( "``text''" ) );
171 dialog->quotesLanguageCO->insertItem( _( "''text''" ) );
172 dialog->quotesLanguageCO->insertItem( _( ",,text``" ) );
173 dialog->quotesLanguageCO->insertItem( _( ",,text''" ) );
174 dialog->quotesLanguageCO->insertItem( _( "«text»" ) );
175 dialog->quotesLanguageCO->insertItem( _( "»text«" ) );
177 bc().addReadOnly (dialog->inputEncCO);
179 // the document options page
180 dialog->secNumDepthSB->setRange( -2, 5 );
181 dialog->tocDepthSB->setRange( -1, 5 );
182 dialog->secNumDepthSB->setSteps( 1, 1 );
183 dialog->tocDepthSB->setRange( 1, 1 );
184 for (int n=0; tex_graphics[n][0]; ++n) {
185 dialog->postscriptDriverCO->insertItem( tex_graphics[n] );
188 bc().addReadOnly (dialog->secNumDepthSB);
189 bc().addReadOnly (dialog->tocDepthSB);
190 bc().addReadOnly (dialog->useAmsMathCB);
191 bc().addReadOnly (dialog->floatPlacementED);
192 bc().addReadOnly (dialog->postscriptDriverCO);
194 // the document bullets page
195 dialog->bulletSizeCO->insertItem( _( "default" ) );
196 dialog->bulletSizeCO->insertItem( _( "tiny" ) );
197 dialog->bulletSizeCO->insertItem( _( "script" ) );
198 dialog->bulletSizeCO->insertItem( _( "footnote" ) );
199 dialog->bulletSizeCO->insertItem( _( "small" ) );
200 dialog->bulletSizeCO->insertItem( _( "normal" ) );
201 dialog->bulletSizeCO->insertItem( _( "large" ) );
202 dialog->bulletSizeCO->insertItem( _( "Large" ) );
203 dialog->bulletSizeCO->insertItem( _( "LARGE" ) );
204 dialog->bulletSizeCO->insertItem( _( "huge" ) );
205 dialog->bulletSizeCO->insertItem( _( "Huge" ) );
207 dialog->bulletSizeCO->setCurrentItem( 0 );
208 dialog->bulletLatexED->setMaxLength( 80 );
210 bc().addReadOnly (dialog->bulletPanelBG);
211 bc().addReadOnly (dialog->bulletSizeCO);
212 bc().addReadOnly (dialog->bulletLatexED);
217 void QDocument::apply()
219 //if (!lv_->view()->available() || !dialog_.get())
223 bool redo = class_apply();
225 redo = language_apply() || redo;
226 redo = options_apply() || redo;
230 lv_->view()->redoCurrentBuffer();
232 lv_->buffer()->markDirty();
233 setMinibuffer(lv_, _("Document layout set"));
238 void QDocument::cancel()
241 // this avoids confusion when reopening
242 BufferParams & param = lv_->buffer()->params;
243 param.temp_bullets[0] = param.user_defined_bullets[0];
244 param.temp_bullets[1] = param.user_defined_bullets[1];
245 param.temp_bullets[2] = param.user_defined_bullets[2];
246 param.temp_bullets[3] = param.user_defined_bullets[3];
252 void QDocument::update_contents()
260 BufferParams const & params = lv_->buffer()->params;
262 class_update(params);
263 paper_update(params);
264 language_update(params);
265 options_update(params);
266 bullets_update(params);
272 bool QDocument::input( FL_OBJECT * ob, long data )
274 State cb = static_cast<State>( data );
277 case CHECKCHOICECLASS:
278 CheckChoiceClass(ob, 0);
280 case CHOICEBULLETSIZE:
281 ChoiceBulletSize(ob, 0);
283 case INPUTBULLETLATEX:
284 InputBulletLaTeX(ob, 0);
301 BulletBMTable(ob, 0);
309 case CHECKCHOICECLASS:
310 case CHOICEBULLETSIZE:
311 case INPUTBULLETLATEX:
313 return CheckDocumentInput(ob, 0);
322 void QDocument::ComboInputCB(int, void * v, Combox * combox)
324 QDocument * pre = static_cast<QDocument*>(v);
325 if (combox == pre->combo_doc_class.get())
326 pre->CheckChoiceClass(0, 0);
327 pre->bc().valid(pre->CheckDocumentInput(0,0));
330 bool QDocument::class_apply()
333 BufferParams ¶ms = lv_->buffer()->params;
335 // If default skip is a "Length" but there's no text in the
336 // input field, reset the kind to "Medskip", which is the default.
337 if( ( dialog_->docSkipCO->currentItem() == 3 ) &&
338 dialog_->docSkipED->text().isEmpty() )
339 dialog_->docSkipCO->setCurrentItem( 1 );
341 params.fonts = dialog_->docFontsCO->currentText();
342 params.fontsize = dialog_->docFontSizeCO->currentText();
343 params.pagestyle = dialog->docPagestyleCO->currentText();
345 unsigned int const new_class = dialog_->docClassCO->currentItem();
347 if (params.textclass != new_class) {
348 // try to load new_class
349 if (textclasslist.Load(new_class)) {
350 // successfully loaded
352 setMinibuffer(lv_, _("Converting document to new document class..."));
354 int ret = cap.SwitchLayoutsBetweenClasses(params.textclass, new_class,
355 lv_->buffer()->paragraph,
356 lv_->buffer()->params);
360 s = _("One paragraph couldn't be converted");
363 s += _(" paragraphs couldn't be converted");
365 Alert::alert(_("Conversion Errors!"),s,
366 _("into chosen document class"));
369 params.textclass = new_class;
371 // problem changing class -- warn user and retain old style
372 Alert::alert(_("Conversion Errors!"),
373 _("Errors loading new document class."),
374 _("Reverting to original document class."));
375 dialog_->docClassCO->setCurrentItem( params.textclass );
378 BufferParams::PARSEP tmpsep = params.paragraph_separation;
379 if( dialog_->_docIndentRB->isChecked() )
380 params.paragraph_separation = BufferParams::PARSEP_INDENT;
382 params.paragraph_separation = BufferParams::PARSEP_SKIP;
383 if (tmpsep != params.paragraph_separation)
386 VSpace tmpdefskip = params.getDefSkip();
387 switch( dialog_->docSkipCO->currentItem() ) {
389 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
392 params.setDefSkip(VSpace(VSpace::MEDSKIP));
395 params.setDefSkip(VSpace(VSpace::BIGSKIP));
399 (VSpace(LyXGlueLength(dialog_->docSkipED->text())));
401 // DocumentDefskipCB assures that this never happens
402 // ... so why is there code for it ?
404 params.setDefSkip(VSpace(VSpace::MEDSKIP));
407 if (!(tmpdefskip == params.getDefSkip()))
410 if( dialog_->docColumnsTwo->isChecked() )
414 if( dialog_->docSidesTwo->isChecked() )
415 params.sides = LyXTextClass::TwoSides;
417 params.sides = LyXTextClass::OneSide;
419 Spacing tmpSpacing = params.spacing;
420 switch( dialog_->docSpacingCO->currentItem() ) {
422 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
423 params.spacing.set(Spacing::Single);
426 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
427 params.spacing.set(Spacing::Onehalf);
430 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
431 params.spacing.set(Spacing::Double);
434 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
435 params.spacing.set(Spacing::Other,
436 dialog_->docSpacingED->text() );
439 if (tmpSpacing != params.spacing)
442 params.options = docExtraED->text();
448 void QDocument::paper_apply()
450 BufferParams & params = lv_->buffer()->params;
453 static_cast<char>(dialog_->papersize2CO->currentItem());
454 params.paperpackage =
455 static_cast<char>(dialog_->paperPackageCO->currentItem() );
456 params.use_geometry = dialog_->useGeometryCB->isChecked();
457 if (dialog_->landscapeRB->isChecked() )
458 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
460 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
461 params.paperwidth = dialog_->customWidthED->text();
462 params.paperheight = dialog_->customHeightED->text();
463 params.leftmargin = dialog_->leftMarginED->text();
464 params.topmargin = dialog_->topMarginED->text();
465 params.rightmargin = dialog_->rightMarginED->text();
466 params.bottommargin = dialog_->bottomMarginED->text();
467 params.headheight = dialog_->headHeightED->text();
468 params.headsep = dialog_->headSepED->text();
469 params.footskip = dialog_->footSkipED->text();
470 lv_->buffer()->setPaperStuff();
474 bool QDocument::language_apply()
476 BufferParams & params = lv_->buffer()->params;
477 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
480 switch (dialog_->quotesLanguageCO->currentItem() ) {
482 lga = InsetQuotes::EnglishQ;
485 lga = InsetQuotes::SwedishQ;
488 lga = InsetQuotes::GermanQ;
491 lga = InsetQuotes::PolishQ;
494 lga = InsetQuotes::FrenchQ;
497 lga = InsetQuotes::DanishQ;
500 params.quotes_language = lga;
501 if (dialog_->singleRB->isChecked() )
502 params.quotes_times = InsetQuotes::SingleQ;
504 params.quotes_times = InsetQuotes::DoubleQ;
506 Language const * old_language = params.language;
507 Language const * new_language =
508 languages.getLanguage(dialog_->languageCO->currentItem() );
510 new_language = default_language;
512 if (old_language != new_language
513 && old_language->RightToLeft() == new_language->RightToLeft()
514 && !lv_->buffer()->isMultiLingual())
515 lv_->buffer()->ChangeLanguage(old_language, new_language);
517 if (old_language != new_language)
520 params.language = new_language;
521 params.inputenc = dialog_->inputEncCO->currentText();
527 bool QDocument::options_apply()
529 BufferParams & params = lv_->buffer()->params;
532 params.graphicsDriver =
533 dialog_->postscriptDriverCO->currentText();
534 params.use_amsmath = dialog_->useAmsMathCB->isChecked();
536 int tmpchar = int(dialog_->secNumDepth->value() );
537 if (params.secnumdepth != tmpchar)
539 params.secnumdepth = tmpchar;
541 params.tocdepth = int(dialog_->tocDepth->value() );
543 params.float_placement =
544 dialog_->floatPlacementED->text();
550 void QDocument::bullets_apply()
552 /* update the bullet settings */
553 BufferParams & param = lv_->buffer()->params;
555 // a little bit of loop unrolling
556 param.user_defined_bullets[0] = param.temp_bullets[0];
557 param.user_defined_bullets[1] = param.temp_bullets[1];
558 param.user_defined_bullets[2] = param.temp_bullets[2];
559 param.user_defined_bullets[3] = param.temp_bullets[3];
563 void QDocument::class_update(BufferParams const & params)
568 LyXTextClass const & tclass = textclasslist[params.textclass];
570 combo_doc_class->select_text(
571 textclasslist.DescOfClass(params.textclass));
572 Qt2Helper::setCurrentComboItem( dialog_->docFonts, params.fonts.c_str() );
573 dialog_->docFontSizeCO->clear();
574 dialog_->docFontSizeCO->insertItem( _( "default" ) );
575 dialog_->docFontSizeCO->insertItem( tclass.opt_fontsize().c_str());
576 dialog_->docFontSizeCO->setCurrentItem( tokenPos(tclass.opt_fontsize(), '|', params.fontsize)+1);
577 dialog_->docPagestyleCO->clear();
578 dialog_->docPagestyleCO->insertItem( _( "default" ) );
579 dialog_->docPagestyleCO->insertItem( tclass.opt_pagestyle().c_str());
580 dialog_->docPagestyleCO->setCurrentItem( tokenPos(tclass.opt_pagestyle(), '|', params.pagestyle)+1);
581 dialog_->docIndentRB->setChecked( false );
582 dialog_->docSkipRB->setChecked( false );
583 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
584 dialog_->docIndentRB->setChecked( true );
586 dialog_->docSkipRB->setChecked( true );
587 switch (params.getDefSkip().kind()) {
588 case VSpace::SMALLSKIP:
589 dialog_->docSkipCO->setCurrentItem( 0 );
591 case VSpace::MEDSKIP:
592 dialog_->docSkipCO->setCurrentItem( 1 );
594 case VSpace::BIGSKIP:
595 dialog_->docSkipCO->setCurrentItem( 2 );
598 dialog_->docSkipCO->setCurrentItem( 3 );
599 dialog_->docSkipED->setText( params.getDefSkip().asLyXCommand().c_str());
602 dialog_->docSkipCO->setCurrentItem( 1 );
605 dialog_->docSidesOneRB->setChecked( false );
606 dialog_->docSidesTwoRB->setChecked( false );
607 if (params.sides == LyXTextClass::TwoSides)
608 dialog_->docSidesTwo->setChecked( true );
610 dialog_->docSidesOne->setChecked( true );
611 dialog_->docColumnsOneRB->setChecked( false );
612 dialog_->docColumnsTwoRB->setChecked( false );
613 if (params.columns == 2)
614 dialog_->docColumnsTwoRB->setChecked( true );
616 dialog_->docColumnsOneRB->setChecked( true );
617 dialog_->docSpacingED->setText( "" );
618 switch (params.spacing.getSpace()) {
619 case Spacing::Default: // nothing bad should happen with this
620 case Spacing::Single:
622 dialog_->docSpacingCO->setCurrentItem( 0 );
624 case Spacing::Onehalf:
626 dialog_->docSpacingCO->setCurrentItem( 1 );
628 case Spacing::Double:
630 dialog_->docSpacingCO->setCurrentItem( 2 );
634 dialog_->docSpacingCO->setCurrentItem( 3 );
636 sval.sprintf("%g",params.spacing.getValue());
637 dialog_->docSpacingED->setText( sval );
641 if (!params.options.empty())
642 dialog_->docExtraED->setText(, params.options.c_str());
644 dialog_->docExtraED->setText( "" );
648 void QDocument::language_update(BufferParams const & params)
650 if (!language_.get())
653 Qt2Helper::setCurrentItemText( dialog_->languageCO, params.language->lang() );
654 Qt2Helper::setCurrentItemText( dialog_->inputEncCO, params.inputenc.c_str() );
655 dialog_->quotesLanguageCO->setCurrentItem( params.quotes_language );
656 dialog_->singleRB->setChecked( false );
657 dialog_->doubleRB->setChecked( false );
658 if (params.quotes_times == InsetQuotes::SingleQ)
659 dialog_->singleRB->setChecked( true );
661 dialog_->doubleRB->setChecked( true );
665 void QDocument::options_update(BufferParams const & params)
670 Qt2Helper::setCurrentItemText( dialog_->postscriptDriverCO,
671 params.graphicsDriver.c_str());
672 dialog_->useAmsMathCB->setChecked( params.use_amsmath );
673 dialog_->secNumDepthSB->setValue( params.secnumdepth );
674 dialog_->setTocDepthSB->setValue( params.tocdepth );
675 if (!params.float_placement.empty())
676 dialog_->floatPlacementED->setText( params.float_placement.c_str());
678 dialog_->floatPlacementED->setText( "" );
682 void QDocument::paper_update(BufferParams const & params)
687 dialog_->papersize2CO->setCurrentItem( params.papersize2 );
688 dialog_->paperPackageCO->setCurrentItem( params.paperpackage );
689 dialog_->useGeometryCB->setChecked( params.use_geometry );
690 dialog_->portraitRB->setChecked( false );
691 dialog_->landscapeRB->setChecked( false );
692 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
693 dialog_->landscapeRB->setChecked( true );
695 dialog_->portraitRB->setChecked( true );
696 dialog_->customWidthED->setText( params.paperwidth.c_str());
697 dialog_->customHeightED->setText( params.paperheight.c_str());
698 dialog_->leftMarginED->setText( params.leftmargin.c_str());
699 dialog_->topMarginED->setText( params.topmargin.c_str());
700 dialog_->rightMarginED->setText( params.rightmargin.c_str());
701 dialog_->bottomMarginED->setText( params.bottommargin.c_str());
702 dialog_->headHeightED->setText( params.headheight.c_str());
703 dialog_->headSepED->setText( params.headsep.c_str());
704 dialog_->footSkipED->setText( params.footskip.c_str());
705 dialog_->papersize2CO->setFocus();
709 void QDocument::bullets_update(BufferParams const & params)
711 bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
712 setEnabled(fbullet, !isLinuxDoc);
714 if (isLinuxDoc) return;
716 dialog_->bulletDepth1RB->setChecked( true );
717 dialog_->bulletLatexED->setText( params.user_defined_bullets[0].getText().c_str());
718 dialog_->bulletSizeCO->setCurrentItem( params.user_defined_bullets[0].getSize() + 1);
722 void QDocument::checkReadOnly()
724 if (bc().readOnly(lv_->buffer()->isReadonly())) {
725 dialog_->docClassCO->setEnabled( false );
726 dialog_->languageCO->setEnabled( false );
727 dialog_->warningLA->setText( _("Document is read-only."
728 " No changes to layout permitted."));
729 dialog_->warningLA->show();
731 dialog_->docClassCO->setEnabled( true );
732 dialog_->languageCO->setEnabled( true );
733 dialog_->warningLA->hide();
738 void QDocument::checkMarginValues()
740 bool const not_empty =
741 !dialog_->topMarginED->text().isEmpty() ||
742 !dialog_->bottomMarginED->text().isEmpty() ||
743 !dialog_->leftMarginED->text().isEmpty() ||
744 !dialog_->rightMarginED->text().isEmpty() ||
745 !dialog_->headHeightED->text().isEmpty() ||
746 !dialog_->headSepED->text().isEmpty() ||
747 !dialog_->footSkipED->text().isEmpty() ||
748 !dialog_->customWidthED->text().isEmpty() ||
749 !dialog_->customHeightED->text().isEmpty();
751 dialog_->useGeometryCB->setChecked( true );
754 #ifdef I_SUPPOSE_THIS_NEEDS_TO_FIXED
755 bool QDocument::CheckDocumentInput(FL_OBJECT * ob, long)
763 if (ob == paper_->choice_papersize2) {
764 val = fl_get_choice(paper_->choice_papersize2)-1;
765 if (val == BufferParams::VM_PAPER_DEFAULT) {
766 fl_set_button(paper_->push_use_geometry, 0);
769 if ((val != BufferParams::VM_PAPER_USLETTER) &&
770 (val != BufferParams::VM_PAPER_USLEGAL) &&
771 (val != BufferParams::VM_PAPER_USEXECUTIVE) &&
772 (val != BufferParams::VM_PAPER_A4) &&
773 (val != BufferParams::VM_PAPER_A5) &&
774 (val != BufferParams::VM_PAPER_B5)) {
775 fl_set_button(paper_->push_use_geometry, 1);
777 fl_set_choice(paper_->choice_paperpackage,
778 BufferParams::PACKAGE_NONE + 1);
780 } else if (ob == paper_->choice_paperpackage) {
781 val = fl_get_choice(paper_->choice_paperpackage)-1;
782 if (val != BufferParams::PACKAGE_NONE) {
783 fl_set_choice(paper_->choice_papersize2,
784 BufferParams::VM_PAPER_DEFAULT + 1);
785 fl_set_button(paper_->push_use_geometry, 0);
787 } else if (ob == class_->input_doc_spacing) {
788 input = fl_get_input(class_->input_doc_spacing);
790 fl_set_choice (class_->choice_doc_spacing, 1);
792 fl_set_choice(class_->choice_doc_spacing, 4);
795 // this has to be all out of if/elseif because it has to deactivate
796 // the document buttons and so the whole stuff has to be tested again.
797 str = fl_get_input(paper_->input_custom_width);
798 ok = ok && (str.empty() || isValidLength(str));
799 str = fl_get_input(paper_->input_custom_height);
800 ok = ok && (str.empty() || isValidLength(str));
801 str = fl_get_input(paper_->input_left_margin);
802 ok = ok && (str.empty() || isValidLength(str));
803 str = fl_get_input(paper_->input_right_margin);
804 ok = ok && (str.empty() || isValidLength(str));
805 str = fl_get_input(paper_->input_top_margin);
806 ok = ok && (str.empty() || isValidLength(str));
807 str = fl_get_input(paper_->input_bottom_margin);
808 ok = ok && (str.empty() || isValidLength(str));
809 str = fl_get_input(paper_->input_head_height);
810 ok = ok && (str.empty() || isValidLength(str));
811 str = fl_get_input(paper_->input_head_sep);
812 ok = ok && (str.empty() || isValidLength(str));
813 str = fl_get_input(paper_->input_foot_skip);
814 ok = ok && (str.empty() || isValidLength(str));
815 // "Synchronize" the choice and the input field, so that it
816 // is impossible to commit senseless data.
817 input = fl_get_input (class_->input_doc_skip);
818 if (ob == class_->input_doc_skip) {
820 fl_set_choice (class_->choice_doc_skip, 2);
821 } else if (isValidGlueLength (input)) {
822 fl_set_choice (class_->choice_doc_skip, 4);
824 fl_set_choice(class_->choice_doc_skip, 4);
828 if (*input && !isValidGlueLength(input))
831 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
833 else if (fl_get_choice(class_->choice_doc_skip) != 4)
834 fl_set_input (class_->input_doc_skip, "");
836 input = fl_get_input(class_->input_doc_spacing);
837 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
839 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
840 fl_set_input (class_->input_doc_spacing, "");
845 void QDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/ )
847 BufferParams & param = lv_->buffer()->params;
849 // convert from 1-6 range to -1-4
850 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
851 fl_set_input(bullets_->input_bullet_latex,
852 param.temp_bullets[current_bullet_depth].getText().c_str());
856 void QDocument::InputBulletLaTeX(FL_OBJECT *, long)
858 BufferParams & param = lv_->buffer()->params;
860 param.temp_bullets[current_bullet_depth].
861 setText(fl_get_input(bullets_->input_bullet_latex));
865 void QDocument::BulletDepth(FL_OBJECT * ob, State cb)
867 /* Should I do the following:
868 * 1. change to the panel that the current bullet belongs in
869 * 2. show that bullet as selected
870 * 3. change the size setting to the size of the bullet in Q.
871 * 4. display the latex equivalent in the latex box
873 * I'm inclined to just go with 3 and 4 at the moment and
874 * maybe try to support the others later
876 BufferParams & param = lv_->buffer()->params;
879 if (cb == BULLETDEPTH1 )
881 else if (cb == BULLETDEPTH2 )
883 else if (cb == BULLETDEPTH3 )
885 else if (cb == BULLETDEPTH4 )
888 switch (fl_get_button_numb(ob)) {
890 // right mouse button resets to default
891 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
893 current_bullet_depth = data;
894 fl_set_input(bullets_->input_bullet_latex,
895 param.temp_bullets[data].getText().c_str());
896 fl_set_choice(bullets_->choice_bullet_size,
897 param.temp_bullets[data].getSize() + 2);
902 void QDocument::BulletPanel(FL_OBJECT * /*ob*/, State cb)
904 /* Here we have to change the background pixmap to that selected */
905 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
908 if (cb == BULLETPANEL1 )
910 else if (cb == BULLETPANEL2 )
912 else if (cb == BULLETPANEL3 )
914 else if (cb == BULLETPANEL4 )
916 else if (cb == BULLETPANEL5 )
918 else if (cb == BULLETPANEL6 )
921 if (data != current_bullet_panel) {
922 fl_freeze_form(bullets_->form);
923 current_bullet_panel = data;
925 /* free the current pixmap */
926 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
929 /* display the new one */
931 new_panel = "standard";
934 new_panel = "amssymb";
937 new_panel = "psnfss1";
940 new_panel = "psnfss2";
943 new_panel = "psnfss3";
946 new_panel = "psnfss4";
949 /* something very wrong happened */
950 // play it safe for now but should be an exception
951 current_bullet_panel = 0; // standard panel
952 new_panel = "standard";
956 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
957 LibFileSearch("images", new_panel).c_str());
958 fl_redraw_object(bullets_->bmtable_bullet_panel);
959 fl_unfreeze_form(bullets_->form);
964 void QDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/ )
966 /* handle the user input by setting the current bullet depth's pixmap */
967 /* to that extracted from the current chosen position of the BMTable */
968 /* Don't forget to free the button's old pixmap first. */
970 BufferParams & param = lv_->buffer()->params;
971 int bmtable_button = fl_get_bmtable(ob);
973 /* try to keep the button held down till another is pushed */
974 /* fl_set_bmtable(ob, 1, bmtable_button); */
975 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
976 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
977 fl_set_input(bullets_->input_bullet_latex,
978 param.temp_bullets[current_bullet_depth].getText().c_str());
982 void QDocument::CheckChoiceClass(FL_OBJECT * ob, long)
985 ob = class_->choice_doc_class;
987 ProhibitInput(lv_->view());
989 unsigned int tc = combo_doc_class->get() - 1;
990 if (textclasslist.Load(tc)) {
991 // we use a copy of the bufferparams because we do not
992 // want to modify them yet.
993 BufferParams params = lv_->buffer()->params;
995 if (params.textclass != tc
996 && Alert::askQuestion(_("Should I set some parameters to"),
997 _("the defaults of this document class?"))) {
998 params.textclass = tc;
999 params.useClassDefaults();
1000 UpdateLayoutDocument(params);
1003 // unable to load new style
1004 Alert::alert(_("Conversion Errors!"),
1005 _("Unable to switch to new document class."),
1006 _("Reverting to original document class."));
1007 combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
1009 AllowInput(lv_->view());
1013 void QDocument::UpdateLayoutDocument(BufferParams const & params)
1019 class_update(params);
1020 paper_update(params);
1021 language_update(params);
1022 options_update(params);
1023 bullets_update(params);