3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * \author Martin Vermeer
9 * \author Jürgen Spitzmüller
11 * Full author contact details are available in file CREDITS.
16 #include "FormDocument.h"
17 #include "ControlDocument.h"
18 #include "forms/form_document.h"
21 #include "checkedwidgets.h"
22 #include "ColorHandler.h"
24 #include "FormColorpicker.h"
25 #include "input_validators.h" // fl_unsigned_float_filter
27 #include "xforms_helpers.h"
30 #include "controllers/ButtonController.h"
31 #include "controllers/frnt_lang.h"
32 #include "controllers/helper_funcs.h"
35 #include "bufferparams.h"
38 #include "lyxtextclasslist.h"
39 #include "tex-strings.h"
42 #include "support/tostr.h"
43 #include "support/lstrings.h" // contains_functor, getStringFromVector
44 #include "support/filetools.h" // LibFileSearch
50 using namespace lyx::support;
60 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
61 bool const scalableTabfolders = false;
63 bool const scalableTabfolders = true;
70 typedef FormCB<ControlDocument, FormDB<FD_document> > base_class;
72 FormDocument::FormDocument()
73 : base_class(_("Document Settings"), scalableTabfolders),
74 ActCell(0), Confirmed(0),
75 current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
79 void FormDocument::redraw()
81 if (form() && form()->visible)
82 fl_redraw_form(form());
86 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
87 if (outer_form && outer_form->visible)
88 fl_redraw_form(outer_form);
92 void FormDocument::build()
95 dialog_.reset(build_document(this));
97 // Allow the base class to control messages
98 setMessageWidget(dialog_->text_warning);
100 // Manage the restore, ok, apply, restore and cancel/close buttons
101 bcview().setOK(dialog_->button_ok);
102 bcview().setApply(dialog_->button_apply);
103 bcview().setCancel(dialog_->button_close);
104 bcview().setRestore(dialog_->button_restore);
106 // the document class form
107 class_.reset(build_document_class(this));
109 // disable for read-only documents
110 bcview().addReadOnly(class_->combox_class);
111 bcview().addReadOnly(class_->radio_indent);
112 bcview().addReadOnly(class_->radio_skip);
113 bcview().addReadOnly(class_->choice_pagestyle);
114 bcview().addReadOnly(class_->choice_fonts);
115 bcview().addReadOnly(class_->choice_fontsize);
116 bcview().addReadOnly(class_->radio_sides_one);
117 bcview().addReadOnly(class_->radio_sides_two);
118 bcview().addReadOnly(class_->radio_columns_one);
119 bcview().addReadOnly(class_->radio_columns_two);
120 bcview().addReadOnly(class_->input_extra);
121 bcview().addReadOnly(class_->input_skip);
122 bcview().addReadOnly(class_->choice_skip);
123 bcview().addReadOnly(class_->choice_spacing);
124 bcview().addReadOnly(class_->input_spacing);
126 // check validity of "length + unit" input
127 addCheckedGlueLength(bcview(), class_->input_skip,
128 class_->choice_skip);
130 // trigger an input event for cut&paste with middle mouse button.
131 setPrehandler(class_->input_extra);
132 setPrehandler(class_->input_skip);
133 setPrehandler(class_->input_spacing);
135 fl_set_input_return(class_->input_extra, FL_RETURN_CHANGED);
136 fl_set_input_return(class_->input_skip, FL_RETURN_CHANGED);
137 fl_set_input_return(class_->input_spacing, FL_RETURN_CHANGED);
141 // Fill the combox and choices.
142 obj = class_->combox_class;
143 LyXTextClassList::const_iterator tit = textclasslist.begin();
144 LyXTextClassList::const_iterator tend = textclasslist.end();
145 for (; tit != tend; ++tit) {
146 if (tit->isTeXClassAvailable()) {
147 fl_addto_combox(obj, tit->description().c_str());
149 string item = bformat(_("Unavailable: %1$s"), tit->description());
150 fl_addto_combox(obj, item.c_str());
153 fl_set_combox_browser_height(obj, 400);
155 fl_addto_choice(class_->choice_spacing,
156 _(" Single | OneHalf | Double | Custom ").c_str());
157 fl_addto_choice(class_->choice_fontsize, "default|10|11|12");
158 for (int n = 0; tex_fonts[n][0]; ++n) {
159 fl_addto_choice(class_->choice_fonts,tex_fonts[n]);
162 // Create the contents of the unit choices; don't include the
164 vector<string> units_vec = getLatexUnits();
165 vector<string>::iterator ret =
166 std::remove_if(units_vec.begin(),
168 bind2nd(contains_functor(), "%"));
169 units_vec.erase(ret, units_vec.end());
171 string const units = getStringFromVector(units_vec, "|");
173 fl_addto_choice(class_->choice_pagestyle,
174 "default|empty|plain|headings|fancy");
175 fl_addto_choice(class_->choice_skip,
176 _(" SmallSkip | MedSkip | BigSkip | Length ").c_str());
177 fl_addto_choice(class_->choice_skip_units, units.c_str());
179 // Set input filters on doc spacing to make it accept only
181 fl_set_input_filter(class_->input_spacing,
182 fl_unsigned_float_filter);
184 // disable for read-only documents
185 bcview().addReadOnly(dialog_->button_save_defaults);
186 bcview().addReadOnly(dialog_->button_reset_defaults);
188 // the document paper form
189 paper_.reset(build_document_paper(this));
191 // disable for read-only documents
192 bcview().addReadOnly(paper_->choice_paperpackage);
193 bcview().addReadOnly(paper_->radio_portrait);
194 bcview().addReadOnly(paper_->radio_landscape);
195 bcview().addReadOnly(paper_->choice_papersize);
196 bcview().addReadOnly(paper_->check_use_geometry);
197 bcview().addReadOnly(paper_->input_custom_width);
198 bcview().addReadOnly(paper_->input_custom_height);
199 bcview().addReadOnly(paper_->input_top_margin);
200 bcview().addReadOnly(paper_->input_bottom_margin);
201 bcview().addReadOnly(paper_->input_inner_margin);
202 bcview().addReadOnly(paper_->input_outer_margin);
203 bcview().addReadOnly(paper_->input_head_height);
204 bcview().addReadOnly(paper_->input_head_sep);
205 bcview().addReadOnly(paper_->input_foot_skip);
207 // check validity of "length + unit" input
208 addCheckedGlueLength(bcview(), paper_->input_custom_width);
209 addCheckedGlueLength(bcview(), paper_->input_custom_height);
210 addCheckedGlueLength(bcview(), paper_->input_top_margin);
211 addCheckedGlueLength(bcview(), paper_->input_bottom_margin);
212 addCheckedGlueLength(bcview(), paper_->input_inner_margin);
213 addCheckedGlueLength(bcview(), paper_->input_outer_margin);
214 addCheckedGlueLength(bcview(), paper_->input_head_height);
215 addCheckedGlueLength(bcview(), paper_->input_head_sep);
216 addCheckedGlueLength(bcview(), paper_->input_foot_skip);
218 // trigger an input event for cut&paste with middle mouse button.
219 setPrehandler(paper_->input_custom_width);
220 setPrehandler(paper_->input_custom_height);
221 setPrehandler(paper_->input_top_margin);
222 setPrehandler(paper_->input_bottom_margin);
223 setPrehandler(paper_->input_inner_margin);
224 setPrehandler(paper_->input_outer_margin);
225 setPrehandler(paper_->input_head_height);
226 setPrehandler(paper_->input_head_sep);
227 setPrehandler(paper_->input_foot_skip);
229 fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
230 fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
231 fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
232 fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
233 fl_set_input_return(paper_->input_inner_margin, FL_RETURN_CHANGED);
234 fl_set_input_return(paper_->input_outer_margin, FL_RETURN_CHANGED);
235 fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
236 fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
237 fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
239 fl_addto_choice(paper_->choice_papersize,
240 _(" Default | Custom | US letter | US legal "
241 "| US executive | A3 | A4 | A5 "
242 "| B3 | B4 | B5 ").c_str());
243 fl_addto_choice(paper_->choice_paperpackage,
246 "| Very small Margins "
247 "| Very wide Margins ").c_str());
249 fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
250 fl_addto_choice(paper_->choice_custom_height_units, units.c_str());
251 fl_addto_choice(paper_->choice_top_margin_units, units.c_str());
252 fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str());
253 fl_addto_choice(paper_->choice_inner_margin_units, units.c_str());
254 fl_addto_choice(paper_->choice_outer_margin_units, units.c_str());
255 fl_addto_choice(paper_->choice_head_height_units, units.c_str());
256 fl_addto_choice(paper_->choice_head_sep_units, units.c_str());
257 fl_addto_choice(paper_->choice_foot_skip_units, units.c_str());
259 // the document language form
260 language_.reset(build_document_language(this));
262 // disable for read-only documents
263 bcview().addReadOnly(language_->combox_language);
264 bcview().addReadOnly(language_->choice_inputenc);
265 bcview().addReadOnly(language_->choice_quotes_language);
266 bcview().addReadOnly(language_->radio_single);
267 bcview().addReadOnly(language_->radio_double);
269 fl_addto_choice(language_->choice_inputenc,
270 "default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
271 "|koi8-r|koi8-u|cp866|cp1251|iso88595|pt154");
273 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
274 // Store the identifiers for later
275 lang_ = getSecond(langs);
277 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
278 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
279 for (; lit != lend; ++lit) {
280 fl_addto_combox(language_->combox_language,
283 fl_set_combox_browser_height(language_->combox_language, 400);
285 fl_addto_choice(language_->choice_quotes_language,
286 _(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
287 " «text» | »text« ").c_str());
289 // the document options form
290 options_.reset(build_document_options(this));
292 // disable for read-only documents
293 bcview().addReadOnly(options_->counter_secnumdepth);
294 bcview().addReadOnly(options_->counter_tocdepth);
295 bcview().addReadOnly(options_->choice_ams_math);
296 bcview().addReadOnly(options_->check_use_natbib);
297 bcview().addReadOnly(options_->choice_citation_format);
298 bcview().addReadOnly(options_->input_float_placement);
299 bcview().addReadOnly(options_->choice_postscript_driver);
301 // trigger an input event for cut&paste with middle mouse button.
302 setPrehandler(options_->input_float_placement);
304 fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
306 fl_addto_choice(options_->choice_ams_math,
307 _("Never | Automatically | Yes ").c_str());
309 for (int n = 0; tex_graphics[n][0]; ++n) {
310 fl_addto_choice(options_->choice_postscript_driver,
313 fl_addto_choice(options_->choice_citation_format,
314 _(" Author-year | Numerical ").c_str());
316 // the document bullets form
317 bullets_.reset(build_document_bullet(this));
319 // disable for read-only documents
320 bcview().addReadOnly(bullets_->radio_depth_1);
321 bcview().addReadOnly(bullets_->radio_depth_2);
322 bcview().addReadOnly(bullets_->radio_depth_3);
323 bcview().addReadOnly(bullets_->radio_depth_4);
324 bcview().addReadOnly(bullets_->radio_panel_standard);
325 bcview().addReadOnly(bullets_->radio_panel_maths);
326 bcview().addReadOnly(bullets_->radio_panel_ding1);
327 bcview().addReadOnly(bullets_->radio_panel_ding2);
328 bcview().addReadOnly(bullets_->radio_panel_ding3);
329 bcview().addReadOnly(bullets_->radio_panel_ding4);
330 bcview().addReadOnly(bullets_->bmtable_panel);
331 bcview().addReadOnly(bullets_->choice_size);
332 bcview().addReadOnly(bullets_->input_latex);
334 // trigger an input event for cut&paste with middle mouse button.
335 setPrehandler(bullets_->input_latex);
337 fl_set_input_return(bullets_->input_latex, FL_RETURN_CHANGED);
339 fl_addto_choice(bullets_->choice_size,
340 _(" Default | Tiny | Smallest | Smaller "
341 "| Small | Normal | Large | Larger | Largest "
342 "| Huge | Huger ").c_str());
343 fl_set_choice(bullets_->choice_size, 1);
345 fl_set_input_maxchars(bullets_->input_latex, 80);
347 string const bmtablefile = LibFileSearch("images", "standard", "xpm");
348 fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6,
349 bmtablefile.c_str());
351 picker_.reset(new FormColorpicker);
353 // the document branches form
354 branch_.reset(build_document_branch(this));
356 fl_set_object_color(branch_->button_color,
357 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
359 bcview().addReadOnly(branch_->input_all_branches);
360 bcview().addReadOnly(branch_->button_add_branch);
361 bcview().addReadOnly(branch_->button_remove_branch);
362 bcview().addReadOnly(branch_->button_select);
363 bcview().addReadOnly(branch_->button_deselect);
364 bcview().addReadOnly(branch_->button_modify);
365 bcview().addReadOnly(branch_->browser_all_branches);
367 // set up the tooltips for branches form
368 string str = _("Enter the name of a new branch.");
369 tooltips().init(branch_->input_all_branches, str);
370 str = _("Add a new branch to the document.");
371 tooltips().init(branch_->button_add_branch, str);
372 str = _("Remove the selected branch from the document.");
373 tooltips().init(branch_->button_remove_branch, str);
374 str = _("Activate the selected branch for output.");
375 tooltips().init(branch_->button_select, str);
376 str = _("Deactivate the selected activated branch.");
377 tooltips().init(branch_->button_deselect, str);
378 str = _("Available branches for this document.");
379 tooltips().init(branch_->browser_all_branches, str);
380 str = _("Activated branches. Content will occur in the document\'s output");
381 tooltips().init(branch_->browser_selection, str);
382 str = _("Modify background color of branch inset");
383 tooltips().init(branch_->button_modify, str);
384 str = _("Background color of branch inset");
385 tooltips().init(branch_->button_color, str);
387 // Handle middle mouse paint:
388 setPrehandler(branch_->input_all_branches);
389 fl_set_input_return(branch_->input_all_branches, FL_RETURN_CHANGED);
391 // Enable the tabfolder to be rescaled correctly.
392 if (scalableTabfolders)
393 fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
396 fl_addto_tabfolder(dialog_->tabfolder,_("Document").c_str(),
398 fl_addto_tabfolder(dialog_->tabfolder,_("Paper").c_str(),
400 fl_addto_tabfolder(dialog_->tabfolder,_("Language").c_str(),
402 fl_addto_tabfolder(dialog_->tabfolder,_("Extra").c_str(),
404 fbullet = fl_addto_tabfolder(dialog_->tabfolder,_("Bullets").c_str(),
407 if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
408 lyxerr << _("Your version of libXpm is older than 4.7.\n"
409 "The `bullet' tab of the document dialog "
410 "has been disabled") << '\n';
411 fl_deactivate_object(fbullet);
412 fl_set_object_lcol(fbullet, FL_INACTIVE);
415 fl_addto_tabfolder(dialog_->tabfolder,_("Branches").c_str(),
420 void FormDocument::apply()
422 BufferParams & params = controller().params();
426 language_apply(params);
427 options_apply(params);
428 bullets_apply(params);
429 branch_apply(params);
433 void FormDocument::update()
440 BufferParams const & params = controller().params();
442 class_update(params);
443 paper_update(params);
444 language_update(params);
445 options_update(params);
446 bullets_update(params);
447 branch_update(params);
451 ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
453 if (ob == bullets_->choice_size) {
454 ChoiceBulletSize(ob, 0);
456 } else if (ob == bullets_->input_latex) {
457 InputBulletLaTeX(ob, 0);
459 } else if (ob == bullets_->radio_depth_1 ||
460 ob == bullets_->radio_depth_2 ||
461 ob == bullets_->radio_depth_3 ||
462 ob == bullets_->radio_depth_4) {
465 } else if (ob == bullets_->radio_panel_standard ||
466 ob == bullets_->radio_panel_maths ||
467 ob == bullets_->radio_panel_ding1 ||
468 ob == bullets_->radio_panel_ding2 ||
469 ob == bullets_->radio_panel_ding3 ||
470 ob == bullets_->radio_panel_ding4) {
473 } else if (ob == bullets_->bmtable_panel) {
474 BulletBMTable(ob, 0);
476 } else if (ob == class_->choice_spacing) {
477 setEnabled(class_->input_spacing,
478 fl_get_choice(class_->choice_spacing) == 4);
480 } else if (ob == class_->combox_class) {
482 } else if (ob == class_->radio_skip ||
483 ob == class_->radio_indent ||
484 ob == class_->choice_skip) {
485 bool const skip_used = fl_get_button(class_->radio_skip);
486 setEnabled(class_->choice_skip, skip_used);
488 bool const length_input =
489 fl_get_choice(class_->choice_skip) == 4;
490 setEnabled(class_->input_skip,
491 skip_used && length_input);
492 setEnabled(class_->choice_skip_units,
493 skip_used && length_input);
495 // Default unit choice is cm if metric, inches if US paper.
496 // If papersize is default, check the lyxrc-settings
497 int const paperchoice = fl_get_choice(paper_->choice_papersize);
498 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
499 || paperchoice == 2 || paperchoice > 5;
500 string const default_unit = metric ? "cm" : "in";
501 if (getString(class_->input_skip).empty())
502 fl_set_choice_text(class_->choice_skip_units,
503 default_unit.c_str());
505 } else if (ob == options_->check_use_natbib) {
506 setEnabled(options_->choice_citation_format,
507 fl_get_button(options_->check_use_natbib));
509 } else if (ob == branch_->browser_all_branches ||
510 ob == branch_->browser_selection ||
511 ob == branch_->button_add_branch ||
512 ob == branch_->button_remove_branch ||
513 ob == branch_->button_modify ||
514 ob == branch_->button_select ||
515 ob == branch_->button_deselect ||
516 ob == branch_->button_deselect) {
518 } else if (ob == dialog_->button_save_defaults) {
520 controller().saveAsDefault();
522 } else if (ob == dialog_->button_reset_defaults) {
523 BufferParams & params = controller().params();
524 params.textclass = fl_get_combox(class_->combox_class) - 1;
525 params.useClassDefaults();
526 UpdateLayoutDocument(params);
528 } else if (ob == paper_->radio_landscape) {
529 fl_set_choice(paper_->choice_paperpackage,
532 } else if (ob == paper_->choice_papersize) {
533 int const paperchoice = fl_get_choice(paper_->choice_papersize);
534 bool const defsize = paperchoice == 1;
535 bool const custom = paperchoice == 2;
536 bool const a3size = paperchoice == 6;
537 bool const b3size = paperchoice == 9;
538 bool const b4size = paperchoice == 10;
541 fl_set_button(paper_->radio_portrait, 1);
543 bool const use_geom = (custom || a3size || b3size || b4size);
545 fl_set_button(paper_->check_use_geometry, int(use_geom));
547 setEnabled(paper_->input_top_margin, use_geom);
548 setEnabled(paper_->input_bottom_margin, use_geom);
549 setEnabled(paper_->input_inner_margin, use_geom);
550 setEnabled(paper_->input_outer_margin, use_geom);
551 setEnabled(paper_->input_head_height, use_geom);
552 setEnabled(paper_->input_head_sep, use_geom);
553 setEnabled(paper_->input_foot_skip, use_geom);
554 setEnabled(paper_->choice_top_margin_units, use_geom);
555 setEnabled(paper_->choice_bottom_margin_units, use_geom);
556 setEnabled(paper_->choice_inner_margin_units, use_geom);
557 setEnabled(paper_->choice_outer_margin_units, use_geom);
558 setEnabled(paper_->choice_head_height_units, use_geom);
559 setEnabled(paper_->choice_head_sep_units, use_geom);
560 setEnabled(paper_->choice_foot_skip_units, use_geom);
561 setEnabled(paper_->choice_custom_width_units, use_geom);
562 setEnabled(paper_->choice_custom_height_units, use_geom);
564 setEnabled(paper_->input_custom_width, custom);
565 setEnabled(paper_->input_custom_height, custom);
566 setEnabled(paper_->choice_custom_width_units, custom);
567 setEnabled(paper_->choice_custom_height_units, custom);
568 setEnabled(paper_->radio_portrait, !custom);
569 setEnabled(paper_->radio_landscape, !custom);
571 // Default unit choice is cm if metric, inches if US paper.
572 // If papersize is default, use the lyxrc-settings
573 bool const metric = (defsize && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
574 || paperchoice == 2 || paperchoice > 5;
575 string const default_unit = metric ? "cm" : "in";
576 if (getString(paper_->input_custom_width).empty())
577 fl_set_choice_text(paper_->choice_custom_width_units,
578 default_unit.c_str());
579 if (getString(paper_->input_custom_height).empty())
580 fl_set_choice_text(paper_->choice_custom_height_units,
581 default_unit.c_str());
582 if (getString(paper_->input_top_margin).empty())
583 fl_set_choice_text(paper_->choice_top_margin_units,
584 default_unit.c_str());
585 if (getString(paper_->input_bottom_margin).empty())
586 fl_set_choice_text(paper_->choice_bottom_margin_units,
587 default_unit.c_str());
588 if (getString(paper_->input_inner_margin).empty())
589 fl_set_choice_text(paper_->choice_inner_margin_units,
590 default_unit.c_str());
591 if (getString(paper_->input_outer_margin).empty())
592 fl_set_choice_text(paper_->choice_outer_margin_units,
593 default_unit.c_str());
594 if (getString(paper_->input_head_height).empty())
595 fl_set_choice_text(paper_->choice_head_height_units,
596 default_unit.c_str());
597 if (getString(paper_->input_head_sep).empty())
598 fl_set_choice_text(paper_->choice_head_sep_units,
599 default_unit.c_str());
600 if (getString(paper_->input_foot_skip).empty())
601 fl_set_choice_text(paper_->choice_foot_skip_units,
602 default_unit.c_str());
604 } else if (ob == paper_->choice_paperpackage &&
605 fl_get_choice(paper_->choice_paperpackage) != 1) {
607 fl_set_button(paper_->check_use_geometry, 0);
608 setEnabled(paper_->input_top_margin, false);
609 setEnabled(paper_->input_bottom_margin, false);
610 setEnabled(paper_->input_inner_margin, false);
611 setEnabled(paper_->input_outer_margin, false);
612 setEnabled(paper_->input_head_height, false);
613 setEnabled(paper_->input_head_sep, false);
614 setEnabled(paper_->input_foot_skip, false);
615 setEnabled(paper_->choice_top_margin_units, false);
616 setEnabled(paper_->choice_bottom_margin_units, false);
617 setEnabled(paper_->choice_inner_margin_units, false);
618 setEnabled(paper_->choice_outer_margin_units, false);
619 setEnabled(paper_->choice_head_height_units, false);
620 setEnabled(paper_->choice_head_sep_units, false);
621 setEnabled(paper_->choice_foot_skip_units, false);
623 } else if (ob == paper_->check_use_geometry) {
624 // don't allow switching geometry off in custom papersize
625 // mode nor in A3, B3, and B4
626 int const choice = fl_get_choice(paper_->choice_papersize);
627 if (choice == 2 || choice == 6 || choice == 9 || choice == 10)
628 fl_set_button(paper_->check_use_geometry, 1);
630 fl_set_choice(paper_->choice_paperpackage,
633 bool const use_geom = fl_get_button(paper_->check_use_geometry);
634 setEnabled(paper_->input_top_margin, use_geom);
635 setEnabled(paper_->input_bottom_margin, use_geom);
636 setEnabled(paper_->input_inner_margin, use_geom);
637 setEnabled(paper_->input_outer_margin, use_geom);
638 setEnabled(paper_->input_head_height, use_geom);
639 setEnabled(paper_->input_head_sep, use_geom);
640 setEnabled(paper_->input_foot_skip, use_geom);
641 setEnabled(paper_->choice_top_margin_units, use_geom);
642 setEnabled(paper_->choice_bottom_margin_units, use_geom);
643 setEnabled(paper_->choice_inner_margin_units, use_geom);
644 setEnabled(paper_->choice_outer_margin_units, use_geom);
645 setEnabled(paper_->choice_head_height_units, use_geom);
646 setEnabled(paper_->choice_head_sep_units, use_geom);
647 setEnabled(paper_->choice_foot_skip_units, use_geom);
650 if (ob == paper_->choice_papersize || ob == paper_->radio_portrait
651 || ob == paper_->radio_landscape) {
652 // either default papersize (preferences) or document
653 // papersize has to be A4
654 bool const enable = ( fl_get_choice(paper_->choice_papersize) == 1
655 && lyxrc.default_papersize == PAPER_A4PAPER )
656 || fl_get_choice(paper_->choice_papersize) == 7;
658 fl_set_choice(paper_->choice_paperpackage,
660 setEnabled(paper_->choice_paperpackage,
661 enable && fl_get_button(paper_->radio_portrait));
664 return ButtonPolicy::SMI_VALID;
668 void FormDocument::branch_input(FL_OBJECT * ob)
670 BufferParams & params = controller().params();
671 std::vector<string> vec;
673 if (ob == branch_->button_add_branch) {
674 string new_branch = fl_get_input(branch_->input_all_branches);
675 if (!new_branch.empty()) {
676 params.branchlist().add(new_branch);
677 fl_set_input(branch_->input_all_branches, "");
678 // Update branch list
679 string const all_branches = params.branchlist().allBranches();
680 fl_clear_browser(branch_->browser_all_branches);
681 vec = getVectorFromString(all_branches, "|");
682 for (unsigned i = 0; i < vec.size(); ++i) {
683 fl_addto_browser(branch_->browser_all_branches,
686 LColor::color c = static_cast<LColor::color>(lcolor.size());
687 lcolor.fill(c, new_branch, lcolor.getX11Name(LColor::background));
690 } else if (ob == branch_->button_remove_branch) {
691 unsigned i = fl_get_browser(branch_->browser_all_branches);
692 string const current_branch =
693 fl_get_browser_line(branch_->browser_all_branches, i);
694 if (!current_branch.empty()) {
695 params.branchlist().remove(current_branch);
696 // Update branch list
697 string const all_branches = params.branchlist().allBranches();
698 fl_clear_browser(branch_->browser_all_branches);
699 vec = getVectorFromString(all_branches, "|");
700 for (unsigned i = 0; i < vec.size(); ++i) {
701 fl_addto_browser(branch_->browser_all_branches,
704 // Update selected-list...
705 string const all_selected = params.branchlist().allSelected();
706 fl_clear_browser(branch_->browser_selection);
707 vec = getVectorFromString(all_selected, "|");
708 for (unsigned i = 0; i < vec.size(); ++i) {
709 fl_addto_browser(branch_->browser_selection, vec[i].c_str());
712 } else if (ob == branch_->button_select) {
713 unsigned i = fl_get_browser(branch_->browser_all_branches);
714 string const current_branch =
715 fl_get_browser_line(branch_->browser_all_branches, i);
716 if (!current_branch.empty()) {
717 fl_clear_browser(branch_->browser_selection);
718 params.branchlist().setSelected(current_branch, true);
719 string const all_selected = params.branchlist().allSelected();
720 vec = getVectorFromString(all_selected, "|");
721 for (unsigned i = 0; i < vec.size(); ++i) {
722 fl_addto_browser(branch_->browser_selection,
726 } else if (ob == branch_->button_deselect) {
727 unsigned i = fl_get_browser(branch_->browser_selection);
728 string const current_sel =
729 fl_get_browser_line(branch_->browser_selection, i);
730 if (!current_sel.empty()) {
731 fl_clear_browser(branch_->browser_selection);
732 params.branchlist().setSelected(current_sel, false);
733 string const all_selected = params.branchlist().allSelected();
734 vec = getVectorFromString(all_selected, "|");
735 for (unsigned i = 0; i < vec.size(); ++i) {
736 fl_addto_browser(branch_->browser_selection,
740 } else if (ob == branch_->button_modify) {
741 unsigned i = fl_get_browser(branch_->browser_all_branches);
742 string const current_branch =
743 fl_get_browser_line(branch_->browser_all_branches, i);
746 string x11hexname = params.branchlist().getColor(current_branch);
747 if (x11hexname[0] == '#') {
748 before = RGBColor(x11hexname);
750 fl_getmcolor(FL_COL1, &before.r, &before.g, &before.b);
753 RGBColor col = picker_->requestColor(before);
755 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
756 fl_redraw_object(branch_->button_color);
757 // Figure out here how to stash the new colour into the
758 // LyX colour database.
760 x11hexname = X11hexname(col);
762 // current_branch already in database
763 LColor::color c = lcolor.getFromLyXName(current_branch);
764 lcolor.setColor(current_branch, x11hexname);
765 // Make sure that new colour is also displayed ;-)
766 lyxColorHandler->getGCForeground(c);
767 lyxColorHandler->updateColor(c);
768 // what about system_lcolor?
769 // Here set colour in BranchList:
770 params.branchlist().setColor(current_branch, x11hexname);
772 } else if (ob == branch_->browser_all_branches) {
773 unsigned i = fl_get_browser(branch_->browser_all_branches);
774 string const current_branch =
775 fl_get_browser_line(branch_->browser_all_branches, i);
776 // make button_color track selected branch:
779 string x11hexname = params.branchlist().getColor(current_branch);
780 if (x11hexname[0] == '#') {
781 rgb = RGBColor(x11hexname);
783 fl_getmcolor(FL_COL1, &rgb.r, &rgb.g, &rgb.b);
785 fl_mapcolor(GUI_COLOR_CHOICE, rgb.r, rgb.g, rgb.b);
786 fl_redraw_object(branch_->button_color);
788 setEnabled(branch_->button_select,
789 (fl_get_browser(branch_->browser_all_branches) > 0));
790 setEnabled(branch_->button_deselect,
791 (fl_get_browser(branch_->browser_selection) > 0));
792 setEnabled(branch_->button_remove_branch,
793 (fl_get_browser(branch_->browser_all_branches) > 0));
794 setEnabled(branch_->button_modify,
795 (fl_get_browser(branch_->browser_all_branches) > 0));
797 branchlist_ = params.branchlist();
801 bool FormDocument::class_apply(BufferParams ¶ms)
805 // If default skip is a "Length" but there's no text in the
806 // input field, reset the kind to "MedSkip", which is the default.
807 if (fl_get_choice(class_->choice_skip) == 4 &&
808 getString(class_->input_skip).empty()) {
809 fl_set_choice(class_->choice_skip, 2);
811 params.fonts = getString(class_->choice_fonts);
812 params.fontsize = getString(class_->choice_fontsize);
813 params.pagestyle = getString(class_->choice_pagestyle);
815 params.textclass = fl_get_combox(class_->combox_class) - 1;
817 BufferParams::PARSEP tmpsep = params.paragraph_separation;
818 if (fl_get_button(class_->radio_indent))
819 params.paragraph_separation = BufferParams::PARSEP_INDENT;
821 params.paragraph_separation = BufferParams::PARSEP_SKIP;
822 if (tmpsep != params.paragraph_separation)
825 VSpace tmpdefskip = params.getDefSkip();
826 switch (fl_get_choice(class_->choice_skip)) {
828 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
831 params.setDefSkip(VSpace(VSpace::MEDSKIP));
834 params.setDefSkip(VSpace(VSpace::BIGSKIP));
838 string const length =
839 getLengthFromWidgets(class_->input_skip,
840 class_->choice_skip_units);
842 params.setDefSkip(VSpace(LyXGlueLength(length)));
846 // DocumentDefskipCB assures that this never happens
847 params.setDefSkip(VSpace(VSpace::MEDSKIP));
850 if (!(tmpdefskip == params.getDefSkip()))
853 if (fl_get_button(class_->radio_columns_two))
857 if (fl_get_button(class_->radio_sides_two))
858 params.sides = LyXTextClass::TwoSides;
860 params.sides = LyXTextClass::OneSide;
862 Spacing tmpSpacing = params.spacing();
863 switch (fl_get_choice(class_->choice_spacing)) {
865 lyxerr[Debug::INFO] << "Spacing: SINGLE" << endl;
866 params.spacing().set(Spacing::Single);
869 lyxerr[Debug::INFO] << "Spacing: ONEHALF" << endl;
870 params.spacing().set(Spacing::Onehalf);
873 lyxerr[Debug::INFO] << "Spacing: DOUBLE" << endl;
874 params.spacing().set(Spacing::Double);
877 lyxerr[Debug::INFO] << "Spacing: OTHER" << endl;
878 params.spacing().set(Spacing::Other,
879 getString(class_->input_spacing));
882 if (tmpSpacing != params.spacing())
885 params.options = getString(class_->input_extra);
891 void FormDocument::paper_apply(BufferParams & params)
893 params.papersize2 = VMARGIN_PAPER_TYPE(fl_get_choice(paper_->choice_papersize) - 1);
895 params.paperpackage =
896 PAPER_PACKAGES(fl_get_choice(paper_->choice_paperpackage) - 1);
898 // set params.papersize from params.papersize2 and params.paperpackage
899 params.setPaperStuff();
901 params.use_geometry = fl_get_button(paper_->check_use_geometry);
903 if (fl_get_button(paper_->radio_landscape))
904 params.orientation = ORIENTATION_LANDSCAPE;
906 params.orientation = ORIENTATION_PORTRAIT;
909 getLengthFromWidgets(paper_->input_custom_width,
910 paper_->choice_custom_width_units);
913 getLengthFromWidgets(paper_->input_custom_height,
914 paper_->choice_custom_height_units);
917 getLengthFromWidgets(paper_->input_inner_margin,
918 paper_->choice_inner_margin_units);
921 getLengthFromWidgets(paper_->input_top_margin,
922 paper_->choice_top_margin_units);
925 getLengthFromWidgets(paper_->input_outer_margin,
926 paper_->choice_outer_margin_units);
928 params.bottommargin =
929 getLengthFromWidgets(paper_->input_bottom_margin,
930 paper_->choice_bottom_margin_units);
933 getLengthFromWidgets(paper_->input_head_height,
934 paper_->choice_head_height_units);
937 getLengthFromWidgets(paper_->input_head_sep,
938 paper_->choice_head_sep_units);
941 getLengthFromWidgets(paper_->input_foot_skip,
942 paper_->choice_foot_skip_units);
946 bool FormDocument::language_apply(BufferParams & params)
948 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
951 switch (fl_get_choice(language_->choice_quotes_language) - 1) {
953 lga = InsetQuotes::EnglishQ;
956 lga = InsetQuotes::SwedishQ;
959 lga = InsetQuotes::GermanQ;
962 lga = InsetQuotes::PolishQ;
965 lga = InsetQuotes::FrenchQ;
968 lga = InsetQuotes::DanishQ;
971 params.quotes_language = lga;
972 if (fl_get_button(language_->radio_single))
973 params.quotes_times = InsetQuotes::SingleQ;
975 params.quotes_times = InsetQuotes::DoubleQ;
977 int const pos = fl_get_combox(language_->combox_language);
978 Language const * new_language = languages.getLanguage(lang_[pos-1]);
980 new_language = default_language;
982 params.language = new_language;
983 params.inputenc = getString(language_->choice_inputenc);
989 bool FormDocument::options_apply(BufferParams & params)
993 params.graphicsDriver = getString(options_->choice_postscript_driver);
994 params.use_amsmath = static_cast<BufferParams::AMS>(
995 fl_get_choice(options_->choice_ams_math) - 1);
996 params.use_natbib = fl_get_button(options_->check_use_natbib);
997 params.use_numerical_citations =
998 fl_get_choice(options_->choice_citation_format) - 1;
1000 int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
1001 if (params.secnumdepth != tmpchar)
1003 params.secnumdepth = tmpchar;
1005 params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
1007 params.float_placement =
1008 getString(options_->input_float_placement);
1014 void FormDocument::bullets_apply(BufferParams & params)
1016 /* update the bullet settings */
1017 BufferParams & buf_params = controller().params();
1019 for (int i = 0; i < 4; ++i) {
1020 params.user_defined_bullet(i) = buf_params.temp_bullet(i);
1025 void FormDocument::branch_apply(BufferParams & params)
1027 BufferParams & prms = controller().params();
1028 if (branchlist_.empty())
1029 branchlist_ = prms.branchlist();
1030 params.branchlist() = branchlist_;
1031 branchlist_.clear();
1035 void FormDocument::UpdateClassParams(BufferParams const & params)
1037 // These are the params that have to be updated on any class change
1038 // (even if the class defaults are not used) (JSpitzm 2002-04-08)
1040 LyXTextClass const & tclass = textclasslist[params.textclass];
1042 fl_set_combox(class_->combox_class, params.textclass + 1);
1043 fl_clear_choice(class_->choice_fontsize);
1044 fl_addto_choice(class_->choice_fontsize, "default");
1045 fl_addto_choice(class_->choice_fontsize,
1046 tclass.opt_fontsize().c_str());
1047 fl_set_choice_text(class_->choice_fontsize,
1048 params.fontsize.c_str());
1049 fl_clear_choice(class_->choice_pagestyle);
1050 fl_addto_choice(class_->choice_pagestyle, "default");
1051 fl_addto_choice(class_->choice_pagestyle,
1052 tclass.opt_pagestyle().c_str());
1053 fl_set_choice_text(class_->choice_pagestyle,
1054 params.pagestyle.c_str());
1056 fl_set_input(class_->input_extra, tclass.options().c_str());
1059 void FormDocument::class_update(BufferParams const & params)
1064 UpdateClassParams(params);
1066 fl_set_choice_text(class_->choice_fonts, params.fonts.c_str());
1068 bool const indent = params.paragraph_separation == BufferParams::PARSEP_INDENT;
1069 fl_set_button(class_->radio_indent, indent);
1070 fl_set_button(class_->radio_skip, !indent);
1074 pos = 2; // VSpace::MEDSKIP is default
1076 switch (params.getDefSkip().kind()) {
1077 case VSpace::LENGTH:
1080 case VSpace::BIGSKIP:
1083 case VSpace::SMALLSKIP:
1086 case VSpace::MEDSKIP:
1092 fl_set_choice (class_->choice_skip, pos);
1094 bool const length_input = pos == 4;
1096 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1097 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
1098 || paperchoice == 2 || paperchoice > 5;
1099 string const default_unit = metric ? "cm" : "in";
1100 string const length = params.getDefSkip().asLyXCommand();
1101 updateWidgetsFromLengthString(class_->input_skip,
1102 class_->choice_skip_units,
1103 length, default_unit);
1106 fl_set_input(class_->input_skip, "");
1108 setEnabled(class_->choice_skip, !indent);
1109 setEnabled(class_->input_skip, length_input);
1110 setEnabled(class_->choice_skip_units, length_input);
1112 bool const two_sides = params.sides == LyXTextClass::TwoSides;
1113 fl_set_button(class_->radio_sides_one, !two_sides);
1114 fl_set_button(class_->radio_sides_two, two_sides);
1116 bool const two_columns = params.columns == 2;
1117 fl_set_button(class_->radio_columns_one, !two_columns);
1118 fl_set_button(class_->radio_columns_two, two_columns);
1120 fl_set_input(class_->input_extra, params.options.c_str());
1122 switch (params.spacing().getSpace()) {
1123 case Spacing::Other:
1126 case Spacing::Double: // \doublespacing
1129 case Spacing::Onehalf: // \onehalfspacing
1132 case Spacing::Single: // \singlespacing
1133 case Spacing::Default: // nothing bad should happen with this
1138 fl_set_choice(class_->choice_spacing, pos);
1140 bool const spacing_input = pos == 4;
1141 setEnabled(class_->input_spacing, spacing_input);
1142 string const input = spacing_input ? tostr(params.spacing().getValue()) : string();
1143 fl_set_input(class_->input_spacing, input.c_str());
1147 void FormDocument::language_update(BufferParams const & params)
1149 if (!language_.get())
1152 int const pos = int(findPos(lang_, params.language->lang()));
1153 fl_set_combox(language_->combox_language, pos+1);
1155 fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
1156 fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
1157 fl_set_button(language_->radio_single, 0);
1158 fl_set_button(language_->radio_double, 0);
1159 if (params.quotes_times == InsetQuotes::SingleQ)
1160 fl_set_button(language_->radio_single, 1);
1162 fl_set_button(language_->radio_double, 1);
1166 void FormDocument::options_update(BufferParams const & params)
1168 if (!options_.get())
1171 fl_set_choice_text(options_->choice_postscript_driver,
1172 params.graphicsDriver.c_str());
1173 fl_set_choice(options_->choice_ams_math, params.use_amsmath + 1);
1174 fl_set_button(options_->check_use_natbib, params.use_natbib);
1175 fl_set_choice(options_->choice_citation_format,
1176 int(params.use_numerical_citations)+1);
1177 setEnabled(options_->choice_citation_format, params.use_natbib);
1178 fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
1179 fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
1180 if (!params.float_placement.empty())
1181 fl_set_input(options_->input_float_placement,
1182 params.float_placement.c_str());
1184 fl_set_input(options_->input_float_placement, "");
1188 void FormDocument::paper_update(BufferParams const & params)
1193 fl_set_choice(paper_->choice_papersize, params.papersize2 + 1);
1194 fl_set_choice(paper_->choice_paperpackage, params.paperpackage + 1);
1195 fl_set_button(paper_->check_use_geometry, params.use_geometry);
1197 int const paperchoice = fl_get_choice(paper_->choice_papersize);
1198 bool const useCustom = paperchoice == 2;
1199 bool const useGeom = fl_get_button(paper_->check_use_geometry);
1201 fl_set_button(paper_->radio_portrait, 0);
1202 setEnabled(paper_->radio_portrait, !useCustom);
1203 fl_set_button(paper_->radio_landscape, 0);
1204 setEnabled(paper_->radio_landscape, !useCustom);
1206 if (params.orientation == ORIENTATION_LANDSCAPE)
1207 fl_set_button(paper_->radio_landscape, 1);
1209 fl_set_button(paper_->radio_portrait, 1);
1210 setEnabled(paper_->choice_paperpackage,
1211 //either default papersize (preferences)
1212 //or document papersize has to be A4
1214 || paperchoice == 1 && lyxrc.default_papersize == PAPER_A4PAPER)
1215 && fl_get_button(paper_->radio_portrait));
1217 // Default unit choice is cm if metric, inches if US paper.
1218 bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
1219 || paperchoice == 2 || paperchoice > 5;
1220 string const default_unit = metric ? "cm" : "in";
1221 updateWidgetsFromLengthString(paper_->input_custom_width,
1222 paper_->choice_custom_width_units,
1223 params.paperwidth, default_unit);
1224 setEnabled(paper_->input_custom_width, useCustom);
1225 setEnabled(paper_->choice_custom_width_units, useCustom);
1227 updateWidgetsFromLengthString(paper_->input_custom_height,
1228 paper_->choice_custom_height_units,
1229 params.paperheight, default_unit);
1230 setEnabled(paper_->input_custom_height, useCustom);
1231 setEnabled(paper_->choice_custom_height_units, useCustom);
1233 updateWidgetsFromLengthString(paper_->input_inner_margin,
1234 paper_->choice_inner_margin_units,
1235 params.leftmargin, default_unit);
1236 setEnabled(paper_->input_inner_margin, useGeom);
1237 setEnabled(paper_->choice_inner_margin_units, useGeom);
1239 updateWidgetsFromLengthString(paper_->input_top_margin,
1240 paper_->choice_top_margin_units,
1241 params.topmargin, default_unit);
1242 setEnabled(paper_->input_top_margin, useGeom);
1243 setEnabled(paper_->choice_top_margin_units, useGeom);
1245 updateWidgetsFromLengthString(paper_->input_outer_margin,
1246 paper_->choice_outer_margin_units,
1247 params.rightmargin, default_unit);
1248 setEnabled(paper_->input_outer_margin, useGeom);
1249 setEnabled(paper_->choice_outer_margin_units, useGeom);
1251 updateWidgetsFromLengthString(paper_->input_bottom_margin,
1252 paper_->choice_bottom_margin_units,
1253 params.bottommargin, default_unit);
1254 setEnabled(paper_->input_bottom_margin, useGeom);
1255 setEnabled(paper_->choice_bottom_margin_units, useGeom);
1257 updateWidgetsFromLengthString(paper_->input_head_height,
1258 paper_->choice_head_height_units,
1259 params.headheight, default_unit);
1260 setEnabled(paper_->input_head_height, useGeom);
1261 setEnabled(paper_->choice_head_height_units, useGeom);
1263 updateWidgetsFromLengthString(paper_->input_head_sep,
1264 paper_->choice_head_sep_units,
1265 params.headsep, default_unit);
1266 setEnabled(paper_->input_head_sep, useGeom);
1267 setEnabled(paper_->choice_head_sep_units, useGeom);
1269 updateWidgetsFromLengthString(paper_->input_foot_skip,
1270 paper_->choice_foot_skip_units,
1271 params.footskip, default_unit);
1272 setEnabled(paper_->input_foot_skip, useGeom);
1273 setEnabled(paper_->choice_foot_skip_units, useGeom);
1275 fl_set_focus_object(paper_->form, paper_->choice_papersize);
1279 void FormDocument::bullets_update(BufferParams const & params)
1281 if (!bullets_.get() ||
1283 (XpmVersion==4 && XpmRevision<7)))
1286 bool const isLinuxDoc =
1287 controller().docType() == ControlDocument::LINUXDOC;
1288 setEnabled(fbullet, !isLinuxDoc);
1290 if (isLinuxDoc) return;
1292 fl_set_button(bullets_->radio_depth_1, 1);
1293 fl_set_input(bullets_->input_latex,
1294 params.user_defined_bullet(0).getText().c_str());
1295 fl_set_choice(bullets_->choice_size,
1296 params.user_defined_bullet(0).getSize() + 2);
1300 void FormDocument::branch_update(BufferParams const & params)
1305 string const all_branches = params.branchlist().allBranches();
1306 fl_clear_browser(branch_->browser_all_branches);
1307 string current_branch("none");
1309 if (!all_branches.empty()) {
1310 std::vector<string> vec = getVectorFromString(all_branches, "|");
1311 for (unsigned i = 0; i < vec.size(); ++i) {
1312 fl_addto_browser(branch_->browser_all_branches, vec[i].c_str());
1314 fl_select_browser_line(branch_->browser_all_branches, 1);
1317 fl_get_browser_line(branch_->browser_all_branches, 1);
1319 current_branch = "none";
1322 // display proper selection...
1323 string const all_selected = params.branchlist().allSelected();
1324 fl_clear_browser(branch_->browser_selection);
1325 if (!all_selected.empty()) {
1326 std::vector<string> vec = getVectorFromString(all_selected, "|");
1327 for (unsigned i = 0; i < vec.size(); ++i) {
1328 fl_addto_browser(branch_->browser_selection, vec[i].c_str());
1331 // display proper colour...
1334 if (current_branch == "none")
1335 x11hexname = "none";
1337 x11hexname = params.branchlist().getColor(current_branch);
1338 if (x11hexname[0] == '#') {
1339 rgb = RGBColor(x11hexname);
1341 fl_getmcolor(FL_COL1, &rgb.r, &rgb.g, &rgb.b);
1343 fl_mapcolor(GUI_COLOR_CHOICE, rgb.r, rgb.g, rgb.b);
1344 fl_redraw_object(branch_->button_color);
1346 setEnabled(branch_->button_select,
1347 (fl_get_browser(branch_->browser_all_branches) > 0));
1348 setEnabled(branch_->button_deselect,
1349 (fl_get_browser(branch_->browser_selection) > 0));
1350 setEnabled(branch_->button_remove_branch,
1351 (fl_get_browser(branch_->browser_all_branches) > 0));
1352 setEnabled(branch_->button_modify,
1353 (fl_get_browser(branch_->browser_all_branches) > 0));
1357 void FormDocument::checkReadOnly()
1359 if (bc().readOnly(controller().bufferIsReadonly())) {
1360 postWarning(_("Document is read-only."
1361 " No changes to layout permitted."));
1368 void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
1370 BufferParams & param = controller().params();
1372 // convert from 1-6 range to -1-4
1373 param.temp_bullet(current_bullet_depth).setSize(fl_get_choice(ob) - 2);
1374 fl_set_input(bullets_->input_latex,
1375 param.temp_bullet(current_bullet_depth).getText().c_str());
1379 void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
1381 BufferParams & param = controller().params();
1383 param.temp_bullet(current_bullet_depth).
1384 setText(getString(bullets_->input_latex));
1388 void FormDocument::BulletDepth(FL_OBJECT * ob)
1390 /* Should I do the following: */
1391 /* 1. change to the panel that the current bullet belongs in */
1392 /* 2. show that bullet as selected */
1393 /* 3. change the size setting to the size of the bullet in Q.*/
1394 /* 4. display the latex equivalent in the latex box */
1396 /* I'm inclined to just go with 3 and 4 at the moment and */
1397 /* maybe try to support the others later */
1398 BufferParams & param = controller().params();
1401 if (ob == bullets_->radio_depth_1)
1403 else if (ob == bullets_->radio_depth_2)
1405 else if (ob == bullets_->radio_depth_3)
1407 else if (ob == bullets_->radio_depth_4)
1410 switch (fl_get_button_numb(ob)) {
1412 // right mouse button resets to default
1413 param.temp_bullet(data) = ITEMIZE_DEFAULTS[data];
1415 current_bullet_depth = data;
1416 fl_set_input(bullets_->input_latex,
1417 param.temp_bullet(data).getText().c_str());
1418 fl_set_choice(bullets_->choice_size,
1419 param.temp_bullet(data).getSize() + 2);
1424 void FormDocument::BulletPanel(FL_OBJECT * ob)
1426 /* Here we have to change the background pixmap to that selected */
1427 /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */
1430 if (ob == bullets_->radio_panel_standard)
1432 else if (ob == bullets_->radio_panel_maths)
1434 else if (ob == bullets_->radio_panel_ding2)
1436 else if (ob == bullets_->radio_panel_ding3)
1438 else if (ob == bullets_->radio_panel_ding4)
1440 else if (ob == bullets_->radio_panel_ding1)
1443 if (data != current_bullet_panel) {
1444 fl_freeze_form(bullets_->form);
1445 current_bullet_panel = data;
1447 /* free the current pixmap */
1448 fl_free_bmtable_pixmap(bullets_->bmtable_panel);
1450 if (ob == bullets_->radio_panel_standard) {
1451 new_panel = "standard";
1452 } else if (ob == bullets_->radio_panel_maths ) {
1453 new_panel = "amssymb";
1454 } else if (ob == bullets_->radio_panel_ding2) {
1455 new_panel = "psnfss1";
1456 } else if (ob == bullets_->radio_panel_ding3) {
1457 new_panel = "psnfss2";
1458 } else if (ob == bullets_->radio_panel_ding4) {
1459 new_panel = "psnfss3";
1460 } else if (ob == bullets_->radio_panel_ding1) {
1461 new_panel = "psnfss4";
1463 /* something very wrong happened */
1464 // play it safe for now but should be an exception
1465 current_bullet_panel = 0; // standard panel
1466 new_panel = "standard";
1468 new_panel += ".xpm";
1469 fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6,
1470 LibFileSearch("images", new_panel).c_str());
1471 fl_redraw_object(bullets_->bmtable_panel);
1472 fl_unfreeze_form(bullets_->form);
1477 void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
1479 /* handle the user input by setting the current bullet depth's pixmap */
1480 /* to that extracted from the current chosen position of the BMTable */
1481 /* Don't forget to free the button's old pixmap first. */
1483 BufferParams & param = controller().params();
1484 int bmtable_button = fl_get_bmtable(ob);
1486 /* try to keep the button held down till another is pushed */
1487 /* fl_set_bmtable(ob, 1, bmtable_button); */
1488 param.temp_bullet(current_bullet_depth).setFont(current_bullet_panel);
1489 param.temp_bullet(current_bullet_depth).setCharacter(bmtable_button);
1490 fl_set_input(bullets_->input_latex,
1491 param.temp_bullet(current_bullet_depth).getText().c_str());
1495 void FormDocument::CheckChoiceClass()
1497 BufferParams & params = controller().params();
1499 lyx::textclass_type const tc =
1500 fl_get_combox(class_->combox_class) - 1;
1502 if (controller().loadTextclass(tc)) {
1503 params.textclass = tc;
1505 if (lyxrc.auto_reset_options) {
1506 params.useClassDefaults();
1507 UpdateLayoutDocument(params);
1509 // update the params which are needed in any case
1510 // (fontsizes, pagestyle)
1511 UpdateClassParams(params);
1515 int const revert = int(params.textclass);
1516 fl_set_combox(class_->combox_class, revert + 1);
1521 void FormDocument::UpdateLayoutDocument(BufferParams const & params)
1527 class_update(params);
1528 paper_update(params);
1529 language_update(params);
1530 options_update(params);
1531 bullets_update(params);