2002-03-11 17:00:41 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file FormParagraph.C
|
|
|
|
|
* Copyright 2000-2001 The LyX Team.
|
|
|
|
|
* See the file COPYING.
|
2000-09-25 15:59:27 +00:00
|
|
|
|
*
|
2002-03-11 17:00:41 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Vigna, jug@sad.it
|
|
|
|
|
*/
|
2000-09-25 15:59:27 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2002-04-23 08:16:27 +00:00
|
|
|
|
#ifdef __GNUG__
|
2000-09-25 15:59:27 +00:00
|
|
|
|
#pragma implementation
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include FORMS_H_LOCATION
|
|
|
|
|
|
|
|
|
|
#include "FormParagraph.h"
|
|
|
|
|
#include "form_paragraph.h"
|
|
|
|
|
#include "Dialogs.h"
|
|
|
|
|
#include "Liason.h"
|
2002-05-23 12:08:47 +00:00
|
|
|
|
#include "frontends/LyXView.h"
|
2000-09-25 15:59:27 +00:00
|
|
|
|
#include "buffer.h"
|
|
|
|
|
#include "lyxtext.h"
|
2001-03-05 19:02:40 +00:00
|
|
|
|
#include "xforms_helpers.h"
|
2002-01-04 15:14:22 +00:00
|
|
|
|
#include "lyxrc.h" // to set the deafult length values
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "BufferView.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
#include "lyxtextclasslist.h"
|
2001-08-16 10:14:48 +00:00
|
|
|
|
#include "Spacing.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "ParagraphParameters.h"
|
2001-08-16 10:14:48 +00:00
|
|
|
|
#include "input_validators.h"
|
2001-10-23 09:04:46 +00:00
|
|
|
|
#include "helper_funcs.h"
|
2000-09-25 15:59:27 +00:00
|
|
|
|
|
2002-01-16 16:34:03 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2002-03-20 17:53:39 +00:00
|
|
|
|
#include "support/LAssert.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
#include <functional>
|
|
|
|
|
|
2000-09-25 15:59:27 +00:00
|
|
|
|
using Liason::setMinibuffer;
|
2002-02-16 15:59:55 +00:00
|
|
|
|
using std::vector;
|
|
|
|
|
using std::bind2nd;
|
2002-02-18 10:08:42 +00:00
|
|
|
|
using std::remove_if;
|
2000-09-25 15:59:27 +00:00
|
|
|
|
|
2001-05-03 14:31:33 +00:00
|
|
|
|
|
2000-09-25 15:59:27 +00:00
|
|
|
|
FormParagraph::FormParagraph(LyXView * lv, Dialogs * d)
|
2001-06-15 16:18:43 +00:00
|
|
|
|
: FormBaseBD(lv, d, _("Paragraph Layout")), par_(0)
|
2000-09-25 15:59:27 +00:00
|
|
|
|
{
|
2002-03-20 17:53:39 +00:00
|
|
|
|
// let the dialog be shown
|
|
|
|
|
// This is a permanent connection so we won't bother
|
|
|
|
|
// storing a copy because we won't be disconnecting.
|
2002-05-29 16:21:03 +00:00
|
|
|
|
d->showParagraph = boost::bind(&FormParagraph::show, this);
|
2001-06-15 16:18:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormParagraph::connect()
|
|
|
|
|
{
|
|
|
|
|
cp_ = d_->updateParagraph
|
2002-05-29 16:21:03 +00:00
|
|
|
|
.connect(boost::bind(&FormParagraph::changedParagraph, this));
|
2001-06-15 16:18:43 +00:00
|
|
|
|
FormBaseBD::connect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormParagraph::disconnect()
|
|
|
|
|
{
|
|
|
|
|
cp_.disconnect();
|
|
|
|
|
FormBaseBD::disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph const * FormParagraph::getCurrentParagraph() const
|
2001-06-15 16:18:43 +00:00
|
|
|
|
{
|
2001-12-05 05:26:22 +00:00
|
|
|
|
return lv_->view()->getLyXText()->cursor.par();
|
2001-06-15 16:18:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormParagraph::changedParagraph()
|
|
|
|
|
{
|
|
|
|
|
/// Record the paragraph
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph const * const p = getCurrentParagraph();
|
2002-04-19 10:51:06 +00:00
|
|
|
|
if (p == 0) // this is wrong as we don't set par_ here! /* || p == par_) */
|
2001-06-15 16:18:43 +00:00
|
|
|
|
return;
|
2002-03-11 22:47:41 +00:00
|
|
|
|
|
2002-03-22 15:24:32 +00:00
|
|
|
|
// For now, don't bother checking if the params are different.
|
2002-03-11 22:47:41 +00:00
|
|
|
|
|
2002-03-22 15:24:32 +00:00
|
|
|
|
// Will the underlying paragraph accept our changes?
|
|
|
|
|
Inset * const inset = p->inInset();
|
|
|
|
|
bool const accept = !(inset && inset->forceDefaultParagraphs(inset));
|
|
|
|
|
bc().valid(accept);
|
|
|
|
|
|
|
|
|
|
if (!accept) {
|
|
|
|
|
postWarning(_("Cannot apply paragraph settings to this inset!"));
|
2002-04-12 09:35:50 +00:00
|
|
|
|
} else {
|
|
|
|
|
clearMessage();
|
2002-03-22 15:24:32 +00:00
|
|
|
|
}
|
2000-09-25 15:59:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-11-10 17:29:47 +00:00
|
|
|
|
void FormParagraph::redraw()
|
|
|
|
|
{
|
2002-02-16 15:59:55 +00:00
|
|
|
|
if (form() && form()->visible)
|
|
|
|
|
fl_redraw_form(form());
|
2000-11-10 17:29:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-10-10 01:33:42 +00:00
|
|
|
|
FL_FORM * FormParagraph::form() const
|
|
|
|
|
{
|
2002-03-19 21:42:50 +00:00
|
|
|
|
if (dialog_.get())
|
|
|
|
|
return dialog_->form;
|
|
|
|
|
return 0;
|
2000-09-25 15:59:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormParagraph::build()
|
|
|
|
|
{
|
2002-03-19 21:42:50 +00:00
|
|
|
|
// the tabbed folder
|
|
|
|
|
dialog_.reset(build_paragraph());
|
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
// Allow the base class to control messages
|
|
|
|
|
setMessageWidget(dialog_->text_warning);
|
|
|
|
|
|
2002-03-19 21:42:50 +00:00
|
|
|
|
fl_addto_choice(dialog_->choice_space_above,
|
2002-03-20 18:47:43 +00:00
|
|
|
|
_(" None | Defskip | Smallskip "
|
|
|
|
|
"| Medskip | Bigskip | VFill | Length "));
|
2002-03-19 21:42:50 +00:00
|
|
|
|
fl_addto_choice(dialog_->choice_space_below,
|
2002-03-20 18:47:43 +00:00
|
|
|
|
_(" None | Defskip | Smallskip "
|
2002-03-21 21:21:28 +00:00
|
|
|
|
"| Medskip | Bigskip | VFill | Length "));
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
|
|
|
|
fl_addto_choice(dialog_->choice_linespacing,
|
2002-05-01 09:46:36 +00:00
|
|
|
|
_(" Default | Single | OneHalf | Double | Custom "));
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
|
|
|
|
fl_set_input_return(dialog_->input_space_above, FL_RETURN_CHANGED);
|
|
|
|
|
fl_set_input_return(dialog_->input_space_below, FL_RETURN_CHANGED);
|
2002-03-20 17:53:39 +00:00
|
|
|
|
fl_set_input_return(dialog_->input_labelwidth, FL_RETURN_CHANGED);
|
2002-03-19 21:42:50 +00:00
|
|
|
|
fl_set_input_return(dialog_->input_linespacing, FL_RETURN_CHANGED);
|
|
|
|
|
fl_set_input_filter(dialog_->input_linespacing, fl_unsigned_float_filter);
|
|
|
|
|
|
|
|
|
|
setPrehandler(dialog_->input_space_above);
|
|
|
|
|
setPrehandler(dialog_->input_space_below);
|
|
|
|
|
setPrehandler(dialog_->input_labelwidth);
|
|
|
|
|
setPrehandler(dialog_->input_linespacing);
|
|
|
|
|
|
|
|
|
|
// Create the contents of the unit choices
|
|
|
|
|
// Don't include the "%" terms...
|
|
|
|
|
vector<string> units_vec = getLatexUnits();
|
2002-02-16 15:59:55 +00:00
|
|
|
|
#if 0
|
2002-03-19 21:42:50 +00:00
|
|
|
|
for (vector<string>::iterator it = units_vec.begin();
|
2002-03-20 18:47:43 +00:00
|
|
|
|
it != units_vec.end(); ++it) {
|
2002-03-19 21:42:50 +00:00
|
|
|
|
if (contains(*it, "%"))
|
|
|
|
|
it = units_vec.erase(it, it+1) - 1;
|
|
|
|
|
}
|
2002-02-16 15:59:55 +00:00
|
|
|
|
#else
|
2002-03-19 21:42:50 +00:00
|
|
|
|
// Something similar to this is a better way to erase
|
|
|
|
|
vector<string>::iterator del =
|
|
|
|
|
remove_if(units_vec.begin(), units_vec.end(),
|
2002-03-20 18:47:43 +00:00
|
|
|
|
bind2nd(contains_functor(), "%"));
|
2002-03-19 21:42:50 +00:00
|
|
|
|
units_vec.erase(del, units_vec.end());
|
2002-02-16 15:59:55 +00:00
|
|
|
|
#endif
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
|
|
|
|
string units = getStringFromVector(units_vec, "|");
|
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
fl_addto_choice(dialog_->choice_value_space_above, units.c_str());
|
2002-03-19 21:42:50 +00:00
|
|
|
|
fl_addto_choice(dialog_->choice_value_space_below, units.c_str());
|
|
|
|
|
|
|
|
|
|
// Manage the ok, apply, restore and cancel/close buttons
|
|
|
|
|
bc_.setOK(dialog_->button_ok);
|
|
|
|
|
bc_.setApply(dialog_->button_apply);
|
|
|
|
|
bc_.setCancel(dialog_->button_close);
|
|
|
|
|
bc_.setRestore(dialog_->button_restore);
|
|
|
|
|
|
|
|
|
|
bc_.addReadOnly(dialog_->radio_align_right);
|
|
|
|
|
bc_.addReadOnly(dialog_->radio_align_left);
|
|
|
|
|
bc_.addReadOnly(dialog_->radio_align_block);
|
|
|
|
|
bc_.addReadOnly(dialog_->radio_align_center);
|
|
|
|
|
bc_.addReadOnly(dialog_->check_lines_top);
|
|
|
|
|
bc_.addReadOnly(dialog_->check_lines_bottom);
|
|
|
|
|
bc_.addReadOnly(dialog_->check_pagebreaks_top);
|
|
|
|
|
bc_.addReadOnly(dialog_->check_pagebreaks_bottom);
|
|
|
|
|
bc_.addReadOnly(dialog_->choice_space_above);
|
|
|
|
|
bc_.addReadOnly(dialog_->input_space_above);
|
|
|
|
|
bc_.addReadOnly(dialog_->check_space_above);
|
|
|
|
|
bc_.addReadOnly(dialog_->choice_space_below);
|
|
|
|
|
bc_.addReadOnly(dialog_->input_space_below);
|
|
|
|
|
bc_.addReadOnly(dialog_->check_space_below);
|
|
|
|
|
bc_.addReadOnly(dialog_->choice_linespacing);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
bc_.addReadOnly(dialog_->input_linespacing);
|
2002-03-19 21:42:50 +00:00
|
|
|
|
bc_.addReadOnly(dialog_->check_noindent);
|
|
|
|
|
bc_.addReadOnly(dialog_->input_labelwidth);
|
2000-09-25 15:59:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
VSpace 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);
|
2002-03-20 18:47:43 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-20 18:47:43 +00:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
} // namespace anon
|
2002-03-20 17:53:39 +00:00
|
|
|
|
|
|
|
|
|
|
2001-08-29 12:52:41 +00:00
|
|
|
|
void FormParagraph::apply()
|
2000-10-10 01:33:42 +00:00
|
|
|
|
{
|
2002-03-19 21:42:50 +00:00
|
|
|
|
if (!lv_->view()->available() || !dialog_.get())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// If a vspace kind is "Length" but there's no text in
|
2002-03-20 18:47:43 +00:00
|
|
|
|
// 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);
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
bool const line_top = fl_get_button(dialog_->check_lines_top);
|
|
|
|
|
bool const line_bottom = fl_get_button(dialog_->check_lines_bottom);
|
|
|
|
|
bool const pagebreak_top = fl_get_button(dialog_->check_pagebreaks_top);
|
|
|
|
|
bool const pagebreak_bottom = fl_get_button(dialog_->check_pagebreaks_bottom);
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
VSpace const space_top =
|
|
|
|
|
setVSpaceFromWidgets(dialog_->choice_space_above,
|
|
|
|
|
dialog_->input_space_above,
|
|
|
|
|
dialog_->choice_value_space_above,
|
|
|
|
|
dialog_->check_space_above);
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
VSpace const space_bottom =
|
|
|
|
|
setVSpaceFromWidgets(dialog_->choice_space_below,
|
|
|
|
|
dialog_->input_space_below,
|
|
|
|
|
dialog_->choice_value_space_below,
|
|
|
|
|
dialog_->check_space_below);
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
LyXAlignment align;
|
2002-03-19 21:42:50 +00:00
|
|
|
|
if (fl_get_button(dialog_->radio_align_left))
|
|
|
|
|
align = LYX_ALIGN_LEFT;
|
|
|
|
|
else if (fl_get_button(dialog_->radio_align_right))
|
|
|
|
|
align = LYX_ALIGN_RIGHT;
|
|
|
|
|
else if (fl_get_button(dialog_->radio_align_center))
|
|
|
|
|
align = LYX_ALIGN_CENTER;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
else
|
2002-03-19 21:42:50 +00:00
|
|
|
|
align = LYX_ALIGN_BLOCK;
|
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
string const labelwidthstring =
|
|
|
|
|
getStringFromInput(dialog_->input_labelwidth);
|
|
|
|
|
|
|
|
|
|
bool const noindent = fl_get_button(dialog_->check_noindent);
|
|
|
|
|
|
2002-03-19 21:42:50 +00:00
|
|
|
|
Spacing::Space linespacing = Spacing::Default;
|
2002-03-20 18:47:43 +00:00
|
|
|
|
string other;
|
2002-03-19 21:42:50 +00:00
|
|
|
|
switch (fl_get_choice(dialog_->choice_linespacing)) {
|
2002-03-20 18:47:43 +00:00
|
|
|
|
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;
|
2002-03-19 21:42:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-20 18:47:43 +00:00
|
|
|
|
Spacing const spacing(linespacing, other);
|
2002-03-20 17:53:39 +00:00
|
|
|
|
|
2002-03-19 21:42:50 +00:00
|
|
|
|
LyXText * text(lv_->view()->getLyXText());
|
|
|
|
|
text->setParagraph(lv_->view(), line_top, line_bottom, pagebreak_top,
|
2002-03-20 17:53:39 +00:00
|
|
|
|
pagebreak_bottom, space_top, space_bottom, spacing,
|
|
|
|
|
align, labelwidthstring, noindent);
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
|
|
|
|
// Actually apply these settings
|
2002-03-21 21:21:28 +00:00
|
|
|
|
lv_->view()->update(text,
|
2002-03-20 18:47:43 +00:00
|
|
|
|
BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
|
2002-03-19 21:42:50 +00:00
|
|
|
|
lv_->buffer()->markDirty();
|
|
|
|
|
setMinibuffer(lv_, _("Paragraph layout set"));
|
2000-09-25 15:59:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
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_input(input_length, "");
|
|
|
|
|
setEnabled(input_length, false);
|
|
|
|
|
setEnabled(choice_length, false);
|
|
|
|
|
|
|
|
|
|
switch (space.kind()) {
|
|
|
|
|
case VSpace::NONE:
|
|
|
|
|
fl_set_choice(choice_type, 1);
|
|
|
|
|
break;
|
|
|
|
|
case VSpace::DEFSKIP:
|
|
|
|
|
fl_set_choice(choice_type, 2);
|
|
|
|
|
break;
|
|
|
|
|
case VSpace::SMALLSKIP:
|
|
|
|
|
fl_set_choice(choice_type, 3);
|
|
|
|
|
break;
|
|
|
|
|
case VSpace::MEDSKIP:
|
|
|
|
|
fl_set_choice(choice_type, 4);
|
|
|
|
|
break;
|
|
|
|
|
case VSpace::BIGSKIP:
|
|
|
|
|
fl_set_choice(choice_type, 5);
|
|
|
|
|
break;
|
|
|
|
|
case VSpace::VFILL:
|
|
|
|
|
fl_set_choice(choice_type, 6);
|
|
|
|
|
break;
|
|
|
|
|
case VSpace::LENGTH:
|
|
|
|
|
{
|
|
|
|
|
fl_set_choice(choice_type, 7);
|
|
|
|
|
|
|
|
|
|
setEnabled(input_length, true);
|
|
|
|
|
setEnabled(choice_length, true);
|
|
|
|
|
|
|
|
|
|
bool const metric = lyxrc.default_papersize > 3;
|
|
|
|
|
string const default_unit = metric ? "cm" : "in";
|
|
|
|
|
string const length = space.length().asString();
|
|
|
|
|
|
|
|
|
|
updateWidgetsFromLengthString(input_length, choice_length,
|
|
|
|
|
length, default_unit);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fl_set_button(check_keep, space.keep());
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
} // namespace anon
|
2002-03-20 17:53:39 +00:00
|
|
|
|
|
|
|
|
|
|
2001-08-29 12:52:41 +00:00
|
|
|
|
void FormParagraph::update()
|
2000-09-25 15:59:27 +00:00
|
|
|
|
{
|
2002-03-19 21:42:50 +00:00
|
|
|
|
if (!dialog_.get())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Do this first; some objects may be de/activated subsequently.
|
|
|
|
|
bc_.readOnly(lv_->buffer()->isReadonly());
|
|
|
|
|
|
|
|
|
|
/// Record the paragraph
|
|
|
|
|
par_ = getCurrentParagraph();
|
|
|
|
|
|
|
|
|
|
fl_set_input(dialog_->input_labelwidth,
|
2002-03-20 17:53:39 +00:00
|
|
|
|
par_->getLabelWidthString().c_str());
|
2002-03-19 21:42:50 +00:00
|
|
|
|
setEnabled(dialog_->input_labelwidth,
|
2002-03-20 17:53:39 +00:00
|
|
|
|
(par_->getLabelWidthString() != _("Senseless with this layout!")));
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
|
|
|
|
fl_set_button(dialog_->radio_align_right, 0);
|
|
|
|
|
fl_set_button(dialog_->radio_align_left, 0);
|
|
|
|
|
fl_set_button(dialog_->radio_align_center, 0);
|
|
|
|
|
fl_set_button(dialog_->radio_align_block, 0);
|
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
LyXTextClass const & tclass =
|
|
|
|
|
textclasslist[lv_->view()->buffer()->params.textclass];
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
|
|
|
|
int align = par_->getAlign();
|
|
|
|
|
if (align == LYX_ALIGN_LAYOUT)
|
|
|
|
|
align = tclass[par_->layout()].align;
|
|
|
|
|
|
|
|
|
|
switch (align) {
|
2002-03-20 18:47:43 +00:00
|
|
|
|
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;
|
2002-03-19 21:42:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LyXAlignment alignpos = tclass[par_->layout()].alignpossible;
|
|
|
|
|
|
|
|
|
|
setEnabled(dialog_->radio_align_block, bool(alignpos & LYX_ALIGN_BLOCK));
|
|
|
|
|
setEnabled(dialog_->radio_align_center, bool(alignpos & LYX_ALIGN_CENTER));
|
|
|
|
|
setEnabled(dialog_->radio_align_left, bool(alignpos & LYX_ALIGN_LEFT));
|
|
|
|
|
setEnabled(dialog_->radio_align_right, bool(alignpos & LYX_ALIGN_RIGHT));
|
|
|
|
|
|
|
|
|
|
// no inset-text-owned paragraph may have pagebreaks
|
|
|
|
|
setEnabled(dialog_->check_pagebreaks_top, !par_->inInset());
|
|
|
|
|
setEnabled(dialog_->check_pagebreaks_bottom, !par_->inInset());
|
|
|
|
|
|
|
|
|
|
fl_set_button(dialog_->check_lines_top,
|
2002-03-20 17:53:39 +00:00
|
|
|
|
par_->params().lineTop());
|
2002-03-19 21:42:50 +00:00
|
|
|
|
fl_set_button(dialog_->check_lines_bottom,
|
2002-03-20 17:53:39 +00:00
|
|
|
|
par_->params().lineBottom());
|
2002-03-19 21:42:50 +00:00
|
|
|
|
fl_set_button(dialog_->check_pagebreaks_top,
|
2002-03-20 17:53:39 +00:00
|
|
|
|
par_->params().pagebreakTop());
|
2002-03-19 21:42:50 +00:00
|
|
|
|
fl_set_button(dialog_->check_pagebreaks_bottom,
|
2002-03-20 17:53:39 +00:00
|
|
|
|
par_->params().pagebreakBottom());
|
2002-03-19 21:42:50 +00:00
|
|
|
|
fl_set_button(dialog_->check_noindent,
|
2002-03-20 17:53:39 +00:00
|
|
|
|
par_->params().noindent());
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
|
|
|
|
int linespacing;
|
|
|
|
|
Spacing const space = par_->params().spacing();
|
|
|
|
|
|
|
|
|
|
switch (space.getSpace()) {
|
2002-03-20 18:47:43 +00:00
|
|
|
|
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;
|
2002-03-19 21:42:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fl_set_choice(dialog_->choice_linespacing, linespacing);
|
|
|
|
|
if (space.getSpace() == Spacing::Other) {
|
|
|
|
|
string const sp = tostr(space.getValue());
|
|
|
|
|
fl_set_input(dialog_->input_linespacing, sp.c_str());
|
|
|
|
|
setEnabled(dialog_->input_linespacing, true);
|
|
|
|
|
} else {
|
|
|
|
|
fl_set_input(dialog_->input_linespacing, "");
|
|
|
|
|
setEnabled(dialog_->input_linespacing, false);
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
setWidgetsFromVSpace(par_->params().spaceTop(),
|
|
|
|
|
dialog_->choice_space_above,
|
|
|
|
|
dialog_->input_space_above,
|
|
|
|
|
dialog_->choice_value_space_above,
|
|
|
|
|
dialog_->check_space_above);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
setWidgetsFromVSpace(par_->params().spaceBottom(),
|
|
|
|
|
dialog_->choice_space_below,
|
|
|
|
|
dialog_->input_space_below,
|
|
|
|
|
dialog_->choice_value_space_below,
|
|
|
|
|
dialog_->check_space_below);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
fl_set_button(dialog_->check_noindent,
|
|
|
|
|
par_->params().noindent());
|
|
|
|
|
}
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
namespace {
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
void synchronizeSpaceWidgets(FL_OBJECT * choice_type,
|
|
|
|
|
FL_OBJECT * input_length,
|
|
|
|
|
FL_OBJECT * choice_length,
|
|
|
|
|
bool readonly)
|
|
|
|
|
{
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
|
|
if (fl_get_choice(choice_type) != 7) {
|
|
|
|
|
fl_set_input(input_length, "");
|
|
|
|
|
setEnabled(input_length, false);
|
|
|
|
|
setEnabled(choice_length, false);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
setEnabled(input_length, !readonly);
|
|
|
|
|
setEnabled(choice_length, !readonly);
|
|
|
|
|
|
|
|
|
|
string const length = getStringFromInput(input_length);
|
|
|
|
|
|
|
|
|
|
if (strip(length).empty()) {
|
2002-03-19 21:42:50 +00:00
|
|
|
|
bool const metric = lyxrc.default_papersize > 3;
|
2002-03-20 17:53:39 +00:00
|
|
|
|
int const default_unit = metric ? 8 : 9;
|
|
|
|
|
|
|
|
|
|
fl_set_choice(choice_length, default_unit);
|
2002-03-19 21:42:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-03-20 17:53:39 +00:00
|
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
bool validSpaceWidgets(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);
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
if (fl_get_choice(choice_type) != 7)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
string const input = getStringFromInput(input_length);
|
|
|
|
|
return (input.empty() ||
|
|
|
|
|
isValidGlueLength(input) ||
|
|
|
|
|
isStrDbl(input));
|
2000-09-25 15:59:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
} // namespace anon
|
2000-09-25 15:59:27 +00:00
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
|
2000-10-10 01:33:42 +00:00
|
|
|
|
bool FormParagraph::input(FL_OBJECT * ob, long)
|
2000-09-25 15:59:27 +00:00
|
|
|
|
{
|
2002-03-20 17:53:39 +00:00
|
|
|
|
clearMessage();
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
|
|
|
|
// First check the buttons which are exclusive and you have to
|
|
|
|
|
// check only the actuall de/activated button.
|
|
|
|
|
//
|
|
|
|
|
// "Synchronize" the choices and input fields, making it
|
|
|
|
|
// impossible to commit senseless data.
|
|
|
|
|
|
|
|
|
|
if (ob == dialog_->choice_space_above) {
|
2002-03-20 17:53:39 +00:00
|
|
|
|
synchronizeSpaceWidgets(dialog_->choice_space_above,
|
|
|
|
|
dialog_->input_space_above,
|
|
|
|
|
dialog_->choice_value_space_above,
|
|
|
|
|
lv_->buffer()->isReadonly());
|
2002-03-19 21:42:50 +00:00
|
|
|
|
}
|
2002-03-20 17:53:39 +00:00
|
|
|
|
|
2002-03-19 21:42:50 +00:00
|
|
|
|
if (ob == dialog_->choice_space_below) {
|
2002-03-20 17:53:39 +00:00
|
|
|
|
synchronizeSpaceWidgets(dialog_->choice_space_below,
|
|
|
|
|
dialog_->input_space_below,
|
|
|
|
|
dialog_->choice_value_space_below,
|
|
|
|
|
lv_->buffer()->isReadonly());
|
2002-03-19 21:42:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
// Display a warning if the input is senseless
|
|
|
|
|
bool valid = (validSpaceWidgets(dialog_->choice_space_above,
|
|
|
|
|
dialog_->input_space_above) &&
|
|
|
|
|
validSpaceWidgets(dialog_->choice_space_below,
|
|
|
|
|
dialog_->input_space_below));
|
|
|
|
|
|
|
|
|
|
if (!valid) {
|
|
|
|
|
postWarning(_("Invalid Length (valid example: 10mm)"));
|
2002-03-19 21:42:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
int const choice_spacing = fl_get_choice(dialog_->choice_linespacing);
|
|
|
|
|
|
|
|
|
|
if (choice_spacing == 5)
|
2002-03-19 21:42:50 +00:00
|
|
|
|
setEnabled(dialog_->input_linespacing, true);
|
|
|
|
|
else {
|
2002-03-20 17:53:39 +00:00
|
|
|
|
fl_set_input(dialog_->input_linespacing, "");
|
2002-03-19 21:42:50 +00:00
|
|
|
|
setEnabled(dialog_->input_linespacing, false);
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
double const spacing =
|
|
|
|
|
strToDbl(getStringFromInput(dialog_->input_linespacing));
|
2002-03-19 21:42:50 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
if (choice_spacing == 5 && int(spacing) == 0)
|
2002-03-19 21:42:50 +00:00
|
|
|
|
valid = false;
|
|
|
|
|
|
|
|
|
|
return valid;
|
2000-09-25 15:59:27 +00:00
|
|
|
|
}
|