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_->tabfolder);
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 // Allow the base class to control messages
96 setMessageWidget(dialog_->text_warning);
98 // Manage the restore, ok, apply, restore and cancel/close buttons
99 bc().setOK(dialog_->button_ok);
100 bc().setApply(dialog_->button_apply);
101 bc().setCancel(dialog_->button_close);
102 bc().setRestore(dialog_->button_restore);
103 bc().addReadOnly (dialog_->button_save_defaults);
104 bc().addReadOnly (dialog_->button_reset_defaults);
106 // the document paper form
107 paper_.reset(build_doc_paper());
108 fl_addto_choice(paper_->choice_papersize,
109 _(" Default | Custom | USletter | USlegal "
110 "| USexecutive | A3 | A4 | A5 | B3 | B4 | B5 "));
111 fl_addto_choice(paper_->choice_paperpackage,
114 "| Very small Margins "
115 "| Very wide Margins "));
117 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
118 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
119 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
120 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
121 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
122 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
123 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
124 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
125 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
127 setPrehandler(paper_->input_custom_width);
128 setPrehandler(paper_->input_custom_height);
129 setPrehandler(paper_->input_top_margin);
130 setPrehandler(paper_->input_bottom_margin);
131 setPrehandler(paper_->input_inner_margin);
132 setPrehandler(paper_->input_outer_margin);
133 setPrehandler(paper_->input_head_height);
134 setPrehandler(paper_->input_head_sep);
135 setPrehandler(paper_->input_foot_skip);
137 // Create the contents of the unit choices
138 // Don't include the "%" terms...
139 vector<string> units_vec = getLatexUnits();
141 for (vector<string>::iterator it = units_vec.begin();
142 it != units_vec.end(); ++it) {
143 if (contains(*it, "%"))
144 it = units_vec.erase(it, it+1) - 1;
147 vector<string>::iterator ret =
148 std::remove_if(units_vec.begin(),
150 bind2nd(contains_functor(), "%"));
151 units_vec.erase(ret, units_vec.end());
153 string units = getStringFromVector(units_vec, "|");
155 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
156 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
157 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
158 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
159 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
160 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
161 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
162 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
163 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
165 bc().addReadOnly (paper_->choice_paperpackage);
166 bc().addReadOnly (paper_->radio_portrait);
167 bc().addReadOnly (paper_->radio_landscape);
168 bc().addReadOnly (paper_->choice_papersize);
169 bc().addReadOnly (paper_->check_use_geometry);
170 bc().addReadOnly (paper_->input_custom_width);
171 bc().addReadOnly (paper_->input_custom_height);
172 bc().addReadOnly (paper_->input_top_margin);
173 bc().addReadOnly (paper_->input_bottom_margin);
174 bc().addReadOnly (paper_->input_inner_margin);
175 bc().addReadOnly (paper_->input_outer_margin);
176 bc().addReadOnly (paper_->input_head_height);
177 bc().addReadOnly (paper_->input_head_sep);
178 bc().addReadOnly (paper_->input_foot_skip);
180 // the document class form
181 class_.reset(build_doc_class());
184 // The language is a combo-box and has to be inserted manually
185 obj = class_->choice_doc_class;
186 fl_deactivate_object(obj);
187 fl_addto_form(class_->form);
188 combo_doc_class.reset(new Combox(FL_COMBOX_DROPLIST));
189 combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400,
191 combo_doc_class->shortcut("#C",1);
192 combo_doc_class->setcallback(ComboInputCB, this);
194 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
195 cit != textclasslist.end(); ++cit) {
196 combo_doc_class->addto(cit->description());
199 fl_addto_choice(class_->choice_doc_spacing,
200 _(" Single | OneHalf | Double | Other "));
201 fl_addto_choice(class_->choice_doc_fontsize, "default|10|11|12");
202 for (n=0; tex_fonts[n][0]; ++n) {
203 fl_addto_choice(class_->choice_doc_fonts,tex_fonts[n]);
205 fl_addto_choice(class_->choice_doc_pagestyle,
206 "default|empty|plain|headings|fancy");
207 fl_addto_choice(class_->choice_doc_skip,
208 _(" Smallskip | Medskip | Bigskip | Length "));
209 fl_addto_choice(class_->choice_default_skip_units, units.c_str());
210 fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
211 fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
212 fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
214 setPrehandler(class_->input_doc_extra);
215 setPrehandler(class_->input_doc_skip);
216 setPrehandler(class_->input_doc_spacing);
218 // Set input filters on doc spacing to make it accept only
220 fl_set_input_filter(class_->input_doc_spacing, fl_unsigned_float_filter);
222 bc().addReadOnly (class_->radio_doc_indent);
223 bc().addReadOnly (class_->radio_doc_skip);
225 bc().addReadOnly (class_->choice_doc_pagestyle);
226 bc().addReadOnly (class_->choice_doc_fonts);
227 bc().addReadOnly (class_->choice_doc_fontsize);
228 bc().addReadOnly (class_->radio_doc_sides_one);
229 bc().addReadOnly (class_->radio_doc_sides_two);
230 bc().addReadOnly (class_->radio_doc_columns_one);
231 bc().addReadOnly (class_->radio_doc_columns_two);
232 bc().addReadOnly (class_->input_doc_extra);
233 bc().addReadOnly (class_->input_doc_skip);
234 bc().addReadOnly (class_->choice_doc_skip);
235 bc().addReadOnly (class_->choice_doc_spacing);
236 bc().addReadOnly (class_->input_doc_spacing);
238 // the document language form
239 language_.reset(build_doc_language());
240 fl_addto_choice(language_->choice_inputenc,
241 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
242 "|koi8-r|koi8-u|cp866|cp1251|iso88595");
244 // The language is a combo-box and has to be inserted manually
245 obj = language_->choice_language;
246 fl_deactivate_object(obj);
247 fl_addto_form(language_->form);
248 combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
249 combo_language->add(obj->x, obj->y, obj->w, obj->h, 400,
251 combo_language->shortcut("#L",1);
252 combo_language->setcallback(ComboInputCB, this);
255 for (Languages::const_iterator cit = languages.begin();
256 cit != languages.end(); ++cit) {
257 combo_language->addto(cit->second.lang());
260 fl_addto_choice(language_->choice_quotes_language,
261 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
262 " «text» | »text« "));
264 bc().addReadOnly (language_->choice_inputenc);
265 bc().addReadOnly (language_->choice_quotes_language);
266 bc().addReadOnly (language_->radio_single);
267 bc().addReadOnly (language_->radio_double);
269 // the document options form
270 options_.reset(build_doc_options());
271 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
272 setPrehandler(options_->input_float_placement);
274 fl_set_counter_bounds(options_->counter_secnumdepth,-2,5);
275 fl_set_counter_bounds(options_->counter_tocdepth,-1,5);
276 fl_set_counter_step(options_->counter_secnumdepth,1,1);
277 fl_set_counter_step(options_->counter_tocdepth,1,1);
278 fl_set_counter_precision(options_->counter_secnumdepth, 0);
279 fl_set_counter_precision(options_->counter_tocdepth, 0);
280 for (n=0; tex_graphics[n][0]; ++n) {
281 fl_addto_choice(options_->choice_postscript_driver,
284 fl_addto_choice(options_->choice_citation_format,
285 _(" Author-year | Numerical "));
287 bc_.addReadOnly (options_->counter_secnumdepth);
288 bc_.addReadOnly (options_->counter_tocdepth);
289 bc_.addReadOnly (options_->check_use_amsmath);
290 bc_.addReadOnly (options_->check_use_natbib);
291 bc_.addReadOnly (options_->choice_citation_format);
292 bc_.addReadOnly (options_->input_float_placement);
293 bc_.addReadOnly (options_->choice_postscript_driver);
295 // the document bullets form
296 bullets_.reset(build_doc_bullet());
297 fl_addto_choice(bullets_->choice_bullet_size,
298 _(" default | tiny | script | footnote | small |"
299 " normal | large | Large | LARGE | huge | Huge"));
300 fl_set_choice(bullets_->choice_bullet_size, 1);
301 fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
302 setPrehandler(bullets_->input_bullet_latex);
303 fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
305 bc_.addReadOnly(bullets_->radio_bullet_depth_1);
306 bc_.addReadOnly(bullets_->radio_bullet_depth_2);
307 bc_.addReadOnly(bullets_->radio_bullet_depth_3);
308 bc_.addReadOnly(bullets_->radio_bullet_depth_4);
309 bc_.addReadOnly(bullets_->radio_bullet_panel_standard);
310 bc_.addReadOnly(bullets_->radio_bullet_panel_maths);
311 bc_.addReadOnly(bullets_->radio_bullet_panel_ding1);
312 bc_.addReadOnly(bullets_->radio_bullet_panel_ding2);
313 bc_.addReadOnly(bullets_->radio_bullet_panel_ding3);
314 bc_.addReadOnly(bullets_->radio_bullet_panel_ding4);
316 bc().addReadOnly (bullets_->bmtable_bullet_panel);
317 bc().addReadOnly (bullets_->choice_bullet_size);
318 bc().addReadOnly (bullets_->input_bullet_latex);
320 fl_addto_tabfolder(dialog_->tabfolder,_("Document"),
322 fl_addto_tabfolder(dialog_->tabfolder,_("Paper"),
324 fl_addto_tabfolder(dialog_->tabfolder,_("Language"),
326 fl_addto_tabfolder(dialog_->tabfolder,_("Extra"),
328 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets"),
330 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
331 lyxerr << _("Your version of libXpm is older than 4.7.\n"
332 "The `bullet' tab of the document dialog "
333 "has been disabled") << '\n';
334 fl_deactivate_object(fbullet);
335 fl_set_object_lcol(fbullet, FL_INACTIVE);
340 void FormDocument::apply()
342 if (!lv_->view()->available() || !dialog_.get())
345 bool redo = class_apply();
347 redo = language_apply() || redo;
348 redo = options_apply() || redo;
352 lv_->view()->redoCurrentBuffer();
354 lv_->buffer()->markDirty();
355 setMinibuffer(lv_, _("Document layout set"));
359 void FormDocument::cancel()
361 // this avoids confusion when reopening
362 BufferParams & param = lv_->buffer()->params;
363 param.temp_bullets[0] = param.user_defined_bullets[0];
364 param.temp_bullets[1] = param.user_defined_bullets[1];
365 param.temp_bullets[2] = param.user_defined_bullets[2];
366 param.temp_bullets[3] = param.user_defined_bullets[3];
371 void FormDocument::update()
378 BufferParams const & params = lv_->buffer()->params;
380 class_update(params);
381 paper_update(params);
382 language_update(params);
383 options_update(params);
384 bullets_update(params);
389 // should this go elsewhere? Maybe a ControllerDocument? (JMarc)
390 /** Save the buffer's parameters as user default.
391 This function saves a file \c user_lyxdir/templates/defaults.lyx
392 which parameters are those of the current buffer. This file
393 is used as a default template when creating a new
394 file. Returns \c true on success.
396 bool saveParamsAsDefault(BufferParams const ¶ms)
398 if (!Alert::askQuestion(_("Do you want to save the current settings"),
399 _("for the document layout as default?"),
400 _("(they will be valid for any new document)")))
403 string const fname = AddName(AddPath(user_lyxdir, "templates/"),
405 Buffer defaults = Buffer(fname);
406 defaults.params = params;
408 // add an empty paragraph. Is this enough?
409 defaults.paragraph = new Paragraph;
411 return defaults.writeFile(defaults.fileName(), false);
417 bool FormDocument::input(FL_OBJECT * ob, long data)
419 State cb = static_cast<State>(data);
422 case CHECKCHOICECLASS:
423 CheckChoiceClass(ob, 0);
425 case CHOICEBULLETSIZE:
426 ChoiceBulletSize(ob, 0);
428 case INPUTBULLETLATEX:
429 InputBulletLaTeX(ob, 0);
446 BulletBMTable(ob, 0);
452 bool const length_input = fl_get_choice(class_->choice_doc_skip) == 4;
453 if (ob == class_->choice_doc_skip) {
454 setEnabled(class_->input_doc_skip, length_input);
455 setEnabled(class_->choice_default_skip_units, length_input);
458 if (ob == class_->choice_doc_spacing)
459 setEnabled(class_->input_doc_spacing,
460 fl_get_choice(class_->choice_doc_spacing) == 4);
462 bool const skip_used = fl_get_button(class_->radio_doc_skip);
463 if (ob == class_->radio_doc_skip ||
464 ob == class_->radio_doc_indent) {
465 setEnabled(class_->choice_doc_skip, skip_used);
466 setEnabled(class_->input_doc_skip,
467 skip_used && length_input);
468 setEnabled(class_->choice_default_skip_units,
469 skip_used && length_input);
470 // Default unit choice is cm if metric, inches if US paper.
471 // If papersize is default, check the lyxrc-settings
472 int const paperchoice = fl_get_choice(paper_->choice_papersize);
473 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
474 || paperchoice == 2 || paperchoice > 5;
475 int const default_unit = metric ? 8 : 9;
476 if (strip(fl_get_input(class_->input_doc_skip)).empty())
477 fl_set_choice(class_->choice_default_skip_units,
481 if (ob == options_->check_use_natbib) {
482 setEnabled(options_->choice_citation_format,
483 fl_get_button(options_->check_use_natbib));
486 if (ob == dialog_->button_save_defaults) {
490 language_apply(params);
491 options_apply(params);
492 bullets_apply(params);
493 saveParamsAsDefault(params);
496 if (ob == dialog_->button_reset_defaults) {
497 BufferParams params = lv_->buffer()->params;
498 params.textclass = combo_doc_class->get() - 1;
499 params.useClassDefaults();
500 UpdateLayoutDocument(params);
503 if (ob == paper_->radio_landscape)
504 fl_set_choice(paper_->choice_paperpackage,
505 BufferParams::PACKAGE_NONE + 1);
507 if (ob == paper_->choice_papersize) {
508 int const paperchoice = fl_get_choice(paper_->choice_papersize);
509 bool const defsize = paperchoice == 1;
510 bool const custom = paperchoice == 2;
511 bool const a3size = paperchoice == 6;
512 bool const b3size = paperchoice == 9;
513 bool const b4size = paperchoice == 10;
516 fl_set_button(paper_->radio_portrait, 1);
518 bool const use_geom = (custom || a3size || b3size || b4size);
520 fl_set_button(paper_->check_use_geometry, int(use_geom));
522 setEnabled(paper_->input_top_margin, use_geom);
523 setEnabled(paper_->input_bottom_margin, use_geom);
524 setEnabled(paper_->input_inner_margin, use_geom);
525 setEnabled(paper_->input_outer_margin, use_geom);
526 setEnabled(paper_->input_head_height, use_geom);
527 setEnabled(paper_->input_head_sep, use_geom);
528 setEnabled(paper_->input_foot_skip, use_geom);
529 setEnabled(paper_->choice_top_margin_units, use_geom);
530 setEnabled(paper_->choice_bottom_margin_units, use_geom);
531 setEnabled(paper_->choice_inner_margin_units, use_geom);
532 setEnabled(paper_->choice_outer_margin_units, use_geom);
533 setEnabled(paper_->choice_head_height_units, use_geom);
534 setEnabled(paper_->choice_head_sep_units, use_geom);
535 setEnabled(paper_->choice_foot_skip_units, use_geom);
536 setEnabled(paper_->choice_custom_width_units, use_geom);
537 setEnabled(paper_->choice_custom_height_units, use_geom);
539 setEnabled(paper_->input_custom_width, custom);
540 setEnabled(paper_->input_custom_height, custom);
541 setEnabled(paper_->choice_custom_width_units, custom);
542 setEnabled(paper_->choice_custom_height_units, custom);
543 setEnabled(paper_->radio_portrait, !custom);
544 setEnabled(paper_->radio_landscape, !custom);
546 // Default unit choice is cm if metric, inches if US paper.
547 // If papersize is default, use the lyxrc-settings
548 bool const metric = (defsize && lyxrc.default_papersize > 3)
549 || paperchoice == 2 || paperchoice > 5;
550 int const default_unit = metric ? 8 : 9;
551 if (strip(fl_get_input(paper_->input_custom_width)).empty())
552 fl_set_choice(paper_->choice_custom_width_units,
554 if (strip(fl_get_input(paper_->input_custom_height)).empty())
555 fl_set_choice(paper_->choice_custom_height_units,
557 if (strip(fl_get_input(paper_->input_top_margin)).empty())
558 fl_set_choice(paper_->choice_top_margin_units,
560 if (strip(fl_get_input(paper_->input_bottom_margin)).empty())
561 fl_set_choice(paper_->choice_bottom_margin_units,
563 if (strip(fl_get_input(paper_->input_inner_margin)).empty())
564 fl_set_choice(paper_->choice_inner_margin_units,
566 if (strip(fl_get_input(paper_->input_outer_margin)).empty())
567 fl_set_choice(paper_->choice_outer_margin_units,
569 if (strip(fl_get_input(paper_->input_head_height)).empty())
570 fl_set_choice(paper_->choice_head_height_units,
572 if (strip(fl_get_input(paper_->input_head_sep)).empty())
573 fl_set_choice(paper_->choice_head_sep_units,
575 if (strip(fl_get_input(paper_->input_foot_skip)).empty())
576 fl_set_choice(paper_->choice_foot_skip_units,
580 if (ob == paper_->choice_papersize ||
581 ob == paper_->radio_portrait ||
582 ob == paper_->radio_landscape) {
584 setEnabled(paper_->choice_paperpackage,
585 //either default papersize (preferences)
586 //or document papersize has to be A4
587 (fl_get_choice(paper_->choice_papersize) == 7
588 || fl_get_choice(paper_->choice_papersize) == 1
589 && lyxrc.default_papersize == 5)
590 && fl_get_button(paper_->radio_portrait));
593 if (ob == paper_->choice_paperpackage) {
594 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
595 fl_set_button(paper_->check_use_geometry, 0);
597 setEnabled(paper_->input_top_margin, false);
598 setEnabled(paper_->input_bottom_margin, false);
599 setEnabled(paper_->input_inner_margin, false);
600 setEnabled(paper_->input_outer_margin, false);
601 setEnabled(paper_->input_head_height, false);
602 setEnabled(paper_->input_head_sep, false);
603 setEnabled(paper_->input_foot_skip, false);
604 setEnabled(paper_->choice_top_margin_units, false);
605 setEnabled(paper_->choice_bottom_margin_units, false);
606 setEnabled(paper_->choice_inner_margin_units, false);
607 setEnabled(paper_->choice_outer_margin_units, false);
608 setEnabled(paper_->choice_head_height_units, false);
609 setEnabled(paper_->choice_head_sep_units, false);
610 setEnabled(paper_->choice_foot_skip_units, false);
614 if (ob == paper_->check_use_geometry) {
615 //don't allow switching geometry off in custom papersize mode
616 //nor in A3, B3, and B4
617 int const choice = fl_get_choice(paper_->choice_papersize);
618 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
619 fl_set_button(paper_->check_use_geometry, 1);
621 fl_set_choice(paper_->choice_paperpackage,
622 BufferParams::PACKAGE_NONE + 1);
624 bool const use_geom = fl_get_button(paper_->check_use_geometry);
625 setEnabled(paper_->input_top_margin, use_geom);
626 setEnabled(paper_->input_bottom_margin, use_geom);
627 setEnabled(paper_->input_inner_margin, use_geom);
628 setEnabled(paper_->input_outer_margin, use_geom);
629 setEnabled(paper_->input_head_height, use_geom);
630 setEnabled(paper_->input_head_sep, use_geom);
631 setEnabled(paper_->input_foot_skip, use_geom);
632 setEnabled(paper_->choice_top_margin_units, use_geom);
633 setEnabled(paper_->choice_bottom_margin_units, use_geom);
634 setEnabled(paper_->choice_inner_margin_units, use_geom);
635 setEnabled(paper_->choice_outer_margin_units, use_geom);
636 setEnabled(paper_->choice_head_height_units, use_geom);
637 setEnabled(paper_->choice_head_sep_units, use_geom);
638 setEnabled(paper_->choice_foot_skip_units, use_geom);
643 case CHECKCHOICECLASS:
644 case CHOICEBULLETSIZE:
645 case INPUTBULLETLATEX:
647 return CheckDocumentInput(ob, 0);
656 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
658 FormDocument * pre = static_cast<FormDocument*>(v);
659 if (combox == pre->combo_doc_class.get())
660 pre->CheckChoiceClass(0, 0);
661 pre->bc().valid(pre->CheckDocumentInput(0,0));
665 bool FormDocument::class_apply(BufferParams ¶ms)
669 // If default skip is a "Length" but there's no text in the
670 // input field, reset the kind to "Medskip", which is the default.
671 if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
672 !*(fl_get_input (class_->input_doc_skip))) {
673 fl_set_choice (class_->choice_doc_skip, 2);
675 params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
676 params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
677 params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
679 params.textclass = combo_doc_class->get() - 1;
681 BufferParams::PARSEP tmpsep = params.paragraph_separation;
682 if (fl_get_button(class_->radio_doc_indent))
683 params.paragraph_separation = BufferParams::PARSEP_INDENT;
685 params.paragraph_separation = BufferParams::PARSEP_SKIP;
686 if (tmpsep != params.paragraph_separation)
689 VSpace tmpdefskip = params.getDefSkip();
690 switch (fl_get_choice (class_->choice_doc_skip)) {
692 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
695 params.setDefSkip(VSpace(VSpace::MEDSKIP));
698 params.setDefSkip(VSpace(VSpace::BIGSKIP));
702 string const length =
703 getLengthFromWidgets(class_->input_doc_skip,
704 class_->choice_default_skip_units);
706 params.setDefSkip(VSpace(LyXGlueLength(length)));
710 // DocumentDefskipCB assures that this never happens
711 params.setDefSkip(VSpace(VSpace::MEDSKIP));
714 if (!(tmpdefskip == params.getDefSkip()))
717 if (fl_get_button(class_->radio_doc_columns_two))
721 if (fl_get_button(class_->radio_doc_sides_two))
722 params.sides = LyXTextClass::TwoSides;
724 params.sides = LyXTextClass::OneSide;
726 Spacing tmpSpacing = params.spacing;
727 switch (fl_get_choice(class_->choice_doc_spacing)) {
729 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
730 params.spacing.set(Spacing::Single);
733 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
734 params.spacing.set(Spacing::Onehalf);
737 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
738 params.spacing.set(Spacing::Double);
741 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
742 params.spacing.set(Spacing::Other,
743 fl_get_input(class_->input_doc_spacing));
746 if (tmpSpacing != params.spacing)
749 params.options = fl_get_input(class_->input_doc_extra);
755 bool FormDocument::class_apply()
757 BufferParams ¶ms = lv_->buffer()->params;
759 unsigned int const old_class = params.textclass;
761 bool redo = class_apply(params);
763 if (params.textclass != old_class) {
764 // try to load new_class
765 if (textclasslist[params.textclass].load()) {
766 // successfully loaded
768 setMinibuffer(lv_, _("Converting document to new document class..."));
769 int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
770 old_class, params.textclass,
771 lv_->buffer()->paragraph,
772 lv_->buffer()->params);
776 s = _("One paragraph couldn't be converted");
779 s += _(" paragraphs couldn't be converted");
781 Alert::alert(_("Conversion Errors!"),s,
782 _("into chosen document class"));
786 // problem changing class -- warn user and retain old style
787 Alert::alert(_("Conversion Errors!"),
788 _("Errors loading new document class."),
789 _("Reverting to original document class."));
790 combo_doc_class->select(int(old_class) + 1);
798 void FormDocument::paper_apply(BufferParams & params)
800 params.papersize2 = char(fl_get_choice(paper_->choice_papersize)-1);
802 params.paperpackage =
803 char(fl_get_choice(paper_->choice_paperpackage)-1);
805 // set params.papersize from params.papersize2 and params.paperpackage
806 params.setPaperStuff();
808 params.use_geometry = fl_get_button(paper_->check_use_geometry);
810 if (fl_get_button(paper_->radio_landscape))
811 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
813 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
816 getLengthFromWidgets(paper_->input_custom_width,
817 paper_->choice_custom_width_units);
820 getLengthFromWidgets(paper_->input_custom_height,
821 paper_->choice_custom_height_units);
824 getLengthFromWidgets(paper_->input_inner_margin,
825 paper_->choice_inner_margin_units);
828 getLengthFromWidgets(paper_->input_top_margin,
829 paper_->choice_top_margin_units);
832 getLengthFromWidgets(paper_->input_outer_margin,
833 paper_->choice_outer_margin_units);
835 params.bottommargin =
836 getLengthFromWidgets(paper_->input_bottom_margin,
837 paper_->choice_bottom_margin_units);
840 getLengthFromWidgets(paper_->input_head_height,
841 paper_->choice_head_height_units);
844 getLengthFromWidgets(paper_->input_head_sep,
845 paper_->choice_head_sep_units);
848 getLengthFromWidgets(paper_->input_foot_skip,
849 paper_->choice_foot_skip_units);
853 void FormDocument::paper_apply()
855 paper_apply(lv_->buffer()->params);
859 bool FormDocument::language_apply(BufferParams & params)
861 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
864 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
866 lga = InsetQuotes::EnglishQ;
869 lga = InsetQuotes::SwedishQ;
872 lga = InsetQuotes::GermanQ;
875 lga = InsetQuotes::PolishQ;
878 lga = InsetQuotes::FrenchQ;
881 lga = InsetQuotes::DanishQ;
884 params.quotes_language = lga;
885 if (fl_get_button(language_->radio_single))
886 params.quotes_times = InsetQuotes::SingleQ;
888 params.quotes_times = InsetQuotes::DoubleQ;
890 Language const * old_language = params.language;
891 Language const * new_language =
892 languages.getLanguage(combo_language->getline());
894 new_language = default_language;
896 if (old_language != new_language
897 && old_language->RightToLeft() == params.language->RightToLeft()
898 && !lv_->buffer()->isMultiLingual())
899 lv_->buffer()->changeLanguage(old_language, params.language);
901 if (old_language != new_language) {
905 params.language = new_language;
906 params.inputenc = fl_get_choice_text(language_->choice_inputenc);
912 bool FormDocument::language_apply()
914 return language_apply(lv_->buffer()->params);
918 bool FormDocument::options_apply(BufferParams & params)
922 params.graphicsDriver =
923 fl_get_choice_text(options_->choice_postscript_driver);
924 params.use_amsmath = fl_get_button(options_->check_use_amsmath);
925 params.use_natbib = fl_get_button(options_->check_use_natbib);
926 params.use_numerical_citations =
927 fl_get_choice(options_->choice_citation_format)-1;
929 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
930 if (params.secnumdepth != tmpchar)
932 params.secnumdepth = tmpchar;
934 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
936 params.float_placement =
937 fl_get_input(options_->input_float_placement);
943 bool FormDocument::options_apply()
945 return options_apply(lv_->buffer()->params);
949 void FormDocument::bullets_apply(BufferParams & params)
951 /* update the bullet settings */
952 BufferParams & buf_params = lv_->buffer()->params;
954 // a little bit of loop unrolling
955 params.user_defined_bullets[0] = buf_params.temp_bullets[0];
956 params.user_defined_bullets[1] = buf_params.temp_bullets[1];
957 params.user_defined_bullets[2] = buf_params.temp_bullets[2];
958 params.user_defined_bullets[3] = buf_params.temp_bullets[3];
962 void FormDocument::bullets_apply()
964 bullets_apply(lv_->buffer()->params);
968 void FormDocument::class_update(BufferParams const & params)
973 LyXTextClass const & tclass = textclasslist[params.textclass];
975 combo_doc_class->select(tclass.description());
976 fl_set_choice_text(class_->choice_doc_fonts, params.fonts.c_str());
977 fl_clear_choice(class_->choice_doc_fontsize);
978 fl_addto_choice(class_->choice_doc_fontsize, "default");
979 fl_addto_choice(class_->choice_doc_fontsize,
980 tclass.opt_fontsize().c_str());
981 fl_set_choice(class_->choice_doc_fontsize,
982 tokenPos(tclass.opt_fontsize(), '|', params.fontsize)+2);
983 fl_clear_choice(class_->choice_doc_pagestyle);
984 fl_addto_choice(class_->choice_doc_pagestyle, "default");
985 fl_addto_choice(class_->choice_doc_pagestyle,
986 tclass.opt_pagestyle().c_str());
987 fl_set_choice(class_->choice_doc_pagestyle,
988 tokenPos(tclass.opt_pagestyle(), '|', params.pagestyle)+2);
989 fl_set_button(class_->radio_doc_indent, 0);
990 fl_set_button(class_->radio_doc_skip, 0);
991 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
992 fl_set_button(class_->radio_doc_indent, 1);
994 fl_set_button(class_->radio_doc_skip, 1);
996 bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
997 setEnabled(class_->choice_default_skip_units, input_length);
998 setEnabled(class_->input_doc_skip, input_length);
1000 switch (params.getDefSkip().kind()) {
1001 case VSpace::SMALLSKIP:
1002 fl_set_choice (class_->choice_doc_skip, 1);
1004 case VSpace::MEDSKIP:
1005 fl_set_choice (class_->choice_doc_skip, 2);
1007 case VSpace::BIGSKIP:
1008 fl_set_choice (class_->choice_doc_skip, 3);
1010 case VSpace::LENGTH:
1012 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1013 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1014 || paperchoice == 2 || paperchoice > 5;
1015 string const default_unit = metric ? "cm" : "in";
1016 string const length = params.getDefSkip().asLyXCommand();
1017 updateWidgetsFromLengthString(class_->input_doc_skip,
1018 class_->choice_default_skip_units,
1019 length, default_unit);
1023 fl_set_choice (class_->choice_doc_skip, 2);
1026 fl_set_button(class_->radio_doc_sides_one, 0);
1027 fl_set_button(class_->radio_doc_sides_two, 0);
1028 setEnabled(class_->choice_doc_skip,
1029 fl_get_button(class_->radio_doc_skip));
1031 if (params.sides == LyXTextClass::TwoSides)
1032 fl_set_button(class_->radio_doc_sides_two, 1);
1034 fl_set_button(class_->radio_doc_sides_one, 1);
1035 fl_set_button(class_->radio_doc_columns_one, 0);
1036 fl_set_button(class_->radio_doc_columns_two, 0);
1037 if (params.columns == 2)
1038 fl_set_button(class_->radio_doc_columns_two, 1);
1040 fl_set_button(class_->radio_doc_columns_one, 1);
1042 fl_set_input(class_->input_doc_spacing, "");
1043 setEnabled(class_->input_doc_spacing, false);
1045 switch (params.spacing.getSpace()) {
1046 case Spacing::Default: // nothing bad should happen with this
1047 case Spacing::Single:
1049 fl_set_choice(class_->choice_doc_spacing, 1);
1051 case Spacing::Onehalf:
1053 fl_set_choice(class_->choice_doc_spacing, 2);
1055 case Spacing::Double:
1057 fl_set_choice(class_->choice_doc_spacing, 3);
1059 case Spacing::Other:
1061 fl_set_choice(class_->choice_doc_spacing, 4);
1063 sprintf(sval,"%g",params.spacing.getValue());
1064 fl_set_input(class_->input_doc_spacing, sval);
1065 setEnabled(class_->input_doc_spacing, true);
1069 if (!params.options.empty())
1070 fl_set_input(class_->input_doc_extra, params.options.c_str());
1072 fl_set_input(class_->input_doc_extra, "");
1076 void FormDocument::language_update(BufferParams const & params)
1078 if (!language_.get())
1081 combo_language->select(params.language->lang());
1082 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1083 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1084 fl_set_button(language_->radio_single, 0);
1085 fl_set_button(language_->radio_double, 0);
1086 if (params.quotes_times == InsetQuotes::SingleQ)
1087 fl_set_button(language_->radio_single, 1);
1089 fl_set_button(language_->radio_double, 1);
1093 void FormDocument::options_update(BufferParams const & params)
1095 if (!options_.get())
1098 fl_set_choice_text(options_->choice_postscript_driver,
1099 params.graphicsDriver.c_str());
1100 fl_set_button(options_->check_use_amsmath, params.use_amsmath);
1101 fl_set_button(options_->check_use_natbib, params.use_natbib);
1102 fl_set_choice(options_->choice_citation_format,
1103 int(params.use_numerical_citations)+1);
1104 setEnabled(options_->choice_citation_format, params.use_natbib);
1105 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1106 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1107 if (!params.float_placement.empty())
1108 fl_set_input(options_->input_float_placement,
1109 params.float_placement.c_str());
1111 fl_set_input(options_->input_float_placement, "");
1115 void FormDocument::paper_update(BufferParams const & params)
1120 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1121 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1122 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1124 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1125 bool const useCustom = paperchoice == 2;
1126 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1128 fl_set_button(paper_->radio_portrait, 0);
1129 setEnabled(paper_->radio_portrait, !useCustom);
1130 fl_set_button(paper_->radio_landscape, 0);
1131 setEnabled(paper_->radio_landscape, !useCustom);
1133 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
1134 fl_set_button(paper_->radio_landscape, 1);
1136 fl_set_button(paper_->radio_portrait, 1);
1137 setEnabled(paper_->choice_paperpackage,
1138 //either default papersize (preferences)
1139 //or document papersize has to be A4
1141 || paperchoice == 1 && lyxrc.default_papersize == 5)
1142 && fl_get_button(paper_->radio_portrait));
1144 // Default unit choice is cm if metric, inches if US paper.
1145 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1146 || paperchoice == 2 || paperchoice > 5;
1147 string const default_unit = metric ? "cm" : "in";
1148 updateWidgetsFromLengthString(paper_->input_custom_width,
1149 paper_->choice_custom_width_units,
1150 params.paperwidth, default_unit);
1151 setEnabled(paper_->input_custom_width, useCustom);
1152 setEnabled(paper_->choice_custom_width_units, useCustom);
1154 updateWidgetsFromLengthString(paper_->input_custom_height,
1155 paper_->choice_custom_height_units,
1156 params.paperheight, default_unit);
1157 setEnabled(paper_->input_custom_height, useCustom);
1158 setEnabled(paper_->choice_custom_height_units, useCustom);
1160 updateWidgetsFromLengthString(paper_->input_inner_margin,
1161 paper_->choice_inner_margin_units,
1162 params.leftmargin, default_unit);
1163 setEnabled(paper_->input_inner_margin, useGeom);
1164 setEnabled(paper_->choice_inner_margin_units, useGeom);
1166 updateWidgetsFromLengthString(paper_->input_top_margin,
1167 paper_->choice_top_margin_units,
1168 params.topmargin, default_unit);
1169 setEnabled(paper_->input_top_margin, useGeom);
1170 setEnabled(paper_->choice_top_margin_units, useGeom);
1172 updateWidgetsFromLengthString(paper_->input_outer_margin,
1173 paper_->choice_outer_margin_units,
1174 params.rightmargin, default_unit);
1175 setEnabled(paper_->input_outer_margin, useGeom);
1176 setEnabled(paper_->choice_outer_margin_units, useGeom);
1178 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1179 paper_->choice_bottom_margin_units,
1180 params.bottommargin, default_unit);
1181 setEnabled(paper_->input_bottom_margin, useGeom);
1182 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1184 updateWidgetsFromLengthString(paper_->input_head_height,
1185 paper_->choice_head_height_units,
1186 params.headheight, default_unit);
1187 setEnabled(paper_->input_head_height, useGeom);
1188 setEnabled(paper_->choice_head_height_units, useGeom);
1190 updateWidgetsFromLengthString(paper_->input_head_sep,
1191 paper_->choice_head_sep_units,
1192 params.headsep, default_unit);
1193 setEnabled(paper_->input_head_sep, useGeom);
1194 setEnabled(paper_->choice_head_sep_units, useGeom);
1196 updateWidgetsFromLengthString(paper_->input_foot_skip,
1197 paper_->choice_foot_skip_units,
1198 params.footskip, default_unit);
1199 setEnabled(paper_->input_foot_skip, useGeom);
1200 setEnabled(paper_->choice_foot_skip_units, useGeom);
1202 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1206 void FormDocument::bullets_update(BufferParams const & params)
1208 if (!bullets_.get() ||
1210 (XpmVersion==4 && XpmRevision<7)))
1213 bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
1214 setEnabled(fbullet, !isLinuxDoc);
1216 if (isLinuxDoc) return;
1218 fl_set_button(bullets_->radio_bullet_depth_1, 1);
1219 fl_set_input(bullets_->input_bullet_latex,
1220 params.user_defined_bullets[0].getText().c_str());
1221 fl_set_choice(bullets_->choice_bullet_size,
1222 params.user_defined_bullets[0].getSize() + 2);
1226 void FormDocument::checkReadOnly()
1228 if (bc().readOnly(lv_->buffer()->isReadonly())) {
1229 combo_doc_class->deactivate();
1230 combo_language->deactivate();
1231 postWarning(_("Document is read-only."
1232 " No changes to layout permitted."));
1234 combo_doc_class->activate();
1235 combo_language->activate();
1241 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
1247 // this has to be all out of if/elseif because it has to deactivate
1248 // the document buttons and so the whole stuff has to be tested again.
1249 // disable OK/Apply if input is not valid
1250 str = fl_get_input(class_->input_doc_skip);
1251 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1252 str = fl_get_input(paper_->input_custom_width);
1253 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1254 str = fl_get_input(paper_->input_custom_height);
1255 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1256 str = fl_get_input(paper_->input_outer_margin);
1257 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1258 str = fl_get_input(paper_->input_inner_margin);
1259 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1260 str = fl_get_input(paper_->input_top_margin);
1261 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1262 str = fl_get_input(paper_->input_bottom_margin);
1263 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1264 str = fl_get_input(paper_->input_head_height);
1265 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1266 str = fl_get_input(paper_->input_head_sep);
1267 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1268 str = fl_get_input(paper_->input_foot_skip);
1269 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1271 //display warning if input is not valid
1272 if (ob == class_->input_doc_skip
1273 || ob == paper_->input_custom_width
1274 || ob == paper_->input_custom_height
1275 || ob == paper_->input_outer_margin
1276 || ob == paper_->input_inner_margin
1277 || ob == paper_->input_top_margin
1278 || ob == paper_->input_bottom_margin
1279 || ob == paper_->input_head_height
1280 || ob == paper_->input_head_sep
1281 || ob == paper_->input_foot_skip) {
1283 postWarning(_("Invalid Length (valid example: 10mm)"));
1291 // "Synchronize" the choice and the input field, so that it
1292 // is impossible to commit senseless data.
1293 input = fl_get_input (class_->input_doc_skip);
1294 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1296 else if (fl_get_choice(class_->choice_doc_skip) != 4)
1297 fl_set_input (class_->input_doc_skip, "");
1299 input = fl_get_input(class_->input_doc_spacing);
1300 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1302 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
1303 fl_set_input (class_->input_doc_spacing, "");
1308 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1310 BufferParams & param = lv_->buffer()->params;
1312 // convert from 1-6 range to -1-4
1313 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1314 fl_set_input(bullets_->input_bullet_latex,
1315 param.temp_bullets[current_bullet_depth].getText().c_str());
1319 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1321 BufferParams & param = lv_->buffer()->params;
1323 param.temp_bullets[current_bullet_depth].
1324 setText(fl_get_input(bullets_->input_bullet_latex));
1328 void FormDocument::BulletDepth(FL_OBJECT * ob, State cb)
1330 /* Should I do the following: */
1331 /* 1. change to the panel that the current bullet belongs in */
1332 /* 2. show that bullet as selected */
1333 /* 3. change the size setting to the size of the bullet in Q.*/
1334 /* 4. display the latex equivalent in the latex box */
1336 /* I'm inclined to just go with 3 and 4 at the moment and */
1337 /* maybe try to support the others later */
1338 BufferParams & param = lv_->buffer()->params;
1341 if (cb == BULLETDEPTH1)
1343 else if (cb == BULLETDEPTH2)
1345 else if (cb == BULLETDEPTH3)
1347 else if (cb == BULLETDEPTH4)
1350 switch (fl_get_button_numb(ob)) {
1352 // right mouse button resets to default
1353 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1355 current_bullet_depth = data;
1356 fl_set_input(bullets_->input_bullet_latex,
1357 param.temp_bullets[data].getText().c_str());
1358 fl_set_choice(bullets_->choice_bullet_size,
1359 param.temp_bullets[data].getSize() + 2);
1364 void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, State cb)
1366 /* Here we have to change the background pixmap to that selected */
1367 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1370 if (cb == BULLETPANEL1)
1372 else if (cb == BULLETPANEL2)
1374 else if (cb == BULLETPANEL3)
1376 else if (cb == BULLETPANEL4)
1378 else if (cb == BULLETPANEL5)
1380 else if (cb == BULLETPANEL6)
1383 if (data != current_bullet_panel) {
1384 fl_freeze_form(bullets_->form);
1385 current_bullet_panel = data;
1387 /* free the current pixmap */
1388 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1391 /* display the new one */
1393 new_panel = "standard";
1396 new_panel = "amssymb";
1399 new_panel = "psnfss1";
1402 new_panel = "psnfss2";
1405 new_panel = "psnfss3";
1408 new_panel = "psnfss4";
1411 /* something very wrong happened */
1412 // play it safe for now but should be an exception
1413 current_bullet_panel = 0; // standard panel
1414 new_panel = "standard";
1417 new_panel += ".xpm";
1418 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1419 LibFileSearch("images", new_panel).c_str());
1420 fl_redraw_object(bullets_->bmtable_bullet_panel);
1421 fl_unfreeze_form(bullets_->form);
1426 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1428 /* handle the user input by setting the current bullet depth's pixmap */
1429 /* to that extracted from the current chosen position of the BMTable */
1430 /* Don't forget to free the button's old pixmap first. */
1432 BufferParams & param = lv_->buffer()->params;
1433 int bmtable_button = fl_get_bmtable(ob);
1435 /* try to keep the button held down till another is pushed */
1436 /* fl_set_bmtable(ob, 1, bmtable_button); */
1437 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1438 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1439 fl_set_input(bullets_->input_bullet_latex,
1440 param.temp_bullets[current_bullet_depth].getText().c_str());
1444 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1447 ob = class_->choice_doc_class;
1449 lv_->prohibitInput();
1451 unsigned int tc = combo_doc_class->get() - 1;
1452 if (textclasslist[tc].load()) {
1453 // we use a copy of the bufferparams because we do not
1454 // want to modify them yet.
1455 BufferParams params = lv_->buffer()->params;
1457 if (lyxrc.auto_reset_options) {
1458 params.textclass = tc;
1459 params.useClassDefaults();
1460 UpdateLayoutDocument(params);
1462 params.textclass = tc;
1463 UpdateLayoutDocument(params);
1467 // unable to load new style
1468 Alert::alert(_("Conversion Errors!"),
1469 _("Unable to switch to new document class."),
1470 _("Reverting to original document class."));
1471 combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
1477 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1483 class_update(params);
1484 paper_update(params);
1485 language_update(params);
1486 options_update(params);
1487 bullets_update(params);