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 "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 <boost/bind.hpp>
55 using Liason::setMinibuffer;
58 FormDocument::FormDocument(LyXView * lv, Dialogs * d)
59 : FormBaseBD(lv, d, _("Document Layout")),
60 ActCell(0), Confirmed(0),
61 current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
63 // let the dialog be shown
64 // This is a permanent connection so we won't bother
65 // storing a copy because we won't be disconnecting.
66 d->showDocument = boost::bind(&FormDocument::show, this);
70 void FormDocument::redraw()
72 if (form() && form()->visible)
73 fl_redraw_form(form());
77 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
78 if (outer_form && outer_form->visible)
79 fl_redraw_form(outer_form);
83 FL_FORM * FormDocument::form() const
85 if (dialog_.get()) return dialog_->form;
90 void FormDocument::build()
95 dialog_.reset(build_tabbed_document());
97 // Allow the base class to control messages
98 setMessageWidget(dialog_->text_warning);
100 // Manage the restore, ok, apply, restore and cancel/close buttons
101 bc().setOK(dialog_->button_ok);
102 bc().setApply(dialog_->button_apply);
103 bc().setCancel(dialog_->button_close);
104 bc().setRestore(dialog_->button_restore);
105 bc().addReadOnly (dialog_->button_save_defaults);
106 bc().addReadOnly (dialog_->button_reset_defaults);
108 // the document paper form
109 paper_.reset(build_doc_paper());
110 fl_addto_choice(paper_->choice_papersize,
111 _(" Default | Custom | US letter | US legal "
112 "| US executive | A3 | A4 | A5 | B3 | B4 | B5 "));
113 fl_addto_choice(paper_->choice_paperpackage,
116 "| Very small Margins "
117 "| Very wide Margins "));
119 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
120 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
121 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
122 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
123 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
124 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
125 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
126 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
127 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
129 setPrehandler(paper_->input_custom_width);
130 setPrehandler(paper_->input_custom_height);
131 setPrehandler(paper_->input_top_margin);
132 setPrehandler(paper_->input_bottom_margin);
133 setPrehandler(paper_->input_inner_margin);
134 setPrehandler(paper_->input_outer_margin);
135 setPrehandler(paper_->input_head_height);
136 setPrehandler(paper_->input_head_sep);
137 setPrehandler(paper_->input_foot_skip);
139 // Create the contents of the unit choices
140 // Don't include the "%" terms...
141 vector<string> units_vec = getLatexUnits();
143 for (vector<string>::iterator it = units_vec.begin();
144 it != units_vec.end(); ++it) {
145 if (contains(*it, "%"))
146 it = units_vec.erase(it, it+1) - 1;
149 vector<string>::iterator ret =
150 std::remove_if(units_vec.begin(),
152 bind2nd(contains_functor(), "%"));
153 units_vec.erase(ret, units_vec.end());
155 string units = getStringFromVector(units_vec, "|");
157 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
158 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
159 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
160 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
161 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
162 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
163 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
164 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
165 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
167 bc().addReadOnly (paper_->choice_paperpackage);
168 bc().addReadOnly (paper_->radio_portrait);
169 bc().addReadOnly (paper_->radio_landscape);
170 bc().addReadOnly (paper_->choice_papersize);
171 bc().addReadOnly (paper_->check_use_geometry);
172 bc().addReadOnly (paper_->input_custom_width);
173 bc().addReadOnly (paper_->input_custom_height);
174 bc().addReadOnly (paper_->input_top_margin);
175 bc().addReadOnly (paper_->input_bottom_margin);
176 bc().addReadOnly (paper_->input_inner_margin);
177 bc().addReadOnly (paper_->input_outer_margin);
178 bc().addReadOnly (paper_->input_head_height);
179 bc().addReadOnly (paper_->input_head_sep);
180 bc().addReadOnly (paper_->input_foot_skip);
182 // the document class form
183 class_.reset(build_doc_class());
186 // The language is a combo-box and has to be inserted manually
187 obj = class_->choice_doc_class;
188 fl_deactivate_object(obj);
189 fl_addto_form(class_->form);
190 combo_doc_class.reset(new Combox(FL_COMBOX_DROPLIST));
191 combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400,
193 combo_doc_class->shortcut("#C",1);
194 combo_doc_class->setcallback(ComboInputCB, this);
196 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
197 cit != textclasslist.end(); ++cit) {
198 combo_doc_class->addto(cit->description());
201 fl_addto_choice(class_->choice_doc_spacing,
202 _(" Single | OneHalf | Double | Custom "));
203 fl_addto_choice(class_->choice_doc_fontsize, "default|10|11|12");
204 for (n=0; tex_fonts[n][0]; ++n) {
205 fl_addto_choice(class_->choice_doc_fonts,tex_fonts[n]);
207 fl_addto_choice(class_->choice_doc_pagestyle,
208 "default|empty|plain|headings|fancy");
209 fl_addto_choice(class_->choice_doc_skip,
210 _(" Smallskip | Medskip | Bigskip | Length "));
211 fl_addto_choice(class_->choice_default_skip_units, units.c_str());
212 fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
213 fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
214 fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
216 setPrehandler(class_->input_doc_extra);
217 setPrehandler(class_->input_doc_skip);
218 setPrehandler(class_->input_doc_spacing);
220 // Set input filters on doc spacing to make it accept only
222 fl_set_input_filter(class_->input_doc_spacing, fl_unsigned_float_filter);
224 bc().addReadOnly (class_->radio_doc_indent);
225 bc().addReadOnly (class_->radio_doc_skip);
227 bc().addReadOnly (class_->choice_doc_pagestyle);
228 bc().addReadOnly (class_->choice_doc_fonts);
229 bc().addReadOnly (class_->choice_doc_fontsize);
230 bc().addReadOnly (class_->radio_doc_sides_one);
231 bc().addReadOnly (class_->radio_doc_sides_two);
232 bc().addReadOnly (class_->radio_doc_columns_one);
233 bc().addReadOnly (class_->radio_doc_columns_two);
234 bc().addReadOnly (class_->input_doc_extra);
235 bc().addReadOnly (class_->input_doc_skip);
236 bc().addReadOnly (class_->choice_doc_skip);
237 bc().addReadOnly (class_->choice_doc_spacing);
238 bc().addReadOnly (class_->input_doc_spacing);
240 // the document language form
241 language_.reset(build_doc_language());
242 fl_addto_choice(language_->choice_inputenc,
243 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
244 "|koi8-r|koi8-u|cp866|cp1251|iso88595");
246 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
247 // Store the identifiers for later
248 lang_ = getSecond(langs);
250 // The language is a combo-box and has to be inserted manually
251 obj = language_->choice_language;
252 fl_deactivate_object(obj);
253 fl_addto_form(language_->form);
254 combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
255 combo_language->add(obj->x, obj->y, obj->w, obj->h, 400,
257 combo_language->shortcut("#L",1);
258 combo_language->setcallback(ComboInputCB, this);
261 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
262 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
263 for (; lit != lend; ++lit) {
264 combo_language->addto(lit->first);
266 combo_language->select(1);
268 fl_addto_choice(language_->choice_quotes_language,
269 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
270 " «text» | »text« "));
272 bc().addReadOnly (language_->choice_inputenc);
273 bc().addReadOnly (language_->choice_quotes_language);
274 bc().addReadOnly (language_->radio_single);
275 bc().addReadOnly (language_->radio_double);
277 // the document options form
278 options_.reset(build_doc_options());
279 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
280 setPrehandler(options_->input_float_placement);
282 fl_set_counter_bounds(options_->counter_secnumdepth,-2,5);
283 fl_set_counter_bounds(options_->counter_tocdepth,-1,5);
284 fl_set_counter_step(options_->counter_secnumdepth,1,1);
285 fl_set_counter_step(options_->counter_tocdepth,1,1);
286 fl_set_counter_precision(options_->counter_secnumdepth, 0);
287 fl_set_counter_precision(options_->counter_tocdepth, 0);
288 for (n=0; tex_graphics[n][0]; ++n) {
289 fl_addto_choice(options_->choice_postscript_driver,
292 fl_addto_choice(options_->choice_citation_format,
293 _(" Author-year | Numerical "));
295 bc_.addReadOnly (options_->counter_secnumdepth);
296 bc_.addReadOnly (options_->counter_tocdepth);
297 bc_.addReadOnly (options_->check_use_amsmath);
298 bc_.addReadOnly (options_->check_use_natbib);
299 bc_.addReadOnly (options_->choice_citation_format);
300 bc_.addReadOnly (options_->input_float_placement);
301 bc_.addReadOnly (options_->choice_postscript_driver);
303 // the document bullets form
304 bullets_.reset(build_doc_bullet());
305 fl_addto_choice(bullets_->choice_bullet_size,
306 _(" default | tiny | script | footnote | small |"
307 " normal | large | Large | LARGE | huge | Huge"));
308 fl_set_choice(bullets_->choice_bullet_size, 1);
309 fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
310 setPrehandler(bullets_->input_bullet_latex);
311 fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
313 bc_.addReadOnly(bullets_->radio_bullet_depth_1);
314 bc_.addReadOnly(bullets_->radio_bullet_depth_2);
315 bc_.addReadOnly(bullets_->radio_bullet_depth_3);
316 bc_.addReadOnly(bullets_->radio_bullet_depth_4);
317 bc_.addReadOnly(bullets_->radio_bullet_panel_standard);
318 bc_.addReadOnly(bullets_->radio_bullet_panel_maths);
319 bc_.addReadOnly(bullets_->radio_bullet_panel_ding1);
320 bc_.addReadOnly(bullets_->radio_bullet_panel_ding2);
321 bc_.addReadOnly(bullets_->radio_bullet_panel_ding3);
322 bc_.addReadOnly(bullets_->radio_bullet_panel_ding4);
324 bc().addReadOnly (bullets_->bmtable_bullet_panel);
325 bc().addReadOnly (bullets_->choice_bullet_size);
326 bc().addReadOnly (bullets_->input_bullet_latex);
328 fl_addto_tabfolder(dialog_->tabfolder,_("Document"),
330 fl_addto_tabfolder(dialog_->tabfolder,_("Paper"),
332 fl_addto_tabfolder(dialog_->tabfolder,_("Language"),
334 fl_addto_tabfolder(dialog_->tabfolder,_("Extra"),
336 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets"),
338 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
339 lyxerr << _("Your version of libXpm is older than 4.7.\n"
340 "The `bullet' tab of the document dialog "
341 "has been disabled") << '\n';
342 fl_deactivate_object(fbullet);
343 fl_set_object_lcol(fbullet, FL_INACTIVE);
348 void FormDocument::apply()
350 if (!lv_->view()->available() || !dialog_.get())
353 bool redo = class_apply();
355 redo = language_apply() || redo;
356 redo = options_apply() || redo;
360 lv_->view()->redoCurrentBuffer();
362 lv_->buffer()->markDirty();
363 setMinibuffer(lv_, _("Document layout set"));
367 void FormDocument::cancel()
369 // this avoids confusion when reopening
370 BufferParams & param = lv_->buffer()->params;
371 param.temp_bullets[0] = param.user_defined_bullets[0];
372 param.temp_bullets[1] = param.user_defined_bullets[1];
373 param.temp_bullets[2] = param.user_defined_bullets[2];
374 param.temp_bullets[3] = param.user_defined_bullets[3];
379 void FormDocument::update()
386 BufferParams const & params = lv_->buffer()->params;
388 class_update(params);
389 paper_update(params);
390 language_update(params);
391 options_update(params);
392 bullets_update(params);
397 // should this go elsewhere? Maybe a ControllerDocument? (JMarc)
398 /** Save the buffer's parameters as user default.
399 This function saves a file \c user_lyxdir/templates/defaults.lyx
400 which parameters are those of the current buffer. This file
401 is used as a default template when creating a new
402 file. Returns \c true on success.
404 bool saveParamsAsDefault(BufferParams const ¶ms)
406 if (!Alert::askQuestion(_("Do you want to save the current settings"),
407 _("for the document layout as default?"),
408 _("(they will be valid for any new document)")))
411 string const fname = AddName(AddPath(user_lyxdir, "templates/"),
413 Buffer defaults = Buffer(fname);
414 defaults.params = params;
416 // add an empty paragraph. Is this enough?
417 defaults.paragraph = new Paragraph;
419 return defaults.writeFile(defaults.fileName(), false);
425 bool FormDocument::input(FL_OBJECT * ob, long data)
427 State cb = static_cast<State>(data);
430 case CHECKCHOICECLASS:
431 CheckChoiceClass(ob, 0);
433 case CHOICEBULLETSIZE:
434 ChoiceBulletSize(ob, 0);
436 case INPUTBULLETLATEX:
437 InputBulletLaTeX(ob, 0);
454 BulletBMTable(ob, 0);
460 bool const length_input = fl_get_choice(class_->choice_doc_skip) == 4;
461 if (ob == class_->choice_doc_skip) {
462 setEnabled(class_->input_doc_skip, length_input);
463 setEnabled(class_->choice_default_skip_units, length_input);
466 if (ob == class_->choice_doc_spacing)
467 setEnabled(class_->input_doc_spacing,
468 fl_get_choice(class_->choice_doc_spacing) == 4);
470 bool const skip_used = fl_get_button(class_->radio_doc_skip);
471 if (ob == class_->radio_doc_skip ||
472 ob == class_->radio_doc_indent) {
473 setEnabled(class_->choice_doc_skip, skip_used);
474 setEnabled(class_->input_doc_skip,
475 skip_used && length_input);
476 setEnabled(class_->choice_default_skip_units,
477 skip_used && length_input);
478 // Default unit choice is cm if metric, inches if US paper.
479 // If papersize is default, check the lyxrc-settings
480 int const paperchoice = fl_get_choice(paper_->choice_papersize);
481 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
482 || paperchoice == 2 || paperchoice > 5;
483 int const default_unit = metric ? 8 : 9;
484 if (strip(fl_get_input(class_->input_doc_skip)).empty())
485 fl_set_choice(class_->choice_default_skip_units,
489 if (ob == options_->check_use_natbib) {
490 setEnabled(options_->choice_citation_format,
491 fl_get_button(options_->check_use_natbib));
494 if (ob == dialog_->button_save_defaults) {
498 language_apply(params);
499 options_apply(params);
500 bullets_apply(params);
501 params.preamble = lv_->buffer()->params.preamble;
502 saveParamsAsDefault(params);
505 if (ob == dialog_->button_reset_defaults) {
506 BufferParams params = lv_->buffer()->params;
507 params.textclass = combo_doc_class->get() - 1;
508 params.useClassDefaults();
509 UpdateLayoutDocument(params);
512 if (ob == paper_->radio_landscape)
513 fl_set_choice(paper_->choice_paperpackage,
514 BufferParams::PACKAGE_NONE + 1);
516 if (ob == paper_->choice_papersize) {
517 int const paperchoice = fl_get_choice(paper_->choice_papersize);
518 bool const defsize = paperchoice == 1;
519 bool const custom = paperchoice == 2;
520 bool const a3size = paperchoice == 6;
521 bool const b3size = paperchoice == 9;
522 bool const b4size = paperchoice == 10;
525 fl_set_button(paper_->radio_portrait, 1);
527 bool const use_geom = (custom || a3size || b3size || b4size);
529 fl_set_button(paper_->check_use_geometry, int(use_geom));
531 setEnabled(paper_->input_top_margin, use_geom);
532 setEnabled(paper_->input_bottom_margin, use_geom);
533 setEnabled(paper_->input_inner_margin, use_geom);
534 setEnabled(paper_->input_outer_margin, use_geom);
535 setEnabled(paper_->input_head_height, use_geom);
536 setEnabled(paper_->input_head_sep, use_geom);
537 setEnabled(paper_->input_foot_skip, use_geom);
538 setEnabled(paper_->choice_top_margin_units, use_geom);
539 setEnabled(paper_->choice_bottom_margin_units, use_geom);
540 setEnabled(paper_->choice_inner_margin_units, use_geom);
541 setEnabled(paper_->choice_outer_margin_units, use_geom);
542 setEnabled(paper_->choice_head_height_units, use_geom);
543 setEnabled(paper_->choice_head_sep_units, use_geom);
544 setEnabled(paper_->choice_foot_skip_units, use_geom);
545 setEnabled(paper_->choice_custom_width_units, use_geom);
546 setEnabled(paper_->choice_custom_height_units, use_geom);
548 setEnabled(paper_->input_custom_width, custom);
549 setEnabled(paper_->input_custom_height, custom);
550 setEnabled(paper_->choice_custom_width_units, custom);
551 setEnabled(paper_->choice_custom_height_units, custom);
552 setEnabled(paper_->radio_portrait, !custom);
553 setEnabled(paper_->radio_landscape, !custom);
555 // Default unit choice is cm if metric, inches if US paper.
556 // If papersize is default, use the lyxrc-settings
557 bool const metric = (defsize && lyxrc.default_papersize > 3)
558 || paperchoice == 2 || paperchoice > 5;
559 int const default_unit = metric ? 8 : 9;
560 if (strip(fl_get_input(paper_->input_custom_width)).empty())
561 fl_set_choice(paper_->choice_custom_width_units,
563 if (strip(fl_get_input(paper_->input_custom_height)).empty())
564 fl_set_choice(paper_->choice_custom_height_units,
566 if (strip(fl_get_input(paper_->input_top_margin)).empty())
567 fl_set_choice(paper_->choice_top_margin_units,
569 if (strip(fl_get_input(paper_->input_bottom_margin)).empty())
570 fl_set_choice(paper_->choice_bottom_margin_units,
572 if (strip(fl_get_input(paper_->input_inner_margin)).empty())
573 fl_set_choice(paper_->choice_inner_margin_units,
575 if (strip(fl_get_input(paper_->input_outer_margin)).empty())
576 fl_set_choice(paper_->choice_outer_margin_units,
578 if (strip(fl_get_input(paper_->input_head_height)).empty())
579 fl_set_choice(paper_->choice_head_height_units,
581 if (strip(fl_get_input(paper_->input_head_sep)).empty())
582 fl_set_choice(paper_->choice_head_sep_units,
584 if (strip(fl_get_input(paper_->input_foot_skip)).empty())
585 fl_set_choice(paper_->choice_foot_skip_units,
589 if (ob == paper_->choice_papersize ||
590 ob == paper_->radio_portrait ||
591 ob == paper_->radio_landscape) {
593 setEnabled(paper_->choice_paperpackage,
594 //either default papersize (preferences)
595 //or document papersize has to be A4
596 (fl_get_choice(paper_->choice_papersize) == 7
597 || fl_get_choice(paper_->choice_papersize) == 1
598 && lyxrc.default_papersize == 5)
599 && fl_get_button(paper_->radio_portrait));
602 if (ob == paper_->choice_paperpackage) {
603 if (fl_get_choice(paper_->choice_paperpackage) != 1) {
604 fl_set_button(paper_->check_use_geometry, 0);
606 setEnabled(paper_->input_top_margin, false);
607 setEnabled(paper_->input_bottom_margin, false);
608 setEnabled(paper_->input_inner_margin, false);
609 setEnabled(paper_->input_outer_margin, false);
610 setEnabled(paper_->input_head_height, false);
611 setEnabled(paper_->input_head_sep, false);
612 setEnabled(paper_->input_foot_skip, false);
613 setEnabled(paper_->choice_top_margin_units, false);
614 setEnabled(paper_->choice_bottom_margin_units, false);
615 setEnabled(paper_->choice_inner_margin_units, false);
616 setEnabled(paper_->choice_outer_margin_units, false);
617 setEnabled(paper_->choice_head_height_units, false);
618 setEnabled(paper_->choice_head_sep_units, false);
619 setEnabled(paper_->choice_foot_skip_units, false);
623 if (ob == paper_->check_use_geometry) {
624 //don't allow switching geometry off in custom papersize mode
625 //nor in A3, B3, and B4
626 int const choice = fl_get_choice(paper_->choice_papersize);
627 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
628 fl_set_button(paper_->check_use_geometry, 1);
630 fl_set_choice(paper_->choice_paperpackage,
631 BufferParams::PACKAGE_NONE + 1);
633 bool const use_geom = fl_get_button(paper_->check_use_geometry);
634 setEnabled(paper_->input_top_margin, use_geom);
635 setEnabled(paper_->input_bottom_margin, use_geom);
636 setEnabled(paper_->input_inner_margin, use_geom);
637 setEnabled(paper_->input_outer_margin, use_geom);
638 setEnabled(paper_->input_head_height, use_geom);
639 setEnabled(paper_->input_head_sep, use_geom);
640 setEnabled(paper_->input_foot_skip, use_geom);
641 setEnabled(paper_->choice_top_margin_units, use_geom);
642 setEnabled(paper_->choice_bottom_margin_units, use_geom);
643 setEnabled(paper_->choice_inner_margin_units, use_geom);
644 setEnabled(paper_->choice_outer_margin_units, use_geom);
645 setEnabled(paper_->choice_head_height_units, use_geom);
646 setEnabled(paper_->choice_head_sep_units, use_geom);
647 setEnabled(paper_->choice_foot_skip_units, use_geom);
652 case CHECKCHOICECLASS:
653 case CHOICEBULLETSIZE:
654 case INPUTBULLETLATEX:
656 return CheckDocumentInput(ob, 0);
665 void FormDocument::ComboInputCB(int, void * v, Combox * combox)
667 FormDocument * pre = static_cast<FormDocument*>(v);
668 if (combox == pre->combo_doc_class.get())
669 pre->CheckChoiceClass(0, 0);
670 pre->bc().valid(pre->CheckDocumentInput(0,0));
674 bool FormDocument::class_apply(BufferParams ¶ms)
678 // If default skip is a "Length" but there's no text in the
679 // input field, reset the kind to "Medskip", which is the default.
680 if ((fl_get_choice (class_->choice_doc_skip) == 4) &&
681 !*(fl_get_input (class_->input_doc_skip))) {
682 fl_set_choice (class_->choice_doc_skip, 2);
684 params.fonts = fl_get_choice_text(class_->choice_doc_fonts);
685 params.fontsize = fl_get_choice_text(class_->choice_doc_fontsize);
686 params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
688 params.textclass = combo_doc_class->get() - 1;
690 BufferParams::PARSEP tmpsep = params.paragraph_separation;
691 if (fl_get_button(class_->radio_doc_indent))
692 params.paragraph_separation = BufferParams::PARSEP_INDENT;
694 params.paragraph_separation = BufferParams::PARSEP_SKIP;
695 if (tmpsep != params.paragraph_separation)
698 VSpace tmpdefskip = params.getDefSkip();
699 switch (fl_get_choice (class_->choice_doc_skip)) {
701 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
704 params.setDefSkip(VSpace(VSpace::MEDSKIP));
707 params.setDefSkip(VSpace(VSpace::BIGSKIP));
711 string const length =
712 getLengthFromWidgets(class_->input_doc_skip,
713 class_->choice_default_skip_units);
715 params.setDefSkip(VSpace(LyXGlueLength(length)));
719 // DocumentDefskipCB assures that this never happens
720 params.setDefSkip(VSpace(VSpace::MEDSKIP));
723 if (!(tmpdefskip == params.getDefSkip()))
726 if (fl_get_button(class_->radio_doc_columns_two))
730 if (fl_get_button(class_->radio_doc_sides_two))
731 params.sides = LyXTextClass::TwoSides;
733 params.sides = LyXTextClass::OneSide;
735 Spacing tmpSpacing = params.spacing;
736 switch (fl_get_choice(class_->choice_doc_spacing)) {
738 lyxerr[Debug::INFO] << "Spacing: SINGLE\n";
739 params.spacing.set(Spacing::Single);
742 lyxerr[Debug::INFO] << "Spacing: ONEHALF\n";
743 params.spacing.set(Spacing::Onehalf);
746 lyxerr[Debug::INFO] << "Spacing: DOUBLE\n";
747 params.spacing.set(Spacing::Double);
750 lyxerr[Debug::INFO] << "Spacing: OTHER\n";
751 params.spacing.set(Spacing::Other,
752 fl_get_input(class_->input_doc_spacing));
755 if (tmpSpacing != params.spacing)
758 params.options = fl_get_input(class_->input_doc_extra);
764 bool FormDocument::class_apply()
766 BufferParams ¶ms = lv_->buffer()->params;
768 unsigned int const old_class = params.textclass;
770 bool redo = class_apply(params);
772 if (params.textclass != old_class) {
773 // try to load new_class
774 if (textclasslist[params.textclass].load()) {
775 // successfully loaded
777 setMinibuffer(lv_, _("Converting document to new document class..."));
778 int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
779 old_class, params.textclass,
780 lv_->buffer()->paragraph,
781 lv_->buffer()->params);
785 s = _("One paragraph couldn't be converted");
788 s += _(" paragraphs couldn't be converted");
790 Alert::alert(_("Conversion Errors!"),s,
791 _("into chosen document class"));
795 // problem changing class -- warn user and retain old style
796 Alert::alert(_("Conversion Errors!"),
797 _("Errors loading new document class."),
798 _("Reverting to original document class."));
799 combo_doc_class->select(int(old_class) + 1);
807 void FormDocument::paper_apply(BufferParams & params)
809 params.papersize2 = char(fl_get_choice(paper_->choice_papersize)-1);
811 params.paperpackage =
812 char(fl_get_choice(paper_->choice_paperpackage)-1);
814 // set params.papersize from params.papersize2 and params.paperpackage
815 params.setPaperStuff();
817 params.use_geometry = fl_get_button(paper_->check_use_geometry);
819 if (fl_get_button(paper_->radio_landscape))
820 params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
822 params.orientation = BufferParams::ORIENTATION_PORTRAIT;
825 getLengthFromWidgets(paper_->input_custom_width,
826 paper_->choice_custom_width_units);
829 getLengthFromWidgets(paper_->input_custom_height,
830 paper_->choice_custom_height_units);
833 getLengthFromWidgets(paper_->input_inner_margin,
834 paper_->choice_inner_margin_units);
837 getLengthFromWidgets(paper_->input_top_margin,
838 paper_->choice_top_margin_units);
841 getLengthFromWidgets(paper_->input_outer_margin,
842 paper_->choice_outer_margin_units);
844 params.bottommargin =
845 getLengthFromWidgets(paper_->input_bottom_margin,
846 paper_->choice_bottom_margin_units);
849 getLengthFromWidgets(paper_->input_head_height,
850 paper_->choice_head_height_units);
853 getLengthFromWidgets(paper_->input_head_sep,
854 paper_->choice_head_sep_units);
857 getLengthFromWidgets(paper_->input_foot_skip,
858 paper_->choice_foot_skip_units);
862 void FormDocument::paper_apply()
864 paper_apply(lv_->buffer()->params);
868 bool FormDocument::language_apply(BufferParams & params)
870 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
873 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
875 lga = InsetQuotes::EnglishQ;
878 lga = InsetQuotes::SwedishQ;
881 lga = InsetQuotes::GermanQ;
884 lga = InsetQuotes::PolishQ;
887 lga = InsetQuotes::FrenchQ;
890 lga = InsetQuotes::DanishQ;
893 params.quotes_language = lga;
894 if (fl_get_button(language_->radio_single))
895 params.quotes_times = InsetQuotes::SingleQ;
897 params.quotes_times = InsetQuotes::DoubleQ;
899 int const pos = combo_language->get();
900 Language const * old_language = params.language;
901 Language const * new_language = languages.getLanguage(lang_[pos-1]);
903 new_language = default_language;
905 if (old_language != new_language
906 && old_language->RightToLeft() == new_language->RightToLeft()
907 && !lv_->buffer()->isMultiLingual())
908 lv_->buffer()->changeLanguage(old_language, new_language);
910 if (old_language != new_language) {
914 params.language = new_language;
915 params.inputenc = fl_get_choice_text(language_->choice_inputenc);
921 bool FormDocument::language_apply()
923 return language_apply(lv_->buffer()->params);
927 bool FormDocument::options_apply(BufferParams & params)
931 params.graphicsDriver =
932 fl_get_choice_text(options_->choice_postscript_driver);
933 params.use_amsmath = fl_get_button(options_->check_use_amsmath);
934 params.use_natbib = fl_get_button(options_->check_use_natbib);
935 params.use_numerical_citations =
936 fl_get_choice(options_->choice_citation_format)-1;
938 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
939 if (params.secnumdepth != tmpchar)
941 params.secnumdepth = tmpchar;
943 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
945 params.float_placement =
946 fl_get_input(options_->input_float_placement);
952 bool FormDocument::options_apply()
954 return options_apply(lv_->buffer()->params);
958 void FormDocument::bullets_apply(BufferParams & params)
960 /* update the bullet settings */
961 BufferParams & buf_params = lv_->buffer()->params;
963 // a little bit of loop unrolling
964 params.user_defined_bullets[0] = buf_params.temp_bullets[0];
965 params.user_defined_bullets[1] = buf_params.temp_bullets[1];
966 params.user_defined_bullets[2] = buf_params.temp_bullets[2];
967 params.user_defined_bullets[3] = buf_params.temp_bullets[3];
971 void FormDocument::bullets_apply()
973 bullets_apply(lv_->buffer()->params);
976 void FormDocument::UpdateClassParams(BufferParams const & params)
978 // These are the params that have to be updated on any class change
979 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
981 LyXTextClass const & tclass = textclasslist[params.textclass];
983 combo_doc_class->select(tclass.description());
984 fl_clear_choice(class_->choice_doc_fontsize);
985 fl_addto_choice(class_->choice_doc_fontsize, "default");
986 fl_addto_choice(class_->choice_doc_fontsize,
987 tclass.opt_fontsize().c_str());
988 fl_set_choice_text(class_->choice_doc_fontsize,
989 params.fontsize.c_str());
990 fl_clear_choice(class_->choice_doc_pagestyle);
991 fl_addto_choice(class_->choice_doc_pagestyle, "default");
992 fl_addto_choice(class_->choice_doc_pagestyle,
993 tclass.opt_pagestyle().c_str());
994 fl_set_choice_text(class_->choice_doc_pagestyle,
995 params.pagestyle.c_str());
999 void FormDocument::class_update(BufferParams const & params)
1004 UpdateClassParams(params);
1006 fl_set_choice_text(class_->choice_doc_fonts,
1007 params.fonts.c_str());
1008 fl_set_button(class_->radio_doc_indent, 0);
1009 fl_set_button(class_->radio_doc_skip, 0);
1010 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
1011 fl_set_button(class_->radio_doc_indent, 1);
1013 fl_set_button(class_->radio_doc_skip, 1);
1015 bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
1016 setEnabled(class_->choice_default_skip_units, input_length);
1017 setEnabled(class_->input_doc_skip, input_length);
1019 switch (params.getDefSkip().kind()) {
1020 case VSpace::SMALLSKIP:
1021 fl_set_choice (class_->choice_doc_skip, 1);
1023 case VSpace::MEDSKIP:
1024 fl_set_choice (class_->choice_doc_skip, 2);
1026 case VSpace::BIGSKIP:
1027 fl_set_choice (class_->choice_doc_skip, 3);
1029 case VSpace::LENGTH:
1031 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1032 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1033 || paperchoice == 2 || paperchoice > 5;
1034 string const default_unit = metric ? "cm" : "in";
1035 string const length = params.getDefSkip().asLyXCommand();
1036 updateWidgetsFromLengthString(class_->input_doc_skip,
1037 class_->choice_default_skip_units,
1038 length, default_unit);
1042 fl_set_choice (class_->choice_doc_skip, 2);
1045 fl_set_button(class_->radio_doc_sides_one, 0);
1046 fl_set_button(class_->radio_doc_sides_two, 0);
1047 setEnabled(class_->choice_doc_skip,
1048 fl_get_button(class_->radio_doc_skip));
1050 if (params.sides == LyXTextClass::TwoSides)
1051 fl_set_button(class_->radio_doc_sides_two, 1);
1053 fl_set_button(class_->radio_doc_sides_one, 1);
1054 fl_set_button(class_->radio_doc_columns_one, 0);
1055 fl_set_button(class_->radio_doc_columns_two, 0);
1056 if (params.columns == 2)
1057 fl_set_button(class_->radio_doc_columns_two, 1);
1059 fl_set_button(class_->radio_doc_columns_one, 1);
1061 fl_set_input(class_->input_doc_spacing, "");
1062 setEnabled(class_->input_doc_spacing, false);
1064 switch (params.spacing.getSpace()) {
1065 case Spacing::Default: // nothing bad should happen with this
1066 case Spacing::Single:
1068 fl_set_choice(class_->choice_doc_spacing, 1);
1070 case Spacing::Onehalf:
1072 fl_set_choice(class_->choice_doc_spacing, 2);
1074 case Spacing::Double:
1076 fl_set_choice(class_->choice_doc_spacing, 3);
1078 case Spacing::Other:
1080 fl_set_choice(class_->choice_doc_spacing, 4);
1082 sprintf(sval,"%g",params.spacing.getValue());
1083 fl_set_input(class_->input_doc_spacing, sval);
1084 setEnabled(class_->input_doc_spacing, true);
1088 if (!params.options.empty())
1089 fl_set_input(class_->input_doc_extra, params.options.c_str());
1091 fl_set_input(class_->input_doc_extra, "");
1095 void FormDocument::language_update(BufferParams const & params)
1097 if (!language_.get())
1100 int const pos = int(findPos(lang_, params.language->lang()));
1101 combo_language->select(pos+1);
1103 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1104 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1105 fl_set_button(language_->radio_single, 0);
1106 fl_set_button(language_->radio_double, 0);
1107 if (params.quotes_times == InsetQuotes::SingleQ)
1108 fl_set_button(language_->radio_single, 1);
1110 fl_set_button(language_->radio_double, 1);
1114 void FormDocument::options_update(BufferParams const & params)
1116 if (!options_.get())
1119 fl_set_choice_text(options_->choice_postscript_driver,
1120 params.graphicsDriver.c_str());
1121 fl_set_button(options_->check_use_amsmath, params.use_amsmath);
1122 fl_set_button(options_->check_use_natbib, params.use_natbib);
1123 fl_set_choice(options_->choice_citation_format,
1124 int(params.use_numerical_citations)+1);
1125 setEnabled(options_->choice_citation_format, params.use_natbib);
1126 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1127 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1128 if (!params.float_placement.empty())
1129 fl_set_input(options_->input_float_placement,
1130 params.float_placement.c_str());
1132 fl_set_input(options_->input_float_placement, "");
1136 void FormDocument::paper_update(BufferParams const & params)
1141 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1142 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1143 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1145 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1146 bool const useCustom = paperchoice == 2;
1147 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1149 fl_set_button(paper_->radio_portrait, 0);
1150 setEnabled(paper_->radio_portrait, !useCustom);
1151 fl_set_button(paper_->radio_landscape, 0);
1152 setEnabled(paper_->radio_landscape, !useCustom);
1154 if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
1155 fl_set_button(paper_->radio_landscape, 1);
1157 fl_set_button(paper_->radio_portrait, 1);
1158 setEnabled(paper_->choice_paperpackage,
1159 //either default papersize (preferences)
1160 //or document papersize has to be A4
1162 || paperchoice == 1 && lyxrc.default_papersize == 5)
1163 && fl_get_button(paper_->radio_portrait));
1165 // Default unit choice is cm if metric, inches if US paper.
1166 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > 3)
1167 || paperchoice == 2 || paperchoice > 5;
1168 string const default_unit = metric ? "cm" : "in";
1169 updateWidgetsFromLengthString(paper_->input_custom_width,
1170 paper_->choice_custom_width_units,
1171 params.paperwidth, default_unit);
1172 setEnabled(paper_->input_custom_width, useCustom);
1173 setEnabled(paper_->choice_custom_width_units, useCustom);
1175 updateWidgetsFromLengthString(paper_->input_custom_height,
1176 paper_->choice_custom_height_units,
1177 params.paperheight, default_unit);
1178 setEnabled(paper_->input_custom_height, useCustom);
1179 setEnabled(paper_->choice_custom_height_units, useCustom);
1181 updateWidgetsFromLengthString(paper_->input_inner_margin,
1182 paper_->choice_inner_margin_units,
1183 params.leftmargin, default_unit);
1184 setEnabled(paper_->input_inner_margin, useGeom);
1185 setEnabled(paper_->choice_inner_margin_units, useGeom);
1187 updateWidgetsFromLengthString(paper_->input_top_margin,
1188 paper_->choice_top_margin_units,
1189 params.topmargin, default_unit);
1190 setEnabled(paper_->input_top_margin, useGeom);
1191 setEnabled(paper_->choice_top_margin_units, useGeom);
1193 updateWidgetsFromLengthString(paper_->input_outer_margin,
1194 paper_->choice_outer_margin_units,
1195 params.rightmargin, default_unit);
1196 setEnabled(paper_->input_outer_margin, useGeom);
1197 setEnabled(paper_->choice_outer_margin_units, useGeom);
1199 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1200 paper_->choice_bottom_margin_units,
1201 params.bottommargin, default_unit);
1202 setEnabled(paper_->input_bottom_margin, useGeom);
1203 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1205 updateWidgetsFromLengthString(paper_->input_head_height,
1206 paper_->choice_head_height_units,
1207 params.headheight, default_unit);
1208 setEnabled(paper_->input_head_height, useGeom);
1209 setEnabled(paper_->choice_head_height_units, useGeom);
1211 updateWidgetsFromLengthString(paper_->input_head_sep,
1212 paper_->choice_head_sep_units,
1213 params.headsep, default_unit);
1214 setEnabled(paper_->input_head_sep, useGeom);
1215 setEnabled(paper_->choice_head_sep_units, useGeom);
1217 updateWidgetsFromLengthString(paper_->input_foot_skip,
1218 paper_->choice_foot_skip_units,
1219 params.footskip, default_unit);
1220 setEnabled(paper_->input_foot_skip, useGeom);
1221 setEnabled(paper_->choice_foot_skip_units, useGeom);
1223 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1227 void FormDocument::bullets_update(BufferParams const & params)
1229 if (!bullets_.get() ||
1231 (XpmVersion==4 && XpmRevision<7)))
1234 bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
1235 setEnabled(fbullet, !isLinuxDoc);
1237 if (isLinuxDoc) return;
1239 fl_set_button(bullets_->radio_bullet_depth_1, 1);
1240 fl_set_input(bullets_->input_bullet_latex,
1241 params.user_defined_bullets[0].getText().c_str());
1242 fl_set_choice(bullets_->choice_bullet_size,
1243 params.user_defined_bullets[0].getSize() + 2);
1247 void FormDocument::checkReadOnly()
1249 if (bc().readOnly(lv_->buffer()->isReadonly())) {
1250 combo_doc_class->deactivate();
1251 combo_language->deactivate();
1252 postWarning(_("Document is read-only."
1253 " No changes to layout permitted."));
1255 combo_doc_class->activate();
1256 combo_language->activate();
1262 bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
1268 // this has to be all out of if/elseif because it has to deactivate
1269 // the document buttons and so the whole stuff has to be tested again.
1270 // disable OK/Apply if input is not valid
1271 str = fl_get_input(class_->input_doc_skip);
1272 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1273 str = fl_get_input(paper_->input_custom_width);
1274 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1275 str = fl_get_input(paper_->input_custom_height);
1276 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1277 str = fl_get_input(paper_->input_outer_margin);
1278 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1279 str = fl_get_input(paper_->input_inner_margin);
1280 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1281 str = fl_get_input(paper_->input_top_margin);
1282 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1283 str = fl_get_input(paper_->input_bottom_margin);
1284 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1285 str = fl_get_input(paper_->input_head_height);
1286 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1287 str = fl_get_input(paper_->input_head_sep);
1288 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1289 str = fl_get_input(paper_->input_foot_skip);
1290 ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
1292 //display warning if input is not valid
1293 if (ob == class_->input_doc_skip
1294 || ob == paper_->input_custom_width
1295 || ob == paper_->input_custom_height
1296 || ob == paper_->input_outer_margin
1297 || ob == paper_->input_inner_margin
1298 || ob == paper_->input_top_margin
1299 || ob == paper_->input_bottom_margin
1300 || ob == paper_->input_head_height
1301 || ob == paper_->input_head_sep
1302 || ob == paper_->input_foot_skip) {
1304 postWarning(_("Invalid Length (valid example: 10mm)"));
1312 // "Synchronize" the choice and the input field, so that it
1313 // is impossible to commit senseless data.
1314 input = fl_get_input (class_->input_doc_skip);
1315 if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
1317 else if (fl_get_choice(class_->choice_doc_skip) != 4)
1318 fl_set_input (class_->input_doc_skip, "");
1320 input = fl_get_input(class_->input_doc_spacing);
1321 if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
1323 else if (fl_get_choice(class_->choice_doc_spacing) != 4)
1324 fl_set_input (class_->input_doc_spacing, "");
1329 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1331 BufferParams & param = lv_->buffer()->params;
1333 // convert from 1-6 range to -1-4
1334 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1335 fl_set_input(bullets_->input_bullet_latex,
1336 param.temp_bullets[current_bullet_depth].getText().c_str());
1340 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1342 BufferParams & param = lv_->buffer()->params;
1344 param.temp_bullets[current_bullet_depth].
1345 setText(fl_get_input(bullets_->input_bullet_latex));
1349 void FormDocument::BulletDepth(FL_OBJECT * ob, State cb)
1351 /* Should I do the following: */
1352 /* 1. change to the panel that the current bullet belongs in */
1353 /* 2. show that bullet as selected */
1354 /* 3. change the size setting to the size of the bullet in Q.*/
1355 /* 4. display the latex equivalent in the latex box */
1357 /* I'm inclined to just go with 3 and 4 at the moment and */
1358 /* maybe try to support the others later */
1359 BufferParams & param = lv_->buffer()->params;
1362 if (cb == BULLETDEPTH1)
1364 else if (cb == BULLETDEPTH2)
1366 else if (cb == BULLETDEPTH3)
1368 else if (cb == BULLETDEPTH4)
1371 switch (fl_get_button_numb(ob)) {
1373 // right mouse button resets to default
1374 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1376 current_bullet_depth = data;
1377 fl_set_input(bullets_->input_bullet_latex,
1378 param.temp_bullets[data].getText().c_str());
1379 fl_set_choice(bullets_->choice_bullet_size,
1380 param.temp_bullets[data].getSize() + 2);
1385 void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, State cb)
1387 /* Here we have to change the background pixmap to that selected */
1388 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1391 if (cb == BULLETPANEL1)
1393 else if (cb == BULLETPANEL2)
1395 else if (cb == BULLETPANEL3)
1397 else if (cb == BULLETPANEL4)
1399 else if (cb == BULLETPANEL5)
1401 else if (cb == BULLETPANEL6)
1404 if (data != current_bullet_panel) {
1405 fl_freeze_form(bullets_->form);
1406 current_bullet_panel = data;
1408 /* free the current pixmap */
1409 fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel);
1412 /* display the new one */
1414 new_panel = "standard";
1417 new_panel = "amssymb";
1420 new_panel = "psnfss1";
1423 new_panel = "psnfss2";
1426 new_panel = "psnfss3";
1429 new_panel = "psnfss4";
1432 /* something very wrong happened */
1433 // play it safe for now but should be an exception
1434 current_bullet_panel = 0; // standard panel
1435 new_panel = "standard";
1438 new_panel += ".xpm";
1439 fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6,
1440 LibFileSearch("images", new_panel).c_str());
1441 fl_redraw_object(bullets_->bmtable_bullet_panel);
1442 fl_unfreeze_form(bullets_->form);
1447 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1449 /* handle the user input by setting the current bullet depth's pixmap */
1450 /* to that extracted from the current chosen position of the BMTable */
1451 /* Don't forget to free the button's old pixmap first. */
1453 BufferParams & param = lv_->buffer()->params;
1454 int bmtable_button = fl_get_bmtable(ob);
1456 /* try to keep the button held down till another is pushed */
1457 /* fl_set_bmtable(ob, 1, bmtable_button); */
1458 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1459 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1460 fl_set_input(bullets_->input_bullet_latex,
1461 param.temp_bullets[current_bullet_depth].getText().c_str());
1465 void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
1468 ob = class_->choice_doc_class;
1470 lv_->prohibitInput();
1472 unsigned int tc = combo_doc_class->get() - 1;
1473 if (textclasslist[tc].load()) {
1474 // we use a copy of the bufferparams because we do not
1475 // want to modify them yet.
1476 BufferParams params = lv_->buffer()->params;
1478 if (lyxrc.auto_reset_options) {
1479 params.textclass = tc;
1480 params.useClassDefaults();
1481 UpdateLayoutDocument(params);
1483 // update the params which are needed in any case
1484 // (fontsizes, pagestyle)
1485 params.textclass = tc;
1486 UpdateClassParams(params);
1490 // unable to load new style
1491 Alert::alert(_("Conversion Errors!"),
1492 _("Unable to switch to new document class."),
1493 _("Reverting to original document class."));
1494 combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
1500 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1506 class_update(params);
1507 paper_update(params);
1508 language_update(params);
1509 options_update(params);
1510 bullets_update(params);