diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 3183f67409..cfd09075ec 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,9 +1,11 @@ -2003-02-27 Rob Lahaye +2003-02-27 Rob Lahaye + + * FormInclude.[Ch]: use RadiobuttonGroup code, add tooltips and add + comments. * xformsImage.C: use lyx::float_equal() for comparing floats & doubles -2003-02-26 Rob Lahaye - + * forms/form_include.fd: nicer layout and add proper Gravity. * forms/form_external.fd: * forms/form_forks.fd: prettifying layout. diff --git a/src/frontends/xforms/FormInclude.C b/src/frontends/xforms/FormInclude.C index 7dcb1ae270..7cab61e6a0 100644 --- a/src/frontends/xforms/FormInclude.C +++ b/src/frontends/xforms/FormInclude.C @@ -21,6 +21,7 @@ #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 @@ -36,40 +37,70 @@ void FormInclude::build() { 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((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()); - setEnabled(dialog_->check_preview, (cmdname == "input")); + bool const inputCommand = cmdname == "input"; + bool const includeCommand = cmdname == "include"; + bool const verbatimStarCommand = cmdname == "verbatiminput*"; + bool const verbatimCommand = cmdname == "verbatiminput"; - 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*"); + setEnabled(dialog_->check_preview, inputCommand); + fl_set_button(dialog_->check_preview, inputCommand ? preview : 0); + + if (cmdname.empty()) + type_.set(ControlInclude::INPUT); + + if (includeCommand) + type_.set(ControlInclude::INCLUDE); + + 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 { @@ -77,9 +108,6 @@ void FormInclude::update() setEnabled(dialog_->check_visiblespace, false); setEnabled(dialog_->button_load, true); } - - if (cmdname.empty()) - fl_set_button(dialog_->radio_useinclude, 1); } @@ -94,11 +122,12 @@ void FormInclude::apply() 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 @@ -112,16 +141,9 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long) 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()); diff --git a/src/frontends/xforms/FormInclude.h b/src/frontends/xforms/FormInclude.h index 406ac4a9c4..1041b02b3f 100644 --- a/src/frontends/xforms/FormInclude.h +++ b/src/frontends/xforms/FormInclude.h @@ -15,6 +15,7 @@ #include "FormBase.h" +#include "RadioButtonGroup.h" class ControlInclude; struct FD_include; @@ -34,6 +35,9 @@ private: virtual void update(); /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); + + /// include type + RadioButtonGroup type_; }; -#endif +#endif // FORMINCLUDE_H diff --git a/src/frontends/xforms/forms/form_include.fd b/src/frontends/xforms/forms/form_include.fd index a987f07a27..c414020d60 100644 --- a/src/frontends/xforms/forms/form_include.fd +++ b/src/frontends/xforms/forms/form_include.fd @@ -5,22 +5,23 @@ Internal Form Definition File 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: @@ -33,7 +34,7 @@ argument: -------------------- 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 @@ -42,8 +43,8 @@ size: FL_DEFAULT_SIZE 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: @@ -51,7 +52,7 @@ 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 @@ -60,8 +61,8 @@ size: FL_NORMAL_SIZE 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 @@ -69,7 +70,7 @@ 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 @@ -78,8 +79,8 @@ size: FL_NORMAL_SIZE 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 @@ -87,7 +88,7 @@ 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 @@ -96,8 +97,8 @@ size: FL_NORMAL_SIZE 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 @@ -105,7 +106,7 @@ 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 @@ -114,8 +115,8 @@ size: FL_NORMAL_SIZE 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 @@ -123,7 +124,7 @@ 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 @@ -132,8 +133,8 @@ size: FL_NORMAL_SIZE 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 @@ -141,7 +142,7 @@ 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 @@ -150,8 +151,8 @@ size: FL_NORMAL_SIZE 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 @@ -177,7 +178,7 @@ argument: -------------------- 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 @@ -186,8 +187,8 @@ size: FL_NORMAL_SIZE 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 @@ -195,35 +196,36 @@ 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 @@ -249,17 +251,17 @@ argument: -------------------- 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