1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000 The LyX Team.
8 * @author Jürgen Vigna, Kalle Dalheimer
10 *======================================================*/
15 #pragma implementation
18 #include "FormDocumentDialog.h"
21 #include "lyx_gui_misc.h"
23 //#include FORMS_H_LOCATION
24 #include XPM_H_LOCATION
26 #include "FormDocument.h"
27 //#include "xform_macros.h"
31 #include "tex-strings.h"
32 #include "bufferparams.h"
33 #include "insets/insetquotes.h"
36 #include "support/filetools.h"
39 #include "BufferView.h"
42 #include "CutAndPaste.h"
43 #include "bufferview_funcs.h"
44 #include "ButtonController.h"
46 #ifdef SIGC_CXX_NAMESPACES
50 #ifdef CXX_WORKING_NAMESPACES
51 using Liason::setMinibuffer;
54 #define USE_CLASS_COMBO 1
56 #include <qcombobox.h>
57 #include <qlineedit.h>
58 #include <qradiobutton.h>
59 #include <qtoolbutton.h>
60 #include <qcheckbox.h>
62 #include <qbuttongroup.h>
66 #include "../../../lib/images/standard.xpm"
67 #include "../../../lib/images/psnfss1.xpm"
68 #include "../../../lib/images/psnfss2.xpm"
69 #include "../../../lib/images/psnfss3.xpm"
70 #include "../../../lib/images/psnfss4.xpm"
71 #include "../../../lib/images/amssymb.xpm"
74 FormDocument::FormDocument(LyXView * lv, Dialogs * d)
75 : FormBaseBD( lv, d, _( "Document Layout" ),
76 new NoRepeatedApplyReadOnlyPolicy ),
77 dialog_(0), lv_(lv), d_(d), u_(0), h_(0),
78 status(POPUP_UNMODIFIED) ,
79 currentBulletPanel(0),
82 // let the popup be shown
83 // This is a permanent connection so we won't bother
84 // storing a copy because we won't be disconnecting.
85 d->showLayoutDocument.connect(slot(this, &FormDocument::show));
88 standardpix = new QPixmap( standard );
89 amssymbpix = new QPixmap( amssymb );
90 psnfss1pix = new QPixmap( psnfss1 );
91 psnfss2pix = new QPixmap( psnfss2 );
92 psnfss3pix = new QPixmap( psnfss3 );
93 psnfss4pix = new QPixmap( psnfss4 );
97 FormDocument::~FormDocument()
108 void FormDocument::build()
112 dialog_ = new FormDocumentDialog( this, 0, _( "Document Layout" ) );
114 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
115 cit != textclasslist.end(); ++cit)
117 dialog_->classesCO->insertItem((*cit).description().c_str());
120 for (n=0; tex_fonts[n][0]; ++n) {
121 dialog_->fontsCO->insertItem( tex_fonts[n] );
124 for(Languages::const_iterator cit = languages.begin();
125 cit != languages.end(); ++cit) {
126 dialog_->languageCO->insertItem((*cit).second.lang().c_str());
129 for (n=0; tex_graphics[n][0]; ++n) {
130 dialog_->psDriverCO->insertItem( tex_graphics[n] );
133 dialog_->bulletDepth1PB->setOn( true );
137 void FormDocument::apply()
139 if (!lv_->view()->available() || !dialog_)
142 bool redo = class_apply();
144 redo = language_apply() || redo;
145 redo = options_apply() || redo;
149 lv_->view()->redoCurrentBuffer();
151 lv_->buffer()->markDirty();
152 setMinibuffer(lv_, _("Document layout set"));
156 bool FormDocument::class_apply()
159 BufferParams ¶ms = lv_->buffer()->params;
161 // If default skip is a "Length" but there's no text in the
162 // input field, reset the kind to "Medskip", which is the default.
163 if( ( dialog_->defaultSkipCO->currentItem() == 4 ) &&
164 ( dialog_->defaultSkipED->text().isEmpty() ) )
165 dialog_->defaultSkipCO->setCurrentItem( 1 );
166 params.fonts = dialog_->fontsCO->currentText();
167 params.fontsize = dialog_->fontSizeCO->currentText();
168 params.pagestyle = dialog_->pagestyleCO->currentText();
170 unsigned int new_class = dialog_->classesCO->currentItem();
171 if (params.textclass != new_class) {
172 // try to load new_class
173 if (textclasslist.Load(new_class)) {
174 // successfully loaded
176 setMinibuffer(lv_, _("Converting document to new document class..."));
178 int ret = cap.SwitchLayoutsBetweenClasses(
179 params.textclass, new_class,
180 lv_->buffer()->paragraph);
184 s = _("One paragraph couldn't be converted");
187 s += _(" paragraphs couldn't be converted");
189 WriteAlert(_("Conversion Errors!"),s,
190 _("into chosen document class"));
193 params.textclass = new_class;
195 // problem changing class -- warn user and retain old style
196 WriteAlert(_("Conversion Errors!"),
197 _("Errors loading new document class."),
198 _("Reverting to original document class."));
199 dialog_->classesCO->setCurrentItem( params.textclass );
202 char tmpsep = params.paragraph_separation;
203 if( dialog_->indentRB->isChecked() )
204 params.paragraph_separation = BufferParams::PARSEP_INDENT;
206 params.paragraph_separation = BufferParams::PARSEP_SKIP;
207 if (tmpsep != params.paragraph_separation)
210 VSpace tmpdefskip = params.getDefSkip();
211 switch( dialog_->defaultSkipCO->currentItem() ) {
213 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
216 params.setDefSkip(VSpace(VSpace::MEDSKIP));
219 params.setDefSkip(VSpace(VSpace::BIGSKIP));
223 (VSpace(LyXGlueLength(dialog_->defaultSkipED->text().latin1())));
225 // DocumentDefskipCB assures that this never happens
227 params.setDefSkip(VSpace(VSpace::MEDSKIP));
230 if (!(tmpdefskip == params.getDefSkip()))
233 if( dialog_->twoColumnsRB->isChecked() )
237 if( dialog_->twoSidesRB->isChecked() )
238 params.sides = LyXTextClass::TwoSides;
240 params.sides = LyXTextClass::OneSide;
242 Spacing tmpSpacing = params.spacing;
243 switch( dialog_->spacingCO->currentItem() ) {
245 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
246 params.spacing.set(Spacing::Single);
249 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
250 params.spacing.set(Spacing::Onehalf);
253 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
254 params.spacing.set(Spacing::Double);
257 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
258 params.spacing.set(Spacing::Other,
259 dialog_->defaultSkipED->text().latin1() );
262 if (tmpSpacing != params.spacing)
265 params.options = dialog_->extraOptionsED->text();
271 void FormDocument::paper_apply()
273 BufferParams & params = lv_->buffer()->params;
275 params.papersize2 = dialog_->papersizeCO->currentItem();
276 params.paperpackage = dialog_->specialCO->currentItem();
277 params.use_geometry = dialog_->CheckBox1->isChecked();
278 if( dialog_->landscapeRB->isChecked() )
279 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
281 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
282 params.paperwidth = dialog_->customWidthED->text();
283 params.paperheight = dialog_->customHeightED->text();
284 params.leftmargin = dialog_->marginLeftED->text();
285 params.topmargin = dialog_->marginTopED->text();
286 params.rightmargin = dialog_->marginRightED->text();
287 params.bottommargin = dialog_->marginBottomED->text();
288 params.headheight = dialog_->headheightED->text();
289 params.headsep = dialog_->headsepED->text();
290 params.footskip = dialog_->footskipED->text();
291 lv_->buffer()->setPaperStuff();
295 bool FormDocument::language_apply()
297 BufferParams & params = lv_->buffer()->params;
298 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
301 switch( dialog_->quoteStyleTypeCO->currentItem() ) {
303 lga = InsetQuotes::EnglishQ;
306 lga = InsetQuotes::SwedishQ;
309 lga = InsetQuotes::GermanQ;
312 lga = InsetQuotes::PolishQ;
315 lga = InsetQuotes::FrenchQ;
318 lga = InsetQuotes::DanishQ;
321 params.quotes_language = lga;
322 if( dialog_->quoteStyleSingleRB->isChecked() )
323 params.quotes_times = InsetQuotes::SingleQ;
325 params.quotes_times = InsetQuotes::DoubleQ;
327 Language const * old_language = params.language;
328 Language const * new_language =
329 languages.getLanguage( dialog_->languageCO->currentText().latin1() );
331 new_language = default_language;
333 if (old_language != new_language
334 && old_language->RightToLeft() == new_language->RightToLeft()
335 && !lv_->buffer()->isMultiLingual())
336 lv_->buffer()->ChangeLanguage(old_language, new_language);
337 if (old_language != new_language) {
340 params.language = new_language;
341 params.inputenc = dialog_->encodingCO->currentText();
347 bool FormDocument::options_apply()
349 BufferParams & params = lv_->buffer()->params;
352 params.graphicsDriver =
353 dialog_->psDriverCO->currentText();
354 params.use_amsmath = dialog_->amsMathCB->isChecked();
356 int tmpchar = dialog_->sectionNumberDepthSB->value();
357 if (params.secnumdepth != tmpchar)
359 params.secnumdepth = tmpchar;
361 params.tocdepth = dialog_->tocDepthSB->value();
363 params.float_placement =
364 dialog_->floatPlacementED->text();
370 void FormDocument::bullets_apply()
372 /* update the bullet settings */
373 BufferParams & param = lv_->buffer()->params;
375 // a little bit of loop unrolling
376 param.user_defined_bullets[0] = param.temp_bullets[0];
377 param.user_defined_bullets[1] = param.temp_bullets[1];
378 param.user_defined_bullets[2] = param.temp_bullets[2];
379 param.user_defined_bullets[3] = param.temp_bullets[3];
383 void FormDocument::cancel()
385 // this avoids confusion when reopening
386 BufferParams & param = lv_->buffer()->params;
387 param.temp_bullets[0] = param.user_defined_bullets[0];
388 param.temp_bullets[1] = param.user_defined_bullets[1];
389 param.temp_bullets[2] = param.user_defined_bullets[2];
390 param.temp_bullets[3] = param.user_defined_bullets[3];
394 void FormDocument::update()
401 BufferParams const & params = lv_->buffer()->params;
403 class_update(params);
404 paper_update(params);
405 language_update(params);
406 options_update(params);
407 bullets_update(params);
411 void FormDocument::class_update(BufferParams const & params)
413 LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
415 for( int i = 0; i < dialog_->classesCO->count(); i++ )
416 if( dialog_->classesCO->text( i ) == textclasslist.DescOfClass( params.textclass ).c_str() )
417 dialog_->classesCO->setCurrentItem( i );
419 for( int i = 0; i < dialog_->fontsCO->count(); i++ )
420 if( dialog_->fontsCO->text( i ) == params.fonts.c_str() )
421 dialog_->fontsCO->setCurrentItem( i );
423 dialog_->fontSizeCO->clear();
424 dialog_->fontSizeCO->insertItem( _("default") );
425 dialog_->fontSizeCO->insertStringList( QStringList::split( "|", tclass.opt_fontsize().c_str() ) );
426 for( int i = 0; i < dialog_->fontSizeCO->count(); i++ )
427 if( dialog_->fontSizeCO->text( i ) ==
428 tokenPos(tclass.opt_fontsize(), '|', params.fontsize)+2)
429 dialog_->fontSizeCO->setCurrentItem( i );
431 dialog_->pagestyleCO->clear();
432 dialog_->pagestyleCO->insertItem( _("default") );
433 dialog_->pagestyleCO->insertStringList( QStringList::split( "|", tclass.opt_pagestyle().c_str() ) );
434 for( int i = 0; i < dialog_->pagestyleCO->count(); i++ )
435 if( dialog_->pagestyleCO->text( i ) ==
436 tokenPos(tclass.opt_pagestyle(), '|', params.pagestyle)+2)
437 dialog_->pagestyleCO->setCurrentItem( i );
439 if (params.paragraph_separation == BufferParams::PARSEP_INDENT) {
440 dialog_->indentRB->setChecked( true );
441 dialog_->skipRB->setChecked( false );
443 dialog_->skipRB->setChecked( true );
444 dialog_->indentRB->setChecked( false );
446 switch (params.getDefSkip().kind()) {
447 case VSpace::SMALLSKIP:
448 dialog_->defaultSkipCO->setCurrentItem( 0 );
450 case VSpace::MEDSKIP:
451 dialog_->defaultSkipCO->setCurrentItem( 1 );
453 case VSpace::BIGSKIP:
454 dialog_->defaultSkipCO->setCurrentItem( 2 );
457 dialog_->defaultSkipCO->setCurrentItem( 3 );
458 dialog_->defaultSkipED->setText( params.getDefSkip().asLyXCommand().c_str() );
461 dialog_->defaultSkipCO->setCurrentItem( 1 );
465 if( params.sides == 2 ) {
466 dialog_->twoSidesRB->setChecked( true );
467 dialog_->oneSideRB->setChecked( false );
469 dialog_->twoSidesRB->setChecked( false );
470 dialog_->oneSideRB->setChecked( true );
473 if( params.columns == 2 ) {
474 dialog_->twoColumnsRB->setChecked( true );
475 dialog_->oneColumnRB->setChecked( false );
477 dialog_->twoColumnsRB->setChecked( false );
478 dialog_->oneColumnRB->setChecked( true );
481 dialog_->spacingED->setText( "" );
482 switch (params.spacing.getSpace()) {
483 case Spacing::Default: // nothing bad should happen with this
484 case Spacing::Single:
486 dialog_->spacingCO->setCurrentItem( 0 );
488 case Spacing::Onehalf:
490 dialog_->spacingCO->setCurrentItem( 1 );
492 case Spacing::Double:
494 dialog_->spacingCO->setCurrentItem( 2 );
498 dialog_->spacingCO->setCurrentItem( 3 );
500 sval.sprintf("%g",params.spacing.getValue());
501 dialog_->spacingED->setText( sval );
505 if (!params.options.empty())
506 dialog_->extraOptionsED->setText( params.options.c_str());
508 dialog_->extraOptionsED->setText( "" );
512 void FormDocument::language_update(BufferParams const & params)
514 for( int i = 0; i < dialog_->languageCO->count(); i++ )
515 if( dialog_->languageCO->text( i ) == params.language->lang().c_str() )
516 dialog_->languageCO->setCurrentItem( i );
519 for( int i = 0; i < dialog_->encodingCO->count(); i++ )
520 if( dialog_->encodingCO->text( i ) == params.inputenc.c_str() )
521 dialog_->encodingCO->setCurrentItem( i );
523 dialog_->quoteStyleTypeCO->setCurrentItem( params.quotes_language );
525 if( params.quotes_times == InsetQuotes::SingleQ ) {
526 dialog_->quoteStyleSingleRB->setChecked( true );
527 dialog_->quoteStyleDoubleRB->setChecked( false );
529 dialog_->quoteStyleSingleRB->setChecked( false );
530 dialog_->quoteStyleDoubleRB->setChecked( true );
535 void FormDocument::options_update(BufferParams const & params)
537 for( int i = 0; i < dialog_->psDriverCO->count(); i++ )
538 if( dialog_->psDriverCO->text( i ) == params.graphicsDriver.c_str() )
539 dialog_->psDriverCO->setCurrentItem( i );
541 dialog_->amsMathCB->setChecked( params.use_amsmath );
542 dialog_->sectionNumberDepthSB->setValue( params.secnumdepth );
543 dialog_->tocDepthSB->setValue( params.tocdepth );
545 if (!params.float_placement.empty())
546 dialog_->floatPlacementED->setText( params.float_placement.c_str());
548 dialog_->floatPlacementED->setText( "" );
552 void FormDocument::paper_update(BufferParams const & params)
554 dialog_->papersizeCO->setCurrentItem( params.papersize2 );
555 dialog_->specialCO->setCurrentItem( params.paperpackage );
556 dialog_->CheckBox1->setChecked( params.use_geometry );
558 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE) {
559 dialog_->landscapeRB->setChecked( true );
560 dialog_->portraitRB->setChecked( false );
562 dialog_->landscapeRB->setChecked( false );
563 dialog_->portraitRB->setChecked( true );
566 dialog_->customWidthED->setText( params.paperwidth.c_str());
567 dialog_->customHeightED->setText( params.paperheight.c_str());
568 dialog_->marginLeftED->setText( params.leftmargin.c_str());
569 dialog_->marginTopED->setText( params.topmargin.c_str());
570 dialog_->marginRightED->setText( params.rightmargin.c_str());
571 dialog_->marginBottomED->setText( params.bottommargin.c_str());
572 dialog_->headheightED->setText( params.headheight.c_str());
573 dialog_->headsepED->setText( params.headsep.c_str());
574 dialog_->footskipED->setText( params.footskip.c_str());
575 dialog_->papersizeCO->setFocus();
579 void FormDocument::bullets_update(BufferParams const & params)
581 if (lv_->buffer()->isLinuxDoc()) {
582 dialog_->bulletTypeBG->setEnabled( false );
583 dialog_->bulletDepth1PB->setEnabled( false );
584 dialog_->bulletDepth2PB->setEnabled( false );
585 dialog_->bulletDepth3PB->setEnabled( false );
586 dialog_->bulletDepth4PB->setEnabled( false );
587 dialog_->bulletSizeCO->setEnabled( false );
588 dialog_->latexED->setEnabled( false );
591 dialog_->bulletTypeBG->setEnabled( true );
592 dialog_->bulletDepth1PB->setEnabled( true );
593 dialog_->bulletDepth2PB->setEnabled( true );
594 dialog_->bulletDepth3PB->setEnabled( true );
595 dialog_->bulletDepth4PB->setEnabled( true );
596 dialog_->bulletSizeCO->setEnabled( true );
597 dialog_->latexED->setEnabled( true );
599 if (lv_->buffer()->isReadonly()) {
600 dialog_->bulletTypeBG->setEnabled( false );
601 dialog_->bulletSizeCO->setEnabled( false );
602 dialog_->latexED->setEnabled( false );
604 dialog_->bulletTypeBG->setEnabled( true );
605 dialog_->bulletSizeCO->setEnabled( true );
606 dialog_->latexED->setEnabled( true );
609 dialog_->bulletDepth1PB->setOn( true );
610 dialog_->latexED->setText( params.user_defined_bullets[0].getText().c_str());
611 dialog_->bulletSizeCO->setCurrentItem( params.user_defined_bullets[0].getSize() + 1);
612 dialog_->bulletStandardPB->setOn( false );
613 dialog_->bulletMathsPB->setOn( false );
614 dialog_->bulletDing1PB->setOn( false );
615 dialog_->bulletDing2PB->setOn( false );
616 dialog_->bulletDing3PB->setOn( false );
617 dialog_->bulletDing4PB->setOn( false );
618 switch( params.user_defined_bullets[0].getFont() ) {
620 dialog_->bulletStandardPB->setOn( true );
623 dialog_->bulletMathsPB->setOn( true );
626 dialog_->bulletDing1PB->setOn( true );
629 dialog_->bulletDing2PB->setOn( true );
632 dialog_->bulletDing3PB->setOn( true );
635 dialog_->bulletDing4PB->setOn( true );
639 dialog_->bulletStandardPB->setOn( true );
644 void FormDocument::free()
654 void FormDocument::checkReadOnly()
656 if (bc_.readOnly(lv_->buffer()->isReadonly())) {
657 dialog_->classesCO->setEnabled( false );
658 dialog_->languageCO->setEnabled( false );
659 dialog_->warningLA->setText( _("Document is read-only."
660 " No changes to layout permitted."));
661 dialog_->warningLA->show();
663 dialog_->classesCO->setEnabled( true );
664 dialog_->languageCO->setEnabled( true );
665 dialog_->warningLA->hide();
670 void FormDocument::checkMarginValues()
673 dialog_->marginTopED->text().isEmpty() &&
674 dialog_->marginBottomED->text().isEmpty() &&
675 dialog_->marginLeftED->text().isEmpty() &&
676 dialog_->marginRightED->text().isEmpty() &&
677 dialog_->headheightED->text().isEmpty() &&
678 dialog_->headsepED->text().isEmpty() &&
679 dialog_->footskipED->text().isEmpty() &&
680 dialog_->customWidthED->text().isEmpty() &&
681 dialog_->customHeightED->text().isEmpty();
683 dialog_->CheckBox1->setChecked( true );
686 bool FormDocument::checkDocumentInput(QWidget* w)
694 if (w == dialog_->papersizeCO) {
695 val = dialog_->papersizeCO->currentItem();
697 if (val == BufferParams::VM_PAPER_DEFAULT) {
698 dialog_->CheckBox1->setChecked( false );
701 if ((val != BufferParams::VM_PAPER_USLETTER) &&
702 (val != BufferParams::VM_PAPER_USLEGAL) &&
703 (val != BufferParams::VM_PAPER_USEXECUTIVE) &&
704 (val != BufferParams::VM_PAPER_A4) &&
705 (val != BufferParams::VM_PAPER_A5) &&
706 (val != BufferParams::VM_PAPER_B5)) {
707 dialog_->CheckBox1->setChecked( true );
709 dialog_->specialCO->setCurrentItem( BufferParams::PACKAGE_NONE );
711 } else if (w == dialog_->specialCO ) {
712 val = dialog_->specialCO->currentItem();
713 if (val != BufferParams::PACKAGE_NONE) {
714 dialog_->papersizeCO->setCurrentItem( BufferParams::VM_PAPER_DEFAULT );
715 dialog_->CheckBox1->setChecked( false );
717 } else if (w == dialog_->spacingED) {
718 input = dialog_->spacingED->text();
719 if (input.isEmpty()) {
720 dialog_->spacingCO->setCurrentItem( 0 );
722 dialog_->spacingCO->setCurrentItem( 3 );
725 // this has to be all out of if/elseif because it has to deactivate
726 // the document buttons and so the whole stuff has to be tested again.
727 str = dialog_->customWidthED->text();
728 ok = ok && (str.empty() || isValidLength(str));
729 str = dialog_->customHeightED->text();
730 ok = ok && (str.empty() || isValidLength(str));
731 str = dialog_->marginLeftED->text();
732 ok = ok && (str.empty() || isValidLength(str));
733 str = dialog_->marginRightED->text();
734 ok = ok && (str.empty() || isValidLength(str));
735 str = dialog_->marginTopED->text();
736 ok = ok && (str.empty() || isValidLength(str));
737 str = dialog_->marginBottomED->text();
738 ok = ok && (str.empty() || isValidLength(str));
739 str = dialog_->headheightED->text();
740 ok = ok && (str.empty() || isValidLength(str));
741 str = dialog_->headsepED->text();
742 ok = ok && (str.empty() || isValidLength(str));
743 str = dialog_->footskipED->text();
744 ok = ok && (str.empty() || isValidLength(str));
745 // "Synchronize" the choice and the input field, so that it
746 // is impossible to commit senseless data.
747 input = dialog_->defaultSkipED->text();
748 if (w == dialog_->defaultSkipED) {
749 if (input.isEmpty()) {
750 dialog_->defaultSkipCO->setCurrentItem( 1 );
751 } else if (isValidGlueLength (input.latin1())) {
752 dialog_->defaultSkipCO->setCurrentItem( 3 );
754 dialog_->defaultSkipCO->setCurrentItem( 3 );
758 if (!input.isEmpty() && !isValidGlueLength(input.latin1()))
761 if(( dialog_->defaultSkipCO->currentItem() == 3 ) && input.isEmpty() )
763 else if( dialog_->defaultSkipCO->currentItem() != 3 )
764 dialog_->defaultSkipED->setText( "" );
766 input = dialog_->spacingED->text();
767 if( ( dialog_->spacingCO->currentItem() == 3 ) && input.isEmpty() )
769 else if( dialog_->spacingCO->currentItem() != 3 )
770 dialog_->spacingED->setText( "" );
775 void FormDocument::choiceBulletSize()
777 BufferParams & param = lv_->buffer()->params;
779 // convert from 0-5 range to -1-4
780 param.temp_bullets[currentBulletDepth].setSize(dialog_->bulletSizeCO->currentItem() - 1);
781 dialog_->latexED->setText( param.temp_bullets[currentBulletDepth].getText().c_str());
785 void FormDocument::inputBulletLaTeX()
787 BufferParams & param = lv_->buffer()->params;
789 param.temp_bullets[currentBulletDepth].
790 setText(dialog_->latexED->text().latin1() );
794 void FormDocument::bulletDepth(int depth)
796 /* Should I do the following: */
797 /* 1. change to the panel that the current bullet belongs in */
798 /* 2. show that bullet as selected */
799 /* 3. change the size setting to the size of the bullet in Q.*/
800 /* 4. display the latex equivalent in the latex box */
802 /* I'm inclined to just go with 3 and 4 at the moment and */
803 /* maybe try to support the others later */
804 BufferParams & param = lv_->buffer()->params;
806 // reset on right mouse button not supported in KLyX
807 // right mouse button resets to default
808 param.temp_bullets[depth] = ITEMIZE_DEFAULTS[depth];
809 dialog_->latexED->setText( param.temp_bullets[depth].getText().c_str());
810 dialog_->bulletSizeCO->setCurrentItem( param.temp_bullets[depth].getSize() + 1 );
812 currentBulletDepth = depth;
816 // PENDING(kalle) Call this.
817 void FormDocument::setBulletPics()
819 QPixmap* currentpix = 0;
820 if( dialog_->bulletStandardPB->isOn() ) {
821 currentpix = standardpix;
822 currentBulletPanel = 0;
823 } else if( dialog_->bulletMathsPB->isOn() ) {
824 currentpix = amssymbpix;
825 currentBulletPanel = 1;
826 } else if( dialog_->bulletDing1PB->isOn() ) {
827 currentpix = psnfss1pix;
828 currentBulletPanel = 2;
829 } else if( dialog_->bulletDing2PB->isOn() ) {
830 currentpix = psnfss2pix;
831 currentBulletPanel = 3;
832 } else if( dialog_->bulletDing3PB->isOn() ) {
833 currentpix = psnfss3pix;
834 currentBulletPanel = 4;
835 } else if( dialog_->bulletDing4PB->isOn() ) {
836 currentpix = psnfss4pix;
837 currentBulletPanel = 5;
840 for( int x = 0; x < 6; x++ )
841 for( int y = 0; y < 6; y++ ) {
842 bulletpics[x*6+y].resize( 44, 29 );
843 bitBlt( &bulletpics[x*6+y], 0, 0, currentpix, x*44, y*29, 44, 29 );
846 // This is disgusting, but the only way since the designer does not
847 // support widget arrays.
848 dialog_->bullet00PB->setPixmap( bulletpics[0] );
849 dialog_->bullet01PB->setPixmap( bulletpics[1] );
850 dialog_->bullet02PB->setPixmap( bulletpics[2] );
851 dialog_->bullet03PB->setPixmap( bulletpics[3] );
852 dialog_->bullet04PB->setPixmap( bulletpics[4] );
853 dialog_->bullet05PB->setPixmap( bulletpics[5] );
854 dialog_->bullet10PB->setPixmap( bulletpics[6] );
855 dialog_->bullet11PB->setPixmap( bulletpics[7] );
856 dialog_->bullet12PB->setPixmap( bulletpics[8] );
857 dialog_->bullet13PB->setPixmap( bulletpics[9] );
858 dialog_->bullet14PB->setPixmap( bulletpics[10] );
859 dialog_->bullet15PB->setPixmap( bulletpics[11] );
860 dialog_->bullet20PB->setPixmap( bulletpics[12] );
861 dialog_->bullet21PB->setPixmap( bulletpics[13] );
862 dialog_->bullet22PB->setPixmap( bulletpics[14] );
863 dialog_->bullet23PB->setPixmap( bulletpics[15] );
864 dialog_->bullet24PB->setPixmap( bulletpics[16] );
865 dialog_->bullet25PB->setPixmap( bulletpics[17] );
866 dialog_->bullet30PB->setPixmap( bulletpics[18] );
867 dialog_->bullet31PB->setPixmap( bulletpics[19] );
868 dialog_->bullet32PB->setPixmap( bulletpics[20] );
869 dialog_->bullet33PB->setPixmap( bulletpics[21] );
870 dialog_->bullet34PB->setPixmap( bulletpics[22] );
871 dialog_->bullet35PB->setPixmap( bulletpics[23] );
872 dialog_->bullet40PB->setPixmap( bulletpics[24] );
873 dialog_->bullet41PB->setPixmap( bulletpics[25] );
874 dialog_->bullet42PB->setPixmap( bulletpics[26] );
875 dialog_->bullet43PB->setPixmap( bulletpics[27] );
876 dialog_->bullet44PB->setPixmap( bulletpics[28] );
877 dialog_->bullet45PB->setPixmap( bulletpics[29] );
878 dialog_->bullet50PB->setPixmap( bulletpics[30] );
879 dialog_->bullet51PB->setPixmap( bulletpics[31] );
880 dialog_->bullet52PB->setPixmap( bulletpics[32] );
881 dialog_->bullet53PB->setPixmap( bulletpics[33] );
882 dialog_->bullet54PB->setPixmap( bulletpics[34] );
883 dialog_->bullet55PB->setPixmap( bulletpics[35] );
887 void FormDocument::bulletBMTable(int button)
889 /* handle the user input by setting the current bullet depth's pixmap */
890 /* to that extracted from the current chosen position of the BMTable */
891 /* Don't forget to free the button's old pixmap first. */
893 BufferParams & param = lv_->buffer()->params;
895 /* try to keep the button held down till another is pushed */
896 /* fl_set_bmtable(ob, 1, bmtable_button); */
897 param.temp_bullets[currentBulletDepth].setFont(currentBulletPanel);
898 param.temp_bullets[currentBulletDepth].setCharacter(button);
899 dialog_->latexED->setText( param.temp_bullets[currentBulletDepth].getText().c_str());
903 void FormDocument::checkChoiceClass(QComboBox* cb)
906 cb = dialog_->classesCO;
908 ProhibitInput(lv_->view());
912 tc = cb->currentItem();
913 tct = cb->currentText();
915 if (textclasslist.Load(tc)) {
916 if (AskQuestion(_("Should I set some parameters to"), tct,
917 _("the defaults of this document class?"))) {
918 BufferParams & params = lv_->buffer()->params;
920 params.textclass = tc;
921 params.useClassDefaults();
922 UpdateLayoutDocument(params);
925 // unable to load new style
926 WriteAlert(_("Conversion Errors!"),
927 _("Unable to switch to new document class."),
928 _("Reverting to original document class."));
930 dialog_->classesCO->setCurrentItem(
931 lv_->buffer()->params.textclass );
933 AllowInput(lv_->view());
937 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
943 class_update(params);
944 paper_update(params);
945 language_update(params);
946 options_update(params);
947 bullets_update(params);