2002-03-11 17:00:41 +00:00
|
|
|
/**
|
2001-03-30 09:51:46 +00:00
|
|
|
* \file FormExternal.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
|
|
|
*
|
2001-03-30 09:51:46 +00:00
|
|
|
* \author Asger Alstrup
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author John Levon
|
2002-11-27 10:30:28 +00:00
|
|
|
* \author Angus Leeming
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-03-12 12:47:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
#include "xformsBC.h"
|
|
|
|
#include "ControlExternal.h"
|
2001-03-12 12:47:07 +00:00
|
|
|
#include "FormExternal.h"
|
2002-06-13 13:43:51 +00:00
|
|
|
#include "forms/form_external.h"
|
2001-03-30 09:51:46 +00:00
|
|
|
#include "gettext.h"
|
|
|
|
#include "xforms_helpers.h"
|
|
|
|
#include "helper_funcs.h"
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2002-04-15 12:05:07 +00:00
|
|
|
#include "support/lstrings.h"
|
2003-05-14 09:17:22 +00:00
|
|
|
#include "lyx_forms.h"
|
2002-04-15 12:05:07 +00:00
|
|
|
|
2003-03-05 11:30:35 +00:00
|
|
|
typedef FormController<ControlExternal, FormView<FD_external> > base_class;
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2003-03-05 11:30:35 +00:00
|
|
|
FormExternal::FormExternal(Dialog & parent)
|
2003-04-30 02:06:04 +00:00
|
|
|
: base_class(parent, _("External Material"))
|
2001-03-30 09:51:46 +00:00
|
|
|
{}
|
2001-03-12 12:47:07 +00:00
|
|
|
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
void FormExternal::apply()
|
2001-03-12 12:47:07 +00:00
|
|
|
{
|
2003-03-05 11:30:35 +00:00
|
|
|
InsetExternal::Params params = controller().params();
|
|
|
|
|
|
|
|
params.filename = fl_get_input(dialog_->input_filename);
|
|
|
|
params.parameters = fl_get_input(dialog_->input_parameters);
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2002-10-24 13:39:59 +00:00
|
|
|
int const choice = fl_get_choice(dialog_->choice_template) - 1;
|
2003-03-05 11:30:35 +00:00
|
|
|
params.templ = controller().getTemplate(choice);
|
|
|
|
|
|
|
|
controller().setParams(params);
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
void FormExternal::build()
|
2001-03-12 12:47:07 +00:00
|
|
|
{
|
2002-06-13 13:43:51 +00:00
|
|
|
dialog_.reset(build_external(this));
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
string const choice =
|
2002-11-27 10:30:28 +00:00
|
|
|
' ' + getStringFromVector(controller().getTemplates(), " | ") + ' ';
|
2001-03-30 09:51:46 +00:00
|
|
|
fl_addto_choice(dialog_->choice_template, choice.c_str());
|
2002-03-11 18:24:31 +00:00
|
|
|
|
|
|
|
fl_set_input_return (dialog_->input_filename, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_return (dialog_->input_parameters, FL_RETURN_CHANGED);
|
|
|
|
|
|
|
|
setPrehandler(dialog_->input_filename);
|
|
|
|
setPrehandler(dialog_->input_parameters);
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().setOK(dialog_->button_ok);
|
|
|
|
bcview().setApply(dialog_->button_apply);
|
|
|
|
bcview().setCancel(dialog_->button_close);
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().addReadOnly(dialog_->input_filename);
|
|
|
|
bcview().addReadOnly(dialog_->button_filenamebrowse);
|
|
|
|
bcview().addReadOnly(dialog_->input_parameters);
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
void FormExternal::update()
|
2001-03-12 12:47:07 +00:00
|
|
|
{
|
2001-03-30 09:51:46 +00:00
|
|
|
InsetExternal::Params const & params = controller().params();
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
fl_set_input(dialog_->input_filename, params.filename.c_str());
|
|
|
|
fl_set_input(dialog_->input_parameters, params.parameters.c_str());
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2003-05-23 10:40:18 +00:00
|
|
|
int ID = controller().getTemplateNumber(params.templ.lyxName);
|
|
|
|
if (ID < 0) ID = 0;
|
|
|
|
fl_set_choice(dialog_->choice_template, ID+1);
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
updateComboChange();
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
ButtonPolicy::SMInput FormExternal::input(FL_OBJECT * ob, long)
|
2001-03-12 12:47:07 +00:00
|
|
|
{
|
2001-03-30 09:51:46 +00:00
|
|
|
if (ob == dialog_->choice_template) {
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
// set to the chosen template
|
2002-10-24 13:39:59 +00:00
|
|
|
int const choice = fl_get_choice(dialog_->choice_template) - 1;
|
2003-03-05 11:30:35 +00:00
|
|
|
InsetExternal::Params params = controller().params();
|
|
|
|
params.templ = controller().getTemplate(choice);
|
|
|
|
controller().setParams(params);
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
updateComboChange();
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
} else if (ob == dialog_->button_filenamebrowse) {
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
string const in_name = fl_get_input(dialog_->input_filename);
|
|
|
|
string const out_name = controller().Browse(in_name);
|
|
|
|
fl_set_input(dialog_->input_filename, out_name.c_str());
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
} else if (ob == dialog_->button_edit) {
|
|
|
|
controller().editExternal();
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
} else if (ob == dialog_->button_view) {
|
|
|
|
controller().viewExternal();
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
} else if (ob == dialog_->button_update) {
|
|
|
|
controller().updateExternal();
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
return ButtonPolicy::SMI_VALID;
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormExternal::updateComboChange()
|
|
|
|
{
|
|
|
|
// Update the help text
|
|
|
|
fl_clear_browser(dialog_->browser_helptext);
|
2001-03-30 09:51:46 +00:00
|
|
|
fl_addto_browser(dialog_->browser_helptext,
|
|
|
|
controller().params().templ.helpText.c_str());
|
2001-03-12 12:47:07 +00:00
|
|
|
fl_set_browser_topline(dialog_->browser_helptext, 0);
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
bool const enabled = (!controller().params().templ.automaticProduction);
|
|
|
|
setEnabled(dialog_->button_update, enabled);
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|