#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
#include "ControlDocument.h"
#include "FormDocument.h"
#include "forms/form_document.h"
#include "xformsBC.h"
+#include "ButtonController.h"
#include "bmtable.h"
#include "checkedwidgets.h"
-#include "combox.h"
#include "input_validators.h" // fl_unsigned_float_filter
#include "xforms_helpers.h"
-//#include "buffer.h"
-//#include "BufferView.h"
#include "CutAndPaste.h"
#include "debug.h"
#include "language.h"
-//#include "lyx_main.h" // for user_lyxdir
#include "lyxrc.h"
#include "lyxtextclasslist.h"
#include "tex-strings.h"
#include XPM_H_LOCATION
#include FORMS_H_LOCATION
+#include "combox.h"
#include <boost/bind.hpp>
setMessageWidget(dialog_->text_warning);
// Manage the restore, ok, apply, restore and cancel/close buttons
- bc().setOK(dialog_->button_ok);
- bc().setApply(dialog_->button_apply);
- bc().setCancel(dialog_->button_close);
- bc().setRestore(dialog_->button_restore);
+ bcview().setOK(dialog_->button_ok);
+ bcview().setApply(dialog_->button_apply);
+ bcview().setCancel(dialog_->button_close);
+ bcview().setRestore(dialog_->button_restore);
// the document class form
class_.reset(build_document_class(this));
// disable for read-only documents
- bc().addReadOnly(class_->radio_doc_indent);
- bc().addReadOnly(class_->radio_doc_skip);
- bc().addReadOnly(class_->choice_doc_pagestyle);
- bc().addReadOnly(class_->choice_doc_fonts);
- bc().addReadOnly(class_->choice_doc_fontsize);
- bc().addReadOnly(class_->radio_doc_sides_one);
- bc().addReadOnly(class_->radio_doc_sides_two);
- bc().addReadOnly(class_->radio_doc_columns_one);
- bc().addReadOnly(class_->radio_doc_columns_two);
- bc().addReadOnly(class_->input_doc_extra);
- bc().addReadOnly(class_->input_doc_skip);
- bc().addReadOnly(class_->choice_doc_skip);
- bc().addReadOnly(class_->choice_doc_spacing);
- bc().addReadOnly(class_->input_doc_spacing);
+ bcview().addReadOnly(class_->combox_doc_class);
+ bcview().addReadOnly(class_->radio_doc_indent);
+ bcview().addReadOnly(class_->radio_doc_skip);
+ bcview().addReadOnly(class_->choice_doc_pagestyle);
+ bcview().addReadOnly(class_->choice_doc_fonts);
+ bcview().addReadOnly(class_->choice_doc_fontsize);
+ bcview().addReadOnly(class_->radio_doc_sides_one);
+ bcview().addReadOnly(class_->radio_doc_sides_two);
+ bcview().addReadOnly(class_->radio_doc_columns_one);
+ bcview().addReadOnly(class_->radio_doc_columns_two);
+ bcview().addReadOnly(class_->input_doc_extra);
+ bcview().addReadOnly(class_->input_doc_skip);
+ bcview().addReadOnly(class_->choice_doc_skip);
+ bcview().addReadOnly(class_->choice_doc_spacing);
+ bcview().addReadOnly(class_->input_doc_spacing);
// check validity of "length + unit" input
- addCheckedGlueLength(bc(), class_->input_doc_skip,
+ addCheckedGlueLength(bcview(), class_->input_doc_skip,
class_->choice_doc_skip);
// trigger an input event for cut&paste with middle mouse button.
FL_OBJECT * obj;
- // the class list is a combo-box and has to be inserted manually
- obj = class_->choice_doc_class;
- fl_deactivate_object(obj);
- fl_addto_form(class_->form);
- combo_doc_class.reset(new Combox(FL_COMBOX_DROPLIST));
- combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400);
- combo_doc_class->shortcut("#C",1);
- combo_doc_class->setcallback(ComboInputCB, this);
- fl_end_form();
- for (LyXTextClassList::const_iterator cit = textclasslist.begin();
- cit != textclasslist.end(); ++cit) {
- combo_doc_class->addto(cit->description());
+ // Fill the combox and choices.
+ obj = class_->combox_doc_class;
+ LyXTextClassList::const_iterator tit = textclasslist.begin();
+ LyXTextClassList::const_iterator tend = textclasslist.end();
+ for (; tit != tend; ++tit) {
+ fl_addto_combox(obj, tit->description().c_str());
}
+ fl_set_combox_browser_height(obj, 400);
fl_addto_choice(class_->choice_doc_spacing,
_(" Single | OneHalf | Double | Custom "));
fl_addto_choice(class_->choice_doc_pagestyle,
"default|empty|plain|headings|fancy");
fl_addto_choice(class_->choice_doc_skip,
- _(" Smallskip | Medskip | Bigskip | Length "));
+ _(" SmallSkip | MedSkip | BigSkip | Length "));
fl_addto_choice(class_->choice_doc_skip_units, units.c_str());
// Set input filters on doc spacing to make it accept only
fl_unsigned_float_filter);
// disable for read-only documents
- bc().addReadOnly(dialog_->button_save_defaults);
- bc().addReadOnly(dialog_->button_reset_defaults);
+ bcview().addReadOnly(dialog_->button_save_defaults);
+ bcview().addReadOnly(dialog_->button_reset_defaults);
// the document paper form
paper_.reset(build_document_paper(this));
// disable for read-only documents
- bc().addReadOnly(paper_->choice_paperpackage);
- bc().addReadOnly(paper_->radio_portrait);
- bc().addReadOnly(paper_->radio_landscape);
- bc().addReadOnly(paper_->choice_papersize);
- bc().addReadOnly(paper_->check_use_geometry);
- bc().addReadOnly(paper_->input_custom_width);
- bc().addReadOnly(paper_->input_custom_height);
- bc().addReadOnly(paper_->input_top_margin);
- bc().addReadOnly(paper_->input_bottom_margin);
- bc().addReadOnly(paper_->input_inner_margin);
- bc().addReadOnly(paper_->input_outer_margin);
- bc().addReadOnly(paper_->input_head_height);
- bc().addReadOnly(paper_->input_head_sep);
- bc().addReadOnly(paper_->input_foot_skip);
+ bcview().addReadOnly(paper_->choice_paperpackage);
+ bcview().addReadOnly(paper_->radio_portrait);
+ bcview().addReadOnly(paper_->radio_landscape);
+ bcview().addReadOnly(paper_->choice_papersize);
+ bcview().addReadOnly(paper_->check_use_geometry);
+ bcview().addReadOnly(paper_->input_custom_width);
+ bcview().addReadOnly(paper_->input_custom_height);
+ bcview().addReadOnly(paper_->input_top_margin);
+ bcview().addReadOnly(paper_->input_bottom_margin);
+ bcview().addReadOnly(paper_->input_inner_margin);
+ bcview().addReadOnly(paper_->input_outer_margin);
+ bcview().addReadOnly(paper_->input_head_height);
+ bcview().addReadOnly(paper_->input_head_sep);
+ bcview().addReadOnly(paper_->input_foot_skip);
// check validity of "length + unit" input
- addCheckedGlueLength(bc(), paper_->input_custom_width);
- addCheckedGlueLength(bc(), paper_->input_custom_height);
- addCheckedGlueLength(bc(), paper_->input_top_margin);
- addCheckedGlueLength(bc(), paper_->input_bottom_margin);
- addCheckedGlueLength(bc(), paper_->input_inner_margin);
- addCheckedGlueLength(bc(), paper_->input_outer_margin);
- addCheckedGlueLength(bc(), paper_->input_head_height);
- addCheckedGlueLength(bc(), paper_->input_head_sep);
- addCheckedGlueLength(bc(), paper_->input_foot_skip);
+ addCheckedGlueLength(bcview(), paper_->input_custom_width);
+ addCheckedGlueLength(bcview(), paper_->input_custom_height);
+ addCheckedGlueLength(bcview(), paper_->input_top_margin);
+ addCheckedGlueLength(bcview(), paper_->input_bottom_margin);
+ addCheckedGlueLength(bcview(), paper_->input_inner_margin);
+ addCheckedGlueLength(bcview(), paper_->input_outer_margin);
+ addCheckedGlueLength(bcview(), paper_->input_head_height);
+ addCheckedGlueLength(bcview(), paper_->input_head_sep);
+ addCheckedGlueLength(bcview(), paper_->input_foot_skip);
// trigger an input event for cut&paste with middle mouse button.
setPrehandler(paper_->input_custom_width);
language_.reset(build_document_language(this));
// disable for read-only documents
- bc().addReadOnly(language_->choice_inputenc);
- bc().addReadOnly(language_->choice_quotes_language);
- bc().addReadOnly(language_->radio_single);
- bc().addReadOnly(language_->radio_double);
+ bcview().addReadOnly(language_->combox_language);
+ bcview().addReadOnly(language_->choice_inputenc);
+ bcview().addReadOnly(language_->choice_quotes_language);
+ bcview().addReadOnly(language_->radio_single);
+ bcview().addReadOnly(language_->radio_double);
fl_addto_choice(language_->choice_inputenc,
"default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
// Store the identifiers for later
lang_ = getSecond(langs);
- // The language is a combo-box and has to be inserted manually
- obj = language_->choice_language;
- fl_deactivate_object(obj);
- fl_addto_form(language_->form);
- combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
- combo_language->add(obj->x, obj->y, obj->w, obj->h, 400);
- combo_language->shortcut("#L",1);
- combo_language->setcallback(ComboInputCB, this);
- fl_end_form();
-
vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
vector<frnt::LanguagePair>::const_iterator lend = langs.end();
for (; lit != lend; ++lit) {
- combo_language->addto(lit->first);
+ fl_addto_combox(language_->combox_language,
+ lit->first.c_str());
}
- combo_language->select(1);
+ fl_set_combox_browser_height(language_->combox_language, 400);
fl_addto_choice(language_->choice_quotes_language,
_(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
options_.reset(build_document_options(this));
// disable for read-only documents
- bc().addReadOnly(options_->counter_secnumdepth);
- bc().addReadOnly(options_->counter_tocdepth);
- bc().addReadOnly(options_->check_use_amsmath);
- bc().addReadOnly(options_->check_use_natbib);
- bc().addReadOnly(options_->choice_citation_format);
- bc().addReadOnly(options_->input_float_placement);
- bc().addReadOnly(options_->choice_postscript_driver);
+ bcview().addReadOnly(options_->counter_secnumdepth);
+ bcview().addReadOnly(options_->counter_tocdepth);
+ bcview().addReadOnly(options_->choice_ams_math);
+ bcview().addReadOnly(options_->check_use_natbib);
+ bcview().addReadOnly(options_->choice_citation_format);
+ bcview().addReadOnly(options_->input_float_placement);
+ bcview().addReadOnly(options_->choice_postscript_driver);
// trigger an input event for cut&paste with middle mouse button.
setPrehandler(options_->input_float_placement);
fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
+ fl_addto_choice(options_->choice_ams_math,
+ _("Never | Automatically | Yes "));
+
for (int n = 0; tex_graphics[n][0]; ++n) {
fl_addto_choice(options_->choice_postscript_driver,
tex_graphics[n]);
bullets_.reset(build_document_bullet(this));
// disable for read-only documents
- bc().addReadOnly(bullets_->radio_bullet_depth_1);
- bc().addReadOnly(bullets_->radio_bullet_depth_2);
- bc().addReadOnly(bullets_->radio_bullet_depth_3);
- bc().addReadOnly(bullets_->radio_bullet_depth_4);
- bc().addReadOnly(bullets_->radio_bullet_panel_standard);
- bc().addReadOnly(bullets_->radio_bullet_panel_maths);
- bc().addReadOnly(bullets_->radio_bullet_panel_ding1);
- bc().addReadOnly(bullets_->radio_bullet_panel_ding2);
- bc().addReadOnly(bullets_->radio_bullet_panel_ding3);
- bc().addReadOnly(bullets_->radio_bullet_panel_ding4);
- bc().addReadOnly(bullets_->bmtable_bullet_panel);
- bc().addReadOnly(bullets_->choice_bullet_size);
- bc().addReadOnly(bullets_->input_bullet_latex);
+ bcview().addReadOnly(bullets_->radio_bullet_depth_1);
+ bcview().addReadOnly(bullets_->radio_bullet_depth_2);
+ bcview().addReadOnly(bullets_->radio_bullet_depth_3);
+ bcview().addReadOnly(bullets_->radio_bullet_depth_4);
+ bcview().addReadOnly(bullets_->radio_bullet_panel_standard);
+ bcview().addReadOnly(bullets_->radio_bullet_panel_maths);
+ bcview().addReadOnly(bullets_->radio_bullet_panel_ding1);
+ bcview().addReadOnly(bullets_->radio_bullet_panel_ding2);
+ bcview().addReadOnly(bullets_->radio_bullet_panel_ding3);
+ bcview().addReadOnly(bullets_->radio_bullet_panel_ding4);
+ bcview().addReadOnly(bullets_->bmtable_bullet_panel);
+ bcview().addReadOnly(bullets_->choice_bullet_size);
+ bcview().addReadOnly(bullets_->input_bullet_latex);
// trigger an input event for cut&paste with middle mouse button.
setPrehandler(bullets_->input_bullet_latex);
fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
fl_addto_choice(bullets_->choice_bullet_size,
- _(" default | tiny | script | footnote | small |"
- " normal | large | Large | LARGE | huge | Huge"));
+ _(" Default | Tiny | Smallest | Smaller | Small |"
+ " Normal | Large | Larger | Largest | Huge | Huger "));
fl_set_choice(bullets_->choice_bullet_size, 1);
fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
setEnabled(class_->input_doc_spacing,
fl_get_choice(class_->choice_doc_spacing) == 4);
+ } else if (ob == class_->combox_doc_class) {
+ CheckChoiceClass();
} else if (ob == class_->radio_doc_skip ||
ob == class_->radio_doc_indent ||
ob == class_->choice_doc_skip) {
string const default_unit = metric ? "cm" : "in";
if (getString(class_->input_doc_skip).empty())
fl_set_choice_text(class_->choice_doc_skip_units,
- default_unit.c_str());
+ default_unit.c_str());
} else if (ob == options_->check_use_natbib) {
setEnabled(options_->choice_citation_format,
} else if (ob == dialog_->button_reset_defaults) {
BufferParams & params = controller().params();
- params.textclass = combo_doc_class->get() - 1;
+ params.textclass = fl_get_combox(class_->combox_doc_class) - 1;
params.useClassDefaults();
UpdateLayoutDocument(params);
}
if (ob == paper_->choice_papersize || ob == paper_->radio_portrait
- || ob == paper_->radio_landscape) {
+ || ob == paper_->radio_landscape) {
// either default papersize (preferences) or document
// papersize has to be A4
bool const enable = ( fl_get_choice(paper_->choice_papersize) == 1
- && lyxrc.default_papersize == BufferParams::PAPER_A4PAPER )
- || fl_get_choice(paper_->choice_papersize) == 7;
- setEnabled(paper_->choice_paperpackage, enable && fl_get_button(paper_->radio_portrait));
+ && lyxrc.default_papersize == BufferParams::PAPER_A4PAPER )
+ || fl_get_choice(paper_->choice_papersize) == 7;
+ if (!enable)
+ fl_set_choice(paper_->choice_paperpackage,
+ BufferParams::PACKAGE_NONE + 1);
+ setEnabled(paper_->choice_paperpackage,
+ enable && fl_get_button(paper_->radio_portrait));
}
return ButtonPolicy::SMI_VALID;
}
-void FormDocument::ComboInputCB(int, void * v, Combox * combox)
-{
- FormDocument * pre = static_cast<FormDocument*>(v);
- if (combox == pre->combo_doc_class.get())
- pre->CheckChoiceClass();
- pre->bc().valid();
-}
-
-
bool FormDocument::class_apply(BufferParams ¶ms)
{
bool redo = false;
// If default skip is a "Length" but there's no text in the
- // input field, reset the kind to "Medskip", which is the default.
+ // input field, reset the kind to "MedSkip", which is the default.
if (fl_get_choice(class_->choice_doc_skip) == 4 &&
getString(class_->input_doc_skip).empty()) {
fl_set_choice(class_->choice_doc_skip, 2);
params.fontsize = getString(class_->choice_doc_fontsize);
params.pagestyle = getString(class_->choice_doc_pagestyle);
- params.textclass = combo_doc_class->get() - 1;
+ params.textclass = fl_get_combox(class_->combox_doc_class) - 1;
BufferParams::PARSEP tmpsep = params.paragraph_separation;
if (fl_get_button(class_->radio_doc_indent))
else
params.quotes_times = InsetQuotes::DoubleQ;
- int const pos = combo_language->get();
+ int const pos = fl_get_combox(language_->combox_language);
Language const * new_language = languages.getLanguage(lang_[pos-1]);
if (!new_language)
new_language = default_language;
bool redo = false;
params.graphicsDriver = getString(options_->choice_postscript_driver);
- params.use_amsmath = fl_get_button(options_->check_use_amsmath);
+ params.use_amsmath = static_cast<BufferParams::AMS>(
+ fl_get_choice(options_->choice_ams_math) - 1);
params.use_natbib = fl_get_button(options_->check_use_natbib);
params.use_numerical_citations =
fl_get_choice(options_->choice_citation_format) - 1;
/* update the bullet settings */
BufferParams & buf_params = controller().params();
- // a little bit of loop unrolling
- params.user_defined_bullets[0] = buf_params.temp_bullets[0];
- params.user_defined_bullets[1] = buf_params.temp_bullets[1];
- params.user_defined_bullets[2] = buf_params.temp_bullets[2];
- params.user_defined_bullets[3] = buf_params.temp_bullets[3];
+ for (int i = 0; i < 4; ++i) {
+ params.user_defined_bullets[i] = buf_params.temp_bullets[i];
+ }
}
LyXTextClass const & tclass = textclasslist[params.textclass];
- combo_doc_class->select(tclass.description());
+ fl_set_combox(class_->combox_doc_class, params.textclass + 1);
fl_clear_choice(class_->choice_doc_fontsize);
fl_addto_choice(class_->choice_doc_fontsize, "default");
fl_addto_choice(class_->choice_doc_fontsize,
tclass.opt_fontsize().c_str());
fl_set_choice_text(class_->choice_doc_fontsize,
- params.fontsize.c_str());
+ params.fontsize.c_str());
fl_clear_choice(class_->choice_doc_pagestyle);
fl_addto_choice(class_->choice_doc_pagestyle, "default");
fl_addto_choice(class_->choice_doc_pagestyle,
tclass.opt_pagestyle().c_str());
fl_set_choice_text(class_->choice_doc_pagestyle,
- params.pagestyle.c_str());
+ params.pagestyle.c_str());
}
return;
int const pos = int(findPos(lang_, params.language->lang()));
- combo_language->select(pos+1);
+ fl_set_combox(language_->combox_language, pos+1);
fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
fl_set_choice_text(options_->choice_postscript_driver,
params.graphicsDriver.c_str());
- fl_set_button(options_->check_use_amsmath, params.use_amsmath);
+ fl_set_choice(options_->choice_ams_math, params.use_amsmath + 1);
fl_set_button(options_->check_use_natbib, params.use_natbib);
fl_set_choice(options_->choice_citation_format,
int(params.use_numerical_citations)+1);
void FormDocument::checkReadOnly()
{
if (bc().readOnly(controller().bufferIsReadonly())) {
- combo_doc_class->deactivate();
- combo_language->deactivate();
postWarning(_("Document is read-only."
" No changes to layout permitted."));
} else {
- combo_doc_class->activate();
- combo_language->activate();
clearMessage();
}
}
{
BufferParams & params = controller().params();
- lyx::textclass_type const tc = combo_doc_class->get() - 1;
+ lyx::textclass_type const tc =
+ fl_get_combox(class_->combox_doc_class) - 1;
if (controller().loadTextclass(tc)) {
params.textclass = tc;
} else {
int const revert = int(params.textclass);
- combo_doc_class->select(revert + 1);
+ fl_set_combox(class_->combox_doc_class, revert + 1);
}
}