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 "ControlDocument.h"
18 #include "forms/form_document.h"
21 #include "checkedwidgets.h"
22 #include "ColorHandler.h"
24 #include "FormColorpicker.h"
25 #include "input_validators.h" // fl_unsigned_float_filter
27 #include "xforms_helpers.h"
30 #include "controllers/ButtonController.h"
31 #include "controllers/frnt_lang.h"
32 #include "controllers/helper_funcs.h"
35 #include "bufferparams.h"
38 #include "lyxtextclasslist.h"
39 #include "tex-strings.h"
42 #include "support/tostr.h"
43 #include "support/lstrings.h" // contains, getStringFromVector
44 #include "support/filetools.h" // LibFileSearch
48 #include <boost/bind.hpp>
52 using lyx::support::bformat;
53 using lyx::support::contains;
54 using lyx::support::getStringFromVector;
55 using lyx::support::getVectorFromString;
56 using lyx::support::LibFileSearch;
67 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
68 bool const scalableTabfolders = false;
70 bool const scalableTabfolders = true;
77 typedef FormCB<ControlDocument, FormDB<FD_document> > base_class;
79 FormDocument::FormDocument()
80 : base_class(_("Document Settings"), scalableTabfolders),
81 ActCell(0), Confirmed(0),
82 current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
86 void FormDocument::redraw()
88 if (form() && form()->visible)
89 fl_redraw_form(form());
93 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
94 if (outer_form && outer_form->visible)
95 fl_redraw_form(outer_form);
99 void FormDocument::build()
102 dialog_.reset(build_document(this));
104 // Allow the base class to control messages
105 setMessageWidget(dialog_->text_warning);
107 // Manage the restore, ok, apply, restore and cancel/close buttons
108 bcview().setOK(dialog_->button_ok);
109 bcview().setApply(dialog_->button_apply);
110 bcview().setCancel(dialog_->button_close);
111 bcview().setRestore(dialog_->button_restore);
113 // the document class form
114 class_.reset(build_document_class(this));
116 // disable for read-only documents
117 bcview().addReadOnly(class_->combox_class);
118 bcview().addReadOnly(class_->radio_indent);
119 bcview().addReadOnly(class_->radio_skip);
120 bcview().addReadOnly(class_->choice_pagestyle);
121 bcview().addReadOnly(class_->choice_fonts);
122 bcview().addReadOnly(class_->choice_fontsize);
123 bcview().addReadOnly(class_->radio_sides_one);
124 bcview().addReadOnly(class_->radio_sides_two);
125 bcview().addReadOnly(class_->radio_columns_one);
126 bcview().addReadOnly(class_->radio_columns_two);
127 bcview().addReadOnly(class_->input_extra);
128 bcview().addReadOnly(class_->input_skip);
129 bcview().addReadOnly(class_->choice_skip);
130 bcview().addReadOnly(class_->choice_spacing);
131 bcview().addReadOnly(class_->input_spacing);
133 // check validity of "length + unit" input
134 addCheckedGlueLength(bcview(), class_->input_skip,
135 class_->choice_skip);
137 // trigger an input event for cut&paste with middle mouse button.
138 setPrehandler(class_->input_extra);
139 setPrehandler(class_->input_skip);
140 setPrehandler(class_->input_spacing);
142 fl_set_input_return(class_->input_extra, FL_RETURN_CHANGED);
143 fl_set_input_return(class_->input_skip, FL_RETURN_CHANGED);
144 fl_set_input_return(class_->input_spacing, FL_RETURN_CHANGED);
148 // Fill the combox and choices.
149 obj = class_->combox_class;
150 LyXTextClassList::const_iterator tit = textclasslist.begin();
151 LyXTextClassList::const_iterator tend = textclasslist.end();
152 for (; tit != tend; ++tit) {
153 if (tit->isTeXClassAvailable()) {
154 fl_addto_combox(obj, tit->description().c_str());
156 string item = bformat(_("Unavailable: %1$s"), tit->description());
157 fl_addto_combox(obj, item.c_str());
160 fl_set_combox_browser_height(obj, 400);
162 fl_addto_choice(class_->choice_spacing,
163 _(" Single | OneHalf | Double | Custom ").c_str());
164 fl_addto_choice(class_->choice_fontsize, "default|10|11|12");
165 for (int n = 0; tex_fonts[n][0]; ++n) {
166 fl_addto_choice(class_->choice_fonts,tex_fonts[n]);
169 // Create the contents of the unit choices; don't include the
171 vector<string> units_vec = getLatexUnits();
172 vector<string>::iterator ret =
173 std::remove_if(units_vec.begin(),
175 bind(contains<char>, _1, '%'));
176 units_vec.erase(ret, units_vec.end());
178 string const units = getStringFromVector(units_vec, "|");
180 fl_addto_choice(class_->choice_pagestyle,
181 "default|empty|plain|headings|fancy");
182 fl_addto_choice(class_->choice_skip,
183 _(" SmallSkip | MedSkip | BigSkip | Length ").c_str());
184 fl_addto_choice(class_->choice_skip_units, units.c_str());
186 // Set input filters on doc spacing to make it accept only
188 fl_set_input_filter(class_->input_spacing,
189 fl_unsigned_float_filter);
191 // disable for read-only documents
192 bcview().addReadOnly(dialog_->button_save_defaults);
193 bcview().addReadOnly(dialog_->button_reset_defaults);
195 // the document paper form
196 paper_.reset(build_document_paper(this));
198 // disable for read-only documents
199 bcview().addReadOnly(paper_->choice_paperpackage);
200 bcview().addReadOnly(paper_->radio_portrait);
201 bcview().addReadOnly(paper_->radio_landscape);
202 bcview().addReadOnly(paper_->choice_papersize);
203 bcview().addReadOnly(paper_->check_use_geometry);
204 bcview().addReadOnly(paper_->input_custom_width);
205 bcview().addReadOnly(paper_->input_custom_height);
206 bcview().addReadOnly(paper_->input_top_margin);
207 bcview().addReadOnly(paper_->input_bottom_margin);
208 bcview().addReadOnly(paper_->input_inner_margin);
209 bcview().addReadOnly(paper_->input_outer_margin);
210 bcview().addReadOnly(paper_->input_head_height);
211 bcview().addReadOnly(paper_->input_head_sep);
212 bcview().addReadOnly(paper_->input_foot_skip);
214 // check validity of "length + unit" input
215 addCheckedGlueLength(bcview(), paper_->input_custom_width);
216 addCheckedGlueLength(bcview(), paper_->input_custom_height);
217 addCheckedGlueLength(bcview(), paper_->input_top_margin);
218 addCheckedGlueLength(bcview(), paper_->input_bottom_margin);
219 addCheckedGlueLength(bcview(), paper_->input_inner_margin);
220 addCheckedGlueLength(bcview(), paper_->input_outer_margin);
221 addCheckedGlueLength(bcview(), paper_->input_head_height);
222 addCheckedGlueLength(bcview(), paper_->input_head_sep);
223 addCheckedGlueLength(bcview(), paper_->input_foot_skip);
225 // trigger an input event for cut&paste with middle mouse button.
226 setPrehandler(paper_->input_custom_width);
227 setPrehandler(paper_->input_custom_height);
228 setPrehandler(paper_->input_top_margin);
229 setPrehandler(paper_->input_bottom_margin);
230 setPrehandler(paper_->input_inner_margin);
231 setPrehandler(paper_->input_outer_margin);
232 setPrehandler(paper_->input_head_height);
233 setPrehandler(paper_->input_head_sep);
234 setPrehandler(paper_->input_foot_skip);
236 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
237 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
238 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
239 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
240 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
241 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
242 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
243 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
244 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
246 fl_addto_choice(paper_->choice_papersize,
247 _(" Default | Custom | US letter | US legal "
248 "| US executive | A3 | A4 | A5 "
249 "| B3 | B4 | B5 ").c_str());
250 fl_addto_choice(paper_->choice_paperpackage,
253 "| Very small Margins "
254 "| Very wide Margins ").c_str());
256 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
257 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
258 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
259 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
260 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
261 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
262 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
263 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
264 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
266 // the document language form
267 language_.reset(build_document_language(this));
269 // disable for read-only documents
270 bcview().addReadOnly(language_->combox_language);
271 bcview().addReadOnly(language_->choice_inputenc);
272 bcview().addReadOnly(language_->choice_quotes_language);
273 bcview().addReadOnly(language_->radio_single);
274 bcview().addReadOnly(language_->radio_double);
276 fl_addto_choice(language_->choice_inputenc,
277 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
278 "|koi8-r|koi8-u|cp866|cp1251|iso88595|pt154");
280 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
281 // Store the identifiers for later
282 lang_ = getSecond(langs);
284 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
285 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
286 for (; lit != lend; ++lit) {
287 fl_addto_combox(language_->combox_language,
290 fl_set_combox_browser_height(language_->combox_language, 400);
292 fl_addto_choice(language_->choice_quotes_language,
293 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
294 " <<text>> | >>text<< ").c_str());
296 // the document options form
297 options_.reset(build_document_options(this));
299 // disable for read-only documents
300 bcview().addReadOnly(options_->counter_secnumdepth);
301 bcview().addReadOnly(options_->counter_tocdepth);
302 bcview().addReadOnly(options_->choice_ams_math);
303 bcview().addReadOnly(options_->check_use_natbib);
304 bcview().addReadOnly(options_->choice_citation_format);
305 bcview().addReadOnly(options_->input_float_placement);
306 bcview().addReadOnly(options_->choice_postscript_driver);
308 // trigger an input event for cut&paste with middle mouse button.
309 setPrehandler(options_->input_float_placement);
311 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
313 fl_addto_choice(options_->choice_ams_math,
314 _(" Never | Automatically | Yes ").c_str());
316 for (int n = 0; tex_graphics[n][0]; ++n) {
317 fl_addto_choice(options_->choice_postscript_driver,
320 fl_addto_choice(options_->choice_citation_format,
321 _(" Author-year | Numerical ").c_str());
323 // the document bullets form
324 bullets_.reset(build_document_bullet(this));
326 // disable for read-only documents
327 bcview().addReadOnly(bullets_->radio_depth_1);
328 bcview().addReadOnly(bullets_->radio_depth_2);
329 bcview().addReadOnly(bullets_->radio_depth_3);
330 bcview().addReadOnly(bullets_->radio_depth_4);
331 bcview().addReadOnly(bullets_->radio_panel_standard);
332 bcview().addReadOnly(bullets_->radio_panel_maths);
333 bcview().addReadOnly(bullets_->radio_panel_ding1);
334 bcview().addReadOnly(bullets_->radio_panel_ding2);
335 bcview().addReadOnly(bullets_->radio_panel_ding3);
336 bcview().addReadOnly(bullets_->radio_panel_ding4);
337 bcview().addReadOnly(bullets_->bmtable_panel);
338 bcview().addReadOnly(bullets_->choice_size);
339 bcview().addReadOnly(bullets_->input_latex);
341 // trigger an input event for cut&paste with middle mouse button.
342 setPrehandler(bullets_->input_latex);
344 fl_set_input_return(bullets_->input_latex, FL_RETURN_CHANGED);
346 fl_addto_choice(bullets_->choice_size,
347 _(" Default | Tiny | Smallest | Smaller "
348 "| Small | Normal | Large | Larger | Largest "
349 "| Huge | Huger ").c_str());
350 fl_set_choice(bullets_->choice_size, 1);
352 fl_set_input_maxchars(bullets_->input_latex, 80);
354 string const bmtablefile = LibFileSearch("images", "standard", "xpm");
355 fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6,
356 bmtablefile.c_str());
358 picker_.reset(new FormColorpicker);
360 // the document branches form
361 branch_.reset(build_document_branch(this));
363 fl_set_object_color(branch_->button_color,
364 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
366 bcview().addReadOnly(branch_->input_all_branches);
367 bcview().addReadOnly(branch_->button_add_branch);
368 bcview().addReadOnly(branch_->button_remove_branch);
369 bcview().addReadOnly(branch_->button_select);
370 bcview().addReadOnly(branch_->button_deselect);
371 bcview().addReadOnly(branch_->button_modify);
372 bcview().addReadOnly(branch_->browser_all_branches);
374 // set up the tooltips for branches form
375 string str = _("Enter the name of a new branch.");
376 tooltips().init(branch_->input_all_branches, str);
377 str = _("Add a new branch to the document.");
378 tooltips().init(branch_->button_add_branch, str);
379 str = _("Remove the selected branch from the document.");
380 tooltips().init(branch_->button_remove_branch, str);
381 str = _("Activate the selected branch for output.");
382 tooltips().init(branch_->button_select, str);
383 str = _("Deactivate the selected activated branch.");
384 tooltips().init(branch_->button_deselect, str);
385 str = _("Available branches for this document.");
386 tooltips().init(branch_->browser_all_branches, str);
387 str = _("Activated branches. Content will occur in the document\'s output");
388 tooltips().init(branch_->browser_selection, str);
389 str = _("Modify background color of branch inset");
390 tooltips().init(branch_->button_modify, str);
391 str = _("Background color of branch inset");
392 tooltips().init(branch_->button_color, str);
394 // Handle middle mouse paint:
395 setPrehandler(branch_->input_all_branches);
396 fl_set_input_return(branch_->input_all_branches, FL_RETURN_CHANGED);
398 // Enable the tabfolder to be rescaled correctly.
399 if (scalableTabfolders)
400 fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
403 fl_addto_tabfolder(dialog_->tabfolder,_("Document").c_str(),
405 fl_addto_tabfolder(dialog_->tabfolder,_("Paper").c_str(),
407 fl_addto_tabfolder(dialog_->tabfolder,_("Language").c_str(),
409 fl_addto_tabfolder(dialog_->tabfolder,_("Extra").c_str(),
411 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets").c_str(),
414 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
415 lyxerr << _("Your version of libXpm is older than 4.7.\n"
416 "The `bullet' tab of the document dialog "
417 "has been disabled") << '\n';
418 fl_deactivate_object(fbullet);
419 fl_set_object_lcol(fbullet, FL_INACTIVE);
422 fl_addto_tabfolder(dialog_->tabfolder,_("Branches").c_str(),
427 void FormDocument::apply()
429 BufferParams & params = controller().params();
433 language_apply(params);
434 options_apply(params);
435 bullets_apply(params);
436 branch_apply(params);
440 void FormDocument::update()
447 BufferParams const & params = controller().params();
449 class_update(params);
450 paper_update(params);
451 language_update(params);
452 options_update(params);
453 bullets_update(params);
454 branch_update(params);
458 ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
460 if (ob == bullets_->choice_size) {
461 ChoiceBulletSize(ob, 0);
463 } else if (ob == bullets_->input_latex) {
464 InputBulletLaTeX(ob, 0);
466 } else if (ob == bullets_->radio_depth_1 ||
467 ob == bullets_->radio_depth_2 ||
468 ob == bullets_->radio_depth_3 ||
469 ob == bullets_->radio_depth_4) {
472 } else if (ob == bullets_->radio_panel_standard ||
473 ob == bullets_->radio_panel_maths ||
474 ob == bullets_->radio_panel_ding1 ||
475 ob == bullets_->radio_panel_ding2 ||
476 ob == bullets_->radio_panel_ding3 ||
477 ob == bullets_->radio_panel_ding4) {
480 } else if (ob == bullets_->bmtable_panel) {
481 BulletBMTable(ob, 0);
483 } else if (ob == class_->choice_spacing) {
484 setEnabled(class_->input_spacing,
485 fl_get_choice(class_->choice_spacing) == 4);
487 } else if (ob == class_->combox_class) {
489 } else if (ob == class_->radio_skip ||
490 ob == class_->radio_indent ||
491 ob == class_->choice_skip) {
492 bool const skip_used = fl_get_button(class_->radio_skip);
493 setEnabled(class_->choice_skip, skip_used);
495 bool const length_input =
496 fl_get_choice(class_->choice_skip) == 4;
497 setEnabled(class_->input_skip,
498 skip_used && length_input);
499 setEnabled(class_->choice_skip_units,
500 skip_used && length_input);
502 // Default unit choice is cm if metric, inches if US paper.
503 // If papersize is default, check the lyxrc-settings
504 int const paperchoice = fl_get_choice(paper_->choice_papersize);
505 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
506 || paperchoice == 2 || paperchoice > 5;
507 string const default_unit = metric ? "cm" : "in";
508 if (getString(class_->input_skip).empty())
509 fl_set_choice_text(class_->choice_skip_units,
510 default_unit.c_str());
512 } else if (ob == options_->check_use_natbib) {
513 setEnabled(options_->choice_citation_format,
514 fl_get_button(options_->check_use_natbib));
516 } else if (ob == branch_->browser_all_branches ||
517 ob == branch_->browser_selection ||
518 ob == branch_->button_add_branch ||
519 ob == branch_->button_remove_branch ||
520 ob == branch_->button_modify ||
521 ob == branch_->button_select ||
522 ob == branch_->button_deselect ||
523 ob == branch_->button_deselect) {
525 } else if (ob == dialog_->button_save_defaults) {
527 controller().saveAsDefault();
529 } else if (ob == dialog_->button_reset_defaults) {
530 BufferParams & params = controller().params();
531 params.textclass = fl_get_combox(class_->combox_class) - 1;
532 params.useClassDefaults();
533 UpdateLayoutDocument(params);
535 } else if (ob == paper_->radio_landscape) {
536 fl_set_choice(paper_->choice_paperpackage,
539 } else if (ob == paper_->choice_papersize) {
540 int const paperchoice = fl_get_choice(paper_->choice_papersize);
541 bool const defsize = paperchoice == 1;
542 bool const custom = paperchoice == 2;
543 bool const a3size = paperchoice == 6;
544 bool const b3size = paperchoice == 9;
545 bool const b4size = paperchoice == 10;
548 fl_set_button(paper_->radio_portrait, 1);
550 bool const use_geom = (custom || a3size || b3size || b4size);
552 fl_set_button(paper_->check_use_geometry, int(use_geom));
554 setEnabled(paper_->input_top_margin, use_geom);
555 setEnabled(paper_->input_bottom_margin, use_geom);
556 setEnabled(paper_->input_inner_margin, use_geom);
557 setEnabled(paper_->input_outer_margin, use_geom);
558 setEnabled(paper_->input_head_height, use_geom);
559 setEnabled(paper_->input_head_sep, use_geom);
560 setEnabled(paper_->input_foot_skip, use_geom);
561 setEnabled(paper_->choice_top_margin_units, use_geom);
562 setEnabled(paper_->choice_bottom_margin_units, use_geom);
563 setEnabled(paper_->choice_inner_margin_units, use_geom);
564 setEnabled(paper_->choice_outer_margin_units, use_geom);
565 setEnabled(paper_->choice_head_height_units, use_geom);
566 setEnabled(paper_->choice_head_sep_units, use_geom);
567 setEnabled(paper_->choice_foot_skip_units, use_geom);
568 setEnabled(paper_->choice_custom_width_units, use_geom);
569 setEnabled(paper_->choice_custom_height_units, use_geom);
571 setEnabled(paper_->input_custom_width, custom);
572 setEnabled(paper_->input_custom_height, custom);
573 setEnabled(paper_->choice_custom_width_units, custom);
574 setEnabled(paper_->choice_custom_height_units, custom);
575 setEnabled(paper_->radio_portrait, !custom);
576 setEnabled(paper_->radio_landscape, !custom);
578 // Default unit choice is cm if metric, inches if US paper.
579 // If papersize is default, use the lyxrc-settings
580 bool const metric = (defsize && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
581 || paperchoice == 2 || paperchoice > 5;
582 string const default_unit = metric ? "cm" : "in";
583 if (getString(paper_->input_custom_width).empty())
584 fl_set_choice_text(paper_->choice_custom_width_units,
585 default_unit.c_str());
586 if (getString(paper_->input_custom_height).empty())
587 fl_set_choice_text(paper_->choice_custom_height_units,
588 default_unit.c_str());
589 if (getString(paper_->input_top_margin).empty())
590 fl_set_choice_text(paper_->choice_top_margin_units,
591 default_unit.c_str());
592 if (getString(paper_->input_bottom_margin).empty())
593 fl_set_choice_text(paper_->choice_bottom_margin_units,
594 default_unit.c_str());
595 if (getString(paper_->input_inner_margin).empty())
596 fl_set_choice_text(paper_->choice_inner_margin_units,
597 default_unit.c_str());
598 if (getString(paper_->input_outer_margin).empty())
599 fl_set_choice_text(paper_->choice_outer_margin_units,
600 default_unit.c_str());
601 if (getString(paper_->input_head_height).empty())
602 fl_set_choice_text(paper_->choice_head_height_units,
603 default_unit.c_str());
604 if (getString(paper_->input_head_sep).empty())
605 fl_set_choice_text(paper_->choice_head_sep_units,
606 default_unit.c_str());
607 if (getString(paper_->input_foot_skip).empty())
608 fl_set_choice_text(paper_->choice_foot_skip_units,
609 default_unit.c_str());
611 } else if (ob == paper_->choice_paperpackage &&
612 fl_get_choice(paper_->choice_paperpackage) != 1) {
614 fl_set_button(paper_->check_use_geometry, 0);
615 setEnabled(paper_->input_top_margin, false);
616 setEnabled(paper_->input_bottom_margin, false);
617 setEnabled(paper_->input_inner_margin, false);
618 setEnabled(paper_->input_outer_margin, false);
619 setEnabled(paper_->input_head_height, false);
620 setEnabled(paper_->input_head_sep, false);
621 setEnabled(paper_->input_foot_skip, false);
622 setEnabled(paper_->choice_top_margin_units, false);
623 setEnabled(paper_->choice_bottom_margin_units, false);
624 setEnabled(paper_->choice_inner_margin_units, false);
625 setEnabled(paper_->choice_outer_margin_units, false);
626 setEnabled(paper_->choice_head_height_units, false);
627 setEnabled(paper_->choice_head_sep_units, false);
628 setEnabled(paper_->choice_foot_skip_units, false);
630 } else if (ob == paper_->check_use_geometry) {
631 // don't allow switching geometry off in custom papersize
632 // mode nor in A3, B3, and B4
633 int const choice = fl_get_choice(paper_->choice_papersize);
634 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
635 fl_set_button(paper_->check_use_geometry, 1);
637 fl_set_choice(paper_->choice_paperpackage,
640 bool const use_geom = fl_get_button(paper_->check_use_geometry);
641 setEnabled(paper_->input_top_margin, use_geom);
642 setEnabled(paper_->input_bottom_margin, use_geom);
643 setEnabled(paper_->input_inner_margin, use_geom);
644 setEnabled(paper_->input_outer_margin, use_geom);
645 setEnabled(paper_->input_head_height, use_geom);
646 setEnabled(paper_->input_head_sep, use_geom);
647 setEnabled(paper_->input_foot_skip, use_geom);
648 setEnabled(paper_->choice_top_margin_units, use_geom);
649 setEnabled(paper_->choice_bottom_margin_units, use_geom);
650 setEnabled(paper_->choice_inner_margin_units, use_geom);
651 setEnabled(paper_->choice_outer_margin_units, use_geom);
652 setEnabled(paper_->choice_head_height_units, use_geom);
653 setEnabled(paper_->choice_head_sep_units, use_geom);
654 setEnabled(paper_->choice_foot_skip_units, use_geom);
657 if (ob == paper_->choice_papersize || ob == paper_->radio_portrait
658 || ob == paper_->radio_landscape) {
659 // either default papersize (preferences) or document
660 // papersize has to be A4
661 bool const enable = ( fl_get_choice(paper_->choice_papersize) == 1
662 && lyxrc.default_papersize == PAPER_A4PAPER )
663 || fl_get_choice(paper_->choice_papersize) == 7;
665 fl_set_choice(paper_->choice_paperpackage,
667 setEnabled(paper_->choice_paperpackage,
668 enable && fl_get_button(paper_->radio_portrait));
671 return ButtonPolicy::SMI_VALID;
675 void FormDocument::rebuild_all_branches_browser()
677 typedef BranchList::const_iterator const_iterator;
679 fl_clear_browser(branch_->browser_all_branches);
681 const_iterator const begin = branchlist_.begin();
682 const_iterator const end = branchlist_.end();
683 for (const_iterator it = begin; it != end; ++it) {
684 fl_addto_browser(branch_->browser_all_branches,
685 it->getBranch().c_str());
690 void FormDocument::rebuild_selected_branches_browser()
692 typedef BranchList::const_iterator const_iterator;
694 fl_clear_browser(branch_->browser_selection);
696 const_iterator const begin = branchlist_.begin();
697 const_iterator const end = branchlist_.end();
698 for (const_iterator it = begin; it != end; ++it) {
699 if (it->getSelected())
700 fl_addto_browser(branch_->browser_selection,
701 it->getBranch().c_str());
708 RGBColor get_current_color(FL_OBJECT * browser, BranchList const & branchlist)
710 BOOST_ASSERT(browser && browser->objclass == FL_BROWSER);
714 int const i = fl_get_browser(browser);
715 string const branch_name = fl_get_browser_line(browser, i);
716 Branch const * branch = branchlist.find(branch_name);
720 string const x11hexname = branch->getColor();
721 if (x11hexname[0] == '#') {
722 color = RGBColor(x11hexname);
724 fl_getmcolor(FL_COL1, &color.r, &color.g, &color.b);
732 void FormDocument::branch_input(FL_OBJECT * ob)
734 if (ob == branch_->button_add_branch) {
735 string const new_branch =
736 getString(branch_->input_all_branches);
738 if (!new_branch.empty() && branchlist_.add(new_branch)) {
740 fl_set_input(branch_->input_all_branches, "");
741 rebuild_all_branches_browser();
744 } else if (ob == branch_->button_remove_branch) {
745 unsigned i = fl_get_browser(branch_->browser_all_branches);
746 string const current_branch =
747 fl_get_browser_line(branch_->browser_all_branches, i);
748 if (!current_branch.empty() &&
749 branchlist_.remove(current_branch)) {
751 rebuild_all_branches_browser();
752 rebuild_selected_branches_browser();
755 } else if (ob == branch_->button_select ||
756 ob == branch_->button_deselect) {
758 bool const selected = ob == branch_->button_select;
760 int const i = fl_get_browser(branch_->browser_all_branches);
761 string const current_branch =
762 fl_get_browser_line(branch_->browser_all_branches, i);
764 Branch * branch = branchlist_.find(current_branch);
766 if (branch && branch->setSelected(selected))
767 rebuild_selected_branches_browser();
769 } else if (ob == branch_->button_modify) {
770 RGBColor const before =
771 get_current_color(branch_->browser_all_branches,
773 RGBColor const after = picker_->requestColor(before);
774 if (before != after) {
775 fl_mapcolor(GUI_COLOR_CHOICE,
776 after.r, after.g, after.b);
777 fl_redraw_object(branch_->button_color);
779 string const branch_name =
780 getString(branch_->browser_all_branches);
781 Branch * branch = branchlist_.find(branch_name);
783 branch->setColor(X11hexname(after));
786 } else if (ob == branch_->browser_all_branches) {
788 get_current_color(branch_->browser_all_branches,
791 fl_mapcolor(GUI_COLOR_CHOICE, rgb.r, rgb.g, rgb.b);
792 fl_redraw_object(branch_->button_color);
794 setEnabled(branch_->button_select,
795 (fl_get_browser(branch_->browser_all_branches) > 0));
796 setEnabled(branch_->button_deselect,
797 (fl_get_browser(branch_->browser_selection) > 0));
798 setEnabled(branch_->button_remove_branch,
799 (fl_get_browser(branch_->browser_all_branches) > 0));
800 setEnabled(branch_->button_modify,
801 (fl_get_browser(branch_->browser_all_branches) > 0));
805 bool FormDocument::class_apply(BufferParams ¶ms)
809 // If default skip is a "Length" but there's no text in the
810 // input field, reset the kind to "MedSkip", which is the default.
811 if (fl_get_choice(class_->choice_skip) == 4 &&
812 getString(class_->input_skip).empty()) {
813 fl_set_choice(class_->choice_skip, 2);
815 params.fonts = getString(class_->choice_fonts);
816 params.fontsize = getString(class_->choice_fontsize);
817 params.pagestyle = getString(class_->choice_pagestyle);
819 params.textclass = fl_get_combox(class_->combox_class) - 1;
821 BufferParams::PARSEP tmpsep = params.paragraph_separation;
822 if (fl_get_button(class_->radio_indent))
823 params.paragraph_separation = BufferParams::PARSEP_INDENT;
825 params.paragraph_separation = BufferParams::PARSEP_SKIP;
826 if (tmpsep != params.paragraph_separation)
829 VSpace tmpdefskip = params.getDefSkip();
830 switch (fl_get_choice(class_->choice_skip)) {
832 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
835 params.setDefSkip(VSpace(VSpace::MEDSKIP));
838 params.setDefSkip(VSpace(VSpace::BIGSKIP));
842 string const length =
843 getLengthFromWidgets(class_->input_skip,
844 class_->choice_skip_units);
846 params.setDefSkip(VSpace(LyXGlueLength(length)));
850 // DocumentDefskipCB assures that this never happens
851 params.setDefSkip(VSpace(VSpace::MEDSKIP));
854 if (!(tmpdefskip == params.getDefSkip()))
857 if (fl_get_button(class_->radio_columns_two))
861 if (fl_get_button(class_->radio_sides_two))
862 params.sides = LyXTextClass::TwoSides;
864 params.sides = LyXTextClass::OneSide;
866 Spacing tmpSpacing = params.spacing();
867 switch (fl_get_choice(class_->choice_spacing)) {
869 lyxerr[Debug::INFO] << "Spacing: SINGLE" << endl;
870 params.spacing().set(Spacing::Single);
873 lyxerr[Debug::INFO] << "Spacing: ONEHALF" << endl;
874 params.spacing().set(Spacing::Onehalf);
877 lyxerr[Debug::INFO] << "Spacing: DOUBLE" << endl;
878 params.spacing().set(Spacing::Double);
881 lyxerr[Debug::INFO] << "Spacing: OTHER" << endl;
882 params.spacing().set(Spacing::Other,
883 getString(class_->input_spacing));
886 if (tmpSpacing != params.spacing())
889 params.options = getString(class_->input_extra);
895 void FormDocument::paper_apply(BufferParams & params)
897 params.papersize2 = VMARGIN_PAPER_TYPE(fl_get_choice(paper_->choice_papersize) - 1);
899 params.paperpackage =
900 PAPER_PACKAGES(fl_get_choice(paper_->choice_paperpackage) - 1);
902 // set params.papersize from params.papersize2 and params.paperpackage
903 params.setPaperStuff();
905 params.use_geometry = fl_get_button(paper_->check_use_geometry);
907 if (fl_get_button(paper_->radio_landscape))
908 params.orientation = ORIENTATION_LANDSCAPE;
910 params.orientation = ORIENTATION_PORTRAIT;
913 getLengthFromWidgets(paper_->input_custom_width,
914 paper_->choice_custom_width_units);
917 getLengthFromWidgets(paper_->input_custom_height,
918 paper_->choice_custom_height_units);
921 getLengthFromWidgets(paper_->input_inner_margin,
922 paper_->choice_inner_margin_units);
925 getLengthFromWidgets(paper_->input_top_margin,
926 paper_->choice_top_margin_units);
929 getLengthFromWidgets(paper_->input_outer_margin,
930 paper_->choice_outer_margin_units);
932 params.bottommargin =
933 getLengthFromWidgets(paper_->input_bottom_margin,
934 paper_->choice_bottom_margin_units);
937 getLengthFromWidgets(paper_->input_head_height,
938 paper_->choice_head_height_units);
941 getLengthFromWidgets(paper_->input_head_sep,
942 paper_->choice_head_sep_units);
945 getLengthFromWidgets(paper_->input_foot_skip,
946 paper_->choice_foot_skip_units);
950 bool FormDocument::language_apply(BufferParams & params)
952 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
955 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
957 lga = InsetQuotes::EnglishQ;
960 lga = InsetQuotes::SwedishQ;
963 lga = InsetQuotes::GermanQ;
966 lga = InsetQuotes::PolishQ;
969 lga = InsetQuotes::FrenchQ;
972 lga = InsetQuotes::DanishQ;
975 params.quotes_language = lga;
976 if (fl_get_button(language_->radio_single))
977 params.quotes_times = InsetQuotes::SingleQ;
979 params.quotes_times = InsetQuotes::DoubleQ;
981 int const pos = fl_get_combox(language_->combox_language);
982 Language const * new_language = languages.getLanguage(lang_[pos-1]);
984 new_language = default_language;
986 params.language = new_language;
987 params.inputenc = getString(language_->choice_inputenc);
993 bool FormDocument::options_apply(BufferParams & params)
997 params.graphicsDriver = getString(options_->choice_postscript_driver);
998 params.use_amsmath = static_cast<BufferParams::AMS>(
999 fl_get_choice(options_->choice_ams_math) - 1);
1000 params.use_natbib = fl_get_button(options_->check_use_natbib);
1001 params.use_numerical_citations =
1002 fl_get_choice(options_->choice_citation_format) - 1;
1004 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
1005 if (params.secnumdepth != tmpchar)
1007 params.secnumdepth = tmpchar;
1009 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
1011 params.float_placement =
1012 getString(options_->input_float_placement);
1018 void FormDocument::bullets_apply(BufferParams & params)
1020 /* update the bullet settings */
1021 BufferParams & buf_params = controller().params();
1023 for (int i = 0; i < 4; ++i) {
1024 params.user_defined_bullet(i) = buf_params.temp_bullet(i);
1029 void FormDocument::branch_apply(BufferParams & params)
1031 params.branchlist() = branchlist_;
1035 void FormDocument::UpdateClassParams(BufferParams const & params)
1037 // These are the params that have to be updated on any class change
1038 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
1040 LyXTextClass const & tclass = textclasslist[params.textclass];
1042 fl_set_combox(class_->combox_class, params.textclass + 1);
1043 fl_clear_choice(class_->choice_fontsize);
1044 fl_addto_choice(class_->choice_fontsize, "default");
1045 fl_addto_choice(class_->choice_fontsize,
1046 tclass.opt_fontsize().c_str());
1047 fl_set_choice_text(class_->choice_fontsize,
1048 params.fontsize.c_str());
1049 fl_clear_choice(class_->choice_pagestyle);
1050 fl_addto_choice(class_->choice_pagestyle, "default");
1051 fl_addto_choice(class_->choice_pagestyle,
1052 tclass.opt_pagestyle().c_str());
1053 fl_set_choice_text(class_->choice_pagestyle,
1054 params.pagestyle.c_str());
1056 fl_set_input(class_->input_extra, tclass.options().c_str());
1059 void FormDocument::class_update(BufferParams const & params)
1064 UpdateClassParams(params);
1066 fl_set_choice_text(class_->choice_fonts, params.fonts.c_str());
1068 bool const indent = params.paragraph_separation == BufferParams::PARSEP_INDENT;
1069 fl_set_button(class_->radio_indent, indent);
1070 fl_set_button(class_->radio_skip, !indent);
1074 pos = 2; // VSpace::MEDSKIP is default
1076 switch (params.getDefSkip().kind()) {
1077 case VSpace::LENGTH:
1080 case VSpace::BIGSKIP:
1083 case VSpace::SMALLSKIP:
1086 case VSpace::MEDSKIP:
1092 fl_set_choice (class_->choice_skip, pos);
1094 bool const length_input = pos == 4;
1096 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1097 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
1098 || paperchoice == 2 || paperchoice > 5;
1099 string const default_unit = metric ? "cm" : "in";
1100 string const length = params.getDefSkip().asLyXCommand();
1101 updateWidgetsFromLengthString(class_->input_skip,
1102 class_->choice_skip_units,
1103 length, default_unit);
1106 fl_set_input(class_->input_skip, "");
1108 setEnabled(class_->choice_skip, !indent);
1109 setEnabled(class_->input_skip, length_input);
1110 setEnabled(class_->choice_skip_units, length_input);
1112 bool const two_sides = params.sides == LyXTextClass::TwoSides;
1113 fl_set_button(class_->radio_sides_one, !two_sides);
1114 fl_set_button(class_->radio_sides_two, two_sides);
1116 bool const two_columns = params.columns == 2;
1117 fl_set_button(class_->radio_columns_one, !two_columns);
1118 fl_set_button(class_->radio_columns_two, two_columns);
1120 fl_set_input(class_->input_extra, params.options.c_str());
1122 switch (params.spacing().getSpace()) {
1123 case Spacing::Other:
1126 case Spacing::Double: // \doublespacing
1129 case Spacing::Onehalf: // \onehalfspacing
1132 case Spacing::Single: // \singlespacing
1133 case Spacing::Default: // nothing bad should happen with this
1138 fl_set_choice(class_->choice_spacing, pos);
1140 bool const spacing_input = pos == 4;
1141 setEnabled(class_->input_spacing, spacing_input);
1142 string const input = spacing_input ? tostr(params.spacing().getValue()) : string();
1143 fl_set_input(class_->input_spacing, input.c_str());
1147 void FormDocument::language_update(BufferParams const & params)
1149 if (!language_.get())
1152 int const pos = int(findPos(lang_, params.language->lang()));
1153 fl_set_combox(language_->combox_language, pos+1);
1155 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1156 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1157 fl_set_button(language_->radio_single, 0);
1158 fl_set_button(language_->radio_double, 0);
1159 if (params.quotes_times == InsetQuotes::SingleQ)
1160 fl_set_button(language_->radio_single, 1);
1162 fl_set_button(language_->radio_double, 1);
1166 void FormDocument::options_update(BufferParams const & params)
1168 if (!options_.get())
1171 fl_set_choice_text(options_->choice_postscript_driver,
1172 params.graphicsDriver.c_str());
1173 fl_set_choice(options_->choice_ams_math, params.use_amsmath + 1);
1174 fl_set_button(options_->check_use_natbib, params.use_natbib);
1175 fl_set_choice(options_->choice_citation_format,
1176 int(params.use_numerical_citations)+1);
1177 setEnabled(options_->choice_citation_format, params.use_natbib);
1178 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1179 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1180 if (!params.float_placement.empty())
1181 fl_set_input(options_->input_float_placement,
1182 params.float_placement.c_str());
1184 fl_set_input(options_->input_float_placement, "");
1188 void FormDocument::paper_update(BufferParams const & params)
1193 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1194 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1195 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1197 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1198 bool const useCustom = paperchoice == 2;
1199 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1201 fl_set_button(paper_->radio_portrait, 0);
1202 setEnabled(paper_->radio_portrait, !useCustom);
1203 fl_set_button(paper_->radio_landscape, 0);
1204 setEnabled(paper_->radio_landscape, !useCustom);
1206 if (params.orientation == ORIENTATION_LANDSCAPE)
1207 fl_set_button(paper_->radio_landscape, 1);
1209 fl_set_button(paper_->radio_portrait, 1);
1210 setEnabled(paper_->choice_paperpackage,
1211 //either default papersize (preferences)
1212 //or document papersize has to be A4
1214 || paperchoice == 1 && lyxrc.default_papersize == PAPER_A4PAPER)
1215 && fl_get_button(paper_->radio_portrait));
1217 // Default unit choice is cm if metric, inches if US paper.
1218 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
1219 || paperchoice == 2 || paperchoice > 5;
1220 string const default_unit = metric ? "cm" : "in";
1221 updateWidgetsFromLengthString(paper_->input_custom_width,
1222 paper_->choice_custom_width_units,
1223 params.paperwidth, default_unit);
1224 setEnabled(paper_->input_custom_width, useCustom);
1225 setEnabled(paper_->choice_custom_width_units, useCustom);
1227 updateWidgetsFromLengthString(paper_->input_custom_height,
1228 paper_->choice_custom_height_units,
1229 params.paperheight, default_unit);
1230 setEnabled(paper_->input_custom_height, useCustom);
1231 setEnabled(paper_->choice_custom_height_units, useCustom);
1233 updateWidgetsFromLengthString(paper_->input_inner_margin,
1234 paper_->choice_inner_margin_units,
1235 params.leftmargin, default_unit);
1236 setEnabled(paper_->input_inner_margin, useGeom);
1237 setEnabled(paper_->choice_inner_margin_units, useGeom);
1239 updateWidgetsFromLengthString(paper_->input_top_margin,
1240 paper_->choice_top_margin_units,
1241 params.topmargin, default_unit);
1242 setEnabled(paper_->input_top_margin, useGeom);
1243 setEnabled(paper_->choice_top_margin_units, useGeom);
1245 updateWidgetsFromLengthString(paper_->input_outer_margin,
1246 paper_->choice_outer_margin_units,
1247 params.rightmargin, default_unit);
1248 setEnabled(paper_->input_outer_margin, useGeom);
1249 setEnabled(paper_->choice_outer_margin_units, useGeom);
1251 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1252 paper_->choice_bottom_margin_units,
1253 params.bottommargin, default_unit);
1254 setEnabled(paper_->input_bottom_margin, useGeom);
1255 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1257 updateWidgetsFromLengthString(paper_->input_head_height,
1258 paper_->choice_head_height_units,
1259 params.headheight, default_unit);
1260 setEnabled(paper_->input_head_height, useGeom);
1261 setEnabled(paper_->choice_head_height_units, useGeom);
1263 updateWidgetsFromLengthString(paper_->input_head_sep,
1264 paper_->choice_head_sep_units,
1265 params.headsep, default_unit);
1266 setEnabled(paper_->input_head_sep, useGeom);
1267 setEnabled(paper_->choice_head_sep_units, useGeom);
1269 updateWidgetsFromLengthString(paper_->input_foot_skip,
1270 paper_->choice_foot_skip_units,
1271 params.footskip, default_unit);
1272 setEnabled(paper_->input_foot_skip, useGeom);
1273 setEnabled(paper_->choice_foot_skip_units, useGeom);
1275 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1279 void FormDocument::bullets_update(BufferParams const & params)
1281 if (!bullets_.get() ||
1283 (XpmVersion==4 && XpmRevision<7)))
1286 bool const isLinuxDoc =
1287 controller().docType() == ControlDocument::LINUXDOC;
1288 setEnabled(fbullet, !isLinuxDoc);
1290 if (isLinuxDoc) return;
1292 fl_set_button(bullets_->radio_depth_1, 1);
1293 fl_set_input(bullets_->input_latex,
1294 params.user_defined_bullet(0).getText().c_str());
1295 fl_set_choice(bullets_->choice_size,
1296 params.user_defined_bullet(0).getSize() + 2);
1300 void FormDocument::branch_update(BufferParams const & params)
1305 branchlist_ = params.branchlist();
1307 rebuild_all_branches_browser();
1308 string const current_branch =
1309 fl_get_browser_maxline(branch_->browser_all_branches) == 0 ?
1311 fl_get_browser_line(branch_->browser_all_branches, 1);
1313 // display proper selection...
1314 rebuild_selected_branches_browser();
1316 // display proper colour...
1319 if (current_branch == "none")
1320 x11hexname = "none";
1322 Branch * branch = branchlist_.find(current_branch);
1324 x11hexname = branch->getColor();
1327 if (x11hexname[0] == '#') {
1328 rgb = RGBColor(x11hexname);
1330 fl_getmcolor(FL_COL1, &rgb.r, &rgb.g, &rgb.b);
1332 fl_mapcolor(GUI_COLOR_CHOICE, rgb.r, rgb.g, rgb.b);
1333 fl_redraw_object(branch_->button_color);
1335 setEnabled(branch_->button_select,
1336 (fl_get_browser(branch_->browser_all_branches) > 0));
1337 setEnabled(branch_->button_deselect,
1338 (fl_get_browser(branch_->browser_selection) > 0));
1339 setEnabled(branch_->button_remove_branch,
1340 (fl_get_browser(branch_->browser_all_branches) > 0));
1341 setEnabled(branch_->button_modify,
1342 (fl_get_browser(branch_->browser_all_branches) > 0));
1346 void FormDocument::checkReadOnly()
1348 if (bc().readOnly(controller().bufferIsReadonly())) {
1349 postWarning(_("Document is read-only."
1350 " No changes to layout permitted."));
1357 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1359 BufferParams & param = controller().params();
1361 // convert from 1-6 range to -1-4
1362 param.temp_bullet(current_bullet_depth).setSize(fl_get_choice(ob) - 2);
1363 fl_set_input(bullets_->input_latex,
1364 param.temp_bullet(current_bullet_depth).getText().c_str());
1368 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1370 BufferParams & param = controller().params();
1372 param.temp_bullet(current_bullet_depth).
1373 setText(getString(bullets_->input_latex));
1377 void FormDocument::BulletDepth(FL_OBJECT * ob)
1379 /* Should I do the following: */
1380 /* 1. change to the panel that the current bullet belongs in */
1381 /* 2. show that bullet as selected */
1382 /* 3. change the size setting to the size of the bullet in Q.*/
1383 /* 4. display the latex equivalent in the latex box */
1385 /* I'm inclined to just go with 3 and 4 at the moment and */
1386 /* maybe try to support the others later */
1387 BufferParams & param = controller().params();
1390 if (ob == bullets_->radio_depth_1)
1392 else if (ob == bullets_->radio_depth_2)
1394 else if (ob == bullets_->radio_depth_3)
1396 else if (ob == bullets_->radio_depth_4)
1399 switch (fl_get_button_numb(ob)) {
1401 // right mouse button resets to default
1402 param.temp_bullet(data) = ITEMIZE_DEFAULTS[data];
1404 current_bullet_depth = data;
1405 fl_set_input(bullets_->input_latex,
1406 param.temp_bullet(data).getText().c_str());
1407 fl_set_choice(bullets_->choice_size,
1408 param.temp_bullet(data).getSize() + 2);
1413 void FormDocument::BulletPanel(FL_OBJECT * ob)
1415 /* Here we have to change the background pixmap to that selected */
1416 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1419 if (ob == bullets_->radio_panel_standard)
1421 else if (ob == bullets_->radio_panel_maths)
1423 else if (ob == bullets_->radio_panel_ding2)
1425 else if (ob == bullets_->radio_panel_ding3)
1427 else if (ob == bullets_->radio_panel_ding4)
1429 else if (ob == bullets_->radio_panel_ding1)
1432 if (data != current_bullet_panel) {
1433 fl_freeze_form(bullets_->form);
1434 current_bullet_panel = data;
1436 /* free the current pixmap */
1437 fl_free_bmtable_pixmap(bullets_->bmtable_panel);
1439 if (ob == bullets_->radio_panel_standard) {
1440 new_panel = "standard";
1441 } else if (ob == bullets_->radio_panel_maths ) {
1442 new_panel = "amssymb";
1443 } else if (ob == bullets_->radio_panel_ding2) {
1444 new_panel = "psnfss1";
1445 } else if (ob == bullets_->radio_panel_ding3) {
1446 new_panel = "psnfss2";
1447 } else if (ob == bullets_->radio_panel_ding4) {
1448 new_panel = "psnfss3";
1449 } else if (ob == bullets_->radio_panel_ding1) {
1450 new_panel = "psnfss4";
1452 /* something very wrong happened */
1453 // play it safe for now but should be an exception
1454 current_bullet_panel = 0; // standard panel
1455 new_panel = "standard";
1457 new_panel += ".xpm";
1458 fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6,
1459 LibFileSearch("images", new_panel).c_str());
1460 fl_redraw_object(bullets_->bmtable_panel);
1461 fl_unfreeze_form(bullets_->form);
1466 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1468 /* handle the user input by setting the current bullet depth's pixmap */
1469 /* to that extracted from the current chosen position of the BMTable */
1470 /* Don't forget to free the button's old pixmap first. */
1472 BufferParams & param = controller().params();
1473 int bmtable_button = fl_get_bmtable(ob);
1475 /* try to keep the button held down till another is pushed */
1476 /* fl_set_bmtable(ob, 1, bmtable_button); */
1477 param.temp_bullet(current_bullet_depth).setFont(current_bullet_panel);
1478 param.temp_bullet(current_bullet_depth).setCharacter(bmtable_button);
1479 fl_set_input(bullets_->input_latex,
1480 param.temp_bullet(current_bullet_depth).getText().c_str());
1484 void FormDocument::CheckChoiceClass()
1486 BufferParams & params = controller().params();
1488 lyx::textclass_type const tc =
1489 fl_get_combox(class_->combox_class) - 1;
1491 if (controller().loadTextclass(tc)) {
1492 params.textclass = tc;
1494 if (lyxrc.auto_reset_options) {
1495 params.useClassDefaults();
1496 UpdateLayoutDocument(params);
1498 // update the params which are needed in any case
1499 // (fontsizes, pagestyle)
1500 UpdateClassParams(params);
1504 int const revert = int(params.textclass);
1505 fl_set_combox(class_->combox_class, revert + 1);
1510 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1516 class_update(params);
1517 paper_update(params);
1518 language_update(params);
1519 options_update(params);
1520 bullets_update(params);