2002-03-11 17:00:41 +00:00
|
|
|
/**
|
2003-02-27 16:29:28 +00:00
|
|
|
* \file FormText.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-11 17:00:41 +00:00
|
|
|
*
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author Angus Leeming
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-08-03 12:56:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2003-02-27 16:29:28 +00:00
|
|
|
#include "FormText.h"
|
2003-09-05 13:15:43 +00:00
|
|
|
#include "ControlCommand.h"
|
2003-02-27 16:29:28 +00:00
|
|
|
#include "forms/form_text.h"
|
2003-09-05 13:15:43 +00:00
|
|
|
|
|
|
|
#include "xformsBC.h"
|
2003-03-04 13:54:05 +00:00
|
|
|
#include "forms_gettext.h"
|
2002-12-02 13:29:21 +00:00
|
|
|
|
2003-09-05 13:15:43 +00:00
|
|
|
#include "controllers/ButtonController.h"
|
|
|
|
|
2002-12-02 13:29:21 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
2003-05-14 09:17:22 +00:00
|
|
|
#include "lyx_forms.h"
|
2000-08-03 12:56:25 +00:00
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
using lyx::support::trim;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2003-09-05 13:15:43 +00:00
|
|
|
|
2003-02-27 16:29:28 +00:00
|
|
|
typedef FormController<ControlCommand, FormView<FD_text> > base_class;
|
2001-03-16 12:08:14 +00:00
|
|
|
|
2003-03-04 13:54:05 +00:00
|
|
|
FormText::FormText(Dialog & parent, string const & title, string const & label)
|
|
|
|
: base_class(parent, title), label_(label)
|
2001-03-28 13:11:08 +00:00
|
|
|
{}
|
2000-10-03 05:53:25 +00:00
|
|
|
|
|
|
|
|
2003-02-27 16:29:28 +00:00
|
|
|
void FormText::build()
|
2000-08-03 12:56:25 +00:00
|
|
|
{
|
2003-02-27 16:29:28 +00:00
|
|
|
dialog_.reset(build_text(this));
|
2000-08-04 13:12:30 +00:00
|
|
|
|
2003-02-27 16:29:28 +00:00
|
|
|
fl_set_input_return(dialog_->input_text, FL_RETURN_CHANGED);
|
|
|
|
setPrehandler(dialog_->input_text);
|
2000-11-28 06:46:06 +00:00
|
|
|
|
2003-03-04 13:54:05 +00:00
|
|
|
fl_set_object_label(dialog_->input_text, idex(label_).c_str());
|
|
|
|
fl_set_button_shortcut(dialog_->input_text, scex(label_).c_str(), 1);
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
// Manage the ok, apply, restore 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);
|
2000-11-28 06:46:06 +00:00
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().addReadOnly(dialog_->input_text);
|
2000-08-03 12:56:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-27 16:29:28 +00:00
|
|
|
void FormText::update()
|
2000-08-03 12:56:25 +00:00
|
|
|
{
|
2002-12-02 13:29:21 +00:00
|
|
|
string const contents = trim(controller().params().getContents());
|
2003-02-27 16:29:28 +00:00
|
|
|
fl_set_input(dialog_->input_text, contents.c_str());
|
2002-12-02 13:29:21 +00:00
|
|
|
|
|
|
|
bc().valid(!contents.empty());
|
2000-08-03 12:56:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-27 16:29:28 +00:00
|
|
|
void FormText::apply()
|
2000-08-03 12:56:25 +00:00
|
|
|
{
|
2003-02-27 16:29:28 +00:00
|
|
|
controller().params().setContents(fl_get_input(dialog_->input_text));
|
2000-08-03 12:56:25 +00:00
|
|
|
}
|