2002-09-10 10:18:58 +00:00
|
|
|
/**
|
|
|
|
* \file FormWrap.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Dekel Tsur
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-10 10:18:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "xformsBC.h"
|
|
|
|
#include "ControlWrap.h"
|
|
|
|
#include "FormWrap.h"
|
|
|
|
#include "forms/form_wrap.h"
|
2002-10-25 09:16:22 +00:00
|
|
|
#include "Tooltips.h"
|
|
|
|
|
2002-09-10 10:18:58 +00:00
|
|
|
#include "helper_funcs.h"
|
|
|
|
#include "xforms_helpers.h"
|
2002-10-25 09:16:22 +00:00
|
|
|
#include "checkedwidgets.h"
|
|
|
|
|
2003-03-05 23:19:45 +00:00
|
|
|
#include "insets/insetwrap.h"
|
|
|
|
#include "support/lstrings.h"
|
2003-05-14 09:17:22 +00:00
|
|
|
#include "lyx_forms.h"
|
2003-05-13 14:36:24 +00:00
|
|
|
#include "support/tostr.h"
|
2003-05-14 09:17:22 +00:00
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
using support::getStringFromVector;
|
|
|
|
using support::subst;
|
|
|
|
|
|
|
|
namespace frontend {
|
2002-09-10 10:18:58 +00:00
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
typedef FormController<ControlWrap, FormView<FD_wrap> > base_class;
|
2003-05-14 09:17:22 +00:00
|
|
|
|
2003-03-05 23:19:45 +00:00
|
|
|
FormWrap::FormWrap(Dialog & parent)
|
2003-04-30 02:06:04 +00:00
|
|
|
: base_class(parent, _("Text Wrap Settings"))
|
2002-09-10 10:18:58 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void FormWrap::build()
|
|
|
|
{
|
|
|
|
dialog_.reset(build_wrap(this));
|
|
|
|
|
|
|
|
// Manage the ok, apply and cancel/close buttons
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().setOK(dialog_->button_ok);
|
|
|
|
bcview().setApply(dialog_->button_apply);
|
|
|
|
bcview().setCancel(dialog_->button_close);
|
|
|
|
bcview().setRestore(dialog_->button_restore);
|
2002-09-10 10:18:58 +00:00
|
|
|
|
2002-10-25 09:16:22 +00:00
|
|
|
// disable for read-only documents
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().addReadOnly(dialog_->input_width);
|
|
|
|
bcview().addReadOnly(dialog_->choice_width_units);
|
2002-10-25 09:16:22 +00:00
|
|
|
|
|
|
|
// check validity of "length + unit" input
|
2003-03-10 03:13:28 +00:00
|
|
|
addCheckedGlueLength(bcview(), dialog_->input_width);
|
2002-10-25 09:16:22 +00:00
|
|
|
|
|
|
|
// trigger an input event for cut&paste with middle mouse button.
|
|
|
|
setPrehandler(dialog_->input_width);
|
|
|
|
|
|
|
|
fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
|
|
|
|
|
|
|
|
string const choice = getStringFromVector(getLatexUnits(), "|");
|
|
|
|
fl_addto_choice(dialog_->choice_width_units,
|
|
|
|
subst(choice, "%", "%%").c_str());
|
|
|
|
|
|
|
|
placement_.init(dialog_->radio_default, 0); // default
|
|
|
|
placement_.init(dialog_->radio_outer, 'p');
|
|
|
|
placement_.init(dialog_->radio_left, 'l');
|
|
|
|
placement_.init(dialog_->radio_right, 'r');
|
|
|
|
|
|
|
|
// set up the tooltips
|
|
|
|
string str = _("Enter width for the float.");
|
|
|
|
tooltips().init(dialog_->input_width, str);
|
|
|
|
str = _("Forces float to the right in a paragraph if the page number "
|
|
|
|
"is odd, and to the left if page number is even.");
|
|
|
|
tooltips().init(dialog_->radio_default, str);
|
|
|
|
str = _("Forces float to the left in a paragraph if the pagenumber "
|
|
|
|
"is odd, and to the right if page number is even.");
|
|
|
|
tooltips().init(dialog_->radio_outer, str);
|
|
|
|
str = _("Forces float to the left in the paragraph.");
|
|
|
|
tooltips().init(dialog_->radio_left, str);
|
|
|
|
str = _("Forces float to the right in the paragraph.");
|
|
|
|
tooltips().init(dialog_->radio_right, str);
|
2002-09-10 10:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormWrap::apply()
|
|
|
|
{
|
2003-03-05 23:19:45 +00:00
|
|
|
InsetWrapParams & params = controller().params();
|
|
|
|
|
|
|
|
params.width =
|
2002-09-10 10:18:58 +00:00
|
|
|
LyXLength(getLengthFromWidgets(dialog_->input_width,
|
|
|
|
dialog_->choice_width_units));
|
|
|
|
|
2002-10-25 09:16:22 +00:00
|
|
|
char const c = static_cast<char>(placement_.get());
|
|
|
|
if (c)
|
2003-03-05 23:19:45 +00:00
|
|
|
params.placement = c;
|
2002-09-10 10:18:58 +00:00
|
|
|
else
|
2003-03-05 23:19:45 +00:00
|
|
|
params.placement.erase(); // default
|
2002-09-10 10:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormWrap::update()
|
|
|
|
{
|
2003-03-05 23:19:45 +00:00
|
|
|
InsetWrapParams const & params = controller().params();
|
|
|
|
LyXLength len(params.width);
|
2002-09-10 10:18:58 +00:00
|
|
|
fl_set_input(dialog_->input_width, tostr(len.value()).c_str());
|
|
|
|
fl_set_choice(dialog_->choice_width_units, len.unit() + 1);
|
|
|
|
|
2003-03-05 23:19:45 +00:00
|
|
|
if (params.placement.empty())
|
2002-10-25 09:16:22 +00:00
|
|
|
placement_.set(dialog_->radio_default); // default
|
2002-09-10 10:18:58 +00:00
|
|
|
else
|
2003-03-05 23:19:45 +00:00
|
|
|
placement_.set(params.placement.c_str()[0]);
|
2002-09-10 10:18:58 +00:00
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|