* Licence details can be found in the file COPYING.
*
* \author Baruch Even
- * \author Herbert Voss
+ * \author Herbert Voß
* \author Rob Lahaye
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "xformsBC.h"
-#include "ControlGraphics.h"
#include "FormGraphics.h"
+#include "ControlGraphics.h"
#include "forms/form_graphics.h"
+#include "controllers/helper_funcs.h"
+
#include "checkedwidgets.h"
#include "input_validators.h"
#include "Tooltips.h"
#include "xforms_helpers.h"
+#include "xformsBC.h"
-#include "debug.h" // for lyxerr
#include "lyxrc.h" // for lyxrc.display_graphics
#include "insets/insetgraphicsParams.h"
-#include "controllers/helper_funcs.h" // for getStringFromVector
-
#include "frontends/Alert.h"
-#include "support/lstrings.h" // for strToDbl & tostr
#include "support/lyxlib.h" // for float_equal
-#include "support/filetools.h" // for MakeAbsPath etc
+#include "support/tostr.h"
-#include "BoostFormat.h"
+#include "lyx_forms.h"
-#include FORMS_H_LOCATION
+using lyx::support::bformat;
+using lyx::support::float_equal;
+using lyx::support::getStringFromVector;
+using lyx::support::strToDbl;
+using lyx::support::strToInt;
+using lyx::support::token;
using std::endl;
+
using std::vector;
+using std::string;
namespace {
string defaultUnit("cm");
+#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
+bool const scalableTabfolders = false;
+#else
+bool const scalableTabfolders = true;
+#endif
+
} // namespace anon
-typedef FormCB<ControlGraphics, FormDB<FD_graphics> > base_class;
+typedef FormController<ControlGraphics, FormView<FD_graphics> > base_class;
-FormGraphics::FormGraphics()
- : base_class(_("Graphics"), false)
+FormGraphics::FormGraphics(Dialog & parent)
+ : base_class(parent, _("Graphics"), scalableTabfolders)
{}
dialog_.reset(build_graphics(this));
// Manage the ok, apply, restore and cancel/close buttons
- bc().setOK(dialog_->button_ok);
- bc().setApply(dialog_->button_apply);
- bc().setCancel(dialog_->button_close);
- bc().setRestore(dialog_->button_restore);
+ bcview().setOK(dialog_->button_ok);
+ bcview().setApply(dialog_->button_apply);
+ bcview().setCancel(dialog_->button_close);
+ bcview().setRestore(dialog_->button_restore);
- // the file section
+ // The file section.
file_.reset(build_graphics_file(this));
- // disable for read-only documents
- bc().addReadOnly(file_->button_browse);
- bc().addReadOnly(file_->check_aspectratio);
- bc().addReadOnly(file_->check_draft);
- bc().addReadOnly(file_->check_nounzip);
+ // Disable for read-only documents.
+ bcview().addReadOnly(file_->button_browse);
+ bcview().addReadOnly(file_->check_aspectratio);
+ bcview().addReadOnly(file_->check_draft);
+ bcview().addReadOnly(file_->check_nounzip);
- // check validity of "length + unit" input
- addCheckedGlueLength(bc(), file_->input_width);
- addCheckedGlueLength(bc(), file_->input_height);
+ // Check validity of "length + unit" input.
+ addCheckedGlueLength(bcview(), file_->input_width);
+ addCheckedGlueLength(bcview(), file_->input_height);
- // trigger an input event for cut&paste with middle mouse button.
+ // Trigger an input event for cut&paste with middle mouse button.
setPrehandler(file_->input_filename);
setPrehandler(file_->input_lyxscale);
setPrehandler(file_->input_width);
setPrehandler(file_->input_height);
- // for activate ok/apply immediately upon input
+ // Activate ok/apply immediately upon input.
fl_set_input_return(file_->input_filename, FL_RETURN_CHANGED);
fl_set_input_return(file_->input_lyxscale, FL_RETURN_CHANGED);
fl_set_input_return(file_->input_width, FL_RETURN_CHANGED);
fl_set_input_maxchars(file_->input_filename, FILENAME_MAXCHARS);
fl_set_input_filter(file_->input_lyxscale, fl_unsigned_int_filter);
- // width default is scaling: use unsigned float filter
+ // Width default is scaling: use unsigned float filter.
fl_set_input_filter(file_->input_width, fl_unsigned_float_filter);
fl_set_input_maxchars(file_->input_height, SIZE_MAXDIGITS);
_("Default|Monochrome|Grayscale|Color|Do not display");
fl_addto_choice(file_->choice_display, display_List.c_str());
- string const width_list = boost::io::str(boost::format(_("Scale%%|%1$s")) % choice_Length_All);
+ string const width_list = bformat(_("Scale%%%%|%1$s"), choice_Length_All);
fl_addto_choice(file_->choice_width, width_list.c_str());
fl_addto_choice(file_->choice_height, choice_Length_All.c_str());
str = _("Set the image width to the inserted value.");
tooltips().init(file_->input_width, str);
+ // xgettext:no-c-format
str = _("Select unit for width; Scale% for scaling whole image.");
tooltips().init(file_->choice_width, str);
str = _("Set the image height to the inserted value.");
bbox_.reset(build_graphics_bbox(this));
// disable for read-only documents
- bc().addReadOnly(bbox_->button_getBB);
- bc().addReadOnly(bbox_->check_clip);
+ bcview().addReadOnly(bbox_->button_getBB);
+ bcview().addReadOnly(bbox_->check_clip);
// check validity of "length + unit" input
- addCheckedLyXLength(bc(), bbox_->input_bb_x1, bbox_->text_X);
+ addCheckedLyXLength(bcview(), bbox_->input_bb_x1, bbox_->text_X);
// trigger an input event for cut&paste with middle mouse button.
setPrehandler(bbox_->input_bb_x0);
extra_.reset(build_graphics_extra(this));
// disable for read-only documents
- bc().addReadOnly(extra_->input_rotate_angle);
- bc().addReadOnly(extra_->choice_origin);
- bc().addReadOnly(extra_->check_subcaption);
- bc().addReadOnly(extra_->input_special);
+ bcview().addReadOnly(extra_->input_rotate_angle);
+ bcview().addReadOnly(extra_->choice_origin);
+ bcview().addReadOnly(extra_->check_subcaption);
+ bcview().addReadOnly(extra_->input_special);
// trigger an input event for cut&paste with middle mouse button.
setPrehandler(extra_->input_rotate_angle);
tooltips().init(extra_->check_subcaption, str);
str = _("Insert the optional subfigure caption.");
tooltips().init(extra_->input_subcaption, str);
- str = _("Add any additional latex option, which is defined in the "
+ str = _("Add any additional LaTeX option, which is defined in the "
"graphicx-package and not mentioned in the gui's tabfolders.");
tooltips().init(extra_->input_special, str);
- // add the different tabfolders
- fl_addto_tabfolder(dialog_->tabfolder, _("File"), file_->form);
- fl_addto_tabfolder(dialog_->tabfolder, _("Bounding Box"), bbox_->form);
- fl_addto_tabfolder(dialog_->tabfolder, _("Extra"), extra_->form);
+ // Enable the tabfolder to be rescaled correctly.
+ if (scalableTabfolders)
+ fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
- // work-around xforms bug re update of folder->x, folder->y coords.
- setPrehandler(dialog_->tabfolder);
+ // Stack tabs
+ fl_addto_tabfolder(dialog_->tabfolder, _("File").c_str(),
+ file_->form);
+ fl_addto_tabfolder(dialog_->tabfolder, _("Bounding Box").c_str(),
+ bbox_->form);
+ fl_addto_tabfolder(dialog_->tabfolder, _("Extra").c_str(),
+ extra_->form);
// set the right default unit
switch (lyxrc.default_papersize) {
- case BufferParams::PAPER_DEFAULT: break;
- case BufferParams::PAPER_USLETTER:
- case BufferParams::PAPER_LEGALPAPER:
- case BufferParams::PAPER_EXECUTIVEPAPER: defaultUnit = "in"; break;
- case BufferParams::PAPER_A3PAPER:
- case BufferParams::PAPER_A4PAPER:
- case BufferParams::PAPER_A5PAPER:
- case BufferParams::PAPER_B5PAPER: defaultUnit = "cm"; break;
+ case PAPER_DEFAULT: break;
+ case PAPER_USLETTER:
+ case PAPER_LEGALPAPER:
+ case PAPER_EXECUTIVEPAPER: defaultUnit = "in"; break;
+ case PAPER_A3PAPER:
+ case PAPER_A4PAPER:
+ case PAPER_A5PAPER:
+ case PAPER_B5PAPER: defaultUnit = "cm"; break;
}
}
InsetGraphicsParams & igp = controller().params();
// the file section
- igp.filename = getString(file_->input_filename);
+ igp.filename.set(getString(file_->input_filename),
+ kernel().bufferFilepath());
igp.lyxscale = strToInt(getString(file_->input_lyxscale));
if (igp.lyxscale == 0) {
switch (fl_get_choice(file_->choice_display)) {
case 5:
- igp.display = grfx::NoDisplay;
+ igp.display = lyx::graphics::NoDisplay;
break;
case 4:
- igp.display = grfx::ColorDisplay;
+ igp.display = lyx::graphics::ColorDisplay;
break;
case 3:
- igp.display = grfx::GrayscaleDisplay;
+ igp.display = lyx::graphics::GrayscaleDisplay;
break;
case 2:
- igp.display = grfx::MonochromeDisplay;
+ igp.display = lyx::graphics::MonochromeDisplay;
break;
case 1:
- igp.display = grfx::DefaultDisplay;
+ igp.display = lyx::graphics::DefaultDisplay;
}
// first item in choice_width means scaling
if (fl_get_choice(file_->choice_width) == 1) {
igp.scale = strToDbl(getString(file_->input_width));
- if (lyx::float_equal(igp.scale, 0.0, 0.05)) {
+ if (float_equal(igp.scale, 0.0, 0.05)) {
igp.scale = 100.0;
}
igp.width = LyXLength();
bb = getLengthFromWidgets(bbox_->input_bb_x0,
bbox_->choice_bb_units);
- bb += " ";
+ bb += ' ';
if (getString(bbox_->input_bb_y0).empty())
- bb += "0";
+ bb += '0';
else
bb += getLengthFromWidgets(bbox_->input_bb_y0,
bbox_->choice_bb_units);
- bb += " " + x1_str + " ";
+ bb += ' ' + x1_str + ' ';
if (getString(bbox_->input_bb_y1).empty())
- bb += "0";
+ bb += '0';
else
bb += getLengthFromWidgets(bbox_->input_bb_y1,
bbox_->choice_bb_units);
fl_set_input(extra_->input_rotate_angle, tostr(igp.rotateAngle).c_str());
int const origin_pos = fl_get_choice(extra_->choice_origin);
- if (origin_pos == 1) {
+ if (origin_pos == 0) {
igp.rotateOrigin.erase();
} else {
igp.rotateOrigin = origins_[origin_pos - 1];
InsetGraphicsParams & igp = controller().params();
// the file section
- fl_set_input(file_->input_filename, igp.filename.c_str());
+ string const name =
+ igp.filename.outputFilename(kernel().bufferFilepath());
+ fl_set_input(file_->input_filename, name.c_str());
fl_set_input(file_->input_lyxscale, tostr(igp.lyxscale).c_str());
switch (igp.display) {
- case grfx::NoDisplay:
+ case lyx::graphics::NoDisplay:
fl_set_choice(file_->choice_display, 5);
break;
- case grfx::ColorDisplay:
+ case lyx::graphics::ColorDisplay:
fl_set_choice(file_->choice_display, 4);
break;
- case grfx::GrayscaleDisplay:
+ case lyx::graphics::GrayscaleDisplay:
fl_set_choice(file_->choice_display, 3);
break;
- case grfx::MonochromeDisplay:
+ case lyx::graphics::MonochromeDisplay:
fl_set_choice(file_->choice_display, 2);
break;
- case grfx::DefaultDisplay:
+ case lyx::graphics::DefaultDisplay:
fl_set_choice(file_->choice_display, 1);
}
// set width input fields according to scaling or width/height input
- if (!lyx::float_equal(igp.scale, 0.0, 0.05)) {
+ if (!float_equal(igp.scale, 0.0, 0.05)) {
fl_set_input_filter(file_->input_width, fl_unsigned_float_filter);
fl_set_input_maxchars(file_->input_width, 0);
fl_set_input(file_->input_width, tostr(igp.scale).c_str());
igp.height, defaultUnit);
// disable height input in case of scaling
- bool const disable_height = !lyx::float_equal(igp.scale, 0.0, 0.05);
+ bool const disable_height = !float_equal(igp.scale, 0.0, 0.05);
setEnabled(file_->input_height, !disable_height);
setEnabled(file_->choice_height, !disable_height);
// the bb section
// set the bounding box values, if exists. First we need the whole
// path, because the controller knows nothing about the doc-dir
- updateBB(igp.filename, igp.bb);
+ updateBB(igp.filename.absFilename(), igp.bb);
fl_set_button(bbox_->check_clip, igp.clip);
// the extra section
if (igp.rotateOrigin.empty()) {
origin_pos = 1;
} else {
- origin_pos = 2 + findPos(origins_, igp.rotateOrigin);
+ origin_pos = 1 + findPos(origins_, igp.rotateOrigin);
}
fl_set_choice(extra_->choice_origin, origin_pos);
if (ob == file_->button_browse) {
// Get the filename from the dialog
string const in_name = getString(file_->input_filename);
- string const out_name = controller().Browse(in_name);
+ string const out_name = controller().browse(in_name);
lyxerr[Debug::GRAPHICS]
<< "[FormGraphics]out_name: " << out_name << endl;
if (out_name != in_name && !out_name.empty()) {