diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index cb28134d43..01049c315e 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -339,15 +339,19 @@ string const LaTeXFeatures::getTClassPreamble() const // the text class specific preamble LyXTextClass const & tclass = textclasslist.TextClass(params.textclass); ostringstream tcpreamble; - + tcpreamble << tclass.preamble(); for (layout_type i = 0; i < tclass.numLayouts(); ++i) { if (layout[i]) { - tcpreamble << tclass[i].preamble(); + tcpreamble << tclass[i].preamble(); } } + // DEC's implementation of ostringstream has a bug which can be + // overcome with this forcing. + tcpreamble.seekp(std::ios::beg); + return tcpreamble.str().c_str(); } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 590d44a465..03781d585d 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -8,6 +8,13 @@ * xforms-helpers.h: added two choice const for the LyXLength one with all and one only with length which have a unit. +2002-01-29 Jürgen Spitzmüller + + * forms/form_minipage.fd: add text_warning field. + + *FormMinipage.[Ch]: added input filters and warnings + (ButtonPolicy::SMInput FormMinipage::input) + 2002-01-28 Angus Leeming * FormAboutlyx.[Ch]: Removed redundant form() method and diff --git a/src/frontends/xforms/FormMinipage.C b/src/frontends/xforms/FormMinipage.C index 4e9ec3a126..519f3c4559 100644 --- a/src/frontends/xforms/FormMinipage.C +++ b/src/frontends/xforms/FormMinipage.C @@ -90,3 +90,28 @@ void FormMinipage::update() break; } } + +ButtonPolicy::SMInput FormMinipage::input(FL_OBJECT * ob, long) +{ + ButtonPolicy::SMInput action = ButtonPolicy::SMI_NOOP; + + // disallow senseless data + // warnings if input is senseless + // + string input = fl_get_input(dialog_->input_width); + bool invalid = false; + + if (ob == dialog_->input_width) { + invalid = !isValidLength(input) && !isStrDbl(input); + if (invalid) { + fl_set_object_label(dialog_->text_warning, + _("Warning: Invalid Length!")); + fl_show_object(dialog_->text_warning); + action = ButtonPolicy::SMI_INVALID; + } else { + fl_hide_object(dialog_->text_warning); + action = ButtonPolicy::SMI_VALID; + } + } + return action; +} diff --git a/src/frontends/xforms/FormMinipage.h b/src/frontends/xforms/FormMinipage.h index d640f50614..deaaa0eb2c 100644 --- a/src/frontends/xforms/FormMinipage.h +++ b/src/frontends/xforms/FormMinipage.h @@ -39,6 +39,8 @@ private: virtual void build(); /// Update dialog before/whilst showing it. virtual void update(); + /// Filter the inputs on callback from xforms + virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); /// Fdesign generated method FD_form_minipage * build_minipage(); diff --git a/src/frontends/xforms/form_minipage.C b/src/frontends/xforms/form_minipage.C index 81ec868406..427dbdcfcf 100644 --- a/src/frontends/xforms/form_minipage.C +++ b/src/frontends/xforms/form_minipage.C @@ -89,6 +89,8 @@ FD_form_minipage * FormMinipage::build_minipage() } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseRestoreCB, 0); + fdui->text_warning = obj = fl_add_text(FL_NORMAL_TEXT, 20, 90, 210, 30, ""); + fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_minipage.h b/src/frontends/xforms/form_minipage.h index 9598da08ca..a7f45190a3 100644 --- a/src/frontends/xforms/form_minipage.h +++ b/src/frontends/xforms/form_minipage.h @@ -27,6 +27,7 @@ struct FD_form_minipage { FL_OBJECT *button_apply; FL_OBJECT *button_ok; FL_OBJECT *button_restore; + FL_OBJECT *text_warning; }; #endif /* FD_form_minipage_h_ */ diff --git a/src/frontends/xforms/forms/form_minipage.fd b/src/frontends/xforms/forms/form_minipage.fd index 2b610ab11b..962b3f8e98 100644 --- a/src/frontends/xforms/forms/form_minipage.fd +++ b/src/frontends/xforms/forms/form_minipage.fd @@ -10,7 +10,7 @@ Unit of measure: FL_COORD_PIXEL Name: form_minipage Width: 430 Height: 170 -Number of Objects: 14 +Number of Objects: 15 -------------------- class: FL_BOX @@ -105,7 +105,7 @@ argument: 0 -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 10 10 0 +box: 0 0 0 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -264,5 +264,23 @@ name: button_restore callback: C_FormBaseRestoreCB argument: 0 +-------------------- +class: FL_TEXT +type: NORMAL_TEXT +box: 20 90 210 30 +boxtype: FL_FLAT_BOX +colors: FL_COL1 FL_MCOL +alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE +style: FL_NORMAL_STYLE +size: FL_DEFAULT_SIZE +lcol: FL_BLACK +label: +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: text_warning +callback: +argument: + ============================== create_the_forms