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