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 "forms/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"
49 #include FORMS_H_LOCATION
51 #include <boost/bind.hpp>
57 using Liason::setMinibuffer;
60 FormDocument::FormDocument(LyXView * lv, Dialogs * d)
61 : FormBaseBD(lv, d, _("Document Layout")),
62 ActCell(0), Confirmed(0),
63 current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
68 void FormDocument::redraw()
70 if (form() && form()->visible)
71 fl_redraw_form(form());
75 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
76 if (outer_form && outer_form->visible)
77 fl_redraw_form(outer_form);
81 FL_FORM * FormDocument::form() const
83 if (dialog_.get()) return dialog_->form;
88 void FormDocument::build()
93 dialog_.reset(build_document(this));
95 // Allow the base class to control messages
96 setMessageWidget(dialog_->text_warning);
98 // Manage the restore, ok, apply, restore and cancel/close buttons
99 bc().setOK(dialog_->button_ok);
100 bc().setApply(dialog_->button_apply);
101 bc().setCancel(dialog_->button_close);
102 bc().setRestore(dialog_->button_restore);
103 bc().addReadOnly (dialog_->button_save_defaults);
104 bc().addReadOnly (dialog_->button_reset_defaults);
106 // the document paper form
107 paper_.reset(build_document_paper(this));
108 fl_addto_choice(paper_->choice_papersize,
109 _(" Default | Custom | US letter | US legal "
110 "| US executive | A3 | A4 | A5 | B3 | B4 | B5 "));
111 fl_addto_choice(paper_->choice_paperpackage,
114 "| Very small Margins "
115 "| Very wide Margins "));
117 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
118 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
119 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
120 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
121 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
122 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
123 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
124 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
125 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
127 setPrehandler(paper_->input_custom_width);
128 setPrehandler(paper_->input_custom_height);
129 setPrehandler(paper_->input_top_margin);
130 setPrehandler(paper_->input_bottom_margin);
131 setPrehandler(paper_->input_inner_margin);
132 setPrehandler(paper_->input_outer_margin);
133 setPrehandler(paper_->input_head_height);
134 setPrehandler(paper_->input_head_sep);
135 setPrehandler(paper_->input_foot_skip);
137 // Create the contents of the unit choices
138 // Don't include the "%" terms...
139 vector<string> units_vec = getLatexUnits();
140 vector<string>::iterator ret =
141 std::remove_if(units_vec.begin(),
143 bind2nd(contains_functor(), "%"));
144 units_vec.erase(ret, units_vec.end());
146 string units = getStringFromVector(units_vec, "|");
148 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
149 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
150 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
151 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
152 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
153 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
154 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
155 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
156 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
158 bc().addReadOnly (paper_->choice_paperpackage);
159 bc().addReadOnly (paper_->radio_portrait);
160 bc().addReadOnly (paper_->radio_landscape);
161 bc().addReadOnly (paper_->choice_papersize);
162 bc().addReadOnly (paper_->check_use_geometry);
163 bc().addReadOnly (paper_->input_custom_width);
164 bc().addReadOnly (paper_->input_custom_height);
165 bc().addReadOnly (paper_->input_top_margin);
166 bc().addReadOnly (paper_->input_bottom_margin);
167 bc().addReadOnly (paper_->input_inner_margin);
168 bc().addReadOnly (paper_->input_outer_margin);
169 bc().addReadOnly (paper_->input_head_height);
170 bc().addReadOnly (paper_->input_head_sep);
171 bc().addReadOnly (paper_->input_foot_skip);
173 // the document class form
174 class_.reset(build_document_class(this));
177 // The language is a combo-box and has to be inserted manually
178 obj = class_->choice_doc_class;
179 fl_deactivate_object(obj);
180 fl_addto_form(class_->form);
181 combo_doc_class.reset(new Combox(FL_COMBOX_DROPLIST));
182 combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400,
184 combo_doc_class->shortcut("#C",1);
185 combo_doc_class->setcallback(ComboInputCB, this);
187 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
188 cit != textclasslist.end(); ++cit) {
189 combo_doc_class->addto(cit->description());
192 fl_addto_choice(class_->choice_doc_spacing,
193 _(" Single | OneHalf | Double | Custom "));
194 fl_addto_choice(class_->choice_doc_fontsize, "default|10|11|12");
195 for (n=0; tex_fonts[n][0]; ++n) {
196 fl_addto_choice(class_->choice_doc_fonts,tex_fonts[n]);
198 fl_addto_choice(class_->choice_doc_pagestyle,
199 "default|empty|plain|headings|fancy");
200 fl_addto_choice(class_->choice_doc_skip,
201 _(" Smallskip | Medskip | Bigskip | Length "));
202 fl_addto_choice(class_->choice_default_skip_units, units.c_str());
203 fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
204 fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
205 fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
207 setPrehandler(class_->input_doc_extra);
208 setPrehandler(class_->input_doc_skip);
209 setPrehandler(class_->input_doc_spacing);
211 // Set input filters on doc spacing to make it accept only
213 fl_set_input_filter(class_->input_doc_spacing, fl_unsigned_float_filter);
215 bc().addReadOnly (class_->radio_doc_indent);
216 bc().addReadOnly (class_->radio_doc_skip);
218 bc().addReadOnly (class_->choice_doc_pagestyle);
219 bc().addReadOnly (class_->choice_doc_fonts);
220 bc().addReadOnly (class_->choice_doc_fontsize);
221 bc().addReadOnly (class_->radio_doc_sides_one);
222 bc().addReadOnly (class_->radio_doc_sides_two);
223 bc().addReadOnly (class_->radio_doc_columns_one);
224 bc().addReadOnly (class_->radio_doc_columns_two);
225 bc().addReadOnly (class_->input_doc_extra);
226 bc().addReadOnly (class_->input_doc_skip);
227 bc().addReadOnly (class_->choice_doc_skip);
228 bc().addReadOnly (class_->choice_doc_spacing);
229 bc().addReadOnly (class_->input_doc_spacing);
231 // the document language form
232 language_.reset(build_document_language(this));
233 fl_addto_choice(language_->choice_inputenc,
234 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
235 "|koi8-r|koi8-u|cp866|cp1251|iso88595|pt154");
237 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
238 // Store the identifiers for later
239 lang_ = getSecond(langs);
241 // The language is a combo-box and has to be inserted manually
242 obj = language_->choice_language;
243 fl_deactivate_object(obj);
244 fl_addto_form(language_->form);
245 combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
246 combo_language->add(obj->x, obj->y, obj->w, obj->h, 400,
248 combo_language->shortcut("#L",1);
249 combo_language->setcallback(ComboInputCB, this);
252 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
253 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
254 for (; lit != lend; ++lit) {
255 combo_language->addto(lit->first);
257 combo_language->select(1);
259 fl_addto_choice(language_->choice_quotes_language,
260 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
261 " «text» | »text« "));
263 bc().addReadOnly (language_->choice_inputenc);
264 bc().addReadOnly (language_->choice_quotes_language);
265 bc().addReadOnly (language_->radio_single);
266 bc().addReadOnly (language_->radio_double);
268 // the document options form
269 options_.reset(build_document_options(this));
270 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
271 setPrehandler(options_->input_float_placement);
273 fl_set_counter_bounds(options_->counter_secnumdepth,-2,5);
274 fl_set_counter_bounds(options_->counter_tocdepth,-1,5);
275 fl_set_counter_step(options_->counter_secnumdepth,1,1);
276 fl_set_counter_step(options_->counter_tocdepth,1,1);
277 fl_set_counter_precision(options_->counter_secnumdepth, 0);
278 fl_set_counter_precision(options_->counter_tocdepth, 0);
279 for (n=0; tex_graphics[n][0]; ++n) {
280 fl_addto_choice(options_->choice_postscript_driver,
283 fl_addto_choice(options_->choice_citation_format,
284 _(" Author-year | Numerical "));
286 bc_.addReadOnly (options_->counter_secnumdepth);
287 bc_.addReadOnly (options_->counter_tocdepth);
288 bc_.addReadOnly (options_->check_use_amsmath);
289 bc_.addReadOnly (options_->check_use_natbib);
290 bc_.addReadOnly (options_->choice_citation_format);
291 bc_.addReadOnly (options_->input_float_placement);
292 bc_.addReadOnly (options_->choice_postscript_driver);
294 // the document bullets form
295 bullets_.reset(build_document_bullet(this));
296 fl_addto_choice(bullets_->choice_bullet_size,
297 _(" default | tiny | script | footnote | small |"
298 " normal | large | Large | LARGE | huge | Huge"));
299 fl_set_choice(bullets_->choice_bullet_size, 1);
300 fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
301 setPrehandler(bullets_->input_bullet_latex);
302 fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
304 bc_.addReadOnly(bullets_->radio_bullet_depth_1);
305 bc_.addReadOnly(bullets_->radio_bullet_depth_2);
306 bc_.addReadOnly(bullets_->radio_bullet_depth_3);
307 bc_.addReadOnly(bullets_->radio_bullet_depth_4);
308 bc_.addReadOnly(bullets_->radio_bullet_panel_standard);
309 bc_.addReadOnly(bullets_->radio_bullet_panel_maths);
310 bc_.addReadOnly(bullets_->radio_bullet_panel_ding1);
311 bc_.addReadOnly(bullets_->radio_bullet_panel_ding2);
312 bc_.addReadOnly(bullets_->radio_bullet_panel_ding3);
313 bc_.addReadOnly(bullets_->radio_bullet_panel_ding4);
315 bc().addReadOnly (bullets_->bmtable_bullet_panel);
316 bc().addReadOnly (bullets_->choice_bullet_size);
317 bc().addReadOnly (bullets_->input_bullet_latex);
319 fl_addto_tabfolder(dialog_->tabfolder,_("Document"),
321 fl_addto_tabfolder(dialog_->tabfolder,_("Paper"),
323 fl_addto_tabfolder(dialog_->tabfolder,_("Language"),
325 fl_addto_tabfolder(dialog_->tabfolder,_("Extra"),
327 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets"),
329 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
330 lyxerr << _("Your version of libXpm is older than 4.7.\n"
331 "The `bullet' tab of the document dialog "
332 "has been disabled") << '\n';
333 fl_deactivate_object(fbullet);
334 fl_set_object_lcol(fbullet, FL_INACTIVE);
339 void FormDocument::apply()
341 if (!lv_->view()->available() || !dialog_.get())
344 bool redo = class_apply();
346 redo = language_apply() || redo;
347 redo = options_apply() || redo;
351 lv_->view()->redoCurrentBuffer();
353 lv_->buffer()->markDirty();
354 setMinibuffer(lv_, _("Document layout set"));
358 void FormDocument::cancel()
360 // this avoids confusion when reopening
361 BufferParams & param = lv_->buffer()->params;
362 param.temp_bullets[0] = param.user_defined_bullets[0];
363 param.temp_bullets[1] = param.user_defined_bullets[1];
364 param.temp_bullets[2] = param.user_defined_bullets[2];
365 param.temp_bullets[3] = param.user_defined_bullets[3];
370 void FormDocument::update()
377 BufferParams const & params = lv_->buffer()->params;
379 class_update(params);
380 paper_update(params);
381 language_update(params);
382 options_update(params);
383 bullets_update(params);
388 // should this go elsewhere? Maybe a ControllerDocument? (JMarc)
389 /** Save the buffer's parameters as user default.
390 This function saves a file \c user_lyxdir/templates/defaults.lyx
391 which parameters are those of the current buffer. This file
392 is used as a default template when creating a new
393 file. Returns \c true on success.
395 bool saveParamsAsDefault(BufferParams const ¶ms)
397 if (!Alert::askQuestion(_("Do you want to save the current settings"),
398 _("for the document layout as default?"),
399 _("(they will be valid for any new document)")))
402 string const fname = AddName(AddPath(user_lyxdir, "templates/"),
404 Buffer defaults = Buffer(fname);
405 defaults.params = params;
407 // add an empty paragraph. Is this enough?
408 defaults.paragraph = new Paragraph;
410 return defaults.writeFile(defaults.fileName(), false);
416 bool FormDocument::input(FL_OBJECT * ob, long)
418 if (ob == class_->choice_doc_class) {
419 CheckChoiceClass(ob, 0);
420 } else if (ob == bullets_->choice_bullet_size) {
421 ChoiceBulletSize(ob, 0);
422 } else if (ob == bullets_->input_bullet_latex) {
423 InputBulletLaTeX(ob, 0);
424 } else if (ob == bullets_->radio_bullet_depth_1 ||
425 ob == bullets_->radio_bullet_depth_2 ||
426 ob == bullets_->radio_bullet_depth_3 ||
427 ob == bullets_->radio_bullet_depth_4) {
429 } else if (ob == bullets_->radio_bullet_panel_standard ||
430 ob == bullets_->radio_bullet_panel_maths ||
431 ob == bullets_->radio_bullet_panel_ding1 ||
432 ob == bullets_->radio_bullet_panel_ding2 ||
433 ob == bullets_->radio_bullet_panel_ding3 ||
434 ob == bullets_->radio_bullet_panel_ding4) {
436 } else if (ob == bullets_->bmtable_bullet_panel) {
437 BulletBMTable(ob, 0);
440 bool const length_input = fl_get_choice(class_->choice_doc_skip) == 4;
441 if (ob == class_->choice_doc_skip) {
442 setEnabled(class_->input_doc_skip, length_input);
443 setEnabled(class_->choice_default_skip_units, length_input);
446 if (ob == class_->choice_doc_spacing)
447 setEnabled(class_->input_doc_spacing,
448 fl_get_choice(class_->choice_doc_spacing) == 4);
450 bool const skip_used = fl_get_button(class_->radio_doc_skip);
451 if (ob == class_->radio_doc_skip ||
452 ob == class_->radio_doc_indent) {
453 setEnabled(class_->choice_doc_skip, skip_used);
454 setEnabled(class_->input_doc_skip,
455 skip_used && length_input);
456 setEnabled(class_->choice_default_skip_units,
457 skip_used && length_input);
458 // Default unit choice is cm if metric, inches if US paper.
459 // If papersize is default, check the lyxrc-settings
460 int const paperchoice = fl_get_choice(paper_->choice_papersize);
461 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
462 || paperchoice == 2 || paperchoice > 5;
463 int const default_unit = metric ? 8 : 9;
464 if (rtrim(fl_get_input(class_->input_doc_skip)).empty())
465 fl_set_choice(class_->choice_default_skip_units,
469 if (ob == options_->check_use_natbib) {
470 setEnabled(options_->choice_citation_format,
471 fl_get_button(options_->check_use_natbib));
474 if (ob == dialog_->button_save_defaults) {
478 language_apply(params);
479 options_apply(params);
480 bullets_apply(params);
481 params.preamble = lv_->buffer()->params.preamble;
482 saveParamsAsDefault(params);
485 if (ob == dialog_->button_reset_defaults) {
486 BufferParams params = lv_->buffer()->params;
487 params.textclass = combo_doc_class->get() - 1;
488 params.useClassDefaults();
489 UpdateLayoutDocument(params);
492 if (ob == paper_->radio_landscape)
493 fl_set_choice(paper_->choice_paperpackage,
494 BufferParams::PACKAGE_NONE + 1);
496 if (ob == paper_->choice_papersize) {
497 int const paperchoice = fl_get_choice(paper_->choice_papersize);
498 bool const defsize = paperchoice == 1;
499 bool const custom = paperchoice == 2;
500 bool const a3size = paperchoice == 6;
501 bool const b3size = paperchoice == 9;
502 bool const b4size = paperchoice == 10;
505 fl_set_button(paper_->radio_portrait, 1);
507 bool const use_geom = (custom || a3size || b3size || b4size);
509 fl_set_button(paper_->check_use_geometry, int(use_geom));
511 setEnabled(paper_->input_top_margin, use_geom);
512 setEnabled(paper_->input_bottom_margin, use_geom);
513 setEnabled(paper_->input_inner_margin, use_geom);
514 setEnabled(paper_->input_outer_margin, use_geom);
515 setEnabled(paper_->input_head_height, use_geom);
516 setEnabled(paper_->input_head_sep, use_geom);
517 setEnabled(paper_->input_foot_skip, use_geom);
518 setEnabled(paper_->choice_top_margin_units, use_geom);
519 setEnabled(paper_->choice_bottom_margin_units, use_geom);
520 setEnabled(paper_->choice_inner_margin_units, use_geom);
521 setEnabled(paper_->choice_outer_margin_units, use_geom);
522 setEnabled(paper_->choice_head_height_units, use_geom);
523 setEnabled(paper_->choice_head_sep_units, use_geom);
524 setEnabled(paper_->choice_foot_skip_units, use_geom);
525 setEnabled(paper_->choice_custom_width_units, use_geom);
526 setEnabled(paper_->choice_custom_height_units, use_geom);
528 setEnabled(paper_->input_custom_width, custom);
529 setEnabled(paper_->input_custom_height, custom);
530 setEnabled(paper_->choice_custom_width_units, custom);
531 setEnabled(paper_->choice_custom_height_units, custom);
532 setEnabled(paper_->radio_portrait, !custom);
533 setEnabled(paper_->radio_landscape, !custom);
535 // Default unit choice is cm if metric, inches if US paper.
536 // If papersize is default, use the lyxrc-settings
537 bool const metric = (defsize && lyxrc.default_papersize > 3)
538 || paperchoice == 2 || paperchoice > 5;
539 int const default_unit = metric ? 8 : 9;
540 if (rtrim(fl_get_input(paper_->input_custom_width)).empty())
541 fl_set_choice(paper_->choice_custom_width_units,
543 if (rtrim(fl_get_input(paper_->input_custom_height)).empty())
544 fl_set_choice(paper_->choice_custom_height_units,
546 if (rtrim(fl_get_input(paper_->input_top_margin)).empty())
547 fl_set_choice(paper_->choice_top_margin_units,
549 if (rtrim(fl_get_input(paper_->input_bottom_margin)).empty())
550 fl_set_choice(paper_->choice_bottom_margin_units,
552 if (rtrim(fl_get_input(paper_->input_inner_margin)).empty())
553 fl_set_choice(paper_->choice_inner_margin_units,
555 if (rtrim(fl_get_input(paper_->input_outer_margin)).empty())
556 fl_set_choice(paper_->choice_outer_margin_units,
558 if (rtrim(fl_get_input(paper_->input_head_height)).empty())
559 fl_set_choice(paper_->choice_head_height_units,
561 if (rtrim(fl_get_input(paper_->input_head_sep)).empty())
562 fl_set_choice(paper_->choice_head_sep_units,
564 if (rtrim(fl_get_input(paper_->input_foot_skip)).empty())
565 fl_set_choice(paper_->choice_foot_skip_units,
569 if (ob == paper_->choice_papersize ||
570 ob == paper_->radio_portrait ||
571 ob == paper_->radio_landscape) {
573 setEnabled(paper_->choice_paperpackage,
574 //either default papersize (preferences)
575 //or document papersize has to be A4
576 (fl_get_choice(paper_->choice_papersize) == 7
577 || fl_get_choice(paper_->choice_papersize) == 1
578 && lyxrc.default_papersize == 5)
579 && fl_get_button(paper_->radio_portrait));
582 if (ob == paper_->choice_paperpackage) {
583 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
584 fl_set_button(paper_->check_use_geometry, 0);
586 setEnabled(paper_->input_top_margin, false);
587 setEnabled(paper_->input_bottom_margin, false);
588 setEnabled(paper_->input_inner_margin, false);
589 setEnabled(paper_->input_outer_margin, false);
590 setEnabled(paper_->input_head_height, false);
591 setEnabled(paper_->input_head_sep, false);
592 setEnabled(paper_->input_foot_skip, false);
593 setEnabled(paper_->choice_top_margin_units, false);
594 setEnabled(paper_->choice_bottom_margin_units, false);
595 setEnabled(paper_->choice_inner_margin_units, false);
596 setEnabled(paper_->choice_outer_margin_units, false);
597 setEnabled(paper_->choice_head_height_units, false);
598 setEnabled(paper_->choice_head_sep_units, false);
599 setEnabled(paper_->choice_foot_skip_units, false);
603 if (ob == paper_->check_use_geometry) {
604 //don't allow switching geometry off in custom papersize mode
605 //nor in A3, B3, and B4
606 int const choice = fl_get_choice(paper_->choice_papersize);
607 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
608 fl_set_button(paper_->check_use_geometry, 1);
610 fl_set_choice(paper_->choice_paperpackage,
611 BufferParams::PACKAGE_NONE + 1);
613 bool const use_geom = fl_get_button(paper_->check_use_geometry);
614 setEnabled(paper_->input_top_margin, use_geom);
615 setEnabled(paper_->input_bottom_margin, use_geom);
616 setEnabled(paper_->input_inner_margin, use_geom);
617 setEnabled(paper_->input_outer_margin, use_geom);
618 setEnabled(paper_->input_head_height, use_geom);
619 setEnabled(paper_->input_head_sep, use_geom);
620 setEnabled(paper_->input_foot_skip, use_geom);
621 setEnabled(paper_->choice_top_margin_units, use_geom);
622 setEnabled(paper_->choice_bottom_margin_units, use_geom);
623 setEnabled(paper_->choice_inner_margin_units, use_geom);
624 setEnabled(paper_->choice_outer_margin_units, use_geom);
625 setEnabled(paper_->choice_head_height_units, use_geom);
626 setEnabled(paper_->choice_head_sep_units, use_geom);
627 setEnabled(paper_->choice_foot_skip_units, use_geom);
630 return CheckDocumentInput(ob, 0);
634 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
636 FormDocument * pre = static_cast<FormDocument*>(v);
637 if (combox == pre->combo_doc_class.get())
638 pre->CheckChoiceClass(0, 0);
639 pre->bc().valid(pre->CheckDocumentInput(0,0));
643 bool FormDocument::class_apply(BufferParams ¶ms)
647 // If default skip is a "Length" but there's no text in the
648 // input field, reset the kind to "Medskip", which is the default.
649 if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
650 !*(fl_get_input (class_->input_doc_skip))) {
651 fl_set_choice (class_->choice_doc_skip, 2);
653 params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
654 params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
655 params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
657 params.textclass = combo_doc_class->get() - 1;
659 BufferParams::PARSEP tmpsep = params.paragraph_separation;
660 if (fl_get_button(class_->radio_doc_indent))
661 params.paragraph_separation = BufferParams::PARSEP_INDENT;
663 params.paragraph_separation = BufferParams::PARSEP_SKIP;
664 if (tmpsep != params.paragraph_separation)
667 VSpace tmpdefskip = params.getDefSkip();
668 switch (fl_get_choice (class_->choice_doc_skip)) {
670 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
673 params.setDefSkip(VSpace(VSpace::MEDSKIP));
676 params.setDefSkip(VSpace(VSpace::BIGSKIP));
680 string const length =
681 getLengthFromWidgets(class_->input_doc_skip,
682 class_->choice_default_skip_units);
684 params.setDefSkip(VSpace(LyXGlueLength(length)));
688 // DocumentDefskipCB assures that this never happens
689 params.setDefSkip(VSpace(VSpace::MEDSKIP));
692 if (!(tmpdefskip == params.getDefSkip()))
695 if (fl_get_button(class_->radio_doc_columns_two))
699 if (fl_get_button(class_->radio_doc_sides_two))
700 params.sides = LyXTextClass::TwoSides;
702 params.sides = LyXTextClass::OneSide;
704 Spacing tmpSpacing = params.spacing;
705 switch (fl_get_choice(class_->choice_doc_spacing)) {
707 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
708 params.spacing.set(Spacing::Single);
711 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
712 params.spacing.set(Spacing::Onehalf);
715 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
716 params.spacing.set(Spacing::Double);
719 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
720 params.spacing.set(Spacing::Other,
721 fl_get_input(class_->input_doc_spacing));
724 if (tmpSpacing != params.spacing)
727 params.options = fl_get_input(class_->input_doc_extra);
733 bool FormDocument::class_apply()
735 BufferParams ¶ms = lv_->buffer()->params;
737 unsigned int const old_class = params.textclass;
739 bool redo = class_apply(params);
741 if (params.textclass != old_class) {
742 // try to load new_class
743 if (textclasslist[params.textclass].load()) {
744 // successfully loaded
746 setMinibuffer(lv_, _("Converting document to new document class..."));
747 int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
748 old_class, params.textclass,
749 lv_->buffer()->paragraph,
750 lv_->buffer()->params);
754 s = _("One paragraph couldn't be converted");
757 s += _(" paragraphs couldn't be converted");
759 Alert::alert(_("Conversion Errors!"),s,
760 _("into chosen document class"));
764 // problem changing class -- warn user and retain old style
765 Alert::alert(_("Conversion Errors!"),
766 _("Errors loading new document class."),
767 _("Reverting to original document class."));
768 combo_doc_class->select(int(old_class) + 1);
776 void FormDocument::paper_apply(BufferParams & params)
778 params.papersize2 = char(fl_get_choice(paper_->choice_papersize)-1);
780 params.paperpackage =
781 char(fl_get_choice(paper_->choice_paperpackage)-1);
783 // set params.papersize from params.papersize2 and params.paperpackage
784 params.setPaperStuff();
786 params.use_geometry = fl_get_button(paper_->check_use_geometry);
788 if (fl_get_button(paper_->radio_landscape))
789 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
791 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
794 getLengthFromWidgets(paper_->input_custom_width,
795 paper_->choice_custom_width_units);
798 getLengthFromWidgets(paper_->input_custom_height,
799 paper_->choice_custom_height_units);
802 getLengthFromWidgets(paper_->input_inner_margin,
803 paper_->choice_inner_margin_units);
806 getLengthFromWidgets(paper_->input_top_margin,
807 paper_->choice_top_margin_units);
810 getLengthFromWidgets(paper_->input_outer_margin,
811 paper_->choice_outer_margin_units);
813 params.bottommargin =
814 getLengthFromWidgets(paper_->input_bottom_margin,
815 paper_->choice_bottom_margin_units);
818 getLengthFromWidgets(paper_->input_head_height,
819 paper_->choice_head_height_units);
822 getLengthFromWidgets(paper_->input_head_sep,
823 paper_->choice_head_sep_units);
826 getLengthFromWidgets(paper_->input_foot_skip,
827 paper_->choice_foot_skip_units);
831 void FormDocument::paper_apply()
833 paper_apply(lv_->buffer()->params);
837 bool FormDocument::language_apply(BufferParams & params)
839 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
842 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
844 lga = InsetQuotes::EnglishQ;
847 lga = InsetQuotes::SwedishQ;
850 lga = InsetQuotes::GermanQ;
853 lga = InsetQuotes::PolishQ;
856 lga = InsetQuotes::FrenchQ;
859 lga = InsetQuotes::DanishQ;
862 params.quotes_language = lga;
863 if (fl_get_button(language_->radio_single))
864 params.quotes_times = InsetQuotes::SingleQ;
866 params.quotes_times = InsetQuotes::DoubleQ;
868 int const pos = combo_language->get();
869 Language const * old_language = params.language;
870 Language const * new_language = languages.getLanguage(lang_[pos-1]);
872 new_language = default_language;
874 if (old_language != new_language
875 && old_language->RightToLeft() == new_language->RightToLeft()
876 && !lv_->buffer()->isMultiLingual())
877 lv_->buffer()->changeLanguage(old_language, new_language);
879 if (old_language != new_language) {
883 params.language = new_language;
884 params.inputenc = fl_get_choice_text(language_->choice_inputenc);
890 bool FormDocument::language_apply()
892 return language_apply(lv_->buffer()->params);
896 bool FormDocument::options_apply(BufferParams & params)
900 params.graphicsDriver =
901 fl_get_choice_text(options_->choice_postscript_driver);
902 params.use_amsmath = fl_get_button(options_->check_use_amsmath);
903 params.use_natbib = fl_get_button(options_->check_use_natbib);
904 params.use_numerical_citations =
905 fl_get_choice(options_->choice_citation_format)-1;
907 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
908 if (params.secnumdepth != tmpchar)
910 params.secnumdepth = tmpchar;
912 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
914 params.float_placement =
915 fl_get_input(options_->input_float_placement);
921 bool FormDocument::options_apply()
923 return options_apply(lv_->buffer()->params);
927 void FormDocument::bullets_apply(BufferParams & params)
929 /* update the bullet settings */
930 BufferParams & buf_params = lv_->buffer()->params;
932 // a little bit of loop unrolling
933 params.user_defined_bullets[0] = buf_params.temp_bullets[0];
934 params.user_defined_bullets[1] = buf_params.temp_bullets[1];
935 params.user_defined_bullets[2] = buf_params.temp_bullets[2];
936 params.user_defined_bullets[3] = buf_params.temp_bullets[3];
940 void FormDocument::bullets_apply()
942 bullets_apply(lv_->buffer()->params);
945 void FormDocument::UpdateClassParams(BufferParams const & params)
947 // These are the params that have to be updated on any class change
948 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
950 LyXTextClass const & tclass = textclasslist[params.textclass];
952 combo_doc_class->select(tclass.description());
953 fl_clear_choice(class_->choice_doc_fontsize);
954 fl_addto_choice(class_->choice_doc_fontsize, "default");
955 fl_addto_choice(class_->choice_doc_fontsize,
956 tclass.opt_fontsize().c_str());
957 fl_set_choice_text(class_->choice_doc_fontsize,
958 params.fontsize.c_str());
959 fl_clear_choice(class_->choice_doc_pagestyle);
960 fl_addto_choice(class_->choice_doc_pagestyle, "default");
961 fl_addto_choice(class_->choice_doc_pagestyle,
962 tclass.opt_pagestyle().c_str());
963 fl_set_choice_text(class_->choice_doc_pagestyle,
964 params.pagestyle.c_str());
968 void FormDocument::class_update(BufferParams const & params)
973 UpdateClassParams(params);
975 fl_set_choice_text(class_->choice_doc_fonts,
976 params.fonts.c_str());
977 fl_set_button(class_->radio_doc_indent, 0);
978 fl_set_button(class_->radio_doc_skip, 0);
979 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
980 fl_set_button(class_->radio_doc_indent, 1);
982 fl_set_button(class_->radio_doc_skip, 1);
984 bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
985 setEnabled(class_->choice_default_skip_units, input_length);
986 setEnabled(class_->input_doc_skip, input_length);
988 switch (params.getDefSkip().kind()) {
989 case VSpace::SMALLSKIP:
990 fl_set_choice (class_->choice_doc_skip, 1);
992 case VSpace::MEDSKIP:
993 fl_set_choice (class_->choice_doc_skip, 2);
995 case VSpace::BIGSKIP:
996 fl_set_choice (class_->choice_doc_skip, 3);
1000 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1001 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1002 || paperchoice == 2 || paperchoice > 5;
1003 string const default_unit = metric ? "cm" : "in";
1004 string const length = params.getDefSkip().asLyXCommand();
1005 updateWidgetsFromLengthString(class_->input_doc_skip,
1006 class_->choice_default_skip_units,
1007 length, default_unit);
1011 fl_set_choice (class_->choice_doc_skip, 2);
1014 fl_set_button(class_->radio_doc_sides_one, 0);
1015 fl_set_button(class_->radio_doc_sides_two, 0);
1016 setEnabled(class_->choice_doc_skip,
1017 fl_get_button(class_->radio_doc_skip));
1019 if (params.sides == LyXTextClass::TwoSides)
1020 fl_set_button(class_->radio_doc_sides_two, 1);
1022 fl_set_button(class_->radio_doc_sides_one, 1);
1023 fl_set_button(class_->radio_doc_columns_one, 0);
1024 fl_set_button(class_->radio_doc_columns_two, 0);
1025 if (params.columns == 2)
1026 fl_set_button(class_->radio_doc_columns_two, 1);
1028 fl_set_button(class_->radio_doc_columns_one, 1);
1030 fl_set_input(class_->input_doc_spacing, "");
1031 setEnabled(class_->input_doc_spacing, false);
1033 switch (params.spacing.getSpace()) {
1034 case Spacing::Default: // nothing bad should happen with this
1035 case Spacing::Single:
1037 fl_set_choice(class_->choice_doc_spacing, 1);
1039 case Spacing::Onehalf:
1041 fl_set_choice(class_->choice_doc_spacing, 2);
1043 case Spacing::Double:
1045 fl_set_choice(class_->choice_doc_spacing, 3);
1047 case Spacing::Other:
1049 fl_set_choice(class_->choice_doc_spacing, 4);
1051 sprintf(sval,"%g",params.spacing.getValue());
1052 fl_set_input(class_->input_doc_spacing, sval);
1053 setEnabled(class_->input_doc_spacing, true);
1057 if (!params.options.empty())
1058 fl_set_input(class_->input_doc_extra, params.options.c_str());
1060 fl_set_input(class_->input_doc_extra, "");
1064 void FormDocument::language_update(BufferParams const & params)
1066 if (!language_.get())
1069 int const pos = int(findPos(lang_, params.language->lang()));
1070 combo_language->select(pos+1);
1072 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1073 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1074 fl_set_button(language_->radio_single, 0);
1075 fl_set_button(language_->radio_double, 0);
1076 if (params.quotes_times == InsetQuotes::SingleQ)
1077 fl_set_button(language_->radio_single, 1);
1079 fl_set_button(language_->radio_double, 1);
1083 void FormDocument::options_update(BufferParams const & params)
1085 if (!options_.get())
1088 fl_set_choice_text(options_->choice_postscript_driver,
1089 params.graphicsDriver.c_str());
1090 fl_set_button(options_->check_use_amsmath, params.use_amsmath);
1091 fl_set_button(options_->check_use_natbib, params.use_natbib);
1092 fl_set_choice(options_->choice_citation_format,
1093 int(params.use_numerical_citations)+1);
1094 setEnabled(options_->choice_citation_format, params.use_natbib);
1095 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1096 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1097 if (!params.float_placement.empty())
1098 fl_set_input(options_->input_float_placement,
1099 params.float_placement.c_str());
1101 fl_set_input(options_->input_float_placement, "");
1105 void FormDocument::paper_update(BufferParams const & params)
1110 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1111 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1112 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1114 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1115 bool const useCustom = paperchoice == 2;
1116 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1118 fl_set_button(paper_->radio_portrait, 0);
1119 setEnabled(paper_->radio_portrait, !useCustom);
1120 fl_set_button(paper_->radio_landscape, 0);
1121 setEnabled(paper_->radio_landscape, !useCustom);
1123 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
1124 fl_set_button(paper_->radio_landscape, 1);
1126 fl_set_button(paper_->radio_portrait, 1);
1127 setEnabled(paper_->choice_paperpackage,
1128 //either default papersize (preferences)
1129 //or document papersize has to be A4
1131 || paperchoice == 1 && lyxrc.default_papersize == 5)
1132 && fl_get_button(paper_->radio_portrait));
1134 // Default unit choice is cm if metric, inches if US paper.
1135 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1136 || paperchoice == 2 || paperchoice > 5;
1137 string const default_unit = metric ? "cm" : "in";
1138 updateWidgetsFromLengthString(paper_->input_custom_width,
1139 paper_->choice_custom_width_units,
1140 params.paperwidth, default_unit);
1141 setEnabled(paper_->input_custom_width, useCustom);
1142 setEnabled(paper_->choice_custom_width_units, useCustom);
1144 updateWidgetsFromLengthString(paper_->input_custom_height,
1145 paper_->choice_custom_height_units,
1146 params.paperheight, default_unit);
1147 setEnabled(paper_->input_custom_height, useCustom);
1148 setEnabled(paper_->choice_custom_height_units, useCustom);
1150 updateWidgetsFromLengthString(paper_->input_inner_margin,
1151 paper_->choice_inner_margin_units,
1152 params.leftmargin, default_unit);
1153 setEnabled(paper_->input_inner_margin, useGeom);
1154 setEnabled(paper_->choice_inner_margin_units, useGeom);
1156 updateWidgetsFromLengthString(paper_->input_top_margin,
1157 paper_->choice_top_margin_units,
1158 params.topmargin, default_unit);
1159 setEnabled(paper_->input_top_margin, useGeom);
1160 setEnabled(paper_->choice_top_margin_units, useGeom);
1162 updateWidgetsFromLengthString(paper_->input_outer_margin,
1163 paper_->choice_outer_margin_units,
1164 params.rightmargin, default_unit);
1165 setEnabled(paper_->input_outer_margin, useGeom);
1166 setEnabled(paper_->choice_outer_margin_units, useGeom);
1168 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1169 paper_->choice_bottom_margin_units,
1170 params.bottommargin, default_unit);
1171 setEnabled(paper_->input_bottom_margin, useGeom);
1172 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1174 updateWidgetsFromLengthString(paper_->input_head_height,
1175 paper_->choice_head_height_units,
1176 params.headheight, default_unit);
1177 setEnabled(paper_->input_head_height, useGeom);
1178 setEnabled(paper_->choice_head_height_units, useGeom);
1180 updateWidgetsFromLengthString(paper_->input_head_sep,
1181 paper_->choice_head_sep_units,
1182 params.headsep, default_unit);
1183 setEnabled(paper_->input_head_sep, useGeom);
1184 setEnabled(paper_->choice_head_sep_units, useGeom);
1186 updateWidgetsFromLengthString(paper_->input_foot_skip,
1187 paper_->choice_foot_skip_units,
1188 params.footskip, default_unit);
1189 setEnabled(paper_->input_foot_skip, useGeom);
1190 setEnabled(paper_->choice_foot_skip_units, useGeom);
1192 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1196 void FormDocument::bullets_update(BufferParams const & params)
1198 if (!bullets_.get() ||
1200 (XpmVersion==4 && XpmRevision<7)))
1203 bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
1204 setEnabled(fbullet, !isLinuxDoc);
1206 if (isLinuxDoc) return;
1208 fl_set_button(bullets_->radio_bullet_depth_1, 1);
1209 fl_set_input(bullets_->input_bullet_latex,
1210 params.user_defined_bullets[0].getText().c_str());
1211 fl_set_choice(bullets_->choice_bullet_size,
1212 params.user_defined_bullets[0].getSize() + 2);
1216 void FormDocument::checkReadOnly()
1218 if (bc().readOnly(lv_->buffer()->isReadonly())) {
1219 combo_doc_class->deactivate();
1220 combo_language->deactivate();
1221 postWarning(_("Document is read-only."
1222 " No changes to layout permitted."));
1224 combo_doc_class->activate();
1225 combo_language->activate();
1231 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
1237 // this has to be all out of if/elseif because it has to deactivate
1238 // the document buttons and so the whole stuff has to be tested again.
1239 // disable OK/Apply if input is not valid
1240 str = fl_get_input(class_->input_doc_skip);
1241 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1242 str = fl_get_input(paper_->input_custom_width);
1243 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1244 str = fl_get_input(paper_->input_custom_height);
1245 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1246 str = fl_get_input(paper_->input_outer_margin);
1247 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1248 str = fl_get_input(paper_->input_inner_margin);
1249 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1250 str = fl_get_input(paper_->input_top_margin);
1251 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1252 str = fl_get_input(paper_->input_bottom_margin);
1253 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1254 str = fl_get_input(paper_->input_head_height);
1255 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1256 str = fl_get_input(paper_->input_head_sep);
1257 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1258 str = fl_get_input(paper_->input_foot_skip);
1259 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1261 //display warning if input is not valid
1262 if (ob == class_->input_doc_skip
1263 || ob == paper_->input_custom_width
1264 || ob == paper_->input_custom_height
1265 || ob == paper_->input_outer_margin
1266 || ob == paper_->input_inner_margin
1267 || ob == paper_->input_top_margin
1268 || ob == paper_->input_bottom_margin
1269 || ob == paper_->input_head_height
1270 || ob == paper_->input_head_sep
1271 || ob == paper_->input_foot_skip) {
1273 postWarning(_("Invalid Length (valid example: 10mm)"));
1281 // "Synchronize" the choice and the input field, so that it
1282 // is impossible to commit senseless data.
1283 input = fl_get_input (class_->input_doc_skip);
1284 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1286 else if (fl_get_choice(class_->choice_doc_skip) != 4)
1287 fl_set_input (class_->input_doc_skip, "");
1289 input = fl_get_input(class_->input_doc_spacing);
1290 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1292 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
1293 fl_set_input (class_->input_doc_spacing, "");
1298 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1300 BufferParams & param = lv_->buffer()->params;
1302 // convert from 1-6 range to -1-4
1303 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1304 fl_set_input(bullets_->input_bullet_latex,
1305 param.temp_bullets[current_bullet_depth].getText().c_str());
1309 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1311 BufferParams & param = lv_->buffer()->params;
1313 param.temp_bullets[current_bullet_depth].
1314 setText(fl_get_input(bullets_->input_bullet_latex));
1318 void FormDocument::BulletDepth(FL_OBJECT * ob)
1320 /* Should I do the following: */
1321 /* 1. change to the panel that the current bullet belongs in */
1322 /* 2. show that bullet as selected */
1323 /* 3. change the size setting to the size of the bullet in Q.*/
1324 /* 4. display the latex equivalent in the latex box */
1326 /* I'm inclined to just go with 3 and 4 at the moment and */
1327 /* maybe try to support the others later */
1328 BufferParams & param = lv_->buffer()->params;
1331 if (ob == bullets_->radio_bullet_depth_1)
1333 else if (ob == bullets_->radio_bullet_depth_2)
1335 else if (ob == bullets_->radio_bullet_depth_3)
1337 else if (ob == bullets_->radio_bullet_depth_4)
1340 switch (fl_get_button_numb(ob)) {
1342 // right mouse button resets to default
1343 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1345 current_bullet_depth = data;
1346 fl_set_input(bullets_->input_bullet_latex,
1347 param.temp_bullets[data].getText().c_str());
1348 fl_set_choice(bullets_->choice_bullet_size,
1349 param.temp_bullets[data].getSize() + 2);
1354 void FormDocument::BulletPanel(FL_OBJECT * ob)
1356 /* Here we have to change the background pixmap to that selected */
1357 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1360 if (ob == bullets_->radio_bullet_panel_standard)
1362 else if (ob == bullets_->radio_bullet_panel_maths)
1364 else if (ob == bullets_->radio_bullet_panel_ding2)
1366 else if (ob == bullets_->radio_bullet_panel_ding3)
1368 else if (ob == bullets_->radio_bullet_panel_ding4)
1370 else if (ob == bullets_->radio_bullet_panel_ding1)
1373 if (data != current_bullet_panel) {
1374 fl_freeze_form(bullets_->form);
1375 current_bullet_panel = data;
1377 /* free the current pixmap */
1378 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1380 if (ob == bullets_->radio_bullet_panel_standard) {
1381 new_panel = "standard";
1382 } else if (ob == bullets_->radio_bullet_panel_maths ) {
1383 new_panel = "amssymb";
1384 } else if (ob == bullets_->radio_bullet_panel_ding2) {
1385 new_panel = "psnfss1";
1386 } else if (ob == bullets_->radio_bullet_panel_ding3) {
1387 new_panel = "psnfss2";
1388 } else if (ob == bullets_->radio_bullet_panel_ding4) {
1389 new_panel = "psnfss3";
1390 } else if (ob == bullets_->radio_bullet_panel_ding1) {
1391 new_panel = "psnfss4";
1393 /* something very wrong happened */
1394 // play it safe for now but should be an exception
1395 current_bullet_panel = 0; // standard panel
1396 new_panel = "standard";
1398 new_panel += ".xpm";
1399 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1400 LibFileSearch("images", new_panel).c_str());
1401 fl_redraw_object(bullets_->bmtable_bullet_panel);
1402 fl_unfreeze_form(bullets_->form);
1407 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1409 /* handle the user input by setting the current bullet depth's pixmap */
1410 /* to that extracted from the current chosen position of the BMTable */
1411 /* Don't forget to free the button's old pixmap first. */
1413 BufferParams & param = lv_->buffer()->params;
1414 int bmtable_button = fl_get_bmtable(ob);
1416 /* try to keep the button held down till another is pushed */
1417 /* fl_set_bmtable(ob, 1, bmtable_button); */
1418 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1419 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1420 fl_set_input(bullets_->input_bullet_latex,
1421 param.temp_bullets[current_bullet_depth].getText().c_str());
1425 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1428 ob = class_->choice_doc_class;
1430 lv_->prohibitInput();
1432 unsigned int tc = combo_doc_class->get() - 1;
1433 if (textclasslist[tc].load()) {
1434 // we use a copy of the bufferparams because we do not
1435 // want to modify them yet.
1436 BufferParams params = lv_->buffer()->params;
1438 if (lyxrc.auto_reset_options) {
1439 params.textclass = tc;
1440 params.useClassDefaults();
1441 UpdateLayoutDocument(params);
1443 // update the params which are needed in any case
1444 // (fontsizes, pagestyle)
1445 params.textclass = tc;
1446 UpdateClassParams(params);
1450 // unable to load new style
1451 Alert::alert(_("Conversion Errors!"),
1452 _("Unable to switch to new document class."),
1453 _("Reverting to original document class."));
1454 combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
1460 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1466 class_update(params);
1467 paper_update(params);
1468 language_update(params);
1469 options_update(params);
1470 bullets_update(params);