#include "FormInclude.h"
#include "forms/form_include.h"
#include "insets/insetinclude.h"
+#include "Tooltips.h"
#include "xforms_helpers.h" // setEnabled
#include "support/lstrings.h" // strip
#include FORMS_H_LOCATION
{
dialog_.reset(build_include(this));
- fl_set_input_return(dialog_->input_filename, FL_RETURN_CHANGED);
- setPrehandler(dialog_->input_filename);
-
// Manage the ok and cancel buttons
bc().setOK(dialog_->button_ok);
bc().setCancel(dialog_->button_close);
+ // trigger an input event for cut&paste with middle mouse button.
+ setPrehandler(dialog_->input_filename);
+
+ fl_set_input_return(dialog_->input_filename, FL_RETURN_CHANGED);
+
+ // disable for read-only documents
bc().addReadOnly(dialog_->button_browse);
- bc().addReadOnly(dialog_->radio_verbatim);
bc().addReadOnly(dialog_->radio_useinput);
bc().addReadOnly(dialog_->radio_useinclude);
+ bc().addReadOnly(dialog_->radio_verbatim);
+
+ type_.init(dialog_->radio_useinput, ControlInclude::INPUT);
+ type_.init(dialog_->radio_useinclude, ControlInclude::INCLUDE);
+ type_.init(dialog_->radio_verbatim, ControlInclude::VERBATIM);
+
+ // set up the tooltips
+ string str = _("File name to include.");
+ tooltips().init(dialog_->input_filename, str);
+ str = _("Browse directories for file name.");
+ tooltips().init(dialog_->button_browse, str);
+ str = _("Use LaTeX \\input.");
+ tooltips().init(dialog_->radio_useinput, str);
+ str = _("Use LaTeX \\include.");
+ tooltips().init(dialog_->radio_useinclude, str);
+ str = _("Use LaTeX \\verbatiminput.");
+ tooltips().init(dialog_->radio_verbatim, str);
+ str = _("Underline spaces in generated output.");
+ tooltips().init(dialog_->check_visiblespace, str);
+ str = _("Show LaTeX preview.");
+ tooltips().init(dialog_->check_preview, str);
+ str = _("Load the file.");
+ tooltips().init(dialog_->button_load, str);
}
void FormInclude::update()
{
- fl_set_input(dialog_->input_filename,
- controller().params().cparams.getContents().c_str());
-
+ string const filename = controller().params().cparams.getContents();
string const cmdname = controller().params().cparams.getCmdName();
+ bool const preview = static_cast<bool>((controller().params().cparams.preview()));
- if (cmdname == "input")
- fl_set_button(dialog_->check_preview,
- int(controller().params().cparams.preview()));
- else
- fl_set_button(dialog_->check_preview, 0);
+ fl_set_input(dialog_->input_filename, filename.c_str());
+
+ bool const inputCommand = cmdname == "input";
+ bool const includeCommand = cmdname == "include";
+ bool const verbatimStarCommand = cmdname == "verbatiminput*";
+ bool const verbatimCommand = cmdname == "verbatiminput";
+
+ setEnabled(dialog_->check_preview, inputCommand);
+ fl_set_button(dialog_->check_preview, inputCommand ? preview : 0);
+
+ if (cmdname.empty())
+ type_.set(ControlInclude::INPUT);
- setEnabled(dialog_->check_preview, (cmdname == "input"));
+ if (includeCommand)
+ type_.set(ControlInclude::INCLUDE);
- fl_set_button(dialog_->radio_useinput, cmdname == "input");
- fl_set_button(dialog_->radio_useinclude, cmdname == "include");
- if (cmdname == "verbatiminput" || cmdname == "verbatiminput*") {
- fl_set_button(dialog_->radio_verbatim, 1);
- fl_set_button(dialog_->check_visiblespace, cmdname == "verbatiminput*");
+ if (verbatimCommand || verbatimStarCommand) {
+ type_.set(ControlInclude::VERBATIM);
+ fl_set_button(dialog_->check_visiblespace, verbatimStarCommand);
setEnabled(dialog_->check_visiblespace, true);
setEnabled(dialog_->button_load, false);
} else {
setEnabled(dialog_->check_visiblespace, false);
setEnabled(dialog_->button_load, true);
}
-
- if (cmdname.empty())
- fl_set_button(dialog_->radio_useinclude, 1);
}
else
controller().params().cparams.setContents("");
- if (fl_get_button(dialog_->radio_useinput))
+ ControlInclude::Type const type = ControlInclude::Type(type_.get());
+ if (type == ControlInclude::INPUT)
controller().params().flag = InsetInclude::INPUT;
- else if (fl_get_button(dialog_->radio_useinclude))
+ else if (type == ControlInclude::INCLUDE)
controller().params().flag = InsetInclude::INCLUDE;
- else if (fl_get_button(dialog_->radio_verbatim)) {
+ else if (type == ControlInclude::VERBATIM) {
if (fl_get_button(dialog_->check_visiblespace))
controller().params().flag = InsetInclude::VERBAST;
else
ButtonPolicy::SMInput action = ButtonPolicy::SMI_VALID;
if (ob == dialog_->button_browse) {
- ControlInclude::Type type;
- if (fl_get_button(dialog_->radio_useinput))
- type = ControlInclude::INPUT;
- else if (fl_get_button(dialog_->radio_verbatim))
- type = ControlInclude::VERBATIM;
- else
- type = ControlInclude::INCLUDE;
-
- string const in_name = fl_get_input(dialog_->input_filename);
+ string const in_name = fl_get_input(dialog_->input_filename);
fl_freeze_form(form());
+ ControlInclude::Type const type = ControlInclude::Type(type_.get());
string const out_name = controller().Browse(in_name, type);
fl_set_input(dialog_->input_filename, out_name.c_str());
fl_unfreeze_form(form());
Number of forms: 1
Unit of measure: FL_COORD_PIXEL
+SnapGrid: 5
=============== FORM ===============
Name: form_include
-Width: 340
-Height: 250
+Width: 305
+Height: 185
Number of Objects: 14
--------------------
class: FL_BOX
-type: UP_BOX
-box: 0 0 340 250
-boxtype: FL_UP_BOX
+type: FLAT_BOX
+box: 0 0 305 185
+boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
+size: FL_NORMAL_SIZE
lcol: FL_BLACK
label:
shortcut:
--------------------
class: FL_FRAME
type: ENGRAVED_FRAME
-box: 10 70 160 90
+box: 5 60 165 85
boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_CENTER
lcol: FL_BLACK
label:
shortcut:
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
+resize: FL_RESIZE_NONE
+gravity: FL_NorthWest FL_NorthWest
name:
callback:
argument:
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
-box: 230 30 100 30
+box: 210 25 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
lcol: FL_BLACK
label: Browse...|#B
shortcut:
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
+resize: FL_RESIZE_X
+gravity: FL_NorthEast FL_NorthEast
name: button_browse
callback: C_FormBaseInputCB
argument: 0
--------------------
class: FL_BUTTON
type: RETURN_BUTTON
-box: 120 210 100 30
+box: 115 155 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
lcol: FL_BLACK
label: OK
shortcut: ^M
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
+resize: FL_RESIZE_NONE
+gravity: FL_SouthEast FL_SouthEast
name: button_ok
callback: C_FormBaseOKCB
argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
-box: 230 210 100 30
+box: 210 155 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
lcol: FL_BLACK
label: Cancel|^[
shortcut:
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
+resize: FL_RESIZE_NONE
+gravity: FL_SouthEast FL_SouthEast
name: button_close
callback: C_FormBaseCancelCB
argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
-box: 230 170 100 30
+box: 210 120 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
lcol: FL_BLACK
label: Load|#L
shortcut:
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
+resize: FL_RESIZE_NONE
+gravity: FL_NorthWest FL_North
name: button_load
callback: C_FormBaseInputCB
argument: 0
--------------------
class: FL_INPUT
type: NORMAL_INPUT
-box: 10 30 210 30
+box: 5 25 205 25
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_TOP_LEFT
lcol: FL_BLACK
label: File name:|#F
shortcut:
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
+resize: FL_RESIZE_X
+gravity: FL_NorthWest FL_NorthEast
name: input_filename
callback: C_FormBaseInputCB
argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
-box: 180 70 150 30
+box: 175 60 125 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
lcol: FL_BLACK
label: Visible space|#s
shortcut:
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
+resize: FL_RESIZE_NONE
+gravity: FL_NorthWest FL_North
name: check_visiblespace
callback: C_FormBaseInputCB
argument: 0
--------------------
class: FL_ROUND3DBUTTON
type: RADIO_BUTTON
-box: 10 130 160 30
+box: 10 115 160 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
lcol: FL_BLACK
label: Verbatim|#V
shortcut:
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
+resize: FL_RESIZE_NONE
+gravity: FL_NorthWest FL_NorthWest
name: radio_verbatim
callback: C_FormBaseInputCB
argument: 0
--------------------
class: FL_ROUND3DBUTTON
type: RADIO_BUTTON
-box: 10 70 160 30
+box: 10 65 160 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
-label: Use input|#i
+label: Use input|#U
shortcut:
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
+resize: FL_RESIZE_NONE
+gravity: FL_NorthWest FL_NorthWest
name: radio_useinput
callback: C_FormBaseInputCB
argument: 0
+ value: 1
--------------------
class: FL_ROUND3DBUTTON
type: RADIO_BUTTON
-box: 10 100 160 30
+box: 10 90 160 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
-label: Use include|#U
+label: Use include|#i
shortcut:
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
+resize: FL_RESIZE_NONE
+gravity: FL_NorthWest FL_NorthWest
name: radio_useinclude
callback: C_FormBaseInputCB
argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
-box: 180 100 150 30
+box: 175 85 125 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
-label: Preview|#p
+label: Preview|#P
shortcut:
resize: FL_RESIZE_NONE
-gravity: FL_NoGravity FL_NoGravity
+gravity: FL_NorthWest FL_North
name: check_preview
callback: C_FormBaseInputCB
argument: 0