+2002-01-15 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
+
+ * xforms_helpers.C: modify getLengthFromWidgets to ignore the unit
+ choice if the input field contains a LyXGlueLength.
+
+ * FormParagraph.C: Allow to insert and display gluelengths in VSpace
+
+ * FormParagraph.C
+ * FormDocument.C
+ * FormTabular.C: Change input filter to allow inserting
+ gluelengths/lyxlength or numbers with unit choices.
+
+ * FormMinipage.C: Use getLengthFromWidgets instead of the code there,
+ which was more or less duplicated.
+
+ * FormGraphics.C: set default units, dependent on US/other paper.
+
2002-01-16 Angus Leeming <a.leeming@ic.ac.uk>
* Dialogs.C: no longer need to #include the Controller classes, as this
fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
- // Set input filters on width and height to make them accept only
- // unsigned numbers.
- fl_set_input_filter(paper_->input_custom_width,
- fl_unsigned_float_filter);
- fl_set_input_filter(paper_->input_custom_height,
- fl_unsigned_float_filter);
- fl_set_input_filter(paper_->input_top_margin,
- fl_unsigned_float_filter);
- fl_set_input_filter(paper_->input_bottom_margin,
- fl_unsigned_float_filter);
- fl_set_input_filter(paper_->input_inner_margin,
- fl_unsigned_float_filter);
- fl_set_input_filter(paper_->input_outer_margin,
- fl_unsigned_float_filter);
- fl_set_input_filter(paper_->input_head_height,
- fl_unsigned_float_filter);
- fl_set_input_filter(paper_->input_head_sep,
- fl_unsigned_float_filter);
- fl_set_input_filter(paper_->input_foot_skip,
- fl_unsigned_float_filter);
// Create the contents of the unit choices
// Don't include the "%" terms...
fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
- // Set input filters on doc skip to make it accept only
+ // Set input filters on doc spacing to make it accept only
// unsigned numbers.
- fl_set_input_filter(class_->input_doc_skip,
- fl_unsigned_float_filter);
+ fl_set_input_filter(class_->input_doc_spacing, fl_unsigned_float_filter);
bc().addReadOnly (class_->radio_doc_indent);
bc().addReadOnly (class_->radio_doc_skip);
}
-bool FormDocument::CheckDocumentInput(FL_OBJECT *, long)
+bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
{
string str;
bool ok = true;
char const * input;
+ // this has to be all out of if/elseif because it has to deactivate
+ // the document buttons and so the whole stuff has to be tested again.
+ // disable OK/Apply if input is not valid
+ str = fl_get_input(class_->input_doc_skip);
+ ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
+ str = fl_get_input(paper_->input_custom_width);
+ ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
+ str = fl_get_input(paper_->input_custom_height);
+ ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
+ str = fl_get_input(paper_->input_outer_margin);
+ ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
+ str = fl_get_input(paper_->input_inner_margin);
+ ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
+ str = fl_get_input(paper_->input_top_margin);
+ ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
+ str = fl_get_input(paper_->input_bottom_margin);
+ ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
+ str = fl_get_input(paper_->input_head_height);
+ ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
+ str = fl_get_input(paper_->input_head_sep);
+ ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
+ str = fl_get_input(paper_->input_foot_skip);
+ ok = ok && (str.empty() || isValidLength(str) || isStrDbl(str));
+
+ //display warning if input is not valid
+ if (ob == class_->input_doc_skip
+ || ob == paper_->input_custom_width
+ || ob == paper_->input_custom_height
+ || ob == paper_->input_outer_margin
+ || ob == paper_->input_inner_margin
+ || ob == paper_->input_top_margin
+ || ob == paper_->input_bottom_margin
+ || ob == paper_->input_head_height
+ || ob == paper_->input_head_sep
+ || ob == paper_->input_foot_skip) {
+ if (!ok) {
+ fl_set_object_label(dialog_->text_warning,
+ _("Warning: Invalid Length (valid example: 10mm)"));
+ fl_show_object(dialog_->text_warning);
+ return false;
+ } else {
+ fl_hide_object(dialog_->text_warning);
+ return true;
+ }
+ }
+
// "Synchronize" the choice and the input field, so that it
// is impossible to commit senseless data.
input = fl_get_input (class_->input_doc_skip);
fl_set_input(dialog_->input_width, number.c_str());
int pos = 1;
+ //use inch as default with US papersizes in lyxrc
+ if (lyxrc.default_papersize < 3)
+ pos = 2;
switch (igp.widthResize) {
+ case InsetGraphicsParams::CM:
+ pos = 1; break;
+
case InsetGraphicsParams::INCH:
pos = 2; break;
fl_set_input(dialog_->input_height, number.c_str());
pos = 1;
+ //use inch as default with US papersizes in lyxrc
+ if (lyxrc.default_papersize < 3)
+ pos = 2;
switch (igp.heightResize) {
+ case InsetGraphicsParams::CM:
+ pos = 1; break;
+
case InsetGraphicsParams::INCH:
pos = 2; break;
#include "support/lstrings.h"
#include "helper_funcs.h"
#include "debug.h"
+#include "xforms_helpers.h"
typedef FormCB<ControlMinipage, FormDB<FD_form_minipage> > base_class;
void FormMinipage::apply()
{
- string const units = fl_get_choice_text(dialog_->choice_width_units);
- double const val = strToDbl(fl_get_input(dialog_->input_width));
-
controller().params().pageWidth =
- tostr(val) + frontStrip(strip(subst(units,"%%","%")));
+ getLengthFromWidgets(dialog_->input_width,
+ dialog_->choice_width_units);
if (fl_get_button(dialog_->radio_top))
controller().params().pos = InsetMinipage::top;
#include "input_validators.h"
#include "helper_funcs.h"
-#include "support/lstrings.h"
+#include "support/lstrings.h"
using Liason::setMinibuffer;
using SigC::slot;
fl_set_input_return(dialog_->input_labelwidth, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_linespacing, FL_RETURN_CHANGED);
fl_set_input_filter(dialog_->input_linespacing, fl_unsigned_float_filter);
- fl_set_input_filter(dialog_->input_space_above, fl_float_filter);
- fl_set_input_filter(dialog_->input_space_below, fl_float_filter);
// Create the contents of the unit choices
// Don't include the "%" terms...
case 7:
string const length =
getLengthFromWidgets(dialog_->input_space_below,
- dialog_->choice_value_space_below);
+ dialog_->choice_value_space_below);
space_bottom = VSpace(LyXGlueLength(length));
break;
}
bool const metric = lyxrc.default_papersize > 3;
string const default_unit = metric ? "cm" : "in";
string const length = par_->params().spaceTop().length().asString();
- updateWidgetsFromLengthString(dialog_->input_space_above,
- dialog_->choice_value_space_above,
- length, default_unit);
- break;
+ //check if there's a stretch or shrink factor
+ if (!isValidLength(length) && !isStrDbl(length))
+ fl_set_input(dialog_->input_space_above, length.c_str());
+ else {
+ updateWidgetsFromLengthString(dialog_->input_space_above,
+ dialog_->choice_value_space_above,
+ length, default_unit);
+ }
+ break;
}
}
string const default_unit = metric ? "cm" : "in";
string const length =
par_->params().spaceBottom().length().asString();
- updateWidgetsFromLengthString(dialog_->input_space_below,
- dialog_->choice_value_space_below,
- length, default_unit);
- break;
+ //check if there's a stretch or shrink factor
+ if (!isValidLength(length) && !isStrDbl(length))
+ fl_set_input(dialog_->input_space_below, length.c_str());
+ else {
+ updateWidgetsFromLengthString(dialog_->input_space_below,
+ dialog_->choice_value_space_below,
+ length, default_unit);
+ }
+ break;
}
}
}
}
+ //
+ // warnings if input is senseless
+ //
+ string input = fl_get_input (dialog_->input_space_above);
+ bool invalid = false;
+
+ if (fl_get_choice(dialog_->choice_space_above)==7)
+ invalid = !input.empty() && !isValidGlueLength(input) && !isStrDbl(input);
+
+ input = fl_get_input (dialog_->input_space_below);
+
+ if (fl_get_choice(dialog_->choice_space_below)==7)
+ invalid = invalid
+ || (!input.empty() && !isValidGlueLength(input) && !isStrDbl(input));
+
+ if (ob == dialog_->input_space_above || ob == dialog_->input_space_below) {
+ if (invalid) {
+ fl_set_object_label(dialog_->text_warning,
+ _("Warning: Invalid Length (valid example: 10mm)"));
+ fl_show_object(dialog_->text_warning);
+ return false;
+ } else {
+ fl_hide_object(dialog_->text_warning);
+ return true;
+ }
+ }
+
if (fl_get_choice (dialog_->choice_linespacing) == 5)
setEnabled (dialog_->input_linespacing, true);
else {
#include "insets/insettabular.h"
#include "buffer.h"
#include "xforms_helpers.h"
+#include "lyxrc.h" // to set the default length values
#include "helper_funcs.h"
#include "input_validators.h"
#include "support/lstrings.h"
setEnabled(cell_options_->radio_valign_center, true);
special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
fl_set_input(cell_options_->input_special_multialign, special.c_str());
- string const default_unit = "cm";
+ bool const metric = lyxrc.default_papersize > 3;
+ string const default_unit = metric ? "cm" : "in";
updateWidgetsFromLength(cell_options_->input_mcolumn_width,
cell_options_->choice_value_mcolumn_width,
pwidth, default_unit);
setEnabled(column_options_->input_special_alignment, !isReadonly);
pwidth = tabular->GetColumnPWidth(cell);
- string const default_unit = "cm";
+ bool const metric = lyxrc.default_papersize > 3;
+ string const default_unit = metric ? "cm" : "in";
updateWidgetsFromLength(column_options_->input_column_width,
column_options_->choice_value_column_width,
pwidth, default_unit);
if ((ob == column_options_->input_column_width) ||
(ob == column_options_->choice_value_column_width))
{
- string const str =
- getLengthFromWidgets(column_options_->input_column_width,
- column_options_->choice_value_column_width);
- inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str);
+ string const str =
+ getLengthFromWidgets(column_options_->input_column_width,
+ column_options_->choice_value_column_width);
+ inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str);
+
+ //check if the input is valid
+ string const input =
+ fl_get_input(column_options_->input_column_width);
+ if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
+ fl_set_object_label(dialog_->text_warning,
+ _("Warning: Invalid Length (valid example: 10mm)"));
+ fl_show_object(dialog_->text_warning);
+ return false;
+ }
update(); // update for alignment
return true;
}
if ((ob == cell_options_->input_mcolumn_width) ||
(ob == cell_options_->choice_value_mcolumn_width))
{
- string const str =
- getLengthFromWidgets(cell_options_->input_mcolumn_width,
- cell_options_->choice_value_mcolumn_width);
- inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH, str);
+ string const str =
+ getLengthFromWidgets(cell_options_->input_mcolumn_width,
+ cell_options_->choice_value_mcolumn_width);
+ inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH, str);
+
+ //check if the input is valid
+ string const input =
+ fl_get_input(cell_options_->input_mcolumn_width);
+ if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
+ fl_set_object_label(dialog_->text_warning,
+ _("Warning: Invalid Length (valid example: 10mm)"));
+ fl_show_object(dialog_->text_warning);
+ return false;
+ }
update(); // update for alignment
return true;
}
#include "gettext.h"
#include "support/LAssert.h"
#include "lyxlength.h"
+#include "lyxgluelength.h"
using std::ofstream;
using std::pair;
if (length.empty())
return string();
+ //don't return unit-from-choice if the input(field) contains a unit
+ if (isValidGlueLength(length))
+ return length;
+
string unit = strip(frontStrip(fl_get_choice_text(choice)));
unit = subst(unit, "%%", "%");