3 * Copyright 2000-2001 The LyX Team.
4 * See the file COPYING.
6 * \author Jürgen Vigna, jug@sad.it
11 #include FORMS_H_LOCATION
12 #include XPM_H_LOCATION
15 #pragma implementation
18 #include "FormDocument.h"
19 #include "form_document.h"
22 #include "lyxtextclasslist.h"
24 #include "tex-strings.h"
25 #include "bufferparams.h"
32 #include "BufferView.h"
35 #include "CutAndPaste.h"
36 #include "bufferview_funcs.h"
37 #include "xforms_helpers.h"
39 #include "input_validators.h" // fl_unsigned_float_filter
40 #include "helper_funcs.h"
41 #include "lyx_main.h" // for user_lyxdir
43 #include "insets/insetquotes.h"
45 #include "support/filetools.h"
46 #include "support/lstrings.h"
52 using Liason::setMinibuffer;
56 FormDocument::FormDocument(LyXView * lv, Dialogs * d)
57 : FormBaseBD(lv, d, _("Document Layout")),
58 ActCell(0), Confirmed(0),
59 current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
61 // let the dialog be shown
62 // This is a permanent connection so we won't bother
63 // storing a copy because we won't be disconnecting.
64 d->showDocument.connect(slot(this, &FormDocument::show));
68 void FormDocument::redraw()
70 if (form() && form()->visible)
71 fl_redraw_form(form());
75 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabbed_folder);
76 if (outer_form && outer_form->visible)
77 fl_redraw_form(outer_form);
81 FL_FORM * FormDocument::form() const
83 if (dialog_.get()) return dialog_->form;
88 void FormDocument::build()
93 dialog_.reset(build_tabbed_document());
95 // Manage the restore, ok, apply, restore and cancel/close buttons
96 bc().setOK(dialog_->button_ok);
97 bc().setApply(dialog_->button_apply);
98 bc().setCancel(dialog_->button_cancel);
99 bc().setRestore(dialog_->button_restore);
100 bc().addReadOnly (dialog_->button_save_defaults);
101 bc().addReadOnly (dialog_->button_reset_defaults);
103 // the document paper form
104 paper_.reset(build_doc_paper());
105 fl_addto_choice(paper_->choice_papersize,
106 _(" Default | Custom | USletter | USlegal "
107 "| USexecutive | A3 | A4 | A5 | B3 | B4 | B5 "));
108 fl_addto_choice(paper_->choice_paperpackage,
111 "| Very small Margins "
112 "| Very wide Margins "));
114 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
115 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
116 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
117 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
118 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
119 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
120 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
121 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
122 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
124 setPrehandler(paper_->input_custom_width);
125 setPrehandler(paper_->input_custom_height);
126 setPrehandler(paper_->input_top_margin);
127 setPrehandler(paper_->input_bottom_margin);
128 setPrehandler(paper_->input_inner_margin);
129 setPrehandler(paper_->input_outer_margin);
130 setPrehandler(paper_->input_head_height);
131 setPrehandler(paper_->input_head_sep);
132 setPrehandler(paper_->input_foot_skip);
134 // Create the contents of the unit choices
135 // Don't include the "%" terms...
136 vector<string> units_vec = getLatexUnits();
138 for (vector<string>::iterator it = units_vec.begin();
139 it != units_vec.end(); ++it) {
140 if (contains(*it, "%"))
141 it = units_vec.erase(it, it+1) - 1;
144 vector<string>::iterator ret =
145 std::remove_if(units_vec.begin(),
147 bind2nd(contains_functor(), "%"));
148 units_vec.erase(ret, units_vec.end());
150 string units = getStringFromVector(units_vec, "|");
152 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
153 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
154 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
155 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
156 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
157 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
158 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
159 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
160 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
162 bc().addReadOnly (paper_->choice_paperpackage);
163 bc().addReadOnly (paper_->group_radio_orientation);
164 bc().addReadOnly (paper_->radio_portrait);
165 bc().addReadOnly (paper_->radio_landscape);
166 bc().addReadOnly (paper_->choice_papersize);
167 bc().addReadOnly (paper_->check_use_geometry);
168 bc().addReadOnly (paper_->input_custom_width);
169 bc().addReadOnly (paper_->input_custom_height);
170 bc().addReadOnly (paper_->input_top_margin);
171 bc().addReadOnly (paper_->input_bottom_margin);
172 bc().addReadOnly (paper_->input_inner_margin);
173 bc().addReadOnly (paper_->input_outer_margin);
174 bc().addReadOnly (paper_->input_head_height);
175 bc().addReadOnly (paper_->input_head_sep);
176 bc().addReadOnly (paper_->input_foot_skip);
178 // the document class form
179 class_.reset(build_doc_class());
182 // The language is a combo-box and has to be inserted manually
183 obj = class_->choice_doc_class;
184 fl_deactivate_object(obj);
185 fl_addto_form(class_->form);
186 combo_doc_class.reset(new Combox(FL_COMBOX_DROPLIST));
187 combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400,
188 dialog_->tabbed_folder);
189 combo_doc_class->shortcut("#C",1);
190 combo_doc_class->setcallback(ComboInputCB, this);
192 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
193 cit != textclasslist.end(); ++cit) {
194 combo_doc_class->addto(cit->description());
197 fl_addto_choice(class_->choice_doc_spacing,
198 _(" Single | OneHalf | Double | Other "));
199 fl_addto_choice(class_->choice_doc_fontsize, "default|10|11|12");
200 for (n=0; tex_fonts[n][0]; ++n) {
201 fl_addto_choice(class_->choice_doc_fonts,tex_fonts[n]);
203 fl_addto_choice(class_->choice_doc_pagestyle,
204 "default|empty|plain|headings|fancy");
205 fl_addto_choice(class_->choice_doc_skip,
206 _(" Smallskip | Medskip | Bigskip | Length "));
207 fl_addto_choice(class_->choice_default_skip_units, units.c_str());
208 fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
209 fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
210 fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
212 setPrehandler(class_->input_doc_extra);
213 setPrehandler(class_->input_doc_skip);
214 setPrehandler(class_->input_doc_spacing);
216 // Set input filters on doc spacing to make it accept only
218 fl_set_input_filter(class_->input_doc_spacing, fl_unsigned_float_filter);
220 bc().addReadOnly (class_->radio_doc_indent);
221 bc().addReadOnly (class_->radio_doc_skip);
223 bc().addReadOnly (class_->choice_doc_pagestyle);
224 bc().addReadOnly (class_->choice_doc_fonts);
225 bc().addReadOnly (class_->choice_doc_fontsize);
226 bc().addReadOnly (class_->radio_doc_sides_one);
227 bc().addReadOnly (class_->radio_doc_sides_two);
228 bc().addReadOnly (class_->radio_doc_columns_one);
229 bc().addReadOnly (class_->radio_doc_columns_two);
230 bc().addReadOnly (class_->input_doc_extra);
231 bc().addReadOnly (class_->input_doc_skip);
232 bc().addReadOnly (class_->choice_doc_skip);
233 bc().addReadOnly (class_->choice_doc_spacing);
234 bc().addReadOnly (class_->input_doc_spacing);
236 // the document language form
237 language_.reset(build_doc_language());
238 fl_addto_choice(language_->choice_inputenc,
239 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
240 "|koi8-r|koi8-u|cp866|cp1251|iso88595");
242 // The language is a combo-box and has to be inserted manually
243 obj = language_->choice_language;
244 fl_deactivate_object(obj);
245 fl_addto_form(language_->form);
246 combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
247 combo_language->add(obj->x, obj->y, obj->w, obj->h, 400,
248 dialog_->tabbed_folder);
249 combo_language->shortcut("#L",1);
250 combo_language->setcallback(ComboInputCB, this);
253 for (Languages::const_iterator cit = languages.begin();
254 cit != languages.end(); ++cit) {
255 combo_language->addto(cit->second.lang());
258 fl_addto_choice(language_->choice_quotes_language,
259 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
260 " «text» | »text« "));
262 bc().addReadOnly (language_->choice_inputenc);
263 bc().addReadOnly (language_->choice_quotes_language);
264 bc().addReadOnly (language_->radio_single);
265 bc().addReadOnly (language_->radio_double);
267 // the document options form
268 options_.reset(build_doc_options());
269 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
270 setPrehandler(options_->input_float_placement);
272 fl_set_counter_bounds(options_->slider_secnumdepth,-2,5);
273 fl_set_counter_bounds(options_->slider_tocdepth,-1,5);
274 fl_set_counter_step(options_->slider_secnumdepth,1,1);
275 fl_set_counter_step(options_->slider_tocdepth,1,1);
276 fl_set_counter_precision(options_->slider_secnumdepth, 0);
277 fl_set_counter_precision(options_->slider_tocdepth, 0);
278 for (n=0; tex_graphics[n][0]; ++n) {
279 fl_addto_choice(options_->choice_postscript_driver,
282 fl_addto_choice(options_->choice_citation_format,
283 _(" Author-year | Numerical "));
285 bc_.addReadOnly (options_->slider_secnumdepth);
286 bc_.addReadOnly (options_->slider_tocdepth);
287 bc_.addReadOnly (options_->check_use_amsmath);
288 bc_.addReadOnly (options_->check_use_natbib);
289 bc_.addReadOnly (options_->choice_citation_format);
290 bc_.addReadOnly (options_->input_float_placement);
291 bc_.addReadOnly (options_->choice_postscript_driver);
293 // the document bullets form
294 bullets_.reset(build_doc_bullet());
295 fl_addto_choice(bullets_->choice_bullet_size,
296 _(" default | tiny | script | footnote | small |"
297 " normal | large | Large | LARGE | huge | Huge"));
298 fl_set_choice(bullets_->choice_bullet_size, 1);
299 fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
300 setPrehandler(bullets_->input_bullet_latex);
301 fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
303 bc().addReadOnly (bullets_->bmtable_bullet_panel);
304 bc().addReadOnly (bullets_->choice_bullet_size);
305 bc().addReadOnly (bullets_->input_bullet_latex);
306 bc().addReadOnly (bullets_->radio_bullet_depth);
307 bc().addReadOnly (bullets_->radio_bullet_panel);
309 fl_addto_tabfolder(dialog_->tabbed_folder,_("Document"),
311 fl_addto_tabfolder(dialog_->tabbed_folder,_("Paper"),
313 fl_addto_tabfolder(dialog_->tabbed_folder,_("Language"),
315 fl_addto_tabfolder(dialog_->tabbed_folder,_("Extra"),
317 fbullet = fl_addto_tabfolder(dialog_->tabbed_folder,_("Bullets"),
319 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
320 lyxerr << _("Your version of libXpm is older than 4.7.\n"
321 "The `bullet' tab of the document dialog "
322 "has been disabled") << '\n';
323 fl_deactivate_object(fbullet);
324 fl_set_object_lcol(fbullet, FL_INACTIVE);
329 void FormDocument::apply()
331 if (!lv_->view()->available() || !dialog_.get())
334 bool redo = class_apply();
336 redo = language_apply() || redo;
337 redo = options_apply() || redo;
341 lv_->view()->redoCurrentBuffer();
343 lv_->buffer()->markDirty();
344 setMinibuffer(lv_, _("Document layout set"));
348 void FormDocument::cancel()
350 // this avoids confusion when reopening
351 BufferParams & param = lv_->buffer()->params;
352 param.temp_bullets[0] = param.user_defined_bullets[0];
353 param.temp_bullets[1] = param.user_defined_bullets[1];
354 param.temp_bullets[2] = param.user_defined_bullets[2];
355 param.temp_bullets[3] = param.user_defined_bullets[3];
360 void FormDocument::update()
367 BufferParams const & params = lv_->buffer()->params;
369 class_update(params);
370 paper_update(params);
371 language_update(params);
372 options_update(params);
373 bullets_update(params);
378 // should this go elsewhere? Maybe a ControllerDocument? (JMarc)
379 /** Save the buffer's parameters as user default.
380 This function saves a file \c user_lyxdir/templates/defaults.lyx
381 which parameters are those of the current buffer. This file
382 is used as a default template when creating a new
383 file. Returns \c true on success.
385 bool saveParamsAsDefault(BufferParams const ¶ms)
387 if (!Alert::askQuestion(_("Do you want to save the current settings"),
388 _("for the document layout as default?"),
389 _("(they will be valid for any new document)")))
392 string const fname = AddName(AddPath(user_lyxdir, "templates/"),
394 Buffer defaults = Buffer(fname);
395 defaults.params = params;
397 // add an empty paragraph. Is this enough?
398 defaults.paragraph = new Paragraph;
400 return defaults.writeFile(defaults.fileName(), false);
405 bool FormDocument::input(FL_OBJECT * ob, long data)
407 State cb = static_cast<State>(data);
410 case CHECKCHOICECLASS:
411 CheckChoiceClass(ob, 0);
413 case CHOICEBULLETSIZE:
414 ChoiceBulletSize(ob, 0);
416 case INPUTBULLETLATEX:
417 InputBulletLaTeX(ob, 0);
434 BulletBMTable(ob, 0);
440 bool const length_input = fl_get_choice(class_->choice_doc_skip) == 4;
441 if (ob == class_->choice_doc_skip) {
442 setEnabled(class_->input_doc_skip, length_input);
443 setEnabled(class_->choice_default_skip_units, length_input);
446 if (ob == class_->choice_doc_spacing)
447 setEnabled(class_->input_doc_spacing,
448 fl_get_choice(class_->choice_doc_spacing) == 4);
450 bool const skip_used = fl_get_button(class_->radio_doc_skip);
451 if (ob == class_->radio_doc_skip ||
452 ob == class_->radio_doc_indent) {
453 setEnabled(class_->choice_doc_skip, skip_used);
454 setEnabled(class_->input_doc_skip,
455 skip_used && length_input);
456 setEnabled(class_->choice_default_skip_units,
457 skip_used && length_input);
458 // Default unit choice is cm if metric, inches if US paper.
459 // If papersize is default, check the lyxrc-settings
460 int const paperchoice = fl_get_choice(paper_->choice_papersize);
461 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
462 || paperchoice == 2 || paperchoice > 5;
463 int const default_unit = metric ? 8 : 9;
464 if (strip(fl_get_input(class_->input_doc_skip)).empty())
465 fl_set_choice(class_->choice_default_skip_units,
469 if (ob == options_->check_use_natbib) {
470 setEnabled(options_->choice_citation_format,
471 fl_get_button(options_->check_use_natbib));
474 if (ob == dialog_->button_save_defaults) {
478 language_apply(params);
479 options_apply(params);
480 bullets_apply(params);
481 saveParamsAsDefault(params);
484 if (ob == dialog_->button_reset_defaults) {
485 BufferParams params = lv_->buffer()->params;
486 params.textclass = combo_doc_class->get() - 1;
487 params.useClassDefaults();
488 UpdateLayoutDocument(params);
491 if (ob == paper_->radio_landscape)
492 fl_set_choice(paper_->choice_paperpackage,
493 BufferParams::PACKAGE_NONE + 1);
495 if (ob == paper_->choice_papersize) {
496 int const paperchoice = fl_get_choice(paper_->choice_papersize);
497 bool const defsize = paperchoice == 1;
498 bool const custom = paperchoice == 2;
499 bool const a3size = paperchoice == 6;
500 bool const b3size = paperchoice == 9;
501 bool const b4size = paperchoice == 10;
504 fl_set_button(paper_->radio_portrait, 1);
506 bool const use_geom = (custom || a3size || b3size || b4size);
508 fl_set_button(paper_->check_use_geometry, int(use_geom));
510 setEnabled(paper_->input_top_margin, use_geom);
511 setEnabled(paper_->input_bottom_margin, use_geom);
512 setEnabled(paper_->input_inner_margin, use_geom);
513 setEnabled(paper_->input_outer_margin, use_geom);
514 setEnabled(paper_->input_head_height, use_geom);
515 setEnabled(paper_->input_head_sep, use_geom);
516 setEnabled(paper_->input_foot_skip, use_geom);
517 setEnabled(paper_->choice_top_margin_units, use_geom);
518 setEnabled(paper_->choice_bottom_margin_units, use_geom);
519 setEnabled(paper_->choice_inner_margin_units, use_geom);
520 setEnabled(paper_->choice_outer_margin_units, use_geom);
521 setEnabled(paper_->choice_head_height_units, use_geom);
522 setEnabled(paper_->choice_head_sep_units, use_geom);
523 setEnabled(paper_->choice_foot_skip_units, use_geom);
524 setEnabled(paper_->choice_custom_width_units, use_geom);
525 setEnabled(paper_->choice_custom_height_units, use_geom);
527 setEnabled(paper_->input_custom_width, custom);
528 setEnabled(paper_->input_custom_height, custom);
529 setEnabled(paper_->choice_custom_width_units, custom);
530 setEnabled(paper_->choice_custom_height_units, custom);
531 setEnabled(paper_->radio_portrait, !custom);
532 setEnabled(paper_->radio_landscape, !custom);
534 // Default unit choice is cm if metric, inches if US paper.
535 // If papersize is default, use the lyxrc-settings
536 bool const metric = (defsize && lyxrc.default_papersize > 3)
537 || paperchoice == 2 || paperchoice > 5;
538 int const default_unit = metric ? 8 : 9;
539 if (strip(fl_get_input(paper_->input_custom_width)).empty())
540 fl_set_choice(paper_->choice_custom_width_units,
542 if (strip(fl_get_input(paper_->input_custom_height)).empty())
543 fl_set_choice(paper_->choice_custom_height_units,
545 if (strip(fl_get_input(paper_->input_top_margin)).empty())
546 fl_set_choice(paper_->choice_top_margin_units,
548 if (strip(fl_get_input(paper_->input_bottom_margin)).empty())
549 fl_set_choice(paper_->choice_bottom_margin_units,
551 if (strip(fl_get_input(paper_->input_inner_margin)).empty())
552 fl_set_choice(paper_->choice_inner_margin_units,
554 if (strip(fl_get_input(paper_->input_outer_margin)).empty())
555 fl_set_choice(paper_->choice_outer_margin_units,
557 if (strip(fl_get_input(paper_->input_head_height)).empty())
558 fl_set_choice(paper_->choice_head_height_units,
560 if (strip(fl_get_input(paper_->input_head_sep)).empty())
561 fl_set_choice(paper_->choice_head_sep_units,
563 if (strip(fl_get_input(paper_->input_foot_skip)).empty())
564 fl_set_choice(paper_->choice_foot_skip_units,
568 if (ob == paper_->choice_papersize ||
569 ob == paper_->radio_portrait ||
570 ob == paper_->radio_landscape) {
572 setEnabled(paper_->choice_paperpackage,
573 //either default papersize (preferences)
574 //or document papersize has to be A4
575 (fl_get_choice(paper_->choice_papersize) == 7
576 || fl_get_choice(paper_->choice_papersize) == 1
577 && lyxrc.default_papersize == 5)
578 && fl_get_button(paper_->radio_portrait));
581 if (ob == paper_->choice_paperpackage) {
582 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
583 fl_set_button(paper_->check_use_geometry, 0);
585 setEnabled(paper_->input_top_margin, false);
586 setEnabled(paper_->input_bottom_margin, false);
587 setEnabled(paper_->input_inner_margin, false);
588 setEnabled(paper_->input_outer_margin, false);
589 setEnabled(paper_->input_head_height, false);
590 setEnabled(paper_->input_head_sep, false);
591 setEnabled(paper_->input_foot_skip, false);
592 setEnabled(paper_->choice_top_margin_units, false);
593 setEnabled(paper_->choice_bottom_margin_units, false);
594 setEnabled(paper_->choice_inner_margin_units, false);
595 setEnabled(paper_->choice_outer_margin_units, false);
596 setEnabled(paper_->choice_head_height_units, false);
597 setEnabled(paper_->choice_head_sep_units, false);
598 setEnabled(paper_->choice_foot_skip_units, false);
602 if (ob == paper_->check_use_geometry) {
603 //don't allow switching geometry off in custom papersize mode
604 //nor in A3, B3, and B4
605 int const choice = fl_get_choice(paper_->choice_papersize);
606 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
607 fl_set_button(paper_->check_use_geometry, 1);
609 fl_set_choice(paper_->choice_paperpackage,
610 BufferParams::PACKAGE_NONE + 1);
612 bool const use_geom = fl_get_button(paper_->check_use_geometry);
613 setEnabled(paper_->input_top_margin, use_geom);
614 setEnabled(paper_->input_bottom_margin, use_geom);
615 setEnabled(paper_->input_inner_margin, use_geom);
616 setEnabled(paper_->input_outer_margin, use_geom);
617 setEnabled(paper_->input_head_height, use_geom);
618 setEnabled(paper_->input_head_sep, use_geom);
619 setEnabled(paper_->input_foot_skip, use_geom);
620 setEnabled(paper_->choice_top_margin_units, use_geom);
621 setEnabled(paper_->choice_bottom_margin_units, use_geom);
622 setEnabled(paper_->choice_inner_margin_units, use_geom);
623 setEnabled(paper_->choice_outer_margin_units, use_geom);
624 setEnabled(paper_->choice_head_height_units, use_geom);
625 setEnabled(paper_->choice_head_sep_units, use_geom);
626 setEnabled(paper_->choice_foot_skip_units, use_geom);
631 case CHECKCHOICECLASS:
632 case CHOICEBULLETSIZE:
633 case INPUTBULLETLATEX:
635 return CheckDocumentInput(ob, 0);
644 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
646 FormDocument * pre = static_cast<FormDocument*>(v);
647 if (combox == pre->combo_doc_class.get())
648 pre->CheckChoiceClass(0, 0);
649 pre->bc().valid(pre->CheckDocumentInput(0,0));
653 bool FormDocument::class_apply(BufferParams ¶ms)
657 // If default skip is a "Length" but there's no text in the
658 // input field, reset the kind to "Medskip", which is the default.
659 if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
660 !*(fl_get_input (class_->input_doc_skip))) {
661 fl_set_choice (class_->choice_doc_skip, 2);
663 params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
664 params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
665 params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
667 params.textclass = combo_doc_class->get() - 1;
669 BufferParams::PARSEP tmpsep = params.paragraph_separation;
670 if (fl_get_button(class_->radio_doc_indent))
671 params.paragraph_separation = BufferParams::PARSEP_INDENT;
673 params.paragraph_separation = BufferParams::PARSEP_SKIP;
674 if (tmpsep != params.paragraph_separation)
677 VSpace tmpdefskip = params.getDefSkip();
678 switch (fl_get_choice (class_->choice_doc_skip)) {
680 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
683 params.setDefSkip(VSpace(VSpace::MEDSKIP));
686 params.setDefSkip(VSpace(VSpace::BIGSKIP));
690 string const length =
691 getLengthFromWidgets(class_->input_doc_skip,
692 class_->choice_default_skip_units);
694 params.setDefSkip(VSpace(LyXGlueLength(length)));
698 // DocumentDefskipCB assures that this never happens
699 params.setDefSkip(VSpace(VSpace::MEDSKIP));
702 if (!(tmpdefskip == params.getDefSkip()))
705 if (fl_get_button(class_->radio_doc_columns_two))
709 if (fl_get_button(class_->radio_doc_sides_two))
710 params.sides = LyXTextClass::TwoSides;
712 params.sides = LyXTextClass::OneSide;
714 Spacing tmpSpacing = params.spacing;
715 switch (fl_get_choice(class_->choice_doc_spacing)) {
717 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
718 params.spacing.set(Spacing::Single);
721 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
722 params.spacing.set(Spacing::Onehalf);
725 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
726 params.spacing.set(Spacing::Double);
729 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
730 params.spacing.set(Spacing::Other,
731 fl_get_input(class_->input_doc_spacing));
734 if (tmpSpacing != params.spacing)
737 params.options = fl_get_input(class_->input_doc_extra);
743 bool FormDocument::class_apply()
745 BufferParams ¶ms = lv_->buffer()->params;
747 unsigned int const old_class = params.textclass;
749 bool redo = class_apply(params);
751 if (params.textclass != old_class) {
752 // try to load new_class
753 if (textclasslist[params.textclass].load()) {
754 // successfully loaded
756 setMinibuffer(lv_, _("Converting document to new document class..."));
757 int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
758 old_class, params.textclass,
759 lv_->buffer()->paragraph,
760 lv_->buffer()->params);
764 s = _("One paragraph couldn't be converted");
767 s += _(" paragraphs couldn't be converted");
769 Alert::alert(_("Conversion Errors!"),s,
770 _("into chosen document class"));
774 // problem changing class -- warn user and retain old style
775 Alert::alert(_("Conversion Errors!"),
776 _("Errors loading new document class."),
777 _("Reverting to original document class."));
778 combo_doc_class->select(int(old_class) + 1);
786 void FormDocument::paper_apply(BufferParams & params)
788 params.papersize2 = char(fl_get_choice(paper_->choice_papersize)-1);
790 params.paperpackage =
791 char(fl_get_choice(paper_->choice_paperpackage)-1);
793 // set params.papersize from params.papersize2 and params.paperpackage
794 params.setPaperStuff();
796 params.use_geometry = fl_get_button(paper_->check_use_geometry);
798 if (fl_get_button(paper_->radio_landscape))
799 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
801 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
804 getLengthFromWidgets(paper_->input_custom_width,
805 paper_->choice_custom_width_units);
808 getLengthFromWidgets(paper_->input_custom_height,
809 paper_->choice_custom_height_units);
812 getLengthFromWidgets(paper_->input_inner_margin,
813 paper_->choice_inner_margin_units);
816 getLengthFromWidgets(paper_->input_top_margin,
817 paper_->choice_top_margin_units);
820 getLengthFromWidgets(paper_->input_outer_margin,
821 paper_->choice_outer_margin_units);
823 params.bottommargin =
824 getLengthFromWidgets(paper_->input_bottom_margin,
825 paper_->choice_bottom_margin_units);
828 getLengthFromWidgets(paper_->input_head_height,
829 paper_->choice_head_height_units);
832 getLengthFromWidgets(paper_->input_head_sep,
833 paper_->choice_head_sep_units);
836 getLengthFromWidgets(paper_->input_foot_skip,
837 paper_->choice_foot_skip_units);
841 void FormDocument::paper_apply()
843 paper_apply(lv_->buffer()->params);
847 bool FormDocument::language_apply(BufferParams & params)
849 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
852 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
854 lga = InsetQuotes::EnglishQ;
857 lga = InsetQuotes::SwedishQ;
860 lga = InsetQuotes::GermanQ;
863 lga = InsetQuotes::PolishQ;
866 lga = InsetQuotes::FrenchQ;
869 lga = InsetQuotes::DanishQ;
872 params.quotes_language = lga;
873 if (fl_get_button(language_->radio_single))
874 params.quotes_times = InsetQuotes::SingleQ;
876 params.quotes_times = InsetQuotes::DoubleQ;
878 Language const * old_language = params.language;
879 Language const * new_language =
880 languages.getLanguage(combo_language->getline());
882 new_language = default_language;
884 if (old_language != new_language
885 && old_language->RightToLeft() == params.language->RightToLeft()
886 && !lv_->buffer()->isMultiLingual())
887 lv_->buffer()->changeLanguage(old_language, params.language);
889 if (old_language != new_language) {
893 params.language = new_language;
894 params.inputenc = fl_get_choice_text(language_->choice_inputenc);
900 bool FormDocument::language_apply()
902 return language_apply(lv_->buffer()->params);
906 bool FormDocument::options_apply(BufferParams & params)
910 params.graphicsDriver =
911 fl_get_choice_text(options_->choice_postscript_driver);
912 params.use_amsmath = fl_get_button(options_->check_use_amsmath);
913 params.use_natbib = fl_get_button(options_->check_use_natbib);
914 params.use_numerical_citations =
915 fl_get_choice(options_->choice_citation_format)-1;
917 int tmpchar = int(fl_get_counter_value(options_->slider_secnumdepth));
918 if (params.secnumdepth != tmpchar)
920 params.secnumdepth = tmpchar;
922 params.tocdepth = int(fl_get_counter_value(options_->slider_tocdepth));
924 params.float_placement =
925 fl_get_input(options_->input_float_placement);
931 bool FormDocument::options_apply()
933 return options_apply(lv_->buffer()->params);
937 void FormDocument::bullets_apply(BufferParams & params)
939 /* update the bullet settings */
940 BufferParams & buf_params = lv_->buffer()->params;
942 // a little bit of loop unrolling
943 params.user_defined_bullets[0] = buf_params.temp_bullets[0];
944 params.user_defined_bullets[1] = buf_params.temp_bullets[1];
945 params.user_defined_bullets[2] = buf_params.temp_bullets[2];
946 params.user_defined_bullets[3] = buf_params.temp_bullets[3];
950 void FormDocument::bullets_apply()
952 bullets_apply(lv_->buffer()->params);
956 void FormDocument::class_update(BufferParams const & params)
961 LyXTextClass const & tclass = textclasslist[params.textclass];
963 combo_doc_class->select(tclass.description());
964 fl_set_choice_text(class_->choice_doc_fonts, params.fonts.c_str());
965 fl_clear_choice(class_->choice_doc_fontsize);
966 fl_addto_choice(class_->choice_doc_fontsize, "default");
967 fl_addto_choice(class_->choice_doc_fontsize,
968 tclass.opt_fontsize().c_str());
969 fl_set_choice(class_->choice_doc_fontsize,
970 tokenPos(tclass.opt_fontsize(), '|', params.fontsize)+2);
971 fl_clear_choice(class_->choice_doc_pagestyle);
972 fl_addto_choice(class_->choice_doc_pagestyle, "default");
973 fl_addto_choice(class_->choice_doc_pagestyle,
974 tclass.opt_pagestyle().c_str());
975 fl_set_choice(class_->choice_doc_pagestyle,
976 tokenPos(tclass.opt_pagestyle(), '|', params.pagestyle)+2);
977 fl_set_button(class_->radio_doc_indent, 0);
978 fl_set_button(class_->radio_doc_skip, 0);
979 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
980 fl_set_button(class_->radio_doc_indent, 1);
982 fl_set_button(class_->radio_doc_skip, 1);
984 bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
985 setEnabled(class_->choice_default_skip_units, input_length);
986 setEnabled(class_->input_doc_skip, input_length);
988 switch (params.getDefSkip().kind()) {
989 case VSpace::SMALLSKIP:
990 fl_set_choice (class_->choice_doc_skip, 1);
992 case VSpace::MEDSKIP:
993 fl_set_choice (class_->choice_doc_skip, 2);
995 case VSpace::BIGSKIP:
996 fl_set_choice (class_->choice_doc_skip, 3);
1000 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1001 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1002 || paperchoice == 2 || paperchoice > 5;
1003 string const default_unit = metric ? "cm" : "in";
1004 string const length = params.getDefSkip().asLyXCommand();
1005 updateWidgetsFromLengthString(class_->input_doc_skip,
1006 class_->choice_default_skip_units,
1007 length, default_unit);
1011 fl_set_choice (class_->choice_doc_skip, 2);
1014 fl_set_button(class_->radio_doc_sides_one, 0);
1015 fl_set_button(class_->radio_doc_sides_two, 0);
1016 setEnabled(class_->choice_doc_skip,
1017 fl_get_button(class_->radio_doc_skip));
1019 if (params.sides == LyXTextClass::TwoSides)
1020 fl_set_button(class_->radio_doc_sides_two, 1);
1022 fl_set_button(class_->radio_doc_sides_one, 1);
1023 fl_set_button(class_->radio_doc_columns_one, 0);
1024 fl_set_button(class_->radio_doc_columns_two, 0);
1025 if (params.columns == 2)
1026 fl_set_button(class_->radio_doc_columns_two, 1);
1028 fl_set_button(class_->radio_doc_columns_one, 1);
1030 fl_set_input(class_->input_doc_spacing, "");
1031 setEnabled(class_->input_doc_spacing, false);
1033 switch (params.spacing.getSpace()) {
1034 case Spacing::Default: // nothing bad should happen with this
1035 case Spacing::Single:
1037 fl_set_choice(class_->choice_doc_spacing, 1);
1039 case Spacing::Onehalf:
1041 fl_set_choice(class_->choice_doc_spacing, 2);
1043 case Spacing::Double:
1045 fl_set_choice(class_->choice_doc_spacing, 3);
1047 case Spacing::Other:
1049 fl_set_choice(class_->choice_doc_spacing, 4);
1051 sprintf(sval,"%g",params.spacing.getValue());
1052 fl_set_input(class_->input_doc_spacing, sval);
1053 setEnabled(class_->input_doc_spacing, true);
1057 if (!params.options.empty())
1058 fl_set_input(class_->input_doc_extra, params.options.c_str());
1060 fl_set_input(class_->input_doc_extra, "");
1064 void FormDocument::language_update(BufferParams const & params)
1066 if (!language_.get())
1069 combo_language->select(params.language->lang());
1070 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1071 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1072 fl_set_button(language_->radio_single, 0);
1073 fl_set_button(language_->radio_double, 0);
1074 if (params.quotes_times == InsetQuotes::SingleQ)
1075 fl_set_button(language_->radio_single, 1);
1077 fl_set_button(language_->radio_double, 1);
1081 void FormDocument::options_update(BufferParams const & params)
1083 if (!options_.get())
1086 fl_set_choice_text(options_->choice_postscript_driver,
1087 params.graphicsDriver.c_str());
1088 fl_set_button(options_->check_use_amsmath, params.use_amsmath);
1089 fl_set_button(options_->check_use_natbib, params.use_natbib);
1090 fl_set_choice(options_->choice_citation_format,
1091 int(params.use_numerical_citations)+1);
1092 setEnabled(options_->choice_citation_format, params.use_natbib);
1093 fl_set_counter_value(options_->slider_secnumdepth, params.secnumdepth);
1094 fl_set_counter_value(options_->slider_tocdepth, params.tocdepth);
1095 if (!params.float_placement.empty())
1096 fl_set_input(options_->input_float_placement,
1097 params.float_placement.c_str());
1099 fl_set_input(options_->input_float_placement, "");
1103 void FormDocument::paper_update(BufferParams const & params)
1108 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1109 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1110 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1112 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1113 bool const useCustom = paperchoice == 2;
1114 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1116 fl_set_button(paper_->radio_portrait, 0);
1117 setEnabled(paper_->radio_portrait, !useCustom);
1118 fl_set_button(paper_->radio_landscape, 0);
1119 setEnabled(paper_->radio_landscape, !useCustom);
1121 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
1122 fl_set_button(paper_->radio_landscape, 1);
1124 fl_set_button(paper_->radio_portrait, 1);
1125 setEnabled(paper_->choice_paperpackage,
1126 //either default papersize (preferences)
1127 //or document papersize has to be A4
1129 || paperchoice == 1 && lyxrc.default_papersize == 5)
1130 && fl_get_button(paper_->radio_portrait));
1132 // Default unit choice is cm if metric, inches if US paper.
1133 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1134 || paperchoice == 2 || paperchoice > 5;
1135 string const default_unit = metric ? "cm" : "in";
1136 updateWidgetsFromLengthString(paper_->input_custom_width,
1137 paper_->choice_custom_width_units,
1138 params.paperwidth, default_unit);
1139 setEnabled(paper_->input_custom_width, useCustom);
1140 setEnabled(paper_->choice_custom_width_units, useCustom);
1142 updateWidgetsFromLengthString(paper_->input_custom_height,
1143 paper_->choice_custom_height_units,
1144 params.paperheight, default_unit);
1145 setEnabled(paper_->input_custom_height, useCustom);
1146 setEnabled(paper_->choice_custom_height_units, useCustom);
1148 updateWidgetsFromLengthString(paper_->input_inner_margin,
1149 paper_->choice_inner_margin_units,
1150 params.leftmargin, default_unit);
1151 setEnabled(paper_->input_inner_margin, useGeom);
1152 setEnabled(paper_->choice_inner_margin_units, useGeom);
1154 updateWidgetsFromLengthString(paper_->input_top_margin,
1155 paper_->choice_top_margin_units,
1156 params.topmargin, default_unit);
1157 setEnabled(paper_->input_top_margin, useGeom);
1158 setEnabled(paper_->choice_top_margin_units, useGeom);
1160 updateWidgetsFromLengthString(paper_->input_outer_margin,
1161 paper_->choice_outer_margin_units,
1162 params.rightmargin, default_unit);
1163 setEnabled(paper_->input_outer_margin, useGeom);
1164 setEnabled(paper_->choice_outer_margin_units, useGeom);
1166 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1167 paper_->choice_bottom_margin_units,
1168 params.bottommargin, default_unit);
1169 setEnabled(paper_->input_bottom_margin, useGeom);
1170 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1172 updateWidgetsFromLengthString(paper_->input_head_height,
1173 paper_->choice_head_height_units,
1174 params.headheight, default_unit);
1175 setEnabled(paper_->input_head_height, useGeom);
1176 setEnabled(paper_->choice_head_height_units, useGeom);
1178 updateWidgetsFromLengthString(paper_->input_head_sep,
1179 paper_->choice_head_sep_units,
1180 params.headsep, default_unit);
1181 setEnabled(paper_->input_head_sep, useGeom);
1182 setEnabled(paper_->choice_head_sep_units, useGeom);
1184 updateWidgetsFromLengthString(paper_->input_foot_skip,
1185 paper_->choice_foot_skip_units,
1186 params.footskip, default_unit);
1187 setEnabled(paper_->input_foot_skip, useGeom);
1188 setEnabled(paper_->choice_foot_skip_units, useGeom);
1190 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1194 void FormDocument::bullets_update(BufferParams const & params)
1196 if (!bullets_.get() ||
1198 (XpmVersion==4 && XpmRevision<7)))
1201 bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
1202 setEnabled(fbullet, !isLinuxDoc);
1204 if (isLinuxDoc) return;
1206 fl_set_button(bullets_->radio_bullet_depth_1, 1);
1207 fl_set_input(bullets_->input_bullet_latex,
1208 params.user_defined_bullets[0].getText().c_str());
1209 fl_set_choice(bullets_->choice_bullet_size,
1210 params.user_defined_bullets[0].getSize() + 2);
1214 void FormDocument::checkReadOnly()
1216 if (bc().readOnly(lv_->buffer()->isReadonly())) {
1217 combo_doc_class->deactivate();
1218 combo_language->deactivate();
1219 fl_set_object_label(dialog_->text_warning,
1220 _("Document is read-only."
1221 " No changes to layout permitted."));
1222 fl_show_object(dialog_->text_warning);
1224 combo_doc_class->activate();
1225 combo_language->activate();
1226 fl_hide_object(dialog_->text_warning);
1231 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
1237 // this has to be all out of if/elseif because it has to deactivate
1238 // the document buttons and so the whole stuff has to be tested again.
1239 // disable OK/Apply if input is not valid
1240 str = fl_get_input(class_->input_doc_skip);
1241 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1242 str = fl_get_input(paper_->input_custom_width);
1243 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1244 str = fl_get_input(paper_->input_custom_height);
1245 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1246 str = fl_get_input(paper_->input_outer_margin);
1247 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1248 str = fl_get_input(paper_->input_inner_margin);
1249 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1250 str = fl_get_input(paper_->input_top_margin);
1251 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1252 str = fl_get_input(paper_->input_bottom_margin);
1253 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1254 str = fl_get_input(paper_->input_head_height);
1255 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1256 str = fl_get_input(paper_->input_head_sep);
1257 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1258 str = fl_get_input(paper_->input_foot_skip);
1259 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1261 //display warning if input is not valid
1262 if (ob == class_->input_doc_skip
1263 || ob == paper_->input_custom_width
1264 || ob == paper_->input_custom_height
1265 || ob == paper_->input_outer_margin
1266 || ob == paper_->input_inner_margin
1267 || ob == paper_->input_top_margin
1268 || ob == paper_->input_bottom_margin
1269 || ob == paper_->input_head_height
1270 || ob == paper_->input_head_sep
1271 || ob == paper_->input_foot_skip) {
1273 fl_set_object_label(dialog_->text_warning,
1274 _("Warning: Invalid Length (valid example: 10mm)"));
1275 fl_show_object(dialog_->text_warning);
1278 fl_hide_object(dialog_->text_warning);
1283 // "Synchronize" the choice and the input field, so that it
1284 // is impossible to commit senseless data.
1285 input = fl_get_input (class_->input_doc_skip);
1286 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1288 else if (fl_get_choice(class_->choice_doc_skip) != 4)
1289 fl_set_input (class_->input_doc_skip, "");
1291 input = fl_get_input(class_->input_doc_spacing);
1292 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1294 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
1295 fl_set_input (class_->input_doc_spacing, "");
1300 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1302 BufferParams & param = lv_->buffer()->params;
1304 // convert from 1-6 range to -1-4
1305 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1306 fl_set_input(bullets_->input_bullet_latex,
1307 param.temp_bullets[current_bullet_depth].getText().c_str());
1311 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1313 BufferParams & param = lv_->buffer()->params;
1315 param.temp_bullets[current_bullet_depth].
1316 setText(fl_get_input(bullets_->input_bullet_latex));
1320 void FormDocument::BulletDepth(FL_OBJECT * ob, State cb)
1322 /* Should I do the following: */
1323 /* 1. change to the panel that the current bullet belongs in */
1324 /* 2. show that bullet as selected */
1325 /* 3. change the size setting to the size of the bullet in Q.*/
1326 /* 4. display the latex equivalent in the latex box */
1328 /* I'm inclined to just go with 3 and 4 at the moment and */
1329 /* maybe try to support the others later */
1330 BufferParams & param = lv_->buffer()->params;
1333 if (cb == BULLETDEPTH1)
1335 else if (cb == BULLETDEPTH2)
1337 else if (cb == BULLETDEPTH3)
1339 else if (cb == BULLETDEPTH4)
1342 switch (fl_get_button_numb(ob)) {
1344 // right mouse button resets to default
1345 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1347 current_bullet_depth = data;
1348 fl_set_input(bullets_->input_bullet_latex,
1349 param.temp_bullets[data].getText().c_str());
1350 fl_set_choice(bullets_->choice_bullet_size,
1351 param.temp_bullets[data].getSize() + 2);
1356 void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, State cb)
1358 /* Here we have to change the background pixmap to that selected */
1359 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1362 if (cb == BULLETPANEL1)
1364 else if (cb == BULLETPANEL2)
1366 else if (cb == BULLETPANEL3)
1368 else if (cb == BULLETPANEL4)
1370 else if (cb == BULLETPANEL5)
1372 else if (cb == BULLETPANEL6)
1375 if (data != current_bullet_panel) {
1376 fl_freeze_form(bullets_->form);
1377 current_bullet_panel = data;
1379 /* free the current pixmap */
1380 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1383 /* display the new one */
1385 new_panel = "standard";
1388 new_panel = "amssymb";
1391 new_panel = "psnfss1";
1394 new_panel = "psnfss2";
1397 new_panel = "psnfss3";
1400 new_panel = "psnfss4";
1403 /* something very wrong happened */
1404 // play it safe for now but should be an exception
1405 current_bullet_panel = 0; // standard panel
1406 new_panel = "standard";
1409 new_panel += ".xpm";
1410 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1411 LibFileSearch("images", new_panel).c_str());
1412 fl_redraw_object(bullets_->bmtable_bullet_panel);
1413 fl_unfreeze_form(bullets_->form);
1418 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1420 /* handle the user input by setting the current bullet depth's pixmap */
1421 /* to that extracted from the current chosen position of the BMTable */
1422 /* Don't forget to free the button's old pixmap first. */
1424 BufferParams & param = lv_->buffer()->params;
1425 int bmtable_button = fl_get_bmtable(ob);
1427 /* try to keep the button held down till another is pushed */
1428 /* fl_set_bmtable(ob, 1, bmtable_button); */
1429 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1430 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1431 fl_set_input(bullets_->input_bullet_latex,
1432 param.temp_bullets[current_bullet_depth].getText().c_str());
1436 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1439 ob = class_->choice_doc_class;
1441 lv_->prohibitInput();
1443 unsigned int tc = combo_doc_class->get() - 1;
1444 if (textclasslist[tc].load()) {
1445 // we use a copy of the bufferparams because we do not
1446 // want to modify them yet.
1447 BufferParams params = lv_->buffer()->params;
1449 if (lyxrc.auto_reset_options) {
1450 params.textclass = tc;
1451 params.useClassDefaults();
1452 UpdateLayoutDocument(params);
1455 // unable to load new style
1456 Alert::alert(_("Conversion Errors!"),
1457 _("Unable to switch to new document class."),
1458 _("Reverting to original document class."));
1459 combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
1465 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1471 class_update(params);
1472 paper_update(params);
1473 language_update(params);
1474 options_update(params);
1475 bullets_update(params);