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