if (p == 0 || p == par_)
return;
- // OBS FIX LOOK HERE
+ // For now, don't bother checking if the params are different.
- // shouldn't we chage the par_ pointer too?
- // anyway for me the below function does just nothing!
- // (Jug 20020108)
+ // Will the underlying paragraph accept our changes?
+ Inset * const inset = p->inInset();
+ bool const accept = !(inset && inset->forceDefaultParagraphs(inset));
+ bc().valid(accept);
- // For now don't bother checking if the params are different,
- // just activate the Apply button
- bc().valid();
+ if (!accept) {
+ postWarning(_("Cannot apply paragraph settings to this inset!"));
+ } else {
+ clearMessage();
+ }
}
setMessageWidget(dialog_->text_warning);
fl_addto_choice(dialog_->choice_space_above,
- _(" None | Defskip | Smallskip "
- "| Medskip | Bigskip | VFill | Length "));
+ _(" None | Defskip | Smallskip "
+ "| Medskip | Bigskip | VFill | Length "));
fl_addto_choice(dialog_->choice_space_below,
- _(" None | Defskip | Smallskip "
- "| Medskip | Bigskip | VFill | Length "));
+ _(" None | Defskip | Smallskip "
+ "| Medskip | Bigskip | VFill | Length "));
fl_addto_choice(dialog_->choice_linespacing,
- _(" Default | Single | OneHalf | Double | Other "));
+ _(" Default | Single | OneHalf | Double | Other "));
fl_set_input_return(dialog_->input_space_above, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_space_below, FL_RETURN_CHANGED);
vector<string> units_vec = getLatexUnits();
#if 0
for (vector<string>::iterator it = units_vec.begin();
- it != units_vec.end(); ++it) {
+ it != units_vec.end(); ++it) {
if (contains(*it, "%"))
it = units_vec.erase(it, it+1) - 1;
}
// Something similar to this is a better way to erase
vector<string>::iterator del =
remove_if(units_vec.begin(), units_vec.end(),
- bind2nd(contains_functor(), "%"));
+ bind2nd(contains_functor(), "%"));
units_vec.erase(del, units_vec.end());
#endif
bc_.addReadOnly(dialog_->input_space_below);
bc_.addReadOnly(dialog_->check_space_below);
bc_.addReadOnly(dialog_->choice_linespacing);
- bc_.addReadOnly(dialog_->input_linespacing);
+ bc_.addReadOnly(dialog_->input_linespacing);
bc_.addReadOnly(dialog_->check_noindent);
bc_.addReadOnly(dialog_->input_labelwidth);
}
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)) {
return space;
}
-} // namespace anon
+
+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 = strip(getStringFromInput(input_length));
+ if (input.empty())
+ fl_set_choice(choice_type, 1);
+}
+
+} // namespace anon
void FormParagraph::apply()
return;
// If a vspace kind is "Length" but there's no text in
- // the input field, reset the kind to "None".
- if ((fl_get_choice(dialog_->choice_space_above) == 7) &&
- !*(fl_get_input(dialog_->input_space_above)))
- {
- fl_set_choice(dialog_->choice_space_above, 1);
- }
-
- if ((fl_get_choice (dialog_->choice_space_below) == 7) &&
- !*(fl_get_input (dialog_->input_space_below)))
- {
- fl_set_choice(dialog_->choice_space_below, 1);
- }
+ // the input field, reset the kind to "None".
+ validateVSpaceWidgets(dialog_->choice_space_above,
+ dialog_->input_space_above);
+ validateVSpaceWidgets(dialog_->choice_space_below,
+ dialog_->input_space_below);
bool const line_top = fl_get_button(dialog_->check_lines_top);
bool const line_bottom = fl_get_button(dialog_->check_lines_bottom);
align = LYX_ALIGN_RIGHT;
else if (fl_get_button(dialog_->radio_align_center))
align = LYX_ALIGN_CENTER;
- else
+ else
align = LYX_ALIGN_BLOCK;
string const labelwidthstring =
bool const noindent = fl_get_button(dialog_->check_noindent);
Spacing::Space linespacing = Spacing::Default;
- string other_linespacing;
+ string other;
switch (fl_get_choice(dialog_->choice_linespacing)) {
- case 1: linespacing = Spacing::Default; break;
- case 2: linespacing = Spacing::Single; break;
- case 3: linespacing = Spacing::Onehalf; break;
- case 4: linespacing = Spacing::Double; break;
- case 5:
- linespacing = Spacing::Other;
- other_linespacing = fl_get_input(dialog_->input_linespacing);
- break;
+ case 1:
+ linespacing = Spacing::Default;
+ break;
+ case 2:
+ linespacing = Spacing::Single;
+ break;
+ case 3:
+ linespacing = Spacing::Onehalf;
+ break;
+ case 4:
+ linespacing = Spacing::Double;
+ break;
+ case 5:
+ linespacing = Spacing::Other;
+ other = getStringFromInput(dialog_->input_linespacing);
+ break;
}
- Spacing const spacing(linespacing, other_linespacing);
+ Spacing const spacing(linespacing, other);
LyXText * text(lv_->view()->getLyXText());
text->setParagraph(lv_->view(), line_top, line_bottom, pagebreak_top,
align, labelwidthstring, noindent);
// Actually apply these settings
- lv_->view()->update(text,
- BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
+ lv_->view()->update(text,
+ BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
lv_->buffer()->markDirty();
setMinibuffer(lv_, _("Paragraph layout set"));
}
fl_set_button(check_keep, space.keep());
}
-} // namespace anon
+} // namespace anon
void FormParagraph::update()
align = tclass[par_->layout()].align;
switch (align) {
- case LYX_ALIGN_RIGHT:
- fl_set_button(dialog_->radio_align_right, 1);
- break;
- case LYX_ALIGN_LEFT:
- fl_set_button(dialog_->radio_align_left, 1);
- break;
- case LYX_ALIGN_CENTER:
- fl_set_button(dialog_->radio_align_center, 1);
- break;
- default:
- fl_set_button(dialog_->radio_align_block, 1);
- break;
+ case LYX_ALIGN_RIGHT:
+ fl_set_button(dialog_->radio_align_right, 1);
+ break;
+ case LYX_ALIGN_LEFT:
+ fl_set_button(dialog_->radio_align_left, 1);
+ break;
+ case LYX_ALIGN_CENTER:
+ fl_set_button(dialog_->radio_align_center, 1);
+ break;
+ default:
+ fl_set_button(dialog_->radio_align_block, 1);
+ break;
}
LyXAlignment alignpos = tclass[par_->layout()].alignpossible;
Spacing const space = par_->params().spacing();
switch (space.getSpace()) {
- default: linespacing = 1; break;
- case Spacing::Single: linespacing = 2; break;
- case Spacing::Onehalf: linespacing = 3; break;
- case Spacing::Double: linespacing = 4; break;
- case Spacing::Other: linespacing = 5; break;
+ default: linespacing = 1; break;
+ case Spacing::Single: linespacing = 2; break;
+ case Spacing::Onehalf: linespacing = 3; break;
+ case Spacing::Double: linespacing = 4; break;
+ case Spacing::Other: linespacing = 5; break;
}
fl_set_choice(dialog_->choice_linespacing, linespacing);
dialog_->input_space_above,
dialog_->choice_value_space_above,
dialog_->check_space_above);
-
+
setWidgetsFromVSpace(par_->params().spaceBottom(),
dialog_->choice_space_below,
dialog_->input_space_below,
dialog_->choice_value_space_below,
dialog_->check_space_below);
-
+
fl_set_button(dialog_->check_noindent,
par_->params().noindent());
}
}
}
}
-
+
bool validSpaceWidgets(FL_OBJECT * choice_type, FL_OBJECT * input_length)
{
// Paranoia check!
} // namespace anon
-
+
bool FormParagraph::input(FL_OBJECT * ob, long)
{
clearMessage();