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