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"
37 #include "CutAndPaste.h"
38 #include "bufferview_funcs.h"
39 #include "xforms_helpers.h"
41 #include "input_validators.h" // fl_unsigned_float_filter
42 #include "helper_funcs.h"
43 #include "lyx_main.h" // for user_lyxdir
45 #include "insets/insetquotes.h"
47 #include "support/filetools.h"
48 #include "support/lstrings.h"
50 #include FORMS_H_LOCATION
52 #include <boost/bind.hpp>
58 using Liason::setMinibuffer;
61 FormDocument::FormDocument(LyXView & lv, Dialogs & d)
62 : FormBaseBD(lv, d, _("Document Layout")),
63 ActCell(0), Confirmed(0),
64 current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
69 void FormDocument::redraw()
71 if (form() && form()->visible)
72 fl_redraw_form(form());
76 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
77 if (outer_form && outer_form->visible)
78 fl_redraw_form(outer_form);
82 FL_FORM * FormDocument::form() const
84 if (dialog_.get()) return dialog_->form;
89 void FormDocument::build()
94 dialog_.reset(build_document(this));
96 // Allow the base class to control messages
97 setMessageWidget(dialog_->text_warning);
99 // Manage the restore, ok, apply, restore and cancel/close buttons
100 bc().setOK(dialog_->button_ok);
101 bc().setApply(dialog_->button_apply);
102 bc().setCancel(dialog_->button_close);
103 bc().setRestore(dialog_->button_restore);
104 bc().addReadOnly (dialog_->button_save_defaults);
105 bc().addReadOnly (dialog_->button_reset_defaults);
107 // the document paper form
108 paper_.reset(build_document_paper(this));
109 fl_addto_choice(paper_->choice_papersize,
110 _(" Default | Custom | US letter | US legal "
111 "| US executive | A3 | A4 | A5 | B3 | B4 | B5 "));
112 fl_addto_choice(paper_->choice_paperpackage,
115 "| Very small Margins "
116 "| Very wide Margins "));
118 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
119 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
120 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
121 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
122 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
123 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
124 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
125 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
126 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
128 setPrehandler(paper_->input_custom_width);
129 setPrehandler(paper_->input_custom_height);
130 setPrehandler(paper_->input_top_margin);
131 setPrehandler(paper_->input_bottom_margin);
132 setPrehandler(paper_->input_inner_margin);
133 setPrehandler(paper_->input_outer_margin);
134 setPrehandler(paper_->input_head_height);
135 setPrehandler(paper_->input_head_sep);
136 setPrehandler(paper_->input_foot_skip);
138 // Create the contents of the unit choices
139 // Don't include the "%" terms...
140 vector<string> units_vec = getLatexUnits();
141 vector<string>::iterator ret =
142 std::remove_if(units_vec.begin(),
144 bind2nd(contains_functor(), "%"));
145 units_vec.erase(ret, units_vec.end());
147 string units = getStringFromVector(units_vec, "|");
149 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
150 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
151 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
152 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
153 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
154 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
155 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
156 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
157 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
159 bc().addReadOnly (paper_->choice_paperpackage);
160 bc().addReadOnly (paper_->radio_portrait);
161 bc().addReadOnly (paper_->radio_landscape);
162 bc().addReadOnly (paper_->choice_papersize);
163 bc().addReadOnly (paper_->check_use_geometry);
164 bc().addReadOnly (paper_->input_custom_width);
165 bc().addReadOnly (paper_->input_custom_height);
166 bc().addReadOnly (paper_->input_top_margin);
167 bc().addReadOnly (paper_->input_bottom_margin);
168 bc().addReadOnly (paper_->input_inner_margin);
169 bc().addReadOnly (paper_->input_outer_margin);
170 bc().addReadOnly (paper_->input_head_height);
171 bc().addReadOnly (paper_->input_head_sep);
172 bc().addReadOnly (paper_->input_foot_skip);
174 // the document class form
175 class_.reset(build_document_class(this));
178 // The language is a combo-box and has to be inserted manually
179 obj = class_->choice_doc_class;
180 fl_deactivate_object(obj);
181 fl_addto_form(class_->form);
182 combo_doc_class.reset(new Combox(FL_COMBOX_DROPLIST));
183 combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400,
185 combo_doc_class->shortcut("#C",1);
186 combo_doc_class->setcallback(ComboInputCB, this);
188 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
189 cit != textclasslist.end(); ++cit) {
190 combo_doc_class->addto(cit->description());
193 fl_addto_choice(class_->choice_doc_spacing,
194 _(" Single | OneHalf | Double | Custom "));
195 fl_addto_choice(class_->choice_doc_fontsize, "default|10|11|12");
196 for (n=0; tex_fonts[n][0]; ++n) {
197 fl_addto_choice(class_->choice_doc_fonts,tex_fonts[n]);
199 fl_addto_choice(class_->choice_doc_pagestyle,
200 "default|empty|plain|headings|fancy");
201 fl_addto_choice(class_->choice_doc_skip,
202 _(" Smallskip | Medskip | Bigskip | Length "));
203 fl_addto_choice(class_->choice_default_skip_units, units.c_str());
204 fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
205 fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
206 fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
208 setPrehandler(class_->input_doc_extra);
209 setPrehandler(class_->input_doc_skip);
210 setPrehandler(class_->input_doc_spacing);
212 // Set input filters on doc spacing to make it accept only
214 fl_set_input_filter(class_->input_doc_spacing, fl_unsigned_float_filter);
216 bc().addReadOnly (class_->radio_doc_indent);
217 bc().addReadOnly (class_->radio_doc_skip);
219 bc().addReadOnly (class_->choice_doc_pagestyle);
220 bc().addReadOnly (class_->choice_doc_fonts);
221 bc().addReadOnly (class_->choice_doc_fontsize);
222 bc().addReadOnly (class_->radio_doc_sides_one);
223 bc().addReadOnly (class_->radio_doc_sides_two);
224 bc().addReadOnly (class_->radio_doc_columns_one);
225 bc().addReadOnly (class_->radio_doc_columns_two);
226 bc().addReadOnly (class_->input_doc_extra);
227 bc().addReadOnly (class_->input_doc_skip);
228 bc().addReadOnly (class_->choice_doc_skip);
229 bc().addReadOnly (class_->choice_doc_spacing);
230 bc().addReadOnly (class_->input_doc_spacing);
232 // the document language form
233 language_.reset(build_document_language(this));
234 fl_addto_choice(language_->choice_inputenc,
235 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
236 "|koi8-r|koi8-u|cp866|cp1251|iso88595|pt154");
238 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
239 // Store the identifiers for later
240 lang_ = getSecond(langs);
242 // The language is a combo-box and has to be inserted manually
243 obj = language_->choice_language;
244 fl_deactivate_object(obj);
245 fl_addto_form(language_->form);
246 combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
247 combo_language->add(obj->x, obj->y, obj->w, obj->h, 400,
249 combo_language->shortcut("#L",1);
250 combo_language->setcallback(ComboInputCB, this);
253 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
254 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
255 for (; lit != lend; ++lit) {
256 combo_language->addto(lit->first);
258 combo_language->select(1);
260 fl_addto_choice(language_->choice_quotes_language,
261 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
262 " «text» | »text« "));
264 bc().addReadOnly (language_->choice_inputenc);
265 bc().addReadOnly (language_->choice_quotes_language);
266 bc().addReadOnly (language_->radio_single);
267 bc().addReadOnly (language_->radio_double);
269 // the document options form
270 options_.reset(build_document_options(this));
271 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
272 setPrehandler(options_->input_float_placement);
274 fl_set_counter_bounds(options_->counter_secnumdepth,-2,5);
275 fl_set_counter_bounds(options_->counter_tocdepth,-1,5);
276 fl_set_counter_step(options_->counter_secnumdepth,1,1);
277 fl_set_counter_step(options_->counter_tocdepth,1,1);
278 fl_set_counter_precision(options_->counter_secnumdepth, 0);
279 fl_set_counter_precision(options_->counter_tocdepth, 0);
280 for (n=0; tex_graphics[n][0]; ++n) {
281 fl_addto_choice(options_->choice_postscript_driver,
284 fl_addto_choice(options_->choice_citation_format,
285 _(" Author-year | Numerical "));
287 bc_.addReadOnly (options_->counter_secnumdepth);
288 bc_.addReadOnly (options_->counter_tocdepth);
289 bc_.addReadOnly (options_->check_use_amsmath);
290 bc_.addReadOnly (options_->check_use_natbib);
291 bc_.addReadOnly (options_->choice_citation_format);
292 bc_.addReadOnly (options_->input_float_placement);
293 bc_.addReadOnly (options_->choice_postscript_driver);
295 // the document bullets form
296 bullets_.reset(build_document_bullet(this));
297 fl_addto_choice(bullets_->choice_bullet_size,
298 _(" default | tiny | script | footnote | small |"
299 " normal | large | Large | LARGE | huge | Huge"));
300 fl_set_choice(bullets_->choice_bullet_size, 1);
301 fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
302 setPrehandler(bullets_->input_bullet_latex);
303 fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
305 string const bmtablefile = LibFileSearch("images", "standard", "xpm");
306 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
307 bmtablefile.c_str());
309 bc_.addReadOnly(bullets_->radio_bullet_depth_1);
310 bc_.addReadOnly(bullets_->radio_bullet_depth_2);
311 bc_.addReadOnly(bullets_->radio_bullet_depth_3);
312 bc_.addReadOnly(bullets_->radio_bullet_depth_4);
313 bc_.addReadOnly(bullets_->radio_bullet_panel_standard);
314 bc_.addReadOnly(bullets_->radio_bullet_panel_maths);
315 bc_.addReadOnly(bullets_->radio_bullet_panel_ding1);
316 bc_.addReadOnly(bullets_->radio_bullet_panel_ding2);
317 bc_.addReadOnly(bullets_->radio_bullet_panel_ding3);
318 bc_.addReadOnly(bullets_->radio_bullet_panel_ding4);
320 bc().addReadOnly (bullets_->bmtable_bullet_panel);
321 bc().addReadOnly (bullets_->choice_bullet_size);
322 bc().addReadOnly (bullets_->input_bullet_latex);
324 fl_addto_tabfolder(dialog_->tabfolder,_("Document"),
326 fl_addto_tabfolder(dialog_->tabfolder,_("Paper"),
328 fl_addto_tabfolder(dialog_->tabfolder,_("Language"),
330 fl_addto_tabfolder(dialog_->tabfolder,_("Extra"),
332 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets"),
335 // work-around xforms bug re update of folder->x, folder->y coords.
336 setPrehandler(dialog_->tabfolder);
338 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
339 lyxerr << _("Your version of libXpm is older than 4.7.\n"
340 "The `bullet' tab of the document dialog "
341 "has been disabled") << '\n';
342 fl_deactivate_object(fbullet);
343 fl_set_object_lcol(fbullet, FL_INACTIVE);
348 void FormDocument::apply()
350 if (!lv_.view()->available() || !dialog_.get())
353 bool redo = class_apply();
355 redo = language_apply() || redo;
356 redo = options_apply() || redo;
360 lv_.view()->redoCurrentBuffer();
362 lv_.buffer()->markDirty();
363 setMinibuffer(&lv_, _("Document layout set"));
367 void FormDocument::cancel()
369 // this avoids confusion when reopening
370 BufferParams & param = lv_.buffer()->params;
371 param.temp_bullets[0] = param.user_defined_bullets[0];
372 param.temp_bullets[1] = param.user_defined_bullets[1];
373 param.temp_bullets[2] = param.user_defined_bullets[2];
374 param.temp_bullets[3] = param.user_defined_bullets[3];
379 void FormDocument::update()
386 BufferParams const & params = lv_.buffer()->params;
388 class_update(params);
389 paper_update(params);
390 language_update(params);
391 options_update(params);
392 bullets_update(params);
397 // should this go elsewhere? Maybe a ControllerDocument? (JMarc)
398 /** Save the buffer's parameters as user default.
399 This function saves a file \c user_lyxdir/templates/defaults.lyx
400 which parameters are those of the current buffer. This file
401 is used as a default template when creating a new
402 file. Returns \c true on success.
404 bool saveParamsAsDefault(BufferParams const ¶ms)
406 if (!Alert::askQuestion(_("Do you want to save the current settings"),
407 _("for the document layout as default?"),
408 _("(they will be valid for any new document)")))
411 string const fname = AddName(AddPath(user_lyxdir, "templates/"),
413 Buffer defaults(fname);
414 defaults.params = params;
416 // add an empty paragraph. Is this enough?
417 defaults.paragraphs.set(new Paragraph);
419 return defaults.writeFile(defaults.fileName());
425 bool FormDocument::input(FL_OBJECT * ob, long)
427 if (ob == class_->choice_doc_class) {
428 CheckChoiceClass(ob, 0);
429 } else if (ob == bullets_->choice_bullet_size) {
430 ChoiceBulletSize(ob, 0);
431 } else if (ob == bullets_->input_bullet_latex) {
432 InputBulletLaTeX(ob, 0);
433 } else if (ob == bullets_->radio_bullet_depth_1 ||
434 ob == bullets_->radio_bullet_depth_2 ||
435 ob == bullets_->radio_bullet_depth_3 ||
436 ob == bullets_->radio_bullet_depth_4) {
438 } else if (ob == bullets_->radio_bullet_panel_standard ||
439 ob == bullets_->radio_bullet_panel_maths ||
440 ob == bullets_->radio_bullet_panel_ding1 ||
441 ob == bullets_->radio_bullet_panel_ding2 ||
442 ob == bullets_->radio_bullet_panel_ding3 ||
443 ob == bullets_->radio_bullet_panel_ding4) {
445 } else if (ob == bullets_->bmtable_bullet_panel) {
446 BulletBMTable(ob, 0);
449 bool const length_input = fl_get_choice(class_->choice_doc_skip) == 4;
450 if (ob == class_->choice_doc_skip) {
451 setEnabled(class_->input_doc_skip, length_input);
452 setEnabled(class_->choice_default_skip_units, length_input);
455 if (ob == class_->choice_doc_spacing)
456 setEnabled(class_->input_doc_spacing,
457 fl_get_choice(class_->choice_doc_spacing) == 4);
459 bool const skip_used = fl_get_button(class_->radio_doc_skip);
460 if (ob == class_->radio_doc_skip ||
461 ob == class_->radio_doc_indent) {
462 setEnabled(class_->choice_doc_skip, skip_used);
463 setEnabled(class_->input_doc_skip,
464 skip_used && length_input);
465 setEnabled(class_->choice_default_skip_units,
466 skip_used && length_input);
467 // Default unit choice is cm if metric, inches if US paper.
468 // If papersize is default, check the lyxrc-settings
469 int const paperchoice = fl_get_choice(paper_->choice_papersize);
470 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
471 || paperchoice == 2 || paperchoice > 5;
472 int const default_unit = metric ? 8 : 9;
473 if (rtrim(fl_get_input(class_->input_doc_skip)).empty())
474 fl_set_choice(class_->choice_default_skip_units,
478 if (ob == options_->check_use_natbib) {
479 setEnabled(options_->choice_citation_format,
480 fl_get_button(options_->check_use_natbib));
483 if (ob == dialog_->button_save_defaults) {
487 language_apply(params);
488 options_apply(params);
489 bullets_apply(params);
490 params.preamble = lv_.buffer()->params.preamble;
491 saveParamsAsDefault(params);
494 if (ob == dialog_->button_reset_defaults) {
495 BufferParams params = lv_.buffer()->params;
496 params.textclass = combo_doc_class->get() - 1;
497 params.useClassDefaults();
498 UpdateLayoutDocument(params);
501 if (ob == paper_->radio_landscape)
502 fl_set_choice(paper_->choice_paperpackage,
503 BufferParams::PACKAGE_NONE + 1);
505 if (ob == paper_->choice_papersize) {
506 int const paperchoice = fl_get_choice(paper_->choice_papersize);
507 bool const defsize = paperchoice == 1;
508 bool const custom = paperchoice == 2;
509 bool const a3size = paperchoice == 6;
510 bool const b3size = paperchoice == 9;
511 bool const b4size = paperchoice == 10;
514 fl_set_button(paper_->radio_portrait, 1);
516 bool const use_geom = (custom || a3size || b3size || b4size);
518 fl_set_button(paper_->check_use_geometry, int(use_geom));
520 setEnabled(paper_->input_top_margin, use_geom);
521 setEnabled(paper_->input_bottom_margin, use_geom);
522 setEnabled(paper_->input_inner_margin, use_geom);
523 setEnabled(paper_->input_outer_margin, use_geom);
524 setEnabled(paper_->input_head_height, use_geom);
525 setEnabled(paper_->input_head_sep, use_geom);
526 setEnabled(paper_->input_foot_skip, use_geom);
527 setEnabled(paper_->choice_top_margin_units, use_geom);
528 setEnabled(paper_->choice_bottom_margin_units, use_geom);
529 setEnabled(paper_->choice_inner_margin_units, use_geom);
530 setEnabled(paper_->choice_outer_margin_units, use_geom);
531 setEnabled(paper_->choice_head_height_units, use_geom);
532 setEnabled(paper_->choice_head_sep_units, use_geom);
533 setEnabled(paper_->choice_foot_skip_units, use_geom);
534 setEnabled(paper_->choice_custom_width_units, use_geom);
535 setEnabled(paper_->choice_custom_height_units, use_geom);
537 setEnabled(paper_->input_custom_width, custom);
538 setEnabled(paper_->input_custom_height, custom);
539 setEnabled(paper_->choice_custom_width_units, custom);
540 setEnabled(paper_->choice_custom_height_units, custom);
541 setEnabled(paper_->radio_portrait, !custom);
542 setEnabled(paper_->radio_landscape, !custom);
544 // Default unit choice is cm if metric, inches if US paper.
545 // If papersize is default, use the lyxrc-settings
546 bool const metric = (defsize && lyxrc.default_papersize > 3)
547 || paperchoice == 2 || paperchoice > 5;
548 int const default_unit = metric ? 8 : 9;
549 if (rtrim(fl_get_input(paper_->input_custom_width)).empty())
550 fl_set_choice(paper_->choice_custom_width_units,
552 if (rtrim(fl_get_input(paper_->input_custom_height)).empty())
553 fl_set_choice(paper_->choice_custom_height_units,
555 if (rtrim(fl_get_input(paper_->input_top_margin)).empty())
556 fl_set_choice(paper_->choice_top_margin_units,
558 if (rtrim(fl_get_input(paper_->input_bottom_margin)).empty())
559 fl_set_choice(paper_->choice_bottom_margin_units,
561 if (rtrim(fl_get_input(paper_->input_inner_margin)).empty())
562 fl_set_choice(paper_->choice_inner_margin_units,
564 if (rtrim(fl_get_input(paper_->input_outer_margin)).empty())
565 fl_set_choice(paper_->choice_outer_margin_units,
567 if (rtrim(fl_get_input(paper_->input_head_height)).empty())
568 fl_set_choice(paper_->choice_head_height_units,
570 if (rtrim(fl_get_input(paper_->input_head_sep)).empty())
571 fl_set_choice(paper_->choice_head_sep_units,
573 if (rtrim(fl_get_input(paper_->input_foot_skip)).empty())
574 fl_set_choice(paper_->choice_foot_skip_units,
578 if (ob == paper_->choice_papersize ||
579 ob == paper_->radio_portrait ||
580 ob == paper_->radio_landscape) {
582 setEnabled(paper_->choice_paperpackage,
583 //either default papersize (preferences)
584 //or document papersize has to be A4
585 (fl_get_choice(paper_->choice_papersize) == 7
586 || fl_get_choice(paper_->choice_papersize) == 1
587 && lyxrc.default_papersize == 5)
588 && fl_get_button(paper_->radio_portrait));
591 if (ob == paper_->choice_paperpackage) {
592 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
593 fl_set_button(paper_->check_use_geometry, 0);
595 setEnabled(paper_->input_top_margin, false);
596 setEnabled(paper_->input_bottom_margin, false);
597 setEnabled(paper_->input_inner_margin, false);
598 setEnabled(paper_->input_outer_margin, false);
599 setEnabled(paper_->input_head_height, false);
600 setEnabled(paper_->input_head_sep, false);
601 setEnabled(paper_->input_foot_skip, false);
602 setEnabled(paper_->choice_top_margin_units, false);
603 setEnabled(paper_->choice_bottom_margin_units, false);
604 setEnabled(paper_->choice_inner_margin_units, false);
605 setEnabled(paper_->choice_outer_margin_units, false);
606 setEnabled(paper_->choice_head_height_units, false);
607 setEnabled(paper_->choice_head_sep_units, false);
608 setEnabled(paper_->choice_foot_skip_units, false);
612 if (ob == paper_->check_use_geometry) {
613 //don't allow switching geometry off in custom papersize mode
614 //nor in A3, B3, and B4
615 int const choice = fl_get_choice(paper_->choice_papersize);
616 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
617 fl_set_button(paper_->check_use_geometry, 1);
619 fl_set_choice(paper_->choice_paperpackage,
620 BufferParams::PACKAGE_NONE + 1);
622 bool const use_geom = fl_get_button(paper_->check_use_geometry);
623 setEnabled(paper_->input_top_margin, use_geom);
624 setEnabled(paper_->input_bottom_margin, use_geom);
625 setEnabled(paper_->input_inner_margin, use_geom);
626 setEnabled(paper_->input_outer_margin, use_geom);
627 setEnabled(paper_->input_head_height, use_geom);
628 setEnabled(paper_->input_head_sep, use_geom);
629 setEnabled(paper_->input_foot_skip, use_geom);
630 setEnabled(paper_->choice_top_margin_units, use_geom);
631 setEnabled(paper_->choice_bottom_margin_units, use_geom);
632 setEnabled(paper_->choice_inner_margin_units, use_geom);
633 setEnabled(paper_->choice_outer_margin_units, use_geom);
634 setEnabled(paper_->choice_head_height_units, use_geom);
635 setEnabled(paper_->choice_head_sep_units, use_geom);
636 setEnabled(paper_->choice_foot_skip_units, use_geom);
639 return CheckDocumentInput(ob, 0);
643 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
645 FormDocument * pre = static_cast<FormDocument*>(v);
646 if (combox == pre->combo_doc_class.get())
647 pre->CheckChoiceClass(0, 0);
648 pre->bc().valid(pre->CheckDocumentInput(0,0));
652 bool FormDocument::class_apply(BufferParams ¶ms)
656 // If default skip is a "Length" but there's no text in the
657 // input field, reset the kind to "Medskip", which is the default.
658 if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
659 !*(fl_get_input (class_->input_doc_skip))) {
660 fl_set_choice (class_->choice_doc_skip, 2);
662 params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
663 params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
664 params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
666 params.textclass = combo_doc_class->get() - 1;
668 BufferParams::PARSEP tmpsep = params.paragraph_separation;
669 if (fl_get_button(class_->radio_doc_indent))
670 params.paragraph_separation = BufferParams::PARSEP_INDENT;
672 params.paragraph_separation = BufferParams::PARSEP_SKIP;
673 if (tmpsep != params.paragraph_separation)
676 VSpace tmpdefskip = params.getDefSkip();
677 switch (fl_get_choice (class_->choice_doc_skip)) {
679 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
682 params.setDefSkip(VSpace(VSpace::MEDSKIP));
685 params.setDefSkip(VSpace(VSpace::BIGSKIP));
689 string const length =
690 getLengthFromWidgets(class_->input_doc_skip,
691 class_->choice_default_skip_units);
693 params.setDefSkip(VSpace(LyXGlueLength(length)));
697 // DocumentDefskipCB assures that this never happens
698 params.setDefSkip(VSpace(VSpace::MEDSKIP));
701 if (!(tmpdefskip == params.getDefSkip()))
704 if (fl_get_button(class_->radio_doc_columns_two))
708 if (fl_get_button(class_->radio_doc_sides_two))
709 params.sides = LyXTextClass::TwoSides;
711 params.sides = LyXTextClass::OneSide;
713 Spacing tmpSpacing = params.spacing;
714 switch (fl_get_choice(class_->choice_doc_spacing)) {
716 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
717 params.spacing.set(Spacing::Single);
720 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
721 params.spacing.set(Spacing::Onehalf);
724 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
725 params.spacing.set(Spacing::Double);
728 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
729 params.spacing.set(Spacing::Other,
730 fl_get_input(class_->input_doc_spacing));
733 if (tmpSpacing != params.spacing)
736 params.options = fl_get_input(class_->input_doc_extra);
742 bool FormDocument::class_apply()
744 BufferParams ¶ms = lv_.buffer()->params;
746 unsigned int const old_class = params.textclass;
748 bool redo = class_apply(params);
750 if (params.textclass != old_class) {
751 // try to load new_class
752 if (textclasslist[params.textclass].load()) {
753 // successfully loaded
755 setMinibuffer(&lv_, _("Converting document to new document class..."));
756 int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
757 old_class, params.textclass,
758 &*(lv_.buffer()->paragraphs.begin()),
759 lv_.buffer()->params);
763 s = _("One paragraph couldn't be converted");
766 s += _(" paragraphs couldn't be converted");
768 Alert::alert(_("Conversion Errors!"),s,
769 _("into chosen document class"));
773 // problem changing class -- warn user and retain old style
774 Alert::alert(_("Conversion Errors!"),
775 _("Errors loading new document class."),
776 _("Reverting to original document class."));
777 combo_doc_class->select(int(old_class) + 1);
785 void FormDocument::paper_apply(BufferParams & params)
787 params.papersize2 = char(fl_get_choice(paper_->choice_papersize) - 1);
789 params.paperpackage =
790 char(fl_get_choice(paper_->choice_paperpackage) - 1);
792 // set params.papersize from params.papersize2 and params.paperpackage
793 params.setPaperStuff();
795 params.use_geometry = fl_get_button(paper_->check_use_geometry);
797 if (fl_get_button(paper_->radio_landscape))
798 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
800 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
803 getLengthFromWidgets(paper_->input_custom_width,
804 paper_->choice_custom_width_units);
807 getLengthFromWidgets(paper_->input_custom_height,
808 paper_->choice_custom_height_units);
811 getLengthFromWidgets(paper_->input_inner_margin,
812 paper_->choice_inner_margin_units);
815 getLengthFromWidgets(paper_->input_top_margin,
816 paper_->choice_top_margin_units);
819 getLengthFromWidgets(paper_->input_outer_margin,
820 paper_->choice_outer_margin_units);
822 params.bottommargin =
823 getLengthFromWidgets(paper_->input_bottom_margin,
824 paper_->choice_bottom_margin_units);
827 getLengthFromWidgets(paper_->input_head_height,
828 paper_->choice_head_height_units);
831 getLengthFromWidgets(paper_->input_head_sep,
832 paper_->choice_head_sep_units);
835 getLengthFromWidgets(paper_->input_foot_skip,
836 paper_->choice_foot_skip_units);
840 void FormDocument::paper_apply()
842 paper_apply(lv_.buffer()->params);
846 bool FormDocument::language_apply(BufferParams & params)
848 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
851 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
853 lga = InsetQuotes::EnglishQ;
856 lga = InsetQuotes::SwedishQ;
859 lga = InsetQuotes::GermanQ;
862 lga = InsetQuotes::PolishQ;
865 lga = InsetQuotes::FrenchQ;
868 lga = InsetQuotes::DanishQ;
871 params.quotes_language = lga;
872 if (fl_get_button(language_->radio_single))
873 params.quotes_times = InsetQuotes::SingleQ;
875 params.quotes_times = InsetQuotes::DoubleQ;
877 int const pos = combo_language->get();
878 Language const * old_language = params.language;
879 Language const * new_language = languages.getLanguage(lang_[pos-1]);
881 new_language = default_language;
883 if (old_language != new_language
884 && old_language->RightToLeft() == new_language->RightToLeft()
885 && !lv_.buffer()->isMultiLingual())
886 lv_.buffer()->changeLanguage(old_language, new_language);
888 if (old_language != new_language) {
892 params.language = new_language;
893 params.inputenc = fl_get_choice_text(language_->choice_inputenc);
899 bool FormDocument::language_apply()
901 return language_apply(lv_.buffer()->params);
905 bool FormDocument::options_apply(BufferParams & params)
909 params.graphicsDriver =
910 fl_get_choice_text(options_->choice_postscript_driver);
911 params.use_amsmath = fl_get_button(options_->check_use_amsmath);
912 params.use_natbib = fl_get_button(options_->check_use_natbib);
913 params.use_numerical_citations =
914 fl_get_choice(options_->choice_citation_format) - 1;
916 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
917 if (params.secnumdepth != tmpchar)
919 params.secnumdepth = tmpchar;
921 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
923 params.float_placement =
924 fl_get_input(options_->input_float_placement);
930 bool FormDocument::options_apply()
932 return options_apply(lv_.buffer()->params);
936 void FormDocument::bullets_apply(BufferParams & params)
938 /* update the bullet settings */
939 BufferParams & buf_params = lv_.buffer()->params;
941 // a little bit of loop unrolling
942 params.user_defined_bullets[0] = buf_params.temp_bullets[0];
943 params.user_defined_bullets[1] = buf_params.temp_bullets[1];
944 params.user_defined_bullets[2] = buf_params.temp_bullets[2];
945 params.user_defined_bullets[3] = buf_params.temp_bullets[3];
949 void FormDocument::bullets_apply()
951 bullets_apply(lv_.buffer()->params);
954 void FormDocument::UpdateClassParams(BufferParams const & params)
956 // These are the params that have to be updated on any class change
957 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
959 LyXTextClass const & tclass = textclasslist[params.textclass];
961 combo_doc_class->select(tclass.description());
962 fl_clear_choice(class_->choice_doc_fontsize);
963 fl_addto_choice(class_->choice_doc_fontsize, "default");
964 fl_addto_choice(class_->choice_doc_fontsize,
965 tclass.opt_fontsize().c_str());
966 fl_set_choice_text(class_->choice_doc_fontsize,
967 params.fontsize.c_str());
968 fl_clear_choice(class_->choice_doc_pagestyle);
969 fl_addto_choice(class_->choice_doc_pagestyle, "default");
970 fl_addto_choice(class_->choice_doc_pagestyle,
971 tclass.opt_pagestyle().c_str());
972 fl_set_choice_text(class_->choice_doc_pagestyle,
973 params.pagestyle.c_str());
977 void FormDocument::class_update(BufferParams const & params)
982 UpdateClassParams(params);
984 fl_set_choice_text(class_->choice_doc_fonts,
985 params.fonts.c_str());
986 fl_set_button(class_->radio_doc_indent, 0);
987 fl_set_button(class_->radio_doc_skip, 0);
988 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
989 fl_set_button(class_->radio_doc_indent, 1);
991 fl_set_button(class_->radio_doc_skip, 1);
993 bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
994 setEnabled(class_->choice_default_skip_units, input_length);
995 setEnabled(class_->input_doc_skip, input_length);
997 switch (params.getDefSkip().kind()) {
998 case VSpace::SMALLSKIP:
999 fl_set_choice (class_->choice_doc_skip, 1);
1001 case VSpace::MEDSKIP:
1002 fl_set_choice (class_->choice_doc_skip, 2);
1004 case VSpace::BIGSKIP:
1005 fl_set_choice (class_->choice_doc_skip, 3);
1007 case VSpace::LENGTH:
1009 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1010 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1011 || paperchoice == 2 || paperchoice > 5;
1012 string const default_unit = metric ? "cm" : "in";
1013 string const length = params.getDefSkip().asLyXCommand();
1014 updateWidgetsFromLengthString(class_->input_doc_skip,
1015 class_->choice_default_skip_units,
1016 length, default_unit);
1020 fl_set_choice (class_->choice_doc_skip, 2);
1023 fl_set_button(class_->radio_doc_sides_one, 0);
1024 fl_set_button(class_->radio_doc_sides_two, 0);
1025 setEnabled(class_->choice_doc_skip,
1026 fl_get_button(class_->radio_doc_skip));
1028 if (params.sides == LyXTextClass::TwoSides)
1029 fl_set_button(class_->radio_doc_sides_two, 1);
1031 fl_set_button(class_->radio_doc_sides_one, 1);
1032 fl_set_button(class_->radio_doc_columns_one, 0);
1033 fl_set_button(class_->radio_doc_columns_two, 0);
1034 if (params.columns == 2)
1035 fl_set_button(class_->radio_doc_columns_two, 1);
1037 fl_set_button(class_->radio_doc_columns_one, 1);
1039 fl_set_input(class_->input_doc_spacing, "");
1040 setEnabled(class_->input_doc_spacing, false);
1042 switch (params.spacing.getSpace()) {
1043 case Spacing::Default: // nothing bad should happen with this
1044 case Spacing::Single:
1046 fl_set_choice(class_->choice_doc_spacing, 1);
1048 case Spacing::Onehalf:
1050 fl_set_choice(class_->choice_doc_spacing, 2);
1052 case Spacing::Double:
1054 fl_set_choice(class_->choice_doc_spacing, 3);
1056 case Spacing::Other:
1058 fl_set_choice(class_->choice_doc_spacing, 4);
1060 sprintf(sval,"%g",params.spacing.getValue());
1061 fl_set_input(class_->input_doc_spacing, sval);
1062 setEnabled(class_->input_doc_spacing, true);
1066 if (!params.options.empty())
1067 fl_set_input(class_->input_doc_extra, params.options.c_str());
1069 fl_set_input(class_->input_doc_extra, "");
1073 void FormDocument::language_update(BufferParams const & params)
1075 if (!language_.get())
1078 int const pos = int(findPos(lang_, params.language->lang()));
1079 combo_language->select(pos+1);
1081 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1082 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1083 fl_set_button(language_->radio_single, 0);
1084 fl_set_button(language_->radio_double, 0);
1085 if (params.quotes_times == InsetQuotes::SingleQ)
1086 fl_set_button(language_->radio_single, 1);
1088 fl_set_button(language_->radio_double, 1);
1092 void FormDocument::options_update(BufferParams const & params)
1094 if (!options_.get())
1097 fl_set_choice_text(options_->choice_postscript_driver,
1098 params.graphicsDriver.c_str());
1099 fl_set_button(options_->check_use_amsmath, params.use_amsmath);
1100 fl_set_button(options_->check_use_natbib, params.use_natbib);
1101 fl_set_choice(options_->choice_citation_format,
1102 int(params.use_numerical_citations)+1);
1103 setEnabled(options_->choice_citation_format, params.use_natbib);
1104 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1105 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1106 if (!params.float_placement.empty())
1107 fl_set_input(options_->input_float_placement,
1108 params.float_placement.c_str());
1110 fl_set_input(options_->input_float_placement, "");
1114 void FormDocument::paper_update(BufferParams const & params)
1119 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1120 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1121 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1123 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1124 bool const useCustom = paperchoice == 2;
1125 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1127 fl_set_button(paper_->radio_portrait, 0);
1128 setEnabled(paper_->radio_portrait, !useCustom);
1129 fl_set_button(paper_->radio_landscape, 0);
1130 setEnabled(paper_->radio_landscape, !useCustom);
1132 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
1133 fl_set_button(paper_->radio_landscape, 1);
1135 fl_set_button(paper_->radio_portrait, 1);
1136 setEnabled(paper_->choice_paperpackage,
1137 //either default papersize (preferences)
1138 //or document papersize has to be A4
1140 || paperchoice == 1 && lyxrc.default_papersize == 5)
1141 && fl_get_button(paper_->radio_portrait));
1143 // Default unit choice is cm if metric, inches if US paper.
1144 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1145 || paperchoice == 2 || paperchoice > 5;
1146 string const default_unit = metric ? "cm" : "in";
1147 updateWidgetsFromLengthString(paper_->input_custom_width,
1148 paper_->choice_custom_width_units,
1149 params.paperwidth, default_unit);
1150 setEnabled(paper_->input_custom_width, useCustom);
1151 setEnabled(paper_->choice_custom_width_units, useCustom);
1153 updateWidgetsFromLengthString(paper_->input_custom_height,
1154 paper_->choice_custom_height_units,
1155 params.paperheight, default_unit);
1156 setEnabled(paper_->input_custom_height, useCustom);
1157 setEnabled(paper_->choice_custom_height_units, useCustom);
1159 updateWidgetsFromLengthString(paper_->input_inner_margin,
1160 paper_->choice_inner_margin_units,
1161 params.leftmargin, default_unit);
1162 setEnabled(paper_->input_inner_margin, useGeom);
1163 setEnabled(paper_->choice_inner_margin_units, useGeom);
1165 updateWidgetsFromLengthString(paper_->input_top_margin,
1166 paper_->choice_top_margin_units,
1167 params.topmargin, default_unit);
1168 setEnabled(paper_->input_top_margin, useGeom);
1169 setEnabled(paper_->choice_top_margin_units, useGeom);
1171 updateWidgetsFromLengthString(paper_->input_outer_margin,
1172 paper_->choice_outer_margin_units,
1173 params.rightmargin, default_unit);
1174 setEnabled(paper_->input_outer_margin, useGeom);
1175 setEnabled(paper_->choice_outer_margin_units, useGeom);
1177 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1178 paper_->choice_bottom_margin_units,
1179 params.bottommargin, default_unit);
1180 setEnabled(paper_->input_bottom_margin, useGeom);
1181 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1183 updateWidgetsFromLengthString(paper_->input_head_height,
1184 paper_->choice_head_height_units,
1185 params.headheight, default_unit);
1186 setEnabled(paper_->input_head_height, useGeom);
1187 setEnabled(paper_->choice_head_height_units, useGeom);
1189 updateWidgetsFromLengthString(paper_->input_head_sep,
1190 paper_->choice_head_sep_units,
1191 params.headsep, default_unit);
1192 setEnabled(paper_->input_head_sep, useGeom);
1193 setEnabled(paper_->choice_head_sep_units, useGeom);
1195 updateWidgetsFromLengthString(paper_->input_foot_skip,
1196 paper_->choice_foot_skip_units,
1197 params.footskip, default_unit);
1198 setEnabled(paper_->input_foot_skip, useGeom);
1199 setEnabled(paper_->choice_foot_skip_units, useGeom);
1201 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1205 void FormDocument::bullets_update(BufferParams const & params)
1207 if (!bullets_.get() ||
1209 (XpmVersion==4 && XpmRevision<7)))
1212 bool const isLinuxDoc = lv_.buffer()->isLinuxDoc();
1213 setEnabled(fbullet, !isLinuxDoc);
1215 if (isLinuxDoc) return;
1217 fl_set_button(bullets_->radio_bullet_depth_1, 1);
1218 fl_set_input(bullets_->input_bullet_latex,
1219 params.user_defined_bullets[0].getText().c_str());
1220 fl_set_choice(bullets_->choice_bullet_size,
1221 params.user_defined_bullets[0].getSize() + 2);
1225 void FormDocument::checkReadOnly()
1227 if (bc().readOnly(lv_.buffer()->isReadonly())) {
1228 combo_doc_class->deactivate();
1229 combo_language->deactivate();
1230 postWarning(_("Document is read-only."
1231 " No changes to layout permitted."));
1233 combo_doc_class->activate();
1234 combo_language->activate();
1240 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
1246 // this has to be all out of if/elseif because it has to deactivate
1247 // the document buttons and so the whole stuff has to be tested again.
1248 // disable OK/Apply if input is not valid
1249 str = fl_get_input(class_->input_doc_skip);
1250 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1251 str = fl_get_input(paper_->input_custom_width);
1252 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1253 str = fl_get_input(paper_->input_custom_height);
1254 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1255 str = fl_get_input(paper_->input_outer_margin);
1256 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1257 str = fl_get_input(paper_->input_inner_margin);
1258 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1259 str = fl_get_input(paper_->input_top_margin);
1260 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1261 str = fl_get_input(paper_->input_bottom_margin);
1262 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1263 str = fl_get_input(paper_->input_head_height);
1264 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1265 str = fl_get_input(paper_->input_head_sep);
1266 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1267 str = fl_get_input(paper_->input_foot_skip);
1268 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1270 //display warning if input is not valid
1271 if (ob == class_->input_doc_skip
1272 || ob == paper_->input_custom_width
1273 || ob == paper_->input_custom_height
1274 || ob == paper_->input_outer_margin
1275 || ob == paper_->input_inner_margin
1276 || ob == paper_->input_top_margin
1277 || ob == paper_->input_bottom_margin
1278 || ob == paper_->input_head_height
1279 || ob == paper_->input_head_sep
1280 || ob == paper_->input_foot_skip) {
1282 postWarning(_("Invalid Length (valid example: 10mm)"));
1290 // "Synchronize" the choice and the input field, so that it
1291 // is impossible to commit senseless data.
1292 input = fl_get_input (class_->input_doc_skip);
1293 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1295 else if (fl_get_choice(class_->choice_doc_skip) != 4)
1296 fl_set_input (class_->input_doc_skip, "");
1298 input = fl_get_input(class_->input_doc_spacing);
1299 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1301 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
1302 fl_set_input (class_->input_doc_spacing, "");
1307 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1309 BufferParams & param = lv_.buffer()->params;
1311 // convert from 1-6 range to -1-4
1312 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1313 fl_set_input(bullets_->input_bullet_latex,
1314 param.temp_bullets[current_bullet_depth].getText().c_str());
1318 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1320 BufferParams & param = lv_.buffer()->params;
1322 param.temp_bullets[current_bullet_depth].
1323 setText(fl_get_input(bullets_->input_bullet_latex));
1327 void FormDocument::BulletDepth(FL_OBJECT * ob)
1329 /* Should I do the following: */
1330 /* 1. change to the panel that the current bullet belongs in */
1331 /* 2. show that bullet as selected */
1332 /* 3. change the size setting to the size of the bullet in Q.*/
1333 /* 4. display the latex equivalent in the latex box */
1335 /* I'm inclined to just go with 3 and 4 at the moment and */
1336 /* maybe try to support the others later */
1337 BufferParams & param = lv_.buffer()->params;
1340 if (ob == bullets_->radio_bullet_depth_1)
1342 else if (ob == bullets_->radio_bullet_depth_2)
1344 else if (ob == bullets_->radio_bullet_depth_3)
1346 else if (ob == bullets_->radio_bullet_depth_4)
1349 switch (fl_get_button_numb(ob)) {
1351 // right mouse button resets to default
1352 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1354 current_bullet_depth = data;
1355 fl_set_input(bullets_->input_bullet_latex,
1356 param.temp_bullets[data].getText().c_str());
1357 fl_set_choice(bullets_->choice_bullet_size,
1358 param.temp_bullets[data].getSize() + 2);
1363 void FormDocument::BulletPanel(FL_OBJECT * ob)
1365 /* Here we have to change the background pixmap to that selected */
1366 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1369 if (ob == bullets_->radio_bullet_panel_standard)
1371 else if (ob == bullets_->radio_bullet_panel_maths)
1373 else if (ob == bullets_->radio_bullet_panel_ding2)
1375 else if (ob == bullets_->radio_bullet_panel_ding3)
1377 else if (ob == bullets_->radio_bullet_panel_ding4)
1379 else if (ob == bullets_->radio_bullet_panel_ding1)
1382 if (data != current_bullet_panel) {
1383 fl_freeze_form(bullets_->form);
1384 current_bullet_panel = data;
1386 /* free the current pixmap */
1387 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1389 if (ob == bullets_->radio_bullet_panel_standard) {
1390 new_panel = "standard";
1391 } else if (ob == bullets_->radio_bullet_panel_maths ) {
1392 new_panel = "amssymb";
1393 } else if (ob == bullets_->radio_bullet_panel_ding2) {
1394 new_panel = "psnfss1";
1395 } else if (ob == bullets_->radio_bullet_panel_ding3) {
1396 new_panel = "psnfss2";
1397 } else if (ob == bullets_->radio_bullet_panel_ding4) {
1398 new_panel = "psnfss3";
1399 } else if (ob == bullets_->radio_bullet_panel_ding1) {
1400 new_panel = "psnfss4";
1402 /* something very wrong happened */
1403 // play it safe for now but should be an exception
1404 current_bullet_panel = 0; // standard panel
1405 new_panel = "standard";
1407 new_panel += ".xpm";
1408 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1409 LibFileSearch("images", new_panel).c_str());
1410 fl_redraw_object(bullets_->bmtable_bullet_panel);
1411 fl_unfreeze_form(bullets_->form);
1416 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1418 /* handle the user input by setting the current bullet depth's pixmap */
1419 /* to that extracted from the current chosen position of the BMTable */
1420 /* Don't forget to free the button's old pixmap first. */
1422 BufferParams & param = lv_.buffer()->params;
1423 int bmtable_button = fl_get_bmtable(ob);
1425 /* try to keep the button held down till another is pushed */
1426 /* fl_set_bmtable(ob, 1, bmtable_button); */
1427 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1428 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1429 fl_set_input(bullets_->input_bullet_latex,
1430 param.temp_bullets[current_bullet_depth].getText().c_str());
1434 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1437 ob = class_->choice_doc_class;
1439 lv_.prohibitInput();
1441 unsigned int tc = combo_doc_class->get() - 1;
1442 if (textclasslist[tc].load()) {
1443 // we use a copy of the bufferparams because we do not
1444 // want to modify them yet.
1445 BufferParams params = lv_.buffer()->params;
1447 if (lyxrc.auto_reset_options) {
1448 params.textclass = tc;
1449 params.useClassDefaults();
1450 UpdateLayoutDocument(params);
1452 // update the params which are needed in any case
1453 // (fontsizes, pagestyle)
1454 params.textclass = tc;
1455 UpdateClassParams(params);
1459 // unable to load new style
1460 Alert::alert(_("Conversion Errors!"),
1461 _("Unable to switch to new document class."),
1462 _("Reverting to original document class."));
1463 combo_doc_class->select(int(lv_.buffer()->params.textclass) + 1);
1469 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1475 class_update(params);
1476 paper_update(params);
1477 language_update(params);
1478 options_update(params);
1479 bullets_update(params);