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
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2000-08-03 12:56:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2001-03-28 13:11:08 +00:00
|
|
|
#include "xformsBC.h"
|
2003-02-27 16:29:28 +00:00
|
|
|
#include "ControlCommand.h"
|
|
|
|
#include "FormText.h"
|
|
|
|
#include "forms/form_text.h"
|
2002-12-02 13:29:21 +00:00
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
#include FORMS_H_LOCATION
|
2000-08-03 12:56:25 +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-02-27 16:29:28 +00:00
|
|
|
FormText::FormText(Dialog & parent, string const & title)
|
|
|
|
: base_class(parent, title)
|
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
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
// Manage the ok, apply, restore and cancel/close buttons
|
2001-03-15 13:37:04 +00:00
|
|
|
bc().setOK(dialog_->button_ok);
|
|
|
|
bc().setApply(dialog_->button_apply);
|
2002-03-12 14:11:15 +00:00
|
|
|
bc().setCancel(dialog_->button_close);
|
2001-04-03 14:30:58 +00:00
|
|
|
bc().setRestore(dialog_->button_restore);
|
2000-11-28 06:46:06 +00:00
|
|
|
|
2003-02-27 16:29:28 +00:00
|
|
|
bc().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
|
|
|
}
|