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"
30 #include "frontends/LyXView.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 params.preamble = lv_->buffer()->params.preamble;
501 saveParamsAsDefault(params);
504 if (ob == dialog_->button_reset_defaults) {
505 BufferParams params = lv_->buffer()->params;
506 params.textclass = combo_doc_class->get() - 1;
507 params.useClassDefaults();
508 UpdateLayoutDocument(params);
511 if (ob == paper_->radio_landscape)
512 fl_set_choice(paper_->choice_paperpackage,
513 BufferParams::PACKAGE_NONE + 1);
515 if (ob == paper_->choice_papersize) {
516 int const paperchoice = fl_get_choice(paper_->choice_papersize);
517 bool const defsize = paperchoice == 1;
518 bool const custom = paperchoice == 2;
519 bool const a3size = paperchoice == 6;
520 bool const b3size = paperchoice == 9;
521 bool const b4size = paperchoice == 10;
524 fl_set_button(paper_->radio_portrait, 1);
526 bool const use_geom = (custom || a3size || b3size || b4size);
528 fl_set_button(paper_->check_use_geometry, int(use_geom));
530 setEnabled(paper_->input_top_margin, use_geom);
531 setEnabled(paper_->input_bottom_margin, use_geom);
532 setEnabled(paper_->input_inner_margin, use_geom);
533 setEnabled(paper_->input_outer_margin, use_geom);
534 setEnabled(paper_->input_head_height, use_geom);
535 setEnabled(paper_->input_head_sep, use_geom);
536 setEnabled(paper_->input_foot_skip, use_geom);
537 setEnabled(paper_->choice_top_margin_units, use_geom);
538 setEnabled(paper_->choice_bottom_margin_units, use_geom);
539 setEnabled(paper_->choice_inner_margin_units, use_geom);
540 setEnabled(paper_->choice_outer_margin_units, use_geom);
541 setEnabled(paper_->choice_head_height_units, use_geom);
542 setEnabled(paper_->choice_head_sep_units, use_geom);
543 setEnabled(paper_->choice_foot_skip_units, use_geom);
544 setEnabled(paper_->choice_custom_width_units, use_geom);
545 setEnabled(paper_->choice_custom_height_units, use_geom);
547 setEnabled(paper_->input_custom_width, custom);
548 setEnabled(paper_->input_custom_height, custom);
549 setEnabled(paper_->choice_custom_width_units, custom);
550 setEnabled(paper_->choice_custom_height_units, custom);
551 setEnabled(paper_->radio_portrait, !custom);
552 setEnabled(paper_->radio_landscape, !custom);
554 // Default unit choice is cm if metric, inches if US paper.
555 // If papersize is default, use the lyxrc-settings
556 bool const metric = (defsize && lyxrc.default_papersize > 3)
557 || paperchoice == 2 || paperchoice > 5;
558 int const default_unit = metric ? 8 : 9;
559 if (strip(fl_get_input(paper_->input_custom_width)).empty())
560 fl_set_choice(paper_->choice_custom_width_units,
562 if (strip(fl_get_input(paper_->input_custom_height)).empty())
563 fl_set_choice(paper_->choice_custom_height_units,
565 if (strip(fl_get_input(paper_->input_top_margin)).empty())
566 fl_set_choice(paper_->choice_top_margin_units,
568 if (strip(fl_get_input(paper_->input_bottom_margin)).empty())
569 fl_set_choice(paper_->choice_bottom_margin_units,
571 if (strip(fl_get_input(paper_->input_inner_margin)).empty())
572 fl_set_choice(paper_->choice_inner_margin_units,
574 if (strip(fl_get_input(paper_->input_outer_margin)).empty())
575 fl_set_choice(paper_->choice_outer_margin_units,
577 if (strip(fl_get_input(paper_->input_head_height)).empty())
578 fl_set_choice(paper_->choice_head_height_units,
580 if (strip(fl_get_input(paper_->input_head_sep)).empty())
581 fl_set_choice(paper_->choice_head_sep_units,
583 if (strip(fl_get_input(paper_->input_foot_skip)).empty())
584 fl_set_choice(paper_->choice_foot_skip_units,
588 if (ob == paper_->choice_papersize ||
589 ob == paper_->radio_portrait ||
590 ob == paper_->radio_landscape) {
592 setEnabled(paper_->choice_paperpackage,
593 //either default papersize (preferences)
594 //or document papersize has to be A4
595 (fl_get_choice(paper_->choice_papersize) == 7
596 || fl_get_choice(paper_->choice_papersize) == 1
597 && lyxrc.default_papersize == 5)
598 && fl_get_button(paper_->radio_portrait));
601 if (ob == paper_->choice_paperpackage) {
602 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
603 fl_set_button(paper_->check_use_geometry, 0);
605 setEnabled(paper_->input_top_margin, false);
606 setEnabled(paper_->input_bottom_margin, false);
607 setEnabled(paper_->input_inner_margin, false);
608 setEnabled(paper_->input_outer_margin, false);
609 setEnabled(paper_->input_head_height, false);
610 setEnabled(paper_->input_head_sep, false);
611 setEnabled(paper_->input_foot_skip, false);
612 setEnabled(paper_->choice_top_margin_units, false);
613 setEnabled(paper_->choice_bottom_margin_units, false);
614 setEnabled(paper_->choice_inner_margin_units, false);
615 setEnabled(paper_->choice_outer_margin_units, false);
616 setEnabled(paper_->choice_head_height_units, false);
617 setEnabled(paper_->choice_head_sep_units, false);
618 setEnabled(paper_->choice_foot_skip_units, false);
622 if (ob == paper_->check_use_geometry) {
623 //don't allow switching geometry off in custom papersize mode
624 //nor in A3, B3, and B4
625 int const choice = fl_get_choice(paper_->choice_papersize);
626 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
627 fl_set_button(paper_->check_use_geometry, 1);
629 fl_set_choice(paper_->choice_paperpackage,
630 BufferParams::PACKAGE_NONE + 1);
632 bool const use_geom = fl_get_button(paper_->check_use_geometry);
633 setEnabled(paper_->input_top_margin, use_geom);
634 setEnabled(paper_->input_bottom_margin, use_geom);
635 setEnabled(paper_->input_inner_margin, use_geom);
636 setEnabled(paper_->input_outer_margin, use_geom);
637 setEnabled(paper_->input_head_height, use_geom);
638 setEnabled(paper_->input_head_sep, use_geom);
639 setEnabled(paper_->input_foot_skip, use_geom);
640 setEnabled(paper_->choice_top_margin_units, use_geom);
641 setEnabled(paper_->choice_bottom_margin_units, use_geom);
642 setEnabled(paper_->choice_inner_margin_units, use_geom);
643 setEnabled(paper_->choice_outer_margin_units, use_geom);
644 setEnabled(paper_->choice_head_height_units, use_geom);
645 setEnabled(paper_->choice_head_sep_units, use_geom);
646 setEnabled(paper_->choice_foot_skip_units, use_geom);
651 case CHECKCHOICECLASS:
652 case CHOICEBULLETSIZE:
653 case INPUTBULLETLATEX:
655 return CheckDocumentInput(ob, 0);
664 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
666 FormDocument * pre = static_cast<FormDocument*>(v);
667 if (combox == pre->combo_doc_class.get())
668 pre->CheckChoiceClass(0, 0);
669 pre->bc().valid(pre->CheckDocumentInput(0,0));
673 bool FormDocument::class_apply(BufferParams ¶ms)
677 // If default skip is a "Length" but there's no text in the
678 // input field, reset the kind to "Medskip", which is the default.
679 if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
680 !*(fl_get_input (class_->input_doc_skip))) {
681 fl_set_choice (class_->choice_doc_skip, 2);
683 params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
684 params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
685 params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
687 params.textclass = combo_doc_class->get() - 1;
689 BufferParams::PARSEP tmpsep = params.paragraph_separation;
690 if (fl_get_button(class_->radio_doc_indent))
691 params.paragraph_separation = BufferParams::PARSEP_INDENT;
693 params.paragraph_separation = BufferParams::PARSEP_SKIP;
694 if (tmpsep != params.paragraph_separation)
697 VSpace tmpdefskip = params.getDefSkip();
698 switch (fl_get_choice (class_->choice_doc_skip)) {
700 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
703 params.setDefSkip(VSpace(VSpace::MEDSKIP));
706 params.setDefSkip(VSpace(VSpace::BIGSKIP));
710 string const length =
711 getLengthFromWidgets(class_->input_doc_skip,
712 class_->choice_default_skip_units);
714 params.setDefSkip(VSpace(LyXGlueLength(length)));
718 // DocumentDefskipCB assures that this never happens
719 params.setDefSkip(VSpace(VSpace::MEDSKIP));
722 if (!(tmpdefskip == params.getDefSkip()))
725 if (fl_get_button(class_->radio_doc_columns_two))
729 if (fl_get_button(class_->radio_doc_sides_two))
730 params.sides = LyXTextClass::TwoSides;
732 params.sides = LyXTextClass::OneSide;
734 Spacing tmpSpacing = params.spacing;
735 switch (fl_get_choice(class_->choice_doc_spacing)) {
737 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
738 params.spacing.set(Spacing::Single);
741 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
742 params.spacing.set(Spacing::Onehalf);
745 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
746 params.spacing.set(Spacing::Double);
749 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
750 params.spacing.set(Spacing::Other,
751 fl_get_input(class_->input_doc_spacing));
754 if (tmpSpacing != params.spacing)
757 params.options = fl_get_input(class_->input_doc_extra);
763 bool FormDocument::class_apply()
765 BufferParams ¶ms = lv_->buffer()->params;
767 unsigned int const old_class = params.textclass;
769 bool redo = class_apply(params);
771 if (params.textclass != old_class) {
772 // try to load new_class
773 if (textclasslist[params.textclass].load()) {
774 // successfully loaded
776 setMinibuffer(lv_, _("Converting document to new document class..."));
777 int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
778 old_class, params.textclass,
779 lv_->buffer()->paragraph,
780 lv_->buffer()->params);
784 s = _("One paragraph couldn't be converted");
787 s += _(" paragraphs couldn't be converted");
789 Alert::alert(_("Conversion Errors!"),s,
790 _("into chosen document class"));
794 // problem changing class -- warn user and retain old style
795 Alert::alert(_("Conversion Errors!"),
796 _("Errors loading new document class."),
797 _("Reverting to original document class."));
798 combo_doc_class->select(int(old_class) + 1);
806 void FormDocument::paper_apply(BufferParams & params)
808 params.papersize2 = char(fl_get_choice(paper_->choice_papersize)-1);
810 params.paperpackage =
811 char(fl_get_choice(paper_->choice_paperpackage)-1);
813 // set params.papersize from params.papersize2 and params.paperpackage
814 params.setPaperStuff();
816 params.use_geometry = fl_get_button(paper_->check_use_geometry);
818 if (fl_get_button(paper_->radio_landscape))
819 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
821 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
824 getLengthFromWidgets(paper_->input_custom_width,
825 paper_->choice_custom_width_units);
828 getLengthFromWidgets(paper_->input_custom_height,
829 paper_->choice_custom_height_units);
832 getLengthFromWidgets(paper_->input_inner_margin,
833 paper_->choice_inner_margin_units);
836 getLengthFromWidgets(paper_->input_top_margin,
837 paper_->choice_top_margin_units);
840 getLengthFromWidgets(paper_->input_outer_margin,
841 paper_->choice_outer_margin_units);
843 params.bottommargin =
844 getLengthFromWidgets(paper_->input_bottom_margin,
845 paper_->choice_bottom_margin_units);
848 getLengthFromWidgets(paper_->input_head_height,
849 paper_->choice_head_height_units);
852 getLengthFromWidgets(paper_->input_head_sep,
853 paper_->choice_head_sep_units);
856 getLengthFromWidgets(paper_->input_foot_skip,
857 paper_->choice_foot_skip_units);
861 void FormDocument::paper_apply()
863 paper_apply(lv_->buffer()->params);
867 bool FormDocument::language_apply(BufferParams & params)
869 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
872 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
874 lga = InsetQuotes::EnglishQ;
877 lga = InsetQuotes::SwedishQ;
880 lga = InsetQuotes::GermanQ;
883 lga = InsetQuotes::PolishQ;
886 lga = InsetQuotes::FrenchQ;
889 lga = InsetQuotes::DanishQ;
892 params.quotes_language = lga;
893 if (fl_get_button(language_->radio_single))
894 params.quotes_times = InsetQuotes::SingleQ;
896 params.quotes_times = InsetQuotes::DoubleQ;
898 int const pos = combo_language->get();
899 Language const * old_language = params.language;
900 Language const * new_language = languages.getLanguage(lang_[pos-1]);
902 new_language = default_language;
904 if (old_language != new_language
905 && old_language->RightToLeft() == new_language->RightToLeft()
906 && !lv_->buffer()->isMultiLingual())
907 lv_->buffer()->changeLanguage(old_language, new_language);
909 if (old_language != new_language) {
913 params.language = new_language;
914 params.inputenc = fl_get_choice_text(language_->choice_inputenc);
920 bool FormDocument::language_apply()
922 return language_apply(lv_->buffer()->params);
926 bool FormDocument::options_apply(BufferParams & params)
930 params.graphicsDriver =
931 fl_get_choice_text(options_->choice_postscript_driver);
932 params.use_amsmath = fl_get_button(options_->check_use_amsmath);
933 params.use_natbib = fl_get_button(options_->check_use_natbib);
934 params.use_numerical_citations =
935 fl_get_choice(options_->choice_citation_format)-1;
937 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
938 if (params.secnumdepth != tmpchar)
940 params.secnumdepth = tmpchar;
942 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
944 params.float_placement =
945 fl_get_input(options_->input_float_placement);
951 bool FormDocument::options_apply()
953 return options_apply(lv_->buffer()->params);
957 void FormDocument::bullets_apply(BufferParams & params)
959 /* update the bullet settings */
960 BufferParams & buf_params = lv_->buffer()->params;
962 // a little bit of loop unrolling
963 params.user_defined_bullets[0] = buf_params.temp_bullets[0];
964 params.user_defined_bullets[1] = buf_params.temp_bullets[1];
965 params.user_defined_bullets[2] = buf_params.temp_bullets[2];
966 params.user_defined_bullets[3] = buf_params.temp_bullets[3];
970 void FormDocument::bullets_apply()
972 bullets_apply(lv_->buffer()->params);
975 void FormDocument::UpdateClassParams(BufferParams const & params)
977 // These are the params that have to be updated on any class change
978 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
980 LyXTextClass const & tclass = textclasslist[params.textclass];
982 combo_doc_class->select(tclass.description());
983 fl_clear_choice(class_->choice_doc_fontsize);
984 fl_addto_choice(class_->choice_doc_fontsize, "default");
985 fl_addto_choice(class_->choice_doc_fontsize,
986 tclass.opt_fontsize().c_str());
987 fl_set_choice_text(class_->choice_doc_fontsize,
988 params.fontsize.c_str());
989 fl_clear_choice(class_->choice_doc_pagestyle);
990 fl_addto_choice(class_->choice_doc_pagestyle, "default");
991 fl_addto_choice(class_->choice_doc_pagestyle,
992 tclass.opt_pagestyle().c_str());
993 fl_set_choice_text(class_->choice_doc_pagestyle,
994 params.pagestyle.c_str());
998 void FormDocument::class_update(BufferParams const & params)
1003 UpdateClassParams(params);
1005 fl_set_choice_text(class_->choice_doc_fonts,
1006 params.fonts.c_str());
1007 fl_set_button(class_->radio_doc_indent, 0);
1008 fl_set_button(class_->radio_doc_skip, 0);
1009 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
1010 fl_set_button(class_->radio_doc_indent, 1);
1012 fl_set_button(class_->radio_doc_skip, 1);
1014 bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
1015 setEnabled(class_->choice_default_skip_units, input_length);
1016 setEnabled(class_->input_doc_skip, input_length);
1018 switch (params.getDefSkip().kind()) {
1019 case VSpace::SMALLSKIP:
1020 fl_set_choice (class_->choice_doc_skip, 1);
1022 case VSpace::MEDSKIP:
1023 fl_set_choice (class_->choice_doc_skip, 2);
1025 case VSpace::BIGSKIP:
1026 fl_set_choice (class_->choice_doc_skip, 3);
1028 case VSpace::LENGTH:
1030 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1031 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1032 || paperchoice == 2 || paperchoice > 5;
1033 string const default_unit = metric ? "cm" : "in";
1034 string const length = params.getDefSkip().asLyXCommand();
1035 updateWidgetsFromLengthString(class_->input_doc_skip,
1036 class_->choice_default_skip_units,
1037 length, default_unit);
1041 fl_set_choice (class_->choice_doc_skip, 2);
1044 fl_set_button(class_->radio_doc_sides_one, 0);
1045 fl_set_button(class_->radio_doc_sides_two, 0);
1046 setEnabled(class_->choice_doc_skip,
1047 fl_get_button(class_->radio_doc_skip));
1049 if (params.sides == LyXTextClass::TwoSides)
1050 fl_set_button(class_->radio_doc_sides_two, 1);
1052 fl_set_button(class_->radio_doc_sides_one, 1);
1053 fl_set_button(class_->radio_doc_columns_one, 0);
1054 fl_set_button(class_->radio_doc_columns_two, 0);
1055 if (params.columns == 2)
1056 fl_set_button(class_->radio_doc_columns_two, 1);
1058 fl_set_button(class_->radio_doc_columns_one, 1);
1060 fl_set_input(class_->input_doc_spacing, "");
1061 setEnabled(class_->input_doc_spacing, false);
1063 switch (params.spacing.getSpace()) {
1064 case Spacing::Default: // nothing bad should happen with this
1065 case Spacing::Single:
1067 fl_set_choice(class_->choice_doc_spacing, 1);
1069 case Spacing::Onehalf:
1071 fl_set_choice(class_->choice_doc_spacing, 2);
1073 case Spacing::Double:
1075 fl_set_choice(class_->choice_doc_spacing, 3);
1077 case Spacing::Other:
1079 fl_set_choice(class_->choice_doc_spacing, 4);
1081 sprintf(sval,"%g",params.spacing.getValue());
1082 fl_set_input(class_->input_doc_spacing, sval);
1083 setEnabled(class_->input_doc_spacing, true);
1087 if (!params.options.empty())
1088 fl_set_input(class_->input_doc_extra, params.options.c_str());
1090 fl_set_input(class_->input_doc_extra, "");
1094 void FormDocument::language_update(BufferParams const & params)
1096 if (!language_.get())
1099 int const pos = int(findPos(lang_, params.language->lang()));
1100 combo_language->select(pos+1);
1102 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1103 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1104 fl_set_button(language_->radio_single, 0);
1105 fl_set_button(language_->radio_double, 0);
1106 if (params.quotes_times == InsetQuotes::SingleQ)
1107 fl_set_button(language_->radio_single, 1);
1109 fl_set_button(language_->radio_double, 1);
1113 void FormDocument::options_update(BufferParams const & params)
1115 if (!options_.get())
1118 fl_set_choice_text(options_->choice_postscript_driver,
1119 params.graphicsDriver.c_str());
1120 fl_set_button(options_->check_use_amsmath, params.use_amsmath);
1121 fl_set_button(options_->check_use_natbib, params.use_natbib);
1122 fl_set_choice(options_->choice_citation_format,
1123 int(params.use_numerical_citations)+1);
1124 setEnabled(options_->choice_citation_format, params.use_natbib);
1125 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1126 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1127 if (!params.float_placement.empty())
1128 fl_set_input(options_->input_float_placement,
1129 params.float_placement.c_str());
1131 fl_set_input(options_->input_float_placement, "");
1135 void FormDocument::paper_update(BufferParams const & params)
1140 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1141 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1142 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1144 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1145 bool const useCustom = paperchoice == 2;
1146 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1148 fl_set_button(paper_->radio_portrait, 0);
1149 setEnabled(paper_->radio_portrait, !useCustom);
1150 fl_set_button(paper_->radio_landscape, 0);
1151 setEnabled(paper_->radio_landscape, !useCustom);
1153 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
1154 fl_set_button(paper_->radio_landscape, 1);
1156 fl_set_button(paper_->radio_portrait, 1);
1157 setEnabled(paper_->choice_paperpackage,
1158 //either default papersize (preferences)
1159 //or document papersize has to be A4
1161 || paperchoice == 1 && lyxrc.default_papersize == 5)
1162 && fl_get_button(paper_->radio_portrait));
1164 // Default unit choice is cm if metric, inches if US paper.
1165 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1166 || paperchoice == 2 || paperchoice > 5;
1167 string const default_unit = metric ? "cm" : "in";
1168 updateWidgetsFromLengthString(paper_->input_custom_width,
1169 paper_->choice_custom_width_units,
1170 params.paperwidth, default_unit);
1171 setEnabled(paper_->input_custom_width, useCustom);
1172 setEnabled(paper_->choice_custom_width_units, useCustom);
1174 updateWidgetsFromLengthString(paper_->input_custom_height,
1175 paper_->choice_custom_height_units,
1176 params.paperheight, default_unit);
1177 setEnabled(paper_->input_custom_height, useCustom);
1178 setEnabled(paper_->choice_custom_height_units, useCustom);
1180 updateWidgetsFromLengthString(paper_->input_inner_margin,
1181 paper_->choice_inner_margin_units,
1182 params.leftmargin, default_unit);
1183 setEnabled(paper_->input_inner_margin, useGeom);
1184 setEnabled(paper_->choice_inner_margin_units, useGeom);
1186 updateWidgetsFromLengthString(paper_->input_top_margin,
1187 paper_->choice_top_margin_units,
1188 params.topmargin, default_unit);
1189 setEnabled(paper_->input_top_margin, useGeom);
1190 setEnabled(paper_->choice_top_margin_units, useGeom);
1192 updateWidgetsFromLengthString(paper_->input_outer_margin,
1193 paper_->choice_outer_margin_units,
1194 params.rightmargin, default_unit);
1195 setEnabled(paper_->input_outer_margin, useGeom);
1196 setEnabled(paper_->choice_outer_margin_units, useGeom);
1198 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1199 paper_->choice_bottom_margin_units,
1200 params.bottommargin, default_unit);
1201 setEnabled(paper_->input_bottom_margin, useGeom);
1202 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1204 updateWidgetsFromLengthString(paper_->input_head_height,
1205 paper_->choice_head_height_units,
1206 params.headheight, default_unit);
1207 setEnabled(paper_->input_head_height, useGeom);
1208 setEnabled(paper_->choice_head_height_units, useGeom);
1210 updateWidgetsFromLengthString(paper_->input_head_sep,
1211 paper_->choice_head_sep_units,
1212 params.headsep, default_unit);
1213 setEnabled(paper_->input_head_sep, useGeom);
1214 setEnabled(paper_->choice_head_sep_units, useGeom);
1216 updateWidgetsFromLengthString(paper_->input_foot_skip,
1217 paper_->choice_foot_skip_units,
1218 params.footskip, default_unit);
1219 setEnabled(paper_->input_foot_skip, useGeom);
1220 setEnabled(paper_->choice_foot_skip_units, useGeom);
1222 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1226 void FormDocument::bullets_update(BufferParams const & params)
1228 if (!bullets_.get() ||
1230 (XpmVersion==4 && XpmRevision<7)))
1233 bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
1234 setEnabled(fbullet, !isLinuxDoc);
1236 if (isLinuxDoc) return;
1238 fl_set_button(bullets_->radio_bullet_depth_1, 1);
1239 fl_set_input(bullets_->input_bullet_latex,
1240 params.user_defined_bullets[0].getText().c_str());
1241 fl_set_choice(bullets_->choice_bullet_size,
1242 params.user_defined_bullets[0].getSize() + 2);
1246 void FormDocument::checkReadOnly()
1248 if (bc().readOnly(lv_->buffer()->isReadonly())) {
1249 combo_doc_class->deactivate();
1250 combo_language->deactivate();
1251 postWarning(_("Document is read-only."
1252 " No changes to layout permitted."));
1254 combo_doc_class->activate();
1255 combo_language->activate();
1261 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
1267 // this has to be all out of if/elseif because it has to deactivate
1268 // the document buttons and so the whole stuff has to be tested again.
1269 // disable OK/Apply if input is not valid
1270 str = fl_get_input(class_->input_doc_skip);
1271 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1272 str = fl_get_input(paper_->input_custom_width);
1273 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1274 str = fl_get_input(paper_->input_custom_height);
1275 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1276 str = fl_get_input(paper_->input_outer_margin);
1277 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1278 str = fl_get_input(paper_->input_inner_margin);
1279 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1280 str = fl_get_input(paper_->input_top_margin);
1281 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1282 str = fl_get_input(paper_->input_bottom_margin);
1283 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1284 str = fl_get_input(paper_->input_head_height);
1285 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1286 str = fl_get_input(paper_->input_head_sep);
1287 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1288 str = fl_get_input(paper_->input_foot_skip);
1289 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1291 //display warning if input is not valid
1292 if (ob == class_->input_doc_skip
1293 || ob == paper_->input_custom_width
1294 || ob == paper_->input_custom_height
1295 || ob == paper_->input_outer_margin
1296 || ob == paper_->input_inner_margin
1297 || ob == paper_->input_top_margin
1298 || ob == paper_->input_bottom_margin
1299 || ob == paper_->input_head_height
1300 || ob == paper_->input_head_sep
1301 || ob == paper_->input_foot_skip) {
1303 postWarning(_("Invalid Length (valid example: 10mm)"));
1311 // "Synchronize" the choice and the input field, so that it
1312 // is impossible to commit senseless data.
1313 input = fl_get_input (class_->input_doc_skip);
1314 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1316 else if (fl_get_choice(class_->choice_doc_skip) != 4)
1317 fl_set_input (class_->input_doc_skip, "");
1319 input = fl_get_input(class_->input_doc_spacing);
1320 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1322 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
1323 fl_set_input (class_->input_doc_spacing, "");
1328 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1330 BufferParams & param = lv_->buffer()->params;
1332 // convert from 1-6 range to -1-4
1333 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1334 fl_set_input(bullets_->input_bullet_latex,
1335 param.temp_bullets[current_bullet_depth].getText().c_str());
1339 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1341 BufferParams & param = lv_->buffer()->params;
1343 param.temp_bullets[current_bullet_depth].
1344 setText(fl_get_input(bullets_->input_bullet_latex));
1348 void FormDocument::BulletDepth(FL_OBJECT * ob, State cb)
1350 /* Should I do the following: */
1351 /* 1. change to the panel that the current bullet belongs in */
1352 /* 2. show that bullet as selected */
1353 /* 3. change the size setting to the size of the bullet in Q.*/
1354 /* 4. display the latex equivalent in the latex box */
1356 /* I'm inclined to just go with 3 and 4 at the moment and */
1357 /* maybe try to support the others later */
1358 BufferParams & param = lv_->buffer()->params;
1361 if (cb == BULLETDEPTH1)
1363 else if (cb == BULLETDEPTH2)
1365 else if (cb == BULLETDEPTH3)
1367 else if (cb == BULLETDEPTH4)
1370 switch (fl_get_button_numb(ob)) {
1372 // right mouse button resets to default
1373 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1375 current_bullet_depth = data;
1376 fl_set_input(bullets_->input_bullet_latex,
1377 param.temp_bullets[data].getText().c_str());
1378 fl_set_choice(bullets_->choice_bullet_size,
1379 param.temp_bullets[data].getSize() + 2);
1384 void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, State cb)
1386 /* Here we have to change the background pixmap to that selected */
1387 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1390 if (cb == BULLETPANEL1)
1392 else if (cb == BULLETPANEL2)
1394 else if (cb == BULLETPANEL3)
1396 else if (cb == BULLETPANEL4)
1398 else if (cb == BULLETPANEL5)
1400 else if (cb == BULLETPANEL6)
1403 if (data != current_bullet_panel) {
1404 fl_freeze_form(bullets_->form);
1405 current_bullet_panel = data;
1407 /* free the current pixmap */
1408 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1411 /* display the new one */
1413 new_panel = "standard";
1416 new_panel = "amssymb";
1419 new_panel = "psnfss1";
1422 new_panel = "psnfss2";
1425 new_panel = "psnfss3";
1428 new_panel = "psnfss4";
1431 /* something very wrong happened */
1432 // play it safe for now but should be an exception
1433 current_bullet_panel = 0; // standard panel
1434 new_panel = "standard";
1437 new_panel += ".xpm";
1438 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1439 LibFileSearch("images", new_panel).c_str());
1440 fl_redraw_object(bullets_->bmtable_bullet_panel);
1441 fl_unfreeze_form(bullets_->form);
1446 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1448 /* handle the user input by setting the current bullet depth's pixmap */
1449 /* to that extracted from the current chosen position of the BMTable */
1450 /* Don't forget to free the button's old pixmap first. */
1452 BufferParams & param = lv_->buffer()->params;
1453 int bmtable_button = fl_get_bmtable(ob);
1455 /* try to keep the button held down till another is pushed */
1456 /* fl_set_bmtable(ob, 1, bmtable_button); */
1457 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1458 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1459 fl_set_input(bullets_->input_bullet_latex,
1460 param.temp_bullets[current_bullet_depth].getText().c_str());
1464 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1467 ob = class_->choice_doc_class;
1469 lv_->prohibitInput();
1471 unsigned int tc = combo_doc_class->get() - 1;
1472 if (textclasslist[tc].load()) {
1473 // we use a copy of the bufferparams because we do not
1474 // want to modify them yet.
1475 BufferParams params = lv_->buffer()->params;
1477 if (lyxrc.auto_reset_options) {
1478 params.textclass = tc;
1479 params.useClassDefaults();
1480 UpdateLayoutDocument(params);
1482 // update the params which are needed in any case
1483 // (fontsizes, pagestyle)
1484 params.textclass = tc;
1485 UpdateClassParams(params);
1489 // unable to load new style
1490 Alert::alert(_("Conversion Errors!"),
1491 _("Unable to switch to new document class."),
1492 _("Reverting to original document class."));
1493 combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
1499 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1505 class_update(params);
1506 paper_update(params);
1507 language_update(params);
1508 options_update(params);
1509 bullets_update(params);