3 * Copyright 2000-2001 The LyX Team.
4 * See the file COPYING.
6 * \author Jürgen Vigna, jug@sad.it
11 #include FORMS_H_LOCATION
12 #include XPM_H_LOCATION
15 #pragma implementation
18 #include "FormDocument.h"
19 #include "forms/form_document.h"
21 #include "lyxtextclasslist.h"
23 #include "tex-strings.h"
24 #include "bufferparams.h"
28 #include "frnt_lang.h"
29 #include "frontends/LyXView.h"
32 #include "BufferView.h"
35 #include "CutAndPaste.h"
36 #include "bufferview_funcs.h"
37 #include "xforms_helpers.h"
39 #include "input_validators.h" // fl_unsigned_float_filter
40 #include "helper_funcs.h"
41 #include "lyx_main.h" // for user_lyxdir
43 #include "insets/insetquotes.h"
45 #include "support/filetools.h"
46 #include "support/lstrings.h"
48 #include FORMS_H_LOCATION
50 #include <boost/bind.hpp>
56 using Liason::setMinibuffer;
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,
183 combo_doc_class->shortcut("#C",1);
184 combo_doc_class->setcallback(ComboInputCB, this);
186 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
187 cit != textclasslist.end(); ++cit) {
188 combo_doc_class->addto(cit->description());
191 fl_addto_choice(class_->choice_doc_spacing,
192 _(" Single | OneHalf | Double | Custom "));
193 fl_addto_choice(class_->choice_doc_fontsize, "default|10|11|12");
194 for (n=0; tex_fonts[n][0]; ++n) {
195 fl_addto_choice(class_->choice_doc_fonts,tex_fonts[n]);
197 fl_addto_choice(class_->choice_doc_pagestyle,
198 "default|empty|plain|headings|fancy");
199 fl_addto_choice(class_->choice_doc_skip,
200 _(" Smallskip | Medskip | Bigskip | Length "));
201 fl_addto_choice(class_->choice_default_skip_units, units.c_str());
202 fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
203 fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
204 fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
206 setPrehandler(class_->input_doc_extra);
207 setPrehandler(class_->input_doc_skip);
208 setPrehandler(class_->input_doc_spacing);
210 // Set input filters on doc spacing to make it accept only
212 fl_set_input_filter(class_->input_doc_spacing, fl_unsigned_float_filter);
214 bc().addReadOnly (class_->radio_doc_indent);
215 bc().addReadOnly (class_->radio_doc_skip);
217 bc().addReadOnly (class_->choice_doc_pagestyle);
218 bc().addReadOnly (class_->choice_doc_fonts);
219 bc().addReadOnly (class_->choice_doc_fontsize);
220 bc().addReadOnly (class_->radio_doc_sides_one);
221 bc().addReadOnly (class_->radio_doc_sides_two);
222 bc().addReadOnly (class_->radio_doc_columns_one);
223 bc().addReadOnly (class_->radio_doc_columns_two);
224 bc().addReadOnly (class_->input_doc_extra);
225 bc().addReadOnly (class_->input_doc_skip);
226 bc().addReadOnly (class_->choice_doc_skip);
227 bc().addReadOnly (class_->choice_doc_spacing);
228 bc().addReadOnly (class_->input_doc_spacing);
230 // the document language form
231 language_.reset(build_document_language(this));
232 fl_addto_choice(language_->choice_inputenc,
233 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
234 "|koi8-r|koi8-u|cp866|cp1251|iso88595|pt154");
236 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
237 // Store the identifiers for later
238 lang_ = getSecond(langs);
240 // The language is a combo-box and has to be inserted manually
241 obj = language_->choice_language;
242 fl_deactivate_object(obj);
243 fl_addto_form(language_->form);
244 combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
245 combo_language->add(obj->x, obj->y, obj->w, obj->h, 400,
247 combo_language->shortcut("#L",1);
248 combo_language->setcallback(ComboInputCB, this);
251 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
252 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
253 for (; lit != lend; ++lit) {
254 combo_language->addto(lit->first);
256 combo_language->select(1);
258 fl_addto_choice(language_->choice_quotes_language,
259 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
260 " «text» | »text« "));
262 bc().addReadOnly (language_->choice_inputenc);
263 bc().addReadOnly (language_->choice_quotes_language);
264 bc().addReadOnly (language_->radio_single);
265 bc().addReadOnly (language_->radio_double);
267 // the document options form
268 options_.reset(build_document_options(this));
269 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
270 setPrehandler(options_->input_float_placement);
272 fl_set_counter_bounds(options_->counter_secnumdepth,-2,5);
273 fl_set_counter_bounds(options_->counter_tocdepth,-1,5);
274 fl_set_counter_step(options_->counter_secnumdepth,1,1);
275 fl_set_counter_step(options_->counter_tocdepth,1,1);
276 fl_set_counter_precision(options_->counter_secnumdepth, 0);
277 fl_set_counter_precision(options_->counter_tocdepth, 0);
278 for (n=0; tex_graphics[n][0]; ++n) {
279 fl_addto_choice(options_->choice_postscript_driver,
282 fl_addto_choice(options_->choice_citation_format,
283 _(" Author-year | Numerical "));
285 bc_.addReadOnly (options_->counter_secnumdepth);
286 bc_.addReadOnly (options_->counter_tocdepth);
287 bc_.addReadOnly (options_->check_use_amsmath);
288 bc_.addReadOnly (options_->check_use_natbib);
289 bc_.addReadOnly (options_->choice_citation_format);
290 bc_.addReadOnly (options_->input_float_placement);
291 bc_.addReadOnly (options_->choice_postscript_driver);
293 // the document bullets form
294 bullets_.reset(build_document_bullet(this));
295 fl_addto_choice(bullets_->choice_bullet_size,
296 _(" default | tiny | script | footnote | small |"
297 " normal | large | Large | LARGE | huge | Huge"));
298 fl_set_choice(bullets_->choice_bullet_size, 1);
299 fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
300 setPrehandler(bullets_->input_bullet_latex);
301 fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
303 string const bmtablefile = LibFileSearch("images", "standard", "xpm");
304 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
305 bmtablefile.c_str());
307 bc_.addReadOnly(bullets_->radio_bullet_depth_1);
308 bc_.addReadOnly(bullets_->radio_bullet_depth_2);
309 bc_.addReadOnly(bullets_->radio_bullet_depth_3);
310 bc_.addReadOnly(bullets_->radio_bullet_depth_4);
311 bc_.addReadOnly(bullets_->radio_bullet_panel_standard);
312 bc_.addReadOnly(bullets_->radio_bullet_panel_maths);
313 bc_.addReadOnly(bullets_->radio_bullet_panel_ding1);
314 bc_.addReadOnly(bullets_->radio_bullet_panel_ding2);
315 bc_.addReadOnly(bullets_->radio_bullet_panel_ding3);
316 bc_.addReadOnly(bullets_->radio_bullet_panel_ding4);
318 bc().addReadOnly (bullets_->bmtable_bullet_panel);
319 bc().addReadOnly (bullets_->choice_bullet_size);
320 bc().addReadOnly (bullets_->input_bullet_latex);
322 fl_addto_tabfolder(dialog_->tabfolder,_("Document"),
324 fl_addto_tabfolder(dialog_->tabfolder,_("Paper"),
326 fl_addto_tabfolder(dialog_->tabfolder,_("Language"),
328 fl_addto_tabfolder(dialog_->tabfolder,_("Extra"),
330 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets"),
332 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
333 lyxerr << _("Your version of libXpm is older than 4.7.\n"
334 "The `bullet' tab of the document dialog "
335 "has been disabled") << '\n';
336 fl_deactivate_object(fbullet);
337 fl_set_object_lcol(fbullet, FL_INACTIVE);
342 void FormDocument::apply()
344 if (!lv_.view()->available() || !dialog_.get())
347 bool redo = class_apply();
349 redo = language_apply() || redo;
350 redo = options_apply() || redo;
354 lv_.view()->redoCurrentBuffer();
356 lv_.buffer()->markDirty();
357 setMinibuffer(&lv_, _("Document layout set"));
361 void FormDocument::cancel()
363 // this avoids confusion when reopening
364 BufferParams & param = lv_.buffer()->params;
365 param.temp_bullets[0] = param.user_defined_bullets[0];
366 param.temp_bullets[1] = param.user_defined_bullets[1];
367 param.temp_bullets[2] = param.user_defined_bullets[2];
368 param.temp_bullets[3] = param.user_defined_bullets[3];
373 void FormDocument::update()
380 BufferParams const & params = lv_.buffer()->params;
382 class_update(params);
383 paper_update(params);
384 language_update(params);
385 options_update(params);
386 bullets_update(params);
391 // should this go elsewhere? Maybe a ControllerDocument? (JMarc)
392 /** Save the buffer's parameters as user default.
393 This function saves a file \c user_lyxdir/templates/defaults.lyx
394 which parameters are those of the current buffer. This file
395 is used as a default template when creating a new
396 file. Returns \c true on success.
398 bool saveParamsAsDefault(BufferParams const ¶ms)
400 if (!Alert::askQuestion(_("Do you want to save the current settings"),
401 _("for the document layout as default?"),
402 _("(they will be valid for any new document)")))
405 string const fname = AddName(AddPath(user_lyxdir, "templates/"),
407 Buffer defaults(fname);
408 defaults.params = params;
410 // add an empty paragraph. Is this enough?
411 defaults.paragraphs.set(new Paragraph);
413 return defaults.writeFile(defaults.fileName());
419 bool FormDocument::input(FL_OBJECT * ob, long)
421 if (ob == class_->choice_doc_class) {
422 CheckChoiceClass(ob, 0);
423 } else if (ob == bullets_->choice_bullet_size) {
424 ChoiceBulletSize(ob, 0);
425 } else if (ob == bullets_->input_bullet_latex) {
426 InputBulletLaTeX(ob, 0);
427 } else if (ob == bullets_->radio_bullet_depth_1 ||
428 ob == bullets_->radio_bullet_depth_2 ||
429 ob == bullets_->radio_bullet_depth_3 ||
430 ob == bullets_->radio_bullet_depth_4) {
432 } else if (ob == bullets_->radio_bullet_panel_standard ||
433 ob == bullets_->radio_bullet_panel_maths ||
434 ob == bullets_->radio_bullet_panel_ding1 ||
435 ob == bullets_->radio_bullet_panel_ding2 ||
436 ob == bullets_->radio_bullet_panel_ding3 ||
437 ob == bullets_->radio_bullet_panel_ding4) {
439 } else if (ob == bullets_->bmtable_bullet_panel) {
440 BulletBMTable(ob, 0);
443 bool const length_input = fl_get_choice(class_->choice_doc_skip) == 4;
444 if (ob == class_->choice_doc_skip) {
445 setEnabled(class_->input_doc_skip, length_input);
446 setEnabled(class_->choice_default_skip_units, length_input);
449 if (ob == class_->choice_doc_spacing)
450 setEnabled(class_->input_doc_spacing,
451 fl_get_choice(class_->choice_doc_spacing) == 4);
453 bool const skip_used = fl_get_button(class_->radio_doc_skip);
454 if (ob == class_->radio_doc_skip ||
455 ob == class_->radio_doc_indent) {
456 setEnabled(class_->choice_doc_skip, skip_used);
457 setEnabled(class_->input_doc_skip,
458 skip_used && length_input);
459 setEnabled(class_->choice_default_skip_units,
460 skip_used && length_input);
461 // Default unit choice is cm if metric, inches if US paper.
462 // If papersize is default, check the lyxrc-settings
463 int const paperchoice = fl_get_choice(paper_->choice_papersize);
464 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
465 || paperchoice == 2 || paperchoice > 5;
466 int const default_unit = metric ? 8 : 9;
467 if (rtrim(fl_get_input(class_->input_doc_skip)).empty())
468 fl_set_choice(class_->choice_default_skip_units,
472 if (ob == options_->check_use_natbib) {
473 setEnabled(options_->choice_citation_format,
474 fl_get_button(options_->check_use_natbib));
477 if (ob == dialog_->button_save_defaults) {
481 language_apply(params);
482 options_apply(params);
483 bullets_apply(params);
484 params.preamble = lv_.buffer()->params.preamble;
485 saveParamsAsDefault(params);
488 if (ob == dialog_->button_reset_defaults) {
489 BufferParams params = lv_.buffer()->params;
490 params.textclass = combo_doc_class->get() - 1;
491 params.useClassDefaults();
492 UpdateLayoutDocument(params);
495 if (ob == paper_->radio_landscape)
496 fl_set_choice(paper_->choice_paperpackage,
497 BufferParams::PACKAGE_NONE + 1);
499 if (ob == paper_->choice_papersize) {
500 int const paperchoice = fl_get_choice(paper_->choice_papersize);
501 bool const defsize = paperchoice == 1;
502 bool const custom = paperchoice == 2;
503 bool const a3size = paperchoice == 6;
504 bool const b3size = paperchoice == 9;
505 bool const b4size = paperchoice == 10;
508 fl_set_button(paper_->radio_portrait, 1);
510 bool const use_geom = (custom || a3size || b3size || b4size);
512 fl_set_button(paper_->check_use_geometry, int(use_geom));
514 setEnabled(paper_->input_top_margin, use_geom);
515 setEnabled(paper_->input_bottom_margin, use_geom);
516 setEnabled(paper_->input_inner_margin, use_geom);
517 setEnabled(paper_->input_outer_margin, use_geom);
518 setEnabled(paper_->input_head_height, use_geom);
519 setEnabled(paper_->input_head_sep, use_geom);
520 setEnabled(paper_->input_foot_skip, use_geom);
521 setEnabled(paper_->choice_top_margin_units, use_geom);
522 setEnabled(paper_->choice_bottom_margin_units, use_geom);
523 setEnabled(paper_->choice_inner_margin_units, use_geom);
524 setEnabled(paper_->choice_outer_margin_units, use_geom);
525 setEnabled(paper_->choice_head_height_units, use_geom);
526 setEnabled(paper_->choice_head_sep_units, use_geom);
527 setEnabled(paper_->choice_foot_skip_units, use_geom);
528 setEnabled(paper_->choice_custom_width_units, use_geom);
529 setEnabled(paper_->choice_custom_height_units, use_geom);
531 setEnabled(paper_->input_custom_width, custom);
532 setEnabled(paper_->input_custom_height, custom);
533 setEnabled(paper_->choice_custom_width_units, custom);
534 setEnabled(paper_->choice_custom_height_units, custom);
535 setEnabled(paper_->radio_portrait, !custom);
536 setEnabled(paper_->radio_landscape, !custom);
538 // Default unit choice is cm if metric, inches if US paper.
539 // If papersize is default, use the lyxrc-settings
540 bool const metric = (defsize && lyxrc.default_papersize > 3)
541 || paperchoice == 2 || paperchoice > 5;
542 int const default_unit = metric ? 8 : 9;
543 if (rtrim(fl_get_input(paper_->input_custom_width)).empty())
544 fl_set_choice(paper_->choice_custom_width_units,
546 if (rtrim(fl_get_input(paper_->input_custom_height)).empty())
547 fl_set_choice(paper_->choice_custom_height_units,
549 if (rtrim(fl_get_input(paper_->input_top_margin)).empty())
550 fl_set_choice(paper_->choice_top_margin_units,
552 if (rtrim(fl_get_input(paper_->input_bottom_margin)).empty())
553 fl_set_choice(paper_->choice_bottom_margin_units,
555 if (rtrim(fl_get_input(paper_->input_inner_margin)).empty())
556 fl_set_choice(paper_->choice_inner_margin_units,
558 if (rtrim(fl_get_input(paper_->input_outer_margin)).empty())
559 fl_set_choice(paper_->choice_outer_margin_units,
561 if (rtrim(fl_get_input(paper_->input_head_height)).empty())
562 fl_set_choice(paper_->choice_head_height_units,
564 if (rtrim(fl_get_input(paper_->input_head_sep)).empty())
565 fl_set_choice(paper_->choice_head_sep_units,
567 if (rtrim(fl_get_input(paper_->input_foot_skip)).empty())
568 fl_set_choice(paper_->choice_foot_skip_units,
572 if (ob == paper_->choice_papersize ||
573 ob == paper_->radio_portrait ||
574 ob == paper_->radio_landscape) {
576 setEnabled(paper_->choice_paperpackage,
577 //either default papersize (preferences)
578 //or document papersize has to be A4
579 (fl_get_choice(paper_->choice_papersize) == 7
580 || fl_get_choice(paper_->choice_papersize) == 1
581 && lyxrc.default_papersize == 5)
582 && fl_get_button(paper_->radio_portrait));
585 if (ob == paper_->choice_paperpackage) {
586 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
587 fl_set_button(paper_->check_use_geometry, 0);
589 setEnabled(paper_->input_top_margin, false);
590 setEnabled(paper_->input_bottom_margin, false);
591 setEnabled(paper_->input_inner_margin, false);
592 setEnabled(paper_->input_outer_margin, false);
593 setEnabled(paper_->input_head_height, false);
594 setEnabled(paper_->input_head_sep, false);
595 setEnabled(paper_->input_foot_skip, false);
596 setEnabled(paper_->choice_top_margin_units, false);
597 setEnabled(paper_->choice_bottom_margin_units, false);
598 setEnabled(paper_->choice_inner_margin_units, false);
599 setEnabled(paper_->choice_outer_margin_units, false);
600 setEnabled(paper_->choice_head_height_units, false);
601 setEnabled(paper_->choice_head_sep_units, false);
602 setEnabled(paper_->choice_foot_skip_units, false);
606 if (ob == paper_->check_use_geometry) {
607 //don't allow switching geometry off in custom papersize mode
608 //nor in A3, B3, and B4
609 int const choice = fl_get_choice(paper_->choice_papersize);
610 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
611 fl_set_button(paper_->check_use_geometry, 1);
613 fl_set_choice(paper_->choice_paperpackage,
614 BufferParams::PACKAGE_NONE + 1);
616 bool const use_geom = fl_get_button(paper_->check_use_geometry);
617 setEnabled(paper_->input_top_margin, use_geom);
618 setEnabled(paper_->input_bottom_margin, use_geom);
619 setEnabled(paper_->input_inner_margin, use_geom);
620 setEnabled(paper_->input_outer_margin, use_geom);
621 setEnabled(paper_->input_head_height, use_geom);
622 setEnabled(paper_->input_head_sep, use_geom);
623 setEnabled(paper_->input_foot_skip, use_geom);
624 setEnabled(paper_->choice_top_margin_units, use_geom);
625 setEnabled(paper_->choice_bottom_margin_units, use_geom);
626 setEnabled(paper_->choice_inner_margin_units, use_geom);
627 setEnabled(paper_->choice_outer_margin_units, use_geom);
628 setEnabled(paper_->choice_head_height_units, use_geom);
629 setEnabled(paper_->choice_head_sep_units, use_geom);
630 setEnabled(paper_->choice_foot_skip_units, use_geom);
633 return CheckDocumentInput(ob, 0);
637 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
639 FormDocument * pre = static_cast<FormDocument*>(v);
640 if (combox == pre->combo_doc_class.get())
641 pre->CheckChoiceClass(0, 0);
642 pre->bc().valid(pre->CheckDocumentInput(0,0));
646 bool FormDocument::class_apply(BufferParams ¶ms)
650 // If default skip is a "Length" but there's no text in the
651 // input field, reset the kind to "Medskip", which is the default.
652 if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
653 !*(fl_get_input (class_->input_doc_skip))) {
654 fl_set_choice (class_->choice_doc_skip, 2);
656 params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
657 params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
658 params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
660 params.textclass = combo_doc_class->get() - 1;
662 BufferParams::PARSEP tmpsep = params.paragraph_separation;
663 if (fl_get_button(class_->radio_doc_indent))
664 params.paragraph_separation = BufferParams::PARSEP_INDENT;
666 params.paragraph_separation = BufferParams::PARSEP_SKIP;
667 if (tmpsep != params.paragraph_separation)
670 VSpace tmpdefskip = params.getDefSkip();
671 switch (fl_get_choice (class_->choice_doc_skip)) {
673 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
676 params.setDefSkip(VSpace(VSpace::MEDSKIP));
679 params.setDefSkip(VSpace(VSpace::BIGSKIP));
683 string const length =
684 getLengthFromWidgets(class_->input_doc_skip,
685 class_->choice_default_skip_units);
687 params.setDefSkip(VSpace(LyXGlueLength(length)));
691 // DocumentDefskipCB assures that this never happens
692 params.setDefSkip(VSpace(VSpace::MEDSKIP));
695 if (!(tmpdefskip == params.getDefSkip()))
698 if (fl_get_button(class_->radio_doc_columns_two))
702 if (fl_get_button(class_->radio_doc_sides_two))
703 params.sides = LyXTextClass::TwoSides;
705 params.sides = LyXTextClass::OneSide;
707 Spacing tmpSpacing = params.spacing;
708 switch (fl_get_choice(class_->choice_doc_spacing)) {
710 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
711 params.spacing.set(Spacing::Single);
714 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
715 params.spacing.set(Spacing::Onehalf);
718 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
719 params.spacing.set(Spacing::Double);
722 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
723 params.spacing.set(Spacing::Other,
724 fl_get_input(class_->input_doc_spacing));
727 if (tmpSpacing != params.spacing)
730 params.options = fl_get_input(class_->input_doc_extra);
736 bool FormDocument::class_apply()
738 BufferParams ¶ms = lv_.buffer()->params;
740 unsigned int const old_class = params.textclass;
742 bool redo = class_apply(params);
744 if (params.textclass != old_class) {
745 // try to load new_class
746 if (textclasslist[params.textclass].load()) {
747 // successfully loaded
749 setMinibuffer(&lv_, _("Converting document to new document class..."));
750 int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
751 old_class, params.textclass,
752 &*(lv_.buffer()->paragraphs.begin()),
753 lv_.buffer()->params);
757 s = _("One paragraph couldn't be converted");
760 s += _(" paragraphs couldn't be converted");
762 Alert::alert(_("Conversion Errors!"),s,
763 _("into chosen document class"));
767 // problem changing class -- warn user and retain old style
768 Alert::alert(_("Conversion Errors!"),
769 _("Errors loading new document class."),
770 _("Reverting to original document class."));
771 combo_doc_class->select(int(old_class) + 1);
779 void FormDocument::paper_apply(BufferParams & params)
781 params.papersize2 = char(fl_get_choice(paper_->choice_papersize)-1);
783 params.paperpackage =
784 char(fl_get_choice(paper_->choice_paperpackage)-1);
786 // set params.papersize from params.papersize2 and params.paperpackage
787 params.setPaperStuff();
789 params.use_geometry = fl_get_button(paper_->check_use_geometry);
791 if (fl_get_button(paper_->radio_landscape))
792 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
794 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
797 getLengthFromWidgets(paper_->input_custom_width,
798 paper_->choice_custom_width_units);
801 getLengthFromWidgets(paper_->input_custom_height,
802 paper_->choice_custom_height_units);
805 getLengthFromWidgets(paper_->input_inner_margin,
806 paper_->choice_inner_margin_units);
809 getLengthFromWidgets(paper_->input_top_margin,
810 paper_->choice_top_margin_units);
813 getLengthFromWidgets(paper_->input_outer_margin,
814 paper_->choice_outer_margin_units);
816 params.bottommargin =
817 getLengthFromWidgets(paper_->input_bottom_margin,
818 paper_->choice_bottom_margin_units);
821 getLengthFromWidgets(paper_->input_head_height,
822 paper_->choice_head_height_units);
825 getLengthFromWidgets(paper_->input_head_sep,
826 paper_->choice_head_sep_units);
829 getLengthFromWidgets(paper_->input_foot_skip,
830 paper_->choice_foot_skip_units);
834 void FormDocument::paper_apply()
836 paper_apply(lv_.buffer()->params);
840 bool FormDocument::language_apply(BufferParams & params)
842 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
845 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
847 lga = InsetQuotes::EnglishQ;
850 lga = InsetQuotes::SwedishQ;
853 lga = InsetQuotes::GermanQ;
856 lga = InsetQuotes::PolishQ;
859 lga = InsetQuotes::FrenchQ;
862 lga = InsetQuotes::DanishQ;
865 params.quotes_language = lga;
866 if (fl_get_button(language_->radio_single))
867 params.quotes_times = InsetQuotes::SingleQ;
869 params.quotes_times = InsetQuotes::DoubleQ;
871 int const pos = combo_language->get();
872 Language const * old_language = params.language;
873 Language const * new_language = languages.getLanguage(lang_[pos-1]);
875 new_language = default_language;
877 if (old_language != new_language
878 && old_language->RightToLeft() == new_language->RightToLeft()
879 && !lv_.buffer()->isMultiLingual())
880 lv_.buffer()->changeLanguage(old_language, new_language);
882 if (old_language != new_language) {
886 params.language = new_language;
887 params.inputenc = fl_get_choice_text(language_->choice_inputenc);
893 bool FormDocument::language_apply()
895 return language_apply(lv_.buffer()->params);
899 bool FormDocument::options_apply(BufferParams & params)
903 params.graphicsDriver =
904 fl_get_choice_text(options_->choice_postscript_driver);
905 params.use_amsmath = fl_get_button(options_->check_use_amsmath);
906 params.use_natbib = fl_get_button(options_->check_use_natbib);
907 params.use_numerical_citations =
908 fl_get_choice(options_->choice_citation_format)-1;
910 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
911 if (params.secnumdepth != tmpchar)
913 params.secnumdepth = tmpchar;
915 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
917 params.float_placement =
918 fl_get_input(options_->input_float_placement);
924 bool FormDocument::options_apply()
926 return options_apply(lv_.buffer()->params);
930 void FormDocument::bullets_apply(BufferParams & params)
932 /* update the bullet settings */
933 BufferParams & buf_params = lv_.buffer()->params;
935 // a little bit of loop unrolling
936 params.user_defined_bullets[0] = buf_params.temp_bullets[0];
937 params.user_defined_bullets[1] = buf_params.temp_bullets[1];
938 params.user_defined_bullets[2] = buf_params.temp_bullets[2];
939 params.user_defined_bullets[3] = buf_params.temp_bullets[3];
943 void FormDocument::bullets_apply()
945 bullets_apply(lv_.buffer()->params);
948 void FormDocument::UpdateClassParams(BufferParams const & params)
950 // These are the params that have to be updated on any class change
951 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
953 LyXTextClass const & tclass = textclasslist[params.textclass];
955 combo_doc_class->select(tclass.description());
956 fl_clear_choice(class_->choice_doc_fontsize);
957 fl_addto_choice(class_->choice_doc_fontsize, "default");
958 fl_addto_choice(class_->choice_doc_fontsize,
959 tclass.opt_fontsize().c_str());
960 fl_set_choice_text(class_->choice_doc_fontsize,
961 params.fontsize.c_str());
962 fl_clear_choice(class_->choice_doc_pagestyle);
963 fl_addto_choice(class_->choice_doc_pagestyle, "default");
964 fl_addto_choice(class_->choice_doc_pagestyle,
965 tclass.opt_pagestyle().c_str());
966 fl_set_choice_text(class_->choice_doc_pagestyle,
967 params.pagestyle.c_str());
971 void FormDocument::class_update(BufferParams const & params)
976 UpdateClassParams(params);
978 fl_set_choice_text(class_->choice_doc_fonts,
979 params.fonts.c_str());
980 fl_set_button(class_->radio_doc_indent, 0);
981 fl_set_button(class_->radio_doc_skip, 0);
982 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
983 fl_set_button(class_->radio_doc_indent, 1);
985 fl_set_button(class_->radio_doc_skip, 1);
987 bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
988 setEnabled(class_->choice_default_skip_units, input_length);
989 setEnabled(class_->input_doc_skip, input_length);
991 switch (params.getDefSkip().kind()) {
992 case VSpace::SMALLSKIP:
993 fl_set_choice (class_->choice_doc_skip, 1);
995 case VSpace::MEDSKIP:
996 fl_set_choice (class_->choice_doc_skip, 2);
998 case VSpace::BIGSKIP:
999 fl_set_choice (class_->choice_doc_skip, 3);
1001 case VSpace::LENGTH:
1003 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1004 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1005 || paperchoice == 2 || paperchoice > 5;
1006 string const default_unit = metric ? "cm" : "in";
1007 string const length = params.getDefSkip().asLyXCommand();
1008 updateWidgetsFromLengthString(class_->input_doc_skip,
1009 class_->choice_default_skip_units,
1010 length, default_unit);
1014 fl_set_choice (class_->choice_doc_skip, 2);
1017 fl_set_button(class_->radio_doc_sides_one, 0);
1018 fl_set_button(class_->radio_doc_sides_two, 0);
1019 setEnabled(class_->choice_doc_skip,
1020 fl_get_button(class_->radio_doc_skip));
1022 if (params.sides == LyXTextClass::TwoSides)
1023 fl_set_button(class_->radio_doc_sides_two, 1);
1025 fl_set_button(class_->radio_doc_sides_one, 1);
1026 fl_set_button(class_->radio_doc_columns_one, 0);
1027 fl_set_button(class_->radio_doc_columns_two, 0);
1028 if (params.columns == 2)
1029 fl_set_button(class_->radio_doc_columns_two, 1);
1031 fl_set_button(class_->radio_doc_columns_one, 1);
1033 fl_set_input(class_->input_doc_spacing, "");
1034 setEnabled(class_->input_doc_spacing, false);
1036 switch (params.spacing.getSpace()) {
1037 case Spacing::Default: // nothing bad should happen with this
1038 case Spacing::Single:
1040 fl_set_choice(class_->choice_doc_spacing, 1);
1042 case Spacing::Onehalf:
1044 fl_set_choice(class_->choice_doc_spacing, 2);
1046 case Spacing::Double:
1048 fl_set_choice(class_->choice_doc_spacing, 3);
1050 case Spacing::Other:
1052 fl_set_choice(class_->choice_doc_spacing, 4);
1054 sprintf(sval,"%g",params.spacing.getValue());
1055 fl_set_input(class_->input_doc_spacing, sval);
1056 setEnabled(class_->input_doc_spacing, true);
1060 if (!params.options.empty())
1061 fl_set_input(class_->input_doc_extra, params.options.c_str());
1063 fl_set_input(class_->input_doc_extra, "");
1067 void FormDocument::language_update(BufferParams const & params)
1069 if (!language_.get())
1072 int const pos = int(findPos(lang_, params.language->lang()));
1073 combo_language->select(pos+1);
1075 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1076 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1077 fl_set_button(language_->radio_single, 0);
1078 fl_set_button(language_->radio_double, 0);
1079 if (params.quotes_times == InsetQuotes::SingleQ)
1080 fl_set_button(language_->radio_single, 1);
1082 fl_set_button(language_->radio_double, 1);
1086 void FormDocument::options_update(BufferParams const & params)
1088 if (!options_.get())
1091 fl_set_choice_text(options_->choice_postscript_driver,
1092 params.graphicsDriver.c_str());
1093 fl_set_button(options_->check_use_amsmath, params.use_amsmath);
1094 fl_set_button(options_->check_use_natbib, params.use_natbib);
1095 fl_set_choice(options_->choice_citation_format,
1096 int(params.use_numerical_citations)+1);
1097 setEnabled(options_->choice_citation_format, params.use_natbib);
1098 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1099 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1100 if (!params.float_placement.empty())
1101 fl_set_input(options_->input_float_placement,
1102 params.float_placement.c_str());
1104 fl_set_input(options_->input_float_placement, "");
1108 void FormDocument::paper_update(BufferParams const & params)
1113 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1114 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1115 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1117 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1118 bool const useCustom = paperchoice == 2;
1119 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1121 fl_set_button(paper_->radio_portrait, 0);
1122 setEnabled(paper_->radio_portrait, !useCustom);
1123 fl_set_button(paper_->radio_landscape, 0);
1124 setEnabled(paper_->radio_landscape, !useCustom);
1126 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
1127 fl_set_button(paper_->radio_landscape, 1);
1129 fl_set_button(paper_->radio_portrait, 1);
1130 setEnabled(paper_->choice_paperpackage,
1131 //either default papersize (preferences)
1132 //or document papersize has to be A4
1134 || paperchoice == 1 && lyxrc.default_papersize == 5)
1135 && fl_get_button(paper_->radio_portrait));
1137 // Default unit choice is cm if metric, inches if US paper.
1138 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1139 || paperchoice == 2 || paperchoice > 5;
1140 string const default_unit = metric ? "cm" : "in";
1141 updateWidgetsFromLengthString(paper_->input_custom_width,
1142 paper_->choice_custom_width_units,
1143 params.paperwidth, default_unit);
1144 setEnabled(paper_->input_custom_width, useCustom);
1145 setEnabled(paper_->choice_custom_width_units, useCustom);
1147 updateWidgetsFromLengthString(paper_->input_custom_height,
1148 paper_->choice_custom_height_units,
1149 params.paperheight, default_unit);
1150 setEnabled(paper_->input_custom_height, useCustom);
1151 setEnabled(paper_->choice_custom_height_units, useCustom);
1153 updateWidgetsFromLengthString(paper_->input_inner_margin,
1154 paper_->choice_inner_margin_units,
1155 params.leftmargin, default_unit);
1156 setEnabled(paper_->input_inner_margin, useGeom);
1157 setEnabled(paper_->choice_inner_margin_units, useGeom);
1159 updateWidgetsFromLengthString(paper_->input_top_margin,
1160 paper_->choice_top_margin_units,
1161 params.topmargin, default_unit);
1162 setEnabled(paper_->input_top_margin, useGeom);
1163 setEnabled(paper_->choice_top_margin_units, useGeom);
1165 updateWidgetsFromLengthString(paper_->input_outer_margin,
1166 paper_->choice_outer_margin_units,
1167 params.rightmargin, default_unit);
1168 setEnabled(paper_->input_outer_margin, useGeom);
1169 setEnabled(paper_->choice_outer_margin_units, useGeom);
1171 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1172 paper_->choice_bottom_margin_units,
1173 params.bottommargin, default_unit);
1174 setEnabled(paper_->input_bottom_margin, useGeom);
1175 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1177 updateWidgetsFromLengthString(paper_->input_head_height,
1178 paper_->choice_head_height_units,
1179 params.headheight, default_unit);
1180 setEnabled(paper_->input_head_height, useGeom);
1181 setEnabled(paper_->choice_head_height_units, useGeom);
1183 updateWidgetsFromLengthString(paper_->input_head_sep,
1184 paper_->choice_head_sep_units,
1185 params.headsep, default_unit);
1186 setEnabled(paper_->input_head_sep, useGeom);
1187 setEnabled(paper_->choice_head_sep_units, useGeom);
1189 updateWidgetsFromLengthString(paper_->input_foot_skip,
1190 paper_->choice_foot_skip_units,
1191 params.footskip, default_unit);
1192 setEnabled(paper_->input_foot_skip, useGeom);
1193 setEnabled(paper_->choice_foot_skip_units, useGeom);
1195 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1199 void FormDocument::bullets_update(BufferParams const & params)
1201 if (!bullets_.get() ||
1203 (XpmVersion==4 && XpmRevision<7)))
1206 bool const isLinuxDoc = lv_.buffer()->isLinuxDoc();
1207 setEnabled(fbullet, !isLinuxDoc);
1209 if (isLinuxDoc) return;
1211 fl_set_button(bullets_->radio_bullet_depth_1, 1);
1212 fl_set_input(bullets_->input_bullet_latex,
1213 params.user_defined_bullets[0].getText().c_str());
1214 fl_set_choice(bullets_->choice_bullet_size,
1215 params.user_defined_bullets[0].getSize() + 2);
1219 void FormDocument::checkReadOnly()
1221 if (bc().readOnly(lv_.buffer()->isReadonly())) {
1222 combo_doc_class->deactivate();
1223 combo_language->deactivate();
1224 postWarning(_("Document is read-only."
1225 " No changes to layout permitted."));
1227 combo_doc_class->activate();
1228 combo_language->activate();
1234 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
1240 // this has to be all out of if/elseif because it has to deactivate
1241 // the document buttons and so the whole stuff has to be tested again.
1242 // disable OK/Apply if input is not valid
1243 str = fl_get_input(class_->input_doc_skip);
1244 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1245 str = fl_get_input(paper_->input_custom_width);
1246 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1247 str = fl_get_input(paper_->input_custom_height);
1248 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1249 str = fl_get_input(paper_->input_outer_margin);
1250 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1251 str = fl_get_input(paper_->input_inner_margin);
1252 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1253 str = fl_get_input(paper_->input_top_margin);
1254 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1255 str = fl_get_input(paper_->input_bottom_margin);
1256 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1257 str = fl_get_input(paper_->input_head_height);
1258 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1259 str = fl_get_input(paper_->input_head_sep);
1260 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1261 str = fl_get_input(paper_->input_foot_skip);
1262 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1264 //display warning if input is not valid
1265 if (ob == class_->input_doc_skip
1266 || ob == paper_->input_custom_width
1267 || ob == paper_->input_custom_height
1268 || ob == paper_->input_outer_margin
1269 || ob == paper_->input_inner_margin
1270 || ob == paper_->input_top_margin
1271 || ob == paper_->input_bottom_margin
1272 || ob == paper_->input_head_height
1273 || ob == paper_->input_head_sep
1274 || ob == paper_->input_foot_skip) {
1276 postWarning(_("Invalid Length (valid example: 10mm)"));
1284 // "Synchronize" the choice and the input field, so that it
1285 // is impossible to commit senseless data.
1286 input = fl_get_input (class_->input_doc_skip);
1287 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1289 else if (fl_get_choice(class_->choice_doc_skip) != 4)
1290 fl_set_input (class_->input_doc_skip, "");
1292 input = fl_get_input(class_->input_doc_spacing);
1293 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1295 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
1296 fl_set_input (class_->input_doc_spacing, "");
1301 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1303 BufferParams & param = lv_.buffer()->params;
1305 // convert from 1-6 range to -1-4
1306 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1307 fl_set_input(bullets_->input_bullet_latex,
1308 param.temp_bullets[current_bullet_depth].getText().c_str());
1312 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1314 BufferParams & param = lv_.buffer()->params;
1316 param.temp_bullets[current_bullet_depth].
1317 setText(fl_get_input(bullets_->input_bullet_latex));
1321 void FormDocument::BulletDepth(FL_OBJECT * ob)
1323 /* Should I do the following: */
1324 /* 1. change to the panel that the current bullet belongs in */
1325 /* 2. show that bullet as selected */
1326 /* 3. change the size setting to the size of the bullet in Q.*/
1327 /* 4. display the latex equivalent in the latex box */
1329 /* I'm inclined to just go with 3 and 4 at the moment and */
1330 /* maybe try to support the others later */
1331 BufferParams & param = lv_.buffer()->params;
1334 if (ob == bullets_->radio_bullet_depth_1)
1336 else if (ob == bullets_->radio_bullet_depth_2)
1338 else if (ob == bullets_->radio_bullet_depth_3)
1340 else if (ob == bullets_->radio_bullet_depth_4)
1343 switch (fl_get_button_numb(ob)) {
1345 // right mouse button resets to default
1346 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1348 current_bullet_depth = data;
1349 fl_set_input(bullets_->input_bullet_latex,
1350 param.temp_bullets[data].getText().c_str());
1351 fl_set_choice(bullets_->choice_bullet_size,
1352 param.temp_bullets[data].getSize() + 2);
1357 void FormDocument::BulletPanel(FL_OBJECT * ob)
1359 /* Here we have to change the background pixmap to that selected */
1360 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1363 if (ob == bullets_->radio_bullet_panel_standard)
1365 else if (ob == bullets_->radio_bullet_panel_maths)
1367 else if (ob == bullets_->radio_bullet_panel_ding2)
1369 else if (ob == bullets_->radio_bullet_panel_ding3)
1371 else if (ob == bullets_->radio_bullet_panel_ding4)
1373 else if (ob == bullets_->radio_bullet_panel_ding1)
1376 if (data != current_bullet_panel) {
1377 fl_freeze_form(bullets_->form);
1378 current_bullet_panel = data;
1380 /* free the current pixmap */
1381 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1383 if (ob == bullets_->radio_bullet_panel_standard) {
1384 new_panel = "standard";
1385 } else if (ob == bullets_->radio_bullet_panel_maths ) {
1386 new_panel = "amssymb";
1387 } else if (ob == bullets_->radio_bullet_panel_ding2) {
1388 new_panel = "psnfss1";
1389 } else if (ob == bullets_->radio_bullet_panel_ding3) {
1390 new_panel = "psnfss2";
1391 } else if (ob == bullets_->radio_bullet_panel_ding4) {
1392 new_panel = "psnfss3";
1393 } else if (ob == bullets_->radio_bullet_panel_ding1) {
1394 new_panel = "psnfss4";
1396 /* something very wrong happened */
1397 // play it safe for now but should be an exception
1398 current_bullet_panel = 0; // standard panel
1399 new_panel = "standard";
1401 new_panel += ".xpm";
1402 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1403 LibFileSearch("images", new_panel).c_str());
1404 fl_redraw_object(bullets_->bmtable_bullet_panel);
1405 fl_unfreeze_form(bullets_->form);
1410 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1412 /* handle the user input by setting the current bullet depth's pixmap */
1413 /* to that extracted from the current chosen position of the BMTable */
1414 /* Don't forget to free the button's old pixmap first. */
1416 BufferParams & param = lv_.buffer()->params;
1417 int bmtable_button = fl_get_bmtable(ob);
1419 /* try to keep the button held down till another is pushed */
1420 /* fl_set_bmtable(ob, 1, bmtable_button); */
1421 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1422 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1423 fl_set_input(bullets_->input_bullet_latex,
1424 param.temp_bullets[current_bullet_depth].getText().c_str());
1428 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1431 ob = class_->choice_doc_class;
1433 lv_.prohibitInput();
1435 unsigned int tc = combo_doc_class->get() - 1;
1436 if (textclasslist[tc].load()) {
1437 // we use a copy of the bufferparams because we do not
1438 // want to modify them yet.
1439 BufferParams params = lv_.buffer()->params;
1441 if (lyxrc.auto_reset_options) {
1442 params.textclass = tc;
1443 params.useClassDefaults();
1444 UpdateLayoutDocument(params);
1446 // update the params which are needed in any case
1447 // (fontsizes, pagestyle)
1448 params.textclass = tc;
1449 UpdateClassParams(params);
1453 // unable to load new style
1454 Alert::alert(_("Conversion Errors!"),
1455 _("Unable to switch to new document class."),
1456 _("Reverting to original document class."));
1457 combo_doc_class->select(int(lv_.buffer()->params.textclass) + 1);
1463 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1469 class_update(params);
1470 paper_update(params);
1471 language_update(params);
1472 options_update(params);
1473 bullets_update(params);