]> git.lyx.org Git - features.git/blob - src/frontends/xforms/FormDocument.C
better latin3&4 support
[features.git] / src / frontends / xforms / FormDocument.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *           Copyright 2000-2001 The LyX Team.
7  *
8  *           @author Jürgen Vigna
9  *
10  *======================================================*/
11
12 #include <config.h>
13
14 #include FORMS_H_LOCATION
15 #include XPM_H_LOCATION
16
17 #ifdef __GNUG_
18 #pragma implementation
19 #endif
20
21 #include "lyx_gui_misc.h"
22
23 #include "FormDocument.h"
24 #include "form_document.h"
25 #include "Dialogs.h"
26 #include "layout.h"
27 #include "combox.h"
28 #include "tex-strings.h"
29 #include "bufferparams.h"
30 #include "insets/insetquotes.h"
31 #include "vspace.h"
32 #include "bmtable.h"
33 #include "support/filetools.h"
34 #include "support/lstrings.h"
35 #include "language.h"
36 #include "LyXView.h"
37 #include "lyxfunc.h"
38 #include "lyxrc.h"
39 #include "BufferView.h"
40 #include "buffer.h"
41 #include "Liason.h"
42 #include "CutAndPaste.h"
43 #include "bufferview_funcs.h"
44 #include "xforms_helpers.h" 
45 #include "debug.h"
46
47 using Liason::setMinibuffer;
48 using SigC::slot;
49
50 FormDocument::FormDocument(LyXView * lv, Dialogs * d)
51         : FormBaseBD(lv, d, _("Document Layout")),
52           ActCell(0), Confirmed(0),
53           current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
54 {
55         // let the dialog be shown
56         // This is a permanent connection so we won't bother
57         // storing a copy because we won't be disconnecting.
58         d->showDocument.connect(slot(this, &FormDocument::show));
59 }
60
61
62 void FormDocument::redraw()
63 {
64         if( form() && form()->visible )
65                 fl_redraw_form( form() );
66         else
67                 return;
68
69         FL_FORM * outer_form = fl_get_active_folder(dialog_->tabbed_folder);
70         if (outer_form && outer_form->visible)
71                 fl_redraw_form( outer_form );
72 }
73
74
75 FL_FORM * FormDocument::form() const
76 {
77         if (dialog_.get()) return dialog_->form;
78         return 0;
79 }
80
81
82 void FormDocument::build()
83 {
84         int n;
85
86         // the tabbed folder
87         dialog_.reset(build_tabbed_document());
88
89         // Manage the restore, ok, apply, restore and cancel/close buttons
90         bc().setOK(dialog_->button_ok);
91         bc().setApply(dialog_->button_apply);
92         bc().setCancel(dialog_->button_cancel);
93         bc().setRestore(dialog_->button_restore);
94         bc().addReadOnly (dialog_->button_save_defaults);
95         bc().addReadOnly (dialog_->button_reset_defaults);
96
97         // the document paper form
98         paper_.reset(build_doc_paper());
99         fl_addto_choice(paper_->choice_papersize2,
100                         _(" Default | Custom | USletter | USlegal "
101                           "| USexecutive | A3 | A4 | A5 | B3 | B4 | B5 "));
102         fl_addto_choice(paper_->choice_paperpackage,
103                         _(" None "
104                           "| Small Margins "
105                           "| Very small Margins "
106                           "| Very wide Margins "));
107
108         fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
109         fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
110         fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
111         fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
112         fl_set_input_return(paper_->input_left_margin, FL_RETURN_CHANGED);
113         fl_set_input_return(paper_->input_right_margin, FL_RETURN_CHANGED);
114         fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
115         fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
116         fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
117
118         bc().addReadOnly (paper_->choice_paperpackage);
119         bc().addReadOnly (paper_->greoup_radio_orientation);
120         bc().addReadOnly (paper_->radio_portrait);
121         bc().addReadOnly (paper_->radio_landscape);
122         bc().addReadOnly (paper_->choice_papersize2);
123         bc().addReadOnly (paper_->push_use_geometry);
124         bc().addReadOnly (paper_->input_custom_width);
125         bc().addReadOnly (paper_->input_custom_height);
126         bc().addReadOnly (paper_->input_top_margin);
127         bc().addReadOnly (paper_->input_bottom_margin);
128         bc().addReadOnly (paper_->input_left_margin);
129         bc().addReadOnly (paper_->input_right_margin);
130         bc().addReadOnly (paper_->input_head_height);
131         bc().addReadOnly (paper_->input_head_sep);
132         bc().addReadOnly (paper_->input_foot_skip);
133
134         // the document class form
135         class_.reset(build_doc_class());
136
137         FL_OBJECT * obj;
138         // The language is a combo-box and has to be inserted manually
139         obj = class_->choice_doc_class;
140         fl_deactivate_object(obj);
141         fl_addto_form(class_->form);
142         combo_doc_class.reset(new Combox(FL_COMBOX_DROPLIST));
143         combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400,
144                              dialog_->tabbed_folder);
145         combo_doc_class->shortcut("#C",1);
146         combo_doc_class->setcallback(ComboInputCB, this);
147         fl_end_form();
148         for (LyXTextClassList::const_iterator cit = textclasslist.begin();
149              cit != textclasslist.end(); ++cit) {
150                 combo_doc_class->addto(cit->description());
151         }
152
153         fl_addto_choice(class_->choice_doc_spacing,
154                         _(" Single | OneHalf | Double | Other "));
155         fl_addto_choice(class_->choice_doc_fontsize, "default|10|11|12");
156         for (n=0; tex_fonts[n][0]; ++n) {
157                 fl_addto_choice(class_->choice_doc_fonts,tex_fonts[n]);
158         }
159         fl_addto_choice(class_->choice_doc_pagestyle,
160                         "default|empty|plain|headings|fancy");
161         fl_addto_choice(class_->choice_doc_skip,
162                         _(" Smallskip | Medskip | Bigskip | Length "));
163         fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
164         fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
165         fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
166
167         bc().addReadOnly (class_->radio_doc_indent);
168         bc().addReadOnly (class_->radio_doc_skip);
169
170         bc().addReadOnly (class_->choice_doc_pagestyle);
171         bc().addReadOnly (class_->choice_doc_fonts);
172         bc().addReadOnly (class_->choice_doc_fontsize);
173         bc().addReadOnly (class_->radio_doc_sides_one);
174         bc().addReadOnly (class_->radio_doc_sides_two);
175         bc().addReadOnly (class_->radio_doc_columns_one);
176         bc().addReadOnly (class_->radio_doc_columns_two);
177         bc().addReadOnly (class_->input_doc_extra);
178         bc().addReadOnly (class_->input_doc_skip);
179         bc().addReadOnly (class_->choice_doc_skip);
180         bc().addReadOnly (class_->choice_doc_spacing);
181         bc().addReadOnly (class_->input_doc_spacing);
182
183         // the document language form
184         language_.reset(build_doc_language());
185         fl_addto_choice(language_->choice_inputenc,
186                         "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
187                         "|koi8-r|koi8-u|cp866|cp1251|iso88595");
188
189         // The language is a combo-box and has to be inserted manually
190         obj = language_->choice_language;
191         fl_deactivate_object(obj);
192         fl_addto_form(language_->form);
193         combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
194         combo_language->add(obj->x, obj->y, obj->w, obj->h, 400,
195                             dialog_->tabbed_folder);
196         combo_language->shortcut("#L",1);
197         combo_language->setcallback(ComboInputCB, this);
198         fl_end_form();
199
200         for (Languages::const_iterator cit = languages.begin();
201              cit != languages.end(); ++cit) {
202                 combo_language->addto(cit->second.lang());
203         }
204
205         fl_addto_choice(language_->choice_quotes_language,
206                         _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
207                           " «text» | »text« "));
208
209         bc().addReadOnly (language_->choice_inputenc);
210         bc().addReadOnly (language_->choice_quotes_language);
211         bc().addReadOnly (language_->radio_single);
212         bc().addReadOnly (language_->radio_double);
213
214         // the document options form
215         options_.reset(build_doc_options());
216         fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
217         fl_set_counter_bounds(options_->slider_secnumdepth,-2,5);
218         fl_set_counter_bounds(options_->slider_tocdepth,-1,5);
219         fl_set_counter_step(options_->slider_secnumdepth,1,1);
220         fl_set_counter_step(options_->slider_tocdepth,1,1);
221         fl_set_counter_precision(options_->slider_secnumdepth, 0);
222         fl_set_counter_precision(options_->slider_tocdepth, 0);
223         for (n=0; tex_graphics[n][0]; ++n) {
224                 fl_addto_choice(options_->choice_postscript_driver,
225                                 tex_graphics[n]);
226         }
227         fl_addto_choice(options_->choice_citation_format,
228                         _(" Author-year | Numerical "));
229
230         bc_.addReadOnly (options_->slider_secnumdepth);
231         bc_.addReadOnly (options_->slider_tocdepth);
232         bc_.addReadOnly (options_->check_use_amsmath);
233         bc_.addReadOnly (options_->check_use_natbib);
234         bc_.addReadOnly (options_->choice_citation_format);
235         bc_.addReadOnly (options_->input_float_placement);
236         bc_.addReadOnly (options_->choice_postscript_driver);
237
238         // the document bullets form
239         bullets_.reset(build_doc_bullet());
240         fl_addto_choice(bullets_->choice_bullet_size,
241                         _(" default | tiny | script | footnote | small |"
242                           " normal | large | Large | LARGE | huge | Huge"));
243         fl_set_choice(bullets_->choice_bullet_size, 1);
244         fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
245         fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
246
247         bc().addReadOnly (bullets_->bmtable_bullet_panel);
248         bc().addReadOnly (bullets_->choice_bullet_size);
249         bc().addReadOnly (bullets_->input_bullet_latex);
250         bc().addReadOnly (bullets_->radio_bullet_depth);
251         bc().addReadOnly (bullets_->radio_bullet_panel);
252
253         fl_addto_tabfolder(dialog_->tabbed_folder,_("Document"),
254                            class_->form);
255         fl_addto_tabfolder(dialog_->tabbed_folder,_("Paper"),
256                            paper_->form);
257         fl_addto_tabfolder(dialog_->tabbed_folder,_("Language"),
258                            language_->form);
259         fl_addto_tabfolder(dialog_->tabbed_folder,_("Extra"),
260                            options_->form);
261         fbullet = fl_addto_tabfolder(dialog_->tabbed_folder,_("Bullets"),
262                                      bullets_->form);
263         if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
264                 lyxerr << _("Your version of libXpm is older than 4.7.\n"
265                             "The `bullet' tab of the document dialog "
266                             "has been disabled") << '\n';
267                 fl_deactivate_object(fbullet);
268                 fl_set_object_lcol(fbullet, FL_INACTIVE);
269         }
270 }
271
272
273 void FormDocument::apply()
274 {
275         if (!lv_->view()->available() || !dialog_.get())
276                 return;
277
278         bool redo = class_apply();
279         paper_apply();
280         redo = language_apply() || redo;
281         redo = options_apply() || redo;
282         bullets_apply();
283
284         if (redo) {
285                 lv_->view()->redoCurrentBuffer();
286         }
287         lv_->buffer()->markDirty();
288         setMinibuffer(lv_, _("Document layout set"));
289 }
290
291
292 void FormDocument::cancel()
293 {
294         // this avoids confusion when reopening
295         BufferParams & param = lv_->buffer()->params;
296         param.temp_bullets[0] = param.user_defined_bullets[0];
297         param.temp_bullets[1] = param.user_defined_bullets[1];
298         param.temp_bullets[2] = param.user_defined_bullets[2];
299         param.temp_bullets[3] = param.user_defined_bullets[3];
300         hide();
301 }
302
303
304 void FormDocument::update()
305 {
306         if (!dialog_.get())
307                 return;
308
309         checkReadOnly();
310
311         BufferParams const & params = lv_->buffer()->params;
312
313 //      fl_set_object_label(dialog_->button_save_defaults,
314 //                          _("Save as Defaults"));
315 //      fl_set_object_label(dialog_->button_reset_defaults,
316 //                          _("Use Class Defaults"));
317         setEnabled(dialog_->button_reset_defaults,
318                    !params.hasClassDefaults());
319
320         class_update(params);
321         paper_update(params);
322         language_update(params);
323         options_update(params);
324         bullets_update(params);
325 }
326
327
328 bool FormDocument::input( FL_OBJECT * ob, long data )
329 {
330         State cb = static_cast<State>( data );
331
332         switch (cb) {
333         case CHECKCHOICECLASS:
334                 CheckChoiceClass(ob, 0);
335                 break;
336         case CHOICEBULLETSIZE:
337                 ChoiceBulletSize(ob, 0);
338                 break;
339         case INPUTBULLETLATEX:
340                 InputBulletLaTeX(ob, 0);
341                 break;
342         case BULLETDEPTH1:
343         case BULLETDEPTH2:
344         case BULLETDEPTH3:
345         case BULLETDEPTH4:
346                 BulletDepth(ob, cb);
347                 break;
348         case BULLETPANEL1:
349         case BULLETPANEL2:
350         case BULLETPANEL3:
351         case BULLETPANEL4:
352         case BULLETPANEL5:
353         case BULLETPANEL6:
354                 BulletPanel(ob, cb);
355                 break;
356         case BULLETBMTABLE:
357                 BulletBMTable(ob, 0);
358                 break;
359         default:
360                 break;
361         }
362
363         if (ob == options_->check_use_natbib) {
364                 setEnabled(options_->choice_citation_format,
365                            fl_get_button(options_->check_use_natbib));
366         }
367
368         if (ob == dialog_->button_save_defaults) {
369                 lv_->getLyXFunc()->dispatch(LFUN_LAYOUT_SAVE_DEFAULT);
370         }
371
372         if (ob == dialog_->button_reset_defaults) {
373                 BufferParams params = lv_->buffer()->params;
374                 params.textclass = combo_doc_class->get() - 1;
375                 params.useClassDefaults();
376                 UpdateLayoutDocument(params);
377         }
378
379         if (ob == paper_->radio_landscape)
380                 fl_set_choice(paper_->choice_paperpackage,
381                 BufferParams::PACKAGE_NONE + 1);
382
383         if (ob == paper_->choice_papersize2) {
384                 if (fl_get_choice(paper_->choice_papersize2) == 2)
385                         fl_set_button(paper_->radio_portrait, 1);
386                 setEnabled(paper_->input_custom_width,
387                         fl_get_choice(paper_->choice_papersize2) == 2);
388                 setEnabled(paper_->input_custom_height,
389                         fl_get_choice(paper_->choice_papersize2) == 2);
390                 setEnabled(paper_->radio_portrait,
391                         fl_get_choice(paper_->choice_papersize2) != 2);
392                 setEnabled(paper_->radio_landscape,
393                         fl_get_choice(paper_->choice_papersize2) != 2);
394         }
395
396         if (ob == paper_->choice_papersize2
397                 || paper_->radio_portrait
398                 || paper_->radio_landscape)
399                 setEnabled(paper_->choice_paperpackage,
400                            //either default papersize (preferences)
401                            //or document papersize has to be A4
402                            (fl_get_choice(paper_->choice_papersize2) == 7
403                             || fl_get_choice(paper_->choice_papersize2) == 1
404                             && lyxrc.default_papersize == 5)
405                            && fl_get_button(paper_->radio_portrait));
406
407         if (ob == paper_->choice_paperpackage) {
408                 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
409                         fl_set_button(paper_->push_use_geometry, 0);
410                         setEnabled(paper_->input_top_margin,
411                                    fl_get_button(paper_->push_use_geometry));
412                         setEnabled(paper_->input_bottom_margin,
413                                    fl_get_button(paper_->push_use_geometry));
414                         setEnabled(paper_->input_left_margin,
415                                    fl_get_button(paper_->push_use_geometry));
416                         setEnabled(paper_->input_right_margin,
417                                    fl_get_button(paper_->push_use_geometry));
418                         setEnabled(paper_->input_head_height,
419                                    fl_get_button(paper_->push_use_geometry));
420                         setEnabled(paper_->input_head_sep,
421                                    fl_get_button(paper_->push_use_geometry));
422                         setEnabled(paper_->input_foot_skip,
423                                    fl_get_button(paper_->push_use_geometry));
424                 }
425         }
426
427         if (ob == paper_->push_use_geometry) {
428                 //don't allow switching geometry off in custom papersize mode
429                 if (fl_get_choice(paper_->choice_papersize2) == 2)
430                         fl_set_button(paper_->push_use_geometry, 1);
431                 fl_set_choice(paper_->choice_paperpackage,
432                               BufferParams::PACKAGE_NONE + 1);
433                 setEnabled(paper_->input_top_margin,
434                            fl_get_button(paper_->push_use_geometry));
435                 setEnabled(paper_->input_bottom_margin,
436                            fl_get_button(paper_->push_use_geometry));
437                 setEnabled(paper_->input_left_margin,
438                            fl_get_button(paper_->push_use_geometry));
439                 setEnabled(paper_->input_right_margin,
440                            fl_get_button(paper_->push_use_geometry));
441                 setEnabled(paper_->input_head_height,
442                            fl_get_button(paper_->push_use_geometry));
443                 setEnabled(paper_->input_head_sep,
444                            fl_get_button(paper_->push_use_geometry));
445                 setEnabled(paper_->input_foot_skip,
446                            fl_get_button(paper_->push_use_geometry));
447         }
448
449         setEnabled(dialog_->button_reset_defaults,
450                    lv_->buffer()->params.hasClassDefaults());
451
452         switch (data) {
453         case INPUT:
454         case CHECKCHOICECLASS:
455         case CHOICEBULLETSIZE:
456         case INPUTBULLETLATEX:
457         case BULLETBMTABLE:
458                 return CheckDocumentInput(ob, 0);
459         default:
460                 break;
461         }
462
463         return true;
464 }
465
466
467 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
468 {
469         FormDocument * pre = static_cast<FormDocument*>(v);
470         if (combox == pre->combo_doc_class.get())
471                 pre->CheckChoiceClass(0, 0);
472         pre->bc().valid(pre->CheckDocumentInput(0,0));
473 }
474
475
476 bool FormDocument::class_apply()
477 {
478         bool redo = false;
479         BufferParams &params = lv_->buffer()->params;
480
481         // If default skip is a "Length" but there's no text in the
482         // input field, reset the kind to "Medskip", which is the default.
483         if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
484             !*(fl_get_input (class_->input_doc_skip))) {
485                 fl_set_choice (class_->choice_doc_skip, 2);
486         }
487         params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
488         params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
489         params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
490
491         unsigned int const new_class = combo_doc_class->get() - 1;
492         
493         if (params.textclass != new_class) {
494                 // try to load new_class
495                 if (textclasslist.Load(new_class)) {
496                         // successfully loaded
497                         redo = true;
498                         setMinibuffer(lv_, _("Converting document to new document class..."));
499                         int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
500                                 params.textclass, new_class,
501                                 lv_->buffer()->paragraph);
502                         if (ret) {
503                                 string s;
504                                 if (ret==1) {
505                                         s = _("One paragraph couldn't be converted");
506                                 } else {
507                                         s += tostr(ret);
508                                         s += _(" paragraphs couldn't be converted");
509                                 }
510                                 WriteAlert(_("Conversion Errors!"),s,
511                                            _("into chosen document class"));
512                         }
513                         
514                         params.textclass = new_class;
515                 } else {
516                         // problem changing class -- warn user and retain old style
517                         WriteAlert(_("Conversion Errors!"),
518                                    _("Errors loading new document class."),
519                                    _("Reverting to original document class."));
520                         combo_doc_class->select(int(params.textclass) + 1);
521                 }
522         }
523         BufferParams::PARSEP tmpsep = params.paragraph_separation;
524         if (fl_get_button(class_->radio_doc_indent))
525                 params.paragraph_separation = BufferParams::PARSEP_INDENT;
526         else
527                 params.paragraph_separation = BufferParams::PARSEP_SKIP;
528         if (tmpsep != params.paragraph_separation)
529                 redo = true;
530         
531         VSpace tmpdefskip = params.getDefSkip();
532         switch (fl_get_choice (class_->choice_doc_skip)) {
533         case 1:
534                 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
535                 break;
536         case 2:
537                 params.setDefSkip(VSpace(VSpace::MEDSKIP));
538                 break;
539         case 3:
540             params.setDefSkip(VSpace(VSpace::BIGSKIP));
541             break;
542         case 4:
543                 params.setDefSkip
544                         (VSpace(LyXGlueLength(fl_get_input(class_->input_doc_skip))));
545                 break;
546                 // DocumentDefskipCB assures that this never happens
547         default:
548                 params.setDefSkip(VSpace(VSpace::MEDSKIP));
549                 break;
550         }
551         if (!(tmpdefskip == params.getDefSkip()))
552                 redo = true;
553         
554         if (fl_get_button(class_->radio_doc_columns_two))
555                 params.columns = 2;
556         else
557                 params.columns = 1;
558         if (fl_get_button(class_->radio_doc_sides_two))
559                 params.sides = LyXTextClass::TwoSides;
560         else
561                 params.sides = LyXTextClass::OneSide;
562         
563         Spacing tmpSpacing = params.spacing;
564         switch (fl_get_choice(class_->choice_doc_spacing)) {
565         case 1:
566                 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
567                 params.spacing.set(Spacing::Single);
568                 break;
569         case 2:
570                 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
571                 params.spacing.set(Spacing::Onehalf);
572                 break;
573         case 3:
574                 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
575                 params.spacing.set(Spacing::Double);
576                 break;
577         case 4:
578                 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
579                 params.spacing.set(Spacing::Other, 
580                                    fl_get_input(class_->input_doc_spacing));
581                 break;
582         }
583         if (tmpSpacing != params.spacing)
584                 redo = true;
585         
586         params.options = fl_get_input(class_->input_doc_extra);
587         
588         return redo;
589 }
590
591
592 void FormDocument::paper_apply()
593 {
594         BufferParams & params = lv_->buffer()->params;
595
596         params.papersize2 =
597                 static_cast<char>(fl_get_choice(paper_->choice_papersize2)-1);
598         params.paperpackage =
599                 static_cast<char>(fl_get_choice(paper_->choice_paperpackage)-1);
600         params.use_geometry = fl_get_button(paper_->push_use_geometry);
601         if (fl_get_button(paper_->radio_landscape))
602                 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
603         else
604                 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
605         params.paperwidth = fl_get_input(paper_->input_custom_width);
606         params.paperheight = fl_get_input(paper_->input_custom_height);
607         params.leftmargin = fl_get_input(paper_->input_left_margin);
608         params.topmargin = fl_get_input(paper_->input_top_margin);
609         params.rightmargin = fl_get_input(paper_->input_right_margin);
610         params.bottommargin = fl_get_input(paper_->input_bottom_margin);
611         params.headheight = fl_get_input(paper_->input_head_height);
612         params.headsep = fl_get_input(paper_->input_head_sep);
613         params.footskip = fl_get_input(paper_->input_foot_skip);
614         lv_->buffer()->setPaperStuff();
615 }
616
617
618 bool FormDocument::language_apply()
619 {
620         BufferParams & params = lv_->buffer()->params;
621         InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
622         bool redo = false;
623
624         switch (fl_get_choice(language_->choice_quotes_language) - 1) {
625         case 0:
626                 lga = InsetQuotes::EnglishQ;
627                 break;
628         case 1:
629                 lga = InsetQuotes::SwedishQ;
630                 break;
631         case 2:
632                 lga = InsetQuotes::GermanQ;
633                 break;
634         case 3:
635                 lga = InsetQuotes::PolishQ;
636                 break;
637         case 4:
638                 lga = InsetQuotes::FrenchQ;
639                 break;
640         case 5:
641                 lga = InsetQuotes::DanishQ;
642                 break;
643         }
644         params.quotes_language = lga;
645         if (fl_get_button(language_->radio_single))   
646                 params.quotes_times = InsetQuotes::SingleQ;
647         else
648                 params.quotes_times = InsetQuotes::DoubleQ;
649
650         Language const * old_language = params.language;
651         Language const * new_language = 
652                 languages.getLanguage(combo_language->getline());
653         if (!new_language)
654                 new_language = default_language;
655
656         if (old_language != new_language
657             && old_language->RightToLeft() == new_language->RightToLeft()
658             && !lv_->buffer()->isMultiLingual())
659                 lv_->buffer()->changeLanguage(old_language, new_language);
660         if (old_language != new_language) {
661                 redo = true;
662         }
663         params.language = new_language;
664         params.inputenc = fl_get_choice_text(language_->choice_inputenc);
665
666         return redo;
667 }
668
669
670 bool FormDocument::options_apply()
671 {
672         BufferParams & params = lv_->buffer()->params;
673         bool redo = false;
674
675         params.graphicsDriver =
676                 fl_get_choice_text(options_->choice_postscript_driver);
677         params.use_amsmath = fl_get_button(options_->check_use_amsmath);
678         params.use_natbib  = fl_get_button(options_->check_use_natbib);
679         params.use_numerical_citations  =
680                 fl_get_choice(options_->choice_citation_format)-1;
681
682         int tmpchar = int(fl_get_counter_value(options_->slider_secnumdepth));
683         if (params.secnumdepth != tmpchar)
684                 redo = true;
685         params.secnumdepth = tmpchar;
686    
687         params.tocdepth = int(fl_get_counter_value(options_->slider_tocdepth));
688
689         params.float_placement =
690                 fl_get_input(options_->input_float_placement);
691
692         return redo;
693 }
694
695
696 void FormDocument::bullets_apply()
697 {
698         /* update the bullet settings */
699         BufferParams & param = lv_->buffer()->params;
700
701         // a little bit of loop unrolling
702         param.user_defined_bullets[0] = param.temp_bullets[0];
703         param.user_defined_bullets[1] = param.temp_bullets[1];
704         param.user_defined_bullets[2] = param.temp_bullets[2];
705         param.user_defined_bullets[3] = param.temp_bullets[3];
706 }
707
708
709 void FormDocument::class_update(BufferParams const & params)
710 {
711         if (!class_.get())
712                 return;
713
714         LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
715
716         combo_doc_class->select(
717                 textclasslist.DescOfClass(params.textclass));
718         fl_set_choice_text(class_->choice_doc_fonts, params.fonts.c_str());
719         fl_clear_choice(class_->choice_doc_fontsize);
720         fl_addto_choice(class_->choice_doc_fontsize, "default");
721         fl_addto_choice(class_->choice_doc_fontsize,
722                         tclass.opt_fontsize().c_str());
723         fl_set_choice(class_->choice_doc_fontsize,
724                       tokenPos(tclass.opt_fontsize(), '|', params.fontsize)+2);
725         fl_clear_choice(class_->choice_doc_pagestyle);
726         fl_addto_choice(class_->choice_doc_pagestyle, "default");
727         fl_addto_choice(class_->choice_doc_pagestyle,
728                         tclass.opt_pagestyle().c_str());
729         fl_set_choice(class_->choice_doc_pagestyle,
730                       tokenPos(tclass.opt_pagestyle(), '|', params.pagestyle)+2);
731         fl_set_button(class_->radio_doc_indent, 0);
732         fl_set_button(class_->radio_doc_skip, 0);
733         if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
734                 fl_set_button(class_->radio_doc_indent, 1);
735         else
736                 fl_set_button(class_->radio_doc_skip, 1);
737         switch (params.getDefSkip().kind()) {
738         case VSpace::SMALLSKIP: 
739                 fl_set_choice (class_->choice_doc_skip, 1);
740                 break;
741         case VSpace::MEDSKIP: 
742                 fl_set_choice (class_->choice_doc_skip, 2);
743                 break;
744         case VSpace::BIGSKIP: 
745                 fl_set_choice (class_->choice_doc_skip, 3);
746                 break;
747         case VSpace::LENGTH: 
748                 fl_set_choice (class_->choice_doc_skip, 4);
749                 fl_set_input (class_->input_doc_skip,
750                               params.getDefSkip().asLyXCommand().c_str());
751                 break;
752         default:
753                 fl_set_choice (class_->choice_doc_skip, 2);
754                 break;
755         }
756         fl_set_button(class_->radio_doc_sides_one, 0);
757         fl_set_button(class_->radio_doc_sides_two, 0);
758         if (params.sides == LyXTextClass::TwoSides)
759                 fl_set_button(class_->radio_doc_sides_two, 1);
760         else
761                 fl_set_button(class_->radio_doc_sides_one, 1);
762         fl_set_button(class_->radio_doc_columns_one, 0);
763         fl_set_button(class_->radio_doc_columns_two, 0);
764         if (params.columns == 2)
765                 fl_set_button(class_->radio_doc_columns_two, 1);
766         else
767                 fl_set_button(class_->radio_doc_columns_one, 1);
768         fl_set_input(class_->input_doc_spacing, "");
769         switch (params.spacing.getSpace()) {
770         case Spacing::Default: // nothing bad should happen with this
771         case Spacing::Single:
772                 // \singlespacing
773                 fl_set_choice(class_->choice_doc_spacing, 1);
774                 break;
775         case Spacing::Onehalf:
776                 // \onehalfspacing
777                 fl_set_choice(class_->choice_doc_spacing, 2);
778                 break;
779         case Spacing::Double:
780                 // \doublespacing
781                 fl_set_choice(class_->choice_doc_spacing, 3);
782                 break;
783         case Spacing::Other:
784         {
785                 fl_set_choice(class_->choice_doc_spacing, 4);
786                 char sval[20];
787                 sprintf(sval,"%g",params.spacing.getValue()); 
788                 fl_set_input(class_->input_doc_spacing, sval);
789                 break;
790         }
791         }
792         if (!params.options.empty())
793                 fl_set_input(class_->input_doc_extra, params.options.c_str());
794         else
795                 fl_set_input(class_->input_doc_extra, "");
796 }
797
798
799 void FormDocument::language_update(BufferParams const & params)
800 {
801         if (!language_.get())
802                 return;
803
804         combo_language->select(params.language->lang());
805         fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
806         fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
807         fl_set_button(language_->radio_single, 0);
808         fl_set_button(language_->radio_double, 0);
809         if (params.quotes_times == InsetQuotes::SingleQ)
810                 fl_set_button(language_->radio_single, 1);
811         else
812                 fl_set_button(language_->radio_double, 1);
813 }
814
815
816 void FormDocument::options_update(BufferParams const & params)
817 {
818         if (!options_.get())
819                 return;
820
821         fl_set_choice_text(options_->choice_postscript_driver,
822                            params.graphicsDriver.c_str());
823         fl_set_button(options_->check_use_amsmath, params.use_amsmath);
824         fl_set_button(options_->check_use_natbib,  params.use_natbib);
825         fl_set_choice(options_->choice_citation_format,
826                       int(params.use_numerical_citations)+1);
827         setEnabled(options_->choice_citation_format, params.use_natbib);
828         fl_set_counter_value(options_->slider_secnumdepth, params.secnumdepth);
829         fl_set_counter_value(options_->slider_tocdepth, params.tocdepth);
830         if (!params.float_placement.empty())
831                 fl_set_input(options_->input_float_placement,
832                              params.float_placement.c_str());
833         else
834                 fl_set_input(options_->input_float_placement, "");
835 }
836
837
838 void FormDocument::paper_update(BufferParams const & params)
839 {
840         if (!paper_.get())
841                 return;
842
843         fl_set_choice(paper_->choice_papersize2, params.papersize2 + 1);
844         fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
845         fl_set_button(paper_->push_use_geometry, params.use_geometry);
846         fl_set_button(paper_->radio_portrait, 0);
847         setEnabled(paper_->radio_portrait,
848                    fl_get_choice(paper_->choice_papersize2) != 2);
849         fl_set_button(paper_->radio_landscape, 0);
850         setEnabled(paper_->radio_landscape,
851                    fl_get_choice(paper_->choice_papersize2) != 2);
852         if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
853                 fl_set_button(paper_->radio_landscape, 1);
854         else
855                 fl_set_button(paper_->radio_portrait, 1);
856         setEnabled(paper_->choice_paperpackage,
857                    //either default papersize (preferences)
858                    //or document papersize has to be A4
859                    (fl_get_choice(paper_->choice_papersize2) == 7
860                     || fl_get_choice(paper_->choice_papersize2) == 1
861                     && lyxrc.default_papersize == 5)
862                    && fl_get_button(paper_->radio_portrait));
863         fl_set_input(paper_->input_custom_width, params.paperwidth.c_str());
864         setEnabled(paper_->input_custom_width,
865                    fl_get_choice(paper_->choice_papersize2) == 2);
866         fl_set_input(paper_->input_custom_height, params.paperheight.c_str());
867         setEnabled(paper_->input_custom_height,
868                    fl_get_choice(paper_->choice_papersize2) == 2);
869         fl_set_input(paper_->input_left_margin, params.leftmargin.c_str());
870         setEnabled(paper_->input_left_margin,
871                    fl_get_button(paper_->push_use_geometry));
872         fl_set_input(paper_->input_top_margin, params.topmargin.c_str());
873         setEnabled(paper_->input_top_margin,
874                    fl_get_button(paper_->push_use_geometry));
875         fl_set_input(paper_->input_right_margin, params.rightmargin.c_str());
876         setEnabled(paper_->input_right_margin,
877                    fl_get_button(paper_->push_use_geometry));
878         fl_set_input(paper_->input_bottom_margin, params.bottommargin.c_str());
879         setEnabled(paper_->input_bottom_margin,
880                    fl_get_button(paper_->push_use_geometry));
881         fl_set_input(paper_->input_head_height, params.headheight.c_str());
882         setEnabled(paper_->input_head_height,
883                    fl_get_button(paper_->push_use_geometry));
884         fl_set_input(paper_->input_head_sep, params.headsep.c_str());
885         setEnabled(paper_->input_head_sep,
886                    fl_get_button(paper_->push_use_geometry));
887         fl_set_input(paper_->input_foot_skip, params.footskip.c_str());
888         setEnabled(paper_->input_foot_skip,
889                    fl_get_button(paper_->push_use_geometry));
890         fl_set_focus_object(paper_->form, paper_->choice_papersize2);
891 }
892
893
894 void FormDocument::bullets_update(BufferParams const & params)
895 {
896         if (!bullets_.get() ||
897             ((XpmVersion<4) ||
898              (XpmVersion==4 && XpmRevision<7)))
899                 return;
900
901         bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
902         setEnabled(fbullet, !isLinuxDoc);
903
904         if (isLinuxDoc) return;
905
906         fl_set_button(bullets_->radio_bullet_depth_1, 1);
907         fl_set_input(bullets_->input_bullet_latex,
908                      params.user_defined_bullets[0].getText().c_str());
909         fl_set_choice(bullets_->choice_bullet_size,
910                       params.user_defined_bullets[0].getSize() + 2);
911 }
912
913
914 void FormDocument::checkReadOnly()
915 {
916         if (bc().readOnly(lv_->buffer()->isReadonly())) {
917                 combo_doc_class->deactivate();
918                 combo_language->deactivate();
919                 fl_set_object_label(dialog_->text_warning,
920                                     _("Document is read-only."
921                                       " No changes to layout permitted."));
922                 fl_show_object(dialog_->text_warning);
923         } else {
924                 combo_doc_class->activate();
925                 combo_language->activate();
926                 fl_hide_object(dialog_->text_warning);
927         }
928 }
929
930
931 void FormDocument::checkMarginValues()
932 {
933 //this is not needed after the recent redesign (JSpitzm)
934 #if 0
935         bool const not_empty =
936                 strlen(fl_get_input(paper_->input_top_margin)) ||
937                 strlen(fl_get_input(paper_->input_bottom_margin)) ||
938                 strlen(fl_get_input(paper_->input_left_margin)) ||
939                 strlen(fl_get_input(paper_->input_right_margin)) ||
940                 strlen(fl_get_input(paper_->input_head_height)) ||
941                 strlen(fl_get_input(paper_->input_head_sep)) ||
942                 strlen(fl_get_input(paper_->input_foot_skip)) ||
943                 strlen(fl_get_input(paper_->input_custom_width)) ||
944                 strlen(fl_get_input(paper_->input_custom_height));
945 #endif
946 }
947
948
949
950 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
951 {
952         string str;
953         int val;
954         bool ok = true;
955         char const * input;
956     
957         checkMarginValues();
958         if (ob == paper_->choice_papersize2) {
959                 val = fl_get_choice(paper_->choice_papersize2)-1;
960                 if (val == BufferParams::VM_PAPER_DEFAULT) {
961                         fl_set_button(paper_->push_use_geometry, 0);
962                         setEnabled(paper_->input_top_margin,
963                                    fl_get_button(paper_->push_use_geometry));
964                         setEnabled(paper_->input_bottom_margin,
965                                    fl_get_button(paper_->push_use_geometry));
966                         setEnabled(paper_->input_left_margin,
967                                    fl_get_button(paper_->push_use_geometry));
968                         setEnabled(paper_->input_right_margin,
969                                    fl_get_button(paper_->push_use_geometry));
970                         setEnabled(paper_->input_head_height,
971                                    fl_get_button(paper_->push_use_geometry));
972                         setEnabled(paper_->input_head_sep,
973                                    fl_get_button(paper_->push_use_geometry));
974                         setEnabled(paper_->input_foot_skip,
975                                    fl_get_button(paper_->push_use_geometry));
976                         checkMarginValues();
977                 } else {
978                         if ((val != BufferParams::VM_PAPER_USLETTER) &&
979                             (val != BufferParams::VM_PAPER_USLEGAL) &&
980                             (val != BufferParams::VM_PAPER_USEXECUTIVE) &&
981                             (val != BufferParams::VM_PAPER_A4) &&
982                             (val != BufferParams::VM_PAPER_A5) &&
983                             (val != BufferParams::VM_PAPER_B5)) {
984                                 fl_set_button(paper_->push_use_geometry, 1);
985                                 setEnabled(paper_->input_top_margin,
986                                            fl_get_button(paper_->push_use_geometry));
987                                 setEnabled(paper_->input_bottom_margin,
988                                            fl_get_button(paper_->push_use_geometry));
989                                 setEnabled(paper_->input_left_margin,
990                                            fl_get_button(paper_->push_use_geometry));
991                                 setEnabled(paper_->input_right_margin,
992                                            fl_get_button(paper_->push_use_geometry));
993                                 setEnabled(paper_->input_head_height,
994                                            fl_get_button(paper_->push_use_geometry));
995                                 setEnabled(paper_->input_head_sep,
996                                            fl_get_button(paper_->push_use_geometry));
997                                 setEnabled(paper_->input_foot_skip,
998                                            fl_get_button(paper_->push_use_geometry));
999                         }
1000                         fl_set_choice(paper_->choice_paperpackage,
1001                                       BufferParams::PACKAGE_NONE + 1);
1002                 }
1003         } else if (ob == paper_->choice_paperpackage) {
1004                 val = fl_get_choice(paper_->choice_paperpackage)-1;
1005                 if (val != BufferParams::PACKAGE_NONE) {
1006                         fl_set_button(paper_->push_use_geometry, 0);
1007                         setEnabled(paper_->input_top_margin,
1008                                    fl_get_button(paper_->push_use_geometry));
1009                         setEnabled(paper_->input_bottom_margin,
1010                                    fl_get_button(paper_->push_use_geometry));
1011                         setEnabled(paper_->input_left_margin,
1012                                    fl_get_button(paper_->push_use_geometry));
1013                         setEnabled(paper_->input_right_margin,
1014                                    fl_get_button(paper_->push_use_geometry));
1015                         setEnabled(paper_->input_head_height,
1016                                    fl_get_button(paper_->push_use_geometry));
1017                         setEnabled(paper_->input_head_sep,
1018                                    fl_get_button(paper_->push_use_geometry));
1019                         setEnabled(paper_->input_foot_skip,
1020                                    fl_get_button(paper_->push_use_geometry));
1021                 }
1022         } else if (ob == class_->input_doc_spacing) {
1023                 input = fl_get_input(class_->input_doc_spacing);
1024                 if (!*input) {
1025                         fl_set_choice (class_->choice_doc_spacing, 1);
1026                 } else {
1027                         fl_set_choice(class_->choice_doc_spacing, 4);
1028                 }
1029         }
1030         // this has to be all out of if/elseif because it has to deactivate
1031         // the document buttons and so the whole stuff has to be tested again.
1032         str = fl_get_input(paper_->input_custom_width);
1033         ok = ok && (str.empty() || isValidLength(str));
1034         str = fl_get_input(paper_->input_custom_height);
1035         ok = ok && (str.empty() || isValidLength(str));
1036         str = fl_get_input(paper_->input_left_margin);
1037         ok = ok && (str.empty() || isValidLength(str));
1038         str = fl_get_input(paper_->input_right_margin);
1039         ok = ok && (str.empty() || isValidLength(str));
1040         str = fl_get_input(paper_->input_top_margin);
1041         ok = ok && (str.empty() || isValidLength(str));
1042         str = fl_get_input(paper_->input_bottom_margin);
1043         ok = ok && (str.empty() || isValidLength(str));
1044         str = fl_get_input(paper_->input_head_height);
1045         ok = ok && (str.empty() || isValidLength(str));
1046         str = fl_get_input(paper_->input_head_sep);
1047         ok = ok && (str.empty() || isValidLength(str));
1048         str = fl_get_input(paper_->input_foot_skip);
1049         ok = ok && (str.empty() || isValidLength(str));
1050         // "Synchronize" the choice and the input field, so that it
1051         // is impossible to commit senseless data.
1052         input = fl_get_input (class_->input_doc_skip);
1053         if (ob == class_->input_doc_skip) {
1054                 if (!*input) {
1055                         fl_set_choice (class_->choice_doc_skip, 2);
1056                 } else if (isValidGlueLength (input)) {
1057                         fl_set_choice (class_->choice_doc_skip, 4);
1058                 } else {
1059                         fl_set_choice(class_->choice_doc_skip, 4);
1060                         ok = false;
1061                 }
1062         } else {
1063                 if (*input && !isValidGlueLength(input))
1064                         ok = false;
1065         }
1066
1067         if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1068                 ok = false;
1069         else if (fl_get_choice(class_->choice_doc_skip) != 4)
1070                 fl_set_input (class_->input_doc_skip, "");
1071
1072         input = fl_get_input(class_->input_doc_spacing);
1073         if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1074                 ok = false;
1075         else  if (fl_get_choice(class_->choice_doc_spacing) != 4)
1076                 fl_set_input (class_->input_doc_spacing, "");
1077         return ok;
1078 }
1079
1080
1081 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/ )
1082 {
1083         BufferParams & param = lv_->buffer()->params;
1084
1085         // convert from 1-6 range to -1-4 
1086         param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1087         fl_set_input(bullets_->input_bullet_latex,
1088                      param.temp_bullets[current_bullet_depth].getText().c_str());
1089 }
1090
1091
1092 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1093 {
1094         BufferParams & param = lv_->buffer()->params;
1095
1096         param.temp_bullets[current_bullet_depth].
1097                 setText(fl_get_input(bullets_->input_bullet_latex));
1098 }
1099
1100
1101 void FormDocument::BulletDepth(FL_OBJECT * ob, State cb)
1102 {
1103         /* Should I do the following:                                 */
1104         /*  1. change to the panel that the current bullet belongs in */
1105         /*  2. show that bullet as selected                           */
1106         /*  3. change the size setting to the size of the bullet in Q.*/
1107         /*  4. display the latex equivalent in the latex box          */
1108         /*                                                            */
1109         /* I'm inclined to just go with 3 and 4 at the moment and     */
1110         /* maybe try to support the others later                      */
1111         BufferParams & param = lv_->buffer()->params;
1112
1113         int data = 0;
1114         if (cb == BULLETDEPTH1 )
1115                 data = 0;
1116         else if (cb == BULLETDEPTH2 )
1117                 data = 1;
1118         else if (cb == BULLETDEPTH3 )
1119                 data = 2;
1120         else if (cb == BULLETDEPTH4 )
1121                 data = 3;
1122
1123         switch (fl_get_button_numb(ob)) {
1124         case 3:
1125                 // right mouse button resets to default
1126                 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1127         default:
1128                 current_bullet_depth = data;
1129                 fl_set_input(bullets_->input_bullet_latex,
1130                              param.temp_bullets[data].getText().c_str());
1131                 fl_set_choice(bullets_->choice_bullet_size,
1132                               param.temp_bullets[data].getSize() + 2);
1133         }
1134 }
1135
1136
1137 void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, State cb)
1138 {
1139         /* Here we have to change the background pixmap to that selected */
1140         /* by the user. (eg. standard.xpm, psnfss1.xpm etc...)           */
1141     
1142         int data = 0;
1143         if (cb == BULLETPANEL1 )
1144                 data = 0;
1145         else if (cb == BULLETPANEL2 )
1146                 data = 1;
1147         else if (cb == BULLETPANEL3 )
1148                 data = 2;
1149         else if (cb == BULLETPANEL4 )
1150                 data = 3;
1151         else if (cb == BULLETPANEL5 )
1152                 data = 4;
1153         else if (cb == BULLETPANEL6 )
1154                 data = 5;
1155
1156         if (data != current_bullet_panel) {
1157                 fl_freeze_form(bullets_->form);
1158                 current_bullet_panel = data;
1159
1160                 /* free the current pixmap */
1161                 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1162                 string new_panel;
1163                 switch (cb) {
1164                         /* display the new one */
1165                 case BULLETPANEL1 :
1166                         new_panel = "standard";
1167                         break;
1168                 case BULLETPANEL2 :
1169                         new_panel = "amssymb";
1170                         break;
1171                 case BULLETPANEL3 :
1172                         new_panel = "psnfss1";
1173                         break;
1174                 case BULLETPANEL4 :
1175                         new_panel = "psnfss2";
1176                         break;
1177                 case BULLETPANEL5 :
1178                         new_panel = "psnfss3";
1179                         break;
1180                 case BULLETPANEL6 :
1181                         new_panel = "psnfss4";
1182                         break;
1183                 default :
1184                         /* something very wrong happened */
1185                         // play it safe for now but should be an exception
1186                         current_bullet_panel = 0;  // standard panel
1187                         new_panel = "standard";
1188                         break;
1189                 }
1190                 new_panel += ".xpm";
1191                 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1192                                            LibFileSearch("images", new_panel).c_str());
1193                 fl_redraw_object(bullets_->bmtable_bullet_panel);
1194                 fl_unfreeze_form(bullets_->form);
1195         }
1196 }
1197
1198
1199 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/ )
1200 {
1201         /* handle the user input by setting the current bullet depth's pixmap */
1202         /* to that extracted from the current chosen position of the BMTable  */
1203         /* Don't forget to free the button's old pixmap first.                */
1204         
1205         BufferParams & param = lv_->buffer()->params;
1206         int bmtable_button = fl_get_bmtable(ob);
1207         
1208         /* try to keep the button held down till another is pushed */
1209         /*  fl_set_bmtable(ob, 1, bmtable_button); */
1210         param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1211         param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1212         fl_set_input(bullets_->input_bullet_latex,
1213                      param.temp_bullets[current_bullet_depth].getText().c_str());
1214 }
1215
1216
1217 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1218 {
1219         if (!ob)
1220                 ob = class_->choice_doc_class;
1221
1222         lv_->prohibitInput();
1223
1224         unsigned int tc = combo_doc_class->get() - 1;
1225         if (textclasslist.Load(tc)) {
1226                 // we use a copy of the bufferparams because we do not
1227                 // want to modify them yet.
1228                 BufferParams params = lv_->buffer()->params;
1229
1230                 if (lyxrc.auto_reset_options) {
1231                         params.textclass = tc;
1232                         params.useClassDefaults();
1233                         UpdateLayoutDocument(params);
1234                 }
1235         } else {
1236                 // unable to load new style
1237                 WriteAlert(_("Conversion Errors!"),
1238                            _("Unable to switch to new document class."),
1239                            _("Reverting to original document class."));
1240                 combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
1241         }
1242         lv_->allowInput();
1243 }
1244
1245
1246 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1247 {
1248         if (!dialog_.get())
1249                 return;
1250
1251         checkReadOnly();
1252         class_update(params);
1253         paper_update(params);
1254         language_update(params);
1255         options_update(params);
1256         bullets_update(params);
1257 }