3 * See the file COPYING.
7 * Full author contact details are available in file CREDITS
12 #include FORMS_H_LOCATION
13 #include XPM_H_LOCATION
16 #pragma implementation
19 #include "FormDocument.h"
20 #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 string const bmtablefile = LibFileSearch("images", "standard", "xpm");
305 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
306 bmtablefile.c_str());
308 bc_.addReadOnly(bullets_->radio_bullet_depth_1);
309 bc_.addReadOnly(bullets_->radio_bullet_depth_2);
310 bc_.addReadOnly(bullets_->radio_bullet_depth_3);
311 bc_.addReadOnly(bullets_->radio_bullet_depth_4);
312 bc_.addReadOnly(bullets_->radio_bullet_panel_standard);
313 bc_.addReadOnly(bullets_->radio_bullet_panel_maths);
314 bc_.addReadOnly(bullets_->radio_bullet_panel_ding1);
315 bc_.addReadOnly(bullets_->radio_bullet_panel_ding2);
316 bc_.addReadOnly(bullets_->radio_bullet_panel_ding3);
317 bc_.addReadOnly(bullets_->radio_bullet_panel_ding4);
319 bc().addReadOnly (bullets_->bmtable_bullet_panel);
320 bc().addReadOnly (bullets_->choice_bullet_size);
321 bc().addReadOnly (bullets_->input_bullet_latex);
323 fl_addto_tabfolder(dialog_->tabfolder,_("Document"),
325 fl_addto_tabfolder(dialog_->tabfolder,_("Paper"),
327 fl_addto_tabfolder(dialog_->tabfolder,_("Language"),
329 fl_addto_tabfolder(dialog_->tabfolder,_("Extra"),
331 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets"),
333 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
334 lyxerr << _("Your version of libXpm is older than 4.7.\n"
335 "The `bullet' tab of the document dialog "
336 "has been disabled") << '\n';
337 fl_deactivate_object(fbullet);
338 fl_set_object_lcol(fbullet, FL_INACTIVE);
343 void FormDocument::apply()
345 if (!lv_.view()->available() || !dialog_.get())
348 bool redo = class_apply();
350 redo = language_apply() || redo;
351 redo = options_apply() || redo;
355 lv_.view()->redoCurrentBuffer();
357 lv_.buffer()->markDirty();
358 setMinibuffer(&lv_, _("Document layout set"));
362 void FormDocument::cancel()
364 // this avoids confusion when reopening
365 BufferParams & param = lv_.buffer()->params;
366 param.temp_bullets[0] = param.user_defined_bullets[0];
367 param.temp_bullets[1] = param.user_defined_bullets[1];
368 param.temp_bullets[2] = param.user_defined_bullets[2];
369 param.temp_bullets[3] = param.user_defined_bullets[3];
374 void FormDocument::update()
381 BufferParams const & params = lv_.buffer()->params;
383 class_update(params);
384 paper_update(params);
385 language_update(params);
386 options_update(params);
387 bullets_update(params);
392 // should this go elsewhere? Maybe a ControllerDocument? (JMarc)
393 /** Save the buffer's parameters as user default.
394 This function saves a file \c user_lyxdir/templates/defaults.lyx
395 which parameters are those of the current buffer. This file
396 is used as a default template when creating a new
397 file. Returns \c true on success.
399 bool saveParamsAsDefault(BufferParams const ¶ms)
401 if (!Alert::askQuestion(_("Do you want to save the current settings"),
402 _("for the document layout as default?"),
403 _("(they will be valid for any new document)")))
406 string const fname = AddName(AddPath(user_lyxdir, "templates/"),
408 Buffer defaults(fname);
409 defaults.params = params;
411 // add an empty paragraph. Is this enough?
412 defaults.paragraphs.set(new Paragraph);
414 return defaults.writeFile(defaults.fileName());
420 bool FormDocument::input(FL_OBJECT * ob, long)
422 if (ob == class_->choice_doc_class) {
423 CheckChoiceClass(ob, 0);
424 } else if (ob == bullets_->choice_bullet_size) {
425 ChoiceBulletSize(ob, 0);
426 } else if (ob == bullets_->input_bullet_latex) {
427 InputBulletLaTeX(ob, 0);
428 } else if (ob == bullets_->radio_bullet_depth_1 ||
429 ob == bullets_->radio_bullet_depth_2 ||
430 ob == bullets_->radio_bullet_depth_3 ||
431 ob == bullets_->radio_bullet_depth_4) {
433 } else if (ob == bullets_->radio_bullet_panel_standard ||
434 ob == bullets_->radio_bullet_panel_maths ||
435 ob == bullets_->radio_bullet_panel_ding1 ||
436 ob == bullets_->radio_bullet_panel_ding2 ||
437 ob == bullets_->radio_bullet_panel_ding3 ||
438 ob == bullets_->radio_bullet_panel_ding4) {
440 } else if (ob == bullets_->bmtable_bullet_panel) {
441 BulletBMTable(ob, 0);
444 bool const length_input = fl_get_choice(class_->choice_doc_skip) == 4;
445 if (ob == class_->choice_doc_skip) {
446 setEnabled(class_->input_doc_skip, length_input);
447 setEnabled(class_->choice_default_skip_units, length_input);
450 if (ob == class_->choice_doc_spacing)
451 setEnabled(class_->input_doc_spacing,
452 fl_get_choice(class_->choice_doc_spacing) == 4);
454 bool const skip_used = fl_get_button(class_->radio_doc_skip);
455 if (ob == class_->radio_doc_skip ||
456 ob == class_->radio_doc_indent) {
457 setEnabled(class_->choice_doc_skip, skip_used);
458 setEnabled(class_->input_doc_skip,
459 skip_used && length_input);
460 setEnabled(class_->choice_default_skip_units,
461 skip_used && length_input);
462 // Default unit choice is cm if metric, inches if US paper.
463 // If papersize is default, check the lyxrc-settings
464 int const paperchoice = fl_get_choice(paper_->choice_papersize);
465 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
466 || paperchoice == 2 || paperchoice > 5;
467 int const default_unit = metric ? 8 : 9;
468 if (rtrim(fl_get_input(class_->input_doc_skip)).empty())
469 fl_set_choice(class_->choice_default_skip_units,
473 if (ob == options_->check_use_natbib) {
474 setEnabled(options_->choice_citation_format,
475 fl_get_button(options_->check_use_natbib));
478 if (ob == dialog_->button_save_defaults) {
482 language_apply(params);
483 options_apply(params);
484 bullets_apply(params);
485 params.preamble = lv_.buffer()->params.preamble;
486 saveParamsAsDefault(params);
489 if (ob == dialog_->button_reset_defaults) {
490 BufferParams params = lv_.buffer()->params;
491 params.textclass = combo_doc_class->get() - 1;
492 params.useClassDefaults();
493 UpdateLayoutDocument(params);
496 if (ob == paper_->radio_landscape)
497 fl_set_choice(paper_->choice_paperpackage,
498 BufferParams::PACKAGE_NONE + 1);
500 if (ob == paper_->choice_papersize) {
501 int const paperchoice = fl_get_choice(paper_->choice_papersize);
502 bool const defsize = paperchoice == 1;
503 bool const custom = paperchoice == 2;
504 bool const a3size = paperchoice == 6;
505 bool const b3size = paperchoice == 9;
506 bool const b4size = paperchoice == 10;
509 fl_set_button(paper_->radio_portrait, 1);
511 bool const use_geom = (custom || a3size || b3size || b4size);
513 fl_set_button(paper_->check_use_geometry, int(use_geom));
515 setEnabled(paper_->input_top_margin, use_geom);
516 setEnabled(paper_->input_bottom_margin, use_geom);
517 setEnabled(paper_->input_inner_margin, use_geom);
518 setEnabled(paper_->input_outer_margin, use_geom);
519 setEnabled(paper_->input_head_height, use_geom);
520 setEnabled(paper_->input_head_sep, use_geom);
521 setEnabled(paper_->input_foot_skip, use_geom);
522 setEnabled(paper_->choice_top_margin_units, use_geom);
523 setEnabled(paper_->choice_bottom_margin_units, use_geom);
524 setEnabled(paper_->choice_inner_margin_units, use_geom);
525 setEnabled(paper_->choice_outer_margin_units, use_geom);
526 setEnabled(paper_->choice_head_height_units, use_geom);
527 setEnabled(paper_->choice_head_sep_units, use_geom);
528 setEnabled(paper_->choice_foot_skip_units, use_geom);
529 setEnabled(paper_->choice_custom_width_units, use_geom);
530 setEnabled(paper_->choice_custom_height_units, use_geom);
532 setEnabled(paper_->input_custom_width, custom);
533 setEnabled(paper_->input_custom_height, custom);
534 setEnabled(paper_->choice_custom_width_units, custom);
535 setEnabled(paper_->choice_custom_height_units, custom);
536 setEnabled(paper_->radio_portrait, !custom);
537 setEnabled(paper_->radio_landscape, !custom);
539 // Default unit choice is cm if metric, inches if US paper.
540 // If papersize is default, use the lyxrc-settings
541 bool const metric = (defsize && lyxrc.default_papersize > 3)
542 || paperchoice == 2 || paperchoice > 5;
543 int const default_unit = metric ? 8 : 9;
544 if (rtrim(fl_get_input(paper_->input_custom_width)).empty())
545 fl_set_choice(paper_->choice_custom_width_units,
547 if (rtrim(fl_get_input(paper_->input_custom_height)).empty())
548 fl_set_choice(paper_->choice_custom_height_units,
550 if (rtrim(fl_get_input(paper_->input_top_margin)).empty())
551 fl_set_choice(paper_->choice_top_margin_units,
553 if (rtrim(fl_get_input(paper_->input_bottom_margin)).empty())
554 fl_set_choice(paper_->choice_bottom_margin_units,
556 if (rtrim(fl_get_input(paper_->input_inner_margin)).empty())
557 fl_set_choice(paper_->choice_inner_margin_units,
559 if (rtrim(fl_get_input(paper_->input_outer_margin)).empty())
560 fl_set_choice(paper_->choice_outer_margin_units,
562 if (rtrim(fl_get_input(paper_->input_head_height)).empty())
563 fl_set_choice(paper_->choice_head_height_units,
565 if (rtrim(fl_get_input(paper_->input_head_sep)).empty())
566 fl_set_choice(paper_->choice_head_sep_units,
568 if (rtrim(fl_get_input(paper_->input_foot_skip)).empty())
569 fl_set_choice(paper_->choice_foot_skip_units,
573 if (ob == paper_->choice_papersize ||
574 ob == paper_->radio_portrait ||
575 ob == paper_->radio_landscape) {
577 setEnabled(paper_->choice_paperpackage,
578 //either default papersize (preferences)
579 //or document papersize has to be A4
580 (fl_get_choice(paper_->choice_papersize) == 7
581 || fl_get_choice(paper_->choice_papersize) == 1
582 && lyxrc.default_papersize == 5)
583 && fl_get_button(paper_->radio_portrait));
586 if (ob == paper_->choice_paperpackage) {
587 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
588 fl_set_button(paper_->check_use_geometry, 0);
590 setEnabled(paper_->input_top_margin, false);
591 setEnabled(paper_->input_bottom_margin, false);
592 setEnabled(paper_->input_inner_margin, false);
593 setEnabled(paper_->input_outer_margin, false);
594 setEnabled(paper_->input_head_height, false);
595 setEnabled(paper_->input_head_sep, false);
596 setEnabled(paper_->input_foot_skip, false);
597 setEnabled(paper_->choice_top_margin_units, false);
598 setEnabled(paper_->choice_bottom_margin_units, false);
599 setEnabled(paper_->choice_inner_margin_units, false);
600 setEnabled(paper_->choice_outer_margin_units, false);
601 setEnabled(paper_->choice_head_height_units, false);
602 setEnabled(paper_->choice_head_sep_units, false);
603 setEnabled(paper_->choice_foot_skip_units, false);
607 if (ob == paper_->check_use_geometry) {
608 //don't allow switching geometry off in custom papersize mode
609 //nor in A3, B3, and B4
610 int const choice = fl_get_choice(paper_->choice_papersize);
611 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
612 fl_set_button(paper_->check_use_geometry, 1);
614 fl_set_choice(paper_->choice_paperpackage,
615 BufferParams::PACKAGE_NONE + 1);
617 bool const use_geom = fl_get_button(paper_->check_use_geometry);
618 setEnabled(paper_->input_top_margin, use_geom);
619 setEnabled(paper_->input_bottom_margin, use_geom);
620 setEnabled(paper_->input_inner_margin, use_geom);
621 setEnabled(paper_->input_outer_margin, use_geom);
622 setEnabled(paper_->input_head_height, use_geom);
623 setEnabled(paper_->input_head_sep, use_geom);
624 setEnabled(paper_->input_foot_skip, use_geom);
625 setEnabled(paper_->choice_top_margin_units, use_geom);
626 setEnabled(paper_->choice_bottom_margin_units, use_geom);
627 setEnabled(paper_->choice_inner_margin_units, use_geom);
628 setEnabled(paper_->choice_outer_margin_units, use_geom);
629 setEnabled(paper_->choice_head_height_units, use_geom);
630 setEnabled(paper_->choice_head_sep_units, use_geom);
631 setEnabled(paper_->choice_foot_skip_units, use_geom);
634 return CheckDocumentInput(ob, 0);
638 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
640 FormDocument * pre = static_cast<FormDocument*>(v);
641 if (combox == pre->combo_doc_class.get())
642 pre->CheckChoiceClass(0, 0);
643 pre->bc().valid(pre->CheckDocumentInput(0,0));
647 bool FormDocument::class_apply(BufferParams ¶ms)
651 // If default skip is a "Length" but there's no text in the
652 // input field, reset the kind to "Medskip", which is the default.
653 if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
654 !*(fl_get_input (class_->input_doc_skip))) {
655 fl_set_choice (class_->choice_doc_skip, 2);
657 params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
658 params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
659 params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
661 params.textclass = combo_doc_class->get() - 1;
663 BufferParams::PARSEP tmpsep = params.paragraph_separation;
664 if (fl_get_button(class_->radio_doc_indent))
665 params.paragraph_separation = BufferParams::PARSEP_INDENT;
667 params.paragraph_separation = BufferParams::PARSEP_SKIP;
668 if (tmpsep != params.paragraph_separation)
671 VSpace tmpdefskip = params.getDefSkip();
672 switch (fl_get_choice (class_->choice_doc_skip)) {
674 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
677 params.setDefSkip(VSpace(VSpace::MEDSKIP));
680 params.setDefSkip(VSpace(VSpace::BIGSKIP));
684 string const length =
685 getLengthFromWidgets(class_->input_doc_skip,
686 class_->choice_default_skip_units);
688 params.setDefSkip(VSpace(LyXGlueLength(length)));
692 // DocumentDefskipCB assures that this never happens
693 params.setDefSkip(VSpace(VSpace::MEDSKIP));
696 if (!(tmpdefskip == params.getDefSkip()))
699 if (fl_get_button(class_->radio_doc_columns_two))
703 if (fl_get_button(class_->radio_doc_sides_two))
704 params.sides = LyXTextClass::TwoSides;
706 params.sides = LyXTextClass::OneSide;
708 Spacing tmpSpacing = params.spacing;
709 switch (fl_get_choice(class_->choice_doc_spacing)) {
711 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
712 params.spacing.set(Spacing::Single);
715 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
716 params.spacing.set(Spacing::Onehalf);
719 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
720 params.spacing.set(Spacing::Double);
723 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
724 params.spacing.set(Spacing::Other,
725 fl_get_input(class_->input_doc_spacing));
728 if (tmpSpacing != params.spacing)
731 params.options = fl_get_input(class_->input_doc_extra);
737 bool FormDocument::class_apply()
739 BufferParams ¶ms = lv_.buffer()->params;
741 unsigned int const old_class = params.textclass;
743 bool redo = class_apply(params);
745 if (params.textclass != old_class) {
746 // try to load new_class
747 if (textclasslist[params.textclass].load()) {
748 // successfully loaded
750 setMinibuffer(&lv_, _("Converting document to new document class..."));
751 int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
752 old_class, params.textclass,
753 &*(lv_.buffer()->paragraphs.begin()),
754 lv_.buffer()->params);
758 s = _("One paragraph couldn't be converted");
761 s += _(" paragraphs couldn't be converted");
763 Alert::alert(_("Conversion Errors!"),s,
764 _("into chosen document class"));
768 // problem changing class -- warn user and retain old style
769 Alert::alert(_("Conversion Errors!"),
770 _("Errors loading new document class."),
771 _("Reverting to original document class."));
772 combo_doc_class->select(int(old_class) + 1);
780 void FormDocument::paper_apply(BufferParams & params)
782 params.papersize2 = char(fl_get_choice(paper_->choice_papersize) - 1);
784 params.paperpackage =
785 char(fl_get_choice(paper_->choice_paperpackage) - 1);
787 // set params.papersize from params.papersize2 and params.paperpackage
788 params.setPaperStuff();
790 params.use_geometry = fl_get_button(paper_->check_use_geometry);
792 if (fl_get_button(paper_->radio_landscape))
793 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
795 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
798 getLengthFromWidgets(paper_->input_custom_width,
799 paper_->choice_custom_width_units);
802 getLengthFromWidgets(paper_->input_custom_height,
803 paper_->choice_custom_height_units);
806 getLengthFromWidgets(paper_->input_inner_margin,
807 paper_->choice_inner_margin_units);
810 getLengthFromWidgets(paper_->input_top_margin,
811 paper_->choice_top_margin_units);
814 getLengthFromWidgets(paper_->input_outer_margin,
815 paper_->choice_outer_margin_units);
817 params.bottommargin =
818 getLengthFromWidgets(paper_->input_bottom_margin,
819 paper_->choice_bottom_margin_units);
822 getLengthFromWidgets(paper_->input_head_height,
823 paper_->choice_head_height_units);
826 getLengthFromWidgets(paper_->input_head_sep,
827 paper_->choice_head_sep_units);
830 getLengthFromWidgets(paper_->input_foot_skip,
831 paper_->choice_foot_skip_units);
835 void FormDocument::paper_apply()
837 paper_apply(lv_.buffer()->params);
841 bool FormDocument::language_apply(BufferParams & params)
843 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
846 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
848 lga = InsetQuotes::EnglishQ;
851 lga = InsetQuotes::SwedishQ;
854 lga = InsetQuotes::GermanQ;
857 lga = InsetQuotes::PolishQ;
860 lga = InsetQuotes::FrenchQ;
863 lga = InsetQuotes::DanishQ;
866 params.quotes_language = lga;
867 if (fl_get_button(language_->radio_single))
868 params.quotes_times = InsetQuotes::SingleQ;
870 params.quotes_times = InsetQuotes::DoubleQ;
872 int const pos = combo_language->get();
873 Language const * old_language = params.language;
874 Language const * new_language = languages.getLanguage(lang_[pos-1]);
876 new_language = default_language;
878 if (old_language != new_language
879 && old_language->RightToLeft() == new_language->RightToLeft()
880 && !lv_.buffer()->isMultiLingual())
881 lv_.buffer()->changeLanguage(old_language, new_language);
883 if (old_language != new_language) {
887 params.language = new_language;
888 params.inputenc = fl_get_choice_text(language_->choice_inputenc);
894 bool FormDocument::language_apply()
896 return language_apply(lv_.buffer()->params);
900 bool FormDocument::options_apply(BufferParams & params)
904 params.graphicsDriver =
905 fl_get_choice_text(options_->choice_postscript_driver);
906 params.use_amsmath = fl_get_button(options_->check_use_amsmath);
907 params.use_natbib = fl_get_button(options_->check_use_natbib);
908 params.use_numerical_citations =
909 fl_get_choice(options_->choice_citation_format) - 1;
911 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
912 if (params.secnumdepth != tmpchar)
914 params.secnumdepth = tmpchar;
916 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
918 params.float_placement =
919 fl_get_input(options_->input_float_placement);
925 bool FormDocument::options_apply()
927 return options_apply(lv_.buffer()->params);
931 void FormDocument::bullets_apply(BufferParams & params)
933 /* update the bullet settings */
934 BufferParams & buf_params = lv_.buffer()->params;
936 // a little bit of loop unrolling
937 params.user_defined_bullets[0] = buf_params.temp_bullets[0];
938 params.user_defined_bullets[1] = buf_params.temp_bullets[1];
939 params.user_defined_bullets[2] = buf_params.temp_bullets[2];
940 params.user_defined_bullets[3] = buf_params.temp_bullets[3];
944 void FormDocument::bullets_apply()
946 bullets_apply(lv_.buffer()->params);
949 void FormDocument::UpdateClassParams(BufferParams const & params)
951 // These are the params that have to be updated on any class change
952 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
954 LyXTextClass const & tclass = textclasslist[params.textclass];
956 combo_doc_class->select(tclass.description());
957 fl_clear_choice(class_->choice_doc_fontsize);
958 fl_addto_choice(class_->choice_doc_fontsize, "default");
959 fl_addto_choice(class_->choice_doc_fontsize,
960 tclass.opt_fontsize().c_str());
961 fl_set_choice_text(class_->choice_doc_fontsize,
962 params.fontsize.c_str());
963 fl_clear_choice(class_->choice_doc_pagestyle);
964 fl_addto_choice(class_->choice_doc_pagestyle, "default");
965 fl_addto_choice(class_->choice_doc_pagestyle,
966 tclass.opt_pagestyle().c_str());
967 fl_set_choice_text(class_->choice_doc_pagestyle,
968 params.pagestyle.c_str());
972 void FormDocument::class_update(BufferParams const & params)
977 UpdateClassParams(params);
979 fl_set_choice_text(class_->choice_doc_fonts,
980 params.fonts.c_str());
981 fl_set_button(class_->radio_doc_indent, 0);
982 fl_set_button(class_->radio_doc_skip, 0);
983 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
984 fl_set_button(class_->radio_doc_indent, 1);
986 fl_set_button(class_->radio_doc_skip, 1);
988 bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
989 setEnabled(class_->choice_default_skip_units, input_length);
990 setEnabled(class_->input_doc_skip, input_length);
992 switch (params.getDefSkip().kind()) {
993 case VSpace::SMALLSKIP:
994 fl_set_choice (class_->choice_doc_skip, 1);
996 case VSpace::MEDSKIP:
997 fl_set_choice (class_->choice_doc_skip, 2);
999 case VSpace::BIGSKIP:
1000 fl_set_choice (class_->choice_doc_skip, 3);
1002 case VSpace::LENGTH:
1004 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1005 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1006 || paperchoice == 2 || paperchoice > 5;
1007 string const default_unit = metric ? "cm" : "in";
1008 string const length = params.getDefSkip().asLyXCommand();
1009 updateWidgetsFromLengthString(class_->input_doc_skip,
1010 class_->choice_default_skip_units,
1011 length, default_unit);
1015 fl_set_choice (class_->choice_doc_skip, 2);
1018 fl_set_button(class_->radio_doc_sides_one, 0);
1019 fl_set_button(class_->radio_doc_sides_two, 0);
1020 setEnabled(class_->choice_doc_skip,
1021 fl_get_button(class_->radio_doc_skip));
1023 if (params.sides == LyXTextClass::TwoSides)
1024 fl_set_button(class_->radio_doc_sides_two, 1);
1026 fl_set_button(class_->radio_doc_sides_one, 1);
1027 fl_set_button(class_->radio_doc_columns_one, 0);
1028 fl_set_button(class_->radio_doc_columns_two, 0);
1029 if (params.columns == 2)
1030 fl_set_button(class_->radio_doc_columns_two, 1);
1032 fl_set_button(class_->radio_doc_columns_one, 1);
1034 fl_set_input(class_->input_doc_spacing, "");
1035 setEnabled(class_->input_doc_spacing, false);
1037 switch (params.spacing.getSpace()) {
1038 case Spacing::Default: // nothing bad should happen with this
1039 case Spacing::Single:
1041 fl_set_choice(class_->choice_doc_spacing, 1);
1043 case Spacing::Onehalf:
1045 fl_set_choice(class_->choice_doc_spacing, 2);
1047 case Spacing::Double:
1049 fl_set_choice(class_->choice_doc_spacing, 3);
1051 case Spacing::Other:
1053 fl_set_choice(class_->choice_doc_spacing, 4);
1055 sprintf(sval,"%g",params.spacing.getValue());
1056 fl_set_input(class_->input_doc_spacing, sval);
1057 setEnabled(class_->input_doc_spacing, true);
1061 if (!params.options.empty())
1062 fl_set_input(class_->input_doc_extra, params.options.c_str());
1064 fl_set_input(class_->input_doc_extra, "");
1068 void FormDocument::language_update(BufferParams const & params)
1070 if (!language_.get())
1073 int const pos = int(findPos(lang_, params.language->lang()));
1074 combo_language->select(pos+1);
1076 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1077 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1078 fl_set_button(language_->radio_single, 0);
1079 fl_set_button(language_->radio_double, 0);
1080 if (params.quotes_times == InsetQuotes::SingleQ)
1081 fl_set_button(language_->radio_single, 1);
1083 fl_set_button(language_->radio_double, 1);
1087 void FormDocument::options_update(BufferParams const & params)
1089 if (!options_.get())
1092 fl_set_choice_text(options_->choice_postscript_driver,
1093 params.graphicsDriver.c_str());
1094 fl_set_button(options_->check_use_amsmath, params.use_amsmath);
1095 fl_set_button(options_->check_use_natbib, params.use_natbib);
1096 fl_set_choice(options_->choice_citation_format,
1097 int(params.use_numerical_citations)+1);
1098 setEnabled(options_->choice_citation_format, params.use_natbib);
1099 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1100 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1101 if (!params.float_placement.empty())
1102 fl_set_input(options_->input_float_placement,
1103 params.float_placement.c_str());
1105 fl_set_input(options_->input_float_placement, "");
1109 void FormDocument::paper_update(BufferParams const & params)
1114 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1115 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1116 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1118 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1119 bool const useCustom = paperchoice == 2;
1120 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1122 fl_set_button(paper_->radio_portrait, 0);
1123 setEnabled(paper_->radio_portrait, !useCustom);
1124 fl_set_button(paper_->radio_landscape, 0);
1125 setEnabled(paper_->radio_landscape, !useCustom);
1127 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
1128 fl_set_button(paper_->radio_landscape, 1);
1130 fl_set_button(paper_->radio_portrait, 1);
1131 setEnabled(paper_->choice_paperpackage,
1132 //either default papersize (preferences)
1133 //or document papersize has to be A4
1135 || paperchoice == 1 && lyxrc.default_papersize == 5)
1136 && fl_get_button(paper_->radio_portrait));
1138 // Default unit choice is cm if metric, inches if US paper.
1139 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1140 || paperchoice == 2 || paperchoice > 5;
1141 string const default_unit = metric ? "cm" : "in";
1142 updateWidgetsFromLengthString(paper_->input_custom_width,
1143 paper_->choice_custom_width_units,
1144 params.paperwidth, default_unit);
1145 setEnabled(paper_->input_custom_width, useCustom);
1146 setEnabled(paper_->choice_custom_width_units, useCustom);
1148 updateWidgetsFromLengthString(paper_->input_custom_height,
1149 paper_->choice_custom_height_units,
1150 params.paperheight, default_unit);
1151 setEnabled(paper_->input_custom_height, useCustom);
1152 setEnabled(paper_->choice_custom_height_units, useCustom);
1154 updateWidgetsFromLengthString(paper_->input_inner_margin,
1155 paper_->choice_inner_margin_units,
1156 params.leftmargin, default_unit);
1157 setEnabled(paper_->input_inner_margin, useGeom);
1158 setEnabled(paper_->choice_inner_margin_units, useGeom);
1160 updateWidgetsFromLengthString(paper_->input_top_margin,
1161 paper_->choice_top_margin_units,
1162 params.topmargin, default_unit);
1163 setEnabled(paper_->input_top_margin, useGeom);
1164 setEnabled(paper_->choice_top_margin_units, useGeom);
1166 updateWidgetsFromLengthString(paper_->input_outer_margin,
1167 paper_->choice_outer_margin_units,
1168 params.rightmargin, default_unit);
1169 setEnabled(paper_->input_outer_margin, useGeom);
1170 setEnabled(paper_->choice_outer_margin_units, useGeom);
1172 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1173 paper_->choice_bottom_margin_units,
1174 params.bottommargin, default_unit);
1175 setEnabled(paper_->input_bottom_margin, useGeom);
1176 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1178 updateWidgetsFromLengthString(paper_->input_head_height,
1179 paper_->choice_head_height_units,
1180 params.headheight, default_unit);
1181 setEnabled(paper_->input_head_height, useGeom);
1182 setEnabled(paper_->choice_head_height_units, useGeom);
1184 updateWidgetsFromLengthString(paper_->input_head_sep,
1185 paper_->choice_head_sep_units,
1186 params.headsep, default_unit);
1187 setEnabled(paper_->input_head_sep, useGeom);
1188 setEnabled(paper_->choice_head_sep_units, useGeom);
1190 updateWidgetsFromLengthString(paper_->input_foot_skip,
1191 paper_->choice_foot_skip_units,
1192 params.footskip, default_unit);
1193 setEnabled(paper_->input_foot_skip, useGeom);
1194 setEnabled(paper_->choice_foot_skip_units, useGeom);
1196 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1200 void FormDocument::bullets_update(BufferParams const & params)
1202 if (!bullets_.get() ||
1204 (XpmVersion==4 && XpmRevision<7)))
1207 bool const isLinuxDoc = lv_.buffer()->isLinuxDoc();
1208 setEnabled(fbullet, !isLinuxDoc);
1210 if (isLinuxDoc) return;
1212 fl_set_button(bullets_->radio_bullet_depth_1, 1);
1213 fl_set_input(bullets_->input_bullet_latex,
1214 params.user_defined_bullets[0].getText().c_str());
1215 fl_set_choice(bullets_->choice_bullet_size,
1216 params.user_defined_bullets[0].getSize() + 2);
1220 void FormDocument::checkReadOnly()
1222 if (bc().readOnly(lv_.buffer()->isReadonly())) {
1223 combo_doc_class->deactivate();
1224 combo_language->deactivate();
1225 postWarning(_("Document is read-only."
1226 " No changes to layout permitted."));
1228 combo_doc_class->activate();
1229 combo_language->activate();
1235 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
1241 // this has to be all out of if/elseif because it has to deactivate
1242 // the document buttons and so the whole stuff has to be tested again.
1243 // disable OK/Apply if input is not valid
1244 str = fl_get_input(class_->input_doc_skip);
1245 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1246 str = fl_get_input(paper_->input_custom_width);
1247 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1248 str = fl_get_input(paper_->input_custom_height);
1249 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1250 str = fl_get_input(paper_->input_outer_margin);
1251 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1252 str = fl_get_input(paper_->input_inner_margin);
1253 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1254 str = fl_get_input(paper_->input_top_margin);
1255 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1256 str = fl_get_input(paper_->input_bottom_margin);
1257 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1258 str = fl_get_input(paper_->input_head_height);
1259 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1260 str = fl_get_input(paper_->input_head_sep);
1261 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1262 str = fl_get_input(paper_->input_foot_skip);
1263 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1265 //display warning if input is not valid
1266 if (ob == class_->input_doc_skip
1267 || ob == paper_->input_custom_width
1268 || ob == paper_->input_custom_height
1269 || ob == paper_->input_outer_margin
1270 || ob == paper_->input_inner_margin
1271 || ob == paper_->input_top_margin
1272 || ob == paper_->input_bottom_margin
1273 || ob == paper_->input_head_height
1274 || ob == paper_->input_head_sep
1275 || ob == paper_->input_foot_skip) {
1277 postWarning(_("Invalid Length (valid example: 10mm)"));
1285 // "Synchronize" the choice and the input field, so that it
1286 // is impossible to commit senseless data.
1287 input = fl_get_input (class_->input_doc_skip);
1288 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1290 else if (fl_get_choice(class_->choice_doc_skip) != 4)
1291 fl_set_input (class_->input_doc_skip, "");
1293 input = fl_get_input(class_->input_doc_spacing);
1294 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1296 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
1297 fl_set_input (class_->input_doc_spacing, "");
1302 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1304 BufferParams & param = lv_.buffer()->params;
1306 // convert from 1-6 range to -1-4
1307 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1308 fl_set_input(bullets_->input_bullet_latex,
1309 param.temp_bullets[current_bullet_depth].getText().c_str());
1313 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1315 BufferParams & param = lv_.buffer()->params;
1317 param.temp_bullets[current_bullet_depth].
1318 setText(fl_get_input(bullets_->input_bullet_latex));
1322 void FormDocument::BulletDepth(FL_OBJECT * ob)
1324 /* Should I do the following: */
1325 /* 1. change to the panel that the current bullet belongs in */
1326 /* 2. show that bullet as selected */
1327 /* 3. change the size setting to the size of the bullet in Q.*/
1328 /* 4. display the latex equivalent in the latex box */
1330 /* I'm inclined to just go with 3 and 4 at the moment and */
1331 /* maybe try to support the others later */
1332 BufferParams & param = lv_.buffer()->params;
1335 if (ob == bullets_->radio_bullet_depth_1)
1337 else if (ob == bullets_->radio_bullet_depth_2)
1339 else if (ob == bullets_->radio_bullet_depth_3)
1341 else if (ob == bullets_->radio_bullet_depth_4)
1344 switch (fl_get_button_numb(ob)) {
1346 // right mouse button resets to default
1347 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1349 current_bullet_depth = data;
1350 fl_set_input(bullets_->input_bullet_latex,
1351 param.temp_bullets[data].getText().c_str());
1352 fl_set_choice(bullets_->choice_bullet_size,
1353 param.temp_bullets[data].getSize() + 2);
1358 void FormDocument::BulletPanel(FL_OBJECT * ob)
1360 /* Here we have to change the background pixmap to that selected */
1361 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1364 if (ob == bullets_->radio_bullet_panel_standard)
1366 else if (ob == bullets_->radio_bullet_panel_maths)
1368 else if (ob == bullets_->radio_bullet_panel_ding2)
1370 else if (ob == bullets_->radio_bullet_panel_ding3)
1372 else if (ob == bullets_->radio_bullet_panel_ding4)
1374 else if (ob == bullets_->radio_bullet_panel_ding1)
1377 if (data != current_bullet_panel) {
1378 fl_freeze_form(bullets_->form);
1379 current_bullet_panel = data;
1381 /* free the current pixmap */
1382 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1384 if (ob == bullets_->radio_bullet_panel_standard) {
1385 new_panel = "standard";
1386 } else if (ob == bullets_->radio_bullet_panel_maths ) {
1387 new_panel = "amssymb";
1388 } else if (ob == bullets_->radio_bullet_panel_ding2) {
1389 new_panel = "psnfss1";
1390 } else if (ob == bullets_->radio_bullet_panel_ding3) {
1391 new_panel = "psnfss2";
1392 } else if (ob == bullets_->radio_bullet_panel_ding4) {
1393 new_panel = "psnfss3";
1394 } else if (ob == bullets_->radio_bullet_panel_ding1) {
1395 new_panel = "psnfss4";
1397 /* something very wrong happened */
1398 // play it safe for now but should be an exception
1399 current_bullet_panel = 0; // standard panel
1400 new_panel = "standard";
1402 new_panel += ".xpm";
1403 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1404 LibFileSearch("images", new_panel).c_str());
1405 fl_redraw_object(bullets_->bmtable_bullet_panel);
1406 fl_unfreeze_form(bullets_->form);
1411 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1413 /* handle the user input by setting the current bullet depth's pixmap */
1414 /* to that extracted from the current chosen position of the BMTable */
1415 /* Don't forget to free the button's old pixmap first. */
1417 BufferParams & param = lv_.buffer()->params;
1418 int bmtable_button = fl_get_bmtable(ob);
1420 /* try to keep the button held down till another is pushed */
1421 /* fl_set_bmtable(ob, 1, bmtable_button); */
1422 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1423 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1424 fl_set_input(bullets_->input_bullet_latex,
1425 param.temp_bullets[current_bullet_depth].getText().c_str());
1429 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1432 ob = class_->choice_doc_class;
1434 lv_.prohibitInput();
1436 unsigned int tc = combo_doc_class->get() - 1;
1437 if (textclasslist[tc].load()) {
1438 // we use a copy of the bufferparams because we do not
1439 // want to modify them yet.
1440 BufferParams params = lv_.buffer()->params;
1442 if (lyxrc.auto_reset_options) {
1443 params.textclass = tc;
1444 params.useClassDefaults();
1445 UpdateLayoutDocument(params);
1447 // update the params which are needed in any case
1448 // (fontsizes, pagestyle)
1449 params.textclass = tc;
1450 UpdateClassParams(params);
1454 // unable to load new style
1455 Alert::alert(_("Conversion Errors!"),
1456 _("Unable to switch to new document class."),
1457 _("Reverting to original document class."));
1458 combo_doc_class->select(int(lv_.buffer()->params.textclass) + 1);
1464 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1470 class_update(params);
1471 paper_update(params);
1472 language_update(params);
1473 options_update(params);
1474 bullets_update(params);