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