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