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