Finishing up my recent changes: This patch adds a text_warning field to the minipage dialog and filters invalid input. One more step towards dialog-wise consistency.
Thanks, Juergen.
Index: src/frontends/xforms/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/ChangeLog,v retrieving revision 1.262 diff -u -r1.262 ChangeLog --- src/frontends/xforms/ChangeLog 2002/01/28 18:35:07 1.262 +++ src/frontends/xforms/ChangeLog 2002/01/29 07:50:48 @@ -1,3 +1,10 @@ +2002-01-29 Jürgen Spitzmüller <[EMAIL PROTECTED]> + + * forms/form_minipage.fd: add text_warning field. + + *FormMinipage.[Ch]: added input filters and warnings + (ButtonPolicy::SMInput FormMinipage::input) + 2002-01-28 Angus Leeming <[EMAIL PROTECTED]> * FormAboutlyx.[Ch]: Removed redundant form() method and Index: src/frontends/xforms/FormMinipage.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/FormMinipage.C,v retrieving revision 1.16 diff -u -r1.16 FormMinipage.C --- src/frontends/xforms/FormMinipage.C 2002/01/17 23:09:31 1.16 +++ src/frontends/xforms/FormMinipage.C 2002/01/29 07:50:49 @@ -90,3 +90,28 @@ break; } } + +ButtonPolicy::SMInput FormMinipage::input(FL_OBJECT * ob, long) +{ + ButtonPolicy::SMInput action = ButtonPolicy::SMI_VALID; + + // 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; + } +} Index: src/frontends/xforms/FormMinipage.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/FormMinipage.h,v retrieving revision 1.5 diff -u -r1.5 FormMinipage.h --- src/frontends/xforms/FormMinipage.h 2001/07/30 11:55:57 1.5 +++ src/frontends/xforms/FormMinipage.h 2002/01/29 07:50:49 @@ -39,6 +39,8 @@ 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(); Index: src/frontends/xforms/form_minipage.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/form_minipage.C,v retrieving revision 1.6 diff -u -r1.6 form_minipage.C --- src/frontends/xforms/form_minipage.C 2002/01/07 11:28:09 1.6 +++ src/frontends/xforms/form_minipage.C 2002/01/29 07:50:49 @@ -89,6 +89,8 @@ } 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; Index: src/frontends/xforms/form_minipage.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/form_minipage.h,v retrieving revision 1.3 diff -u -r1.3 form_minipage.h --- src/frontends/xforms/form_minipage.h 2001/03/29 15:00:19 1.3 +++ src/frontends/xforms/form_minipage.h 2002/01/29 07:50:49 @@ -27,6 +27,7 @@ FL_OBJECT *button_apply; FL_OBJECT *button_ok; FL_OBJECT *button_restore; + FL_OBJECT *text_warning; }; #endif /* FD_form_minipage_h_ */ Index: src/frontends/xforms/forms/form_minipage.fd =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/forms/form_minipage.fd,v retrieving revision 1.5 diff -u -r1.5 form_minipage.fd --- src/frontends/xforms/forms/form_minipage.fd 2002/01/07 11:28:09 1.5 +++ src/frontends/xforms/forms/form_minipage.fd 2002/01/29 07:50:50 @@ -10,7 +10,7 @@ Name: form_minipage Width: 430 Height: 170 -Number of Objects: 14 +Number of Objects: 15 -------------------- class: FL_BOX @@ -105,7 +105,7 @@ -------------------- 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 @@ -263,6 +263,24 @@ 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