3 * Copyright 2000-2001 The LyX Team.
4 * See the file COPYING.
6 * \author Jürgen Vigna, jug@sad.it
11 #include FORMS_H_LOCATION
12 #include XPM_H_LOCATION
15 #pragma implementation
18 #include "FormDocument.h"
19 #include "form_document.h"
22 #include "lyxtextclasslist.h"
24 #include "tex-strings.h"
25 #include "bufferparams.h"
29 #include "frnt_lang.h"
33 #include "BufferView.h"
36 #include "CutAndPaste.h"
37 #include "bufferview_funcs.h"
38 #include "xforms_helpers.h"
40 #include "input_validators.h" // fl_unsigned_float_filter
41 #include "helper_funcs.h"
42 #include "lyx_main.h" // for user_lyxdir
44 #include "insets/insetquotes.h"
46 #include "support/filetools.h"
47 #include "support/lstrings.h"
53 using Liason::setMinibuffer;
57 FormDocument::FormDocument(LyXView * lv, Dialogs * d)
58 : FormBaseBD(lv, d, _("Document Layout")),
59 ActCell(0), Confirmed(0),
60 current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
62 // let the dialog be shown
63 // This is a permanent connection so we won't bother
64 // storing a copy because we won't be disconnecting.
65 d->showDocument.connect(slot(this, &FormDocument::show));
69 void FormDocument::redraw()
71 if (form() && form()->visible)
72 fl_redraw_form(form());
76 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
77 if (outer_form && outer_form->visible)
78 fl_redraw_form(outer_form);
82 FL_FORM * FormDocument::form() const
84 if (dialog_.get()) return dialog_->form;
89 void FormDocument::build()
94 dialog_.reset(build_tabbed_document());
96 // Allow the base class to control messages
97 setMessageWidget(dialog_->text_warning);
99 // Manage the restore, ok, apply, restore and cancel/close buttons
100 bc().setOK(dialog_->button_ok);
101 bc().setApply(dialog_->button_apply);
102 bc().setCancel(dialog_->button_close);
103 bc().setRestore(dialog_->button_restore);
104 bc().addReadOnly (dialog_->button_save_defaults);
105 bc().addReadOnly (dialog_->button_reset_defaults);
107 // the document paper form
108 paper_.reset(build_doc_paper());
109 fl_addto_choice(paper_->choice_papersize,
110 _(" Default | Custom | US letter | US legal "
111 "| US executive | A3 | A4 | A5 | B3 | B4 | B5 "));
112 fl_addto_choice(paper_->choice_paperpackage,
115 "| Very small Margins "
116 "| Very wide Margins "));
118 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
119 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
120 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
121 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
122 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
123 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
124 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
125 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
126 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
128 setPrehandler(paper_->input_custom_width);
129 setPrehandler(paper_->input_custom_height);
130 setPrehandler(paper_->input_top_margin);
131 setPrehandler(paper_->input_bottom_margin);
132 setPrehandler(paper_->input_inner_margin);
133 setPrehandler(paper_->input_outer_margin);
134 setPrehandler(paper_->input_head_height);
135 setPrehandler(paper_->input_head_sep);
136 setPrehandler(paper_->input_foot_skip);
138 // Create the contents of the unit choices
139 // Don't include the "%" terms...
140 vector<string> units_vec = getLatexUnits();
142 for (vector<string>::iterator it = units_vec.begin();
143 it != units_vec.end(); ++it) {
144 if (contains(*it, "%"))
145 it = units_vec.erase(it, it+1) - 1;
148 vector<string>::iterator ret =
149 std::remove_if(units_vec.begin(),
151 bind2nd(contains_functor(), "%"));
152 units_vec.erase(ret, units_vec.end());
154 string units = getStringFromVector(units_vec, "|");
156 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
157 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
158 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
159 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
160 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
161 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
162 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
163 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
164 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
166 bc().addReadOnly (paper_->choice_paperpackage);
167 bc().addReadOnly (paper_->radio_portrait);
168 bc().addReadOnly (paper_->radio_landscape);
169 bc().addReadOnly (paper_->choice_papersize);
170 bc().addReadOnly (paper_->check_use_geometry);
171 bc().addReadOnly (paper_->input_custom_width);
172 bc().addReadOnly (paper_->input_custom_height);
173 bc().addReadOnly (paper_->input_top_margin);
174 bc().addReadOnly (paper_->input_bottom_margin);
175 bc().addReadOnly (paper_->input_inner_margin);
176 bc().addReadOnly (paper_->input_outer_margin);
177 bc().addReadOnly (paper_->input_head_height);
178 bc().addReadOnly (paper_->input_head_sep);
179 bc().addReadOnly (paper_->input_foot_skip);
181 // the document class form
182 class_.reset(build_doc_class());
185 // The language is a combo-box and has to be inserted manually
186 obj = class_->choice_doc_class;
187 fl_deactivate_object(obj);
188 fl_addto_form(class_->form);
189 combo_doc_class.reset(new Combox(FL_COMBOX_DROPLIST));
190 combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400,
192 combo_doc_class->shortcut("#C",1);
193 combo_doc_class->setcallback(ComboInputCB, this);
195 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
196 cit != textclasslist.end(); ++cit) {
197 combo_doc_class->addto(cit->description());
200 fl_addto_choice(class_->choice_doc_spacing,
201 _(" Single | OneHalf | Double | Custom "));
202 fl_addto_choice(class_->choice_doc_fontsize, "default|10|11|12");
203 for (n=0; tex_fonts[n][0]; ++n) {
204 fl_addto_choice(class_->choice_doc_fonts,tex_fonts[n]);
206 fl_addto_choice(class_->choice_doc_pagestyle,
207 "default|empty|plain|headings|fancy");
208 fl_addto_choice(class_->choice_doc_skip,
209 _(" Smallskip | Medskip | Bigskip | Length "));
210 fl_addto_choice(class_->choice_default_skip_units, units.c_str());
211 fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
212 fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
213 fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
215 setPrehandler(class_->input_doc_extra);
216 setPrehandler(class_->input_doc_skip);
217 setPrehandler(class_->input_doc_spacing);
219 // Set input filters on doc spacing to make it accept only
221 fl_set_input_filter(class_->input_doc_spacing, fl_unsigned_float_filter);
223 bc().addReadOnly (class_->radio_doc_indent);
224 bc().addReadOnly (class_->radio_doc_skip);
226 bc().addReadOnly (class_->choice_doc_pagestyle);
227 bc().addReadOnly (class_->choice_doc_fonts);
228 bc().addReadOnly (class_->choice_doc_fontsize);
229 bc().addReadOnly (class_->radio_doc_sides_one);
230 bc().addReadOnly (class_->radio_doc_sides_two);
231 bc().addReadOnly (class_->radio_doc_columns_one);
232 bc().addReadOnly (class_->radio_doc_columns_two);
233 bc().addReadOnly (class_->input_doc_extra);
234 bc().addReadOnly (class_->input_doc_skip);
235 bc().addReadOnly (class_->choice_doc_skip);
236 bc().addReadOnly (class_->choice_doc_spacing);
237 bc().addReadOnly (class_->input_doc_spacing);
239 // the document language form
240 language_.reset(build_doc_language());
241 fl_addto_choice(language_->choice_inputenc,
242 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
243 "|koi8-r|koi8-u|cp866|cp1251|iso88595");
245 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
246 // Store the identifiers for later
247 lang_ = getSecond(langs);
249 // The language is a combo-box and has to be inserted manually
250 obj = language_->choice_language;
251 fl_deactivate_object(obj);
252 fl_addto_form(language_->form);
253 combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
254 combo_language->add(obj->x, obj->y, obj->w, obj->h, 400,
256 combo_language->shortcut("#L",1);
257 combo_language->setcallback(ComboInputCB, this);
260 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
261 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
262 for (; lit != lend; ++lit) {
263 combo_language->addto(lit->first);
265 combo_language->select(1);
267 fl_addto_choice(language_->choice_quotes_language,
268 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
269 " «text» | »text« "));
271 bc().addReadOnly (language_->choice_inputenc);
272 bc().addReadOnly (language_->choice_quotes_language);
273 bc().addReadOnly (language_->radio_single);
274 bc().addReadOnly (language_->radio_double);
276 // the document options form
277 options_.reset(build_doc_options());
278 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
279 setPrehandler(options_->input_float_placement);
281 fl_set_counter_bounds(options_->counter_secnumdepth,-2,5);
282 fl_set_counter_bounds(options_->counter_tocdepth,-1,5);
283 fl_set_counter_step(options_->counter_secnumdepth,1,1);
284 fl_set_counter_step(options_->counter_tocdepth,1,1);
285 fl_set_counter_precision(options_->counter_secnumdepth, 0);
286 fl_set_counter_precision(options_->counter_tocdepth, 0);
287 for (n=0; tex_graphics[n][0]; ++n) {
288 fl_addto_choice(options_->choice_postscript_driver,
291 fl_addto_choice(options_->choice_citation_format,
292 _(" Author-year | Numerical "));
294 bc_.addReadOnly (options_->counter_secnumdepth);
295 bc_.addReadOnly (options_->counter_tocdepth);
296 bc_.addReadOnly (options_->check_use_amsmath);
297 bc_.addReadOnly (options_->check_use_natbib);
298 bc_.addReadOnly (options_->choice_citation_format);
299 bc_.addReadOnly (options_->input_float_placement);
300 bc_.addReadOnly (options_->choice_postscript_driver);
302 // the document bullets form
303 bullets_.reset(build_doc_bullet());
304 fl_addto_choice(bullets_->choice_bullet_size,
305 _(" default | tiny | script | footnote | small |"
306 " normal | large | Large | LARGE | huge | Huge"));
307 fl_set_choice(bullets_->choice_bullet_size, 1);
308 fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
309 setPrehandler(bullets_->input_bullet_latex);
310 fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
312 bc_.addReadOnly(bullets_->radio_bullet_depth_1);
313 bc_.addReadOnly(bullets_->radio_bullet_depth_2);
314 bc_.addReadOnly(bullets_->radio_bullet_depth_3);
315 bc_.addReadOnly(bullets_->radio_bullet_depth_4);
316 bc_.addReadOnly(bullets_->radio_bullet_panel_standard);
317 bc_.addReadOnly(bullets_->radio_bullet_panel_maths);
318 bc_.addReadOnly(bullets_->radio_bullet_panel_ding1);
319 bc_.addReadOnly(bullets_->radio_bullet_panel_ding2);
320 bc_.addReadOnly(bullets_->radio_bullet_panel_ding3);
321 bc_.addReadOnly(bullets_->radio_bullet_panel_ding4);
323 bc().addReadOnly (bullets_->bmtable_bullet_panel);
324 bc().addReadOnly (bullets_->choice_bullet_size);
325 bc().addReadOnly (bullets_->input_bullet_latex);
327 fl_addto_tabfolder(dialog_->tabfolder,_("Document"),
329 fl_addto_tabfolder(dialog_->tabfolder,_("Paper"),
331 fl_addto_tabfolder(dialog_->tabfolder,_("Language"),
333 fl_addto_tabfolder(dialog_->tabfolder,_("Extra"),
335 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets"),
337 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
338 lyxerr << _("Your version of libXpm is older than 4.7.\n"
339 "The `bullet' tab of the document dialog "
340 "has been disabled") << '\n';
341 fl_deactivate_object(fbullet);
342 fl_set_object_lcol(fbullet, FL_INACTIVE);
347 void FormDocument::apply()
349 if (!lv_->view()->available() || !dialog_.get())
352 bool redo = class_apply();
354 redo = language_apply() || redo;
355 redo = options_apply() || redo;
359 lv_->view()->redoCurrentBuffer();
361 lv_->buffer()->markDirty();
362 setMinibuffer(lv_, _("Document layout set"));
366 void FormDocument::cancel()
368 // this avoids confusion when reopening
369 BufferParams & param = lv_->buffer()->params;
370 param.temp_bullets[0] = param.user_defined_bullets[0];
371 param.temp_bullets[1] = param.user_defined_bullets[1];
372 param.temp_bullets[2] = param.user_defined_bullets[2];
373 param.temp_bullets[3] = param.user_defined_bullets[3];
378 void FormDocument::update()
385 BufferParams const & params = lv_->buffer()->params;
387 class_update(params);
388 paper_update(params);
389 language_update(params);
390 options_update(params);
391 bullets_update(params);
396 // should this go elsewhere? Maybe a ControllerDocument? (JMarc)
397 /** Save the buffer's parameters as user default.
398 This function saves a file \c user_lyxdir/templates/defaults.lyx
399 which parameters are those of the current buffer. This file
400 is used as a default template when creating a new
401 file. Returns \c true on success.
403 bool saveParamsAsDefault(BufferParams const ¶ms)
405 if (!Alert::askQuestion(_("Do you want to save the current settings"),
406 _("for the document layout as default?"),
407 _("(they will be valid for any new document)")))
410 string const fname = AddName(AddPath(user_lyxdir, "templates/"),
412 Buffer defaults = Buffer(fname);
413 defaults.params = params;
415 // add an empty paragraph. Is this enough?
416 defaults.paragraph = new Paragraph;
418 return defaults.writeFile(defaults.fileName(), false);
424 bool FormDocument::input(FL_OBJECT * ob, long data)
426 State cb = static_cast<State>(data);
429 case CHECKCHOICECLASS:
430 CheckChoiceClass(ob, 0);
432 case CHOICEBULLETSIZE:
433 ChoiceBulletSize(ob, 0);
435 case INPUTBULLETLATEX:
436 InputBulletLaTeX(ob, 0);
453 BulletBMTable(ob, 0);
459 bool const length_input = fl_get_choice(class_->choice_doc_skip) == 4;
460 if (ob == class_->choice_doc_skip) {
461 setEnabled(class_->input_doc_skip, length_input);
462 setEnabled(class_->choice_default_skip_units, length_input);
465 if (ob == class_->choice_doc_spacing)
466 setEnabled(class_->input_doc_spacing,
467 fl_get_choice(class_->choice_doc_spacing) == 4);
469 bool const skip_used = fl_get_button(class_->radio_doc_skip);
470 if (ob == class_->radio_doc_skip ||
471 ob == class_->radio_doc_indent) {
472 setEnabled(class_->choice_doc_skip, skip_used);
473 setEnabled(class_->input_doc_skip,
474 skip_used && length_input);
475 setEnabled(class_->choice_default_skip_units,
476 skip_used && length_input);
477 // Default unit choice is cm if metric, inches if US paper.
478 // If papersize is default, check the lyxrc-settings
479 int const paperchoice = fl_get_choice(paper_->choice_papersize);
480 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
481 || paperchoice == 2 || paperchoice > 5;
482 int const default_unit = metric ? 8 : 9;
483 if (strip(fl_get_input(class_->input_doc_skip)).empty())
484 fl_set_choice(class_->choice_default_skip_units,
488 if (ob == options_->check_use_natbib) {
489 setEnabled(options_->choice_citation_format,
490 fl_get_button(options_->check_use_natbib));
493 if (ob == dialog_->button_save_defaults) {
497 language_apply(params);
498 options_apply(params);
499 bullets_apply(params);
500 saveParamsAsDefault(params);
503 if (ob == dialog_->button_reset_defaults) {
504 BufferParams params = lv_->buffer()->params;
505 params.textclass = combo_doc_class->get() - 1;
506 params.useClassDefaults();
507 UpdateLayoutDocument(params);
510 if (ob == paper_->radio_landscape)
511 fl_set_choice(paper_->choice_paperpackage,
512 BufferParams::PACKAGE_NONE + 1);
514 if (ob == paper_->choice_papersize) {
515 int const paperchoice = fl_get_choice(paper_->choice_papersize);
516 bool const defsize = paperchoice == 1;
517 bool const custom = paperchoice == 2;
518 bool const a3size = paperchoice == 6;
519 bool const b3size = paperchoice == 9;
520 bool const b4size = paperchoice == 10;
523 fl_set_button(paper_->radio_portrait, 1);
525 bool const use_geom = (custom || a3size || b3size || b4size);
527 fl_set_button(paper_->check_use_geometry, int(use_geom));
529 setEnabled(paper_->input_top_margin, use_geom);
530 setEnabled(paper_->input_bottom_margin, use_geom);
531 setEnabled(paper_->input_inner_margin, use_geom);
532 setEnabled(paper_->input_outer_margin, use_geom);
533 setEnabled(paper_->input_head_height, use_geom);
534 setEnabled(paper_->input_head_sep, use_geom);
535 setEnabled(paper_->input_foot_skip, use_geom);
536 setEnabled(paper_->choice_top_margin_units, use_geom);
537 setEnabled(paper_->choice_bottom_margin_units, use_geom);
538 setEnabled(paper_->choice_inner_margin_units, use_geom);
539 setEnabled(paper_->choice_outer_margin_units, use_geom);
540 setEnabled(paper_->choice_head_height_units, use_geom);
541 setEnabled(paper_->choice_head_sep_units, use_geom);
542 setEnabled(paper_->choice_foot_skip_units, use_geom);
543 setEnabled(paper_->choice_custom_width_units, use_geom);
544 setEnabled(paper_->choice_custom_height_units, use_geom);
546 setEnabled(paper_->input_custom_width, custom);
547 setEnabled(paper_->input_custom_height, custom);
548 setEnabled(paper_->choice_custom_width_units, custom);
549 setEnabled(paper_->choice_custom_height_units, custom);
550 setEnabled(paper_->radio_portrait, !custom);
551 setEnabled(paper_->radio_landscape, !custom);
553 // Default unit choice is cm if metric, inches if US paper.
554 // If papersize is default, use the lyxrc-settings
555 bool const metric = (defsize && lyxrc.default_papersize > 3)
556 || paperchoice == 2 || paperchoice > 5;
557 int const default_unit = metric ? 8 : 9;
558 if (strip(fl_get_input(paper_->input_custom_width)).empty())
559 fl_set_choice(paper_->choice_custom_width_units,
561 if (strip(fl_get_input(paper_->input_custom_height)).empty())
562 fl_set_choice(paper_->choice_custom_height_units,
564 if (strip(fl_get_input(paper_->input_top_margin)).empty())
565 fl_set_choice(paper_->choice_top_margin_units,
567 if (strip(fl_get_input(paper_->input_bottom_margin)).empty())
568 fl_set_choice(paper_->choice_bottom_margin_units,
570 if (strip(fl_get_input(paper_->input_inner_margin)).empty())
571 fl_set_choice(paper_->choice_inner_margin_units,
573 if (strip(fl_get_input(paper_->input_outer_margin)).empty())
574 fl_set_choice(paper_->choice_outer_margin_units,
576 if (strip(fl_get_input(paper_->input_head_height)).empty())
577 fl_set_choice(paper_->choice_head_height_units,
579 if (strip(fl_get_input(paper_->input_head_sep)).empty())
580 fl_set_choice(paper_->choice_head_sep_units,
582 if (strip(fl_get_input(paper_->input_foot_skip)).empty())
583 fl_set_choice(paper_->choice_foot_skip_units,
587 if (ob == paper_->choice_papersize ||
588 ob == paper_->radio_portrait ||
589 ob == paper_->radio_landscape) {
591 setEnabled(paper_->choice_paperpackage,
592 //either default papersize (preferences)
593 //or document papersize has to be A4
594 (fl_get_choice(paper_->choice_papersize) == 7
595 || fl_get_choice(paper_->choice_papersize) == 1
596 && lyxrc.default_papersize == 5)
597 && fl_get_button(paper_->radio_portrait));
600 if (ob == paper_->choice_paperpackage) {
601 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
602 fl_set_button(paper_->check_use_geometry, 0);
604 setEnabled(paper_->input_top_margin, false);
605 setEnabled(paper_->input_bottom_margin, false);
606 setEnabled(paper_->input_inner_margin, false);
607 setEnabled(paper_->input_outer_margin, false);
608 setEnabled(paper_->input_head_height, false);
609 setEnabled(paper_->input_head_sep, false);
610 setEnabled(paper_->input_foot_skip, false);
611 setEnabled(paper_->choice_top_margin_units, false);
612 setEnabled(paper_->choice_bottom_margin_units, false);
613 setEnabled(paper_->choice_inner_margin_units, false);
614 setEnabled(paper_->choice_outer_margin_units, false);
615 setEnabled(paper_->choice_head_height_units, false);
616 setEnabled(paper_->choice_head_sep_units, false);
617 setEnabled(paper_->choice_foot_skip_units, false);
621 if (ob == paper_->check_use_geometry) {
622 //don't allow switching geometry off in custom papersize mode
623 //nor in A3, B3, and B4
624 int const choice = fl_get_choice(paper_->choice_papersize);
625 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
626 fl_set_button(paper_->check_use_geometry, 1);
628 fl_set_choice(paper_->choice_paperpackage,
629 BufferParams::PACKAGE_NONE + 1);
631 bool const use_geom = fl_get_button(paper_->check_use_geometry);
632 setEnabled(paper_->input_top_margin, use_geom);
633 setEnabled(paper_->input_bottom_margin, use_geom);
634 setEnabled(paper_->input_inner_margin, use_geom);
635 setEnabled(paper_->input_outer_margin, use_geom);
636 setEnabled(paper_->input_head_height, use_geom);
637 setEnabled(paper_->input_head_sep, use_geom);
638 setEnabled(paper_->input_foot_skip, use_geom);
639 setEnabled(paper_->choice_top_margin_units, use_geom);
640 setEnabled(paper_->choice_bottom_margin_units, use_geom);
641 setEnabled(paper_->choice_inner_margin_units, use_geom);
642 setEnabled(paper_->choice_outer_margin_units, use_geom);
643 setEnabled(paper_->choice_head_height_units, use_geom);
644 setEnabled(paper_->choice_head_sep_units, use_geom);
645 setEnabled(paper_->choice_foot_skip_units, use_geom);
650 case CHECKCHOICECLASS:
651 case CHOICEBULLETSIZE:
652 case INPUTBULLETLATEX:
654 return CheckDocumentInput(ob, 0);
663 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
665 FormDocument * pre = static_cast<FormDocument*>(v);
666 if (combox == pre->combo_doc_class.get())
667 pre->CheckChoiceClass(0, 0);
668 pre->bc().valid(pre->CheckDocumentInput(0,0));
672 bool FormDocument::class_apply(BufferParams ¶ms)
676 // If default skip is a "Length" but there's no text in the
677 // input field, reset the kind to "Medskip", which is the default.
678 if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
679 !*(fl_get_input (class_->input_doc_skip))) {
680 fl_set_choice (class_->choice_doc_skip, 2);
682 params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
683 params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
684 params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
686 params.textclass = combo_doc_class->get() - 1;
688 BufferParams::PARSEP tmpsep = params.paragraph_separation;
689 if (fl_get_button(class_->radio_doc_indent))
690 params.paragraph_separation = BufferParams::PARSEP_INDENT;
692 params.paragraph_separation = BufferParams::PARSEP_SKIP;
693 if (tmpsep != params.paragraph_separation)
696 VSpace tmpdefskip = params.getDefSkip();
697 switch (fl_get_choice (class_->choice_doc_skip)) {
699 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
702 params.setDefSkip(VSpace(VSpace::MEDSKIP));
705 params.setDefSkip(VSpace(VSpace::BIGSKIP));
709 string const length =
710 getLengthFromWidgets(class_->input_doc_skip,
711 class_->choice_default_skip_units);
713 params.setDefSkip(VSpace(LyXGlueLength(length)));
717 // DocumentDefskipCB assures that this never happens
718 params.setDefSkip(VSpace(VSpace::MEDSKIP));
721 if (!(tmpdefskip == params.getDefSkip()))
724 if (fl_get_button(class_->radio_doc_columns_two))
728 if (fl_get_button(class_->radio_doc_sides_two))
729 params.sides = LyXTextClass::TwoSides;
731 params.sides = LyXTextClass::OneSide;
733 Spacing tmpSpacing = params.spacing;
734 switch (fl_get_choice(class_->choice_doc_spacing)) {
736 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
737 params.spacing.set(Spacing::Single);
740 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
741 params.spacing.set(Spacing::Onehalf);
744 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
745 params.spacing.set(Spacing::Double);
748 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
749 params.spacing.set(Spacing::Other,
750 fl_get_input(class_->input_doc_spacing));
753 if (tmpSpacing != params.spacing)
756 params.options = fl_get_input(class_->input_doc_extra);
762 bool FormDocument::class_apply()
764 BufferParams ¶ms = lv_->buffer()->params;
766 unsigned int const old_class = params.textclass;
768 bool redo = class_apply(params);
770 if (params.textclass != old_class) {
771 // try to load new_class
772 if (textclasslist[params.textclass].load()) {
773 // successfully loaded
775 setMinibuffer(lv_, _("Converting document to new document class..."));
776 int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
777 old_class, params.textclass,
778 lv_->buffer()->paragraph,
779 lv_->buffer()->params);
783 s = _("One paragraph couldn't be converted");
786 s += _(" paragraphs couldn't be converted");
788 Alert::alert(_("Conversion Errors!"),s,
789 _("into chosen document class"));
793 // problem changing class -- warn user and retain old style
794 Alert::alert(_("Conversion Errors!"),
795 _("Errors loading new document class."),
796 _("Reverting to original document class."));
797 combo_doc_class->select(int(old_class) + 1);
805 void FormDocument::paper_apply(BufferParams & params)
807 params.papersize2 = char(fl_get_choice(paper_->choice_papersize)-1);
809 params.paperpackage =
810 char(fl_get_choice(paper_->choice_paperpackage)-1);
812 // set params.papersize from params.papersize2 and params.paperpackage
813 params.setPaperStuff();
815 params.use_geometry = fl_get_button(paper_->check_use_geometry);
817 if (fl_get_button(paper_->radio_landscape))
818 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
820 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
823 getLengthFromWidgets(paper_->input_custom_width,
824 paper_->choice_custom_width_units);
827 getLengthFromWidgets(paper_->input_custom_height,
828 paper_->choice_custom_height_units);
831 getLengthFromWidgets(paper_->input_inner_margin,
832 paper_->choice_inner_margin_units);
835 getLengthFromWidgets(paper_->input_top_margin,
836 paper_->choice_top_margin_units);
839 getLengthFromWidgets(paper_->input_outer_margin,
840 paper_->choice_outer_margin_units);
842 params.bottommargin =
843 getLengthFromWidgets(paper_->input_bottom_margin,
844 paper_->choice_bottom_margin_units);
847 getLengthFromWidgets(paper_->input_head_height,
848 paper_->choice_head_height_units);
851 getLengthFromWidgets(paper_->input_head_sep,
852 paper_->choice_head_sep_units);
855 getLengthFromWidgets(paper_->input_foot_skip,
856 paper_->choice_foot_skip_units);
860 void FormDocument::paper_apply()
862 paper_apply(lv_->buffer()->params);
866 bool FormDocument::language_apply(BufferParams & params)
868 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
871 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
873 lga = InsetQuotes::EnglishQ;
876 lga = InsetQuotes::SwedishQ;
879 lga = InsetQuotes::GermanQ;
882 lga = InsetQuotes::PolishQ;
885 lga = InsetQuotes::FrenchQ;
888 lga = InsetQuotes::DanishQ;
891 params.quotes_language = lga;
892 if (fl_get_button(language_->radio_single))
893 params.quotes_times = InsetQuotes::SingleQ;
895 params.quotes_times = InsetQuotes::DoubleQ;
897 int const pos = combo_language->get();
898 Language const * old_language = params.language;
899 Language const * new_language = languages.getLanguage(lang_[pos-1]);
901 new_language = default_language;
903 if (old_language != new_language
904 && old_language->RightToLeft() == new_language->RightToLeft()
905 && !lv_->buffer()->isMultiLingual())
906 lv_->buffer()->changeLanguage(old_language, new_language);
908 if (old_language != new_language) {
912 params.language = new_language;
913 params.inputenc = fl_get_choice_text(language_->choice_inputenc);
919 bool FormDocument::language_apply()
921 return language_apply(lv_->buffer()->params);
925 bool FormDocument::options_apply(BufferParams & params)
929 params.graphicsDriver =
930 fl_get_choice_text(options_->choice_postscript_driver);
931 params.use_amsmath = fl_get_button(options_->check_use_amsmath);
932 params.use_natbib = fl_get_button(options_->check_use_natbib);
933 params.use_numerical_citations =
934 fl_get_choice(options_->choice_citation_format)-1;
936 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
937 if (params.secnumdepth != tmpchar)
939 params.secnumdepth = tmpchar;
941 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
943 params.float_placement =
944 fl_get_input(options_->input_float_placement);
950 bool FormDocument::options_apply()
952 return options_apply(lv_->buffer()->params);
956 void FormDocument::bullets_apply(BufferParams & params)
958 /* update the bullet settings */
959 BufferParams & buf_params = lv_->buffer()->params;
961 // a little bit of loop unrolling
962 params.user_defined_bullets[0] = buf_params.temp_bullets[0];
963 params.user_defined_bullets[1] = buf_params.temp_bullets[1];
964 params.user_defined_bullets[2] = buf_params.temp_bullets[2];
965 params.user_defined_bullets[3] = buf_params.temp_bullets[3];
969 void FormDocument::bullets_apply()
971 bullets_apply(lv_->buffer()->params);
974 void FormDocument::UpdateClassParams(BufferParams const & params)
976 // These are the params that have to be updated on any class change
977 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
979 LyXTextClass const & tclass = textclasslist[params.textclass];
981 combo_doc_class->select(tclass.description());
982 fl_clear_choice(class_->choice_doc_fontsize);
983 fl_addto_choice(class_->choice_doc_fontsize, "default");
984 fl_addto_choice(class_->choice_doc_fontsize,
985 tclass.opt_fontsize().c_str());
986 fl_set_choice_text(class_->choice_doc_fontsize,
987 params.fontsize.c_str());
988 fl_clear_choice(class_->choice_doc_pagestyle);
989 fl_addto_choice(class_->choice_doc_pagestyle, "default");
990 fl_addto_choice(class_->choice_doc_pagestyle,
991 tclass.opt_pagestyle().c_str());
992 fl_set_choice_text(class_->choice_doc_pagestyle,
993 params.pagestyle.c_str());
997 void FormDocument::class_update(BufferParams const & params)
1002 UpdateClassParams(params);
1004 fl_set_choice_text(class_->choice_doc_fonts,
1005 params.fonts.c_str());
1006 fl_set_button(class_->radio_doc_indent, 0);
1007 fl_set_button(class_->radio_doc_skip, 0);
1008 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
1009 fl_set_button(class_->radio_doc_indent, 1);
1011 fl_set_button(class_->radio_doc_skip, 1);
1013 bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
1014 setEnabled(class_->choice_default_skip_units, input_length);
1015 setEnabled(class_->input_doc_skip, input_length);
1017 switch (params.getDefSkip().kind()) {
1018 case VSpace::SMALLSKIP:
1019 fl_set_choice (class_->choice_doc_skip, 1);
1021 case VSpace::MEDSKIP:
1022 fl_set_choice (class_->choice_doc_skip, 2);
1024 case VSpace::BIGSKIP:
1025 fl_set_choice (class_->choice_doc_skip, 3);
1027 case VSpace::LENGTH:
1029 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1030 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1031 || paperchoice == 2 || paperchoice > 5;
1032 string const default_unit = metric ? "cm" : "in";
1033 string const length = params.getDefSkip().asLyXCommand();
1034 updateWidgetsFromLengthString(class_->input_doc_skip,
1035 class_->choice_default_skip_units,
1036 length, default_unit);
1040 fl_set_choice (class_->choice_doc_skip, 2);
1043 fl_set_button(class_->radio_doc_sides_one, 0);
1044 fl_set_button(class_->radio_doc_sides_two, 0);
1045 setEnabled(class_->choice_doc_skip,
1046 fl_get_button(class_->radio_doc_skip));
1048 if (params.sides == LyXTextClass::TwoSides)
1049 fl_set_button(class_->radio_doc_sides_two, 1);
1051 fl_set_button(class_->radio_doc_sides_one, 1);
1052 fl_set_button(class_->radio_doc_columns_one, 0);
1053 fl_set_button(class_->radio_doc_columns_two, 0);
1054 if (params.columns == 2)
1055 fl_set_button(class_->radio_doc_columns_two, 1);
1057 fl_set_button(class_->radio_doc_columns_one, 1);
1059 fl_set_input(class_->input_doc_spacing, "");
1060 setEnabled(class_->input_doc_spacing, false);
1062 switch (params.spacing.getSpace()) {
1063 case Spacing::Default: // nothing bad should happen with this
1064 case Spacing::Single:
1066 fl_set_choice(class_->choice_doc_spacing, 1);
1068 case Spacing::Onehalf:
1070 fl_set_choice(class_->choice_doc_spacing, 2);
1072 case Spacing::Double:
1074 fl_set_choice(class_->choice_doc_spacing, 3);
1076 case Spacing::Other:
1078 fl_set_choice(class_->choice_doc_spacing, 4);
1080 sprintf(sval,"%g",params.spacing.getValue());
1081 fl_set_input(class_->input_doc_spacing, sval);
1082 setEnabled(class_->input_doc_spacing, true);
1086 if (!params.options.empty())
1087 fl_set_input(class_->input_doc_extra, params.options.c_str());
1089 fl_set_input(class_->input_doc_extra, "");
1093 void FormDocument::language_update(BufferParams const & params)
1095 if (!language_.get())
1098 int const pos = int(findPos(lang_, params.language->lang()));
1099 combo_language->select(pos+1);
1101 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1102 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1103 fl_set_button(language_->radio_single, 0);
1104 fl_set_button(language_->radio_double, 0);
1105 if (params.quotes_times == InsetQuotes::SingleQ)
1106 fl_set_button(language_->radio_single, 1);
1108 fl_set_button(language_->radio_double, 1);
1112 void FormDocument::options_update(BufferParams const & params)
1114 if (!options_.get())
1117 fl_set_choice_text(options_->choice_postscript_driver,
1118 params.graphicsDriver.c_str());
1119 fl_set_button(options_->check_use_amsmath, params.use_amsmath);
1120 fl_set_button(options_->check_use_natbib, params.use_natbib);
1121 fl_set_choice(options_->choice_citation_format,
1122 int(params.use_numerical_citations)+1);
1123 setEnabled(options_->choice_citation_format, params.use_natbib);
1124 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1125 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1126 if (!params.float_placement.empty())
1127 fl_set_input(options_->input_float_placement,
1128 params.float_placement.c_str());
1130 fl_set_input(options_->input_float_placement, "");
1134 void FormDocument::paper_update(BufferParams const & params)
1139 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1140 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1141 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1143 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1144 bool const useCustom = paperchoice == 2;
1145 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1147 fl_set_button(paper_->radio_portrait, 0);
1148 setEnabled(paper_->radio_portrait, !useCustom);
1149 fl_set_button(paper_->radio_landscape, 0);
1150 setEnabled(paper_->radio_landscape, !useCustom);
1152 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
1153 fl_set_button(paper_->radio_landscape, 1);
1155 fl_set_button(paper_->radio_portrait, 1);
1156 setEnabled(paper_->choice_paperpackage,
1157 //either default papersize (preferences)
1158 //or document papersize has to be A4
1160 || paperchoice == 1 && lyxrc.default_papersize == 5)
1161 && fl_get_button(paper_->radio_portrait));
1163 // Default unit choice is cm if metric, inches if US paper.
1164 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1165 || paperchoice == 2 || paperchoice > 5;
1166 string const default_unit = metric ? "cm" : "in";
1167 updateWidgetsFromLengthString(paper_->input_custom_width,
1168 paper_->choice_custom_width_units,
1169 params.paperwidth, default_unit);
1170 setEnabled(paper_->input_custom_width, useCustom);
1171 setEnabled(paper_->choice_custom_width_units, useCustom);
1173 updateWidgetsFromLengthString(paper_->input_custom_height,
1174 paper_->choice_custom_height_units,
1175 params.paperheight, default_unit);
1176 setEnabled(paper_->input_custom_height, useCustom);
1177 setEnabled(paper_->choice_custom_height_units, useCustom);
1179 updateWidgetsFromLengthString(paper_->input_inner_margin,
1180 paper_->choice_inner_margin_units,
1181 params.leftmargin, default_unit);
1182 setEnabled(paper_->input_inner_margin, useGeom);
1183 setEnabled(paper_->choice_inner_margin_units, useGeom);
1185 updateWidgetsFromLengthString(paper_->input_top_margin,
1186 paper_->choice_top_margin_units,
1187 params.topmargin, default_unit);
1188 setEnabled(paper_->input_top_margin, useGeom);
1189 setEnabled(paper_->choice_top_margin_units, useGeom);
1191 updateWidgetsFromLengthString(paper_->input_outer_margin,
1192 paper_->choice_outer_margin_units,
1193 params.rightmargin, default_unit);
1194 setEnabled(paper_->input_outer_margin, useGeom);
1195 setEnabled(paper_->choice_outer_margin_units, useGeom);
1197 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1198 paper_->choice_bottom_margin_units,
1199 params.bottommargin, default_unit);
1200 setEnabled(paper_->input_bottom_margin, useGeom);
1201 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1203 updateWidgetsFromLengthString(paper_->input_head_height,
1204 paper_->choice_head_height_units,
1205 params.headheight, default_unit);
1206 setEnabled(paper_->input_head_height, useGeom);
1207 setEnabled(paper_->choice_head_height_units, useGeom);
1209 updateWidgetsFromLengthString(paper_->input_head_sep,
1210 paper_->choice_head_sep_units,
1211 params.headsep, default_unit);
1212 setEnabled(paper_->input_head_sep, useGeom);
1213 setEnabled(paper_->choice_head_sep_units, useGeom);
1215 updateWidgetsFromLengthString(paper_->input_foot_skip,
1216 paper_->choice_foot_skip_units,
1217 params.footskip, default_unit);
1218 setEnabled(paper_->input_foot_skip, useGeom);
1219 setEnabled(paper_->choice_foot_skip_units, useGeom);
1221 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1225 void FormDocument::bullets_update(BufferParams const & params)
1227 if (!bullets_.get() ||
1229 (XpmVersion==4 && XpmRevision<7)))
1232 bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
1233 setEnabled(fbullet, !isLinuxDoc);
1235 if (isLinuxDoc) return;
1237 fl_set_button(bullets_->radio_bullet_depth_1, 1);
1238 fl_set_input(bullets_->input_bullet_latex,
1239 params.user_defined_bullets[0].getText().c_str());
1240 fl_set_choice(bullets_->choice_bullet_size,
1241 params.user_defined_bullets[0].getSize() + 2);
1245 void FormDocument::checkReadOnly()
1247 if (bc().readOnly(lv_->buffer()->isReadonly())) {
1248 combo_doc_class->deactivate();
1249 combo_language->deactivate();
1250 postWarning(_("Document is read-only."
1251 " No changes to layout permitted."));
1253 combo_doc_class->activate();
1254 combo_language->activate();
1260 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
1266 // this has to be all out of if/elseif because it has to deactivate
1267 // the document buttons and so the whole stuff has to be tested again.
1268 // disable OK/Apply if input is not valid
1269 str = fl_get_input(class_->input_doc_skip);
1270 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1271 str = fl_get_input(paper_->input_custom_width);
1272 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1273 str = fl_get_input(paper_->input_custom_height);
1274 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1275 str = fl_get_input(paper_->input_outer_margin);
1276 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1277 str = fl_get_input(paper_->input_inner_margin);
1278 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1279 str = fl_get_input(paper_->input_top_margin);
1280 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1281 str = fl_get_input(paper_->input_bottom_margin);
1282 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1283 str = fl_get_input(paper_->input_head_height);
1284 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1285 str = fl_get_input(paper_->input_head_sep);
1286 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1287 str = fl_get_input(paper_->input_foot_skip);
1288 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1290 //display warning if input is not valid
1291 if (ob == class_->input_doc_skip
1292 || ob == paper_->input_custom_width
1293 || ob == paper_->input_custom_height
1294 || ob == paper_->input_outer_margin
1295 || ob == paper_->input_inner_margin
1296 || ob == paper_->input_top_margin
1297 || ob == paper_->input_bottom_margin
1298 || ob == paper_->input_head_height
1299 || ob == paper_->input_head_sep
1300 || ob == paper_->input_foot_skip) {
1302 postWarning(_("Invalid Length (valid example: 10mm)"));
1310 // "Synchronize" the choice and the input field, so that it
1311 // is impossible to commit senseless data.
1312 input = fl_get_input (class_->input_doc_skip);
1313 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1315 else if (fl_get_choice(class_->choice_doc_skip) != 4)
1316 fl_set_input (class_->input_doc_skip, "");
1318 input = fl_get_input(class_->input_doc_spacing);
1319 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1321 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
1322 fl_set_input (class_->input_doc_spacing, "");
1327 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1329 BufferParams & param = lv_->buffer()->params;
1331 // convert from 1-6 range to -1-4
1332 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1333 fl_set_input(bullets_->input_bullet_latex,
1334 param.temp_bullets[current_bullet_depth].getText().c_str());
1338 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1340 BufferParams & param = lv_->buffer()->params;
1342 param.temp_bullets[current_bullet_depth].
1343 setText(fl_get_input(bullets_->input_bullet_latex));
1347 void FormDocument::BulletDepth(FL_OBJECT * ob, State cb)
1349 /* Should I do the following: */
1350 /* 1. change to the panel that the current bullet belongs in */
1351 /* 2. show that bullet as selected */
1352 /* 3. change the size setting to the size of the bullet in Q.*/
1353 /* 4. display the latex equivalent in the latex box */
1355 /* I'm inclined to just go with 3 and 4 at the moment and */
1356 /* maybe try to support the others later */
1357 BufferParams & param = lv_->buffer()->params;
1360 if (cb == BULLETDEPTH1)
1362 else if (cb == BULLETDEPTH2)
1364 else if (cb == BULLETDEPTH3)
1366 else if (cb == BULLETDEPTH4)
1369 switch (fl_get_button_numb(ob)) {
1371 // right mouse button resets to default
1372 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1374 current_bullet_depth = data;
1375 fl_set_input(bullets_->input_bullet_latex,
1376 param.temp_bullets[data].getText().c_str());
1377 fl_set_choice(bullets_->choice_bullet_size,
1378 param.temp_bullets[data].getSize() + 2);
1383 void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, State cb)
1385 /* Here we have to change the background pixmap to that selected */
1386 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1389 if (cb == BULLETPANEL1)
1391 else if (cb == BULLETPANEL2)
1393 else if (cb == BULLETPANEL3)
1395 else if (cb == BULLETPANEL4)
1397 else if (cb == BULLETPANEL5)
1399 else if (cb == BULLETPANEL6)
1402 if (data != current_bullet_panel) {
1403 fl_freeze_form(bullets_->form);
1404 current_bullet_panel = data;
1406 /* free the current pixmap */
1407 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1410 /* display the new one */
1412 new_panel = "standard";
1415 new_panel = "amssymb";
1418 new_panel = "psnfss1";
1421 new_panel = "psnfss2";
1424 new_panel = "psnfss3";
1427 new_panel = "psnfss4";
1430 /* something very wrong happened */
1431 // play it safe for now but should be an exception
1432 current_bullet_panel = 0; // standard panel
1433 new_panel = "standard";
1436 new_panel += ".xpm";
1437 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1438 LibFileSearch("images", new_panel).c_str());
1439 fl_redraw_object(bullets_->bmtable_bullet_panel);
1440 fl_unfreeze_form(bullets_->form);
1445 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1447 /* handle the user input by setting the current bullet depth's pixmap */
1448 /* to that extracted from the current chosen position of the BMTable */
1449 /* Don't forget to free the button's old pixmap first. */
1451 BufferParams & param = lv_->buffer()->params;
1452 int bmtable_button = fl_get_bmtable(ob);
1454 /* try to keep the button held down till another is pushed */
1455 /* fl_set_bmtable(ob, 1, bmtable_button); */
1456 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1457 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1458 fl_set_input(bullets_->input_bullet_latex,
1459 param.temp_bullets[current_bullet_depth].getText().c_str());
1463 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1466 ob = class_->choice_doc_class;
1468 lv_->prohibitInput();
1470 unsigned int tc = combo_doc_class->get() - 1;
1471 if (textclasslist[tc].load()) {
1472 // we use a copy of the bufferparams because we do not
1473 // want to modify them yet.
1474 BufferParams params = lv_->buffer()->params;
1476 if (lyxrc.auto_reset_options) {
1477 params.textclass = tc;
1478 params.useClassDefaults();
1479 UpdateLayoutDocument(params);
1481 // update the params which are needed in any case
1482 // (fontsizes, pagestyle)
1483 params.textclass = tc;
1484 UpdateClassParams(params);
1488 // unable to load new style
1489 Alert::alert(_("Conversion Errors!"),
1490 _("Unable to switch to new document class."),
1491 _("Reverting to original document class."));
1492 combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
1498 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1504 class_update(params);
1505 paper_update(params);
1506 language_update(params);
1507 options_update(params);
1508 bullets_update(params);