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"
34 #include "bufferparams.h"
37 #include "lyxtextclasslist.h"
38 #include "tex-strings.h"
40 #include "support/tostr.h"
41 #include "support/lstrings.h" // contains_functor, getStringFromVector
42 #include "support/filetools.h" // LibFileSearch
48 using namespace lyx::support;
58 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
59 bool const scalableTabfolders = false;
61 bool const scalableTabfolders = true;
68 typedef FormCB<ControlDocument, FormDB<FD_document> > base_class;
70 FormDocument::FormDocument()
71 : base_class(_("Document Settings"), scalableTabfolders),
72 ActCell(0), Confirmed(0),
73 current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
77 void FormDocument::redraw()
79 if (form() && form()->visible)
80 fl_redraw_form(form());
84 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
85 if (outer_form && outer_form->visible)
86 fl_redraw_form(outer_form);
90 void FormDocument::build()
93 dialog_.reset(build_document(this));
95 // Allow the base class to control messages
96 setMessageWidget(dialog_->text_warning);
98 // Manage the restore, ok, apply, restore and cancel/close buttons
99 bcview().setOK(dialog_->button_ok);
100 bcview().setApply(dialog_->button_apply);
101 bcview().setCancel(dialog_->button_close);
102 bcview().setRestore(dialog_->button_restore);
104 // the document class form
105 class_.reset(build_document_class(this));
107 // disable for read-only documents
108 bcview().addReadOnly(class_->combox_class);
109 bcview().addReadOnly(class_->radio_indent);
110 bcview().addReadOnly(class_->radio_skip);
111 bcview().addReadOnly(class_->choice_pagestyle);
112 bcview().addReadOnly(class_->choice_fonts);
113 bcview().addReadOnly(class_->choice_fontsize);
114 bcview().addReadOnly(class_->radio_sides_one);
115 bcview().addReadOnly(class_->radio_sides_two);
116 bcview().addReadOnly(class_->radio_columns_one);
117 bcview().addReadOnly(class_->radio_columns_two);
118 bcview().addReadOnly(class_->input_extra);
119 bcview().addReadOnly(class_->input_skip);
120 bcview().addReadOnly(class_->choice_skip);
121 bcview().addReadOnly(class_->choice_spacing);
122 bcview().addReadOnly(class_->input_spacing);
124 // check validity of "length + unit" input
125 addCheckedGlueLength(bcview(), class_->input_skip,
126 class_->choice_skip);
128 // trigger an input event for cut&paste with middle mouse button.
129 setPrehandler(class_->input_extra);
130 setPrehandler(class_->input_skip);
131 setPrehandler(class_->input_spacing);
133 fl_set_input_return(class_->input_extra, FL_RETURN_CHANGED);
134 fl_set_input_return(class_->input_skip, FL_RETURN_CHANGED);
135 fl_set_input_return(class_->input_spacing, FL_RETURN_CHANGED);
139 // Fill the combox and choices.
140 obj = class_->combox_class;
141 LyXTextClassList::const_iterator tit = textclasslist.begin();
142 LyXTextClassList::const_iterator tend = textclasslist.end();
143 for (; tit != tend; ++tit) {
144 if (tit->isTeXClassAvailable()) {
145 fl_addto_combox(obj, tit->description().c_str());
147 string item = bformat(_("Unavailable: %1$s"), tit->description());
148 fl_addto_combox(obj, item.c_str());
151 fl_set_combox_browser_height(obj, 400);
153 fl_addto_choice(class_->choice_spacing,
154 _(" Single | OneHalf | Double | Custom ").c_str());
155 fl_addto_choice(class_->choice_fontsize, "default|10|11|12");
156 for (int n = 0; tex_fonts[n][0]; ++n) {
157 fl_addto_choice(class_->choice_fonts,tex_fonts[n]);
160 // Create the contents of the unit choices; don't include the
162 vector<string> units_vec = getLatexUnits();
163 vector<string>::iterator ret =
164 std::remove_if(units_vec.begin(),
166 bind2nd(contains_functor(), "%"));
167 units_vec.erase(ret, units_vec.end());
169 string const units = getStringFromVector(units_vec, "|");
171 fl_addto_choice(class_->choice_pagestyle,
172 "default|empty|plain|headings|fancy");
173 fl_addto_choice(class_->choice_skip,
174 _(" SmallSkip | MedSkip | BigSkip | Length ").c_str());
175 fl_addto_choice(class_->choice_skip_units, units.c_str());
177 // Set input filters on doc spacing to make it accept only
179 fl_set_input_filter(class_->input_spacing,
180 fl_unsigned_float_filter);
182 // disable for read-only documents
183 bcview().addReadOnly(dialog_->button_save_defaults);
184 bcview().addReadOnly(dialog_->button_reset_defaults);
186 // the document paper form
187 paper_.reset(build_document_paper(this));
189 // disable for read-only documents
190 bcview().addReadOnly(paper_->choice_paperpackage);
191 bcview().addReadOnly(paper_->radio_portrait);
192 bcview().addReadOnly(paper_->radio_landscape);
193 bcview().addReadOnly(paper_->choice_papersize);
194 bcview().addReadOnly(paper_->check_use_geometry);
195 bcview().addReadOnly(paper_->input_custom_width);
196 bcview().addReadOnly(paper_->input_custom_height);
197 bcview().addReadOnly(paper_->input_top_margin);
198 bcview().addReadOnly(paper_->input_bottom_margin);
199 bcview().addReadOnly(paper_->input_inner_margin);
200 bcview().addReadOnly(paper_->input_outer_margin);
201 bcview().addReadOnly(paper_->input_head_height);
202 bcview().addReadOnly(paper_->input_head_sep);
203 bcview().addReadOnly(paper_->input_foot_skip);
205 // check validity of "length + unit" input
206 addCheckedGlueLength(bcview(), paper_->input_custom_width);
207 addCheckedGlueLength(bcview(), paper_->input_custom_height);
208 addCheckedGlueLength(bcview(), paper_->input_top_margin);
209 addCheckedGlueLength(bcview(), paper_->input_bottom_margin);
210 addCheckedGlueLength(bcview(), paper_->input_inner_margin);
211 addCheckedGlueLength(bcview(), paper_->input_outer_margin);
212 addCheckedGlueLength(bcview(), paper_->input_head_height);
213 addCheckedGlueLength(bcview(), paper_->input_head_sep);
214 addCheckedGlueLength(bcview(), paper_->input_foot_skip);
216 // trigger an input event for cut&paste with middle mouse button.
217 setPrehandler(paper_->input_custom_width);
218 setPrehandler(paper_->input_custom_height);
219 setPrehandler(paper_->input_top_margin);
220 setPrehandler(paper_->input_bottom_margin);
221 setPrehandler(paper_->input_inner_margin);
222 setPrehandler(paper_->input_outer_margin);
223 setPrehandler(paper_->input_head_height);
224 setPrehandler(paper_->input_head_sep);
225 setPrehandler(paper_->input_foot_skip);
227 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
228 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
229 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
230 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
231 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
232 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
233 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
234 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
235 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
237 fl_addto_choice(paper_->choice_papersize,
238 _(" Default | Custom | US letter | US legal "
239 "| US executive | A3 | A4 | A5 "
240 "| B3 | B4 | B5 ").c_str());
241 fl_addto_choice(paper_->choice_paperpackage,
244 "| Very small Margins "
245 "| Very wide Margins ").c_str());
247 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
248 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
249 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
250 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
251 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
252 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
253 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
254 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
255 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
257 // the document language form
258 language_.reset(build_document_language(this));
260 // disable for read-only documents
261 bcview().addReadOnly(language_->combox_language);
262 bcview().addReadOnly(language_->choice_inputenc);
263 bcview().addReadOnly(language_->choice_quotes_language);
264 bcview().addReadOnly(language_->radio_single);
265 bcview().addReadOnly(language_->radio_double);
267 fl_addto_choice(language_->choice_inputenc,
268 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
269 "|koi8-r|koi8-u|cp866|cp1251|iso88595|pt154");
271 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
272 // Store the identifiers for later
273 lang_ = getSecond(langs);
275 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
276 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
277 for (; lit != lend; ++lit) {
278 fl_addto_combox(language_->combox_language,
281 fl_set_combox_browser_height(language_->combox_language, 400);
283 fl_addto_choice(language_->choice_quotes_language,
284 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
285 " «text» | »text« ").c_str());
287 // the document options form
288 options_.reset(build_document_options(this));
290 // disable for read-only documents
291 bcview().addReadOnly(options_->counter_secnumdepth);
292 bcview().addReadOnly(options_->counter_tocdepth);
293 bcview().addReadOnly(options_->choice_ams_math);
294 bcview().addReadOnly(options_->check_use_natbib);
295 bcview().addReadOnly(options_->choice_citation_format);
296 bcview().addReadOnly(options_->input_float_placement);
297 bcview().addReadOnly(options_->choice_postscript_driver);
299 // trigger an input event for cut&paste with middle mouse button.
300 setPrehandler(options_->input_float_placement);
302 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
304 fl_addto_choice(options_->choice_ams_math,
305 _("Never | Automatically | Yes ").c_str());
307 for (int n = 0; tex_graphics[n][0]; ++n) {
308 fl_addto_choice(options_->choice_postscript_driver,
311 fl_addto_choice(options_->choice_citation_format,
312 _(" Author-year | Numerical ").c_str());
314 // the document bullets form
315 bullets_.reset(build_document_bullet(this));
317 // disable for read-only documents
318 bcview().addReadOnly(bullets_->radio_depth_1);
319 bcview().addReadOnly(bullets_->radio_depth_2);
320 bcview().addReadOnly(bullets_->radio_depth_3);
321 bcview().addReadOnly(bullets_->radio_depth_4);
322 bcview().addReadOnly(bullets_->radio_panel_standard);
323 bcview().addReadOnly(bullets_->radio_panel_maths);
324 bcview().addReadOnly(bullets_->radio_panel_ding1);
325 bcview().addReadOnly(bullets_->radio_panel_ding2);
326 bcview().addReadOnly(bullets_->radio_panel_ding3);
327 bcview().addReadOnly(bullets_->radio_panel_ding4);
328 bcview().addReadOnly(bullets_->bmtable_panel);
329 bcview().addReadOnly(bullets_->choice_size);
330 bcview().addReadOnly(bullets_->input_latex);
332 // trigger an input event for cut&paste with middle mouse button.
333 setPrehandler(bullets_->input_latex);
335 fl_set_input_return(bullets_->input_latex, FL_RETURN_CHANGED);
337 fl_addto_choice(bullets_->choice_size,
338 _(" Default | Tiny | Smallest | Smaller "
339 "| Small | Normal | Large | Larger | Largest "
340 "| Huge | Huger ").c_str());
341 fl_set_choice(bullets_->choice_size, 1);
343 fl_set_input_maxchars(bullets_->input_latex, 80);
345 string const bmtablefile = LibFileSearch("images", "standard", "xpm");
346 fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6,
347 bmtablefile.c_str());
349 picker_.reset(new FormColorpicker);
351 // the document branches form
352 branch_.reset(build_document_branch(this));
354 fl_set_object_color(branch_->button_color,
355 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
357 bcview().addReadOnly(branch_->input_all_branches);
358 bcview().addReadOnly(branch_->button_add_branch);
359 bcview().addReadOnly(branch_->button_remove_branch);
360 bcview().addReadOnly(branch_->button_select);
361 bcview().addReadOnly(branch_->button_deselect);
362 bcview().addReadOnly(branch_->button_modify);
363 bcview().addReadOnly(branch_->browser_all_branches);
365 // set up the tooltips for branches form
366 string str = _("Enter the name of a new branch.");
367 tooltips().init(branch_->input_all_branches, str);
368 str = _("Add a new branch to the document.");
369 tooltips().init(branch_->button_add_branch, str);
370 str = _("Remove the selected branch from the document.");
371 tooltips().init(branch_->button_remove_branch, str);
372 str = _("Activate the selected branch for output.");
373 tooltips().init(branch_->button_select, str);
374 str = _("Deactivate the selected activated branch.");
375 tooltips().init(branch_->button_deselect, str);
376 str = _("Available branches for this document.");
377 tooltips().init(branch_->browser_all_branches, str);
378 str = _("Activated branches. Content will occur in the document\'s output");
379 tooltips().init(branch_->browser_selection, str);
380 str = _("Modify background color of branch inset");
381 tooltips().init(branch_->button_modify, str);
382 str = _("Background color of branch inset");
383 tooltips().init(branch_->button_color, str);
385 // Handle middle mouse paint:
386 setPrehandler(branch_->input_all_branches);
387 fl_set_input_return(branch_->input_all_branches, FL_RETURN_CHANGED);
389 // Enable the tabfolder to be rescaled correctly.
390 if (scalableTabfolders)
391 fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
394 fl_addto_tabfolder(dialog_->tabfolder,_("Document").c_str(),
396 fl_addto_tabfolder(dialog_->tabfolder,_("Paper").c_str(),
398 fl_addto_tabfolder(dialog_->tabfolder,_("Language").c_str(),
400 fl_addto_tabfolder(dialog_->tabfolder,_("Extra").c_str(),
402 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets").c_str(),
405 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
406 lyxerr << _("Your version of libXpm is older than 4.7.\n"
407 "The `bullet' tab of the document dialog "
408 "has been disabled") << '\n';
409 fl_deactivate_object(fbullet);
410 fl_set_object_lcol(fbullet, FL_INACTIVE);
413 fl_addto_tabfolder(dialog_->tabfolder,_("Branches").c_str(),
418 void FormDocument::apply()
420 BufferParams & params = controller().params();
424 language_apply(params);
425 options_apply(params);
426 bullets_apply(params);
427 branch_apply(params);
431 void FormDocument::update()
438 BufferParams const & params = controller().params();
440 class_update(params);
441 paper_update(params);
442 language_update(params);
443 options_update(params);
444 bullets_update(params);
445 branch_update(params);
449 ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
451 if (ob == bullets_->choice_size) {
452 ChoiceBulletSize(ob, 0);
454 } else if (ob == bullets_->input_latex) {
455 InputBulletLaTeX(ob, 0);
457 } else if (ob == bullets_->radio_depth_1 ||
458 ob == bullets_->radio_depth_2 ||
459 ob == bullets_->radio_depth_3 ||
460 ob == bullets_->radio_depth_4) {
463 } else if (ob == bullets_->radio_panel_standard ||
464 ob == bullets_->radio_panel_maths ||
465 ob == bullets_->radio_panel_ding1 ||
466 ob == bullets_->radio_panel_ding2 ||
467 ob == bullets_->radio_panel_ding3 ||
468 ob == bullets_->radio_panel_ding4) {
471 } else if (ob == bullets_->bmtable_panel) {
472 BulletBMTable(ob, 0);
474 } else if (ob == class_->choice_spacing) {
475 setEnabled(class_->input_spacing,
476 fl_get_choice(class_->choice_spacing) == 4);
478 } else if (ob == class_->combox_class) {
480 } else if (ob == class_->radio_skip ||
481 ob == class_->radio_indent ||
482 ob == class_->choice_skip) {
483 bool const skip_used = fl_get_button(class_->radio_skip);
484 setEnabled(class_->choice_skip, skip_used);
486 bool const length_input =
487 fl_get_choice(class_->choice_skip) == 4;
488 setEnabled(class_->input_skip,
489 skip_used && length_input);
490 setEnabled(class_->choice_skip_units,
491 skip_used && length_input);
493 // Default unit choice is cm if metric, inches if US paper.
494 // If papersize is default, check the lyxrc-settings
495 int const paperchoice = fl_get_choice(paper_->choice_papersize);
496 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
497 || paperchoice == 2 || paperchoice > 5;
498 string const default_unit = metric ? "cm" : "in";
499 if (getString(class_->input_skip).empty())
500 fl_set_choice_text(class_->choice_skip_units,
501 default_unit.c_str());
503 } else if (ob == options_->check_use_natbib) {
504 setEnabled(options_->choice_citation_format,
505 fl_get_button(options_->check_use_natbib));
507 } else if (ob == branch_->browser_all_branches ||
508 ob == branch_->browser_selection ||
509 ob == branch_->button_add_branch ||
510 ob == branch_->button_remove_branch ||
511 ob == branch_->button_modify ||
512 ob == branch_->button_select ||
513 ob == branch_->button_deselect ||
514 ob == branch_->button_deselect) {
516 } else if (ob == dialog_->button_save_defaults) {
518 controller().saveAsDefault();
520 } else if (ob == dialog_->button_reset_defaults) {
521 BufferParams & params = controller().params();
522 params.textclass = fl_get_combox(class_->combox_class) - 1;
523 params.useClassDefaults();
524 UpdateLayoutDocument(params);
526 } else if (ob == paper_->radio_landscape) {
527 fl_set_choice(paper_->choice_paperpackage,
530 } else if (ob == paper_->choice_papersize) {
531 int const paperchoice = fl_get_choice(paper_->choice_papersize);
532 bool const defsize = paperchoice == 1;
533 bool const custom = paperchoice == 2;
534 bool const a3size = paperchoice == 6;
535 bool const b3size = paperchoice == 9;
536 bool const b4size = paperchoice == 10;
539 fl_set_button(paper_->radio_portrait, 1);
541 bool const use_geom = (custom || a3size || b3size || b4size);
543 fl_set_button(paper_->check_use_geometry, int(use_geom));
545 setEnabled(paper_->input_top_margin, use_geom);
546 setEnabled(paper_->input_bottom_margin, use_geom);
547 setEnabled(paper_->input_inner_margin, use_geom);
548 setEnabled(paper_->input_outer_margin, use_geom);
549 setEnabled(paper_->input_head_height, use_geom);
550 setEnabled(paper_->input_head_sep, use_geom);
551 setEnabled(paper_->input_foot_skip, use_geom);
552 setEnabled(paper_->choice_top_margin_units, use_geom);
553 setEnabled(paper_->choice_bottom_margin_units, use_geom);
554 setEnabled(paper_->choice_inner_margin_units, use_geom);
555 setEnabled(paper_->choice_outer_margin_units, use_geom);
556 setEnabled(paper_->choice_head_height_units, use_geom);
557 setEnabled(paper_->choice_head_sep_units, use_geom);
558 setEnabled(paper_->choice_foot_skip_units, use_geom);
559 setEnabled(paper_->choice_custom_width_units, use_geom);
560 setEnabled(paper_->choice_custom_height_units, use_geom);
562 setEnabled(paper_->input_custom_width, custom);
563 setEnabled(paper_->input_custom_height, custom);
564 setEnabled(paper_->choice_custom_width_units, custom);
565 setEnabled(paper_->choice_custom_height_units, custom);
566 setEnabled(paper_->radio_portrait, !custom);
567 setEnabled(paper_->radio_landscape, !custom);
569 // Default unit choice is cm if metric, inches if US paper.
570 // If papersize is default, use the lyxrc-settings
571 bool const metric = (defsize && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
572 || paperchoice == 2 || paperchoice > 5;
573 string const default_unit = metric ? "cm" : "in";
574 if (getString(paper_->input_custom_width).empty())
575 fl_set_choice_text(paper_->choice_custom_width_units,
576 default_unit.c_str());
577 if (getString(paper_->input_custom_height).empty())
578 fl_set_choice_text(paper_->choice_custom_height_units,
579 default_unit.c_str());
580 if (getString(paper_->input_top_margin).empty())
581 fl_set_choice_text(paper_->choice_top_margin_units,
582 default_unit.c_str());
583 if (getString(paper_->input_bottom_margin).empty())
584 fl_set_choice_text(paper_->choice_bottom_margin_units,
585 default_unit.c_str());
586 if (getString(paper_->input_inner_margin).empty())
587 fl_set_choice_text(paper_->choice_inner_margin_units,
588 default_unit.c_str());
589 if (getString(paper_->input_outer_margin).empty())
590 fl_set_choice_text(paper_->choice_outer_margin_units,
591 default_unit.c_str());
592 if (getString(paper_->input_head_height).empty())
593 fl_set_choice_text(paper_->choice_head_height_units,
594 default_unit.c_str());
595 if (getString(paper_->input_head_sep).empty())
596 fl_set_choice_text(paper_->choice_head_sep_units,
597 default_unit.c_str());
598 if (getString(paper_->input_foot_skip).empty())
599 fl_set_choice_text(paper_->choice_foot_skip_units,
600 default_unit.c_str());
602 } else if (ob == paper_->choice_paperpackage &&
603 fl_get_choice(paper_->choice_paperpackage) != 1) {
605 fl_set_button(paper_->check_use_geometry, 0);
606 setEnabled(paper_->input_top_margin, false);
607 setEnabled(paper_->input_bottom_margin, false);
608 setEnabled(paper_->input_inner_margin, false);
609 setEnabled(paper_->input_outer_margin, false);
610 setEnabled(paper_->input_head_height, false);
611 setEnabled(paper_->input_head_sep, false);
612 setEnabled(paper_->input_foot_skip, false);
613 setEnabled(paper_->choice_top_margin_units, false);
614 setEnabled(paper_->choice_bottom_margin_units, false);
615 setEnabled(paper_->choice_inner_margin_units, false);
616 setEnabled(paper_->choice_outer_margin_units, false);
617 setEnabled(paper_->choice_head_height_units, false);
618 setEnabled(paper_->choice_head_sep_units, false);
619 setEnabled(paper_->choice_foot_skip_units, false);
621 } else if (ob == paper_->check_use_geometry) {
622 // don't allow switching geometry off in custom papersize
623 // mode nor in A3, B3, and B4
624 int const choice = fl_get_choice(paper_->choice_papersize);
625 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
626 fl_set_button(paper_->check_use_geometry, 1);
628 fl_set_choice(paper_->choice_paperpackage,
631 bool const use_geom = fl_get_button(paper_->check_use_geometry);
632 setEnabled(paper_->input_top_margin, use_geom);
633 setEnabled(paper_->input_bottom_margin, use_geom);
634 setEnabled(paper_->input_inner_margin, use_geom);
635 setEnabled(paper_->input_outer_margin, use_geom);
636 setEnabled(paper_->input_head_height, use_geom);
637 setEnabled(paper_->input_head_sep, use_geom);
638 setEnabled(paper_->input_foot_skip, use_geom);
639 setEnabled(paper_->choice_top_margin_units, use_geom);
640 setEnabled(paper_->choice_bottom_margin_units, use_geom);
641 setEnabled(paper_->choice_inner_margin_units, use_geom);
642 setEnabled(paper_->choice_outer_margin_units, use_geom);
643 setEnabled(paper_->choice_head_height_units, use_geom);
644 setEnabled(paper_->choice_head_sep_units, use_geom);
645 setEnabled(paper_->choice_foot_skip_units, use_geom);
648 if (ob == paper_->choice_papersize || ob == paper_->radio_portrait
649 || ob == paper_->radio_landscape) {
650 // either default papersize (preferences) or document
651 // papersize has to be A4
652 bool const enable = ( fl_get_choice(paper_->choice_papersize) == 1
653 && lyxrc.default_papersize == PAPER_A4PAPER )
654 || fl_get_choice(paper_->choice_papersize) == 7;
656 fl_set_choice(paper_->choice_paperpackage,
658 setEnabled(paper_->choice_paperpackage,
659 enable && fl_get_button(paper_->radio_portrait));
662 return ButtonPolicy::SMI_VALID;
666 void FormDocument::branch_input(FL_OBJECT * ob)
668 BufferParams & params = controller().params();
669 std::vector<string> vec;
671 if (ob == branch_->button_add_branch) {
672 string new_branch = fl_get_input(branch_->input_all_branches);
673 if (!new_branch.empty()) {
674 params.branchlist.add(new_branch);
675 fl_set_input(branch_->input_all_branches, "");
676 // Update branch list
677 string const all_branches = params.branchlist.allBranches();
678 fl_clear_browser(branch_->browser_all_branches);
679 vec = getVectorFromString(all_branches, "|");
680 for (unsigned i = 0; i < vec.size(); ++i) {
681 fl_addto_browser(branch_->browser_all_branches,
684 LColor::color c = static_cast<LColor::color>(lcolor.size());
685 lcolor.fill(c, new_branch, lcolor.getX11Name(LColor::background));
688 } else if (ob == branch_->button_remove_branch) {
689 unsigned i = fl_get_browser(branch_->browser_all_branches);
690 string const current_branch =
691 fl_get_browser_line(branch_->browser_all_branches, i);
692 if (!current_branch.empty()) {
693 params.branchlist.remove(current_branch);
694 // Update branch list
695 string const all_branches = params.branchlist.allBranches();
696 fl_clear_browser(branch_->browser_all_branches);
697 vec = getVectorFromString(all_branches, "|");
698 for (unsigned i = 0; i < vec.size(); ++i) {
699 fl_addto_browser(branch_->browser_all_branches,
702 // Update selected-list...
703 string const all_selected = params.branchlist.allSelected();
704 fl_clear_browser(branch_->browser_selection);
705 vec = getVectorFromString(all_selected, "|");
706 for (unsigned i = 0; i < vec.size(); ++i) {
707 fl_addto_browser(branch_->browser_selection, vec[i].c_str());
710 } else if (ob == branch_->button_select) {
711 unsigned i = fl_get_browser(branch_->browser_all_branches);
712 string const current_branch =
713 fl_get_browser_line(branch_->browser_all_branches, i);
714 if (!current_branch.empty()) {
715 fl_clear_browser(branch_->browser_selection);
716 params.branchlist.setSelected(current_branch, true);
717 string const all_selected = params.branchlist.allSelected();
718 vec = getVectorFromString(all_selected, "|");
719 for (unsigned i = 0; i < vec.size(); ++i) {
720 fl_addto_browser(branch_->browser_selection,
724 } else if (ob == branch_->button_deselect) {
725 unsigned i = fl_get_browser(branch_->browser_selection);
726 string const current_sel =
727 fl_get_browser_line(branch_->browser_selection, i);
728 if (!current_sel.empty()) {
729 fl_clear_browser(branch_->browser_selection);
730 params.branchlist.setSelected(current_sel, false);
731 string const all_selected = params.branchlist.allSelected();
732 vec = getVectorFromString(all_selected, "|");
733 for (unsigned i = 0; i < vec.size(); ++i) {
734 fl_addto_browser(branch_->browser_selection,
738 } else if (ob == branch_->button_modify) {
739 unsigned i = fl_get_browser(branch_->browser_all_branches);
740 string const current_branch =
741 fl_get_browser_line(branch_->browser_all_branches, i);
744 string x11hexname = params.branchlist.getColor(current_branch);
745 if (x11hexname[0] == '#') {
746 before = RGBColor(x11hexname);
748 fl_getmcolor(FL_COL1, &before.r, &before.g, &before.b);
751 RGBColor col = picker_->requestColor(before);
753 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
754 fl_redraw_object(branch_->button_color);
755 // Figure out here how to stash the new colour into the
756 // LyX colour database.
758 x11hexname = X11hexname(col);
760 // current_branch already in database
761 LColor::color c = lcolor.getFromLyXName(current_branch);
762 lcolor.setColor(current_branch, x11hexname);
763 // Make sure that new colour is also displayed ;-)
764 lyxColorHandler->getGCForeground(c);
765 lyxColorHandler->updateColor(c);
766 // what about system_lcolor?
767 // Here set colour in BranchList:
768 params.branchlist.setColor(current_branch, x11hexname);
770 } else if (ob == branch_->browser_all_branches) {
771 unsigned i = fl_get_browser(branch_->browser_all_branches);
772 string const current_branch =
773 fl_get_browser_line(branch_->browser_all_branches, i);
774 // make button_color track selected branch:
777 string x11hexname = params.branchlist.getColor(current_branch);
778 if (x11hexname[0] == '#') {
779 rgb = RGBColor(x11hexname);
781 fl_getmcolor(FL_COL1, &rgb.r, &rgb.g, &rgb.b);
783 fl_mapcolor(GUI_COLOR_CHOICE, rgb.r, rgb.g, rgb.b);
784 fl_redraw_object(branch_->button_color);
786 setEnabled(branch_->button_select,
787 (fl_get_browser(branch_->browser_all_branches) > 0));
788 setEnabled(branch_->button_deselect,
789 (fl_get_browser(branch_->browser_selection) > 0));
790 setEnabled(branch_->button_remove_branch,
791 (fl_get_browser(branch_->browser_all_branches) > 0));
792 setEnabled(branch_->button_modify,
793 (fl_get_browser(branch_->browser_all_branches) > 0));
795 branchlist_ = params.branchlist;
799 bool FormDocument::class_apply(BufferParams ¶ms)
803 // If default skip is a "Length" but there's no text in the
804 // input field, reset the kind to "MedSkip", which is the default.
805 if (fl_get_choice(class_->choice_skip) == 4 &&
806 getString(class_->input_skip).empty()) {
807 fl_set_choice(class_->choice_skip, 2);
809 params.fonts = getString(class_->choice_fonts);
810 params.fontsize = getString(class_->choice_fontsize);
811 params.pagestyle = getString(class_->choice_pagestyle);
813 params.textclass = fl_get_combox(class_->combox_class) - 1;
815 BufferParams::PARSEP tmpsep = params.paragraph_separation;
816 if (fl_get_button(class_->radio_indent))
817 params.paragraph_separation = BufferParams::PARSEP_INDENT;
819 params.paragraph_separation = BufferParams::PARSEP_SKIP;
820 if (tmpsep != params.paragraph_separation)
823 VSpace tmpdefskip = params.getDefSkip();
824 switch (fl_get_choice(class_->choice_skip)) {
826 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
829 params.setDefSkip(VSpace(VSpace::MEDSKIP));
832 params.setDefSkip(VSpace(VSpace::BIGSKIP));
836 string const length =
837 getLengthFromWidgets(class_->input_skip,
838 class_->choice_skip_units);
840 params.setDefSkip(VSpace(LyXGlueLength(length)));
844 // DocumentDefskipCB assures that this never happens
845 params.setDefSkip(VSpace(VSpace::MEDSKIP));
848 if (!(tmpdefskip == params.getDefSkip()))
851 if (fl_get_button(class_->radio_columns_two))
855 if (fl_get_button(class_->radio_sides_two))
856 params.sides = LyXTextClass::TwoSides;
858 params.sides = LyXTextClass::OneSide;
860 Spacing tmpSpacing = params.spacing;
861 switch (fl_get_choice(class_->choice_spacing)) {
863 lyxerr[Debug::INFO] << "Spacing: SINGLE" << endl;
864 params.spacing.set(Spacing::Single);
867 lyxerr[Debug::INFO] << "Spacing: ONEHALF" << endl;
868 params.spacing.set(Spacing::Onehalf);
871 lyxerr[Debug::INFO] << "Spacing: DOUBLE" << endl;
872 params.spacing.set(Spacing::Double);
875 lyxerr[Debug::INFO] << "Spacing: OTHER" << endl;
876 params.spacing.set(Spacing::Other,
877 getString(class_->input_spacing));
880 if (tmpSpacing != params.spacing)
883 params.options = getString(class_->input_extra);
889 void FormDocument::paper_apply(BufferParams & params)
891 params.papersize2 = VMARGIN_PAPER_TYPE(fl_get_choice(paper_->choice_papersize) - 1);
893 params.paperpackage =
894 PAPER_PACKAGES(fl_get_choice(paper_->choice_paperpackage) - 1);
896 // set params.papersize from params.papersize2 and params.paperpackage
897 params.setPaperStuff();
899 params.use_geometry = fl_get_button(paper_->check_use_geometry);
901 if (fl_get_button(paper_->radio_landscape))
902 params.orientation = ORIENTATION_LANDSCAPE;
904 params.orientation = ORIENTATION_PORTRAIT;
907 getLengthFromWidgets(paper_->input_custom_width,
908 paper_->choice_custom_width_units);
911 getLengthFromWidgets(paper_->input_custom_height,
912 paper_->choice_custom_height_units);
915 getLengthFromWidgets(paper_->input_inner_margin,
916 paper_->choice_inner_margin_units);
919 getLengthFromWidgets(paper_->input_top_margin,
920 paper_->choice_top_margin_units);
923 getLengthFromWidgets(paper_->input_outer_margin,
924 paper_->choice_outer_margin_units);
926 params.bottommargin =
927 getLengthFromWidgets(paper_->input_bottom_margin,
928 paper_->choice_bottom_margin_units);
931 getLengthFromWidgets(paper_->input_head_height,
932 paper_->choice_head_height_units);
935 getLengthFromWidgets(paper_->input_head_sep,
936 paper_->choice_head_sep_units);
939 getLengthFromWidgets(paper_->input_foot_skip,
940 paper_->choice_foot_skip_units);
944 bool FormDocument::language_apply(BufferParams & params)
946 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
949 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
951 lga = InsetQuotes::EnglishQ;
954 lga = InsetQuotes::SwedishQ;
957 lga = InsetQuotes::GermanQ;
960 lga = InsetQuotes::PolishQ;
963 lga = InsetQuotes::FrenchQ;
966 lga = InsetQuotes::DanishQ;
969 params.quotes_language = lga;
970 if (fl_get_button(language_->radio_single))
971 params.quotes_times = InsetQuotes::SingleQ;
973 params.quotes_times = InsetQuotes::DoubleQ;
975 int const pos = fl_get_combox(language_->combox_language);
976 Language const * new_language = languages.getLanguage(lang_[pos-1]);
978 new_language = default_language;
980 params.language = new_language;
981 params.inputenc = getString(language_->choice_inputenc);
987 bool FormDocument::options_apply(BufferParams & params)
991 params.graphicsDriver = getString(options_->choice_postscript_driver);
992 params.use_amsmath = static_cast<BufferParams::AMS>(
993 fl_get_choice(options_->choice_ams_math) - 1);
994 params.use_natbib = fl_get_button(options_->check_use_natbib);
995 params.use_numerical_citations =
996 fl_get_choice(options_->choice_citation_format) - 1;
998 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
999 if (params.secnumdepth != tmpchar)
1001 params.secnumdepth = tmpchar;
1003 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
1005 params.float_placement =
1006 getString(options_->input_float_placement);
1012 void FormDocument::bullets_apply(BufferParams & params)
1014 /* update the bullet settings */
1015 BufferParams & buf_params = controller().params();
1017 for (int i = 0; i < 4; ++i) {
1018 params.user_defined_bullets[i] = buf_params.temp_bullets[i];
1023 void FormDocument::branch_apply(BufferParams & params)
1025 BufferParams & prms = controller().params();
1026 if (branchlist_.empty())
1027 branchlist_ = prms.branchlist;
1028 params.branchlist = branchlist_;
1029 branchlist_.clear();
1033 void FormDocument::UpdateClassParams(BufferParams const & params)
1035 // These are the params that have to be updated on any class change
1036 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
1038 LyXTextClass const & tclass = textclasslist[params.textclass];
1040 fl_set_combox(class_->combox_class, params.textclass + 1);
1041 fl_clear_choice(class_->choice_fontsize);
1042 fl_addto_choice(class_->choice_fontsize, "default");
1043 fl_addto_choice(class_->choice_fontsize,
1044 tclass.opt_fontsize().c_str());
1045 fl_set_choice_text(class_->choice_fontsize,
1046 params.fontsize.c_str());
1047 fl_clear_choice(class_->choice_pagestyle);
1048 fl_addto_choice(class_->choice_pagestyle, "default");
1049 fl_addto_choice(class_->choice_pagestyle,
1050 tclass.opt_pagestyle().c_str());
1051 fl_set_choice_text(class_->choice_pagestyle,
1052 params.pagestyle.c_str());
1054 fl_set_input(class_->input_extra, tclass.options().c_str());
1057 void FormDocument::class_update(BufferParams const & params)
1062 UpdateClassParams(params);
1064 fl_set_choice_text(class_->choice_fonts, params.fonts.c_str());
1066 bool const indent = params.paragraph_separation == BufferParams::PARSEP_INDENT;
1067 fl_set_button(class_->radio_indent, indent);
1068 fl_set_button(class_->radio_skip, !indent);
1072 pos = 2; // VSpace::MEDSKIP is default
1074 switch (params.getDefSkip().kind()) {
1075 case VSpace::LENGTH:
1078 case VSpace::BIGSKIP:
1081 case VSpace::SMALLSKIP:
1084 case VSpace::MEDSKIP:
1090 fl_set_choice (class_->choice_skip, pos);
1092 bool const length_input = pos == 4;
1094 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1095 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
1096 || paperchoice == 2 || paperchoice > 5;
1097 string const default_unit = metric ? "cm" : "in";
1098 string const length = params.getDefSkip().asLyXCommand();
1099 updateWidgetsFromLengthString(class_->input_skip,
1100 class_->choice_skip_units,
1101 length, default_unit);
1104 fl_set_input(class_->input_skip, "");
1106 setEnabled(class_->choice_skip, !indent);
1107 setEnabled(class_->input_skip, length_input);
1108 setEnabled(class_->choice_skip_units, length_input);
1110 bool const two_sides = params.sides == LyXTextClass::TwoSides;
1111 fl_set_button(class_->radio_sides_one, !two_sides);
1112 fl_set_button(class_->radio_sides_two, two_sides);
1114 bool const two_columns = params.columns == 2;
1115 fl_set_button(class_->radio_columns_one, !two_columns);
1116 fl_set_button(class_->radio_columns_two, two_columns);
1118 fl_set_input(class_->input_extra, params.options.c_str());
1120 switch (params.spacing.getSpace()) {
1121 case Spacing::Other:
1124 case Spacing::Double: // \doublespacing
1127 case Spacing::Onehalf: // \onehalfspacing
1130 case Spacing::Single: // \singlespacing
1131 case Spacing::Default: // nothing bad should happen with this
1136 fl_set_choice(class_->choice_spacing, pos);
1138 bool const spacing_input = pos == 4;
1139 setEnabled(class_->input_spacing, spacing_input);
1140 string const input = spacing_input ? tostr(params.spacing.getValue()) : string();
1141 fl_set_input(class_->input_spacing, input.c_str());
1145 void FormDocument::language_update(BufferParams const & params)
1147 if (!language_.get())
1150 int const pos = int(findPos(lang_, params.language->lang()));
1151 fl_set_combox(language_->combox_language, pos+1);
1153 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1154 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1155 fl_set_button(language_->radio_single, 0);
1156 fl_set_button(language_->radio_double, 0);
1157 if (params.quotes_times == InsetQuotes::SingleQ)
1158 fl_set_button(language_->radio_single, 1);
1160 fl_set_button(language_->radio_double, 1);
1164 void FormDocument::options_update(BufferParams const & params)
1166 if (!options_.get())
1169 fl_set_choice_text(options_->choice_postscript_driver,
1170 params.graphicsDriver.c_str());
1171 fl_set_choice(options_->choice_ams_math, params.use_amsmath + 1);
1172 fl_set_button(options_->check_use_natbib, params.use_natbib);
1173 fl_set_choice(options_->choice_citation_format,
1174 int(params.use_numerical_citations)+1);
1175 setEnabled(options_->choice_citation_format, params.use_natbib);
1176 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1177 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1178 if (!params.float_placement.empty())
1179 fl_set_input(options_->input_float_placement,
1180 params.float_placement.c_str());
1182 fl_set_input(options_->input_float_placement, "");
1186 void FormDocument::paper_update(BufferParams const & params)
1191 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1192 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1193 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1195 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1196 bool const useCustom = paperchoice == 2;
1197 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1199 fl_set_button(paper_->radio_portrait, 0);
1200 setEnabled(paper_->radio_portrait, !useCustom);
1201 fl_set_button(paper_->radio_landscape, 0);
1202 setEnabled(paper_->radio_landscape, !useCustom);
1204 if (params.orientation == ORIENTATION_LANDSCAPE)
1205 fl_set_button(paper_->radio_landscape, 1);
1207 fl_set_button(paper_->radio_portrait, 1);
1208 setEnabled(paper_->choice_paperpackage,
1209 //either default papersize (preferences)
1210 //or document papersize has to be A4
1212 || paperchoice == 1 && lyxrc.default_papersize == PAPER_A4PAPER)
1213 && fl_get_button(paper_->radio_portrait));
1215 // Default unit choice is cm if metric, inches if US paper.
1216 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
1217 || paperchoice == 2 || paperchoice > 5;
1218 string const default_unit = metric ? "cm" : "in";
1219 updateWidgetsFromLengthString(paper_->input_custom_width,
1220 paper_->choice_custom_width_units,
1221 params.paperwidth, default_unit);
1222 setEnabled(paper_->input_custom_width, useCustom);
1223 setEnabled(paper_->choice_custom_width_units, useCustom);
1225 updateWidgetsFromLengthString(paper_->input_custom_height,
1226 paper_->choice_custom_height_units,
1227 params.paperheight, default_unit);
1228 setEnabled(paper_->input_custom_height, useCustom);
1229 setEnabled(paper_->choice_custom_height_units, useCustom);
1231 updateWidgetsFromLengthString(paper_->input_inner_margin,
1232 paper_->choice_inner_margin_units,
1233 params.leftmargin, default_unit);
1234 setEnabled(paper_->input_inner_margin, useGeom);
1235 setEnabled(paper_->choice_inner_margin_units, useGeom);
1237 updateWidgetsFromLengthString(paper_->input_top_margin,
1238 paper_->choice_top_margin_units,
1239 params.topmargin, default_unit);
1240 setEnabled(paper_->input_top_margin, useGeom);
1241 setEnabled(paper_->choice_top_margin_units, useGeom);
1243 updateWidgetsFromLengthString(paper_->input_outer_margin,
1244 paper_->choice_outer_margin_units,
1245 params.rightmargin, default_unit);
1246 setEnabled(paper_->input_outer_margin, useGeom);
1247 setEnabled(paper_->choice_outer_margin_units, useGeom);
1249 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1250 paper_->choice_bottom_margin_units,
1251 params.bottommargin, default_unit);
1252 setEnabled(paper_->input_bottom_margin, useGeom);
1253 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1255 updateWidgetsFromLengthString(paper_->input_head_height,
1256 paper_->choice_head_height_units,
1257 params.headheight, default_unit);
1258 setEnabled(paper_->input_head_height, useGeom);
1259 setEnabled(paper_->choice_head_height_units, useGeom);
1261 updateWidgetsFromLengthString(paper_->input_head_sep,
1262 paper_->choice_head_sep_units,
1263 params.headsep, default_unit);
1264 setEnabled(paper_->input_head_sep, useGeom);
1265 setEnabled(paper_->choice_head_sep_units, useGeom);
1267 updateWidgetsFromLengthString(paper_->input_foot_skip,
1268 paper_->choice_foot_skip_units,
1269 params.footskip, default_unit);
1270 setEnabled(paper_->input_foot_skip, useGeom);
1271 setEnabled(paper_->choice_foot_skip_units, useGeom);
1273 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1277 void FormDocument::bullets_update(BufferParams const & params)
1279 if (!bullets_.get() ||
1281 (XpmVersion==4 && XpmRevision<7)))
1284 bool const isLinuxDoc =
1285 controller().docType() == ControlDocument::LINUXDOC;
1286 setEnabled(fbullet, !isLinuxDoc);
1288 if (isLinuxDoc) return;
1290 fl_set_button(bullets_->radio_depth_1, 1);
1291 fl_set_input(bullets_->input_latex,
1292 params.user_defined_bullets[0].getText().c_str());
1293 fl_set_choice(bullets_->choice_size,
1294 params.user_defined_bullets[0].getSize() + 2);
1298 void FormDocument::branch_update(BufferParams const & params)
1303 string const all_branches = params.branchlist.allBranches();
1304 fl_clear_browser(branch_->browser_all_branches);
1305 string current_branch("none");
1307 if (!all_branches.empty()) {
1308 std::vector<string> vec = getVectorFromString(all_branches, "|");
1309 for (unsigned i = 0; i < vec.size(); ++i) {
1310 fl_addto_browser(branch_->browser_all_branches, vec[i].c_str());
1312 fl_select_browser_line(branch_->browser_all_branches, 1);
1315 fl_get_browser_line(branch_->browser_all_branches, 1);
1317 current_branch = "none";
1320 // display proper selection...
1321 string const all_selected = params.branchlist.allSelected();
1322 fl_clear_browser(branch_->browser_selection);
1323 if (!all_selected.empty()) {
1324 std::vector<string> vec = getVectorFromString(all_selected, "|");
1325 for (unsigned i = 0; i < vec.size(); ++i) {
1326 fl_addto_browser(branch_->browser_selection, vec[i].c_str());
1329 // display proper colour...
1332 if (current_branch == "none")
1333 x11hexname = "none";
1335 x11hexname = params.branchlist.getColor(current_branch);
1336 if (x11hexname[0] == '#') {
1337 rgb = RGBColor(x11hexname);
1339 fl_getmcolor(FL_COL1, &rgb.r, &rgb.g, &rgb.b);
1341 fl_mapcolor(GUI_COLOR_CHOICE, rgb.r, rgb.g, rgb.b);
1342 fl_redraw_object(branch_->button_color);
1344 setEnabled(branch_->button_select,
1345 (fl_get_browser(branch_->browser_all_branches) > 0));
1346 setEnabled(branch_->button_deselect,
1347 (fl_get_browser(branch_->browser_selection) > 0));
1348 setEnabled(branch_->button_remove_branch,
1349 (fl_get_browser(branch_->browser_all_branches) > 0));
1350 setEnabled(branch_->button_modify,
1351 (fl_get_browser(branch_->browser_all_branches) > 0));
1355 void FormDocument::checkReadOnly()
1357 if (bc().readOnly(controller().bufferIsReadonly())) {
1358 postWarning(_("Document is read-only."
1359 " No changes to layout permitted."));
1366 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1368 BufferParams & param = controller().params();
1370 // convert from 1-6 range to -1-4
1371 param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
1372 fl_set_input(bullets_->input_latex,
1373 param.temp_bullets[current_bullet_depth].getText().c_str());
1377 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1379 BufferParams & param = controller().params();
1381 param.temp_bullets[current_bullet_depth].
1382 setText(getString(bullets_->input_latex));
1386 void FormDocument::BulletDepth(FL_OBJECT * ob)
1388 /* Should I do the following: */
1389 /* 1. change to the panel that the current bullet belongs in */
1390 /* 2. show that bullet as selected */
1391 /* 3. change the size setting to the size of the bullet in Q.*/
1392 /* 4. display the latex equivalent in the latex box */
1394 /* I'm inclined to just go with 3 and 4 at the moment and */
1395 /* maybe try to support the others later */
1396 BufferParams & param = controller().params();
1399 if (ob == bullets_->radio_depth_1)
1401 else if (ob == bullets_->radio_depth_2)
1403 else if (ob == bullets_->radio_depth_3)
1405 else if (ob == bullets_->radio_depth_4)
1408 switch (fl_get_button_numb(ob)) {
1410 // right mouse button resets to default
1411 param.temp_bullets[data] = ITEMIZE_DEFAULTS[data];
1413 current_bullet_depth = data;
1414 fl_set_input(bullets_->input_latex,
1415 param.temp_bullets[data].getText().c_str());
1416 fl_set_choice(bullets_->choice_size,
1417 param.temp_bullets[data].getSize() + 2);
1422 void FormDocument::BulletPanel(FL_OBJECT * ob)
1424 /* Here we have to change the background pixmap to that selected */
1425 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1428 if (ob == bullets_->radio_panel_standard)
1430 else if (ob == bullets_->radio_panel_maths)
1432 else if (ob == bullets_->radio_panel_ding2)
1434 else if (ob == bullets_->radio_panel_ding3)
1436 else if (ob == bullets_->radio_panel_ding4)
1438 else if (ob == bullets_->radio_panel_ding1)
1441 if (data != current_bullet_panel) {
1442 fl_freeze_form(bullets_->form);
1443 current_bullet_panel = data;
1445 /* free the current pixmap */
1446 fl_free_bmtable_pixmap(bullets_->bmtable_panel);
1448 if (ob == bullets_->radio_panel_standard) {
1449 new_panel = "standard";
1450 } else if (ob == bullets_->radio_panel_maths ) {
1451 new_panel = "amssymb";
1452 } else if (ob == bullets_->radio_panel_ding2) {
1453 new_panel = "psnfss1";
1454 } else if (ob == bullets_->radio_panel_ding3) {
1455 new_panel = "psnfss2";
1456 } else if (ob == bullets_->radio_panel_ding4) {
1457 new_panel = "psnfss3";
1458 } else if (ob == bullets_->radio_panel_ding1) {
1459 new_panel = "psnfss4";
1461 /* something very wrong happened */
1462 // play it safe for now but should be an exception
1463 current_bullet_panel = 0; // standard panel
1464 new_panel = "standard";
1466 new_panel += ".xpm";
1467 fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6,
1468 LibFileSearch("images", new_panel).c_str());
1469 fl_redraw_object(bullets_->bmtable_panel);
1470 fl_unfreeze_form(bullets_->form);
1475 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1477 /* handle the user input by setting the current bullet depth's pixmap */
1478 /* to that extracted from the current chosen position of the BMTable */
1479 /* Don't forget to free the button's old pixmap first. */
1481 BufferParams & param = controller().params();
1482 int bmtable_button = fl_get_bmtable(ob);
1484 /* try to keep the button held down till another is pushed */
1485 /* fl_set_bmtable(ob, 1, bmtable_button); */
1486 param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
1487 param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
1488 fl_set_input(bullets_->input_latex,
1489 param.temp_bullets[current_bullet_depth].getText().c_str());
1493 void FormDocument::CheckChoiceClass()
1495 BufferParams & params = controller().params();
1497 lyx::textclass_type const tc =
1498 fl_get_combox(class_->combox_class) - 1;
1500 if (controller().loadTextclass(tc)) {
1501 params.textclass = tc;
1503 if (lyxrc.auto_reset_options) {
1504 params.useClassDefaults();
1505 UpdateLayoutDocument(params);
1507 // update the params which are needed in any case
1508 // (fontsizes, pagestyle)
1509 UpdateClassParams(params);
1513 int const revert = int(params.textclass);
1514 fl_set_combox(class_->combox_class, revert + 1);
1519 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1525 class_update(params);
1526 paper_update(params);
1527 language_update(params);
1528 options_update(params);
1529 bullets_update(params);