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