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"
36 #include "lyxtextclasslist.h"
37 #include "tex-strings.h"
39 #include "support/tostr.h"
40 #include "support/lstrings.h" // contains_functor, getStringFromVector
41 #include "support/filetools.h" // LibFileSearch
47 using namespace lyx::support;
57 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
58 bool const scalableTabfolders = false;
60 bool const scalableTabfolders = true;
67 typedef FormCB<ControlDocument, FormDB<FD_document> > base_class;
69 FormDocument::FormDocument()
70 : base_class(_("Document Settings"), scalableTabfolders),
71 ActCell(0), Confirmed(0),
72 current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
76 void FormDocument::redraw()
78 if (form() && form()->visible)
79 fl_redraw_form(form());
83 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
84 if (outer_form && outer_form->visible)
85 fl_redraw_form(outer_form);
89 void FormDocument::build()
92 dialog_.reset(build_document(this));
94 // Allow the base class to control messages
95 setMessageWidget(dialog_->text_warning);
97 // Manage the restore, ok, apply, restore and cancel/close buttons
98 bcview().setOK(dialog_->button_ok);
99 bcview().setApply(dialog_->button_apply);
100 bcview().setCancel(dialog_->button_close);
101 bcview().setRestore(dialog_->button_restore);
103 // the document class form
104 class_.reset(build_document_class(this));
106 // disable for read-only documents
107 bcview().addReadOnly(class_->combox_class);
108 bcview().addReadOnly(class_->radio_indent);
109 bcview().addReadOnly(class_->radio_skip);
110 bcview().addReadOnly(class_->choice_pagestyle);
111 bcview().addReadOnly(class_->choice_fonts);
112 bcview().addReadOnly(class_->choice_fontsize);
113 bcview().addReadOnly(class_->radio_sides_one);
114 bcview().addReadOnly(class_->radio_sides_two);
115 bcview().addReadOnly(class_->radio_columns_one);
116 bcview().addReadOnly(class_->radio_columns_two);
117 bcview().addReadOnly(class_->input_extra);
118 bcview().addReadOnly(class_->input_skip);
119 bcview().addReadOnly(class_->choice_skip);
120 bcview().addReadOnly(class_->choice_spacing);
121 bcview().addReadOnly(class_->input_spacing);
123 // check validity of "length + unit" input
124 addCheckedGlueLength(bcview(), class_->input_skip,
125 class_->choice_skip);
127 // trigger an input event for cut&paste with middle mouse button.
128 setPrehandler(class_->input_extra);
129 setPrehandler(class_->input_skip);
130 setPrehandler(class_->input_spacing);
132 fl_set_input_return(class_->input_extra, FL_RETURN_CHANGED);
133 fl_set_input_return(class_->input_skip, FL_RETURN_CHANGED);
134 fl_set_input_return(class_->input_spacing, FL_RETURN_CHANGED);
138 // Fill the combox and choices.
139 obj = class_->combox_class;
140 LyXTextClassList::const_iterator tit = textclasslist.begin();
141 LyXTextClassList::const_iterator tend = textclasslist.end();
142 for (; tit != tend; ++tit) {
143 if (tit->isTeXClassAvailable()) {
144 fl_addto_combox(obj, tit->description().c_str());
146 string item = bformat(_("Unavailable: %1$s"), tit->description());
147 fl_addto_combox(obj, item.c_str());
150 fl_set_combox_browser_height(obj, 400);
152 fl_addto_choice(class_->choice_spacing,
153 _(" Single | OneHalf | Double | Custom ").c_str());
154 fl_addto_choice(class_->choice_fontsize, "default|10|11|12");
155 for (int n = 0; tex_fonts[n][0]; ++n) {
156 fl_addto_choice(class_->choice_fonts,tex_fonts[n]);
159 // Create the contents of the unit choices; don't include the
161 vector<string> units_vec = getLatexUnits();
162 vector<string>::iterator ret =
163 std::remove_if(units_vec.begin(),
165 bind2nd(contains_functor(), "%"));
166 units_vec.erase(ret, units_vec.end());
168 string const units = getStringFromVector(units_vec, "|");
170 fl_addto_choice(class_->choice_pagestyle,
171 "default|empty|plain|headings|fancy");
172 fl_addto_choice(class_->choice_skip,
173 _(" SmallSkip | MedSkip | BigSkip | Length ").c_str());
174 fl_addto_choice(class_->choice_skip_units, units.c_str());
176 // Set input filters on doc spacing to make it accept only
178 fl_set_input_filter(class_->input_spacing,
179 fl_unsigned_float_filter);
181 // disable for read-only documents
182 bcview().addReadOnly(dialog_->button_save_defaults);
183 bcview().addReadOnly(dialog_->button_reset_defaults);
185 // the document paper form
186 paper_.reset(build_document_paper(this));
188 // disable for read-only documents
189 bcview().addReadOnly(paper_->choice_paperpackage);
190 bcview().addReadOnly(paper_->radio_portrait);
191 bcview().addReadOnly(paper_->radio_landscape);
192 bcview().addReadOnly(paper_->choice_papersize);
193 bcview().addReadOnly(paper_->check_use_geometry);
194 bcview().addReadOnly(paper_->input_custom_width);
195 bcview().addReadOnly(paper_->input_custom_height);
196 bcview().addReadOnly(paper_->input_top_margin);
197 bcview().addReadOnly(paper_->input_bottom_margin);
198 bcview().addReadOnly(paper_->input_inner_margin);
199 bcview().addReadOnly(paper_->input_outer_margin);
200 bcview().addReadOnly(paper_->input_head_height);
201 bcview().addReadOnly(paper_->input_head_sep);
202 bcview().addReadOnly(paper_->input_foot_skip);
204 // check validity of "length + unit" input
205 addCheckedGlueLength(bcview(), paper_->input_custom_width);
206 addCheckedGlueLength(bcview(), paper_->input_custom_height);
207 addCheckedGlueLength(bcview(), paper_->input_top_margin);
208 addCheckedGlueLength(bcview(), paper_->input_bottom_margin);
209 addCheckedGlueLength(bcview(), paper_->input_inner_margin);
210 addCheckedGlueLength(bcview(), paper_->input_outer_margin);
211 addCheckedGlueLength(bcview(), paper_->input_head_height);
212 addCheckedGlueLength(bcview(), paper_->input_head_sep);
213 addCheckedGlueLength(bcview(), paper_->input_foot_skip);
215 // trigger an input event for cut&paste with middle mouse button.
216 setPrehandler(paper_->input_custom_width);
217 setPrehandler(paper_->input_custom_height);
218 setPrehandler(paper_->input_top_margin);
219 setPrehandler(paper_->input_bottom_margin);
220 setPrehandler(paper_->input_inner_margin);
221 setPrehandler(paper_->input_outer_margin);
222 setPrehandler(paper_->input_head_height);
223 setPrehandler(paper_->input_head_sep);
224 setPrehandler(paper_->input_foot_skip);
226 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
227 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
228 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
229 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
230 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
231 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
232 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
233 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
234 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
236 fl_addto_choice(paper_->choice_papersize,
237 _(" Default | Custom | US letter | US legal "
238 "| US executive | A3 | A4 | A5 "
239 "| B3 | B4 | B5 ").c_str());
240 fl_addto_choice(paper_->choice_paperpackage,
243 "| Very small Margins "
244 "| Very wide Margins ").c_str());
246 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
247 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
248 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
249 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
250 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
251 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
252 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
253 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
254 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
256 // the document language form
257 language_.reset(build_document_language(this));
259 // disable for read-only documents
260 bcview().addReadOnly(language_->combox_language);
261 bcview().addReadOnly(language_->choice_inputenc);
262 bcview().addReadOnly(language_->choice_quotes_language);
263 bcview().addReadOnly(language_->radio_single);
264 bcview().addReadOnly(language_->radio_double);
266 fl_addto_choice(language_->choice_inputenc,
267 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
268 "|koi8-r|koi8-u|cp866|cp1251|iso88595|pt154");
270 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
271 // Store the identifiers for later
272 lang_ = getSecond(langs);
274 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
275 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
276 for (; lit != lend; ++lit) {
277 fl_addto_combox(language_->combox_language,
280 fl_set_combox_browser_height(language_->combox_language, 400);
282 fl_addto_choice(language_->choice_quotes_language,
283 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
284 " «text» | »text« ").c_str());
286 // the document options form
287 options_.reset(build_document_options(this));
289 // disable for read-only documents
290 bcview().addReadOnly(options_->counter_secnumdepth);
291 bcview().addReadOnly(options_->counter_tocdepth);
292 bcview().addReadOnly(options_->choice_ams_math);
293 bcview().addReadOnly(options_->check_use_natbib);
294 bcview().addReadOnly(options_->choice_citation_format);
295 bcview().addReadOnly(options_->input_float_placement);
296 bcview().addReadOnly(options_->choice_postscript_driver);
298 // trigger an input event for cut&paste with middle mouse button.
299 setPrehandler(options_->input_float_placement);
301 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
303 fl_addto_choice(options_->choice_ams_math,
304 _("Never | Automatically | Yes ").c_str());
306 for (int n = 0; tex_graphics[n][0]; ++n) {
307 fl_addto_choice(options_->choice_postscript_driver,
310 fl_addto_choice(options_->choice_citation_format,
311 _(" Author-year | Numerical ").c_str());
313 // the document bullets form
314 bullets_.reset(build_document_bullet(this));
316 // disable for read-only documents
317 bcview().addReadOnly(bullets_->radio_depth_1);
318 bcview().addReadOnly(bullets_->radio_depth_2);
319 bcview().addReadOnly(bullets_->radio_depth_3);
320 bcview().addReadOnly(bullets_->radio_depth_4);
321 bcview().addReadOnly(bullets_->radio_panel_standard);
322 bcview().addReadOnly(bullets_->radio_panel_maths);
323 bcview().addReadOnly(bullets_->radio_panel_ding1);
324 bcview().addReadOnly(bullets_->radio_panel_ding2);
325 bcview().addReadOnly(bullets_->radio_panel_ding3);
326 bcview().addReadOnly(bullets_->radio_panel_ding4);
327 bcview().addReadOnly(bullets_->bmtable_panel);
328 bcview().addReadOnly(bullets_->choice_size);
329 bcview().addReadOnly(bullets_->input_latex);
331 // trigger an input event for cut&paste with middle mouse button.
332 setPrehandler(bullets_->input_latex);
334 fl_set_input_return(bullets_->input_latex, FL_RETURN_CHANGED);
336 fl_addto_choice(bullets_->choice_size,
337 _(" Default | Tiny | Smallest | Smaller "
338 "| Small | Normal | Large | Larger | Largest "
339 "| Huge | Huger ").c_str());
340 fl_set_choice(bullets_->choice_size, 1);
342 fl_set_input_maxchars(bullets_->input_latex, 80);
344 string const bmtablefile = LibFileSearch("images", "standard", "xpm");
345 fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6,
346 bmtablefile.c_str());
348 picker_.reset(new FormColorpicker);
350 // the document branches form
351 branch_.reset(build_document_branch(this));
353 fl_set_object_color(branch_->button_color,
354 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
356 bcview().addReadOnly(branch_->input_all_branches);
357 bcview().addReadOnly(branch_->button_add_branch);
358 bcview().addReadOnly(branch_->button_remove_branch);
359 bcview().addReadOnly(branch_->button_select);
360 bcview().addReadOnly(branch_->button_deselect);
361 bcview().addReadOnly(branch_->button_modify);
362 bcview().addReadOnly(branch_->browser_all_branches);
364 // set up the tooltips for branches form
365 string str = _("Enter the name of a new branch.");
366 tooltips().init(branch_->input_all_branches, str);
367 str = _("Add a new branch to the document.");
368 tooltips().init(branch_->button_add_branch, str);
369 str = _("Remove the selected branch from the document.");
370 tooltips().init(branch_->button_remove_branch, str);
371 str = _("Activate the selected branch for output.");
372 tooltips().init(branch_->button_select, str);
373 str = _("Deactivate the selected activated branch.");
374 tooltips().init(branch_->button_deselect, str);
375 str = _("Available branches for this document.");
376 tooltips().init(branch_->browser_all_branches, str);
377 str = _("Activated branches. Content will occur in the document\'s output");
378 tooltips().init(branch_->browser_selection, str);
379 str = _("Modify background color of branch inset");
380 tooltips().init(branch_->button_modify, str);
381 str = _("Background color of branch inset");
382 tooltips().init(branch_->button_color, str);
384 // Handle middle mouse paint:
385 setPrehandler(branch_->input_all_branches);
386 fl_set_input_return(branch_->input_all_branches, FL_RETURN_CHANGED);
388 // Enable the tabfolder to be rescaled correctly.
389 if (scalableTabfolders)
390 fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
393 fl_addto_tabfolder(dialog_->tabfolder,_("Document").c_str(),
395 fl_addto_tabfolder(dialog_->tabfolder,_("Paper").c_str(),
397 fl_addto_tabfolder(dialog_->tabfolder,_("Language").c_str(),
399 fl_addto_tabfolder(dialog_->tabfolder,_("Extra").c_str(),
401 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets").c_str(),
404 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
405 lyxerr << _("Your version of libXpm is older than 4.7.\n"
406 "The `bullet' tab of the document dialog "
407 "has been disabled") << '\n';
408 fl_deactivate_object(fbullet);
409 fl_set_object_lcol(fbullet, FL_INACTIVE);
412 fl_addto_tabfolder(dialog_->tabfolder,_("Branches").c_str(),
417 void FormDocument::apply()
419 BufferParams & params = controller().params();
423 language_apply(params);
424 options_apply(params);
425 bullets_apply(params);
426 branch_apply(params);
430 void FormDocument::update()
437 BufferParams const & params = controller().params();
439 class_update(params);
440 paper_update(params);
441 language_update(params);
442 options_update(params);
443 bullets_update(params);
444 branch_update(params);
448 ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
450 if (ob == bullets_->choice_size) {
451 ChoiceBulletSize(ob, 0);
453 } else if (ob == bullets_->input_latex) {
454 InputBulletLaTeX(ob, 0);
456 } else if (ob == bullets_->radio_depth_1 ||
457 ob == bullets_->radio_depth_2 ||
458 ob == bullets_->radio_depth_3 ||
459 ob == bullets_->radio_depth_4) {
462 } else if (ob == bullets_->radio_panel_standard ||
463 ob == bullets_->radio_panel_maths ||
464 ob == bullets_->radio_panel_ding1 ||
465 ob == bullets_->radio_panel_ding2 ||
466 ob == bullets_->radio_panel_ding3 ||
467 ob == bullets_->radio_panel_ding4) {
470 } else if (ob == bullets_->bmtable_panel) {
471 BulletBMTable(ob, 0);
473 } else if (ob == class_->choice_spacing) {
474 setEnabled(class_->input_spacing,
475 fl_get_choice(class_->choice_spacing) == 4);
477 } else if (ob == class_->combox_class) {
479 } else if (ob == class_->radio_skip ||
480 ob == class_->radio_indent ||
481 ob == class_->choice_skip) {
482 bool const skip_used = fl_get_button(class_->radio_skip);
483 setEnabled(class_->choice_skip, skip_used);
485 bool const length_input =
486 fl_get_choice(class_->choice_skip) == 4;
487 setEnabled(class_->input_skip,
488 skip_used && length_input);
489 setEnabled(class_->choice_skip_units,
490 skip_used && length_input);
492 // Default unit choice is cm if metric, inches if US paper.
493 // If papersize is default, check the lyxrc-settings
494 int const paperchoice = fl_get_choice(paper_->choice_papersize);
495 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
496 || paperchoice == 2 || paperchoice > 5;
497 string const default_unit = metric ? "cm" : "in";
498 if (getString(class_->input_skip).empty())
499 fl_set_choice_text(class_->choice_skip_units,
500 default_unit.c_str());
502 } else if (ob == options_->check_use_natbib) {
503 setEnabled(options_->choice_citation_format,
504 fl_get_button(options_->check_use_natbib));
506 } else if (ob == branch_->browser_all_branches ||
507 ob == branch_->browser_selection ||
508 ob == branch_->button_add_branch ||
509 ob == branch_->button_remove_branch ||
510 ob == branch_->button_modify ||
511 ob == branch_->button_select ||
512 ob == branch_->button_deselect ||
513 ob == branch_->button_deselect) {
515 } else if (ob == dialog_->button_save_defaults) {
517 controller().saveAsDefault();
519 } else if (ob == dialog_->button_reset_defaults) {
520 BufferParams & params = controller().params();
521 params.textclass = fl_get_combox(class_->combox_class) - 1;
522 params.useClassDefaults();
523 UpdateLayoutDocument(params);
525 } else if (ob == paper_->radio_landscape) {
526 fl_set_choice(paper_->choice_paperpackage,
529 } else if (ob == paper_->choice_papersize) {
530 int const paperchoice = fl_get_choice(paper_->choice_papersize);
531 bool const defsize = paperchoice == 1;
532 bool const custom = paperchoice == 2;
533 bool const a3size = paperchoice == 6;
534 bool const b3size = paperchoice == 9;
535 bool const b4size = paperchoice == 10;
538 fl_set_button(paper_->radio_portrait, 1);
540 bool const use_geom = (custom || a3size || b3size || b4size);
542 fl_set_button(paper_->check_use_geometry, int(use_geom));
544 setEnabled(paper_->input_top_margin, use_geom);
545 setEnabled(paper_->input_bottom_margin, use_geom);
546 setEnabled(paper_->input_inner_margin, use_geom);
547 setEnabled(paper_->input_outer_margin, use_geom);
548 setEnabled(paper_->input_head_height, use_geom);
549 setEnabled(paper_->input_head_sep, use_geom);
550 setEnabled(paper_->input_foot_skip, use_geom);
551 setEnabled(paper_->choice_top_margin_units, use_geom);
552 setEnabled(paper_->choice_bottom_margin_units, use_geom);
553 setEnabled(paper_->choice_inner_margin_units, use_geom);
554 setEnabled(paper_->choice_outer_margin_units, use_geom);
555 setEnabled(paper_->choice_head_height_units, use_geom);
556 setEnabled(paper_->choice_head_sep_units, use_geom);
557 setEnabled(paper_->choice_foot_skip_units, use_geom);
558 setEnabled(paper_->choice_custom_width_units, use_geom);
559 setEnabled(paper_->choice_custom_height_units, use_geom);
561 setEnabled(paper_->input_custom_width, custom);
562 setEnabled(paper_->input_custom_height, custom);
563 setEnabled(paper_->choice_custom_width_units, custom);
564 setEnabled(paper_->choice_custom_height_units, custom);
565 setEnabled(paper_->radio_portrait, !custom);
566 setEnabled(paper_->radio_landscape, !custom);
568 // Default unit choice is cm if metric, inches if US paper.
569 // If papersize is default, use the lyxrc-settings
570 bool const metric = (defsize && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
571 || paperchoice == 2 || paperchoice > 5;
572 string const default_unit = metric ? "cm" : "in";
573 if (getString(paper_->input_custom_width).empty())
574 fl_set_choice_text(paper_->choice_custom_width_units,
575 default_unit.c_str());
576 if (getString(paper_->input_custom_height).empty())
577 fl_set_choice_text(paper_->choice_custom_height_units,
578 default_unit.c_str());
579 if (getString(paper_->input_top_margin).empty())
580 fl_set_choice_text(paper_->choice_top_margin_units,
581 default_unit.c_str());
582 if (getString(paper_->input_bottom_margin).empty())
583 fl_set_choice_text(paper_->choice_bottom_margin_units,
584 default_unit.c_str());
585 if (getString(paper_->input_inner_margin).empty())
586 fl_set_choice_text(paper_->choice_inner_margin_units,
587 default_unit.c_str());
588 if (getString(paper_->input_outer_margin).empty())
589 fl_set_choice_text(paper_->choice_outer_margin_units,
590 default_unit.c_str());
591 if (getString(paper_->input_head_height).empty())
592 fl_set_choice_text(paper_->choice_head_height_units,
593 default_unit.c_str());
594 if (getString(paper_->input_head_sep).empty())
595 fl_set_choice_text(paper_->choice_head_sep_units,
596 default_unit.c_str());
597 if (getString(paper_->input_foot_skip).empty())
598 fl_set_choice_text(paper_->choice_foot_skip_units,
599 default_unit.c_str());
601 } else if (ob == paper_->choice_paperpackage &&
602 fl_get_choice(paper_->choice_paperpackage) != 1) {
604 fl_set_button(paper_->check_use_geometry, 0);
605 setEnabled(paper_->input_top_margin, false);
606 setEnabled(paper_->input_bottom_margin, false);
607 setEnabled(paper_->input_inner_margin, false);
608 setEnabled(paper_->input_outer_margin, false);
609 setEnabled(paper_->input_head_height, false);
610 setEnabled(paper_->input_head_sep, false);
611 setEnabled(paper_->input_foot_skip, false);
612 setEnabled(paper_->choice_top_margin_units, false);
613 setEnabled(paper_->choice_bottom_margin_units, false);
614 setEnabled(paper_->choice_inner_margin_units, false);
615 setEnabled(paper_->choice_outer_margin_units, false);
616 setEnabled(paper_->choice_head_height_units, false);
617 setEnabled(paper_->choice_head_sep_units, false);
618 setEnabled(paper_->choice_foot_skip_units, false);
620 } else if (ob == paper_->check_use_geometry) {
621 // don't allow switching geometry off in custom papersize
622 // mode nor in A3, B3, and B4
623 int const choice = fl_get_choice(paper_->choice_papersize);
624 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
625 fl_set_button(paper_->check_use_geometry, 1);
627 fl_set_choice(paper_->choice_paperpackage,
630 bool const use_geom = fl_get_button(paper_->check_use_geometry);
631 setEnabled(paper_->input_top_margin, use_geom);
632 setEnabled(paper_->input_bottom_margin, use_geom);
633 setEnabled(paper_->input_inner_margin, use_geom);
634 setEnabled(paper_->input_outer_margin, use_geom);
635 setEnabled(paper_->input_head_height, use_geom);
636 setEnabled(paper_->input_head_sep, use_geom);
637 setEnabled(paper_->input_foot_skip, use_geom);
638 setEnabled(paper_->choice_top_margin_units, use_geom);
639 setEnabled(paper_->choice_bottom_margin_units, use_geom);
640 setEnabled(paper_->choice_inner_margin_units, use_geom);
641 setEnabled(paper_->choice_outer_margin_units, use_geom);
642 setEnabled(paper_->choice_head_height_units, use_geom);
643 setEnabled(paper_->choice_head_sep_units, use_geom);
644 setEnabled(paper_->choice_foot_skip_units, use_geom);
647 if (ob == paper_->choice_papersize || ob == paper_->radio_portrait
648 || ob == paper_->radio_landscape) {
649 // either default papersize (preferences) or document
650 // papersize has to be A4
651 bool const enable = ( fl_get_choice(paper_->choice_papersize) == 1
652 && lyxrc.default_papersize == PAPER_A4PAPER )
653 || fl_get_choice(paper_->choice_papersize) == 7;
655 fl_set_choice(paper_->choice_paperpackage,
657 setEnabled(paper_->choice_paperpackage,
658 enable && fl_get_button(paper_->radio_portrait));
661 return ButtonPolicy::SMI_VALID;
665 void FormDocument::branch_input(FL_OBJECT * ob)
667 BufferParams & params = controller().params();
668 std::vector<string> vec;
670 if (ob == branch_->button_add_branch) {
671 string new_branch = fl_get_input(branch_->input_all_branches);
672 if (!new_branch.empty()) {
673 params.branchlist.add(new_branch);
674 fl_set_input(branch_->input_all_branches, "");
675 // Update branch list
676 string const all_branches = params.branchlist.allBranches();
677 fl_clear_browser(branch_->browser_all_branches);
678 vec = getVectorFromString(all_branches, "|");
679 for (unsigned i = 0; i < vec.size(); ++i) {
680 fl_addto_browser(branch_->browser_all_branches,
683 LColor::color c = static_cast<LColor::color>(lcolor.size());
684 lcolor.fill(c, new_branch, lcolor.getX11Name(LColor::background));
687 } else if (ob == branch_->button_remove_branch) {
688 unsigned i = fl_get_browser(branch_->browser_all_branches);
689 string const current_branch =
690 fl_get_browser_line(branch_->browser_all_branches, i);
691 if (!current_branch.empty()) {
692 params.branchlist.remove(current_branch);
693 // Update branch list
694 string const all_branches = params.branchlist.allBranches();
695 fl_clear_browser(branch_->browser_all_branches);
696 vec = getVectorFromString(all_branches, "|");
697 for (unsigned i = 0; i < vec.size(); ++i) {
698 fl_addto_browser(branch_->browser_all_branches,
701 // Update selected-list...
702 string const all_selected = params.branchlist.allSelected();
703 fl_clear_browser(branch_->browser_selection);
704 vec = getVectorFromString(all_selected, "|");
705 for (unsigned i = 0; i < vec.size(); ++i) {
706 fl_addto_browser(branch_->browser_selection, vec[i].c_str());
709 } else if (ob == branch_->button_select) {
710 unsigned i = fl_get_browser(branch_->browser_all_branches);
711 string const current_branch =
712 fl_get_browser_line(branch_->browser_all_branches, i);
713 if (!current_branch.empty()) {
714 fl_clear_browser(branch_->browser_selection);
715 params.branchlist.setSelected(current_branch, true);
716 string const all_selected = params.branchlist.allSelected();
717 vec = getVectorFromString(all_selected, "|");
718 for (unsigned i = 0; i < vec.size(); ++i) {
719 fl_addto_browser(branch_->browser_selection,
723 } else if (ob == branch_->button_deselect) {
724 unsigned i = fl_get_browser(branch_->browser_selection);
725 string const current_sel =
726 fl_get_browser_line(branch_->browser_selection, i);
727 if (!current_sel.empty()) {
728 fl_clear_browser(branch_->browser_selection);
729 params.branchlist.setSelected(current_sel, false);
730 string const all_selected = params.branchlist.allSelected();
731 vec = getVectorFromString(all_selected, "|");
732 for (unsigned i = 0; i < vec.size(); ++i) {
733 fl_addto_browser(branch_->browser_selection,
737 } else if (ob == branch_->button_modify) {
738 unsigned i = fl_get_browser(branch_->browser_all_branches);
739 string const current_branch =
740 fl_get_browser_line(branch_->browser_all_branches, i);
743 string x11hexname = params.branchlist.getColor(current_branch);
744 if (x11hexname[0] == '#') {
745 before = RGBColor(x11hexname);
747 fl_getmcolor(FL_COL1, &before.r, &before.g, &before.b);
750 RGBColor col = picker_->requestColor(before);
752 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
753 fl_redraw_object(branch_->button_color);
754 // Figure out here how to stash the new colour into the
755 // LyX colour database.
757 x11hexname = X11hexname(col);
759 // current_branch already in database
760 LColor::color c = lcolor.getFromLyXName(current_branch);
761 lcolor.setColor(current_branch, x11hexname);
762 // Make sure that new colour is also displayed ;-)
763 lyxColorHandler->getGCForeground(c);
764 lyxColorHandler->updateColor(c);
765 // what about system_lcolor?
766 // Here set colour in BranchList:
767 params.branchlist.setColor(current_branch, x11hexname);
769 } else if (ob == branch_->browser_all_branches) {
770 unsigned i = fl_get_browser(branch_->browser_all_branches);
771 string const current_branch =
772 fl_get_browser_line(branch_->browser_all_branches, i);
773 // make button_color track selected branch:
776 string x11hexname = params.branchlist.getColor(current_branch);
777 if (x11hexname[0] == '#') {
778 rgb = RGBColor(x11hexname);
780 fl_getmcolor(FL_COL1, &rgb.r, &rgb.g, &rgb.b);
782 fl_mapcolor(GUI_COLOR_CHOICE, rgb.r, rgb.g, rgb.b);
783 fl_redraw_object(branch_->button_color);
785 setEnabled(branch_->button_select,
786 (fl_get_browser(branch_->browser_all_branches) > 0));
787 setEnabled(branch_->button_deselect,
788 (fl_get_browser(branch_->browser_selection) > 0));
789 setEnabled(branch_->button_remove_branch,
790 (fl_get_browser(branch_->browser_all_branches) > 0));
791 setEnabled(branch_->button_modify,
792 (fl_get_browser(branch_->browser_all_branches) > 0));
794 branchlist_ = params.branchlist;
798 bool FormDocument::class_apply(BufferParams ¶ms)
802 // If default skip is a "Length" but there's no text in the
803 // input field, reset the kind to "MedSkip", which is the default.
804 if (fl_get_choice(class_->choice_skip) == 4 &&
805 getString(class_->input_skip).empty()) {
806 fl_set_choice(class_->choice_skip, 2);
808 params.fonts = getString(class_->choice_fonts);
809 params.fontsize = getString(class_->choice_fontsize);
810 params.pagestyle = getString(class_->choice_pagestyle);
812 params.textclass = fl_get_combox(class_->combox_class) - 1;
814 BufferParams::PARSEP tmpsep = params.paragraph_separation;
815 if (fl_get_button(class_->radio_indent))
816 params.paragraph_separation = BufferParams::PARSEP_INDENT;
818 params.paragraph_separation = BufferParams::PARSEP_SKIP;
819 if (tmpsep != params.paragraph_separation)
822 VSpace tmpdefskip = params.getDefSkip();
823 switch (fl_get_choice(class_->choice_skip)) {
825 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
828 params.setDefSkip(VSpace(VSpace::MEDSKIP));
831 params.setDefSkip(VSpace(VSpace::BIGSKIP));
835 string const length =
836 getLengthFromWidgets(class_->input_skip,
837 class_->choice_skip_units);
839 params.setDefSkip(VSpace(LyXGlueLength(length)));
843 // DocumentDefskipCB assures that this never happens
844 params.setDefSkip(VSpace(VSpace::MEDSKIP));
847 if (!(tmpdefskip == params.getDefSkip()))
850 if (fl_get_button(class_->radio_columns_two))
854 if (fl_get_button(class_->radio_sides_two))
855 params.sides = LyXTextClass::TwoSides;
857 params.sides = LyXTextClass::OneSide;
859 Spacing tmpSpacing = params.spacing;
860 switch (fl_get_choice(class_->choice_spacing)) {
862 lyxerr[Debug::INFO] << "Spacing: SINGLE" << endl;
863 params.spacing.set(Spacing::Single);
866 lyxerr[Debug::INFO] << "Spacing: ONEHALF" << endl;
867 params.spacing.set(Spacing::Onehalf);
870 lyxerr[Debug::INFO] << "Spacing: DOUBLE" << endl;
871 params.spacing.set(Spacing::Double);
874 lyxerr[Debug::INFO] << "Spacing: OTHER" << endl;
875 params.spacing.set(Spacing::Other,
876 getString(class_->input_spacing));
879 if (tmpSpacing != params.spacing)
882 params.options = getString(class_->input_extra);
888 void FormDocument::paper_apply(BufferParams & params)
890 params.papersize2 = VMARGIN_PAPER_TYPE(fl_get_choice(paper_->choice_papersize) - 1);
892 params.paperpackage =
893 PAPER_PACKAGES(fl_get_choice(paper_->choice_paperpackage) - 1);
895 // set params.papersize from params.papersize2 and params.paperpackage
896 params.setPaperStuff();
898 params.use_geometry = fl_get_button(paper_->check_use_geometry);
900 if (fl_get_button(paper_->radio_landscape))
901 params.orientation = ORIENTATION_LANDSCAPE;
903 params.orientation = ORIENTATION_PORTRAIT;
906 getLengthFromWidgets(paper_->input_custom_width,
907 paper_->choice_custom_width_units);
910 getLengthFromWidgets(paper_->input_custom_height,
911 paper_->choice_custom_height_units);
914 getLengthFromWidgets(paper_->input_inner_margin,
915 paper_->choice_inner_margin_units);
918 getLengthFromWidgets(paper_->input_top_margin,
919 paper_->choice_top_margin_units);
922 getLengthFromWidgets(paper_->input_outer_margin,
923 paper_->choice_outer_margin_units);
925 params.bottommargin =
926 getLengthFromWidgets(paper_->input_bottom_margin,
927 paper_->choice_bottom_margin_units);
930 getLengthFromWidgets(paper_->input_head_height,
931 paper_->choice_head_height_units);
934 getLengthFromWidgets(paper_->input_head_sep,
935 paper_->choice_head_sep_units);
938 getLengthFromWidgets(paper_->input_foot_skip,
939 paper_->choice_foot_skip_units);
943 bool FormDocument::language_apply(BufferParams & params)
945 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
948 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
950 lga = InsetQuotes::EnglishQ;
953 lga = InsetQuotes::SwedishQ;
956 lga = InsetQuotes::GermanQ;
959 lga = InsetQuotes::PolishQ;
962 lga = InsetQuotes::FrenchQ;
965 lga = InsetQuotes::DanishQ;
968 params.quotes_language = lga;
969 if (fl_get_button(language_->radio_single))
970 params.quotes_times = InsetQuotes::SingleQ;
972 params.quotes_times = InsetQuotes::DoubleQ;
974 int const pos = fl_get_combox(language_->combox_language);
975 Language const * new_language = languages.getLanguage(lang_[pos-1]);
977 new_language = default_language;
979 params.language = new_language;
980 params.inputenc = getString(language_->choice_inputenc);
986 bool FormDocument::options_apply(BufferParams & params)
990 params.graphicsDriver = getString(options_->choice_postscript_driver);
991 params.use_amsmath = static_cast<BufferParams::AMS>(
992 fl_get_choice(options_->choice_ams_math) - 1);
993 params.use_natbib = fl_get_button(options_->check_use_natbib);
994 params.use_numerical_citations =
995 fl_get_choice(options_->choice_citation_format) - 1;
997 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
998 if (params.secnumdepth != tmpchar)
1000 params.secnumdepth = tmpchar;
1002 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
1004 params.float_placement =
1005 getString(options_->input_float_placement);
1011 void FormDocument::bullets_apply(BufferParams & params)
1013 /* update the bullet settings */
1014 BufferParams & buf_params = controller().params();
1016 for (int i = 0; i < 4; ++i) {
1017 params.user_defined_bullets[i] = buf_params.temp_bullets[i];
1022 void FormDocument::branch_apply(BufferParams & params)
1024 BufferParams & prms = controller().params();
1025 if (branchlist_.empty())
1026 branchlist_ = prms.branchlist;
1027 params.branchlist = branchlist_;
1028 branchlist_.clear();
1032 void FormDocument::UpdateClassParams(BufferParams const & params)
1034 // These are the params that have to be updated on any class change
1035 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
1037 LyXTextClass const & tclass = textclasslist[params.textclass];
1039 fl_set_combox(class_->combox_class, params.textclass + 1);
1040 fl_clear_choice(class_->choice_fontsize);
1041 fl_addto_choice(class_->choice_fontsize, "default");
1042 fl_addto_choice(class_->choice_fontsize,
1043 tclass.opt_fontsize().c_str());
1044 fl_set_choice_text(class_->choice_fontsize,
1045 params.fontsize.c_str());
1046 fl_clear_choice(class_->choice_pagestyle);
1047 fl_addto_choice(class_->choice_pagestyle, "default");
1048 fl_addto_choice(class_->choice_pagestyle,
1049 tclass.opt_pagestyle().c_str());
1050 fl_set_choice_text(class_->choice_pagestyle,
1051 params.pagestyle.c_str());
1053 fl_set_input(class_->input_extra, tclass.options().c_str());
1056 void FormDocument::class_update(BufferParams const & params)
1061 UpdateClassParams(params);
1063 fl_set_choice_text(class_->choice_fonts, params.fonts.c_str());
1065 bool const indent = params.paragraph_separation == BufferParams::PARSEP_INDENT;
1066 fl_set_button(class_->radio_indent, indent);
1067 fl_set_button(class_->radio_skip, !indent);
1071 pos = 2; // VSpace::MEDSKIP is default
1073 switch (params.getDefSkip().kind()) {
1074 case VSpace::LENGTH:
1077 case VSpace::BIGSKIP:
1080 case VSpace::SMALLSKIP:
1083 case VSpace::MEDSKIP:
1089 fl_set_choice (class_->choice_skip, pos);
1091 bool const length_input = pos == 4;
1093 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1094 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
1095 || paperchoice == 2 || paperchoice > 5;
1096 string const default_unit = metric ? "cm" : "in";
1097 string const length = params.getDefSkip().asLyXCommand();
1098 updateWidgetsFromLengthString(class_->input_skip,
1099 class_->choice_skip_units,
1100 length, default_unit);
1103 fl_set_input(class_->input_skip, "");
1105 setEnabled(class_->choice_skip, !indent);
1106 setEnabled(class_->input_skip, length_input);
1107 setEnabled(class_->choice_skip_units, length_input);
1109 bool const two_sides = params.sides == LyXTextClass::TwoSides;
1110 fl_set_button(class_->radio_sides_one, !two_sides);
1111 fl_set_button(class_->radio_sides_two, two_sides);
1113 bool const two_columns = params.columns == 2;
1114 fl_set_button(class_->radio_columns_one, !two_columns);
1115 fl_set_button(class_->radio_columns_two, two_columns);
1117 fl_set_input(class_->input_extra, params.options.c_str());
1119 switch (params.spacing.getSpace()) {
1120 case Spacing::Other:
1123 case Spacing::Double: // \doublespacing
1126 case Spacing::Onehalf: // \onehalfspacing
1129 case Spacing::Single: // \singlespacing
1130 case Spacing::Default: // nothing bad should happen with this
1135 fl_set_choice(class_->choice_spacing, pos);
1137 bool const spacing_input = pos == 4;
1138 setEnabled(class_->input_spacing, spacing_input);
1139 string const input = spacing_input ? tostr(params.spacing.getValue()) : string();
1140 fl_set_input(class_->input_spacing, input.c_str());
1144 void FormDocument::language_update(BufferParams const & params)
1146 if (!language_.get())
1149 int const pos = int(findPos(lang_, params.language->lang()));
1150 fl_set_combox(language_->combox_language, pos+1);
1152 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1153 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1154 fl_set_button(language_->radio_single, 0);
1155 fl_set_button(language_->radio_double, 0);
1156 if (params.quotes_times == InsetQuotes::SingleQ)
1157 fl_set_button(language_->radio_single, 1);
1159 fl_set_button(language_->radio_double, 1);
1163 void FormDocument::options_update(BufferParams const & params)
1165 if (!options_.get())
1168 fl_set_choice_text(options_->choice_postscript_driver,
1169 params.graphicsDriver.c_str());
1170 fl_set_choice(options_->choice_ams_math, params.use_amsmath + 1);
1171 fl_set_button(options_->check_use_natbib, params.use_natbib);
1172 fl_set_choice(options_->choice_citation_format,
1173 int(params.use_numerical_citations)+1);
1174 setEnabled(options_->choice_citation_format, params.use_natbib);
1175 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1176 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1177 if (!params.float_placement.empty())
1178 fl_set_input(options_->input_float_placement,
1179 params.float_placement.c_str());
1181 fl_set_input(options_->input_float_placement, "");
1185 void FormDocument::paper_update(BufferParams const & params)
1190 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1191 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1192 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1194 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1195 bool const useCustom = paperchoice == 2;
1196 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1198 fl_set_button(paper_->radio_portrait, 0);
1199 setEnabled(paper_->radio_portrait, !useCustom);
1200 fl_set_button(paper_->radio_landscape, 0);
1201 setEnabled(paper_->radio_landscape, !useCustom);
1203 if (params.orientation == ORIENTATION_LANDSCAPE)
1204 fl_set_button(paper_->radio_landscape, 1);
1206 fl_set_button(paper_->radio_portrait, 1);
1207 setEnabled(paper_->choice_paperpackage,
1208 //either default papersize (preferences)
1209 //or document papersize has to be A4
1211 || paperchoice == 1 && lyxrc.default_papersize == PAPER_A4PAPER)
1212 && fl_get_button(paper_->radio_portrait));
1214 // Default unit choice is cm if metric, inches if US paper.
1215 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
1216 || paperchoice == 2 || paperchoice > 5;
1217 string const default_unit = metric ? "cm" : "in";
1218 updateWidgetsFromLengthString(paper_->input_custom_width,
1219 paper_->choice_custom_width_units,
1220 params.paperwidth, default_unit);
1221 setEnabled(paper_->input_custom_width, useCustom);
1222 setEnabled(paper_->choice_custom_width_units, useCustom);
1224 updateWidgetsFromLengthString(paper_->input_custom_height,
1225 paper_->choice_custom_height_units,
1226 params.paperheight, default_unit);
1227 setEnabled(paper_->input_custom_height, useCustom);
1228 setEnabled(paper_->choice_custom_height_units, useCustom);
1230 updateWidgetsFromLengthString(paper_->input_inner_margin,
1231 paper_->choice_inner_margin_units,
1232 params.leftmargin, default_unit);
1233 setEnabled(paper_->input_inner_margin, useGeom);
1234 setEnabled(paper_->choice_inner_margin_units, useGeom);
1236 updateWidgetsFromLengthString(paper_->input_top_margin,
1237 paper_->choice_top_margin_units,
1238 params.topmargin, default_unit);
1239 setEnabled(paper_->input_top_margin, useGeom);
1240 setEnabled(paper_->choice_top_margin_units, useGeom);
1242 updateWidgetsFromLengthString(paper_->input_outer_margin,
1243 paper_->choice_outer_margin_units,
1244 params.rightmargin, default_unit);
1245 setEnabled(paper_->input_outer_margin, useGeom);
1246 setEnabled(paper_->choice_outer_margin_units, useGeom);
1248 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1249 paper_->choice_bottom_margin_units,
1250 params.bottommargin, default_unit);
1251 setEnabled(paper_->input_bottom_margin, useGeom);
1252 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1254 updateWidgetsFromLengthString(paper_->input_head_height,
1255 paper_->choice_head_height_units,
1256 params.headheight, default_unit);
1257 setEnabled(paper_->input_head_height, useGeom);
1258 setEnabled(paper_->choice_head_height_units, useGeom);
1260 updateWidgetsFromLengthString(paper_->input_head_sep,
1261 paper_->choice_head_sep_units,
1262 params.headsep, default_unit);
1263 setEnabled(paper_->input_head_sep, useGeom);
1264 setEnabled(paper_->choice_head_sep_units, useGeom);
1266 updateWidgetsFromLengthString(paper_->input_foot_skip,
1267 paper_->choice_foot_skip_units,
1268 params.footskip, default_unit);
1269 setEnabled(paper_->input_foot_skip, useGeom);
1270 setEnabled(paper_->choice_foot_skip_units, useGeom);
1272 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1276 void FormDocument::bullets_update(BufferParams const & params)
1278 if (!bullets_.get() ||
1280 (XpmVersion==4 && XpmRevision<7)))
1283 bool const isLinuxDoc =
1284 controller().docType() == ControlDocument::LINUXDOC;
1285 setEnabled(fbullet, !isLinuxDoc);
1287 if (isLinuxDoc) return;
1289 fl_set_button(bullets_->radio_depth_1, 1);
1290 fl_set_input(bullets_->input_latex,
1291 params.user_defined_bullets[0].getText().c_str());
1292 fl_set_choice(bullets_->choice_size,
1293 params.user_defined_bullets[0].getSize() + 2);
1297 void FormDocument::branch_update(BufferParams const & params)
1302 string const all_branches = params.branchlist.allBranches();
1303 fl_clear_browser(branch_->browser_all_branches);
1304 string current_branch("none");
1306 if (!all_branches.empty()) {
1307 std::vector<string> vec = getVectorFromString(all_branches, "|");
1308 for (unsigned i = 0; i < vec.size(); ++i) {
1309 fl_addto_browser(branch_->browser_all_branches, vec[i].c_str());
1311 fl_select_browser_line(branch_->browser_all_branches, 1);
1314 fl_get_browser_line(branch_->browser_all_branches, 1);
1316 current_branch = "none";
1319 // display proper selection...
1320 string const all_selected = params.branchlist.allSelected();
1321 fl_clear_browser(branch_->browser_selection);
1322 if (!all_selected.empty()) {
1323 std::vector<string> vec = getVectorFromString(all_selected, "|");
1324 for (unsigned i = 0; i < vec.size(); ++i) {
1325 fl_addto_browser(branch_->browser_selection, vec[i].c_str());
1328 // display proper colour...
1331 if (current_branch == "none")
1332 x11hexname = "none";
1334 x11hexname = params.branchlist.getColor(current_branch);
1335 if (x11hexname[0] == '#') {
1336 rgb = RGBColor(x11hexname);
1338 fl_getmcolor(FL_COL1, &rgb.r, &rgb.g, &rgb.b);
1340 fl_mapcolor(GUI_COLOR_CHOICE, rgb.r, rgb.g, rgb.b);
1341 fl_redraw_object(branch_->button_color);
1343 setEnabled(branch_->button_select,
1344 (fl_get_browser(branch_->browser_all_branches) > 0));
1345 setEnabled(branch_->button_deselect,
1346 (fl_get_browser(branch_->browser_selection) > 0));
1347 setEnabled(branch_->button_remove_branch,
1348 (fl_get_browser(branch_->browser_all_branches) > 0));
1349 setEnabled(branch_->button_modify,
1350 (fl_get_browser(branch_->browser_all_branches) > 0));
1354 void FormDocument::checkReadOnly()
1356 if (bc().readOnly(controller().bufferIsReadonly())) {
1357 postWarning(_("Document is read-only."
1358 " No changes to layout permitted."));
1365 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1367 BufferParams & param = controller().params();
1369 // convert from 1-6 range to -1-4
1370 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1371 fl_set_input(bullets_->input_latex,
1372 param.temp_bullets[current_bullet_depth].getText().c_str());
1376 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1378 BufferParams & param = controller().params();
1380 param.temp_bullets[current_bullet_depth].
1381 setText(getString(bullets_->input_latex));
1385 void FormDocument::BulletDepth(FL_OBJECT * ob)
1387 /* Should I do the following: */
1388 /* 1. change to the panel that the current bullet belongs in */
1389 /* 2. show that bullet as selected */
1390 /* 3. change the size setting to the size of the bullet in Q.*/
1391 /* 4. display the latex equivalent in the latex box */
1393 /* I'm inclined to just go with 3 and 4 at the moment and */
1394 /* maybe try to support the others later */
1395 BufferParams & param = controller().params();
1398 if (ob == bullets_->radio_depth_1)
1400 else if (ob == bullets_->radio_depth_2)
1402 else if (ob == bullets_->radio_depth_3)
1404 else if (ob == bullets_->radio_depth_4)
1407 switch (fl_get_button_numb(ob)) {
1409 // right mouse button resets to default
1410 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1412 current_bullet_depth = data;
1413 fl_set_input(bullets_->input_latex,
1414 param.temp_bullets[data].getText().c_str());
1415 fl_set_choice(bullets_->choice_size,
1416 param.temp_bullets[data].getSize() + 2);
1421 void FormDocument::BulletPanel(FL_OBJECT * ob)
1423 /* Here we have to change the background pixmap to that selected */
1424 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1427 if (ob == bullets_->radio_panel_standard)
1429 else if (ob == bullets_->radio_panel_maths)
1431 else if (ob == bullets_->radio_panel_ding2)
1433 else if (ob == bullets_->radio_panel_ding3)
1435 else if (ob == bullets_->radio_panel_ding4)
1437 else if (ob == bullets_->radio_panel_ding1)
1440 if (data != current_bullet_panel) {
1441 fl_freeze_form(bullets_->form);
1442 current_bullet_panel = data;
1444 /* free the current pixmap */
1445 fl_free_bmtable_pixmap(bullets_->bmtable_panel);
1447 if (ob == bullets_->radio_panel_standard) {
1448 new_panel = "standard";
1449 } else if (ob == bullets_->radio_panel_maths ) {
1450 new_panel = "amssymb";
1451 } else if (ob == bullets_->radio_panel_ding2) {
1452 new_panel = "psnfss1";
1453 } else if (ob == bullets_->radio_panel_ding3) {
1454 new_panel = "psnfss2";
1455 } else if (ob == bullets_->radio_panel_ding4) {
1456 new_panel = "psnfss3";
1457 } else if (ob == bullets_->radio_panel_ding1) {
1458 new_panel = "psnfss4";
1460 /* something very wrong happened */
1461 // play it safe for now but should be an exception
1462 current_bullet_panel = 0; // standard panel
1463 new_panel = "standard";
1465 new_panel += ".xpm";
1466 fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6,
1467 LibFileSearch("images", new_panel).c_str());
1468 fl_redraw_object(bullets_->bmtable_panel);
1469 fl_unfreeze_form(bullets_->form);
1474 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1476 /* handle the user input by setting the current bullet depth's pixmap */
1477 /* to that extracted from the current chosen position of the BMTable */
1478 /* Don't forget to free the button's old pixmap first. */
1480 BufferParams & param = controller().params();
1481 int bmtable_button = fl_get_bmtable(ob);
1483 /* try to keep the button held down till another is pushed */
1484 /* fl_set_bmtable(ob, 1, bmtable_button); */
1485 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1486 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1487 fl_set_input(bullets_->input_latex,
1488 param.temp_bullets[current_bullet_depth].getText().c_str());
1492 void FormDocument::CheckChoiceClass()
1494 BufferParams & params = controller().params();
1496 lyx::textclass_type const tc =
1497 fl_get_combox(class_->combox_class) - 1;
1499 if (controller().loadTextclass(tc)) {
1500 params.textclass = tc;
1502 if (lyxrc.auto_reset_options) {
1503 params.useClassDefaults();
1504 UpdateLayoutDocument(params);
1506 // update the params which are needed in any case
1507 // (fontsizes, pagestyle)
1508 UpdateClassParams(params);
1512 int const revert = int(params.textclass);
1513 fl_set_combox(class_->combox_class, revert + 1);
1518 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1524 class_update(params);
1525 paper_update(params);
1526 language_update(params);
1527 options_update(params);
1528 bullets_update(params);