3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * \author Martin Vermeer
9 * \author Jürgen Spitzmüller
11 * Full author contact details are available in file CREDITS.
16 #include "FormDocument.h"
17 #include "forms/form_document.h"
19 #include "controllers/ControlDocument.h"
22 #include "checkedwidgets.h"
23 #include "ColorHandler.h"
25 #include "FormColorpicker.h"
26 #include "input_validators.h" // fl_unsigned_float_filter
28 #include "xforms_helpers.h"
31 #include "controllers/ButtonController.h"
32 #include "controllers/frnt_lang.h"
33 #include "controllers/helper_funcs.h"
36 #include "bufferparams.h"
39 #include "lyxtextclasslist.h"
40 #include "tex-strings.h"
43 #include "support/tostr.h"
44 #include "support/lstrings.h" // contains, getStringFromVector
45 #include "support/filetools.h" // LibFileSearch
49 #include <boost/bind.hpp>
53 using lyx::support::bformat;
54 using lyx::support::contains;
55 using lyx::support::getStringFromVector;
56 using lyx::support::getVectorFromString;
57 using lyx::support::LibFileSearch;
68 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
69 bool const scalableTabfolders = false;
71 bool const scalableTabfolders = true;
81 GUI_COLOR_CHOICE = FL_FREE_COL15
87 typedef FormController<ControlDocument, FormView<FD_document> > base_class;
89 FormDocument::FormDocument(Dialog & parent)
90 : base_class(parent, _("Document Settings"), scalableTabfolders),
91 ActCell(0), Confirmed(0),
92 current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
96 void FormDocument::redraw()
98 if (form() && form()->visible)
99 fl_redraw_form(form());
103 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
104 if (outer_form && outer_form->visible)
105 fl_redraw_form(outer_form);
109 void FormDocument::build()
112 dialog_.reset(build_document(this));
114 // Allow the base class to control messages
115 setMessageWidget(dialog_->text_warning);
117 // Manage the restore, ok, apply, restore and cancel/close buttons
118 bcview().setOK(dialog_->button_ok);
119 bcview().setApply(dialog_->button_apply);
120 bcview().setCancel(dialog_->button_close);
121 bcview().setRestore(dialog_->button_restore);
123 // the document class form
124 class_.reset(build_document_class(this));
126 // disable for read-only documents
127 bcview().addReadOnly(class_->combox_class);
128 bcview().addReadOnly(class_->radio_indent);
129 bcview().addReadOnly(class_->radio_skip);
130 bcview().addReadOnly(class_->choice_pagestyle);
131 bcview().addReadOnly(class_->choice_fonts);
132 bcview().addReadOnly(class_->choice_fontsize);
133 bcview().addReadOnly(class_->radio_sides_one);
134 bcview().addReadOnly(class_->radio_sides_two);
135 bcview().addReadOnly(class_->radio_columns_one);
136 bcview().addReadOnly(class_->radio_columns_two);
137 bcview().addReadOnly(class_->input_extra);
138 bcview().addReadOnly(class_->input_skip);
139 bcview().addReadOnly(class_->choice_skip);
140 bcview().addReadOnly(class_->choice_spacing);
141 bcview().addReadOnly(class_->input_spacing);
143 // check validity of "length + unit" input
144 addCheckedGlueLength(bcview(), class_->input_skip,
145 class_->choice_skip);
147 // trigger an input event for cut&paste with middle mouse button.
148 setPrehandler(class_->input_extra);
149 setPrehandler(class_->input_skip);
150 setPrehandler(class_->input_spacing);
152 fl_set_input_return(class_->input_extra, FL_RETURN_CHANGED);
153 fl_set_input_return(class_->input_skip, FL_RETURN_CHANGED);
154 fl_set_input_return(class_->input_spacing, FL_RETURN_CHANGED);
158 // Fill the combox and choices.
159 obj = class_->combox_class;
160 LyXTextClassList::const_iterator tit = textclasslist.begin();
161 LyXTextClassList::const_iterator tend = textclasslist.end();
162 for (; tit != tend; ++tit) {
163 if (tit->isTeXClassAvailable()) {
164 fl_addto_combox(obj, tit->description().c_str());
166 string item = bformat(_("Unavailable: %1$s"), tit->description());
167 fl_addto_combox(obj, item.c_str());
170 fl_set_combox_browser_height(obj, 400);
172 fl_addto_choice(class_->choice_spacing,
173 _(" Single | OneHalf | Double | Custom ").c_str());
174 fl_addto_choice(class_->choice_fontsize, "default|10|11|12");
175 for (int n = 0; tex_fonts[n][0]; ++n) {
176 fl_addto_choice(class_->choice_fonts,tex_fonts[n]);
179 // Create the contents of the unit choices; don't include the
181 vector<string> units_vec = getLatexUnits();
182 vector<string>::iterator ret =
183 std::remove_if(units_vec.begin(),
185 bind(contains<char>, _1, '%'));
186 units_vec.erase(ret, units_vec.end());
188 string const units = getStringFromVector(units_vec, "|");
190 fl_addto_choice(class_->choice_pagestyle,
191 "default|empty|plain|headings|fancy");
192 fl_addto_choice(class_->choice_skip,
193 _(" SmallSkip | MedSkip | BigSkip | Length ").c_str());
194 fl_addto_choice(class_->choice_skip_units, units.c_str());
196 // Set input filters on doc spacing to make it accept only
198 fl_set_input_filter(class_->input_spacing,
199 fl_unsigned_float_filter);
201 // disable for read-only documents
202 bcview().addReadOnly(dialog_->button_save_defaults);
203 bcview().addReadOnly(dialog_->button_reset_defaults);
205 // the document paper form
206 paper_.reset(build_document_paper(this));
208 // disable for read-only documents
209 bcview().addReadOnly(paper_->choice_paperpackage);
210 bcview().addReadOnly(paper_->radio_portrait);
211 bcview().addReadOnly(paper_->radio_landscape);
212 bcview().addReadOnly(paper_->choice_papersize);
213 bcview().addReadOnly(paper_->check_use_geometry);
214 bcview().addReadOnly(paper_->input_custom_width);
215 bcview().addReadOnly(paper_->input_custom_height);
216 bcview().addReadOnly(paper_->input_top_margin);
217 bcview().addReadOnly(paper_->input_bottom_margin);
218 bcview().addReadOnly(paper_->input_inner_margin);
219 bcview().addReadOnly(paper_->input_outer_margin);
220 bcview().addReadOnly(paper_->input_head_height);
221 bcview().addReadOnly(paper_->input_head_sep);
222 bcview().addReadOnly(paper_->input_foot_skip);
224 // check validity of "length + unit" input
225 addCheckedGlueLength(bcview(), paper_->input_custom_width);
226 addCheckedGlueLength(bcview(), paper_->input_custom_height);
227 addCheckedGlueLength(bcview(), paper_->input_top_margin);
228 addCheckedGlueLength(bcview(), paper_->input_bottom_margin);
229 addCheckedGlueLength(bcview(), paper_->input_inner_margin);
230 addCheckedGlueLength(bcview(), paper_->input_outer_margin);
231 addCheckedGlueLength(bcview(), paper_->input_head_height);
232 addCheckedGlueLength(bcview(), paper_->input_head_sep);
233 addCheckedGlueLength(bcview(), paper_->input_foot_skip);
235 // trigger an input event for cut&paste with middle mouse button.
236 setPrehandler(paper_->input_custom_width);
237 setPrehandler(paper_->input_custom_height);
238 setPrehandler(paper_->input_top_margin);
239 setPrehandler(paper_->input_bottom_margin);
240 setPrehandler(paper_->input_inner_margin);
241 setPrehandler(paper_->input_outer_margin);
242 setPrehandler(paper_->input_head_height);
243 setPrehandler(paper_->input_head_sep);
244 setPrehandler(paper_->input_foot_skip);
246 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
247 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
248 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
249 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
250 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
251 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
252 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
253 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
254 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
256 fl_addto_choice(paper_->choice_papersize,
257 _(" Default | Custom | US letter | US legal "
258 "| US executive | A3 | A4 | A5 "
259 "| B3 | B4 | B5 ").c_str());
260 fl_addto_choice(paper_->choice_paperpackage,
263 "| Very small Margins "
264 "| Very wide Margins ").c_str());
266 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
267 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
268 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
269 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
270 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
271 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
272 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
273 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
274 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
276 // the document language form
277 language_.reset(build_document_language(this));
279 // disable for read-only documents
280 bcview().addReadOnly(language_->combox_language);
281 bcview().addReadOnly(language_->choice_inputenc);
282 bcview().addReadOnly(language_->choice_quotes_language);
284 fl_addto_choice(language_->choice_inputenc,
285 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
286 "|koi8-r|koi8-u|cp866|cp1251|iso88595|pt154");
288 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
289 // Store the identifiers for later
290 lang_ = getSecond(langs);
292 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
293 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
294 for (; lit != lend; ++lit) {
295 fl_addto_combox(language_->combox_language,
298 fl_set_combox_browser_height(language_->combox_language, 400);
300 fl_addto_choice(language_->choice_quotes_language,
301 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
302 " <<text>> | >>text<< ").c_str());
304 // the document options form
305 options_.reset(build_document_options(this));
307 // disable for read-only documents
308 bcview().addReadOnly(options_->counter_secnumdepth);
309 bcview().addReadOnly(options_->counter_tocdepth);
310 bcview().addReadOnly(options_->choice_ams_math);
311 bcview().addReadOnly(options_->radio_use_defcite);
312 bcview().addReadOnly(options_->radio_use_jurabib);
313 bcview().addReadOnly(options_->radio_use_natbib);
314 bcview().addReadOnly(options_->check_bibtopic);
315 bcview().addReadOnly(options_->choice_citation_format);
316 bcview().addReadOnly(options_->input_float_placement);
317 bcview().addReadOnly(options_->choice_postscript_driver);
319 // add cite style radio buttons
320 citestyle_.init(options_->radio_use_defcite, DEFCITE);
321 citestyle_.init(options_->radio_use_natbib, NATBIB);
322 citestyle_.init(options_->radio_use_jurabib, JURABIB);
324 // set up the tooltips for optionss form
325 string str = _("Use LaTeX's default citation style");
326 tooltips().init(options_->radio_use_defcite, str);
327 str = _("Use the natbib styles for natural sciences and arts");
328 tooltips().init(options_->radio_use_natbib, str);
329 str = _("Use the jurabib styles for law and humanities");
330 tooltips().init(options_->radio_use_jurabib, str);
331 str = _("Select this if you want to split your bibliography into sections");
332 tooltips().init(options_->check_bibtopic, str);
334 // trigger an input event for cut&paste with middle mouse button.
335 setPrehandler(options_->input_float_placement);
337 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
339 fl_addto_choice(options_->choice_ams_math,
340 _(" Never | Automatically | Yes ").c_str());
342 for (int n = 0; tex_graphics[n][0]; ++n) {
343 fl_addto_choice(options_->choice_postscript_driver,
346 fl_addto_choice(options_->choice_citation_format,
347 _(" Author-year | Numerical ").c_str());
349 // the document bullets form
350 bullets_.reset(build_document_bullet(this));
352 // disable for read-only documents
353 bcview().addReadOnly(bullets_->radio_depth_1);
354 bcview().addReadOnly(bullets_->radio_depth_2);
355 bcview().addReadOnly(bullets_->radio_depth_3);
356 bcview().addReadOnly(bullets_->radio_depth_4);
357 bcview().addReadOnly(bullets_->radio_panel_standard);
358 bcview().addReadOnly(bullets_->radio_panel_maths);
359 bcview().addReadOnly(bullets_->radio_panel_ding1);
360 bcview().addReadOnly(bullets_->radio_panel_ding2);
361 bcview().addReadOnly(bullets_->radio_panel_ding3);
362 bcview().addReadOnly(bullets_->radio_panel_ding4);
363 bcview().addReadOnly(bullets_->bmtable_panel);
364 bcview().addReadOnly(bullets_->choice_size);
365 bcview().addReadOnly(bullets_->input_latex);
367 // trigger an input event for cut&paste with middle mouse button.
368 setPrehandler(bullets_->input_latex);
370 fl_set_input_return(bullets_->input_latex, FL_RETURN_CHANGED);
372 fl_addto_choice(bullets_->choice_size,
373 _(" Default | Tiny | Smallest | Smaller "
374 "| Small | Normal | Large | Larger | Largest "
375 "| Huge | Huger ").c_str());
376 fl_set_choice(bullets_->choice_size, 1);
378 fl_set_input_maxchars(bullets_->input_latex, 80);
380 string const bmtablefile = LibFileSearch("images", "standard", "xpm");
381 fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6,
382 bmtablefile.c_str());
384 picker_.reset(new FormColorpicker);
386 // the document branches form
387 branch_.reset(build_document_branch(this));
389 fl_set_object_color(branch_->button_color,
390 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
392 bcview().addReadOnly(branch_->input_all_branches);
393 bcview().addReadOnly(branch_->button_add_branch);
394 bcview().addReadOnly(branch_->button_remove_branch);
395 bcview().addReadOnly(branch_->button_select);
396 bcview().addReadOnly(branch_->button_deselect);
397 bcview().addReadOnly(branch_->button_modify);
398 bcview().addReadOnly(branch_->browser_all_branches);
400 // set up the tooltips for branches form
401 str = _("Enter the name of a new branch.");
402 tooltips().init(branch_->input_all_branches, str);
403 str = _("Add a new branch to the document.");
404 tooltips().init(branch_->button_add_branch, str);
405 str = _("Remove the selected branch from the document.");
406 tooltips().init(branch_->button_remove_branch, str);
407 str = _("Activate the selected branch for output.");
408 tooltips().init(branch_->button_select, str);
409 str = _("Deactivate the selected activated branch.");
410 tooltips().init(branch_->button_deselect, str);
411 str = _("Available branches for this document.");
412 tooltips().init(branch_->browser_all_branches, str);
413 str = _("Activated branches. Content will occur in the document\'s output");
414 tooltips().init(branch_->browser_selection, str);
415 str = _("Modify background color of branch inset");
416 tooltips().init(branch_->button_modify, str);
417 str = _("Background color of branch inset");
418 tooltips().init(branch_->button_color, str);
420 // Handle middle mouse paint:
421 setPrehandler(branch_->input_all_branches);
422 fl_set_input_return(branch_->input_all_branches, FL_RETURN_CHANGED);
424 // Enable the tabfolder to be rescaled correctly.
425 if (scalableTabfolders)
426 fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
429 fl_addto_tabfolder(dialog_->tabfolder,_("Document").c_str(),
431 fl_addto_tabfolder(dialog_->tabfolder,_("Paper").c_str(),
433 fl_addto_tabfolder(dialog_->tabfolder,_("Language").c_str(),
435 fl_addto_tabfolder(dialog_->tabfolder,_("Extra").c_str(),
437 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets").c_str(),
440 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
441 lyxerr << _("Your version of libXpm is older than 4.7.\n"
442 "The `bullet' tab of the document dialog "
443 "has been disabled") << '\n';
444 fl_deactivate_object(fbullet);
445 fl_set_object_lcol(fbullet, FL_INACTIVE);
448 fl_addto_tabfolder(dialog_->tabfolder,_("Branches").c_str(),
453 void FormDocument::apply()
455 BufferParams & params = controller().params();
459 language_apply(params);
460 options_apply(params);
461 bullets_apply(params);
462 branch_apply(params);
466 void FormDocument::update()
473 BufferParams const & params = controller().params();
475 class_update(params);
476 paper_update(params);
477 language_update(params);
478 options_update(params);
479 bullets_update(params);
480 branch_update(params);
484 ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
486 if (ob == bullets_->choice_size) {
487 ChoiceBulletSize(ob, 0);
489 } else if (ob == bullets_->input_latex) {
490 InputBulletLaTeX(ob, 0);
492 } else if (ob == bullets_->radio_depth_1 ||
493 ob == bullets_->radio_depth_2 ||
494 ob == bullets_->radio_depth_3 ||
495 ob == bullets_->radio_depth_4) {
498 } else if (ob == bullets_->radio_panel_standard ||
499 ob == bullets_->radio_panel_maths ||
500 ob == bullets_->radio_panel_ding1 ||
501 ob == bullets_->radio_panel_ding2 ||
502 ob == bullets_->radio_panel_ding3 ||
503 ob == bullets_->radio_panel_ding4) {
506 } else if (ob == bullets_->bmtable_panel) {
507 BulletBMTable(ob, 0);
509 } else if (ob == class_->choice_spacing) {
510 setEnabled(class_->input_spacing,
511 fl_get_choice(class_->choice_spacing) == 4);
513 } else if (ob == class_->combox_class) {
515 } else if (ob == class_->radio_skip ||
516 ob == class_->radio_indent ||
517 ob == class_->choice_skip) {
518 bool const skip_used = fl_get_button(class_->radio_skip);
519 setEnabled(class_->choice_skip, skip_used);
521 bool const length_input =
522 fl_get_choice(class_->choice_skip) == 4;
523 setEnabled(class_->input_skip,
524 skip_used && length_input);
525 setEnabled(class_->choice_skip_units,
526 skip_used && length_input);
528 // Default unit choice is cm if metric, inches if US paper.
529 // If papersize is default, check the lyxrc-settings
530 int const paperchoice = fl_get_choice(paper_->choice_papersize);
531 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
532 || paperchoice == 2 || paperchoice > 5;
533 string const default_unit = metric ? "cm" : "in";
534 if (getString(class_->input_skip).empty())
535 fl_set_choice_text(class_->choice_skip_units,
536 default_unit.c_str());
538 } else if (ob == options_->radio_use_jurabib ||
539 ob == options_->radio_use_defcite ||
540 ob == options_->radio_use_natbib) {
541 setEnabled(options_->choice_citation_format,
542 fl_get_button(options_->radio_use_natbib));
544 } else if (ob == branch_->browser_all_branches ||
545 ob == branch_->browser_selection ||
546 ob == branch_->button_add_branch ||
547 ob == branch_->button_remove_branch ||
548 ob == branch_->button_modify ||
549 ob == branch_->button_select ||
550 ob == branch_->button_deselect) {
552 } else if (ob == dialog_->button_save_defaults) {
554 controller().saveAsDefault();
556 } else if (ob == dialog_->button_reset_defaults) {
557 BufferParams & params = controller().params();
558 params.textclass = fl_get_combox(class_->combox_class) - 1;
559 params.useClassDefaults();
560 UpdateLayoutDocument(params);
562 } else if (ob == paper_->radio_landscape) {
563 fl_set_choice(paper_->choice_paperpackage,
566 } else if (ob == paper_->choice_papersize) {
567 int const paperchoice = fl_get_choice(paper_->choice_papersize);
568 bool const defsize = paperchoice == 1;
569 bool const custom = paperchoice == 2;
570 bool const a3size = paperchoice == 6;
571 bool const b3size = paperchoice == 9;
572 bool const b4size = paperchoice == 10;
575 fl_set_button(paper_->radio_portrait, 1);
577 bool const use_geom = (custom || a3size || b3size || b4size);
579 fl_set_button(paper_->check_use_geometry, int(use_geom));
581 setEnabled(paper_->input_top_margin, use_geom);
582 setEnabled(paper_->input_bottom_margin, use_geom);
583 setEnabled(paper_->input_inner_margin, use_geom);
584 setEnabled(paper_->input_outer_margin, use_geom);
585 setEnabled(paper_->input_head_height, use_geom);
586 setEnabled(paper_->input_head_sep, use_geom);
587 setEnabled(paper_->input_foot_skip, use_geom);
588 setEnabled(paper_->choice_top_margin_units, use_geom);
589 setEnabled(paper_->choice_bottom_margin_units, use_geom);
590 setEnabled(paper_->choice_inner_margin_units, use_geom);
591 setEnabled(paper_->choice_outer_margin_units, use_geom);
592 setEnabled(paper_->choice_head_height_units, use_geom);
593 setEnabled(paper_->choice_head_sep_units, use_geom);
594 setEnabled(paper_->choice_foot_skip_units, use_geom);
595 setEnabled(paper_->choice_custom_width_units, use_geom);
596 setEnabled(paper_->choice_custom_height_units, use_geom);
598 setEnabled(paper_->input_custom_width, custom);
599 setEnabled(paper_->input_custom_height, custom);
600 setEnabled(paper_->choice_custom_width_units, custom);
601 setEnabled(paper_->choice_custom_height_units, custom);
602 setEnabled(paper_->radio_portrait, !custom);
603 setEnabled(paper_->radio_landscape, !custom);
605 // Default unit choice is cm if metric, inches if US paper.
606 // If papersize is default, use the lyxrc-settings
607 bool const metric = (defsize && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
608 || paperchoice == 2 || paperchoice > 5;
609 string const default_unit = metric ? "cm" : "in";
610 if (getString(paper_->input_custom_width).empty())
611 fl_set_choice_text(paper_->choice_custom_width_units,
612 default_unit.c_str());
613 if (getString(paper_->input_custom_height).empty())
614 fl_set_choice_text(paper_->choice_custom_height_units,
615 default_unit.c_str());
616 if (getString(paper_->input_top_margin).empty())
617 fl_set_choice_text(paper_->choice_top_margin_units,
618 default_unit.c_str());
619 if (getString(paper_->input_bottom_margin).empty())
620 fl_set_choice_text(paper_->choice_bottom_margin_units,
621 default_unit.c_str());
622 if (getString(paper_->input_inner_margin).empty())
623 fl_set_choice_text(paper_->choice_inner_margin_units,
624 default_unit.c_str());
625 if (getString(paper_->input_outer_margin).empty())
626 fl_set_choice_text(paper_->choice_outer_margin_units,
627 default_unit.c_str());
628 if (getString(paper_->input_head_height).empty())
629 fl_set_choice_text(paper_->choice_head_height_units,
630 default_unit.c_str());
631 if (getString(paper_->input_head_sep).empty())
632 fl_set_choice_text(paper_->choice_head_sep_units,
633 default_unit.c_str());
634 if (getString(paper_->input_foot_skip).empty())
635 fl_set_choice_text(paper_->choice_foot_skip_units,
636 default_unit.c_str());
638 } else if (ob == paper_->choice_paperpackage &&
639 fl_get_choice(paper_->choice_paperpackage) != 1) {
641 fl_set_button(paper_->check_use_geometry, 0);
642 setEnabled(paper_->input_top_margin, false);
643 setEnabled(paper_->input_bottom_margin, false);
644 setEnabled(paper_->input_inner_margin, false);
645 setEnabled(paper_->input_outer_margin, false);
646 setEnabled(paper_->input_head_height, false);
647 setEnabled(paper_->input_head_sep, false);
648 setEnabled(paper_->input_foot_skip, false);
649 setEnabled(paper_->choice_top_margin_units, false);
650 setEnabled(paper_->choice_bottom_margin_units, false);
651 setEnabled(paper_->choice_inner_margin_units, false);
652 setEnabled(paper_->choice_outer_margin_units, false);
653 setEnabled(paper_->choice_head_height_units, false);
654 setEnabled(paper_->choice_head_sep_units, false);
655 setEnabled(paper_->choice_foot_skip_units, false);
657 } else if (ob == paper_->check_use_geometry) {
658 // don't allow switching geometry off in custom papersize
659 // mode nor in A3, B3, and B4
660 int const choice = fl_get_choice(paper_->choice_papersize);
661 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
662 fl_set_button(paper_->check_use_geometry, 1);
664 fl_set_choice(paper_->choice_paperpackage,
667 bool const use_geom = fl_get_button(paper_->check_use_geometry);
668 setEnabled(paper_->input_top_margin, use_geom);
669 setEnabled(paper_->input_bottom_margin, use_geom);
670 setEnabled(paper_->input_inner_margin, use_geom);
671 setEnabled(paper_->input_outer_margin, use_geom);
672 setEnabled(paper_->input_head_height, use_geom);
673 setEnabled(paper_->input_head_sep, use_geom);
674 setEnabled(paper_->input_foot_skip, use_geom);
675 setEnabled(paper_->choice_top_margin_units, use_geom);
676 setEnabled(paper_->choice_bottom_margin_units, use_geom);
677 setEnabled(paper_->choice_inner_margin_units, use_geom);
678 setEnabled(paper_->choice_outer_margin_units, use_geom);
679 setEnabled(paper_->choice_head_height_units, use_geom);
680 setEnabled(paper_->choice_head_sep_units, use_geom);
681 setEnabled(paper_->choice_foot_skip_units, use_geom);
684 if (ob == paper_->choice_papersize || ob == paper_->radio_portrait
685 || ob == paper_->radio_landscape) {
686 // either default papersize (preferences) or document
687 // papersize has to be A4
688 bool const enable = ( fl_get_choice(paper_->choice_papersize) == 1
689 && lyxrc.default_papersize == PAPER_A4PAPER )
690 || fl_get_choice(paper_->choice_papersize) == 7;
692 fl_set_choice(paper_->choice_paperpackage,
694 setEnabled(paper_->choice_paperpackage,
695 enable && fl_get_button(paper_->radio_portrait));
698 return ButtonPolicy::SMI_VALID;
702 void FormDocument::rebuild_all_branches_browser()
704 typedef BranchList::const_iterator const_iterator;
706 fl_clear_browser(branch_->browser_all_branches);
708 const_iterator const begin = branchlist_.begin();
709 const_iterator const end = branchlist_.end();
710 for (const_iterator it = begin; it != end; ++it) {
711 fl_addto_browser(branch_->browser_all_branches,
712 it->getBranch().c_str());
717 void FormDocument::rebuild_selected_branches_browser()
719 typedef BranchList::const_iterator const_iterator;
721 fl_clear_browser(branch_->browser_selection);
723 const_iterator const begin = branchlist_.begin();
724 const_iterator const end = branchlist_.end();
725 for (const_iterator it = begin; it != end; ++it) {
726 if (it->getSelected())
727 fl_addto_browser(branch_->browser_selection,
728 it->getBranch().c_str());
735 RGBColor get_current_color(FL_OBJECT * browser, BranchList const & branchlist)
737 BOOST_ASSERT(browser && browser->objclass == FL_BROWSER);
741 int const i = fl_get_browser(browser);
742 string const branch_name = fl_get_browser_line(browser, i);
743 Branch const * branch = branchlist.find(branch_name);
747 string const x11hexname = branch->getColor();
748 if (x11hexname[0] == '#') {
749 color = RGBColor(x11hexname);
751 fl_getmcolor(FL_COL1, &color.r, &color.g, &color.b);
759 void FormDocument::branch_input(FL_OBJECT * ob)
761 if (ob == branch_->button_add_branch) {
762 string const new_branch =
763 getString(branch_->input_all_branches);
765 if (!new_branch.empty() && branchlist_.add(new_branch)) {
767 fl_set_input(branch_->input_all_branches, "");
768 rebuild_all_branches_browser();
771 } else if (ob == branch_->button_remove_branch) {
772 unsigned i = fl_get_browser(branch_->browser_all_branches);
773 string const current_branch =
774 fl_get_browser_line(branch_->browser_all_branches, i);
775 if (!current_branch.empty() &&
776 branchlist_.remove(current_branch)) {
778 rebuild_all_branches_browser();
779 rebuild_selected_branches_browser();
782 } else if (ob == branch_->button_select ||
783 ob == branch_->button_deselect) {
785 bool const selecting = ob == branch_->button_select;
786 string current_branch;
788 // When selecting, take highlighted item from left browser,
789 // when deselecting, from right browser:
791 int const i = fl_get_browser(branch_->browser_all_branches);
793 fl_get_browser_line(branch_->browser_all_branches, i);
795 int const i = fl_get_browser(branch_->browser_selection);
797 fl_get_browser_line(branch_->browser_selection, i);
799 Branch * branch = branchlist_.find(current_branch);
801 if (branch && branch->setSelected(selecting))
802 rebuild_selected_branches_browser();
804 } else if (ob == branch_->button_modify) {
805 RGBColor const before =
806 get_current_color(branch_->browser_all_branches,
808 RGBColor const after = picker_->requestColor(before);
809 if (before != after) {
810 fl_mapcolor(GUI_COLOR_CHOICE,
811 after.r, after.g, after.b);
812 fl_redraw_object(branch_->button_color);
814 string const branch_name =
815 getString(branch_->browser_all_branches);
816 Branch * branch = branchlist_.find(branch_name);
818 branch->setColor(X11hexname(after));
821 } else if (ob == branch_->browser_all_branches) {
823 get_current_color(branch_->browser_all_branches,
826 fl_mapcolor(GUI_COLOR_CHOICE, rgb.r, rgb.g, rgb.b);
827 fl_redraw_object(branch_->button_color);
829 setEnabled(branch_->button_select,
830 (fl_get_browser(branch_->browser_all_branches) > 0));
831 setEnabled(branch_->button_deselect,
832 (fl_get_browser(branch_->browser_selection) > 0));
833 setEnabled(branch_->button_remove_branch,
834 (fl_get_browser(branch_->browser_all_branches) > 0));
835 setEnabled(branch_->button_modify,
836 (fl_get_browser(branch_->browser_all_branches) > 0));
840 bool FormDocument::class_apply(BufferParams ¶ms)
844 // If default skip is a "Length" but there's no text in the
845 // input field, reset the kind to "MedSkip", which is the default.
846 if (fl_get_choice(class_->choice_skip) == 4 &&
847 getString(class_->input_skip).empty()) {
848 fl_set_choice(class_->choice_skip, 2);
850 params.fonts = getString(class_->choice_fonts);
851 params.fontsize = getString(class_->choice_fontsize);
852 params.pagestyle = getString(class_->choice_pagestyle);
854 params.textclass = fl_get_combox(class_->combox_class) - 1;
856 BufferParams::PARSEP tmpsep = params.paragraph_separation;
857 if (fl_get_button(class_->radio_indent))
858 params.paragraph_separation = BufferParams::PARSEP_INDENT;
860 params.paragraph_separation = BufferParams::PARSEP_SKIP;
861 if (tmpsep != params.paragraph_separation)
864 VSpace tmpdefskip = params.getDefSkip();
865 switch (fl_get_choice(class_->choice_skip)) {
867 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
870 params.setDefSkip(VSpace(VSpace::MEDSKIP));
873 params.setDefSkip(VSpace(VSpace::BIGSKIP));
877 string const length =
878 getLengthFromWidgets(class_->input_skip,
879 class_->choice_skip_units);
881 params.setDefSkip(VSpace(LyXGlueLength(length)));
885 // DocumentDefskipCB assures that this never happens
886 params.setDefSkip(VSpace(VSpace::MEDSKIP));
889 if (!(tmpdefskip == params.getDefSkip()))
892 if (fl_get_button(class_->radio_columns_two))
896 if (fl_get_button(class_->radio_sides_two))
897 params.sides = LyXTextClass::TwoSides;
899 params.sides = LyXTextClass::OneSide;
901 Spacing tmpSpacing = params.spacing();
902 switch (fl_get_choice(class_->choice_spacing)) {
904 lyxerr[Debug::INFO] << "Spacing: SINGLE" << endl;
905 params.spacing().set(Spacing::Single);
908 lyxerr[Debug::INFO] << "Spacing: ONEHALF" << endl;
909 params.spacing().set(Spacing::Onehalf);
912 lyxerr[Debug::INFO] << "Spacing: DOUBLE" << endl;
913 params.spacing().set(Spacing::Double);
916 lyxerr[Debug::INFO] << "Spacing: OTHER" << endl;
917 params.spacing().set(Spacing::Other,
918 getString(class_->input_spacing));
921 if (tmpSpacing != params.spacing())
924 params.options = getString(class_->input_extra);
930 void FormDocument::paper_apply(BufferParams & params)
932 params.papersize2 = VMARGIN_PAPER_TYPE(fl_get_choice(paper_->choice_papersize) - 1);
934 params.paperpackage =
935 PAPER_PACKAGES(fl_get_choice(paper_->choice_paperpackage) - 1);
937 // set params.papersize from params.papersize2 and params.paperpackage
938 params.setPaperStuff();
940 params.use_geometry = fl_get_button(paper_->check_use_geometry);
942 if (fl_get_button(paper_->radio_landscape))
943 params.orientation = ORIENTATION_LANDSCAPE;
945 params.orientation = ORIENTATION_PORTRAIT;
948 getLengthFromWidgets(paper_->input_custom_width,
949 paper_->choice_custom_width_units);
952 getLengthFromWidgets(paper_->input_custom_height,
953 paper_->choice_custom_height_units);
956 getLengthFromWidgets(paper_->input_inner_margin,
957 paper_->choice_inner_margin_units);
960 getLengthFromWidgets(paper_->input_top_margin,
961 paper_->choice_top_margin_units);
964 getLengthFromWidgets(paper_->input_outer_margin,
965 paper_->choice_outer_margin_units);
967 params.bottommargin =
968 getLengthFromWidgets(paper_->input_bottom_margin,
969 paper_->choice_bottom_margin_units);
972 getLengthFromWidgets(paper_->input_head_height,
973 paper_->choice_head_height_units);
976 getLengthFromWidgets(paper_->input_head_sep,
977 paper_->choice_head_sep_units);
980 getLengthFromWidgets(paper_->input_foot_skip,
981 paper_->choice_foot_skip_units);
985 bool FormDocument::language_apply(BufferParams & params)
987 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
990 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
992 lga = InsetQuotes::EnglishQ;
995 lga = InsetQuotes::SwedishQ;
998 lga = InsetQuotes::GermanQ;
1001 lga = InsetQuotes::PolishQ;
1004 lga = InsetQuotes::FrenchQ;
1007 lga = InsetQuotes::DanishQ;
1010 params.quotes_language = lga;
1012 int const pos = fl_get_combox(language_->combox_language);
1013 Language const * new_language = languages.getLanguage(lang_[pos-1]);
1015 new_language = default_language;
1017 params.language = new_language;
1018 params.inputenc = getString(language_->choice_inputenc);
1024 bool FormDocument::options_apply(BufferParams & params)
1028 params.graphicsDriver = getString(options_->choice_postscript_driver);
1029 params.use_amsmath = static_cast<BufferParams::AMS>(
1030 fl_get_choice(options_->choice_ams_math) - 1);
1031 params.use_natbib = fl_get_button(options_->radio_use_natbib);
1032 params.use_numerical_citations =
1033 fl_get_choice(options_->choice_citation_format) - 1;
1034 params.use_jurabib = fl_get_button(options_->radio_use_jurabib);
1035 params.use_bibtopic = fl_get_button(options_->check_bibtopic);
1037 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
1038 if (params.secnumdepth != tmpchar)
1040 params.secnumdepth = tmpchar;
1042 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
1044 params.float_placement =
1045 getString(options_->input_float_placement);
1051 void FormDocument::bullets_apply(BufferParams & params)
1053 /* update the bullet settings */
1054 BufferParams & buf_params = controller().params();
1056 for (int i = 0; i < 4; ++i) {
1057 params.user_defined_bullet(i) = buf_params.temp_bullet(i);
1062 void FormDocument::branch_apply(BufferParams & params)
1064 params.branchlist() = branchlist_;
1068 void FormDocument::UpdateClassParams(BufferParams const & params)
1070 // These are the params that have to be updated on any class change
1071 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
1073 LyXTextClass const & tclass = textclasslist[params.textclass];
1075 fl_set_combox(class_->combox_class, params.textclass + 1);
1076 fl_clear_choice(class_->choice_fontsize);
1077 fl_addto_choice(class_->choice_fontsize, "default");
1078 fl_addto_choice(class_->choice_fontsize,
1079 tclass.opt_fontsize().c_str());
1080 fl_set_choice_text(class_->choice_fontsize,
1081 params.fontsize.c_str());
1082 fl_clear_choice(class_->choice_pagestyle);
1083 fl_addto_choice(class_->choice_pagestyle, "default");
1084 fl_addto_choice(class_->choice_pagestyle,
1085 tclass.opt_pagestyle().c_str());
1086 fl_set_choice_text(class_->choice_pagestyle,
1087 params.pagestyle.c_str());
1089 fl_set_input(class_->input_extra, tclass.options().c_str());
1092 void FormDocument::class_update(BufferParams const & params)
1097 UpdateClassParams(params);
1099 fl_set_choice_text(class_->choice_fonts, params.fonts.c_str());
1101 bool const indent = params.paragraph_separation == BufferParams::PARSEP_INDENT;
1102 fl_set_button(class_->radio_indent, indent);
1103 fl_set_button(class_->radio_skip, !indent);
1107 pos = 2; // VSpace::MEDSKIP is default
1109 switch (params.getDefSkip().kind()) {
1110 case VSpace::LENGTH:
1113 case VSpace::BIGSKIP:
1116 case VSpace::SMALLSKIP:
1119 case VSpace::MEDSKIP:
1125 fl_set_choice (class_->choice_skip, pos);
1127 bool const length_input = pos == 4;
1129 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1130 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
1131 || paperchoice == 2 || paperchoice > 5;
1132 string const default_unit = metric ? "cm" : "in";
1133 string const length = params.getDefSkip().asLyXCommand();
1134 updateWidgetsFromLengthString(class_->input_skip,
1135 class_->choice_skip_units,
1136 length, default_unit);
1139 fl_set_input(class_->input_skip, "");
1141 setEnabled(class_->choice_skip, !indent);
1142 setEnabled(class_->input_skip, length_input);
1143 setEnabled(class_->choice_skip_units, length_input);
1145 bool const two_sides = params.sides == LyXTextClass::TwoSides;
1146 fl_set_button(class_->radio_sides_one, !two_sides);
1147 fl_set_button(class_->radio_sides_two, two_sides);
1149 bool const two_columns = params.columns == 2;
1150 fl_set_button(class_->radio_columns_one, !two_columns);
1151 fl_set_button(class_->radio_columns_two, two_columns);
1153 fl_set_input(class_->input_extra, params.options.c_str());
1155 switch (params.spacing().getSpace()) {
1156 case Spacing::Other:
1159 case Spacing::Double: // \doublespacing
1162 case Spacing::Onehalf: // \onehalfspacing
1165 case Spacing::Single: // \singlespacing
1166 case Spacing::Default: // nothing bad should happen with this
1171 fl_set_choice(class_->choice_spacing, pos);
1173 bool const spacing_input = pos == 4;
1174 setEnabled(class_->input_spacing, spacing_input);
1175 string const input = spacing_input ? tostr(params.spacing().getValue()) : string();
1176 fl_set_input(class_->input_spacing, input.c_str());
1180 void FormDocument::language_update(BufferParams const & params)
1182 if (!language_.get())
1185 int const pos = int(findPos(lang_, params.language->lang()));
1186 fl_set_combox(language_->combox_language, pos+1);
1188 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1189 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1193 void FormDocument::options_update(BufferParams const & params)
1195 if (!options_.get())
1198 fl_set_choice_text(options_->choice_postscript_driver,
1199 params.graphicsDriver.c_str());
1200 fl_set_choice(options_->choice_ams_math, params.use_amsmath + 1);
1201 fl_set_button(options_->radio_use_natbib, params.use_natbib);
1202 fl_set_choice(options_->choice_citation_format,
1203 int(params.use_numerical_citations)+1);
1204 setEnabled(options_->choice_citation_format, params.use_natbib);
1205 fl_set_button(options_->radio_use_jurabib, params.use_jurabib);
1206 fl_set_button(options_->check_bibtopic, params.use_bibtopic);
1207 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1208 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1209 if (!params.float_placement.empty())
1210 fl_set_input(options_->input_float_placement,
1211 params.float_placement.c_str());
1213 fl_set_input(options_->input_float_placement, "");
1217 void FormDocument::paper_update(BufferParams const & params)
1222 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1223 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1224 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1226 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1227 bool const useCustom = paperchoice == 2;
1228 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1230 fl_set_button(paper_->radio_portrait, 0);
1231 setEnabled(paper_->radio_portrait, !useCustom);
1232 fl_set_button(paper_->radio_landscape, 0);
1233 setEnabled(paper_->radio_landscape, !useCustom);
1235 if (params.orientation == ORIENTATION_LANDSCAPE)
1236 fl_set_button(paper_->radio_landscape, 1);
1238 fl_set_button(paper_->radio_portrait, 1);
1239 setEnabled(paper_->choice_paperpackage,
1240 //either default papersize (preferences)
1241 //or document papersize has to be A4
1243 || paperchoice == 1 && lyxrc.default_papersize == PAPER_A4PAPER)
1244 && fl_get_button(paper_->radio_portrait));
1246 // Default unit choice is cm if metric, inches if US paper.
1247 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
1248 || paperchoice == 2 || paperchoice > 5;
1249 string const default_unit = metric ? "cm" : "in";
1250 updateWidgetsFromLengthString(paper_->input_custom_width,
1251 paper_->choice_custom_width_units,
1252 params.paperwidth, default_unit);
1253 setEnabled(paper_->input_custom_width, useCustom);
1254 setEnabled(paper_->choice_custom_width_units, useCustom);
1256 updateWidgetsFromLengthString(paper_->input_custom_height,
1257 paper_->choice_custom_height_units,
1258 params.paperheight, default_unit);
1259 setEnabled(paper_->input_custom_height, useCustom);
1260 setEnabled(paper_->choice_custom_height_units, useCustom);
1262 updateWidgetsFromLengthString(paper_->input_inner_margin,
1263 paper_->choice_inner_margin_units,
1264 params.leftmargin, default_unit);
1265 setEnabled(paper_->input_inner_margin, useGeom);
1266 setEnabled(paper_->choice_inner_margin_units, useGeom);
1268 updateWidgetsFromLengthString(paper_->input_top_margin,
1269 paper_->choice_top_margin_units,
1270 params.topmargin, default_unit);
1271 setEnabled(paper_->input_top_margin, useGeom);
1272 setEnabled(paper_->choice_top_margin_units, useGeom);
1274 updateWidgetsFromLengthString(paper_->input_outer_margin,
1275 paper_->choice_outer_margin_units,
1276 params.rightmargin, default_unit);
1277 setEnabled(paper_->input_outer_margin, useGeom);
1278 setEnabled(paper_->choice_outer_margin_units, useGeom);
1280 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1281 paper_->choice_bottom_margin_units,
1282 params.bottommargin, default_unit);
1283 setEnabled(paper_->input_bottom_margin, useGeom);
1284 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1286 updateWidgetsFromLengthString(paper_->input_head_height,
1287 paper_->choice_head_height_units,
1288 params.headheight, default_unit);
1289 setEnabled(paper_->input_head_height, useGeom);
1290 setEnabled(paper_->choice_head_height_units, useGeom);
1292 updateWidgetsFromLengthString(paper_->input_head_sep,
1293 paper_->choice_head_sep_units,
1294 params.headsep, default_unit);
1295 setEnabled(paper_->input_head_sep, useGeom);
1296 setEnabled(paper_->choice_head_sep_units, useGeom);
1298 updateWidgetsFromLengthString(paper_->input_foot_skip,
1299 paper_->choice_foot_skip_units,
1300 params.footskip, default_unit);
1301 setEnabled(paper_->input_foot_skip, useGeom);
1302 setEnabled(paper_->choice_foot_skip_units, useGeom);
1304 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1308 void FormDocument::bullets_update(BufferParams const & params)
1310 if (!bullets_.get() ||
1312 (XpmVersion==4 && XpmRevision<7)))
1315 bool const isLinuxDoc = kernel().docType() == Kernel::LINUXDOC;
1316 setEnabled(fbullet, !isLinuxDoc);
1318 if (isLinuxDoc) return;
1320 fl_set_button(bullets_->radio_depth_1, 1);
1321 fl_set_input(bullets_->input_latex,
1322 params.user_defined_bullet(0).getText().c_str());
1323 fl_set_choice(bullets_->choice_size,
1324 params.user_defined_bullet(0).getSize() + 2);
1328 void FormDocument::branch_update(BufferParams const & params)
1333 branchlist_ = params.branchlist();
1335 rebuild_all_branches_browser();
1336 string const current_branch =
1337 fl_get_browser_maxline(branch_->browser_all_branches) == 0 ?
1339 fl_get_browser_line(branch_->browser_all_branches, 1);
1341 // display proper selection...
1342 rebuild_selected_branches_browser();
1344 // display proper colour...
1347 if (current_branch == "none")
1348 x11hexname = "none";
1350 Branch * branch = branchlist_.find(current_branch);
1352 x11hexname = branch->getColor();
1355 if (x11hexname[0] == '#') {
1356 rgb = RGBColor(x11hexname);
1358 fl_getmcolor(FL_COL1, &rgb.r, &rgb.g, &rgb.b);
1360 fl_mapcolor(GUI_COLOR_CHOICE, rgb.r, rgb.g, rgb.b);
1361 fl_redraw_object(branch_->button_color);
1363 setEnabled(branch_->button_select,
1364 (fl_get_browser(branch_->browser_all_branches) > 0));
1365 setEnabled(branch_->button_deselect,
1366 (fl_get_browser(branch_->browser_selection) > 0));
1367 setEnabled(branch_->button_remove_branch,
1368 (fl_get_browser(branch_->browser_all_branches) > 0));
1369 setEnabled(branch_->button_modify,
1370 (fl_get_browser(branch_->browser_all_branches) > 0));
1374 void FormDocument::checkReadOnly()
1376 if (bc().readOnly(kernel().isBufferReadonly())) {
1377 postWarning(_("Document is read-only."
1378 " No changes to layout permitted."));
1385 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1387 BufferParams & param = controller().params();
1389 // convert from 1-6 range to -1-4
1390 param.temp_bullet(current_bullet_depth).setSize(fl_get_choice(ob) - 2);
1391 fl_set_input(bullets_->input_latex,
1392 param.temp_bullet(current_bullet_depth).getText().c_str());
1396 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1398 BufferParams & param = controller().params();
1400 param.temp_bullet(current_bullet_depth).
1401 setText(getString(bullets_->input_latex));
1405 void FormDocument::BulletDepth(FL_OBJECT * ob)
1407 /* Should I do the following: */
1408 /* 1. change to the panel that the current bullet belongs in */
1409 /* 2. show that bullet as selected */
1410 /* 3. change the size setting to the size of the bullet in Q.*/
1411 /* 4. display the latex equivalent in the latex box */
1413 /* I'm inclined to just go with 3 and 4 at the moment and */
1414 /* maybe try to support the others later */
1415 BufferParams & param = controller().params();
1418 if (ob == bullets_->radio_depth_1)
1420 else if (ob == bullets_->radio_depth_2)
1422 else if (ob == bullets_->radio_depth_3)
1424 else if (ob == bullets_->radio_depth_4)
1427 switch (fl_get_button_numb(ob)) {
1429 // right mouse button resets to default
1430 param.temp_bullet(data) = ITEMIZE_DEFAULTS[data];
1432 current_bullet_depth = data;
1433 fl_set_input(bullets_->input_latex,
1434 param.temp_bullet(data).getText().c_str());
1435 fl_set_choice(bullets_->choice_size,
1436 param.temp_bullet(data).getSize() + 2);
1441 void FormDocument::BulletPanel(FL_OBJECT * ob)
1443 /* Here we have to change the background pixmap to that selected */
1444 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1447 if (ob == bullets_->radio_panel_standard)
1449 else if (ob == bullets_->radio_panel_maths)
1451 else if (ob == bullets_->radio_panel_ding2)
1453 else if (ob == bullets_->radio_panel_ding3)
1455 else if (ob == bullets_->radio_panel_ding4)
1457 else if (ob == bullets_->radio_panel_ding1)
1460 if (data != current_bullet_panel) {
1461 fl_freeze_form(bullets_->form);
1462 current_bullet_panel = data;
1464 /* free the current pixmap */
1465 fl_free_bmtable_pixmap(bullets_->bmtable_panel);
1467 if (ob == bullets_->radio_panel_standard) {
1468 new_panel = "standard";
1469 } else if (ob == bullets_->radio_panel_maths ) {
1470 new_panel = "amssymb";
1471 } else if (ob == bullets_->radio_panel_ding2) {
1472 new_panel = "psnfss1";
1473 } else if (ob == bullets_->radio_panel_ding3) {
1474 new_panel = "psnfss2";
1475 } else if (ob == bullets_->radio_panel_ding4) {
1476 new_panel = "psnfss3";
1477 } else if (ob == bullets_->radio_panel_ding1) {
1478 new_panel = "psnfss4";
1480 /* something very wrong happened */
1481 // play it safe for now but should be an exception
1482 current_bullet_panel = 0; // standard panel
1483 new_panel = "standard";
1485 new_panel += ".xpm";
1486 fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6,
1487 LibFileSearch("images", new_panel).c_str());
1488 fl_redraw_object(bullets_->bmtable_panel);
1489 fl_unfreeze_form(bullets_->form);
1494 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1496 /* handle the user input by setting the current bullet depth's pixmap */
1497 /* to that extracted from the current chosen position of the BMTable */
1498 /* Don't forget to free the button's old pixmap first. */
1500 BufferParams & param = controller().params();
1501 int bmtable_button = fl_get_bmtable(ob);
1503 /* try to keep the button held down till another is pushed */
1504 /* fl_set_bmtable(ob, 1, bmtable_button); */
1505 param.temp_bullet(current_bullet_depth).setFont(current_bullet_panel);
1506 param.temp_bullet(current_bullet_depth).setCharacter(bmtable_button);
1507 fl_set_input(bullets_->input_latex,
1508 param.temp_bullet(current_bullet_depth).getText().c_str());
1512 void FormDocument::CheckChoiceClass()
1514 BufferParams & params = controller().params();
1516 lyx::textclass_type const tc =
1517 fl_get_combox(class_->combox_class) - 1;
1519 if (controller().loadTextclass(tc)) {
1520 params.textclass = tc;
1522 if (lyxrc.auto_reset_options) {
1523 params.useClassDefaults();
1524 UpdateLayoutDocument(params);
1526 // update the params which are needed in any case
1527 // (fontsizes, pagestyle)
1528 UpdateClassParams(params);
1532 int const revert = int(params.textclass);
1533 fl_set_combox(class_->combox_class, revert + 1);
1538 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1544 class_update(params);
1545 paper_update(params);
1546 language_update(params);
1547 options_update(params);
1548 bullets_update(params);