/**
* \file FormInclude.C
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
* \author Alejandro Aguilar Sierra
- * \author John Levon, moz@compsoc.man.ac.uk
- * \author Angus Leeming, a.leeming@ic.ac.uk
+ * \author John Levon
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
*/
#include <config.h>
#pragma implementation
#endif
+#include "debug.h"
+
#include "xformsBC.h"
#include "ControlInclude.h"
#include "FormInclude.h"
-#include "form_include.h"
+#include "forms/form_include.h"
#include "insets/insetinclude.h"
#include "xforms_helpers.h" // setEnabled
#include "support/lstrings.h" // strip
+#include FORMS_H_LOCATION
-typedef FormCB<ControlInclude, FormDB<FD_form_include> > base_class;
+typedef FormCB<ControlInclude, FormDB<FD_include> > base_class;
-FormInclude::FormInclude(ControlInclude & c)
- : base_class(c, _("Include file"))
+FormInclude::FormInclude()
+ : base_class(_("Include file"))
{}
void FormInclude::build()
{
- dialog_.reset(build_include());
+ dialog_.reset(build_include(this));
fl_set_input_return(dialog_->input_filename, FL_RETURN_CHANGED);
setPrehandler(dialog_->input_filename);
bc().addReadOnly(dialog_->button_browse);
bc().addReadOnly(dialog_->radio_verbatim);
- bc().addReadOnly(dialog_->check_typeset);
bc().addReadOnly(dialog_->radio_useinput);
bc().addReadOnly(dialog_->radio_useinclude);
}
void FormInclude::update()
{
- if (controller().params().noload) {
- fl_set_input(dialog_->input_filename, "");
- fl_set_button(dialog_->check_typeset, 0);
- fl_set_button(dialog_->radio_useinput, 0);
- fl_set_button(dialog_->radio_useinclude, 1);
- fl_set_button(dialog_->radio_verbatim, 0);
- fl_set_button(dialog_->check_visiblespace, 0);
- fl_deactivate_object(dialog_->check_visiblespace);
- fl_set_object_lcol(dialog_->check_visiblespace, FL_INACTIVE);
- return;
- }
-
fl_set_input(dialog_->input_filename,
controller().params().cparams.getContents().c_str());
string const cmdname = controller().params().cparams.getCmdName();
- fl_set_button(dialog_->check_typeset,
- int(controller().params().noload));
+ if (cmdname == "input")
+ fl_set_button(dialog_->check_preview,
+ int(controller().params().cparams.preview()));
+ else
+ fl_set_button(dialog_->check_preview, 0);
+
+ setEnabled(dialog_->check_preview, (cmdname == "input"));
fl_set_button(dialog_->radio_useinput, cmdname == "input");
fl_set_button(dialog_->radio_useinclude, cmdname == "include");
fl_set_button(dialog_->radio_verbatim, 1);
fl_set_button(dialog_->check_visiblespace, cmdname == "verbatiminput*");
setEnabled(dialog_->check_visiblespace, true);
+ setEnabled(dialog_->button_load, false);
} else {
fl_set_button(dialog_->check_visiblespace, 0);
setEnabled(dialog_->check_visiblespace, false);
+ setEnabled(dialog_->button_load, true);
}
if (cmdname.empty())
void FormInclude::apply()
{
- controller().params().noload = fl_get_button(dialog_->check_typeset);
+ controller().params().cparams
+ .preview(fl_get_button(dialog_->check_preview));
string const file = fl_get_input(dialog_->input_filename);
if (controller().fileExists(file))
} else if (ob == dialog_->button_load) {
string const in_name = fl_get_input(dialog_->input_filename);
- if (!strip(in_name).empty() && controller().fileExists(in_name)) {
-// ApplyButton();
- OKButton();
- controller().load(strip(in_name));
+ if (!rtrim(in_name).empty() && controller().fileExists(in_name)) {
+ controller().OKButton();
+ controller().load(rtrim(in_name));
action = ButtonPolicy::SMI_NOOP;
}
} else if (ob == dialog_->radio_verbatim) {
setEnabled(dialog_->check_visiblespace, true);
+ setEnabled(dialog_->button_load, false);
} else if (ob == dialog_->radio_useinclude ||
ob == dialog_->radio_useinput) {
fl_set_button(dialog_->check_visiblespace, 0);
setEnabled(dialog_->check_visiblespace, false);
+ setEnabled(dialog_->button_load, true);
} else if (ob == dialog_->input_filename) {
string const in_name = fl_get_input(dialog_->input_filename);
- if (strip(in_name).empty())
+ if (rtrim(in_name).empty())
action = ButtonPolicy::SMI_INVALID;
}
+ if (ob == dialog_->radio_useinput) {
+ setEnabled(dialog_->check_preview, true);
+ } else if (ob == dialog_->radio_verbatim ||
+ ob == dialog_->radio_useinclude) {
+ fl_set_button(dialog_->check_preview, 0);
+ setEnabled(dialog_->check_preview, false);
+ }
+
return action;
}