]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormDocument.C
move reading of bind files from lyxrc.C to kbmap.C; do not read bindings or menus...
[lyx.git] / src / frontends / xforms / FormDocument.C
1 /**
2  * \file FormDocument.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Jürgen Vigna
7  * \author Rob Lahaye
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #include <config.h>
13
14 #include "ControlDocument.h"
15 #include "FormDocument.h"
16 #include "forms/form_document.h"
17 #include "xformsBC.h"
18 #include "ButtonController.h"
19
20 #include "bmtable.h"
21 #include "checkedwidgets.h"
22 #include "input_validators.h" // fl_unsigned_float_filter
23 #include "xforms_helpers.h"
24
25 #include "CutAndPaste.h"
26 #include "debug.h"
27 #include "language.h"
28 #include "lyxrc.h"
29 #include "lyxtextclasslist.h"
30 #include "tex-strings.h"
31
32 #include "controllers/frnt_lang.h"
33 #include "controllers/helper_funcs.h"
34
35 #include "support/tostr.h"
36 #include "support/lstrings.h" // contains_functor, getStringFromVector
37 #include "support/filetools.h" // LibFileSearch
38
39 #include "lyx_xpm.h"
40 #include "lyx_forms.h"
41 #include "combox.h"
42
43 #include <boost/bind.hpp>
44
45 #include <functional>
46
47 using namespace lyx::support;
48
49 using std::bind2nd;
50 using std::vector;
51
52
53 namespace {
54
55 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
56 bool const scalableTabfolders = false;
57 #else
58 bool const scalableTabfolders = true;
59 #endif
60
61 } // namespace anon
62
63
64 typedef FormCB<ControlDocument, FormDB<FD_document> > base_class;
65
66 FormDocument::FormDocument()
67         : base_class(_("Document Settings"), scalableTabfolders),
68           ActCell(0), Confirmed(0),
69           current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
70 {}
71
72
73 void FormDocument::redraw()
74 {
75         if (form() && form()->visible)
76                 fl_redraw_form(form());
77         else
78                 return;
79
80         FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
81         if (outer_form && outer_form->visible)
82                 fl_redraw_form(outer_form);
83 }
84
85
86 void FormDocument::build()
87 {
88         // the tabbed folder
89         dialog_.reset(build_document(this));
90
91         // Allow the base class to control messages
92         setMessageWidget(dialog_->text_warning);
93
94         // Manage the restore, ok, apply, restore and cancel/close buttons
95         bcview().setOK(dialog_->button_ok);
96         bcview().setApply(dialog_->button_apply);
97         bcview().setCancel(dialog_->button_close);
98         bcview().setRestore(dialog_->button_restore);
99
100         // the document class form
101         class_.reset(build_document_class(this));
102
103         // disable for read-only documents
104         bcview().addReadOnly(class_->combox_class);
105         bcview().addReadOnly(class_->radio_indent);
106         bcview().addReadOnly(class_->radio_skip);
107         bcview().addReadOnly(class_->choice_pagestyle);
108         bcview().addReadOnly(class_->choice_fonts);
109         bcview().addReadOnly(class_->choice_fontsize);
110         bcview().addReadOnly(class_->radio_sides_one);
111         bcview().addReadOnly(class_->radio_sides_two);
112         bcview().addReadOnly(class_->radio_columns_one);
113         bcview().addReadOnly(class_->radio_columns_two);
114         bcview().addReadOnly(class_->input_extra);
115         bcview().addReadOnly(class_->input_skip);
116         bcview().addReadOnly(class_->choice_skip);
117         bcview().addReadOnly(class_->choice_spacing);
118         bcview().addReadOnly(class_->input_spacing);
119
120         // check validity of "length + unit" input
121         addCheckedGlueLength(bcview(), class_->input_skip,
122                              class_->choice_skip);
123
124         // trigger an input event for cut&paste with middle mouse button.
125         setPrehandler(class_->input_extra);
126         setPrehandler(class_->input_skip);
127         setPrehandler(class_->input_spacing);
128
129         fl_set_input_return(class_->input_extra, FL_RETURN_CHANGED);
130         fl_set_input_return(class_->input_skip, FL_RETURN_CHANGED);
131         fl_set_input_return(class_->input_spacing, FL_RETURN_CHANGED);
132
133         FL_OBJECT * obj;
134
135         // Fill the combox and choices.
136         obj = class_->combox_class;
137         LyXTextClassList::const_iterator tit  = textclasslist.begin();
138         LyXTextClassList::const_iterator tend = textclasslist.end();
139         for (; tit != tend; ++tit) {
140                 if (tit->isTeXClassAvailable()) {
141                         fl_addto_combox(obj, tit->description().c_str());
142                 } else {
143                         string item = bformat(_("Unavailable: %1$s"), tit->description());
144                         fl_addto_combox(obj, item.c_str());
145                 }
146         }
147         fl_set_combox_browser_height(obj, 400);
148
149         fl_addto_choice(class_->choice_spacing,
150                         _(" Single | OneHalf | Double | Custom ").c_str());
151         fl_addto_choice(class_->choice_fontsize, "default|10|11|12");
152         for (int n = 0; tex_fonts[n][0]; ++n) {
153                 fl_addto_choice(class_->choice_fonts,tex_fonts[n]);
154         }
155
156         // Create the contents of the unit choices; don't include the
157         // "%" terms...
158         vector<string> units_vec = getLatexUnits();
159         vector<string>::iterator ret =
160                 std::remove_if(units_vec.begin(),
161                                units_vec.end(),
162                                bind2nd(contains_functor(), "%"));
163         units_vec.erase(ret, units_vec.end());
164
165         string const units = getStringFromVector(units_vec, "|");
166
167         fl_addto_choice(class_->choice_pagestyle,
168                         "default|empty|plain|headings|fancy");
169         fl_addto_choice(class_->choice_skip,
170                         _(" SmallSkip | MedSkip | BigSkip | Length ").c_str());
171         fl_addto_choice(class_->choice_skip_units,  units.c_str());
172
173         // Set input filters on doc spacing to make it accept only
174         // unsigned numbers.
175         fl_set_input_filter(class_->input_spacing,
176                             fl_unsigned_float_filter);
177
178         // disable for read-only documents
179         bcview().addReadOnly(dialog_->button_save_defaults);
180         bcview().addReadOnly(dialog_->button_reset_defaults);
181
182         // the document paper form
183         paper_.reset(build_document_paper(this));
184
185         // disable for read-only documents
186         bcview().addReadOnly(paper_->choice_paperpackage);
187         bcview().addReadOnly(paper_->radio_portrait);
188         bcview().addReadOnly(paper_->radio_landscape);
189         bcview().addReadOnly(paper_->choice_papersize);
190         bcview().addReadOnly(paper_->check_use_geometry);
191         bcview().addReadOnly(paper_->input_custom_width);
192         bcview().addReadOnly(paper_->input_custom_height);
193         bcview().addReadOnly(paper_->input_top_margin);
194         bcview().addReadOnly(paper_->input_bottom_margin);
195         bcview().addReadOnly(paper_->input_inner_margin);
196         bcview().addReadOnly(paper_->input_outer_margin);
197         bcview().addReadOnly(paper_->input_head_height);
198         bcview().addReadOnly(paper_->input_head_sep);
199         bcview().addReadOnly(paper_->input_foot_skip);
200
201         // check validity of "length + unit" input
202         addCheckedGlueLength(bcview(), paper_->input_custom_width);
203         addCheckedGlueLength(bcview(), paper_->input_custom_height);
204         addCheckedGlueLength(bcview(), paper_->input_top_margin);
205         addCheckedGlueLength(bcview(), paper_->input_bottom_margin);
206         addCheckedGlueLength(bcview(), paper_->input_inner_margin);
207         addCheckedGlueLength(bcview(), paper_->input_outer_margin);
208         addCheckedGlueLength(bcview(), paper_->input_head_height);
209         addCheckedGlueLength(bcview(), paper_->input_head_sep);
210         addCheckedGlueLength(bcview(), paper_->input_foot_skip);
211
212         // trigger an input event for cut&paste with middle mouse button.
213         setPrehandler(paper_->input_custom_width);
214         setPrehandler(paper_->input_custom_height);
215         setPrehandler(paper_->input_top_margin);
216         setPrehandler(paper_->input_bottom_margin);
217         setPrehandler(paper_->input_inner_margin);
218         setPrehandler(paper_->input_outer_margin);
219         setPrehandler(paper_->input_head_height);
220         setPrehandler(paper_->input_head_sep);
221         setPrehandler(paper_->input_foot_skip);
222
223         fl_set_input_return(paper_->input_custom_width,  FL_RETURN_CHANGED);
224         fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
225         fl_set_input_return(paper_->input_top_margin,    FL_RETURN_CHANGED);
226         fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
227         fl_set_input_return(paper_->input_inner_margin,  FL_RETURN_CHANGED);
228         fl_set_input_return(paper_->input_outer_margin,  FL_RETURN_CHANGED);
229         fl_set_input_return(paper_->input_head_height,   FL_RETURN_CHANGED);
230         fl_set_input_return(paper_->input_head_sep,      FL_RETURN_CHANGED);
231         fl_set_input_return(paper_->input_foot_skip,     FL_RETURN_CHANGED);
232
233         fl_addto_choice(paper_->choice_papersize,
234                         _(" Default | Custom | US letter | US legal "
235                           "| US executive | A3 | A4 | A5 "
236                           "| B3 | B4 | B5 ").c_str());
237         fl_addto_choice(paper_->choice_paperpackage,
238                         _(" None "
239                           "| Small Margins "
240                           "| Very small Margins "
241                           "| Very wide Margins ").c_str());
242
243         fl_addto_choice(paper_->choice_custom_width_units,  units.c_str());
244         fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
245         fl_addto_choice(paper_->choice_top_margin_units,    units.c_str());
246         fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
247         fl_addto_choice(paper_->choice_inner_margin_units,  units.c_str());
248         fl_addto_choice(paper_->choice_outer_margin_units,  units.c_str());
249         fl_addto_choice(paper_->choice_head_height_units,   units.c_str());
250         fl_addto_choice(paper_->choice_head_sep_units,      units.c_str());
251         fl_addto_choice(paper_->choice_foot_skip_units,     units.c_str());
252
253         // the document language form
254         language_.reset(build_document_language(this));
255
256         // disable for read-only documents
257         bcview().addReadOnly(language_->combox_language);
258         bcview().addReadOnly(language_->choice_inputenc);
259         bcview().addReadOnly(language_->choice_quotes_language);
260         bcview().addReadOnly(language_->radio_single);
261         bcview().addReadOnly(language_->radio_double);
262
263         fl_addto_choice(language_->choice_inputenc,
264                         "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
265                         "|koi8-r|koi8-u|cp866|cp1251|iso88595|pt154");
266
267         vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
268         // Store the identifiers for later
269         lang_ = getSecond(langs);
270
271         vector<frnt::LanguagePair>::const_iterator lit  = langs.begin();
272         vector<frnt::LanguagePair>::const_iterator lend = langs.end();
273         for (; lit != lend; ++lit) {
274                 fl_addto_combox(language_->combox_language,
275                                 lit->first.c_str());
276         }
277         fl_set_combox_browser_height(language_->combox_language, 400);
278
279         fl_addto_choice(language_->choice_quotes_language,
280                         _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
281                           " «text» | »text« ").c_str());
282
283         // the document options form
284         options_.reset(build_document_options(this));
285
286         // disable for read-only documents
287         bcview().addReadOnly(options_->counter_secnumdepth);
288         bcview().addReadOnly(options_->counter_tocdepth);
289         bcview().addReadOnly(options_->choice_ams_math);
290         bcview().addReadOnly(options_->check_use_natbib);
291         bcview().addReadOnly(options_->choice_citation_format);
292         bcview().addReadOnly(options_->input_float_placement);
293         bcview().addReadOnly(options_->choice_postscript_driver);
294
295         // trigger an input event for cut&paste with middle mouse button.
296         setPrehandler(options_->input_float_placement);
297
298         fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
299
300         fl_addto_choice(options_->choice_ams_math,
301                         _("Never | Automatically | Yes ").c_str());
302
303         for (int n = 0; tex_graphics[n][0]; ++n) {
304                 fl_addto_choice(options_->choice_postscript_driver,
305                                 tex_graphics[n]);
306         }
307         fl_addto_choice(options_->choice_citation_format,
308                         _(" Author-year | Numerical ").c_str());
309
310         // the document bullets form
311         bullets_.reset(build_document_bullet(this));
312
313         // disable for read-only documents
314         bcview().addReadOnly(bullets_->radio_depth_1);
315         bcview().addReadOnly(bullets_->radio_depth_2);
316         bcview().addReadOnly(bullets_->radio_depth_3);
317         bcview().addReadOnly(bullets_->radio_depth_4);
318         bcview().addReadOnly(bullets_->radio_panel_standard);
319         bcview().addReadOnly(bullets_->radio_panel_maths);
320         bcview().addReadOnly(bullets_->radio_panel_ding1);
321         bcview().addReadOnly(bullets_->radio_panel_ding2);
322         bcview().addReadOnly(bullets_->radio_panel_ding3);
323         bcview().addReadOnly(bullets_->radio_panel_ding4);
324         bcview().addReadOnly(bullets_->bmtable_panel);
325         bcview().addReadOnly(bullets_->choice_size);
326         bcview().addReadOnly(bullets_->input_latex);
327
328         // trigger an input event for cut&paste with middle mouse button.
329         setPrehandler(bullets_->input_latex);
330
331         fl_set_input_return(bullets_->input_latex, FL_RETURN_CHANGED);
332
333         fl_addto_choice(bullets_->choice_size,
334                         _(" Default | Tiny | Smallest | Smaller "
335                           "| Small | Normal | Large | Larger | Largest "
336                           "| Huge | Huger ").c_str());
337         fl_set_choice(bullets_->choice_size, 1);
338
339         fl_set_input_maxchars(bullets_->input_latex, 80);
340
341         string const bmtablefile = LibFileSearch("images", "standard", "xpm");
342         fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6,
343                                    bmtablefile.c_str());
344
345         // Enable the tabfolder to be rescaled correctly.
346         if (scalableTabfolders)
347                 fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
348
349         // Stack tabs
350         fl_addto_tabfolder(dialog_->tabfolder,_("Document").c_str(),
351                            class_->form);
352         fl_addto_tabfolder(dialog_->tabfolder,_("Paper").c_str(),
353                            paper_->form);
354         fl_addto_tabfolder(dialog_->tabfolder,_("Language").c_str(),
355                            language_->form);
356         fl_addto_tabfolder(dialog_->tabfolder,_("Extra").c_str(),
357                            options_->form);
358         fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets").c_str(),
359                                      bullets_->form);
360
361         if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
362                 lyxerr << _("Your version of libXpm is older than 4.7.\n"
363                             "The `bullet' tab of the document dialog "
364                             "has been disabled") << '\n';
365                 fl_deactivate_object(fbullet);
366                 fl_set_object_lcol(fbullet, FL_INACTIVE);
367         }
368 }
369
370
371 void FormDocument::apply()
372 {
373         BufferParams & params = controller().params();
374
375         class_apply(params);
376         paper_apply(params);
377         language_apply(params);
378         options_apply(params);
379         bullets_apply(params);
380 }
381
382
383 void FormDocument::update()
384 {
385         if (!dialog_.get())
386                 return;
387
388         checkReadOnly();
389
390         BufferParams const & params = controller().params();
391
392         class_update(params);
393         paper_update(params);
394         language_update(params);
395         options_update(params);
396         bullets_update(params);
397 }
398
399
400 ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
401 {
402         if (ob == bullets_->choice_size) {
403                 ChoiceBulletSize(ob, 0);
404
405         } else if (ob == bullets_->input_latex) {
406                 InputBulletLaTeX(ob, 0);
407
408         } else if (ob == bullets_->radio_depth_1 ||
409                    ob == bullets_->radio_depth_2 ||
410                    ob == bullets_->radio_depth_3 ||
411                    ob == bullets_->radio_depth_4) {
412                 BulletDepth(ob);
413
414         } else if (ob == bullets_->radio_panel_standard ||
415                    ob == bullets_->radio_panel_maths ||
416                    ob == bullets_->radio_panel_ding1 ||
417                    ob == bullets_->radio_panel_ding2 ||
418                    ob == bullets_->radio_panel_ding3 ||
419                    ob == bullets_->radio_panel_ding4) {
420                 BulletPanel(ob);
421
422         } else if (ob == bullets_->bmtable_panel) {
423                 BulletBMTable(ob, 0);
424
425         } else if (ob == class_->choice_spacing) {
426                 setEnabled(class_->input_spacing,
427                            fl_get_choice(class_->choice_spacing) == 4);
428
429         } else if (ob == class_->combox_class) {
430                 CheckChoiceClass();
431         } else if (ob == class_->radio_skip ||
432                    ob == class_->radio_indent ||
433                    ob == class_->choice_skip) {
434                 bool const skip_used = fl_get_button(class_->radio_skip);
435                 setEnabled(class_->choice_skip, skip_used);
436
437                 bool const length_input =
438                         fl_get_choice(class_->choice_skip) == 4;
439                 setEnabled(class_->input_skip,
440                            skip_used && length_input);
441                 setEnabled(class_->choice_skip_units,
442                            skip_used && length_input);
443
444                 // Default unit choice is cm if metric, inches if US paper.
445                 // If papersize is default, check the lyxrc-settings
446                 int const paperchoice = fl_get_choice(paper_->choice_papersize);
447                 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
448                         || paperchoice == 2 || paperchoice > 5;
449                 string const default_unit = metric ? "cm" : "in";
450                 if (getString(class_->input_skip).empty())
451                         fl_set_choice_text(class_->choice_skip_units,
452                                            default_unit.c_str());
453
454         } else if (ob == options_->check_use_natbib) {
455                 setEnabled(options_->choice_citation_format,
456                            fl_get_button(options_->check_use_natbib));
457
458         } else if (ob == dialog_->button_save_defaults) {
459                 apply();
460                 controller().saveAsDefault();
461
462         } else if (ob == dialog_->button_reset_defaults) {
463                 BufferParams & params = controller().params();
464                 params.textclass = fl_get_combox(class_->combox_class) - 1;
465                 params.useClassDefaults();
466                 UpdateLayoutDocument(params);
467
468         } else if (ob == paper_->radio_landscape) {
469                 fl_set_choice(paper_->choice_paperpackage,
470                               PACKAGE_NONE + 1);
471
472         } else if (ob == paper_->choice_papersize) {
473                 int const paperchoice = fl_get_choice(paper_->choice_papersize);
474                 bool const defsize = paperchoice == 1;
475                 bool const custom = paperchoice == 2;
476                 bool const a3size = paperchoice == 6;
477                 bool const b3size = paperchoice == 9;
478                 bool const b4size = paperchoice == 10;
479
480                 if (custom)
481                         fl_set_button(paper_->radio_portrait, 1);
482
483                 bool const use_geom = (custom || a3size || b3size || b4size);
484
485                 fl_set_button(paper_->check_use_geometry, int(use_geom));
486
487                 setEnabled(paper_->input_top_margin,    use_geom);
488                 setEnabled(paper_->input_bottom_margin, use_geom);
489                 setEnabled(paper_->input_inner_margin,  use_geom);
490                 setEnabled(paper_->input_outer_margin,  use_geom);
491                 setEnabled(paper_->input_head_height,   use_geom);
492                 setEnabled(paper_->input_head_sep,      use_geom);
493                 setEnabled(paper_->input_foot_skip,     use_geom);
494                 setEnabled(paper_->choice_top_margin_units,    use_geom);
495                 setEnabled(paper_->choice_bottom_margin_units, use_geom);
496                 setEnabled(paper_->choice_inner_margin_units,  use_geom);
497                 setEnabled(paper_->choice_outer_margin_units,  use_geom);
498                 setEnabled(paper_->choice_head_height_units,   use_geom);
499                 setEnabled(paper_->choice_head_sep_units,      use_geom);
500                 setEnabled(paper_->choice_foot_skip_units,     use_geom);
501                 setEnabled(paper_->choice_custom_width_units,  use_geom);
502                 setEnabled(paper_->choice_custom_height_units, use_geom);
503
504                 setEnabled(paper_->input_custom_width,  custom);
505                 setEnabled(paper_->input_custom_height, custom);
506                 setEnabled(paper_->choice_custom_width_units,  custom);
507                 setEnabled(paper_->choice_custom_height_units, custom);
508                 setEnabled(paper_->radio_portrait,  !custom);
509                 setEnabled(paper_->radio_landscape, !custom);
510
511                 // Default unit choice is cm if metric, inches if US paper.
512                 // If papersize is default, use the lyxrc-settings
513                 bool const metric = (defsize && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
514                         || paperchoice == 2 || paperchoice > 5;
515                 string const default_unit = metric ? "cm" : "in";
516                 if (getString(paper_->input_custom_width).empty())
517                         fl_set_choice_text(paper_->choice_custom_width_units,
518                                            default_unit.c_str());
519                 if (getString(paper_->input_custom_height).empty())
520                         fl_set_choice_text(paper_->choice_custom_height_units,
521                                            default_unit.c_str());
522                 if (getString(paper_->input_top_margin).empty())
523                         fl_set_choice_text(paper_->choice_top_margin_units,
524                                            default_unit.c_str());
525                 if (getString(paper_->input_bottom_margin).empty())
526                         fl_set_choice_text(paper_->choice_bottom_margin_units,
527                                            default_unit.c_str());
528                 if (getString(paper_->input_inner_margin).empty())
529                         fl_set_choice_text(paper_->choice_inner_margin_units,
530                                            default_unit.c_str());
531                 if (getString(paper_->input_outer_margin).empty())
532                         fl_set_choice_text(paper_->choice_outer_margin_units,
533                                            default_unit.c_str());
534                 if (getString(paper_->input_head_height).empty())
535                         fl_set_choice_text(paper_->choice_head_height_units,
536                                            default_unit.c_str());
537                 if (getString(paper_->input_head_sep).empty())
538                         fl_set_choice_text(paper_->choice_head_sep_units,
539                                            default_unit.c_str());
540                 if (getString(paper_->input_foot_skip).empty())
541                         fl_set_choice_text(paper_->choice_foot_skip_units,
542                                            default_unit.c_str());
543
544         } else if (ob == paper_->choice_paperpackage &&
545                    fl_get_choice(paper_->choice_paperpackage) != 1) {
546
547                 fl_set_button(paper_->check_use_geometry, 0);
548                 setEnabled(paper_->input_top_margin,    false);
549                 setEnabled(paper_->input_bottom_margin, false);
550                 setEnabled(paper_->input_inner_margin,  false);
551                 setEnabled(paper_->input_outer_margin,  false);
552                 setEnabled(paper_->input_head_height,   false);
553                 setEnabled(paper_->input_head_sep,      false);
554                 setEnabled(paper_->input_foot_skip,     false);
555                 setEnabled(paper_->choice_top_margin_units,    false);
556                 setEnabled(paper_->choice_bottom_margin_units, false);
557                 setEnabled(paper_->choice_inner_margin_units,  false);
558                 setEnabled(paper_->choice_outer_margin_units,  false);
559                 setEnabled(paper_->choice_head_height_units,   false);
560                 setEnabled(paper_->choice_head_sep_units,      false);
561                 setEnabled(paper_->choice_foot_skip_units,     false);
562
563         } else if (ob == paper_->check_use_geometry) {
564                 // don't allow switching geometry off in custom papersize
565                 // mode nor in A3, B3, and B4
566                 int const choice = fl_get_choice(paper_->choice_papersize);
567                 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
568                         fl_set_button(paper_->check_use_geometry, 1);
569
570                 fl_set_choice(paper_->choice_paperpackage,
571                               PACKAGE_NONE + 1);
572
573                 bool const use_geom = fl_get_button(paper_->check_use_geometry);
574                 setEnabled(paper_->input_top_margin,    use_geom);
575                 setEnabled(paper_->input_bottom_margin, use_geom);
576                 setEnabled(paper_->input_inner_margin,  use_geom);
577                 setEnabled(paper_->input_outer_margin,  use_geom);
578                 setEnabled(paper_->input_head_height,   use_geom);
579                 setEnabled(paper_->input_head_sep,      use_geom);
580                 setEnabled(paper_->input_foot_skip,     use_geom);
581                 setEnabled(paper_->choice_top_margin_units,    use_geom);
582                 setEnabled(paper_->choice_bottom_margin_units, use_geom);
583                 setEnabled(paper_->choice_inner_margin_units,  use_geom);
584                 setEnabled(paper_->choice_outer_margin_units,  use_geom);
585                 setEnabled(paper_->choice_head_height_units,   use_geom);
586                 setEnabled(paper_->choice_head_sep_units,      use_geom);
587                 setEnabled(paper_->choice_foot_skip_units,     use_geom);
588         }
589
590         if (ob == paper_->choice_papersize || ob == paper_->radio_portrait
591             || ob == paper_->radio_landscape) {
592                 // either default papersize (preferences) or document
593                 // papersize has to be A4
594                 bool const enable = ( fl_get_choice(paper_->choice_papersize) == 1
595                                       && lyxrc.default_papersize == PAPER_A4PAPER )
596                         || fl_get_choice(paper_->choice_papersize) == 7;
597                 if (!enable)
598                         fl_set_choice(paper_->choice_paperpackage,
599                                       PACKAGE_NONE + 1);
600                 setEnabled(paper_->choice_paperpackage,
601                            enable && fl_get_button(paper_->radio_portrait));
602         }
603
604         return ButtonPolicy::SMI_VALID;
605 }
606
607
608 bool FormDocument::class_apply(BufferParams &params)
609 {
610         bool redo = false;
611
612         // If default skip is a "Length" but there's no text in the
613         // input field, reset the kind to "MedSkip", which is the default.
614         if (fl_get_choice(class_->choice_skip) == 4 &&
615             getString(class_->input_skip).empty()) {
616                 fl_set_choice(class_->choice_skip, 2);
617         }
618         params.fonts = getString(class_->choice_fonts);
619         params.fontsize = getString(class_->choice_fontsize);
620         params.pagestyle = getString(class_->choice_pagestyle);
621
622         params.textclass = fl_get_combox(class_->combox_class) - 1;
623
624         BufferParams::PARSEP tmpsep = params.paragraph_separation;
625         if (fl_get_button(class_->radio_indent))
626                 params.paragraph_separation = BufferParams::PARSEP_INDENT;
627         else
628                 params.paragraph_separation = BufferParams::PARSEP_SKIP;
629         if (tmpsep != params.paragraph_separation)
630                 redo = true;
631
632         VSpace tmpdefskip = params.getDefSkip();
633         switch (fl_get_choice(class_->choice_skip)) {
634         case 1:
635                 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
636                 break;
637         case 2:
638                 params.setDefSkip(VSpace(VSpace::MEDSKIP));
639                 break;
640         case 3:
641                 params.setDefSkip(VSpace(VSpace::BIGSKIP));
642                 break;
643         case 4:
644         {
645                 string const length =
646                         getLengthFromWidgets(class_->input_skip,
647                                              class_->choice_skip_units);
648
649                 params.setDefSkip(VSpace(LyXGlueLength(length)));
650                 break;
651         }
652         default:
653                 // DocumentDefskipCB assures that this never happens
654                 params.setDefSkip(VSpace(VSpace::MEDSKIP));
655                 break;
656         }
657         if (!(tmpdefskip == params.getDefSkip()))
658                 redo = true;
659
660         if (fl_get_button(class_->radio_columns_two))
661                 params.columns = 2;
662         else
663                 params.columns = 1;
664         if (fl_get_button(class_->radio_sides_two))
665                 params.sides = LyXTextClass::TwoSides;
666         else
667                 params.sides = LyXTextClass::OneSide;
668
669         Spacing tmpSpacing = params.spacing;
670         switch (fl_get_choice(class_->choice_spacing)) {
671         case 1:
672                 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
673                 params.spacing.set(Spacing::Single);
674                 break;
675         case 2:
676                 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
677                 params.spacing.set(Spacing::Onehalf);
678                 break;
679         case 3:
680                 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
681                 params.spacing.set(Spacing::Double);
682                 break;
683         case 4:
684                 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
685                 params.spacing.set(Spacing::Other,
686                                    getString(class_->input_spacing));
687                 break;
688         }
689         if (tmpSpacing != params.spacing)
690                 redo = true;
691
692         params.options = getString(class_->input_extra);
693
694         return redo;
695 }
696
697
698 void FormDocument::paper_apply(BufferParams & params)
699 {
700         params.papersize2 = VMARGIN_PAPER_TYPE(fl_get_choice(paper_->choice_papersize) - 1);
701
702         params.paperpackage =
703                 PAPER_PACKAGES(fl_get_choice(paper_->choice_paperpackage) - 1);
704
705         // set params.papersize from params.papersize2 and params.paperpackage
706         params.setPaperStuff();
707
708         params.use_geometry = fl_get_button(paper_->check_use_geometry);
709
710         if (fl_get_button(paper_->radio_landscape))
711                 params.orientation = ORIENTATION_LANDSCAPE;
712         else
713                 params.orientation = ORIENTATION_PORTRAIT;
714
715         params.paperwidth =
716                 getLengthFromWidgets(paper_->input_custom_width,
717                                      paper_->choice_custom_width_units);
718
719         params.paperheight =
720                 getLengthFromWidgets(paper_->input_custom_height,
721                                      paper_->choice_custom_height_units);
722
723         params.leftmargin =
724                 getLengthFromWidgets(paper_->input_inner_margin,
725                                      paper_->choice_inner_margin_units);
726
727         params.topmargin =
728                 getLengthFromWidgets(paper_->input_top_margin,
729                                      paper_->choice_top_margin_units);
730
731         params.rightmargin =
732                 getLengthFromWidgets(paper_->input_outer_margin,
733                                      paper_->choice_outer_margin_units);
734
735         params.bottommargin =
736                 getLengthFromWidgets(paper_->input_bottom_margin,
737                                      paper_->choice_bottom_margin_units);
738
739         params.headheight =
740                 getLengthFromWidgets(paper_->input_head_height,
741                                      paper_->choice_head_height_units);
742
743         params.headsep =
744                 getLengthFromWidgets(paper_->input_head_sep,
745                                      paper_->choice_head_sep_units);
746
747         params.footskip =
748                 getLengthFromWidgets(paper_->input_foot_skip,
749                                      paper_->choice_foot_skip_units);
750 }
751
752
753 bool FormDocument::language_apply(BufferParams & params)
754 {
755         InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
756         bool redo = false;
757
758         switch (fl_get_choice(language_->choice_quotes_language) - 1) {
759         case 0:
760                 lga = InsetQuotes::EnglishQ;
761                 break;
762         case 1:
763                 lga = InsetQuotes::SwedishQ;
764                 break;
765         case 2:
766                 lga = InsetQuotes::GermanQ;
767                 break;
768         case 3:
769                 lga = InsetQuotes::PolishQ;
770                 break;
771         case 4:
772                 lga = InsetQuotes::FrenchQ;
773                 break;
774         case 5:
775                 lga = InsetQuotes::DanishQ;
776                 break;
777         }
778         params.quotes_language = lga;
779         if (fl_get_button(language_->radio_single))
780                 params.quotes_times = InsetQuotes::SingleQ;
781         else
782                 params.quotes_times = InsetQuotes::DoubleQ;
783
784         int const pos = fl_get_combox(language_->combox_language);
785         Language const * new_language = languages.getLanguage(lang_[pos-1]);
786         if (!new_language)
787                 new_language = default_language;
788
789         params.language = new_language;
790         params.inputenc = getString(language_->choice_inputenc);
791
792         return redo;
793 }
794
795
796 bool FormDocument::options_apply(BufferParams & params)
797 {
798         bool redo = false;
799
800         params.graphicsDriver = getString(options_->choice_postscript_driver);
801         params.use_amsmath = static_cast<BufferParams::AMS>(
802                 fl_get_choice(options_->choice_ams_math) - 1);
803         params.use_natbib  = fl_get_button(options_->check_use_natbib);
804         params.use_numerical_citations  =
805                 fl_get_choice(options_->choice_citation_format) - 1;
806
807         int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
808         if (params.secnumdepth != tmpchar)
809                 redo = true;
810         params.secnumdepth = tmpchar;
811
812         params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
813
814         params.float_placement =
815                 getString(options_->input_float_placement);
816
817         return redo;
818 }
819
820
821 void FormDocument::bullets_apply(BufferParams & params)
822 {
823         /* update the bullet settings */
824         BufferParams & buf_params = controller().params();
825
826         for (int i = 0; i < 4; ++i) {
827                 params.user_defined_bullets[i] = buf_params.temp_bullets[i];
828         }
829 }
830
831
832 void FormDocument::UpdateClassParams(BufferParams const & params)
833 {
834         // These are the params that have to be updated on any class change
835         // (even if the class defaults are not used) (JSpitzm 2002-04-08)
836
837         LyXTextClass const & tclass = textclasslist[params.textclass];
838
839         fl_set_combox(class_->combox_class, params.textclass + 1);
840         fl_clear_choice(class_->choice_fontsize);
841         fl_addto_choice(class_->choice_fontsize, "default");
842         fl_addto_choice(class_->choice_fontsize,
843                         tclass.opt_fontsize().c_str());
844         fl_set_choice_text(class_->choice_fontsize,
845                            params.fontsize.c_str());
846         fl_clear_choice(class_->choice_pagestyle);
847         fl_addto_choice(class_->choice_pagestyle, "default");
848         fl_addto_choice(class_->choice_pagestyle,
849                         tclass.opt_pagestyle().c_str());
850         fl_set_choice_text(class_->choice_pagestyle,
851                            params.pagestyle.c_str());
852
853 }
854
855 void FormDocument::class_update(BufferParams const & params)
856 {
857         if (!class_.get())
858                 return;
859
860         UpdateClassParams(params);
861
862         fl_set_choice_text(class_->choice_fonts, params.fonts.c_str());
863
864         bool const indent = params.paragraph_separation == BufferParams::PARSEP_INDENT;
865         fl_set_button(class_->radio_indent, indent);
866         fl_set_button(class_->radio_skip, !indent);
867
868         int pos;
869         if (indent) {
870                 pos = 2; // VSpace::MEDSKIP is default
871         } else {
872                 switch (params.getDefSkip().kind()) {
873                 case VSpace::LENGTH:
874                         pos = 4;
875                         break;
876                 case VSpace::BIGSKIP:
877                         pos = 3;
878                         break;
879                 case VSpace::SMALLSKIP:
880                         pos = 1;
881                         break;
882                 case VSpace::MEDSKIP:
883                 default:
884                         pos = 2;
885                         break;
886                 }
887         }
888         fl_set_choice (class_->choice_skip, pos);
889
890         bool const length_input = pos == 4;
891         if (length_input) {
892                 int const paperchoice = fl_get_choice(paper_->choice_papersize);
893                 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
894                         || paperchoice == 2 || paperchoice > 5;
895                 string const default_unit = metric ? "cm" : "in";
896                 string const length = params.getDefSkip().asLyXCommand();
897                 updateWidgetsFromLengthString(class_->input_skip,
898                                               class_->choice_skip_units,
899                                               length, default_unit);
900
901         } else {
902                 fl_set_input(class_->input_skip, "");
903         }
904         setEnabled(class_->choice_skip, !indent);
905         setEnabled(class_->input_skip, length_input);
906         setEnabled(class_->choice_skip_units, length_input);
907
908         bool const two_sides = params.sides == LyXTextClass::TwoSides;
909         fl_set_button(class_->radio_sides_one, !two_sides);
910         fl_set_button(class_->radio_sides_two, two_sides);
911
912         bool const two_columns = params.columns == 2;
913         fl_set_button(class_->radio_columns_one, !two_columns);
914         fl_set_button(class_->radio_columns_two, two_columns);
915
916         fl_set_input(class_->input_extra, params.options.c_str());
917
918         switch (params.spacing.getSpace()) {
919         case Spacing::Other:
920                 pos = 4;
921                 break;
922         case Spacing::Double: // \doublespacing
923                 pos = 3;
924                 break;
925         case Spacing::Onehalf: // \onehalfspacing
926                 pos = 2;
927                 break;
928         case Spacing::Single: // \singlespacing
929         case Spacing::Default: // nothing bad should happen with this
930         default:
931                 pos = 1;
932                 break;
933         }
934         fl_set_choice(class_->choice_spacing, pos);
935
936         bool const spacing_input = pos == 4;
937         setEnabled(class_->input_spacing, spacing_input);
938         string const input = spacing_input ? tostr(params.spacing.getValue()) : string();
939         fl_set_input(class_->input_spacing, input.c_str());
940 }
941
942
943 void FormDocument::language_update(BufferParams const & params)
944 {
945         if (!language_.get())
946                 return;
947
948         int const pos = int(findPos(lang_, params.language->lang()));
949         fl_set_combox(language_->combox_language, pos+1);
950
951         fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
952         fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
953         fl_set_button(language_->radio_single, 0);
954         fl_set_button(language_->radio_double, 0);
955         if (params.quotes_times == InsetQuotes::SingleQ)
956                 fl_set_button(language_->radio_single, 1);
957         else
958                 fl_set_button(language_->radio_double, 1);
959 }
960
961
962 void FormDocument::options_update(BufferParams const & params)
963 {
964         if (!options_.get())
965                 return;
966
967         fl_set_choice_text(options_->choice_postscript_driver,
968                            params.graphicsDriver.c_str());
969         fl_set_choice(options_->choice_ams_math, params.use_amsmath + 1);
970         fl_set_button(options_->check_use_natbib,  params.use_natbib);
971         fl_set_choice(options_->choice_citation_format,
972                       int(params.use_numerical_citations)+1);
973         setEnabled(options_->choice_citation_format, params.use_natbib);
974         fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
975         fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
976         if (!params.float_placement.empty())
977                 fl_set_input(options_->input_float_placement,
978                              params.float_placement.c_str());
979         else
980                 fl_set_input(options_->input_float_placement, "");
981 }
982
983
984 void FormDocument::paper_update(BufferParams const & params)
985 {
986         if (!paper_.get())
987                 return;
988
989         fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
990         fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
991         fl_set_button(paper_->check_use_geometry, params.use_geometry);
992
993         int const paperchoice = fl_get_choice(paper_->choice_papersize);
994         bool const useCustom = paperchoice == 2;
995         bool const useGeom = fl_get_button(paper_->check_use_geometry);
996
997         fl_set_button(paper_->radio_portrait, 0);
998         setEnabled(paper_->radio_portrait, !useCustom);
999         fl_set_button(paper_->radio_landscape, 0);
1000         setEnabled(paper_->radio_landscape, !useCustom);
1001
1002         if (params.orientation == ORIENTATION_LANDSCAPE)
1003                 fl_set_button(paper_->radio_landscape, 1);
1004         else
1005                 fl_set_button(paper_->radio_portrait, 1);
1006         setEnabled(paper_->choice_paperpackage,
1007                    //either default papersize (preferences)
1008                    //or document papersize has to be A4
1009                    (paperchoice == 7
1010                     || paperchoice == 1 && lyxrc.default_papersize == PAPER_A4PAPER)
1011                    && fl_get_button(paper_->radio_portrait));
1012
1013         // Default unit choice is cm if metric, inches if US paper.
1014         bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
1015                 || paperchoice == 2 || paperchoice > 5;
1016         string const default_unit = metric ? "cm" : "in";
1017         updateWidgetsFromLengthString(paper_->input_custom_width,
1018                                       paper_->choice_custom_width_units,
1019                                       params.paperwidth, default_unit);
1020         setEnabled(paper_->input_custom_width, useCustom);
1021         setEnabled(paper_->choice_custom_width_units, useCustom);
1022
1023         updateWidgetsFromLengthString(paper_->input_custom_height,
1024                                       paper_->choice_custom_height_units,
1025                                       params.paperheight, default_unit);
1026         setEnabled(paper_->input_custom_height, useCustom);
1027         setEnabled(paper_->choice_custom_height_units, useCustom);
1028
1029         updateWidgetsFromLengthString(paper_->input_inner_margin,
1030                                       paper_->choice_inner_margin_units,
1031                                       params.leftmargin, default_unit);
1032         setEnabled(paper_->input_inner_margin, useGeom);
1033         setEnabled(paper_->choice_inner_margin_units, useGeom);
1034
1035         updateWidgetsFromLengthString(paper_->input_top_margin,
1036                                       paper_->choice_top_margin_units,
1037                                       params.topmargin, default_unit);
1038         setEnabled(paper_->input_top_margin, useGeom);
1039         setEnabled(paper_->choice_top_margin_units, useGeom);
1040
1041         updateWidgetsFromLengthString(paper_->input_outer_margin,
1042                                       paper_->choice_outer_margin_units,
1043                                       params.rightmargin, default_unit);
1044         setEnabled(paper_->input_outer_margin, useGeom);
1045         setEnabled(paper_->choice_outer_margin_units, useGeom);
1046
1047         updateWidgetsFromLengthString(paper_->input_bottom_margin,
1048                                       paper_->choice_bottom_margin_units,
1049                                       params.bottommargin, default_unit);
1050         setEnabled(paper_->input_bottom_margin, useGeom);
1051         setEnabled(paper_->choice_bottom_margin_units, useGeom);
1052
1053         updateWidgetsFromLengthString(paper_->input_head_height,
1054                                       paper_->choice_head_height_units,
1055                                       params.headheight, default_unit);
1056         setEnabled(paper_->input_head_height, useGeom);
1057         setEnabled(paper_->choice_head_height_units, useGeom);
1058
1059         updateWidgetsFromLengthString(paper_->input_head_sep,
1060                                       paper_->choice_head_sep_units,
1061                                       params.headsep, default_unit);
1062         setEnabled(paper_->input_head_sep, useGeom);
1063         setEnabled(paper_->choice_head_sep_units, useGeom);
1064
1065         updateWidgetsFromLengthString(paper_->input_foot_skip,
1066                                       paper_->choice_foot_skip_units,
1067                                       params.footskip, default_unit);
1068         setEnabled(paper_->input_foot_skip, useGeom);
1069         setEnabled(paper_->choice_foot_skip_units, useGeom);
1070
1071         fl_set_focus_object(paper_->form, paper_->choice_papersize);
1072 }
1073
1074
1075 void FormDocument::bullets_update(BufferParams const & params)
1076 {
1077         if (!bullets_.get() ||
1078             ((XpmVersion<4) ||
1079              (XpmVersion==4 && XpmRevision<7)))
1080                 return;
1081
1082         bool const isLinuxDoc =
1083                 controller().docType() == ControlDocument::LINUXDOC;
1084         setEnabled(fbullet, !isLinuxDoc);
1085
1086         if (isLinuxDoc) return;
1087
1088         fl_set_button(bullets_->radio_depth_1, 1);
1089         fl_set_input(bullets_->input_latex,
1090                      params.user_defined_bullets[0].getText().c_str());
1091         fl_set_choice(bullets_->choice_size,
1092                       params.user_defined_bullets[0].getSize() + 2);
1093 }
1094
1095
1096 void FormDocument::checkReadOnly()
1097 {
1098         if (bc().readOnly(controller().bufferIsReadonly())) {
1099                 postWarning(_("Document is read-only."
1100                               " No changes to layout permitted."));
1101         } else {
1102                 clearMessage();
1103         }
1104 }
1105
1106
1107 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1108 {
1109         BufferParams & param = controller().params();
1110
1111         // convert from 1-6 range to -1-4
1112         param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1113         fl_set_input(bullets_->input_latex,
1114                      param.temp_bullets[current_bullet_depth].getText().c_str());
1115 }
1116
1117
1118 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1119 {
1120         BufferParams & param = controller().params();
1121
1122         param.temp_bullets[current_bullet_depth].
1123                 setText(getString(bullets_->input_latex));
1124 }
1125
1126
1127 void FormDocument::BulletDepth(FL_OBJECT * ob)
1128 {
1129         /* Should I do the following:                                 */
1130         /*  1. change to the panel that the current bullet belongs in */
1131         /*  2. show that bullet as selected                           */
1132         /*  3. change the size setting to the size of the bullet in Q.*/
1133         /*  4. display the latex equivalent in the latex box          */
1134         /*                                                            */
1135         /* I'm inclined to just go with 3 and 4 at the moment and     */
1136         /* maybe try to support the others later                      */
1137         BufferParams & param = controller().params();
1138
1139         int data = 0;
1140         if (ob == bullets_->radio_depth_1)
1141                 data = 0;
1142         else if (ob == bullets_->radio_depth_2)
1143                 data = 1;
1144         else if (ob == bullets_->radio_depth_3)
1145                 data = 2;
1146         else if (ob == bullets_->radio_depth_4)
1147                 data = 3;
1148
1149         switch (fl_get_button_numb(ob)) {
1150         case 3:
1151                 // right mouse button resets to default
1152                 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1153         default:
1154                 current_bullet_depth = data;
1155                 fl_set_input(bullets_->input_latex,
1156                              param.temp_bullets[data].getText().c_str());
1157                 fl_set_choice(bullets_->choice_size,
1158                               param.temp_bullets[data].getSize() + 2);
1159         }
1160 }
1161
1162
1163 void FormDocument::BulletPanel(FL_OBJECT * ob)
1164 {
1165         /* Here we have to change the background pixmap to that selected */
1166         /* by the user. (eg. standard.xpm, psnfss1.xpm etc...)           */
1167
1168         int data = 0;
1169         if (ob == bullets_->radio_panel_standard)
1170                 data = 0;
1171         else if (ob == bullets_->radio_panel_maths)
1172                 data = 1;
1173         else if (ob == bullets_->radio_panel_ding2)
1174                 data = 2;
1175         else if (ob == bullets_->radio_panel_ding3)
1176                 data = 3;
1177         else if (ob == bullets_->radio_panel_ding4)
1178                 data = 4;
1179         else if (ob == bullets_->radio_panel_ding1)
1180                 data = 5;
1181
1182         if (data != current_bullet_panel) {
1183                 fl_freeze_form(bullets_->form);
1184                 current_bullet_panel = data;
1185
1186                 /* free the current pixmap */
1187                 fl_free_bmtable_pixmap(bullets_->bmtable_panel);
1188                 string new_panel;
1189                 if (ob == bullets_->radio_panel_standard) {
1190                         new_panel = "standard";
1191                 } else if (ob == bullets_->radio_panel_maths ) {
1192                         new_panel = "amssymb";
1193                 } else if (ob == bullets_->radio_panel_ding2) {
1194                         new_panel = "psnfss1";
1195                 } else if (ob == bullets_->radio_panel_ding3) {
1196                         new_panel = "psnfss2";
1197                 } else if (ob == bullets_->radio_panel_ding4) {
1198                         new_panel = "psnfss3";
1199                 } else if (ob == bullets_->radio_panel_ding1) {
1200                         new_panel = "psnfss4";
1201                 } else {
1202                         /* something very wrong happened */
1203                         // play it safe for now but should be an exception
1204                         current_bullet_panel = 0;  // standard panel
1205                         new_panel = "standard";
1206                 }
1207                 new_panel += ".xpm";
1208                 fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6,
1209                                            LibFileSearch("images", new_panel).c_str());
1210                 fl_redraw_object(bullets_->bmtable_panel);
1211                 fl_unfreeze_form(bullets_->form);
1212         }
1213 }
1214
1215
1216 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1217 {
1218         /* handle the user input by setting the current bullet depth's pixmap */
1219         /* to that extracted from the current chosen position of the BMTable  */
1220         /* Don't forget to free the button's old pixmap first.                */
1221
1222         BufferParams & param = controller().params();
1223         int bmtable_button = fl_get_bmtable(ob);
1224
1225         /* try to keep the button held down till another is pushed */
1226         /*  fl_set_bmtable(ob, 1, bmtable_button); */
1227         param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1228         param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1229         fl_set_input(bullets_->input_latex,
1230                      param.temp_bullets[current_bullet_depth].getText().c_str());
1231 }
1232
1233
1234 void FormDocument::CheckChoiceClass()
1235 {
1236         BufferParams & params = controller().params();
1237
1238         lyx::textclass_type const tc =
1239                 fl_get_combox(class_->combox_class) - 1;
1240
1241         if (controller().loadTextclass(tc)) {
1242                 params.textclass = tc;
1243
1244                 if (lyxrc.auto_reset_options) {
1245                         params.useClassDefaults();
1246                         UpdateLayoutDocument(params);
1247                 } else {
1248                         // update the params which are needed in any case
1249                         // (fontsizes, pagestyle)
1250                         UpdateClassParams(params);
1251                 }
1252
1253         } else {
1254                 int const revert = int(params.textclass);
1255                 fl_set_combox(class_->combox_class, revert + 1);
1256         }
1257 }
1258
1259
1260 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1261 {
1262         if (!dialog_.get())
1263                 return;
1264
1265         checkReadOnly();
1266         class_update(params);
1267         paper_update(params);
1268         language_update(params);
1269         options_update(params);
1270         bullets_update(params);
1271 }