-
-namespace {
-
-void validateVSpaceWidgets(FL_OBJECT * choice_type, FL_OBJECT * input_length)
-{
- // Paranoia check!
- lyx::Assert(choice_type && choice_type->objclass == FL_CHOICE &&
- input_length && input_length->objclass == FL_INPUT);
-
- if (fl_get_choice(choice_type) != 7)
- return;
-
- // If a vspace kind is "Length" but there's no text in
- // the input field, reset the kind to "None".
- string const input = rtrim(getString(input_length));
- if (input.empty())
- fl_set_choice(choice_type, 1);
-}
-
-
-VSpace const setVSpaceFromWidgets(FL_OBJECT * choice_type,
- FL_OBJECT * input_length,
- FL_OBJECT * choice_length,
- FL_OBJECT * check_keep)
-{
- // Paranoia check!
- lyx::Assert(choice_type && choice_type->objclass == FL_CHOICE &&
- input_length && input_length->objclass == FL_INPUT &&
- choice_length && choice_length->objclass == FL_CHOICE &&
- check_keep && check_keep->objclass == FL_CHECKBUTTON);
-
- VSpace space;
- switch (fl_get_choice(choice_type)) {
- case 1:
- space = VSpace(VSpace::NONE);
- break;
- case 2:
- space = VSpace(VSpace::DEFSKIP);
- break;
- case 3:
- space = VSpace(VSpace::SMALLSKIP);
- break;
- case 4:
- space = VSpace(VSpace::MEDSKIP);
- break;
- case 5:
- space = VSpace(VSpace::BIGSKIP);
- break;
- case 6:
- space = VSpace(VSpace::VFILL);
- break;
- case 7:
- {
- string const length =
- getLengthFromWidgets(input_length, choice_length);
- space = VSpace(LyXGlueLength(length));
- break;
- }
- }
-
- if (fl_get_button(check_keep))
- space.setKeep(true);
-
- return space;
-}
-
-
-void setWidgetsFromVSpace(VSpace const & space,
- FL_OBJECT * choice_type,
- FL_OBJECT * input_length,
- FL_OBJECT * choice_length,
- FL_OBJECT * check_keep)
-{
- // Paranoia check!
- lyx::Assert(choice_type && choice_type->objclass == FL_CHOICE &&
- input_length && input_length->objclass == FL_INPUT &&
- choice_length && choice_length->objclass == FL_CHOICE &&
- check_keep && check_keep->objclass == FL_CHECKBUTTON);
-
- fl_set_button(check_keep, space.keep());
-
- int pos = 1;
- switch (space.kind()) {
- case VSpace::NONE:
- pos = 1;
- break;
- case VSpace::DEFSKIP:
- pos = 2;
- break;
- case VSpace::SMALLSKIP:
- pos = 3;
- break;
- case VSpace::MEDSKIP:
- pos = 4;
- break;
- case VSpace::BIGSKIP:
- pos = 5;
- break;
- case VSpace::VFILL:
- pos = 6;
- break;
- case VSpace::LENGTH:
- pos = 7;
- break;
- }
- fl_set_choice(choice_type, pos);
-
- bool const custom_vspace = space.kind() == VSpace::LENGTH;
- setEnabled(input_length, custom_vspace);
- setEnabled(choice_length, custom_vspace);
- if (custom_vspace) {
- string const length = space.length().asString();
- updateWidgetsFromLengthString(input_length, choice_length,
- length, defaultUnit);
- } else {
- bool const no_vspace = space.kind() == VSpace::NONE;
- setEnabled(check_keep, !no_vspace);
- fl_set_input(input_length, "");
- fl_set_choice_text(choice_length, defaultUnit.c_str());
- }
-}
-
-} // namespace anon