3 * Copyright 2000-2001 The LyX Team.
4 * See the file COPYING.
6 * \author Jürgen Vigna, jug@sad.it
11 #include FORMS_H_LOCATION
12 #include XPM_H_LOCATION
15 #pragma implementation
18 #include "FormDocument.h"
19 #include "forms/form_document.h"
22 #include "lyxtextclasslist.h"
24 #include "tex-strings.h"
25 #include "bufferparams.h"
29 #include "frnt_lang.h"
30 #include "frontends/LyXView.h"
33 #include "BufferView.h"
36 #include "CutAndPaste.h"
37 #include "bufferview_funcs.h"
38 #include "xforms_helpers.h"
40 #include "input_validators.h" // fl_unsigned_float_filter
41 #include "helper_funcs.h"
42 #include "lyx_main.h" // for user_lyxdir
44 #include "insets/insetquotes.h"
46 #include "support/filetools.h"
47 #include "support/lstrings.h"
49 #include FORMS_H_LOCATION
51 #include <boost/bind.hpp>
57 using Liason::setMinibuffer;
60 FormDocument::FormDocument(LyXView * lv, Dialogs * d)
61 : FormBaseBD(lv, d, _("Document Layout")),
62 ActCell(0), Confirmed(0),
63 current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
65 // let the dialog be shown
66 // This is a permanent connection so we won't bother
67 // storing a copy because we won't be disconnecting.
68 d->showDocument = boost::bind(&FormDocument::show, this);
72 void FormDocument::redraw()
74 if (form() && form()->visible)
75 fl_redraw_form(form());
79 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
80 if (outer_form && outer_form->visible)
81 fl_redraw_form(outer_form);
85 FL_FORM * FormDocument::form() const
87 if (dialog_.get()) return dialog_->form;
92 void FormDocument::build()
97 dialog_.reset(build_document(this));
99 // Allow the base class to control messages
100 setMessageWidget(dialog_->text_warning);
102 // Manage the restore, ok, apply, restore and cancel/close buttons
103 bc().setOK(dialog_->button_ok);
104 bc().setApply(dialog_->button_apply);
105 bc().setCancel(dialog_->button_close);
106 bc().setRestore(dialog_->button_restore);
107 bc().addReadOnly (dialog_->button_save_defaults);
108 bc().addReadOnly (dialog_->button_reset_defaults);
110 // the document paper form
111 paper_.reset(build_document_paper(this));
112 fl_addto_choice(paper_->choice_papersize,
113 _(" Default | Custom | US letter | US legal "
114 "| US executive | A3 | A4 | A5 | B3 | B4 | B5 "));
115 fl_addto_choice(paper_->choice_paperpackage,
118 "| Very small Margins "
119 "| Very wide Margins "));
121 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
122 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
123 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
124 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
125 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
126 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
127 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
128 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
129 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
131 setPrehandler(paper_->input_custom_width);
132 setPrehandler(paper_->input_custom_height);
133 setPrehandler(paper_->input_top_margin);
134 setPrehandler(paper_->input_bottom_margin);
135 setPrehandler(paper_->input_inner_margin);
136 setPrehandler(paper_->input_outer_margin);
137 setPrehandler(paper_->input_head_height);
138 setPrehandler(paper_->input_head_sep);
139 setPrehandler(paper_->input_foot_skip);
141 // Create the contents of the unit choices
142 // Don't include the "%" terms...
143 vector<string> units_vec = getLatexUnits();
145 for (vector<string>::iterator it = units_vec.begin();
146 it != units_vec.end(); ++it) {
147 if (contains(*it, "%"))
148 it = units_vec.erase(it, it+1) - 1;
151 vector<string>::iterator ret =
152 std::remove_if(units_vec.begin(),
154 bind2nd(contains_functor(), "%"));
155 units_vec.erase(ret, units_vec.end());
157 string units = getStringFromVector(units_vec, "|");
159 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
160 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
161 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
162 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
163 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
164 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
165 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
166 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
167 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
169 bc().addReadOnly (paper_->choice_paperpackage);
170 bc().addReadOnly (paper_->radio_portrait);
171 bc().addReadOnly (paper_->radio_landscape);
172 bc().addReadOnly (paper_->choice_papersize);
173 bc().addReadOnly (paper_->check_use_geometry);
174 bc().addReadOnly (paper_->input_custom_width);
175 bc().addReadOnly (paper_->input_custom_height);
176 bc().addReadOnly (paper_->input_top_margin);
177 bc().addReadOnly (paper_->input_bottom_margin);
178 bc().addReadOnly (paper_->input_inner_margin);
179 bc().addReadOnly (paper_->input_outer_margin);
180 bc().addReadOnly (paper_->input_head_height);
181 bc().addReadOnly (paper_->input_head_sep);
182 bc().addReadOnly (paper_->input_foot_skip);
184 // the document class form
185 class_.reset(build_document_class(this));
188 // The language is a combo-box and has to be inserted manually
189 obj = class_->choice_doc_class;
190 fl_deactivate_object(obj);
191 fl_addto_form(class_->form);
192 combo_doc_class.reset(new Combox(FL_COMBOX_DROPLIST));
193 combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400,
195 combo_doc_class->shortcut("#C",1);
196 combo_doc_class->setcallback(ComboInputCB, this);
198 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
199 cit != textclasslist.end(); ++cit) {
200 combo_doc_class->addto(cit->description());
203 fl_addto_choice(class_->choice_doc_spacing,
204 _(" Single | OneHalf | Double | Custom "));
205 fl_addto_choice(class_->choice_doc_fontsize, "default|10|11|12");
206 for (n=0; tex_fonts[n][0]; ++n) {
207 fl_addto_choice(class_->choice_doc_fonts,tex_fonts[n]);
209 fl_addto_choice(class_->choice_doc_pagestyle,
210 "default|empty|plain|headings|fancy");
211 fl_addto_choice(class_->choice_doc_skip,
212 _(" Smallskip | Medskip | Bigskip | Length "));
213 fl_addto_choice(class_->choice_default_skip_units, units.c_str());
214 fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
215 fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
216 fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
218 setPrehandler(class_->input_doc_extra);
219 setPrehandler(class_->input_doc_skip);
220 setPrehandler(class_->input_doc_spacing);
222 // Set input filters on doc spacing to make it accept only
224 fl_set_input_filter(class_->input_doc_spacing, fl_unsigned_float_filter);
226 bc().addReadOnly (class_->radio_doc_indent);
227 bc().addReadOnly (class_->radio_doc_skip);
229 bc().addReadOnly (class_->choice_doc_pagestyle);
230 bc().addReadOnly (class_->choice_doc_fonts);
231 bc().addReadOnly (class_->choice_doc_fontsize);
232 bc().addReadOnly (class_->radio_doc_sides_one);
233 bc().addReadOnly (class_->radio_doc_sides_two);
234 bc().addReadOnly (class_->radio_doc_columns_one);
235 bc().addReadOnly (class_->radio_doc_columns_two);
236 bc().addReadOnly (class_->input_doc_extra);
237 bc().addReadOnly (class_->input_doc_skip);
238 bc().addReadOnly (class_->choice_doc_skip);
239 bc().addReadOnly (class_->choice_doc_spacing);
240 bc().addReadOnly (class_->input_doc_spacing);
242 // the document language form
243 language_.reset(build_document_language(this));
244 fl_addto_choice(language_->choice_inputenc,
245 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
246 "|koi8-r|koi8-u|cp866|cp1251|iso88595");
248 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
249 // Store the identifiers for later
250 lang_ = getSecond(langs);
252 // The language is a combo-box and has to be inserted manually
253 obj = language_->choice_language;
254 fl_deactivate_object(obj);
255 fl_addto_form(language_->form);
256 combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
257 combo_language->add(obj->x, obj->y, obj->w, obj->h, 400,
259 combo_language->shortcut("#L",1);
260 combo_language->setcallback(ComboInputCB, this);
263 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
264 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
265 for (; lit != lend; ++lit) {
266 combo_language->addto(lit->first);
268 combo_language->select(1);
270 fl_addto_choice(language_->choice_quotes_language,
271 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
272 " «text» | »text« "));
274 bc().addReadOnly (language_->choice_inputenc);
275 bc().addReadOnly (language_->choice_quotes_language);
276 bc().addReadOnly (language_->radio_single);
277 bc().addReadOnly (language_->radio_double);
279 // the document options form
280 options_.reset(build_document_options(this));
281 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
282 setPrehandler(options_->input_float_placement);
284 fl_set_counter_bounds(options_->counter_secnumdepth,-2,5);
285 fl_set_counter_bounds(options_->counter_tocdepth,-1,5);
286 fl_set_counter_step(options_->counter_secnumdepth,1,1);
287 fl_set_counter_step(options_->counter_tocdepth,1,1);
288 fl_set_counter_precision(options_->counter_secnumdepth, 0);
289 fl_set_counter_precision(options_->counter_tocdepth, 0);
290 for (n=0; tex_graphics[n][0]; ++n) {
291 fl_addto_choice(options_->choice_postscript_driver,
294 fl_addto_choice(options_->choice_citation_format,
295 _(" Author-year | Numerical "));
297 bc_.addReadOnly (options_->counter_secnumdepth);
298 bc_.addReadOnly (options_->counter_tocdepth);
299 bc_.addReadOnly (options_->check_use_amsmath);
300 bc_.addReadOnly (options_->check_use_natbib);
301 bc_.addReadOnly (options_->choice_citation_format);
302 bc_.addReadOnly (options_->input_float_placement);
303 bc_.addReadOnly (options_->choice_postscript_driver);
305 // the document bullets form
306 bullets_.reset(build_document_bullet(this));
307 fl_addto_choice(bullets_->choice_bullet_size,
308 _(" default | tiny | script | footnote | small |"
309 " normal | large | Large | LARGE | huge | Huge"));
310 fl_set_choice(bullets_->choice_bullet_size, 1);
311 fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
312 setPrehandler(bullets_->input_bullet_latex);
313 fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
315 bc_.addReadOnly(bullets_->radio_bullet_depth_1);
316 bc_.addReadOnly(bullets_->radio_bullet_depth_2);
317 bc_.addReadOnly(bullets_->radio_bullet_depth_3);
318 bc_.addReadOnly(bullets_->radio_bullet_depth_4);
319 bc_.addReadOnly(bullets_->radio_bullet_panel_standard);
320 bc_.addReadOnly(bullets_->radio_bullet_panel_maths);
321 bc_.addReadOnly(bullets_->radio_bullet_panel_ding1);
322 bc_.addReadOnly(bullets_->radio_bullet_panel_ding2);
323 bc_.addReadOnly(bullets_->radio_bullet_panel_ding3);
324 bc_.addReadOnly(bullets_->radio_bullet_panel_ding4);
326 bc().addReadOnly (bullets_->bmtable_bullet_panel);
327 bc().addReadOnly (bullets_->choice_bullet_size);
328 bc().addReadOnly (bullets_->input_bullet_latex);
330 fl_addto_tabfolder(dialog_->tabfolder,_("Document"),
332 fl_addto_tabfolder(dialog_->tabfolder,_("Paper"),
334 fl_addto_tabfolder(dialog_->tabfolder,_("Language"),
336 fl_addto_tabfolder(dialog_->tabfolder,_("Extra"),
338 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets"),
340 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
341 lyxerr << _("Your version of libXpm is older than 4.7.\n"
342 "The `bullet' tab of the document dialog "
343 "has been disabled") << '\n';
344 fl_deactivate_object(fbullet);
345 fl_set_object_lcol(fbullet, FL_INACTIVE);
350 void FormDocument::apply()
352 if (!lv_->view()->available() || !dialog_.get())
355 bool redo = class_apply();
357 redo = language_apply() || redo;
358 redo = options_apply() || redo;
362 lv_->view()->redoCurrentBuffer();
364 lv_->buffer()->markDirty();
365 setMinibuffer(lv_, _("Document layout set"));
369 void FormDocument::cancel()
371 // this avoids confusion when reopening
372 BufferParams & param = lv_->buffer()->params;
373 param.temp_bullets[0] = param.user_defined_bullets[0];
374 param.temp_bullets[1] = param.user_defined_bullets[1];
375 param.temp_bullets[2] = param.user_defined_bullets[2];
376 param.temp_bullets[3] = param.user_defined_bullets[3];
381 void FormDocument::update()
388 BufferParams const & params = lv_->buffer()->params;
390 class_update(params);
391 paper_update(params);
392 language_update(params);
393 options_update(params);
394 bullets_update(params);
399 // should this go elsewhere? Maybe a ControllerDocument? (JMarc)
400 /** Save the buffer's parameters as user default.
401 This function saves a file \c user_lyxdir/templates/defaults.lyx
402 which parameters are those of the current buffer. This file
403 is used as a default template when creating a new
404 file. Returns \c true on success.
406 bool saveParamsAsDefault(BufferParams const ¶ms)
408 if (!Alert::askQuestion(_("Do you want to save the current settings"),
409 _("for the document layout as default?"),
410 _("(they will be valid for any new document)")))
413 string const fname = AddName(AddPath(user_lyxdir, "templates/"),
415 Buffer defaults = Buffer(fname);
416 defaults.params = params;
418 // add an empty paragraph. Is this enough?
419 defaults.paragraph = new Paragraph;
421 return defaults.writeFile(defaults.fileName(), false);
427 bool FormDocument::input(FL_OBJECT * ob, long)
429 if (ob == class_->choice_doc_class) {
430 CheckChoiceClass(ob, 0);
431 } else if (ob == bullets_->choice_bullet_size) {
432 ChoiceBulletSize(ob, 0);
433 } else if (ob == bullets_->input_bullet_latex) {
434 InputBulletLaTeX(ob, 0);
435 } else if (ob == bullets_->radio_bullet_depth_1 ||
436 ob == bullets_->radio_bullet_depth_2 ||
437 ob == bullets_->radio_bullet_depth_3 ||
438 ob == bullets_->radio_bullet_depth_4) {
440 } else if (ob == bullets_->radio_bullet_panel_standard ||
441 ob == bullets_->radio_bullet_panel_maths ||
442 ob == bullets_->radio_bullet_panel_ding1 ||
443 ob == bullets_->radio_bullet_panel_ding2 ||
444 ob == bullets_->radio_bullet_panel_ding3 ||
445 ob == bullets_->radio_bullet_panel_ding4) {
447 } else if (ob == bullets_->bmtable_bullet_panel) {
448 BulletBMTable(ob, 0);
451 bool const length_input = fl_get_choice(class_->choice_doc_skip) == 4;
452 if (ob == class_->choice_doc_skip) {
453 setEnabled(class_->input_doc_skip, length_input);
454 setEnabled(class_->choice_default_skip_units, length_input);
457 if (ob == class_->choice_doc_spacing)
458 setEnabled(class_->input_doc_spacing,
459 fl_get_choice(class_->choice_doc_spacing) == 4);
461 bool const skip_used = fl_get_button(class_->radio_doc_skip);
462 if (ob == class_->radio_doc_skip ||
463 ob == class_->radio_doc_indent) {
464 setEnabled(class_->choice_doc_skip, skip_used);
465 setEnabled(class_->input_doc_skip,
466 skip_used && length_input);
467 setEnabled(class_->choice_default_skip_units,
468 skip_used && length_input);
469 // Default unit choice is cm if metric, inches if US paper.
470 // If papersize is default, check the lyxrc-settings
471 int const paperchoice = fl_get_choice(paper_->choice_papersize);
472 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
473 || paperchoice == 2 || paperchoice > 5;
474 int const default_unit = metric ? 8 : 9;
475 if (strip(fl_get_input(class_->input_doc_skip)).empty())
476 fl_set_choice(class_->choice_default_skip_units,
480 if (ob == options_->check_use_natbib) {
481 setEnabled(options_->choice_citation_format,
482 fl_get_button(options_->check_use_natbib));
485 if (ob == dialog_->button_save_defaults) {
489 language_apply(params);
490 options_apply(params);
491 bullets_apply(params);
492 params.preamble = lv_->buffer()->params.preamble;
493 saveParamsAsDefault(params);
496 if (ob == dialog_->button_reset_defaults) {
497 BufferParams params = lv_->buffer()->params;
498 params.textclass = combo_doc_class->get() - 1;
499 params.useClassDefaults();
500 UpdateLayoutDocument(params);
503 if (ob == paper_->radio_landscape)
504 fl_set_choice(paper_->choice_paperpackage,
505 BufferParams::PACKAGE_NONE + 1);
507 if (ob == paper_->choice_papersize) {
508 int const paperchoice = fl_get_choice(paper_->choice_papersize);
509 bool const defsize = paperchoice == 1;
510 bool const custom = paperchoice == 2;
511 bool const a3size = paperchoice == 6;
512 bool const b3size = paperchoice == 9;
513 bool const b4size = paperchoice == 10;
516 fl_set_button(paper_->radio_portrait, 1);
518 bool const use_geom = (custom || a3size || b3size || b4size);
520 fl_set_button(paper_->check_use_geometry, int(use_geom));
522 setEnabled(paper_->input_top_margin, use_geom);
523 setEnabled(paper_->input_bottom_margin, use_geom);
524 setEnabled(paper_->input_inner_margin, use_geom);
525 setEnabled(paper_->input_outer_margin, use_geom);
526 setEnabled(paper_->input_head_height, use_geom);
527 setEnabled(paper_->input_head_sep, use_geom);
528 setEnabled(paper_->input_foot_skip, use_geom);
529 setEnabled(paper_->choice_top_margin_units, use_geom);
530 setEnabled(paper_->choice_bottom_margin_units, use_geom);
531 setEnabled(paper_->choice_inner_margin_units, use_geom);
532 setEnabled(paper_->choice_outer_margin_units, use_geom);
533 setEnabled(paper_->choice_head_height_units, use_geom);
534 setEnabled(paper_->choice_head_sep_units, use_geom);
535 setEnabled(paper_->choice_foot_skip_units, use_geom);
536 setEnabled(paper_->choice_custom_width_units, use_geom);
537 setEnabled(paper_->choice_custom_height_units, use_geom);
539 setEnabled(paper_->input_custom_width, custom);
540 setEnabled(paper_->input_custom_height, custom);
541 setEnabled(paper_->choice_custom_width_units, custom);
542 setEnabled(paper_->choice_custom_height_units, custom);
543 setEnabled(paper_->radio_portrait, !custom);
544 setEnabled(paper_->radio_landscape, !custom);
546 // Default unit choice is cm if metric, inches if US paper.
547 // If papersize is default, use the lyxrc-settings
548 bool const metric = (defsize && lyxrc.default_papersize > 3)
549 || paperchoice == 2 || paperchoice > 5;
550 int const default_unit = metric ? 8 : 9;
551 if (strip(fl_get_input(paper_->input_custom_width)).empty())
552 fl_set_choice(paper_->choice_custom_width_units,
554 if (strip(fl_get_input(paper_->input_custom_height)).empty())
555 fl_set_choice(paper_->choice_custom_height_units,
557 if (strip(fl_get_input(paper_->input_top_margin)).empty())
558 fl_set_choice(paper_->choice_top_margin_units,
560 if (strip(fl_get_input(paper_->input_bottom_margin)).empty())
561 fl_set_choice(paper_->choice_bottom_margin_units,
563 if (strip(fl_get_input(paper_->input_inner_margin)).empty())
564 fl_set_choice(paper_->choice_inner_margin_units,
566 if (strip(fl_get_input(paper_->input_outer_margin)).empty())
567 fl_set_choice(paper_->choice_outer_margin_units,
569 if (strip(fl_get_input(paper_->input_head_height)).empty())
570 fl_set_choice(paper_->choice_head_height_units,
572 if (strip(fl_get_input(paper_->input_head_sep)).empty())
573 fl_set_choice(paper_->choice_head_sep_units,
575 if (strip(fl_get_input(paper_->input_foot_skip)).empty())
576 fl_set_choice(paper_->choice_foot_skip_units,
580 if (ob == paper_->choice_papersize ||
581 ob == paper_->radio_portrait ||
582 ob == paper_->radio_landscape) {
584 setEnabled(paper_->choice_paperpackage,
585 //either default papersize (preferences)
586 //or document papersize has to be A4
587 (fl_get_choice(paper_->choice_papersize) == 7
588 || fl_get_choice(paper_->choice_papersize) == 1
589 && lyxrc.default_papersize == 5)
590 && fl_get_button(paper_->radio_portrait));
593 if (ob == paper_->choice_paperpackage) {
594 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
595 fl_set_button(paper_->check_use_geometry, 0);
597 setEnabled(paper_->input_top_margin, false);
598 setEnabled(paper_->input_bottom_margin, false);
599 setEnabled(paper_->input_inner_margin, false);
600 setEnabled(paper_->input_outer_margin, false);
601 setEnabled(paper_->input_head_height, false);
602 setEnabled(paper_->input_head_sep, false);
603 setEnabled(paper_->input_foot_skip, false);
604 setEnabled(paper_->choice_top_margin_units, false);
605 setEnabled(paper_->choice_bottom_margin_units, false);
606 setEnabled(paper_->choice_inner_margin_units, false);
607 setEnabled(paper_->choice_outer_margin_units, false);
608 setEnabled(paper_->choice_head_height_units, false);
609 setEnabled(paper_->choice_head_sep_units, false);
610 setEnabled(paper_->choice_foot_skip_units, false);
614 if (ob == paper_->check_use_geometry) {
615 //don't allow switching geometry off in custom papersize mode
616 //nor in A3, B3, and B4
617 int const choice = fl_get_choice(paper_->choice_papersize);
618 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
619 fl_set_button(paper_->check_use_geometry, 1);
621 fl_set_choice(paper_->choice_paperpackage,
622 BufferParams::PACKAGE_NONE + 1);
624 bool const use_geom = fl_get_button(paper_->check_use_geometry);
625 setEnabled(paper_->input_top_margin, use_geom);
626 setEnabled(paper_->input_bottom_margin, use_geom);
627 setEnabled(paper_->input_inner_margin, use_geom);
628 setEnabled(paper_->input_outer_margin, use_geom);
629 setEnabled(paper_->input_head_height, use_geom);
630 setEnabled(paper_->input_head_sep, use_geom);
631 setEnabled(paper_->input_foot_skip, use_geom);
632 setEnabled(paper_->choice_top_margin_units, use_geom);
633 setEnabled(paper_->choice_bottom_margin_units, use_geom);
634 setEnabled(paper_->choice_inner_margin_units, use_geom);
635 setEnabled(paper_->choice_outer_margin_units, use_geom);
636 setEnabled(paper_->choice_head_height_units, use_geom);
637 setEnabled(paper_->choice_head_sep_units, use_geom);
638 setEnabled(paper_->choice_foot_skip_units, use_geom);
641 return CheckDocumentInput(ob, 0);
645 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
647 FormDocument * pre = static_cast<FormDocument*>(v);
648 if (combox == pre->combo_doc_class.get())
649 pre->CheckChoiceClass(0, 0);
650 pre->bc().valid(pre->CheckDocumentInput(0,0));
654 bool FormDocument::class_apply(BufferParams ¶ms)
658 // If default skip is a "Length" but there's no text in the
659 // input field, reset the kind to "Medskip", which is the default.
660 if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
661 !*(fl_get_input (class_->input_doc_skip))) {
662 fl_set_choice (class_->choice_doc_skip, 2);
664 params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
665 params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
666 params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
668 params.textclass = combo_doc_class->get() - 1;
670 BufferParams::PARSEP tmpsep = params.paragraph_separation;
671 if (fl_get_button(class_->radio_doc_indent))
672 params.paragraph_separation = BufferParams::PARSEP_INDENT;
674 params.paragraph_separation = BufferParams::PARSEP_SKIP;
675 if (tmpsep != params.paragraph_separation)
678 VSpace tmpdefskip = params.getDefSkip();
679 switch (fl_get_choice (class_->choice_doc_skip)) {
681 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
684 params.setDefSkip(VSpace(VSpace::MEDSKIP));
687 params.setDefSkip(VSpace(VSpace::BIGSKIP));
691 string const length =
692 getLengthFromWidgets(class_->input_doc_skip,
693 class_->choice_default_skip_units);
695 params.setDefSkip(VSpace(LyXGlueLength(length)));
699 // DocumentDefskipCB assures that this never happens
700 params.setDefSkip(VSpace(VSpace::MEDSKIP));
703 if (!(tmpdefskip == params.getDefSkip()))
706 if (fl_get_button(class_->radio_doc_columns_two))
710 if (fl_get_button(class_->radio_doc_sides_two))
711 params.sides = LyXTextClass::TwoSides;
713 params.sides = LyXTextClass::OneSide;
715 Spacing tmpSpacing = params.spacing;
716 switch (fl_get_choice(class_->choice_doc_spacing)) {
718 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
719 params.spacing.set(Spacing::Single);
722 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
723 params.spacing.set(Spacing::Onehalf);
726 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
727 params.spacing.set(Spacing::Double);
730 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
731 params.spacing.set(Spacing::Other,
732 fl_get_input(class_->input_doc_spacing));
735 if (tmpSpacing != params.spacing)
738 params.options = fl_get_input(class_->input_doc_extra);
744 bool FormDocument::class_apply()
746 BufferParams ¶ms = lv_->buffer()->params;
748 unsigned int const old_class = params.textclass;
750 bool redo = class_apply(params);
752 if (params.textclass != old_class) {
753 // try to load new_class
754 if (textclasslist[params.textclass].load()) {
755 // successfully loaded
757 setMinibuffer(lv_, _("Converting document to new document class..."));
758 int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
759 old_class, params.textclass,
760 lv_->buffer()->paragraph,
761 lv_->buffer()->params);
765 s = _("One paragraph couldn't be converted");
768 s += _(" paragraphs couldn't be converted");
770 Alert::alert(_("Conversion Errors!"),s,
771 _("into chosen document class"));
775 // problem changing class -- warn user and retain old style
776 Alert::alert(_("Conversion Errors!"),
777 _("Errors loading new document class."),
778 _("Reverting to original document class."));
779 combo_doc_class->select(int(old_class) + 1);
787 void FormDocument::paper_apply(BufferParams & params)
789 params.papersize2 = char(fl_get_choice(paper_->choice_papersize)-1);
791 params.paperpackage =
792 char(fl_get_choice(paper_->choice_paperpackage)-1);
794 // set params.papersize from params.papersize2 and params.paperpackage
795 params.setPaperStuff();
797 params.use_geometry = fl_get_button(paper_->check_use_geometry);
799 if (fl_get_button(paper_->radio_landscape))
800 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
802 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
805 getLengthFromWidgets(paper_->input_custom_width,
806 paper_->choice_custom_width_units);
809 getLengthFromWidgets(paper_->input_custom_height,
810 paper_->choice_custom_height_units);
813 getLengthFromWidgets(paper_->input_inner_margin,
814 paper_->choice_inner_margin_units);
817 getLengthFromWidgets(paper_->input_top_margin,
818 paper_->choice_top_margin_units);
821 getLengthFromWidgets(paper_->input_outer_margin,
822 paper_->choice_outer_margin_units);
824 params.bottommargin =
825 getLengthFromWidgets(paper_->input_bottom_margin,
826 paper_->choice_bottom_margin_units);
829 getLengthFromWidgets(paper_->input_head_height,
830 paper_->choice_head_height_units);
833 getLengthFromWidgets(paper_->input_head_sep,
834 paper_->choice_head_sep_units);
837 getLengthFromWidgets(paper_->input_foot_skip,
838 paper_->choice_foot_skip_units);
842 void FormDocument::paper_apply()
844 paper_apply(lv_->buffer()->params);
848 bool FormDocument::language_apply(BufferParams & params)
850 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
853 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
855 lga = InsetQuotes::EnglishQ;
858 lga = InsetQuotes::SwedishQ;
861 lga = InsetQuotes::GermanQ;
864 lga = InsetQuotes::PolishQ;
867 lga = InsetQuotes::FrenchQ;
870 lga = InsetQuotes::DanishQ;
873 params.quotes_language = lga;
874 if (fl_get_button(language_->radio_single))
875 params.quotes_times = InsetQuotes::SingleQ;
877 params.quotes_times = InsetQuotes::DoubleQ;
879 int const pos = combo_language->get();
880 Language const * old_language = params.language;
881 Language const * new_language = languages.getLanguage(lang_[pos-1]);
883 new_language = default_language;
885 if (old_language != new_language
886 && old_language->RightToLeft() == new_language->RightToLeft()
887 && !lv_->buffer()->isMultiLingual())
888 lv_->buffer()->changeLanguage(old_language, new_language);
890 if (old_language != new_language) {
894 params.language = new_language;
895 params.inputenc = fl_get_choice_text(language_->choice_inputenc);
901 bool FormDocument::language_apply()
903 return language_apply(lv_->buffer()->params);
907 bool FormDocument::options_apply(BufferParams & params)
911 params.graphicsDriver =
912 fl_get_choice_text(options_->choice_postscript_driver);
913 params.use_amsmath = fl_get_button(options_->check_use_amsmath);
914 params.use_natbib = fl_get_button(options_->check_use_natbib);
915 params.use_numerical_citations =
916 fl_get_choice(options_->choice_citation_format)-1;
918 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
919 if (params.secnumdepth != tmpchar)
921 params.secnumdepth = tmpchar;
923 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
925 params.float_placement =
926 fl_get_input(options_->input_float_placement);
932 bool FormDocument::options_apply()
934 return options_apply(lv_->buffer()->params);
938 void FormDocument::bullets_apply(BufferParams & params)
940 /* update the bullet settings */
941 BufferParams & buf_params = lv_->buffer()->params;
943 // a little bit of loop unrolling
944 params.user_defined_bullets[0] = buf_params.temp_bullets[0];
945 params.user_defined_bullets[1] = buf_params.temp_bullets[1];
946 params.user_defined_bullets[2] = buf_params.temp_bullets[2];
947 params.user_defined_bullets[3] = buf_params.temp_bullets[3];
951 void FormDocument::bullets_apply()
953 bullets_apply(lv_->buffer()->params);
956 void FormDocument::UpdateClassParams(BufferParams const & params)
958 // These are the params that have to be updated on any class change
959 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
961 LyXTextClass const & tclass = textclasslist[params.textclass];
963 combo_doc_class->select(tclass.description());
964 fl_clear_choice(class_->choice_doc_fontsize);
965 fl_addto_choice(class_->choice_doc_fontsize, "default");
966 fl_addto_choice(class_->choice_doc_fontsize,
967 tclass.opt_fontsize().c_str());
968 fl_set_choice_text(class_->choice_doc_fontsize,
969 params.fontsize.c_str());
970 fl_clear_choice(class_->choice_doc_pagestyle);
971 fl_addto_choice(class_->choice_doc_pagestyle, "default");
972 fl_addto_choice(class_->choice_doc_pagestyle,
973 tclass.opt_pagestyle().c_str());
974 fl_set_choice_text(class_->choice_doc_pagestyle,
975 params.pagestyle.c_str());
979 void FormDocument::class_update(BufferParams const & params)
984 UpdateClassParams(params);
986 fl_set_choice_text(class_->choice_doc_fonts,
987 params.fonts.c_str());
988 fl_set_button(class_->radio_doc_indent, 0);
989 fl_set_button(class_->radio_doc_skip, 0);
990 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
991 fl_set_button(class_->radio_doc_indent, 1);
993 fl_set_button(class_->radio_doc_skip, 1);
995 bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
996 setEnabled(class_->choice_default_skip_units, input_length);
997 setEnabled(class_->input_doc_skip, input_length);
999 switch (params.getDefSkip().kind()) {
1000 case VSpace::SMALLSKIP:
1001 fl_set_choice (class_->choice_doc_skip, 1);
1003 case VSpace::MEDSKIP:
1004 fl_set_choice (class_->choice_doc_skip, 2);
1006 case VSpace::BIGSKIP:
1007 fl_set_choice (class_->choice_doc_skip, 3);
1009 case VSpace::LENGTH:
1011 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1012 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1013 || paperchoice == 2 || paperchoice > 5;
1014 string const default_unit = metric ? "cm" : "in";
1015 string const length = params.getDefSkip().asLyXCommand();
1016 updateWidgetsFromLengthString(class_->input_doc_skip,
1017 class_->choice_default_skip_units,
1018 length, default_unit);
1022 fl_set_choice (class_->choice_doc_skip, 2);
1025 fl_set_button(class_->radio_doc_sides_one, 0);
1026 fl_set_button(class_->radio_doc_sides_two, 0);
1027 setEnabled(class_->choice_doc_skip,
1028 fl_get_button(class_->radio_doc_skip));
1030 if (params.sides == LyXTextClass::TwoSides)
1031 fl_set_button(class_->radio_doc_sides_two, 1);
1033 fl_set_button(class_->radio_doc_sides_one, 1);
1034 fl_set_button(class_->radio_doc_columns_one, 0);
1035 fl_set_button(class_->radio_doc_columns_two, 0);
1036 if (params.columns == 2)
1037 fl_set_button(class_->radio_doc_columns_two, 1);
1039 fl_set_button(class_->radio_doc_columns_one, 1);
1041 fl_set_input(class_->input_doc_spacing, "");
1042 setEnabled(class_->input_doc_spacing, false);
1044 switch (params.spacing.getSpace()) {
1045 case Spacing::Default: // nothing bad should happen with this
1046 case Spacing::Single:
1048 fl_set_choice(class_->choice_doc_spacing, 1);
1050 case Spacing::Onehalf:
1052 fl_set_choice(class_->choice_doc_spacing, 2);
1054 case Spacing::Double:
1056 fl_set_choice(class_->choice_doc_spacing, 3);
1058 case Spacing::Other:
1060 fl_set_choice(class_->choice_doc_spacing, 4);
1062 sprintf(sval,"%g",params.spacing.getValue());
1063 fl_set_input(class_->input_doc_spacing, sval);
1064 setEnabled(class_->input_doc_spacing, true);
1068 if (!params.options.empty())
1069 fl_set_input(class_->input_doc_extra, params.options.c_str());
1071 fl_set_input(class_->input_doc_extra, "");
1075 void FormDocument::language_update(BufferParams const & params)
1077 if (!language_.get())
1080 int const pos = int(findPos(lang_, params.language->lang()));
1081 combo_language->select(pos+1);
1083 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1084 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1085 fl_set_button(language_->radio_single, 0);
1086 fl_set_button(language_->radio_double, 0);
1087 if (params.quotes_times == InsetQuotes::SingleQ)
1088 fl_set_button(language_->radio_single, 1);
1090 fl_set_button(language_->radio_double, 1);
1094 void FormDocument::options_update(BufferParams const & params)
1096 if (!options_.get())
1099 fl_set_choice_text(options_->choice_postscript_driver,
1100 params.graphicsDriver.c_str());
1101 fl_set_button(options_->check_use_amsmath, params.use_amsmath);
1102 fl_set_button(options_->check_use_natbib, params.use_natbib);
1103 fl_set_choice(options_->choice_citation_format,
1104 int(params.use_numerical_citations)+1);
1105 setEnabled(options_->choice_citation_format, params.use_natbib);
1106 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1107 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1108 if (!params.float_placement.empty())
1109 fl_set_input(options_->input_float_placement,
1110 params.float_placement.c_str());
1112 fl_set_input(options_->input_float_placement, "");
1116 void FormDocument::paper_update(BufferParams const & params)
1121 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1122 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1123 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1125 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1126 bool const useCustom = paperchoice == 2;
1127 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1129 fl_set_button(paper_->radio_portrait, 0);
1130 setEnabled(paper_->radio_portrait, !useCustom);
1131 fl_set_button(paper_->radio_landscape, 0);
1132 setEnabled(paper_->radio_landscape, !useCustom);
1134 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
1135 fl_set_button(paper_->radio_landscape, 1);
1137 fl_set_button(paper_->radio_portrait, 1);
1138 setEnabled(paper_->choice_paperpackage,
1139 //either default papersize (preferences)
1140 //or document papersize has to be A4
1142 || paperchoice == 1 && lyxrc.default_papersize == 5)
1143 && fl_get_button(paper_->radio_portrait));
1145 // Default unit choice is cm if metric, inches if US paper.
1146 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1147 || paperchoice == 2 || paperchoice > 5;
1148 string const default_unit = metric ? "cm" : "in";
1149 updateWidgetsFromLengthString(paper_->input_custom_width,
1150 paper_->choice_custom_width_units,
1151 params.paperwidth, default_unit);
1152 setEnabled(paper_->input_custom_width, useCustom);
1153 setEnabled(paper_->choice_custom_width_units, useCustom);
1155 updateWidgetsFromLengthString(paper_->input_custom_height,
1156 paper_->choice_custom_height_units,
1157 params.paperheight, default_unit);
1158 setEnabled(paper_->input_custom_height, useCustom);
1159 setEnabled(paper_->choice_custom_height_units, useCustom);
1161 updateWidgetsFromLengthString(paper_->input_inner_margin,
1162 paper_->choice_inner_margin_units,
1163 params.leftmargin, default_unit);
1164 setEnabled(paper_->input_inner_margin, useGeom);
1165 setEnabled(paper_->choice_inner_margin_units, useGeom);
1167 updateWidgetsFromLengthString(paper_->input_top_margin,
1168 paper_->choice_top_margin_units,
1169 params.topmargin, default_unit);
1170 setEnabled(paper_->input_top_margin, useGeom);
1171 setEnabled(paper_->choice_top_margin_units, useGeom);
1173 updateWidgetsFromLengthString(paper_->input_outer_margin,
1174 paper_->choice_outer_margin_units,
1175 params.rightmargin, default_unit);
1176 setEnabled(paper_->input_outer_margin, useGeom);
1177 setEnabled(paper_->choice_outer_margin_units, useGeom);
1179 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1180 paper_->choice_bottom_margin_units,
1181 params.bottommargin, default_unit);
1182 setEnabled(paper_->input_bottom_margin, useGeom);
1183 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1185 updateWidgetsFromLengthString(paper_->input_head_height,
1186 paper_->choice_head_height_units,
1187 params.headheight, default_unit);
1188 setEnabled(paper_->input_head_height, useGeom);
1189 setEnabled(paper_->choice_head_height_units, useGeom);
1191 updateWidgetsFromLengthString(paper_->input_head_sep,
1192 paper_->choice_head_sep_units,
1193 params.headsep, default_unit);
1194 setEnabled(paper_->input_head_sep, useGeom);
1195 setEnabled(paper_->choice_head_sep_units, useGeom);
1197 updateWidgetsFromLengthString(paper_->input_foot_skip,
1198 paper_->choice_foot_skip_units,
1199 params.footskip, default_unit);
1200 setEnabled(paper_->input_foot_skip, useGeom);
1201 setEnabled(paper_->choice_foot_skip_units, useGeom);
1203 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1207 void FormDocument::bullets_update(BufferParams const & params)
1209 if (!bullets_.get() ||
1211 (XpmVersion==4 && XpmRevision<7)))
1214 bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
1215 setEnabled(fbullet, !isLinuxDoc);
1217 if (isLinuxDoc) return;
1219 fl_set_button(bullets_->radio_bullet_depth_1, 1);
1220 fl_set_input(bullets_->input_bullet_latex,
1221 params.user_defined_bullets[0].getText().c_str());
1222 fl_set_choice(bullets_->choice_bullet_size,
1223 params.user_defined_bullets[0].getSize() + 2);
1227 void FormDocument::checkReadOnly()
1229 if (bc().readOnly(lv_->buffer()->isReadonly())) {
1230 combo_doc_class->deactivate();
1231 combo_language->deactivate();
1232 postWarning(_("Document is read-only."
1233 " No changes to layout permitted."));
1235 combo_doc_class->activate();
1236 combo_language->activate();
1242 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
1248 // this has to be all out of if/elseif because it has to deactivate
1249 // the document buttons and so the whole stuff has to be tested again.
1250 // disable OK/Apply if input is not valid
1251 str = fl_get_input(class_->input_doc_skip);
1252 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1253 str = fl_get_input(paper_->input_custom_width);
1254 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1255 str = fl_get_input(paper_->input_custom_height);
1256 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1257 str = fl_get_input(paper_->input_outer_margin);
1258 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1259 str = fl_get_input(paper_->input_inner_margin);
1260 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1261 str = fl_get_input(paper_->input_top_margin);
1262 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1263 str = fl_get_input(paper_->input_bottom_margin);
1264 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1265 str = fl_get_input(paper_->input_head_height);
1266 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1267 str = fl_get_input(paper_->input_head_sep);
1268 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1269 str = fl_get_input(paper_->input_foot_skip);
1270 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1272 //display warning if input is not valid
1273 if (ob == class_->input_doc_skip
1274 || ob == paper_->input_custom_width
1275 || ob == paper_->input_custom_height
1276 || ob == paper_->input_outer_margin
1277 || ob == paper_->input_inner_margin
1278 || ob == paper_->input_top_margin
1279 || ob == paper_->input_bottom_margin
1280 || ob == paper_->input_head_height
1281 || ob == paper_->input_head_sep
1282 || ob == paper_->input_foot_skip) {
1284 postWarning(_("Invalid Length (valid example: 10mm)"));
1292 // "Synchronize" the choice and the input field, so that it
1293 // is impossible to commit senseless data.
1294 input = fl_get_input (class_->input_doc_skip);
1295 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1297 else if (fl_get_choice(class_->choice_doc_skip) != 4)
1298 fl_set_input (class_->input_doc_skip, "");
1300 input = fl_get_input(class_->input_doc_spacing);
1301 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1303 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
1304 fl_set_input (class_->input_doc_spacing, "");
1309 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1311 BufferParams & param = lv_->buffer()->params;
1313 // convert from 1-6 range to -1-4
1314 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1315 fl_set_input(bullets_->input_bullet_latex,
1316 param.temp_bullets[current_bullet_depth].getText().c_str());
1320 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1322 BufferParams & param = lv_->buffer()->params;
1324 param.temp_bullets[current_bullet_depth].
1325 setText(fl_get_input(bullets_->input_bullet_latex));
1329 void FormDocument::BulletDepth(FL_OBJECT * ob)
1331 /* Should I do the following: */
1332 /* 1. change to the panel that the current bullet belongs in */
1333 /* 2. show that bullet as selected */
1334 /* 3. change the size setting to the size of the bullet in Q.*/
1335 /* 4. display the latex equivalent in the latex box */
1337 /* I'm inclined to just go with 3 and 4 at the moment and */
1338 /* maybe try to support the others later */
1339 BufferParams & param = lv_->buffer()->params;
1342 if (ob == bullets_->radio_bullet_depth_1)
1344 else if (ob == bullets_->radio_bullet_depth_2)
1346 else if (ob == bullets_->radio_bullet_depth_3)
1348 else if (ob == bullets_->radio_bullet_depth_4)
1351 switch (fl_get_button_numb(ob)) {
1353 // right mouse button resets to default
1354 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1356 current_bullet_depth = data;
1357 fl_set_input(bullets_->input_bullet_latex,
1358 param.temp_bullets[data].getText().c_str());
1359 fl_set_choice(bullets_->choice_bullet_size,
1360 param.temp_bullets[data].getSize() + 2);
1365 void FormDocument::BulletPanel(FL_OBJECT * ob)
1367 /* Here we have to change the background pixmap to that selected */
1368 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1371 if (ob == bullets_->radio_bullet_panel_standard)
1373 else if (ob == bullets_->radio_bullet_panel_maths)
1375 else if (ob == bullets_->radio_bullet_panel_ding2)
1377 else if (ob == bullets_->radio_bullet_panel_ding3)
1379 else if (ob == bullets_->radio_bullet_panel_ding4)
1381 else if (ob == bullets_->radio_bullet_panel_ding1)
1384 if (data != current_bullet_panel) {
1385 fl_freeze_form(bullets_->form);
1386 current_bullet_panel = data;
1388 /* free the current pixmap */
1389 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1391 if (ob == bullets_->radio_bullet_panel_standard) {
1392 new_panel = "standard";
1393 } else if (ob == bullets_->radio_bullet_panel_maths ) {
1394 new_panel = "amssymb";
1395 } else if (ob == bullets_->radio_bullet_panel_ding2) {
1396 new_panel = "psnfss1";
1397 } else if (ob == bullets_->radio_bullet_panel_ding3) {
1398 new_panel = "psnfss2";
1399 } else if (ob == bullets_->radio_bullet_panel_ding4) {
1400 new_panel = "psnfss3";
1401 } else if (ob == bullets_->radio_bullet_panel_ding1) {
1402 new_panel = "psnfss4";
1404 /* something very wrong happened */
1405 // play it safe for now but should be an exception
1406 current_bullet_panel = 0; // standard panel
1407 new_panel = "standard";
1409 new_panel += ".xpm";
1410 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1411 LibFileSearch("images", new_panel).c_str());
1412 fl_redraw_object(bullets_->bmtable_bullet_panel);
1413 fl_unfreeze_form(bullets_->form);
1418 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1420 /* handle the user input by setting the current bullet depth's pixmap */
1421 /* to that extracted from the current chosen position of the BMTable */
1422 /* Don't forget to free the button's old pixmap first. */
1424 BufferParams & param = lv_->buffer()->params;
1425 int bmtable_button = fl_get_bmtable(ob);
1427 /* try to keep the button held down till another is pushed */
1428 /* fl_set_bmtable(ob, 1, bmtable_button); */
1429 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1430 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1431 fl_set_input(bullets_->input_bullet_latex,
1432 param.temp_bullets[current_bullet_depth].getText().c_str());
1436 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1439 ob = class_->choice_doc_class;
1441 lv_->prohibitInput();
1443 unsigned int tc = combo_doc_class->get() - 1;
1444 if (textclasslist[tc].load()) {
1445 // we use a copy of the bufferparams because we do not
1446 // want to modify them yet.
1447 BufferParams params = lv_->buffer()->params;
1449 if (lyxrc.auto_reset_options) {
1450 params.textclass = tc;
1451 params.useClassDefaults();
1452 UpdateLayoutDocument(params);
1454 // update the params which are needed in any case
1455 // (fontsizes, pagestyle)
1456 params.textclass = tc;
1457 UpdateClassParams(params);
1461 // unable to load new style
1462 Alert::alert(_("Conversion Errors!"),
1463 _("Unable to switch to new document class."),
1464 _("Reverting to original document class."));
1465 combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
1471 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1477 class_update(params);
1478 paper_update(params);
1479 language_update(params);
1480 options_update(params);
1481 bullets_update(params);