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)
66 // let the dialog be shown
67 // This is a permanent connection so we won't bother
68 // storing a copy because we won't be disconnecting.
69 d->showDocument = boost::bind(&FormDocument::show, this);
74 void FormDocument::redraw()
76 if (form() && form()->visible)
77 fl_redraw_form(form());
81 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
82 if (outer_form && outer_form->visible)
83 fl_redraw_form(outer_form);
87 FL_FORM * FormDocument::form() const
89 if (dialog_.get()) return dialog_->form;
94 void FormDocument::build()
99 dialog_.reset(build_document(this));
101 // Allow the base class to control messages
102 setMessageWidget(dialog_->text_warning);
104 // Manage the restore, ok, apply, restore and cancel/close buttons
105 bc().setOK(dialog_->button_ok);
106 bc().setApply(dialog_->button_apply);
107 bc().setCancel(dialog_->button_close);
108 bc().setRestore(dialog_->button_restore);
109 bc().addReadOnly (dialog_->button_save_defaults);
110 bc().addReadOnly (dialog_->button_reset_defaults);
112 // the document paper form
113 paper_.reset(build_document_paper(this));
114 fl_addto_choice(paper_->choice_papersize,
115 _(" Default | Custom | US letter | US legal "
116 "| US executive | A3 | A4 | A5 | B3 | B4 | B5 "));
117 fl_addto_choice(paper_->choice_paperpackage,
120 "| Very small Margins "
121 "| Very wide Margins "));
123 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
124 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
125 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
126 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
127 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
128 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
129 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
130 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
131 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
133 setPrehandler(paper_->input_custom_width);
134 setPrehandler(paper_->input_custom_height);
135 setPrehandler(paper_->input_top_margin);
136 setPrehandler(paper_->input_bottom_margin);
137 setPrehandler(paper_->input_inner_margin);
138 setPrehandler(paper_->input_outer_margin);
139 setPrehandler(paper_->input_head_height);
140 setPrehandler(paper_->input_head_sep);
141 setPrehandler(paper_->input_foot_skip);
143 // Create the contents of the unit choices
144 // Don't include the "%" terms...
145 vector<string> units_vec = getLatexUnits();
147 for (vector<string>::iterator it = units_vec.begin();
148 it != units_vec.end(); ++it) {
149 if (contains(*it, "%"))
150 it = units_vec.erase(it, it+1) - 1;
153 vector<string>::iterator ret =
154 std::remove_if(units_vec.begin(),
156 bind2nd(contains_functor(), "%"));
157 units_vec.erase(ret, units_vec.end());
159 string units = getStringFromVector(units_vec, "|");
161 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
162 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
163 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
164 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
165 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
166 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
167 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
168 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
169 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
171 bc().addReadOnly (paper_->choice_paperpackage);
172 bc().addReadOnly (paper_->radio_portrait);
173 bc().addReadOnly (paper_->radio_landscape);
174 bc().addReadOnly (paper_->choice_papersize);
175 bc().addReadOnly (paper_->check_use_geometry);
176 bc().addReadOnly (paper_->input_custom_width);
177 bc().addReadOnly (paper_->input_custom_height);
178 bc().addReadOnly (paper_->input_top_margin);
179 bc().addReadOnly (paper_->input_bottom_margin);
180 bc().addReadOnly (paper_->input_inner_margin);
181 bc().addReadOnly (paper_->input_outer_margin);
182 bc().addReadOnly (paper_->input_head_height);
183 bc().addReadOnly (paper_->input_head_sep);
184 bc().addReadOnly (paper_->input_foot_skip);
186 // the document class form
187 class_.reset(build_document_class(this));
190 // The language is a combo-box and has to be inserted manually
191 obj = class_->choice_doc_class;
192 fl_deactivate_object(obj);
193 fl_addto_form(class_->form);
194 combo_doc_class.reset(new Combox(FL_COMBOX_DROPLIST));
195 combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400,
197 combo_doc_class->shortcut("#C",1);
198 combo_doc_class->setcallback(ComboInputCB, this);
200 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
201 cit != textclasslist.end(); ++cit) {
202 combo_doc_class->addto(cit->description());
205 fl_addto_choice(class_->choice_doc_spacing,
206 _(" Single | OneHalf | Double | Custom "));
207 fl_addto_choice(class_->choice_doc_fontsize, "default|10|11|12");
208 for (n=0; tex_fonts[n][0]; ++n) {
209 fl_addto_choice(class_->choice_doc_fonts,tex_fonts[n]);
211 fl_addto_choice(class_->choice_doc_pagestyle,
212 "default|empty|plain|headings|fancy");
213 fl_addto_choice(class_->choice_doc_skip,
214 _(" Smallskip | Medskip | Bigskip | Length "));
215 fl_addto_choice(class_->choice_default_skip_units, units.c_str());
216 fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
217 fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
218 fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
220 setPrehandler(class_->input_doc_extra);
221 setPrehandler(class_->input_doc_skip);
222 setPrehandler(class_->input_doc_spacing);
224 // Set input filters on doc spacing to make it accept only
226 fl_set_input_filter(class_->input_doc_spacing, fl_unsigned_float_filter);
228 bc().addReadOnly (class_->radio_doc_indent);
229 bc().addReadOnly (class_->radio_doc_skip);
231 bc().addReadOnly (class_->choice_doc_pagestyle);
232 bc().addReadOnly (class_->choice_doc_fonts);
233 bc().addReadOnly (class_->choice_doc_fontsize);
234 bc().addReadOnly (class_->radio_doc_sides_one);
235 bc().addReadOnly (class_->radio_doc_sides_two);
236 bc().addReadOnly (class_->radio_doc_columns_one);
237 bc().addReadOnly (class_->radio_doc_columns_two);
238 bc().addReadOnly (class_->input_doc_extra);
239 bc().addReadOnly (class_->input_doc_skip);
240 bc().addReadOnly (class_->choice_doc_skip);
241 bc().addReadOnly (class_->choice_doc_spacing);
242 bc().addReadOnly (class_->input_doc_spacing);
244 // the document language form
245 language_.reset(build_document_language(this));
246 fl_addto_choice(language_->choice_inputenc,
247 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
248 "|koi8-r|koi8-u|cp866|cp1251|iso88595");
250 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
251 // Store the identifiers for later
252 lang_ = getSecond(langs);
254 // The language is a combo-box and has to be inserted manually
255 obj = language_->choice_language;
256 fl_deactivate_object(obj);
257 fl_addto_form(language_->form);
258 combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
259 combo_language->add(obj->x, obj->y, obj->w, obj->h, 400,
261 combo_language->shortcut("#L",1);
262 combo_language->setcallback(ComboInputCB, this);
265 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
266 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
267 for (; lit != lend; ++lit) {
268 combo_language->addto(lit->first);
270 combo_language->select(1);
272 fl_addto_choice(language_->choice_quotes_language,
273 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
274 " «text» | »text« "));
276 bc().addReadOnly (language_->choice_inputenc);
277 bc().addReadOnly (language_->choice_quotes_language);
278 bc().addReadOnly (language_->radio_single);
279 bc().addReadOnly (language_->radio_double);
281 // the document options form
282 options_.reset(build_document_options(this));
283 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
284 setPrehandler(options_->input_float_placement);
286 fl_set_counter_bounds(options_->counter_secnumdepth,-2,5);
287 fl_set_counter_bounds(options_->counter_tocdepth,-1,5);
288 fl_set_counter_step(options_->counter_secnumdepth,1,1);
289 fl_set_counter_step(options_->counter_tocdepth,1,1);
290 fl_set_counter_precision(options_->counter_secnumdepth, 0);
291 fl_set_counter_precision(options_->counter_tocdepth, 0);
292 for (n=0; tex_graphics[n][0]; ++n) {
293 fl_addto_choice(options_->choice_postscript_driver,
296 fl_addto_choice(options_->choice_citation_format,
297 _(" Author-year | Numerical "));
299 bc_.addReadOnly (options_->counter_secnumdepth);
300 bc_.addReadOnly (options_->counter_tocdepth);
301 bc_.addReadOnly (options_->check_use_amsmath);
302 bc_.addReadOnly (options_->check_use_natbib);
303 bc_.addReadOnly (options_->choice_citation_format);
304 bc_.addReadOnly (options_->input_float_placement);
305 bc_.addReadOnly (options_->choice_postscript_driver);
307 // the document bullets form
308 bullets_.reset(build_document_bullet(this));
309 fl_addto_choice(bullets_->choice_bullet_size,
310 _(" default | tiny | script | footnote | small |"
311 " normal | large | Large | LARGE | huge | Huge"));
312 fl_set_choice(bullets_->choice_bullet_size, 1);
313 fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
314 setPrehandler(bullets_->input_bullet_latex);
315 fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
317 bc_.addReadOnly(bullets_->radio_bullet_depth_1);
318 bc_.addReadOnly(bullets_->radio_bullet_depth_2);
319 bc_.addReadOnly(bullets_->radio_bullet_depth_3);
320 bc_.addReadOnly(bullets_->radio_bullet_depth_4);
321 bc_.addReadOnly(bullets_->radio_bullet_panel_standard);
322 bc_.addReadOnly(bullets_->radio_bullet_panel_maths);
323 bc_.addReadOnly(bullets_->radio_bullet_panel_ding1);
324 bc_.addReadOnly(bullets_->radio_bullet_panel_ding2);
325 bc_.addReadOnly(bullets_->radio_bullet_panel_ding3);
326 bc_.addReadOnly(bullets_->radio_bullet_panel_ding4);
328 bc().addReadOnly (bullets_->bmtable_bullet_panel);
329 bc().addReadOnly (bullets_->choice_bullet_size);
330 bc().addReadOnly (bullets_->input_bullet_latex);
332 fl_addto_tabfolder(dialog_->tabfolder,_("Document"),
334 fl_addto_tabfolder(dialog_->tabfolder,_("Paper"),
336 fl_addto_tabfolder(dialog_->tabfolder,_("Language"),
338 fl_addto_tabfolder(dialog_->tabfolder,_("Extra"),
340 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets"),
342 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
343 lyxerr << _("Your version of libXpm is older than 4.7.\n"
344 "The `bullet' tab of the document dialog "
345 "has been disabled") << '\n';
346 fl_deactivate_object(fbullet);
347 fl_set_object_lcol(fbullet, FL_INACTIVE);
352 void FormDocument::apply()
354 if (!lv_->view()->available() || !dialog_.get())
357 bool redo = class_apply();
359 redo = language_apply() || redo;
360 redo = options_apply() || redo;
364 lv_->view()->redoCurrentBuffer();
366 lv_->buffer()->markDirty();
367 setMinibuffer(lv_, _("Document layout set"));
371 void FormDocument::cancel()
373 // this avoids confusion when reopening
374 BufferParams & param = lv_->buffer()->params;
375 param.temp_bullets[0] = param.user_defined_bullets[0];
376 param.temp_bullets[1] = param.user_defined_bullets[1];
377 param.temp_bullets[2] = param.user_defined_bullets[2];
378 param.temp_bullets[3] = param.user_defined_bullets[3];
383 void FormDocument::update()
390 BufferParams const & params = lv_->buffer()->params;
392 class_update(params);
393 paper_update(params);
394 language_update(params);
395 options_update(params);
396 bullets_update(params);
401 // should this go elsewhere? Maybe a ControllerDocument? (JMarc)
402 /** Save the buffer's parameters as user default.
403 This function saves a file \c user_lyxdir/templates/defaults.lyx
404 which parameters are those of the current buffer. This file
405 is used as a default template when creating a new
406 file. Returns \c true on success.
408 bool saveParamsAsDefault(BufferParams const ¶ms)
410 if (!Alert::askQuestion(_("Do you want to save the current settings"),
411 _("for the document layout as default?"),
412 _("(they will be valid for any new document)")))
415 string const fname = AddName(AddPath(user_lyxdir, "templates/"),
417 Buffer defaults = Buffer(fname);
418 defaults.params = params;
420 // add an empty paragraph. Is this enough?
421 defaults.paragraph = new Paragraph;
423 return defaults.writeFile(defaults.fileName(), false);
429 bool FormDocument::input(FL_OBJECT * ob, long)
431 if (ob == class_->choice_doc_class) {
432 CheckChoiceClass(ob, 0);
433 } else if (ob == bullets_->choice_bullet_size) {
434 ChoiceBulletSize(ob, 0);
435 } else if (ob == bullets_->input_bullet_latex) {
436 InputBulletLaTeX(ob, 0);
437 } else if (ob == bullets_->radio_bullet_depth_1 ||
438 ob == bullets_->radio_bullet_depth_2 ||
439 ob == bullets_->radio_bullet_depth_3 ||
440 ob == bullets_->radio_bullet_depth_4) {
442 } else if (ob == bullets_->radio_bullet_panel_standard ||
443 ob == bullets_->radio_bullet_panel_maths ||
444 ob == bullets_->radio_bullet_panel_ding1 ||
445 ob == bullets_->radio_bullet_panel_ding2 ||
446 ob == bullets_->radio_bullet_panel_ding3 ||
447 ob == bullets_->radio_bullet_panel_ding4) {
449 } else if (ob == bullets_->bmtable_bullet_panel) {
450 BulletBMTable(ob, 0);
453 bool const length_input = fl_get_choice(class_->choice_doc_skip) == 4;
454 if (ob == class_->choice_doc_skip) {
455 setEnabled(class_->input_doc_skip, length_input);
456 setEnabled(class_->choice_default_skip_units, length_input);
459 if (ob == class_->choice_doc_spacing)
460 setEnabled(class_->input_doc_spacing,
461 fl_get_choice(class_->choice_doc_spacing) == 4);
463 bool const skip_used = fl_get_button(class_->radio_doc_skip);
464 if (ob == class_->radio_doc_skip ||
465 ob == class_->radio_doc_indent) {
466 setEnabled(class_->choice_doc_skip, skip_used);
467 setEnabled(class_->input_doc_skip,
468 skip_used && length_input);
469 setEnabled(class_->choice_default_skip_units,
470 skip_used && length_input);
471 // Default unit choice is cm if metric, inches if US paper.
472 // If papersize is default, check the lyxrc-settings
473 int const paperchoice = fl_get_choice(paper_->choice_papersize);
474 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
475 || paperchoice == 2 || paperchoice > 5;
476 int const default_unit = metric ? 8 : 9;
477 if (strip(fl_get_input(class_->input_doc_skip)).empty())
478 fl_set_choice(class_->choice_default_skip_units,
482 if (ob == options_->check_use_natbib) {
483 setEnabled(options_->choice_citation_format,
484 fl_get_button(options_->check_use_natbib));
487 if (ob == dialog_->button_save_defaults) {
491 language_apply(params);
492 options_apply(params);
493 bullets_apply(params);
494 params.preamble = lv_->buffer()->params.preamble;
495 saveParamsAsDefault(params);
498 if (ob == dialog_->button_reset_defaults) {
499 BufferParams params = lv_->buffer()->params;
500 params.textclass = combo_doc_class->get() - 1;
501 params.useClassDefaults();
502 UpdateLayoutDocument(params);
505 if (ob == paper_->radio_landscape)
506 fl_set_choice(paper_->choice_paperpackage,
507 BufferParams::PACKAGE_NONE + 1);
509 if (ob == paper_->choice_papersize) {
510 int const paperchoice = fl_get_choice(paper_->choice_papersize);
511 bool const defsize = paperchoice == 1;
512 bool const custom = paperchoice == 2;
513 bool const a3size = paperchoice == 6;
514 bool const b3size = paperchoice == 9;
515 bool const b4size = paperchoice == 10;
518 fl_set_button(paper_->radio_portrait, 1);
520 bool const use_geom = (custom || a3size || b3size || b4size);
522 fl_set_button(paper_->check_use_geometry, int(use_geom));
524 setEnabled(paper_->input_top_margin, use_geom);
525 setEnabled(paper_->input_bottom_margin, use_geom);
526 setEnabled(paper_->input_inner_margin, use_geom);
527 setEnabled(paper_->input_outer_margin, use_geom);
528 setEnabled(paper_->input_head_height, use_geom);
529 setEnabled(paper_->input_head_sep, use_geom);
530 setEnabled(paper_->input_foot_skip, use_geom);
531 setEnabled(paper_->choice_top_margin_units, use_geom);
532 setEnabled(paper_->choice_bottom_margin_units, use_geom);
533 setEnabled(paper_->choice_inner_margin_units, use_geom);
534 setEnabled(paper_->choice_outer_margin_units, use_geom);
535 setEnabled(paper_->choice_head_height_units, use_geom);
536 setEnabled(paper_->choice_head_sep_units, use_geom);
537 setEnabled(paper_->choice_foot_skip_units, use_geom);
538 setEnabled(paper_->choice_custom_width_units, use_geom);
539 setEnabled(paper_->choice_custom_height_units, use_geom);
541 setEnabled(paper_->input_custom_width, custom);
542 setEnabled(paper_->input_custom_height, custom);
543 setEnabled(paper_->choice_custom_width_units, custom);
544 setEnabled(paper_->choice_custom_height_units, custom);
545 setEnabled(paper_->radio_portrait, !custom);
546 setEnabled(paper_->radio_landscape, !custom);
548 // Default unit choice is cm if metric, inches if US paper.
549 // If papersize is default, use the lyxrc-settings
550 bool const metric = (defsize && lyxrc.default_papersize > 3)
551 || paperchoice == 2 || paperchoice > 5;
552 int const default_unit = metric ? 8 : 9;
553 if (strip(fl_get_input(paper_->input_custom_width)).empty())
554 fl_set_choice(paper_->choice_custom_width_units,
556 if (strip(fl_get_input(paper_->input_custom_height)).empty())
557 fl_set_choice(paper_->choice_custom_height_units,
559 if (strip(fl_get_input(paper_->input_top_margin)).empty())
560 fl_set_choice(paper_->choice_top_margin_units,
562 if (strip(fl_get_input(paper_->input_bottom_margin)).empty())
563 fl_set_choice(paper_->choice_bottom_margin_units,
565 if (strip(fl_get_input(paper_->input_inner_margin)).empty())
566 fl_set_choice(paper_->choice_inner_margin_units,
568 if (strip(fl_get_input(paper_->input_outer_margin)).empty())
569 fl_set_choice(paper_->choice_outer_margin_units,
571 if (strip(fl_get_input(paper_->input_head_height)).empty())
572 fl_set_choice(paper_->choice_head_height_units,
574 if (strip(fl_get_input(paper_->input_head_sep)).empty())
575 fl_set_choice(paper_->choice_head_sep_units,
577 if (strip(fl_get_input(paper_->input_foot_skip)).empty())
578 fl_set_choice(paper_->choice_foot_skip_units,
582 if (ob == paper_->choice_papersize ||
583 ob == paper_->radio_portrait ||
584 ob == paper_->radio_landscape) {
586 setEnabled(paper_->choice_paperpackage,
587 //either default papersize (preferences)
588 //or document papersize has to be A4
589 (fl_get_choice(paper_->choice_papersize) == 7
590 || fl_get_choice(paper_->choice_papersize) == 1
591 && lyxrc.default_papersize == 5)
592 && fl_get_button(paper_->radio_portrait));
595 if (ob == paper_->choice_paperpackage) {
596 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
597 fl_set_button(paper_->check_use_geometry, 0);
599 setEnabled(paper_->input_top_margin, false);
600 setEnabled(paper_->input_bottom_margin, false);
601 setEnabled(paper_->input_inner_margin, false);
602 setEnabled(paper_->input_outer_margin, false);
603 setEnabled(paper_->input_head_height, false);
604 setEnabled(paper_->input_head_sep, false);
605 setEnabled(paper_->input_foot_skip, false);
606 setEnabled(paper_->choice_top_margin_units, false);
607 setEnabled(paper_->choice_bottom_margin_units, false);
608 setEnabled(paper_->choice_inner_margin_units, false);
609 setEnabled(paper_->choice_outer_margin_units, false);
610 setEnabled(paper_->choice_head_height_units, false);
611 setEnabled(paper_->choice_head_sep_units, false);
612 setEnabled(paper_->choice_foot_skip_units, false);
616 if (ob == paper_->check_use_geometry) {
617 //don't allow switching geometry off in custom papersize mode
618 //nor in A3, B3, and B4
619 int const choice = fl_get_choice(paper_->choice_papersize);
620 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
621 fl_set_button(paper_->check_use_geometry, 1);
623 fl_set_choice(paper_->choice_paperpackage,
624 BufferParams::PACKAGE_NONE + 1);
626 bool const use_geom = fl_get_button(paper_->check_use_geometry);
627 setEnabled(paper_->input_top_margin, use_geom);
628 setEnabled(paper_->input_bottom_margin, use_geom);
629 setEnabled(paper_->input_inner_margin, use_geom);
630 setEnabled(paper_->input_outer_margin, use_geom);
631 setEnabled(paper_->input_head_height, use_geom);
632 setEnabled(paper_->input_head_sep, use_geom);
633 setEnabled(paper_->input_foot_skip, use_geom);
634 setEnabled(paper_->choice_top_margin_units, use_geom);
635 setEnabled(paper_->choice_bottom_margin_units, use_geom);
636 setEnabled(paper_->choice_inner_margin_units, use_geom);
637 setEnabled(paper_->choice_outer_margin_units, use_geom);
638 setEnabled(paper_->choice_head_height_units, use_geom);
639 setEnabled(paper_->choice_head_sep_units, use_geom);
640 setEnabled(paper_->choice_foot_skip_units, use_geom);
643 return CheckDocumentInput(ob, 0);
647 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
649 FormDocument * pre = static_cast<FormDocument*>(v);
650 if (combox == pre->combo_doc_class.get())
651 pre->CheckChoiceClass(0, 0);
652 pre->bc().valid(pre->CheckDocumentInput(0,0));
656 bool FormDocument::class_apply(BufferParams ¶ms)
660 // If default skip is a "Length" but there's no text in the
661 // input field, reset the kind to "Medskip", which is the default.
662 if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
663 !*(fl_get_input (class_->input_doc_skip))) {
664 fl_set_choice (class_->choice_doc_skip, 2);
666 params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
667 params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
668 params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
670 params.textclass = combo_doc_class->get() - 1;
672 BufferParams::PARSEP tmpsep = params.paragraph_separation;
673 if (fl_get_button(class_->radio_doc_indent))
674 params.paragraph_separation = BufferParams::PARSEP_INDENT;
676 params.paragraph_separation = BufferParams::PARSEP_SKIP;
677 if (tmpsep != params.paragraph_separation)
680 VSpace tmpdefskip = params.getDefSkip();
681 switch (fl_get_choice (class_->choice_doc_skip)) {
683 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
686 params.setDefSkip(VSpace(VSpace::MEDSKIP));
689 params.setDefSkip(VSpace(VSpace::BIGSKIP));
693 string const length =
694 getLengthFromWidgets(class_->input_doc_skip,
695 class_->choice_default_skip_units);
697 params.setDefSkip(VSpace(LyXGlueLength(length)));
701 // DocumentDefskipCB assures that this never happens
702 params.setDefSkip(VSpace(VSpace::MEDSKIP));
705 if (!(tmpdefskip == params.getDefSkip()))
708 if (fl_get_button(class_->radio_doc_columns_two))
712 if (fl_get_button(class_->radio_doc_sides_two))
713 params.sides = LyXTextClass::TwoSides;
715 params.sides = LyXTextClass::OneSide;
717 Spacing tmpSpacing = params.spacing;
718 switch (fl_get_choice(class_->choice_doc_spacing)) {
720 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
721 params.spacing.set(Spacing::Single);
724 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
725 params.spacing.set(Spacing::Onehalf);
728 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
729 params.spacing.set(Spacing::Double);
732 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
733 params.spacing.set(Spacing::Other,
734 fl_get_input(class_->input_doc_spacing));
737 if (tmpSpacing != params.spacing)
740 params.options = fl_get_input(class_->input_doc_extra);
746 bool FormDocument::class_apply()
748 BufferParams ¶ms = lv_->buffer()->params;
750 unsigned int const old_class = params.textclass;
752 bool redo = class_apply(params);
754 if (params.textclass != old_class) {
755 // try to load new_class
756 if (textclasslist[params.textclass].load()) {
757 // successfully loaded
759 setMinibuffer(lv_, _("Converting document to new document class..."));
760 int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
761 old_class, params.textclass,
762 lv_->buffer()->paragraph,
763 lv_->buffer()->params);
767 s = _("One paragraph couldn't be converted");
770 s += _(" paragraphs couldn't be converted");
772 Alert::alert(_("Conversion Errors!"),s,
773 _("into chosen document class"));
777 // problem changing class -- warn user and retain old style
778 Alert::alert(_("Conversion Errors!"),
779 _("Errors loading new document class."),
780 _("Reverting to original document class."));
781 combo_doc_class->select(int(old_class) + 1);
789 void FormDocument::paper_apply(BufferParams & params)
791 params.papersize2 = char(fl_get_choice(paper_->choice_papersize)-1);
793 params.paperpackage =
794 char(fl_get_choice(paper_->choice_paperpackage)-1);
796 // set params.papersize from params.papersize2 and params.paperpackage
797 params.setPaperStuff();
799 params.use_geometry = fl_get_button(paper_->check_use_geometry);
801 if (fl_get_button(paper_->radio_landscape))
802 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
804 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
807 getLengthFromWidgets(paper_->input_custom_width,
808 paper_->choice_custom_width_units);
811 getLengthFromWidgets(paper_->input_custom_height,
812 paper_->choice_custom_height_units);
815 getLengthFromWidgets(paper_->input_inner_margin,
816 paper_->choice_inner_margin_units);
819 getLengthFromWidgets(paper_->input_top_margin,
820 paper_->choice_top_margin_units);
823 getLengthFromWidgets(paper_->input_outer_margin,
824 paper_->choice_outer_margin_units);
826 params.bottommargin =
827 getLengthFromWidgets(paper_->input_bottom_margin,
828 paper_->choice_bottom_margin_units);
831 getLengthFromWidgets(paper_->input_head_height,
832 paper_->choice_head_height_units);
835 getLengthFromWidgets(paper_->input_head_sep,
836 paper_->choice_head_sep_units);
839 getLengthFromWidgets(paper_->input_foot_skip,
840 paper_->choice_foot_skip_units);
844 void FormDocument::paper_apply()
846 paper_apply(lv_->buffer()->params);
850 bool FormDocument::language_apply(BufferParams & params)
852 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
855 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
857 lga = InsetQuotes::EnglishQ;
860 lga = InsetQuotes::SwedishQ;
863 lga = InsetQuotes::GermanQ;
866 lga = InsetQuotes::PolishQ;
869 lga = InsetQuotes::FrenchQ;
872 lga = InsetQuotes::DanishQ;
875 params.quotes_language = lga;
876 if (fl_get_button(language_->radio_single))
877 params.quotes_times = InsetQuotes::SingleQ;
879 params.quotes_times = InsetQuotes::DoubleQ;
881 int const pos = combo_language->get();
882 Language const * old_language = params.language;
883 Language const * new_language = languages.getLanguage(lang_[pos-1]);
885 new_language = default_language;
887 if (old_language != new_language
888 && old_language->RightToLeft() == new_language->RightToLeft()
889 && !lv_->buffer()->isMultiLingual())
890 lv_->buffer()->changeLanguage(old_language, new_language);
892 if (old_language != new_language) {
896 params.language = new_language;
897 params.inputenc = fl_get_choice_text(language_->choice_inputenc);
903 bool FormDocument::language_apply()
905 return language_apply(lv_->buffer()->params);
909 bool FormDocument::options_apply(BufferParams & params)
913 params.graphicsDriver =
914 fl_get_choice_text(options_->choice_postscript_driver);
915 params.use_amsmath = fl_get_button(options_->check_use_amsmath);
916 params.use_natbib = fl_get_button(options_->check_use_natbib);
917 params.use_numerical_citations =
918 fl_get_choice(options_->choice_citation_format)-1;
920 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
921 if (params.secnumdepth != tmpchar)
923 params.secnumdepth = tmpchar;
925 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
927 params.float_placement =
928 fl_get_input(options_->input_float_placement);
934 bool FormDocument::options_apply()
936 return options_apply(lv_->buffer()->params);
940 void FormDocument::bullets_apply(BufferParams & params)
942 /* update the bullet settings */
943 BufferParams & buf_params = lv_->buffer()->params;
945 // a little bit of loop unrolling
946 params.user_defined_bullets[0] = buf_params.temp_bullets[0];
947 params.user_defined_bullets[1] = buf_params.temp_bullets[1];
948 params.user_defined_bullets[2] = buf_params.temp_bullets[2];
949 params.user_defined_bullets[3] = buf_params.temp_bullets[3];
953 void FormDocument::bullets_apply()
955 bullets_apply(lv_->buffer()->params);
958 void FormDocument::UpdateClassParams(BufferParams const & params)
960 // These are the params that have to be updated on any class change
961 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
963 LyXTextClass const & tclass = textclasslist[params.textclass];
965 combo_doc_class->select(tclass.description());
966 fl_clear_choice(class_->choice_doc_fontsize);
967 fl_addto_choice(class_->choice_doc_fontsize, "default");
968 fl_addto_choice(class_->choice_doc_fontsize,
969 tclass.opt_fontsize().c_str());
970 fl_set_choice_text(class_->choice_doc_fontsize,
971 params.fontsize.c_str());
972 fl_clear_choice(class_->choice_doc_pagestyle);
973 fl_addto_choice(class_->choice_doc_pagestyle, "default");
974 fl_addto_choice(class_->choice_doc_pagestyle,
975 tclass.opt_pagestyle().c_str());
976 fl_set_choice_text(class_->choice_doc_pagestyle,
977 params.pagestyle.c_str());
981 void FormDocument::class_update(BufferParams const & params)
986 UpdateClassParams(params);
988 fl_set_choice_text(class_->choice_doc_fonts,
989 params.fonts.c_str());
990 fl_set_button(class_->radio_doc_indent, 0);
991 fl_set_button(class_->radio_doc_skip, 0);
992 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
993 fl_set_button(class_->radio_doc_indent, 1);
995 fl_set_button(class_->radio_doc_skip, 1);
997 bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
998 setEnabled(class_->choice_default_skip_units, input_length);
999 setEnabled(class_->input_doc_skip, input_length);
1001 switch (params.getDefSkip().kind()) {
1002 case VSpace::SMALLSKIP:
1003 fl_set_choice (class_->choice_doc_skip, 1);
1005 case VSpace::MEDSKIP:
1006 fl_set_choice (class_->choice_doc_skip, 2);
1008 case VSpace::BIGSKIP:
1009 fl_set_choice (class_->choice_doc_skip, 3);
1011 case VSpace::LENGTH:
1013 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1014 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1015 || paperchoice == 2 || paperchoice > 5;
1016 string const default_unit = metric ? "cm" : "in";
1017 string const length = params.getDefSkip().asLyXCommand();
1018 updateWidgetsFromLengthString(class_->input_doc_skip,
1019 class_->choice_default_skip_units,
1020 length, default_unit);
1024 fl_set_choice (class_->choice_doc_skip, 2);
1027 fl_set_button(class_->radio_doc_sides_one, 0);
1028 fl_set_button(class_->radio_doc_sides_two, 0);
1029 setEnabled(class_->choice_doc_skip,
1030 fl_get_button(class_->radio_doc_skip));
1032 if (params.sides == LyXTextClass::TwoSides)
1033 fl_set_button(class_->radio_doc_sides_two, 1);
1035 fl_set_button(class_->radio_doc_sides_one, 1);
1036 fl_set_button(class_->radio_doc_columns_one, 0);
1037 fl_set_button(class_->radio_doc_columns_two, 0);
1038 if (params.columns == 2)
1039 fl_set_button(class_->radio_doc_columns_two, 1);
1041 fl_set_button(class_->radio_doc_columns_one, 1);
1043 fl_set_input(class_->input_doc_spacing, "");
1044 setEnabled(class_->input_doc_spacing, false);
1046 switch (params.spacing.getSpace()) {
1047 case Spacing::Default: // nothing bad should happen with this
1048 case Spacing::Single:
1050 fl_set_choice(class_->choice_doc_spacing, 1);
1052 case Spacing::Onehalf:
1054 fl_set_choice(class_->choice_doc_spacing, 2);
1056 case Spacing::Double:
1058 fl_set_choice(class_->choice_doc_spacing, 3);
1060 case Spacing::Other:
1062 fl_set_choice(class_->choice_doc_spacing, 4);
1064 sprintf(sval,"%g",params.spacing.getValue());
1065 fl_set_input(class_->input_doc_spacing, sval);
1066 setEnabled(class_->input_doc_spacing, true);
1070 if (!params.options.empty())
1071 fl_set_input(class_->input_doc_extra, params.options.c_str());
1073 fl_set_input(class_->input_doc_extra, "");
1077 void FormDocument::language_update(BufferParams const & params)
1079 if (!language_.get())
1082 int const pos = int(findPos(lang_, params.language->lang()));
1083 combo_language->select(pos+1);
1085 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1086 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1087 fl_set_button(language_->radio_single, 0);
1088 fl_set_button(language_->radio_double, 0);
1089 if (params.quotes_times == InsetQuotes::SingleQ)
1090 fl_set_button(language_->radio_single, 1);
1092 fl_set_button(language_->radio_double, 1);
1096 void FormDocument::options_update(BufferParams const & params)
1098 if (!options_.get())
1101 fl_set_choice_text(options_->choice_postscript_driver,
1102 params.graphicsDriver.c_str());
1103 fl_set_button(options_->check_use_amsmath, params.use_amsmath);
1104 fl_set_button(options_->check_use_natbib, params.use_natbib);
1105 fl_set_choice(options_->choice_citation_format,
1106 int(params.use_numerical_citations)+1);
1107 setEnabled(options_->choice_citation_format, params.use_natbib);
1108 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1109 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1110 if (!params.float_placement.empty())
1111 fl_set_input(options_->input_float_placement,
1112 params.float_placement.c_str());
1114 fl_set_input(options_->input_float_placement, "");
1118 void FormDocument::paper_update(BufferParams const & params)
1123 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1124 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1125 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1127 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1128 bool const useCustom = paperchoice == 2;
1129 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1131 fl_set_button(paper_->radio_portrait, 0);
1132 setEnabled(paper_->radio_portrait, !useCustom);
1133 fl_set_button(paper_->radio_landscape, 0);
1134 setEnabled(paper_->radio_landscape, !useCustom);
1136 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
1137 fl_set_button(paper_->radio_landscape, 1);
1139 fl_set_button(paper_->radio_portrait, 1);
1140 setEnabled(paper_->choice_paperpackage,
1141 //either default papersize (preferences)
1142 //or document papersize has to be A4
1144 || paperchoice == 1 && lyxrc.default_papersize == 5)
1145 && fl_get_button(paper_->radio_portrait));
1147 // Default unit choice is cm if metric, inches if US paper.
1148 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1149 || paperchoice == 2 || paperchoice > 5;
1150 string const default_unit = metric ? "cm" : "in";
1151 updateWidgetsFromLengthString(paper_->input_custom_width,
1152 paper_->choice_custom_width_units,
1153 params.paperwidth, default_unit);
1154 setEnabled(paper_->input_custom_width, useCustom);
1155 setEnabled(paper_->choice_custom_width_units, useCustom);
1157 updateWidgetsFromLengthString(paper_->input_custom_height,
1158 paper_->choice_custom_height_units,
1159 params.paperheight, default_unit);
1160 setEnabled(paper_->input_custom_height, useCustom);
1161 setEnabled(paper_->choice_custom_height_units, useCustom);
1163 updateWidgetsFromLengthString(paper_->input_inner_margin,
1164 paper_->choice_inner_margin_units,
1165 params.leftmargin, default_unit);
1166 setEnabled(paper_->input_inner_margin, useGeom);
1167 setEnabled(paper_->choice_inner_margin_units, useGeom);
1169 updateWidgetsFromLengthString(paper_->input_top_margin,
1170 paper_->choice_top_margin_units,
1171 params.topmargin, default_unit);
1172 setEnabled(paper_->input_top_margin, useGeom);
1173 setEnabled(paper_->choice_top_margin_units, useGeom);
1175 updateWidgetsFromLengthString(paper_->input_outer_margin,
1176 paper_->choice_outer_margin_units,
1177 params.rightmargin, default_unit);
1178 setEnabled(paper_->input_outer_margin, useGeom);
1179 setEnabled(paper_->choice_outer_margin_units, useGeom);
1181 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1182 paper_->choice_bottom_margin_units,
1183 params.bottommargin, default_unit);
1184 setEnabled(paper_->input_bottom_margin, useGeom);
1185 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1187 updateWidgetsFromLengthString(paper_->input_head_height,
1188 paper_->choice_head_height_units,
1189 params.headheight, default_unit);
1190 setEnabled(paper_->input_head_height, useGeom);
1191 setEnabled(paper_->choice_head_height_units, useGeom);
1193 updateWidgetsFromLengthString(paper_->input_head_sep,
1194 paper_->choice_head_sep_units,
1195 params.headsep, default_unit);
1196 setEnabled(paper_->input_head_sep, useGeom);
1197 setEnabled(paper_->choice_head_sep_units, useGeom);
1199 updateWidgetsFromLengthString(paper_->input_foot_skip,
1200 paper_->choice_foot_skip_units,
1201 params.footskip, default_unit);
1202 setEnabled(paper_->input_foot_skip, useGeom);
1203 setEnabled(paper_->choice_foot_skip_units, useGeom);
1205 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1209 void FormDocument::bullets_update(BufferParams const & params)
1211 if (!bullets_.get() ||
1213 (XpmVersion==4 && XpmRevision<7)))
1216 bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
1217 setEnabled(fbullet, !isLinuxDoc);
1219 if (isLinuxDoc) return;
1221 fl_set_button(bullets_->radio_bullet_depth_1, 1);
1222 fl_set_input(bullets_->input_bullet_latex,
1223 params.user_defined_bullets[0].getText().c_str());
1224 fl_set_choice(bullets_->choice_bullet_size,
1225 params.user_defined_bullets[0].getSize() + 2);
1229 void FormDocument::checkReadOnly()
1231 if (bc().readOnly(lv_->buffer()->isReadonly())) {
1232 combo_doc_class->deactivate();
1233 combo_language->deactivate();
1234 postWarning(_("Document is read-only."
1235 " No changes to layout permitted."));
1237 combo_doc_class->activate();
1238 combo_language->activate();
1244 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
1250 // this has to be all out of if/elseif because it has to deactivate
1251 // the document buttons and so the whole stuff has to be tested again.
1252 // disable OK/Apply if input is not valid
1253 str = fl_get_input(class_->input_doc_skip);
1254 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1255 str = fl_get_input(paper_->input_custom_width);
1256 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1257 str = fl_get_input(paper_->input_custom_height);
1258 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1259 str = fl_get_input(paper_->input_outer_margin);
1260 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1261 str = fl_get_input(paper_->input_inner_margin);
1262 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1263 str = fl_get_input(paper_->input_top_margin);
1264 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1265 str = fl_get_input(paper_->input_bottom_margin);
1266 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1267 str = fl_get_input(paper_->input_head_height);
1268 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1269 str = fl_get_input(paper_->input_head_sep);
1270 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1271 str = fl_get_input(paper_->input_foot_skip);
1272 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1274 //display warning if input is not valid
1275 if (ob == class_->input_doc_skip
1276 || ob == paper_->input_custom_width
1277 || ob == paper_->input_custom_height
1278 || ob == paper_->input_outer_margin
1279 || ob == paper_->input_inner_margin
1280 || ob == paper_->input_top_margin
1281 || ob == paper_->input_bottom_margin
1282 || ob == paper_->input_head_height
1283 || ob == paper_->input_head_sep
1284 || ob == paper_->input_foot_skip) {
1286 postWarning(_("Invalid Length (valid example: 10mm)"));
1294 // "Synchronize" the choice and the input field, so that it
1295 // is impossible to commit senseless data.
1296 input = fl_get_input (class_->input_doc_skip);
1297 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1299 else if (fl_get_choice(class_->choice_doc_skip) != 4)
1300 fl_set_input (class_->input_doc_skip, "");
1302 input = fl_get_input(class_->input_doc_spacing);
1303 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1305 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
1306 fl_set_input (class_->input_doc_spacing, "");
1311 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1313 BufferParams & param = lv_->buffer()->params;
1315 // convert from 1-6 range to -1-4
1316 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1317 fl_set_input(bullets_->input_bullet_latex,
1318 param.temp_bullets[current_bullet_depth].getText().c_str());
1322 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1324 BufferParams & param = lv_->buffer()->params;
1326 param.temp_bullets[current_bullet_depth].
1327 setText(fl_get_input(bullets_->input_bullet_latex));
1331 void FormDocument::BulletDepth(FL_OBJECT * ob)
1333 /* Should I do the following: */
1334 /* 1. change to the panel that the current bullet belongs in */
1335 /* 2. show that bullet as selected */
1336 /* 3. change the size setting to the size of the bullet in Q.*/
1337 /* 4. display the latex equivalent in the latex box */
1339 /* I'm inclined to just go with 3 and 4 at the moment and */
1340 /* maybe try to support the others later */
1341 BufferParams & param = lv_->buffer()->params;
1344 if (ob == bullets_->radio_bullet_depth_1)
1346 else if (ob == bullets_->radio_bullet_depth_2)
1348 else if (ob == bullets_->radio_bullet_depth_3)
1350 else if (ob == bullets_->radio_bullet_depth_4)
1353 switch (fl_get_button_numb(ob)) {
1355 // right mouse button resets to default
1356 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1358 current_bullet_depth = data;
1359 fl_set_input(bullets_->input_bullet_latex,
1360 param.temp_bullets[data].getText().c_str());
1361 fl_set_choice(bullets_->choice_bullet_size,
1362 param.temp_bullets[data].getSize() + 2);
1367 void FormDocument::BulletPanel(FL_OBJECT * ob)
1369 /* Here we have to change the background pixmap to that selected */
1370 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1373 if (ob == bullets_->radio_bullet_panel_standard)
1375 else if (ob == bullets_->radio_bullet_panel_maths)
1377 else if (ob == bullets_->radio_bullet_panel_ding2)
1379 else if (ob == bullets_->radio_bullet_panel_ding3)
1381 else if (ob == bullets_->radio_bullet_panel_ding4)
1383 else if (ob == bullets_->radio_bullet_panel_ding1)
1386 if (data != current_bullet_panel) {
1387 fl_freeze_form(bullets_->form);
1388 current_bullet_panel = data;
1390 /* free the current pixmap */
1391 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1393 if (ob == bullets_->radio_bullet_panel_standard) {
1394 new_panel = "standard";
1395 } else if (ob == bullets_->radio_bullet_panel_maths ) {
1396 new_panel = "amssymb";
1397 } else if (ob == bullets_->radio_bullet_panel_ding2) {
1398 new_panel = "psnfss1";
1399 } else if (ob == bullets_->radio_bullet_panel_ding3) {
1400 new_panel = "psnfss2";
1401 } else if (ob == bullets_->radio_bullet_panel_ding4) {
1402 new_panel = "psnfss3";
1403 } else if (ob == bullets_->radio_bullet_panel_ding1) {
1404 new_panel = "psnfss4";
1406 /* something very wrong happened */
1407 // play it safe for now but should be an exception
1408 current_bullet_panel = 0; // standard panel
1409 new_panel = "standard";
1411 new_panel += ".xpm";
1412 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1413 LibFileSearch("images", new_panel).c_str());
1414 fl_redraw_object(bullets_->bmtable_bullet_panel);
1415 fl_unfreeze_form(bullets_->form);
1420 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1422 /* handle the user input by setting the current bullet depth's pixmap */
1423 /* to that extracted from the current chosen position of the BMTable */
1424 /* Don't forget to free the button's old pixmap first. */
1426 BufferParams & param = lv_->buffer()->params;
1427 int bmtable_button = fl_get_bmtable(ob);
1429 /* try to keep the button held down till another is pushed */
1430 /* fl_set_bmtable(ob, 1, bmtable_button); */
1431 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1432 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1433 fl_set_input(bullets_->input_bullet_latex,
1434 param.temp_bullets[current_bullet_depth].getText().c_str());
1438 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1441 ob = class_->choice_doc_class;
1443 lv_->prohibitInput();
1445 unsigned int tc = combo_doc_class->get() - 1;
1446 if (textclasslist[tc].load()) {
1447 // we use a copy of the bufferparams because we do not
1448 // want to modify them yet.
1449 BufferParams params = lv_->buffer()->params;
1451 if (lyxrc.auto_reset_options) {
1452 params.textclass = tc;
1453 params.useClassDefaults();
1454 UpdateLayoutDocument(params);
1456 // update the params which are needed in any case
1457 // (fontsizes, pagestyle)
1458 params.textclass = tc;
1459 UpdateClassParams(params);
1463 // unable to load new style
1464 Alert::alert(_("Conversion Errors!"),
1465 _("Unable to switch to new document class."),
1466 _("Reverting to original document class."));
1467 combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
1473 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1479 class_update(params);
1480 paper_update(params);
1481 language_update(params);
1482 options_update(params);
1483 bullets_update(params);