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