3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
13 #include FORMS_H_LOCATION
14 #include XPM_H_LOCATION
17 #pragma implementation
20 #include "FormDocument.h"
21 #include "forms/form_document.h"
23 #include "lyxtextclasslist.h"
25 #include "tex-strings.h"
26 #include "bufferparams.h"
30 #include "frnt_lang.h"
31 #include "frontends/LyXView.h"
34 #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>
59 FormDocument::FormDocument(LyXView & lv, Dialogs & d)
60 : FormBaseBD(lv, d, _("Document Layout")),
61 ActCell(0), Confirmed(0),
62 current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
67 void FormDocument::redraw()
69 if (form() && form()->visible)
70 fl_redraw_form(form());
74 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
75 if (outer_form && outer_form->visible)
76 fl_redraw_form(outer_form);
80 FL_FORM * FormDocument::form() const
82 if (dialog_.get()) return dialog_->form;
87 void FormDocument::build()
92 dialog_.reset(build_document(this));
94 // Allow the base class to control messages
95 setMessageWidget(dialog_->text_warning);
97 // Manage the restore, ok, apply, restore and cancel/close buttons
98 bc().setOK(dialog_->button_ok);
99 bc().setApply(dialog_->button_apply);
100 bc().setCancel(dialog_->button_close);
101 bc().setRestore(dialog_->button_restore);
102 bc().addReadOnly (dialog_->button_save_defaults);
103 bc().addReadOnly (dialog_->button_reset_defaults);
105 // the document paper form
106 paper_.reset(build_document_paper(this));
107 fl_addto_choice(paper_->choice_papersize,
108 _(" Default | Custom | US letter | US legal "
109 "| US executive | A3 | A4 | A5 | B3 | B4 | B5 "));
110 fl_addto_choice(paper_->choice_paperpackage,
113 "| Very small Margins "
114 "| Very wide Margins "));
116 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
117 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
118 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
119 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
120 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
121 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
122 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
123 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
124 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
126 setPrehandler(paper_->input_custom_width);
127 setPrehandler(paper_->input_custom_height);
128 setPrehandler(paper_->input_top_margin);
129 setPrehandler(paper_->input_bottom_margin);
130 setPrehandler(paper_->input_inner_margin);
131 setPrehandler(paper_->input_outer_margin);
132 setPrehandler(paper_->input_head_height);
133 setPrehandler(paper_->input_head_sep);
134 setPrehandler(paper_->input_foot_skip);
136 // Create the contents of the unit choices
137 // Don't include the "%" terms...
138 vector<string> units_vec = getLatexUnits();
139 vector<string>::iterator ret =
140 std::remove_if(units_vec.begin(),
142 bind2nd(contains_functor(), "%"));
143 units_vec.erase(ret, units_vec.end());
145 string units = getStringFromVector(units_vec, "|");
147 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
148 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
149 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
150 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
151 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
152 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
153 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
154 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
155 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
157 bc().addReadOnly (paper_->choice_paperpackage);
158 bc().addReadOnly (paper_->radio_portrait);
159 bc().addReadOnly (paper_->radio_landscape);
160 bc().addReadOnly (paper_->choice_papersize);
161 bc().addReadOnly (paper_->check_use_geometry);
162 bc().addReadOnly (paper_->input_custom_width);
163 bc().addReadOnly (paper_->input_custom_height);
164 bc().addReadOnly (paper_->input_top_margin);
165 bc().addReadOnly (paper_->input_bottom_margin);
166 bc().addReadOnly (paper_->input_inner_margin);
167 bc().addReadOnly (paper_->input_outer_margin);
168 bc().addReadOnly (paper_->input_head_height);
169 bc().addReadOnly (paper_->input_head_sep);
170 bc().addReadOnly (paper_->input_foot_skip);
172 // the document class form
173 class_.reset(build_document_class(this));
176 // The language is a combo-box and has to be inserted manually
177 obj = class_->choice_doc_class;
178 fl_deactivate_object(obj);
179 fl_addto_form(class_->form);
180 combo_doc_class.reset(new Combox(FL_COMBOX_DROPLIST));
181 combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400);
182 combo_doc_class->shortcut("#C",1);
183 combo_doc_class->setcallback(ComboInputCB, this);
185 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
186 cit != textclasslist.end(); ++cit) {
187 combo_doc_class->addto(cit->description());
190 fl_addto_choice(class_->choice_doc_spacing,
191 _(" Single | OneHalf | Double | Custom "));
192 fl_addto_choice(class_->choice_doc_fontsize, "default|10|11|12");
193 for (n=0; tex_fonts[n][0]; ++n) {
194 fl_addto_choice(class_->choice_doc_fonts,tex_fonts[n]);
196 fl_addto_choice(class_->choice_doc_pagestyle,
197 "default|empty|plain|headings|fancy");
198 fl_addto_choice(class_->choice_doc_skip,
199 _(" Smallskip | Medskip | Bigskip | Length "));
200 fl_addto_choice(class_->choice_default_skip_units, units.c_str());
201 fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
202 fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
203 fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
205 setPrehandler(class_->input_doc_extra);
206 setPrehandler(class_->input_doc_skip);
207 setPrehandler(class_->input_doc_spacing);
209 // Set input filters on doc spacing to make it accept only
211 fl_set_input_filter(class_->input_doc_spacing, fl_unsigned_float_filter);
213 bc().addReadOnly (class_->radio_doc_indent);
214 bc().addReadOnly (class_->radio_doc_skip);
216 bc().addReadOnly (class_->choice_doc_pagestyle);
217 bc().addReadOnly (class_->choice_doc_fonts);
218 bc().addReadOnly (class_->choice_doc_fontsize);
219 bc().addReadOnly (class_->radio_doc_sides_one);
220 bc().addReadOnly (class_->radio_doc_sides_two);
221 bc().addReadOnly (class_->radio_doc_columns_one);
222 bc().addReadOnly (class_->radio_doc_columns_two);
223 bc().addReadOnly (class_->input_doc_extra);
224 bc().addReadOnly (class_->input_doc_skip);
225 bc().addReadOnly (class_->choice_doc_skip);
226 bc().addReadOnly (class_->choice_doc_spacing);
227 bc().addReadOnly (class_->input_doc_spacing);
229 // the document language form
230 language_.reset(build_document_language(this));
231 fl_addto_choice(language_->choice_inputenc,
232 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
233 "|koi8-r|koi8-u|cp866|cp1251|iso88595|pt154");
235 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
236 // Store the identifiers for later
237 lang_ = getSecond(langs);
239 // The language is a combo-box and has to be inserted manually
240 obj = language_->choice_language;
241 fl_deactivate_object(obj);
242 fl_addto_form(language_->form);
243 combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
244 combo_language->add(obj->x, obj->y, obj->w, obj->h, 400);
245 combo_language->shortcut("#L",1);
246 combo_language->setcallback(ComboInputCB, this);
249 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
250 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
251 for (; lit != lend; ++lit) {
252 combo_language->addto(lit->first);
254 combo_language->select(1);
256 fl_addto_choice(language_->choice_quotes_language,
257 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
258 " «text» | »text« "));
260 bc().addReadOnly (language_->choice_inputenc);
261 bc().addReadOnly (language_->choice_quotes_language);
262 bc().addReadOnly (language_->radio_single);
263 bc().addReadOnly (language_->radio_double);
265 // the document options form
266 options_.reset(build_document_options(this));
267 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
268 setPrehandler(options_->input_float_placement);
270 fl_set_counter_bounds(options_->counter_secnumdepth,-2,5);
271 fl_set_counter_bounds(options_->counter_tocdepth,-1,5);
272 fl_set_counter_step(options_->counter_secnumdepth,1,1);
273 fl_set_counter_step(options_->counter_tocdepth,1,1);
274 fl_set_counter_precision(options_->counter_secnumdepth, 0);
275 fl_set_counter_precision(options_->counter_tocdepth, 0);
276 for (n=0; tex_graphics[n][0]; ++n) {
277 fl_addto_choice(options_->choice_postscript_driver,
280 fl_addto_choice(options_->choice_citation_format,
281 _(" Author-year | Numerical "));
283 bc_.addReadOnly (options_->counter_secnumdepth);
284 bc_.addReadOnly (options_->counter_tocdepth);
285 bc_.addReadOnly (options_->check_use_amsmath);
286 bc_.addReadOnly (options_->check_use_natbib);
287 bc_.addReadOnly (options_->choice_citation_format);
288 bc_.addReadOnly (options_->input_float_placement);
289 bc_.addReadOnly (options_->choice_postscript_driver);
291 // the document bullets form
292 bullets_.reset(build_document_bullet(this));
293 fl_addto_choice(bullets_->choice_bullet_size,
294 _(" default | tiny | script | footnote | small |"
295 " normal | large | Large | LARGE | huge | Huge"));
296 fl_set_choice(bullets_->choice_bullet_size, 1);
297 fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
298 setPrehandler(bullets_->input_bullet_latex);
299 fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
301 string const bmtablefile = LibFileSearch("images", "standard", "xpm");
302 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
303 bmtablefile.c_str());
305 bc_.addReadOnly(bullets_->radio_bullet_depth_1);
306 bc_.addReadOnly(bullets_->radio_bullet_depth_2);
307 bc_.addReadOnly(bullets_->radio_bullet_depth_3);
308 bc_.addReadOnly(bullets_->radio_bullet_depth_4);
309 bc_.addReadOnly(bullets_->radio_bullet_panel_standard);
310 bc_.addReadOnly(bullets_->radio_bullet_panel_maths);
311 bc_.addReadOnly(bullets_->radio_bullet_panel_ding1);
312 bc_.addReadOnly(bullets_->radio_bullet_panel_ding2);
313 bc_.addReadOnly(bullets_->radio_bullet_panel_ding3);
314 bc_.addReadOnly(bullets_->radio_bullet_panel_ding4);
316 bc().addReadOnly (bullets_->bmtable_bullet_panel);
317 bc().addReadOnly (bullets_->choice_bullet_size);
318 bc().addReadOnly (bullets_->input_bullet_latex);
320 fl_addto_tabfolder(dialog_->tabfolder,_("Document"),
322 fl_addto_tabfolder(dialog_->tabfolder,_("Paper"),
324 fl_addto_tabfolder(dialog_->tabfolder,_("Language"),
326 fl_addto_tabfolder(dialog_->tabfolder,_("Extra"),
328 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets"),
331 // work-around xforms bug re update of folder->x, folder->y coords.
332 setPrehandler(dialog_->tabfolder);
334 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
335 lyxerr << _("Your version of libXpm is older than 4.7.\n"
336 "The `bullet' tab of the document dialog "
337 "has been disabled") << '\n';
338 fl_deactivate_object(fbullet);
339 fl_set_object_lcol(fbullet, FL_INACTIVE);
344 void FormDocument::apply()
346 if (!lv_.view()->available() || !dialog_.get())
349 bool redo = class_apply();
351 redo = language_apply() || redo;
352 redo = options_apply() || redo;
356 lv_.view()->redoCurrentBuffer();
358 lv_.buffer()->markDirty();
359 lv_.message(_("Document layout set"));
363 void FormDocument::cancel()
365 // this avoids confusion when reopening
366 BufferParams & param = lv_.buffer()->params;
367 param.temp_bullets[0] = param.user_defined_bullets[0];
368 param.temp_bullets[1] = param.user_defined_bullets[1];
369 param.temp_bullets[2] = param.user_defined_bullets[2];
370 param.temp_bullets[3] = param.user_defined_bullets[3];
375 void FormDocument::update()
382 BufferParams const & params = lv_.buffer()->params;
384 class_update(params);
385 paper_update(params);
386 language_update(params);
387 options_update(params);
388 bullets_update(params);
393 // should this go elsewhere? Maybe a ControllerDocument? (JMarc)
394 /** Save the buffer's parameters as user default.
395 This function saves a file \c user_lyxdir/templates/defaults.lyx
396 which parameters are those of the current buffer. This file
397 is used as a default template when creating a new
398 file. Returns \c true on success.
400 bool saveParamsAsDefault(BufferParams const ¶ms)
402 if (!Alert::askQuestion(_("Do you want to save the current settings"),
403 _("for the document layout as default?"),
404 _("(they will be valid for any new document)")))
407 string const fname = AddName(AddPath(user_lyxdir, "templates/"),
409 Buffer defaults(fname);
410 defaults.params = params;
412 // add an empty paragraph. Is this enough?
413 Paragraph * par = new Paragraph;
414 par->layout(params.getLyXTextClass().defaultLayout());
415 defaults.paragraphs.set(par);
417 return defaults.writeFile(defaults.fileName());
423 bool FormDocument::input(FL_OBJECT * ob, long)
425 if (ob == class_->choice_doc_class) {
426 CheckChoiceClass(ob, 0);
427 } else if (ob == bullets_->choice_bullet_size) {
428 ChoiceBulletSize(ob, 0);
429 } else if (ob == bullets_->input_bullet_latex) {
430 InputBulletLaTeX(ob, 0);
431 } else if (ob == bullets_->radio_bullet_depth_1 ||
432 ob == bullets_->radio_bullet_depth_2 ||
433 ob == bullets_->radio_bullet_depth_3 ||
434 ob == bullets_->radio_bullet_depth_4) {
436 } else if (ob == bullets_->radio_bullet_panel_standard ||
437 ob == bullets_->radio_bullet_panel_maths ||
438 ob == bullets_->radio_bullet_panel_ding1 ||
439 ob == bullets_->radio_bullet_panel_ding2 ||
440 ob == bullets_->radio_bullet_panel_ding3 ||
441 ob == bullets_->radio_bullet_panel_ding4) {
443 } else if (ob == bullets_->bmtable_bullet_panel) {
444 BulletBMTable(ob, 0);
447 bool const length_input = fl_get_choice(class_->choice_doc_skip) == 4;
448 if (ob == class_->choice_doc_skip) {
449 setEnabled(class_->input_doc_skip, length_input);
450 setEnabled(class_->choice_default_skip_units, length_input);
453 if (ob == class_->choice_doc_spacing)
454 setEnabled(class_->input_doc_spacing,
455 fl_get_choice(class_->choice_doc_spacing) == 4);
457 bool const skip_used = fl_get_button(class_->radio_doc_skip);
458 if (ob == class_->radio_doc_skip ||
459 ob == class_->radio_doc_indent) {
460 setEnabled(class_->choice_doc_skip, skip_used);
461 setEnabled(class_->input_doc_skip,
462 skip_used && length_input);
463 setEnabled(class_->choice_default_skip_units,
464 skip_used && length_input);
465 // Default unit choice is cm if metric, inches if US paper.
466 // If papersize is default, check the lyxrc-settings
467 int const paperchoice = fl_get_choice(paper_->choice_papersize);
468 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
469 || paperchoice == 2 || paperchoice > 5;
470 int const default_unit = metric ? 8 : 9;
471 if (rtrim(fl_get_input(class_->input_doc_skip)).empty())
472 fl_set_choice(class_->choice_default_skip_units,
476 if (ob == options_->check_use_natbib) {
477 setEnabled(options_->choice_citation_format,
478 fl_get_button(options_->check_use_natbib));
481 if (ob == dialog_->button_save_defaults) {
485 language_apply(params);
486 options_apply(params);
487 bullets_apply(params);
488 params.preamble = lv_.buffer()->params.preamble;
489 saveParamsAsDefault(params);
492 if (ob == dialog_->button_reset_defaults) {
493 BufferParams params = lv_.buffer()->params;
494 params.textclass = combo_doc_class->get() - 1;
495 params.useClassDefaults();
496 UpdateLayoutDocument(params);
499 if (ob == paper_->radio_landscape)
500 fl_set_choice(paper_->choice_paperpackage,
501 BufferParams::PACKAGE_NONE + 1);
503 if (ob == paper_->choice_papersize) {
504 int const paperchoice = fl_get_choice(paper_->choice_papersize);
505 bool const defsize = paperchoice == 1;
506 bool const custom = paperchoice == 2;
507 bool const a3size = paperchoice == 6;
508 bool const b3size = paperchoice == 9;
509 bool const b4size = paperchoice == 10;
512 fl_set_button(paper_->radio_portrait, 1);
514 bool const use_geom = (custom || a3size || b3size || b4size);
516 fl_set_button(paper_->check_use_geometry, int(use_geom));
518 setEnabled(paper_->input_top_margin, use_geom);
519 setEnabled(paper_->input_bottom_margin, use_geom);
520 setEnabled(paper_->input_inner_margin, use_geom);
521 setEnabled(paper_->input_outer_margin, use_geom);
522 setEnabled(paper_->input_head_height, use_geom);
523 setEnabled(paper_->input_head_sep, use_geom);
524 setEnabled(paper_->input_foot_skip, use_geom);
525 setEnabled(paper_->choice_top_margin_units, use_geom);
526 setEnabled(paper_->choice_bottom_margin_units, use_geom);
527 setEnabled(paper_->choice_inner_margin_units, use_geom);
528 setEnabled(paper_->choice_outer_margin_units, use_geom);
529 setEnabled(paper_->choice_head_height_units, use_geom);
530 setEnabled(paper_->choice_head_sep_units, use_geom);
531 setEnabled(paper_->choice_foot_skip_units, use_geom);
532 setEnabled(paper_->choice_custom_width_units, use_geom);
533 setEnabled(paper_->choice_custom_height_units, use_geom);
535 setEnabled(paper_->input_custom_width, custom);
536 setEnabled(paper_->input_custom_height, custom);
537 setEnabled(paper_->choice_custom_width_units, custom);
538 setEnabled(paper_->choice_custom_height_units, custom);
539 setEnabled(paper_->radio_portrait, !custom);
540 setEnabled(paper_->radio_landscape, !custom);
542 // Default unit choice is cm if metric, inches if US paper.
543 // If papersize is default, use the lyxrc-settings
544 bool const metric = (defsize && lyxrc.default_papersize > 3)
545 || paperchoice == 2 || paperchoice > 5;
546 int const default_unit = metric ? 8 : 9;
547 if (rtrim(fl_get_input(paper_->input_custom_width)).empty())
548 fl_set_choice(paper_->choice_custom_width_units,
550 if (rtrim(fl_get_input(paper_->input_custom_height)).empty())
551 fl_set_choice(paper_->choice_custom_height_units,
553 if (rtrim(fl_get_input(paper_->input_top_margin)).empty())
554 fl_set_choice(paper_->choice_top_margin_units,
556 if (rtrim(fl_get_input(paper_->input_bottom_margin)).empty())
557 fl_set_choice(paper_->choice_bottom_margin_units,
559 if (rtrim(fl_get_input(paper_->input_inner_margin)).empty())
560 fl_set_choice(paper_->choice_inner_margin_units,
562 if (rtrim(fl_get_input(paper_->input_outer_margin)).empty())
563 fl_set_choice(paper_->choice_outer_margin_units,
565 if (rtrim(fl_get_input(paper_->input_head_height)).empty())
566 fl_set_choice(paper_->choice_head_height_units,
568 if (rtrim(fl_get_input(paper_->input_head_sep)).empty())
569 fl_set_choice(paper_->choice_head_sep_units,
571 if (rtrim(fl_get_input(paper_->input_foot_skip)).empty())
572 fl_set_choice(paper_->choice_foot_skip_units,
576 if (ob == paper_->choice_papersize ||
577 ob == paper_->radio_portrait ||
578 ob == paper_->radio_landscape) {
580 setEnabled(paper_->choice_paperpackage,
581 //either default papersize (preferences)
582 //or document papersize has to be A4
583 (fl_get_choice(paper_->choice_papersize) == 7
584 || fl_get_choice(paper_->choice_papersize) == 1
585 && lyxrc.default_papersize == 5)
586 && fl_get_button(paper_->radio_portrait));
589 if (ob == paper_->choice_paperpackage) {
590 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
591 fl_set_button(paper_->check_use_geometry, 0);
593 setEnabled(paper_->input_top_margin, false);
594 setEnabled(paper_->input_bottom_margin, false);
595 setEnabled(paper_->input_inner_margin, false);
596 setEnabled(paper_->input_outer_margin, false);
597 setEnabled(paper_->input_head_height, false);
598 setEnabled(paper_->input_head_sep, false);
599 setEnabled(paper_->input_foot_skip, false);
600 setEnabled(paper_->choice_top_margin_units, false);
601 setEnabled(paper_->choice_bottom_margin_units, false);
602 setEnabled(paper_->choice_inner_margin_units, false);
603 setEnabled(paper_->choice_outer_margin_units, false);
604 setEnabled(paper_->choice_head_height_units, false);
605 setEnabled(paper_->choice_head_sep_units, false);
606 setEnabled(paper_->choice_foot_skip_units, false);
610 if (ob == paper_->check_use_geometry) {
611 //don't allow switching geometry off in custom papersize mode
612 //nor in A3, B3, and B4
613 int const choice = fl_get_choice(paper_->choice_papersize);
614 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
615 fl_set_button(paper_->check_use_geometry, 1);
617 fl_set_choice(paper_->choice_paperpackage,
618 BufferParams::PACKAGE_NONE + 1);
620 bool const use_geom = fl_get_button(paper_->check_use_geometry);
621 setEnabled(paper_->input_top_margin, use_geom);
622 setEnabled(paper_->input_bottom_margin, use_geom);
623 setEnabled(paper_->input_inner_margin, use_geom);
624 setEnabled(paper_->input_outer_margin, use_geom);
625 setEnabled(paper_->input_head_height, use_geom);
626 setEnabled(paper_->input_head_sep, use_geom);
627 setEnabled(paper_->input_foot_skip, use_geom);
628 setEnabled(paper_->choice_top_margin_units, use_geom);
629 setEnabled(paper_->choice_bottom_margin_units, use_geom);
630 setEnabled(paper_->choice_inner_margin_units, use_geom);
631 setEnabled(paper_->choice_outer_margin_units, use_geom);
632 setEnabled(paper_->choice_head_height_units, use_geom);
633 setEnabled(paper_->choice_head_sep_units, use_geom);
634 setEnabled(paper_->choice_foot_skip_units, use_geom);
637 return CheckDocumentInput(ob, 0);
641 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
643 FormDocument * pre = static_cast<FormDocument*>(v);
644 if (combox == pre->combo_doc_class.get())
645 pre->CheckChoiceClass(0, 0);
646 pre->bc().valid(pre->CheckDocumentInput(0,0));
650 bool FormDocument::class_apply(BufferParams ¶ms)
654 // If default skip is a "Length" but there's no text in the
655 // input field, reset the kind to "Medskip", which is the default.
656 if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
657 !*(fl_get_input (class_->input_doc_skip))) {
658 fl_set_choice (class_->choice_doc_skip, 2);
660 params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
661 params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
662 params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
664 params.textclass = combo_doc_class->get() - 1;
666 BufferParams::PARSEP tmpsep = params.paragraph_separation;
667 if (fl_get_button(class_->radio_doc_indent))
668 params.paragraph_separation = BufferParams::PARSEP_INDENT;
670 params.paragraph_separation = BufferParams::PARSEP_SKIP;
671 if (tmpsep != params.paragraph_separation)
674 VSpace tmpdefskip = params.getDefSkip();
675 switch (fl_get_choice (class_->choice_doc_skip)) {
677 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
680 params.setDefSkip(VSpace(VSpace::MEDSKIP));
683 params.setDefSkip(VSpace(VSpace::BIGSKIP));
687 string const length =
688 getLengthFromWidgets(class_->input_doc_skip,
689 class_->choice_default_skip_units);
691 params.setDefSkip(VSpace(LyXGlueLength(length)));
695 // DocumentDefskipCB assures that this never happens
696 params.setDefSkip(VSpace(VSpace::MEDSKIP));
699 if (!(tmpdefskip == params.getDefSkip()))
702 if (fl_get_button(class_->radio_doc_columns_two))
706 if (fl_get_button(class_->radio_doc_sides_two))
707 params.sides = LyXTextClass::TwoSides;
709 params.sides = LyXTextClass::OneSide;
711 Spacing tmpSpacing = params.spacing;
712 switch (fl_get_choice(class_->choice_doc_spacing)) {
714 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
715 params.spacing.set(Spacing::Single);
718 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
719 params.spacing.set(Spacing::Onehalf);
722 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
723 params.spacing.set(Spacing::Double);
726 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
727 params.spacing.set(Spacing::Other,
728 fl_get_input(class_->input_doc_spacing));
731 if (tmpSpacing != params.spacing)
734 params.options = fl_get_input(class_->input_doc_extra);
740 bool FormDocument::class_apply()
742 BufferParams ¶ms = lv_.buffer()->params;
744 unsigned int const old_class = params.textclass;
746 bool redo = class_apply(params);
748 if (params.textclass != old_class) {
749 // try to load new_class
750 if (textclasslist[params.textclass].load()) {
751 // successfully loaded
753 lv_.message(_("Converting document to new document class..."));
754 int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
755 old_class, params.textclass,
756 &*(lv_.buffer()->paragraphs.begin()),
757 lv_.buffer()->params);
761 s = _("One paragraph couldn't be converted");
764 s += _(" paragraphs couldn't be converted");
766 Alert::alert(_("Conversion Errors!"),s,
767 _("into chosen document class"));
771 // problem changing class -- warn user and retain old style
772 Alert::alert(_("Conversion Errors!"),
773 _("Errors loading new document class."),
774 _("Reverting to original document class."));
775 combo_doc_class->select(int(old_class) + 1);
783 void FormDocument::paper_apply(BufferParams & params)
785 params.papersize2 = char(fl_get_choice(paper_->choice_papersize) - 1);
787 params.paperpackage =
788 char(fl_get_choice(paper_->choice_paperpackage) - 1);
790 // set params.papersize from params.papersize2 and params.paperpackage
791 params.setPaperStuff();
793 params.use_geometry = fl_get_button(paper_->check_use_geometry);
795 if (fl_get_button(paper_->radio_landscape))
796 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
798 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
801 getLengthFromWidgets(paper_->input_custom_width,
802 paper_->choice_custom_width_units);
805 getLengthFromWidgets(paper_->input_custom_height,
806 paper_->choice_custom_height_units);
809 getLengthFromWidgets(paper_->input_inner_margin,
810 paper_->choice_inner_margin_units);
813 getLengthFromWidgets(paper_->input_top_margin,
814 paper_->choice_top_margin_units);
817 getLengthFromWidgets(paper_->input_outer_margin,
818 paper_->choice_outer_margin_units);
820 params.bottommargin =
821 getLengthFromWidgets(paper_->input_bottom_margin,
822 paper_->choice_bottom_margin_units);
825 getLengthFromWidgets(paper_->input_head_height,
826 paper_->choice_head_height_units);
829 getLengthFromWidgets(paper_->input_head_sep,
830 paper_->choice_head_sep_units);
833 getLengthFromWidgets(paper_->input_foot_skip,
834 paper_->choice_foot_skip_units);
838 void FormDocument::paper_apply()
840 paper_apply(lv_.buffer()->params);
844 bool FormDocument::language_apply(BufferParams & params)
846 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
849 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
851 lga = InsetQuotes::EnglishQ;
854 lga = InsetQuotes::SwedishQ;
857 lga = InsetQuotes::GermanQ;
860 lga = InsetQuotes::PolishQ;
863 lga = InsetQuotes::FrenchQ;
866 lga = InsetQuotes::DanishQ;
869 params.quotes_language = lga;
870 if (fl_get_button(language_->radio_single))
871 params.quotes_times = InsetQuotes::SingleQ;
873 params.quotes_times = InsetQuotes::DoubleQ;
875 int const pos = combo_language->get();
876 Language const * old_language = params.language;
877 Language const * new_language = languages.getLanguage(lang_[pos-1]);
879 new_language = default_language;
881 if (old_language != new_language
882 && old_language->RightToLeft() == new_language->RightToLeft()
883 && !lv_.buffer()->isMultiLingual())
884 lv_.buffer()->changeLanguage(old_language, new_language);
886 if (old_language != new_language) {
890 params.language = new_language;
891 params.inputenc = fl_get_choice_text(language_->choice_inputenc);
897 bool FormDocument::language_apply()
899 return language_apply(lv_.buffer()->params);
903 bool FormDocument::options_apply(BufferParams & params)
907 params.graphicsDriver =
908 fl_get_choice_text(options_->choice_postscript_driver);
909 params.use_amsmath = fl_get_button(options_->check_use_amsmath);
910 params.use_natbib = fl_get_button(options_->check_use_natbib);
911 params.use_numerical_citations =
912 fl_get_choice(options_->choice_citation_format) - 1;
914 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
915 if (params.secnumdepth != tmpchar)
917 params.secnumdepth = tmpchar;
919 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
921 params.float_placement =
922 fl_get_input(options_->input_float_placement);
928 bool FormDocument::options_apply()
930 return options_apply(lv_.buffer()->params);
934 void FormDocument::bullets_apply(BufferParams & params)
936 /* update the bullet settings */
937 BufferParams & buf_params = lv_.buffer()->params;
939 // a little bit of loop unrolling
940 params.user_defined_bullets[0] = buf_params.temp_bullets[0];
941 params.user_defined_bullets[1] = buf_params.temp_bullets[1];
942 params.user_defined_bullets[2] = buf_params.temp_bullets[2];
943 params.user_defined_bullets[3] = buf_params.temp_bullets[3];
947 void FormDocument::bullets_apply()
949 bullets_apply(lv_.buffer()->params);
952 void FormDocument::UpdateClassParams(BufferParams const & params)
954 // These are the params that have to be updated on any class change
955 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
957 LyXTextClass const & tclass = textclasslist[params.textclass];
959 combo_doc_class->select(tclass.description());
960 fl_clear_choice(class_->choice_doc_fontsize);
961 fl_addto_choice(class_->choice_doc_fontsize, "default");
962 fl_addto_choice(class_->choice_doc_fontsize,
963 tclass.opt_fontsize().c_str());
964 fl_set_choice_text(class_->choice_doc_fontsize,
965 params.fontsize.c_str());
966 fl_clear_choice(class_->choice_doc_pagestyle);
967 fl_addto_choice(class_->choice_doc_pagestyle, "default");
968 fl_addto_choice(class_->choice_doc_pagestyle,
969 tclass.opt_pagestyle().c_str());
970 fl_set_choice_text(class_->choice_doc_pagestyle,
971 params.pagestyle.c_str());
975 void FormDocument::class_update(BufferParams const & params)
980 UpdateClassParams(params);
982 fl_set_choice_text(class_->choice_doc_fonts,
983 params.fonts.c_str());
984 fl_set_button(class_->radio_doc_indent, 0);
985 fl_set_button(class_->radio_doc_skip, 0);
986 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
987 fl_set_button(class_->radio_doc_indent, 1);
989 fl_set_button(class_->radio_doc_skip, 1);
991 bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
992 setEnabled(class_->choice_default_skip_units, input_length);
993 setEnabled(class_->input_doc_skip, input_length);
995 switch (params.getDefSkip().kind()) {
996 case VSpace::SMALLSKIP:
997 fl_set_choice (class_->choice_doc_skip, 1);
999 case VSpace::MEDSKIP:
1000 fl_set_choice (class_->choice_doc_skip, 2);
1002 case VSpace::BIGSKIP:
1003 fl_set_choice (class_->choice_doc_skip, 3);
1005 case VSpace::LENGTH:
1007 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1008 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1009 || paperchoice == 2 || paperchoice > 5;
1010 string const default_unit = metric ? "cm" : "in";
1011 string const length = params.getDefSkip().asLyXCommand();
1012 updateWidgetsFromLengthString(class_->input_doc_skip,
1013 class_->choice_default_skip_units,
1014 length, default_unit);
1018 fl_set_choice (class_->choice_doc_skip, 2);
1021 fl_set_button(class_->radio_doc_sides_one, 0);
1022 fl_set_button(class_->radio_doc_sides_two, 0);
1023 setEnabled(class_->choice_doc_skip,
1024 fl_get_button(class_->radio_doc_skip));
1026 if (params.sides == LyXTextClass::TwoSides)
1027 fl_set_button(class_->radio_doc_sides_two, 1);
1029 fl_set_button(class_->radio_doc_sides_one, 1);
1030 fl_set_button(class_->radio_doc_columns_one, 0);
1031 fl_set_button(class_->radio_doc_columns_two, 0);
1032 if (params.columns == 2)
1033 fl_set_button(class_->radio_doc_columns_two, 1);
1035 fl_set_button(class_->radio_doc_columns_one, 1);
1037 fl_set_input(class_->input_doc_spacing, "");
1038 setEnabled(class_->input_doc_spacing, false);
1040 switch (params.spacing.getSpace()) {
1041 case Spacing::Default: // nothing bad should happen with this
1042 case Spacing::Single:
1044 fl_set_choice(class_->choice_doc_spacing, 1);
1046 case Spacing::Onehalf:
1048 fl_set_choice(class_->choice_doc_spacing, 2);
1050 case Spacing::Double:
1052 fl_set_choice(class_->choice_doc_spacing, 3);
1054 case Spacing::Other:
1056 fl_set_choice(class_->choice_doc_spacing, 4);
1058 sprintf(sval,"%g",params.spacing.getValue());
1059 fl_set_input(class_->input_doc_spacing, sval);
1060 setEnabled(class_->input_doc_spacing, true);
1064 if (!params.options.empty())
1065 fl_set_input(class_->input_doc_extra, params.options.c_str());
1067 fl_set_input(class_->input_doc_extra, "");
1071 void FormDocument::language_update(BufferParams const & params)
1073 if (!language_.get())
1076 int const pos = int(findPos(lang_, params.language->lang()));
1077 combo_language->select(pos+1);
1079 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1080 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1081 fl_set_button(language_->radio_single, 0);
1082 fl_set_button(language_->radio_double, 0);
1083 if (params.quotes_times == InsetQuotes::SingleQ)
1084 fl_set_button(language_->radio_single, 1);
1086 fl_set_button(language_->radio_double, 1);
1090 void FormDocument::options_update(BufferParams const & params)
1092 if (!options_.get())
1095 fl_set_choice_text(options_->choice_postscript_driver,
1096 params.graphicsDriver.c_str());
1097 fl_set_button(options_->check_use_amsmath, params.use_amsmath);
1098 fl_set_button(options_->check_use_natbib, params.use_natbib);
1099 fl_set_choice(options_->choice_citation_format,
1100 int(params.use_numerical_citations)+1);
1101 setEnabled(options_->choice_citation_format, params.use_natbib);
1102 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1103 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1104 if (!params.float_placement.empty())
1105 fl_set_input(options_->input_float_placement,
1106 params.float_placement.c_str());
1108 fl_set_input(options_->input_float_placement, "");
1112 void FormDocument::paper_update(BufferParams const & params)
1117 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1118 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1119 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1121 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1122 bool const useCustom = paperchoice == 2;
1123 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1125 fl_set_button(paper_->radio_portrait, 0);
1126 setEnabled(paper_->radio_portrait, !useCustom);
1127 fl_set_button(paper_->radio_landscape, 0);
1128 setEnabled(paper_->radio_landscape, !useCustom);
1130 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
1131 fl_set_button(paper_->radio_landscape, 1);
1133 fl_set_button(paper_->radio_portrait, 1);
1134 setEnabled(paper_->choice_paperpackage,
1135 //either default papersize (preferences)
1136 //or document papersize has to be A4
1138 || paperchoice == 1 && lyxrc.default_papersize == 5)
1139 && fl_get_button(paper_->radio_portrait));
1141 // Default unit choice is cm if metric, inches if US paper.
1142 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1143 || paperchoice == 2 || paperchoice > 5;
1144 string const default_unit = metric ? "cm" : "in";
1145 updateWidgetsFromLengthString(paper_->input_custom_width,
1146 paper_->choice_custom_width_units,
1147 params.paperwidth, default_unit);
1148 setEnabled(paper_->input_custom_width, useCustom);
1149 setEnabled(paper_->choice_custom_width_units, useCustom);
1151 updateWidgetsFromLengthString(paper_->input_custom_height,
1152 paper_->choice_custom_height_units,
1153 params.paperheight, default_unit);
1154 setEnabled(paper_->input_custom_height, useCustom);
1155 setEnabled(paper_->choice_custom_height_units, useCustom);
1157 updateWidgetsFromLengthString(paper_->input_inner_margin,
1158 paper_->choice_inner_margin_units,
1159 params.leftmargin, default_unit);
1160 setEnabled(paper_->input_inner_margin, useGeom);
1161 setEnabled(paper_->choice_inner_margin_units, useGeom);
1163 updateWidgetsFromLengthString(paper_->input_top_margin,
1164 paper_->choice_top_margin_units,
1165 params.topmargin, default_unit);
1166 setEnabled(paper_->input_top_margin, useGeom);
1167 setEnabled(paper_->choice_top_margin_units, useGeom);
1169 updateWidgetsFromLengthString(paper_->input_outer_margin,
1170 paper_->choice_outer_margin_units,
1171 params.rightmargin, default_unit);
1172 setEnabled(paper_->input_outer_margin, useGeom);
1173 setEnabled(paper_->choice_outer_margin_units, useGeom);
1175 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1176 paper_->choice_bottom_margin_units,
1177 params.bottommargin, default_unit);
1178 setEnabled(paper_->input_bottom_margin, useGeom);
1179 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1181 updateWidgetsFromLengthString(paper_->input_head_height,
1182 paper_->choice_head_height_units,
1183 params.headheight, default_unit);
1184 setEnabled(paper_->input_head_height, useGeom);
1185 setEnabled(paper_->choice_head_height_units, useGeom);
1187 updateWidgetsFromLengthString(paper_->input_head_sep,
1188 paper_->choice_head_sep_units,
1189 params.headsep, default_unit);
1190 setEnabled(paper_->input_head_sep, useGeom);
1191 setEnabled(paper_->choice_head_sep_units, useGeom);
1193 updateWidgetsFromLengthString(paper_->input_foot_skip,
1194 paper_->choice_foot_skip_units,
1195 params.footskip, default_unit);
1196 setEnabled(paper_->input_foot_skip, useGeom);
1197 setEnabled(paper_->choice_foot_skip_units, useGeom);
1199 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1203 void FormDocument::bullets_update(BufferParams const & params)
1205 if (!bullets_.get() ||
1207 (XpmVersion==4 && XpmRevision<7)))
1210 bool const isLinuxDoc = lv_.buffer()->isLinuxDoc();
1211 setEnabled(fbullet, !isLinuxDoc);
1213 if (isLinuxDoc) return;
1215 fl_set_button(bullets_->radio_bullet_depth_1, 1);
1216 fl_set_input(bullets_->input_bullet_latex,
1217 params.user_defined_bullets[0].getText().c_str());
1218 fl_set_choice(bullets_->choice_bullet_size,
1219 params.user_defined_bullets[0].getSize() + 2);
1223 void FormDocument::checkReadOnly()
1225 if (bc().readOnly(lv_.buffer()->isReadonly())) {
1226 combo_doc_class->deactivate();
1227 combo_language->deactivate();
1228 postWarning(_("Document is read-only."
1229 " No changes to layout permitted."));
1231 combo_doc_class->activate();
1232 combo_language->activate();
1238 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
1244 // this has to be all out of if/elseif because it has to deactivate
1245 // the document buttons and so the whole stuff has to be tested again.
1246 // disable OK/Apply if input is not valid
1247 str = fl_get_input(class_->input_doc_skip);
1248 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1249 str = fl_get_input(paper_->input_custom_width);
1250 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1251 str = fl_get_input(paper_->input_custom_height);
1252 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1253 str = fl_get_input(paper_->input_outer_margin);
1254 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1255 str = fl_get_input(paper_->input_inner_margin);
1256 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1257 str = fl_get_input(paper_->input_top_margin);
1258 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1259 str = fl_get_input(paper_->input_bottom_margin);
1260 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1261 str = fl_get_input(paper_->input_head_height);
1262 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1263 str = fl_get_input(paper_->input_head_sep);
1264 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1265 str = fl_get_input(paper_->input_foot_skip);
1266 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1268 //display warning if input is not valid
1269 if (ob == class_->input_doc_skip
1270 || ob == paper_->input_custom_width
1271 || ob == paper_->input_custom_height
1272 || ob == paper_->input_outer_margin
1273 || ob == paper_->input_inner_margin
1274 || ob == paper_->input_top_margin
1275 || ob == paper_->input_bottom_margin
1276 || ob == paper_->input_head_height
1277 || ob == paper_->input_head_sep
1278 || ob == paper_->input_foot_skip) {
1280 postWarning(_("Invalid Length (valid example: 10mm)"));
1288 // "Synchronize" the choice and the input field, so that it
1289 // is impossible to commit senseless data.
1290 input = fl_get_input (class_->input_doc_skip);
1291 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1293 else if (fl_get_choice(class_->choice_doc_skip) != 4)
1294 fl_set_input (class_->input_doc_skip, "");
1296 input = fl_get_input(class_->input_doc_spacing);
1297 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1299 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
1300 fl_set_input (class_->input_doc_spacing, "");
1305 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1307 BufferParams & param = lv_.buffer()->params;
1309 // convert from 1-6 range to -1-4
1310 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1311 fl_set_input(bullets_->input_bullet_latex,
1312 param.temp_bullets[current_bullet_depth].getText().c_str());
1316 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1318 BufferParams & param = lv_.buffer()->params;
1320 param.temp_bullets[current_bullet_depth].
1321 setText(fl_get_input(bullets_->input_bullet_latex));
1325 void FormDocument::BulletDepth(FL_OBJECT * ob)
1327 /* Should I do the following: */
1328 /* 1. change to the panel that the current bullet belongs in */
1329 /* 2. show that bullet as selected */
1330 /* 3. change the size setting to the size of the bullet in Q.*/
1331 /* 4. display the latex equivalent in the latex box */
1333 /* I'm inclined to just go with 3 and 4 at the moment and */
1334 /* maybe try to support the others later */
1335 BufferParams & param = lv_.buffer()->params;
1338 if (ob == bullets_->radio_bullet_depth_1)
1340 else if (ob == bullets_->radio_bullet_depth_2)
1342 else if (ob == bullets_->radio_bullet_depth_3)
1344 else if (ob == bullets_->radio_bullet_depth_4)
1347 switch (fl_get_button_numb(ob)) {
1349 // right mouse button resets to default
1350 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1352 current_bullet_depth = data;
1353 fl_set_input(bullets_->input_bullet_latex,
1354 param.temp_bullets[data].getText().c_str());
1355 fl_set_choice(bullets_->choice_bullet_size,
1356 param.temp_bullets[data].getSize() + 2);
1361 void FormDocument::BulletPanel(FL_OBJECT * ob)
1363 /* Here we have to change the background pixmap to that selected */
1364 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1367 if (ob == bullets_->radio_bullet_panel_standard)
1369 else if (ob == bullets_->radio_bullet_panel_maths)
1371 else if (ob == bullets_->radio_bullet_panel_ding2)
1373 else if (ob == bullets_->radio_bullet_panel_ding3)
1375 else if (ob == bullets_->radio_bullet_panel_ding4)
1377 else if (ob == bullets_->radio_bullet_panel_ding1)
1380 if (data != current_bullet_panel) {
1381 fl_freeze_form(bullets_->form);
1382 current_bullet_panel = data;
1384 /* free the current pixmap */
1385 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1387 if (ob == bullets_->radio_bullet_panel_standard) {
1388 new_panel = "standard";
1389 } else if (ob == bullets_->radio_bullet_panel_maths ) {
1390 new_panel = "amssymb";
1391 } else if (ob == bullets_->radio_bullet_panel_ding2) {
1392 new_panel = "psnfss1";
1393 } else if (ob == bullets_->radio_bullet_panel_ding3) {
1394 new_panel = "psnfss2";
1395 } else if (ob == bullets_->radio_bullet_panel_ding4) {
1396 new_panel = "psnfss3";
1397 } else if (ob == bullets_->radio_bullet_panel_ding1) {
1398 new_panel = "psnfss4";
1400 /* something very wrong happened */
1401 // play it safe for now but should be an exception
1402 current_bullet_panel = 0; // standard panel
1403 new_panel = "standard";
1405 new_panel += ".xpm";
1406 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1407 LibFileSearch("images", new_panel).c_str());
1408 fl_redraw_object(bullets_->bmtable_bullet_panel);
1409 fl_unfreeze_form(bullets_->form);
1414 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1416 /* handle the user input by setting the current bullet depth's pixmap */
1417 /* to that extracted from the current chosen position of the BMTable */
1418 /* Don't forget to free the button's old pixmap first. */
1420 BufferParams & param = lv_.buffer()->params;
1421 int bmtable_button = fl_get_bmtable(ob);
1423 /* try to keep the button held down till another is pushed */
1424 /* fl_set_bmtable(ob, 1, bmtable_button); */
1425 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1426 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1427 fl_set_input(bullets_->input_bullet_latex,
1428 param.temp_bullets[current_bullet_depth].getText().c_str());
1432 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1435 ob = class_->choice_doc_class;
1437 lv_.prohibitInput();
1439 unsigned int tc = combo_doc_class->get() - 1;
1440 if (textclasslist[tc].load()) {
1441 // we use a copy of the bufferparams because we do not
1442 // want to modify them yet.
1443 BufferParams params = lv_.buffer()->params;
1445 if (lyxrc.auto_reset_options) {
1446 params.textclass = tc;
1447 params.useClassDefaults();
1448 UpdateLayoutDocument(params);
1450 // update the params which are needed in any case
1451 // (fontsizes, pagestyle)
1452 params.textclass = tc;
1453 UpdateClassParams(params);
1457 // unable to load new style
1458 Alert::alert(_("Conversion Errors!"),
1459 _("Unable to switch to new document class."),
1460 _("Reverting to original document class."));
1461 combo_doc_class->select(int(lv_.buffer()->params.textclass) + 1);
1467 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1473 class_update(params);
1474 paper_update(params);
1475 language_update(params);
1476 options_update(params);
1477 bullets_update(params);