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