2001-03-28 13:11:08 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2000-2001 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* \file FormGraphics.C
|
|
|
|
* \author Baruch Even, baruch.even@writeme.com
|
2000-07-31 12:30:10 +00:00
|
|
|
*/
|
|
|
|
|
2000-08-14 09:44:53 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
2000-08-14 09:44:53 +00:00
|
|
|
#endif
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2001-03-28 13:11:08 +00:00
|
|
|
#include "xformsBC.h"
|
|
|
|
#include "ControlGraphics.h"
|
2000-07-31 12:30:10 +00:00
|
|
|
#include "FormGraphics.h"
|
|
|
|
#include "form_graphics.h"
|
|
|
|
|
2001-09-13 12:37:40 +00:00
|
|
|
#include "xforms_helpers.h"
|
2001-03-28 13:11:08 +00:00
|
|
|
#include "input_validators.h"
|
2000-07-31 12:30:10 +00:00
|
|
|
#include "debug.h" // for lyxerr
|
2000-12-11 09:46:09 +00:00
|
|
|
#include "support/lstrings.h" // for strToDbl & tostr
|
2002-01-29 09:26:24 +00:00
|
|
|
#include "support/FileInfo.h"
|
|
|
|
#include "support/filetools.h" // for MakeAbsPath etc
|
2000-07-31 12:30:10 +00:00
|
|
|
#include "insets/insetgraphicsParams.h"
|
2001-09-18 10:58:35 +00:00
|
|
|
#include "lyxrc.h" // for lyxrc.display_graphics
|
2000-07-31 12:30:10 +00:00
|
|
|
|
2000-07-31 13:36:03 +00:00
|
|
|
using std::endl;
|
2000-08-14 09:44:53 +00:00
|
|
|
|
2001-10-23 09:03:17 +00:00
|
|
|
namespace {
|
|
|
|
|
2002-01-29 09:26:24 +00:00
|
|
|
// Bound the number of input characters
|
2001-10-23 09:03:17 +00:00
|
|
|
int const SCALE_MAXDIGITS = 3;
|
|
|
|
int const WIDTH_MAXDIGITS = 3;
|
|
|
|
int const HEIGHT_MAXDIGITS = 3;
|
|
|
|
int const ROTATE_MAXCHARS = 4;
|
|
|
|
int const FILENAME_MAXCHARS = 1024;
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
2001-09-13 09:34:39 +00:00
|
|
|
|
2001-03-28 13:11:08 +00:00
|
|
|
typedef FormCB<ControlGraphics, FormDB<FD_form_graphics> > base_class;
|
|
|
|
|
|
|
|
FormGraphics::FormGraphics(ControlGraphics & c)
|
2001-09-13 09:34:39 +00:00
|
|
|
: base_class(c, _("Graphics"))
|
2001-03-28 13:11:08 +00:00
|
|
|
{}
|
2000-07-31 12:30:10 +00:00
|
|
|
|
|
|
|
|
2002-01-29 09:26:24 +00:00
|
|
|
void FormGraphics::redraw()
|
|
|
|
{
|
|
|
|
if(form() && form()->visible)
|
|
|
|
fl_redraw_form(form());
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
FL_FORM * outer_form = fl_get_active_folder(dialog_->tabFolder);
|
|
|
|
if (outer_form && outer_form->visible)
|
|
|
|
fl_redraw_form(outer_form);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
void FormGraphics::build()
|
|
|
|
{
|
2001-03-15 13:37:04 +00:00
|
|
|
dialog_.reset(build_graphics());
|
2000-08-14 09:44:53 +00:00
|
|
|
|
2000-11-28 06:46:06 +00:00
|
|
|
// Manage the ok, apply, restore and cancel/close buttons
|
2001-03-15 13:37:04 +00:00
|
|
|
bc().setOK(dialog_->button_ok);
|
2002-01-29 09:26:24 +00:00
|
|
|
// bc().setApply(dialog_->button_apply);
|
2001-03-15 13:37:04 +00:00
|
|
|
bc().setCancel(dialog_->button_cancel);
|
2001-04-03 14:30:58 +00:00
|
|
|
bc().setRestore(dialog_->button_restore);
|
2001-03-15 13:37:04 +00:00
|
|
|
|
2002-01-29 09:26:24 +00:00
|
|
|
// the file section
|
|
|
|
file_.reset(build_file());
|
|
|
|
|
|
|
|
fl_set_input_return (file_->input_filename, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_return (file_->input_subcaption, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_return (file_->input_bbx0, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_return (file_->input_bby0, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_return (file_->input_bbx1, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_return (file_->input_bby1, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_maxchars(file_->input_filename, FILENAME_MAXCHARS);
|
|
|
|
|
|
|
|
string const bb_units = "pt|cm|in";
|
|
|
|
fl_addto_choice(file_->choice_bb_x0, bb_units.c_str());
|
|
|
|
fl_addto_choice(file_->choice_bb_y0, bb_units.c_str());
|
|
|
|
fl_addto_choice(file_->choice_bb_x1, bb_units.c_str());
|
|
|
|
fl_addto_choice(file_->choice_bb_y1, bb_units.c_str());
|
|
|
|
|
|
|
|
bc().addReadOnly(file_->button_browse);
|
|
|
|
bc().addReadOnly(file_->check_subcaption);
|
|
|
|
bc().addReadOnly(file_->button_getBB);
|
|
|
|
bc().addReadOnly(file_->button_clip);
|
|
|
|
bc().addReadOnly(file_->button_draft);
|
|
|
|
|
|
|
|
// the size section
|
|
|
|
size_.reset(build_size());
|
|
|
|
|
|
|
|
fl_set_input_return (size_->input_scale, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_return (size_->input_width, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_return (size_->input_height, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_return (size_->input_lyxwidth, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_return (size_->input_lyxheight, FL_RETURN_CHANGED);
|
|
|
|
|
|
|
|
fl_set_input_maxchars(size_->input_scale, SCALE_MAXDIGITS);
|
|
|
|
fl_set_input_maxchars(size_->input_width, WIDTH_MAXDIGITS);
|
|
|
|
fl_set_input_maxchars(size_->input_height, HEIGHT_MAXDIGITS);
|
|
|
|
|
|
|
|
fl_set_input_filter(size_->input_scale, fl_unsigned_float_filter);
|
|
|
|
fl_set_input_filter(size_->input_width, fl_unsigned_float_filter);
|
|
|
|
fl_set_input_filter(size_->input_height, fl_unsigned_float_filter);
|
|
|
|
|
|
|
|
fl_addto_choice(size_->choice_width_units, choice_Length_All.c_str());
|
|
|
|
fl_addto_choice(size_->choice_height_units, choice_Length_All.c_str());
|
|
|
|
fl_addto_choice(size_->choice_width_lyxwidth, choice_Length_All.c_str());
|
|
|
|
fl_addto_choice(size_->choice_width_lyxheight, choice_Length_All.c_str());
|
|
|
|
|
|
|
|
bc().addReadOnly(size_->button_default);
|
|
|
|
bc().addReadOnly(size_->button_wh);
|
|
|
|
bc().addReadOnly(size_->button_scale);
|
|
|
|
bc().addReadOnly(size_->check_aspectratio);
|
|
|
|
bc().addReadOnly(size_->radio_check_display);
|
|
|
|
bc().addReadOnly(size_->radio_display_mono);
|
|
|
|
bc().addReadOnly(size_->radio_display_gray);
|
|
|
|
bc().addReadOnly(size_->radio_display_color);
|
|
|
|
|
|
|
|
// the rotate section
|
|
|
|
special_.reset(build_special());
|
|
|
|
|
|
|
|
fl_set_input_return (special_->input_rotate_angle, FL_RETURN_CHANGED);
|
|
|
|
|
|
|
|
string const choice_origin =
|
|
|
|
"default|" // not important
|
|
|
|
"leftTop|leftBottom|leftBaseline|" // lt lb lB
|
|
|
|
"center|" // c
|
|
|
|
"centerTop|centerBottom|centerBaseline|" // ct cb cB
|
|
|
|
"rightTop|rightBottom|rightBaseline|" // rt rb rB
|
|
|
|
"referencePoint"; // special
|
|
|
|
fl_addto_choice(special_->choice_origin, choice_origin.c_str());
|
|
|
|
|
|
|
|
fl_set_input_return (special_->input_special, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_maxchars(special_->input_rotate_angle, ROTATE_MAXCHARS);
|
|
|
|
fl_set_input_filter(special_->input_rotate_angle, fl_float_filter);
|
|
|
|
|
|
|
|
// add the different tabfolders
|
|
|
|
fl_addto_tabfolder(dialog_->tabFolder, _("Filename"), file_->form);
|
|
|
|
fl_addto_tabfolder(dialog_->tabFolder, _("Image size"), size_->form);
|
|
|
|
fl_addto_tabfolder(dialog_->tabFolder, _("Special"), special_->form);
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormGraphics::apply()
|
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
// Create the parameters structure and fill the data from the dialog.
|
2001-03-28 13:11:08 +00:00
|
|
|
InsetGraphicsParams & igp = controller().params();
|
2002-01-29 09:26:24 +00:00
|
|
|
igp.filename = getStringFromInput(file_->input_filename);
|
|
|
|
if (!controller().bbChanged) // different to the original one?
|
|
|
|
igp.bb = string(); // don't write anything
|
|
|
|
else {
|
|
|
|
string bb;
|
|
|
|
if (getStringFromInput(file_->input_bbx0).empty())
|
|
|
|
bb = "0 ";
|
|
|
|
else
|
|
|
|
bb = getLengthFromWidgets(file_->input_bbx0,file_->choice_bb_x0)+" ";
|
|
|
|
if (getStringFromInput(file_->input_bby0).empty())
|
|
|
|
bb += "0 ";
|
|
|
|
else
|
|
|
|
bb += (getLengthFromWidgets(file_->input_bby0,file_->choice_bb_y0)+" ");
|
|
|
|
if (getStringFromInput(file_->input_bbx1).empty())
|
|
|
|
bb += "0 ";
|
|
|
|
else
|
|
|
|
bb += (getLengthFromWidgets(file_->input_bbx1,file_->choice_bb_x1)+" ");
|
|
|
|
if (getStringFromInput(file_->input_bby1).empty())
|
|
|
|
bb += "0 ";
|
|
|
|
else
|
|
|
|
bb += (getLengthFromWidgets(file_->input_bby1,file_->choice_bb_y1)+" ");
|
|
|
|
igp.bb = bb;
|
|
|
|
}
|
|
|
|
igp.draft = fl_get_button(file_->button_draft);
|
|
|
|
igp.clip = fl_get_button(file_->button_clip);
|
|
|
|
igp.subcaption = fl_get_button(file_->check_subcaption);
|
|
|
|
igp.subcaptionText = getStringFromInput(file_->input_subcaption);
|
|
|
|
if (fl_get_button(size_->radio_check_display)) {
|
2001-09-13 09:34:39 +00:00
|
|
|
igp.display = InsetGraphicsParams::NONE;
|
2002-01-29 09:26:24 +00:00
|
|
|
} else if (fl_get_button(size_->radio_display_mono)) {
|
|
|
|
igp.display = InsetGraphicsParams::MONOCHROME;
|
|
|
|
} else if (fl_get_button(size_->radio_display_gray)) {
|
|
|
|
igp.display = InsetGraphicsParams::GRAYSCALE;
|
|
|
|
} else if (fl_get_button(size_->radio_display_color)) {
|
|
|
|
igp.display = InsetGraphicsParams::COLOR;
|
2001-09-13 09:34:39 +00:00
|
|
|
}
|
2002-01-29 09:26:24 +00:00
|
|
|
if (fl_get_button(size_->button_default))
|
|
|
|
igp.size_type = InsetGraphicsParams::DEFAULT_SIZE;
|
|
|
|
else if (fl_get_button(size_->button_wh))
|
|
|
|
igp.size_type = InsetGraphicsParams::WH;
|
|
|
|
else
|
|
|
|
igp.size_type = InsetGraphicsParams::SCALE;
|
|
|
|
igp.width = LyXLength(getLengthFromWidgets(size_->input_width,size_->choice_width_units));
|
|
|
|
igp.height = LyXLength(getLengthFromWidgets(size_->input_height,size_->choice_height_units));
|
|
|
|
igp.scale = strToInt(getStringFromInput(size_->input_scale));
|
|
|
|
igp.keepAspectRatio = fl_get_button(size_->check_aspectratio);
|
|
|
|
igp.lyxwidth = LyXLength(getLengthFromWidgets(size_->input_lyxwidth,size_->choice_width_lyxwidth));
|
|
|
|
igp.lyxheight = LyXLength(getLengthFromWidgets(size_->input_lyxheight,size_->choice_width_lyxheight));
|
2000-08-14 09:44:53 +00:00
|
|
|
|
2001-09-13 12:37:40 +00:00
|
|
|
igp.rotateAngle =
|
2002-01-29 09:26:24 +00:00
|
|
|
strToDbl(getStringFromInput(special_->input_rotate_angle));
|
2001-09-13 09:34:39 +00:00
|
|
|
while (igp.rotateAngle < 0.0 || igp.rotateAngle > 360.0) {
|
|
|
|
if (igp.rotateAngle < 0.0) {
|
|
|
|
igp.rotateAngle += 360.0;
|
|
|
|
} else if (igp.rotateAngle > 360.0) {
|
|
|
|
igp.rotateAngle -= 360.0;
|
|
|
|
}
|
|
|
|
}
|
2002-01-29 09:26:24 +00:00
|
|
|
if (fl_get_choice(special_->choice_origin) > 0)
|
|
|
|
igp.rotateOrigin = fl_get_choice_text(special_->choice_origin);
|
|
|
|
else
|
|
|
|
igp.rotateOrigin = string();
|
|
|
|
igp.special = getStringFromInput(special_->input_special);
|
2000-08-14 09:44:53 +00:00
|
|
|
igp.testInvariant();
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
|
|
|
|
2000-10-13 05:57:05 +00:00
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
void FormGraphics::update()
|
2002-01-29 09:26:24 +00:00
|
|
|
{ string unit = "cm";
|
|
|
|
if (lyxrc.default_papersize < 3)
|
|
|
|
unit = "in";
|
|
|
|
string const defaultUnit = string(unit);
|
2000-08-14 09:44:53 +00:00
|
|
|
// Update dialog with details from inset
|
2001-03-28 13:11:08 +00:00
|
|
|
InsetGraphicsParams & igp = controller().params();
|
2002-01-29 09:26:24 +00:00
|
|
|
fl_set_input(file_->input_filename, igp.filename.c_str());
|
|
|
|
// set the bounding box values, if exists. First we need the whole
|
|
|
|
// path, because the controller knows nothing about the doc-dir
|
|
|
|
lyxerr << "GraphicsUpdate::BoundingBox = " << igp.bb << "\n";
|
|
|
|
controller().bbChanged = false;
|
|
|
|
if (igp.bb.empty()) {
|
|
|
|
string const fileWithAbsPath = MakeAbsPath(igp.filename, OnlyPath(igp.filename));
|
|
|
|
string bb = controller().readBB(fileWithAbsPath);
|
|
|
|
lyxerr << "file::BoundingBox = " << bb << "\n";
|
|
|
|
if (!bb.empty()) {
|
|
|
|
// get the values from the file
|
|
|
|
// in this case we always have the point-unit
|
|
|
|
fl_set_input(file_->input_bbx0, token(bb,' ',0).c_str());
|
|
|
|
fl_set_input(file_->input_bby0, token(bb,' ',1).c_str());
|
|
|
|
fl_set_input(file_->input_bbx1, token(bb,' ',2).c_str());
|
|
|
|
fl_set_input(file_->input_bby1, token(bb,' ',3).c_str());
|
|
|
|
}
|
|
|
|
} else { // get the values from the inset
|
|
|
|
controller().bbChanged = true;
|
|
|
|
LyXLength anyLength;
|
|
|
|
anyLength = LyXLength(token(igp.bb,' ',0));
|
|
|
|
updateWidgetsFromLength(file_->input_bbx0,file_->choice_bb_x0,anyLength,"pt");
|
|
|
|
anyLength = LyXLength(token(igp.bb,' ',1));
|
|
|
|
updateWidgetsFromLength(file_->input_bby0,file_->choice_bb_y0,anyLength,"pt");
|
|
|
|
anyLength = LyXLength(token(igp.bb,' ',2));
|
|
|
|
updateWidgetsFromLength(file_->input_bbx1,file_->choice_bb_x1,anyLength,"pt");
|
|
|
|
anyLength = LyXLength(token(igp.bb,' ',3));
|
|
|
|
updateWidgetsFromLength(file_->input_bby1,file_->choice_bb_y1,anyLength,"pt");
|
2001-09-13 09:34:39 +00:00
|
|
|
}
|
2002-01-29 09:26:24 +00:00
|
|
|
// Update the draft and clip mode
|
|
|
|
fl_set_button(file_->button_draft, igp.draft);
|
|
|
|
fl_set_button(file_->button_clip, igp.clip);
|
|
|
|
// Update the subcaption check button and input field
|
|
|
|
fl_set_button(file_->check_subcaption, igp.subcaption);
|
|
|
|
fl_set_input(file_->input_subcaption, igp.subcaptionText.c_str());
|
|
|
|
setEnabled(file_->input_subcaption,
|
|
|
|
fl_get_button(file_->check_subcaption));
|
|
|
|
switch (igp.display) {
|
|
|
|
case InsetGraphicsParams::NONE: { // dont't display
|
|
|
|
fl_set_button(size_->radio_check_display, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case InsetGraphicsParams::MONOCHROME: {
|
|
|
|
fl_set_button(size_->radio_display_mono, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case InsetGraphicsParams::GRAYSCALE: {
|
|
|
|
fl_set_button(size_->radio_display_gray, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case InsetGraphicsParams::COLOR: {
|
|
|
|
fl_set_button(size_->radio_display_color, 1);
|
|
|
|
break;
|
|
|
|
}
|
2001-09-13 09:34:39 +00:00
|
|
|
}
|
2002-01-29 09:26:24 +00:00
|
|
|
updateWidgetsFromLength(size_->input_width,size_->choice_width_units,igp.width,defaultUnit);
|
|
|
|
updateWidgetsFromLength(size_->input_height,size_->choice_height_units,igp.height,defaultUnit);
|
|
|
|
fl_set_input(size_->input_scale, tostr(igp.scale).c_str());
|
|
|
|
switch (igp.size_type) {
|
|
|
|
case InsetGraphicsParams::DEFAULT_SIZE: {
|
|
|
|
fl_set_button(size_->button_default,1);
|
|
|
|
setEnabled(size_->input_width, 0);
|
|
|
|
setEnabled(size_->choice_width_units, 0);
|
|
|
|
setEnabled(size_->input_height, 0);
|
|
|
|
setEnabled(size_->choice_height_units, 0);
|
|
|
|
setEnabled(size_->input_scale, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case InsetGraphicsParams::WH: {
|
|
|
|
fl_set_button(size_->button_wh, 1);
|
|
|
|
setEnabled(size_->input_width, 1);
|
|
|
|
setEnabled(size_->choice_width_units, 1);
|
|
|
|
setEnabled(size_->input_height, 1);
|
|
|
|
setEnabled(size_->choice_height_units, 1);
|
|
|
|
setEnabled(size_->input_scale, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case InsetGraphicsParams::SCALE: {
|
|
|
|
fl_set_button(size_->button_scale, 1);
|
|
|
|
setEnabled(size_->input_width, 0);
|
|
|
|
setEnabled(size_->choice_width_units, 0);
|
|
|
|
setEnabled(size_->input_height, 0);
|
|
|
|
setEnabled(size_->choice_height_units, 0);
|
|
|
|
setEnabled(size_->input_scale, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fl_set_button(size_->check_aspectratio,igp.keepAspectRatio);
|
|
|
|
// now the lyx-internally viewsize
|
|
|
|
updateWidgetsFromLength(size_->input_lyxwidth,size_->choice_width_lyxwidth,igp.lyxwidth,defaultUnit);
|
|
|
|
updateWidgetsFromLength(size_->input_lyxheight,size_->choice_width_lyxheight,igp.lyxheight,defaultUnit);
|
|
|
|
// Update the rotate angle and special commands
|
|
|
|
fl_set_input(special_->input_rotate_angle,
|
2000-08-14 09:44:53 +00:00
|
|
|
tostr(igp.rotateAngle).c_str());
|
2002-01-29 09:26:24 +00:00
|
|
|
if (igp.rotateOrigin.empty())
|
|
|
|
fl_set_choice(special_->choice_origin,0);
|
|
|
|
else
|
|
|
|
fl_set_choice_text(special_->choice_origin,igp.rotateOrigin.c_str());
|
|
|
|
fl_set_input(special_->input_special, igp.special.c_str());
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
|
2001-09-13 09:34:39 +00:00
|
|
|
ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
|
2000-10-24 13:13:59 +00:00
|
|
|
{
|
2002-01-29 09:26:24 +00:00
|
|
|
if (ob == file_->button_browse) {
|
2001-03-30 09:51:46 +00:00
|
|
|
// Get the filename from the dialog
|
2002-01-29 09:26:24 +00:00
|
|
|
string const in_name = getStringFromInput(file_->input_filename);
|
2001-03-30 09:51:46 +00:00
|
|
|
string const out_name = controller().Browse(in_name);
|
|
|
|
if (out_name != in_name && !out_name.empty()) {
|
2002-01-29 09:26:24 +00:00
|
|
|
fl_set_input(file_->input_filename, out_name.c_str());
|
2001-03-30 09:51:46 +00:00
|
|
|
}
|
2002-01-29 09:26:24 +00:00
|
|
|
} else if (!controller().bbChanged &&
|
|
|
|
((ob == file_->input_bbx0) || (ob == file_->input_bby0) ||
|
|
|
|
(ob == file_->input_bbx1) || (ob == file_->input_bby1) ||
|
|
|
|
(ob == file_->choice_bb_x0) || (ob == file_->choice_bb_y0) ||
|
|
|
|
(ob == file_->choice_bb_x1) || (ob == file_->choice_bb_y1))) {
|
|
|
|
controller().bbChanged = true;
|
|
|
|
} else if (ob == size_->button_default) {
|
|
|
|
setEnabled(size_->input_width, 0);
|
|
|
|
setEnabled(size_->choice_width_units, 0);
|
|
|
|
setEnabled(size_->input_height, 0);
|
|
|
|
setEnabled(size_->choice_height_units, 0);
|
|
|
|
setEnabled(size_->input_scale, 0);
|
|
|
|
} else if (ob == size_->button_wh) {
|
|
|
|
setEnabled(size_->input_width, 1);
|
|
|
|
setEnabled(size_->choice_width_units, 1);
|
|
|
|
setEnabled(size_->input_height, 1);
|
|
|
|
setEnabled(size_->choice_height_units, 1);
|
|
|
|
setEnabled(size_->input_scale, 0);
|
|
|
|
} else if (ob == size_->button_scale) {
|
|
|
|
setEnabled(size_->input_width, 0);
|
|
|
|
setEnabled(size_->choice_width_units, 0);
|
|
|
|
setEnabled(size_->input_height, 0);
|
|
|
|
setEnabled(size_->choice_height_units, 0);
|
|
|
|
setEnabled(size_->input_scale, 1);
|
|
|
|
} else if (ob == file_->check_subcaption) {
|
|
|
|
setEnabled(file_->input_subcaption,
|
|
|
|
fl_get_button(file_->check_subcaption));
|
|
|
|
} else if (ob == file_->button_getBB) {
|
|
|
|
string const filename = getStringFromInput(file_->input_filename);
|
|
|
|
if (!filename.empty()) {
|
|
|
|
string const fileWithAbsPath = MakeAbsPath(filename, OnlyPath(filename));
|
|
|
|
string bb = controller().readBB(fileWithAbsPath);
|
|
|
|
lyxerr << "getBB::BoundingBox = " << bb << "\n";
|
|
|
|
if (!bb.empty()) {
|
|
|
|
fl_set_input(file_->input_bbx0, token(bb,' ',0).c_str());
|
|
|
|
fl_set_input(file_->input_bby0, token(bb,' ',1).c_str());
|
|
|
|
fl_set_input(file_->input_bbx1, token(bb,' ',2).c_str());
|
|
|
|
fl_set_input(file_->input_bby1, token(bb,' ',3).c_str());
|
2001-09-13 09:34:39 +00:00
|
|
|
}
|
2002-01-29 09:26:24 +00:00
|
|
|
controller().bbChanged = false;
|
|
|
|
}
|
|
|
|
} else if (ob == dialog_->button_help) {
|
|
|
|
controller().help();
|
2001-09-13 09:34:39 +00:00
|
|
|
}
|
|
|
|
return checkInput();
|
2000-10-24 13:13:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-28 13:11:08 +00:00
|
|
|
ButtonPolicy::SMInput FormGraphics::checkInput()
|
2000-07-31 12:30:10 +00:00
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
// Put verifications that the dialog shows some sane values,
|
|
|
|
// if not disallow clicking on ok/apply.
|
|
|
|
// Possibly use a label in the bottom of the dialog to give the reason.
|
2001-03-28 13:11:08 +00:00
|
|
|
ButtonPolicy::SMInput activate = ButtonPolicy::SMI_VALID;
|
2000-08-14 09:44:53 +00:00
|
|
|
// We verify now that there is a filename, it exists, it's a file
|
|
|
|
// and it's readable.
|
2002-01-29 09:26:24 +00:00
|
|
|
string filename = getStringFromInput(file_->input_filename);
|
2000-08-14 09:44:53 +00:00
|
|
|
FileInfo file(filename);
|
2002-01-29 09:26:24 +00:00
|
|
|
if (filename.empty() || !file.isOK() || !file.exist()
|
|
|
|
|| !file.isRegular() || !file.readable()
|
2000-08-14 09:44:53 +00:00
|
|
|
)
|
2001-09-13 09:34:39 +00:00
|
|
|
activate = ButtonPolicy::SMI_INVALID;
|
2000-08-14 09:44:53 +00:00
|
|
|
|
2001-03-28 13:11:08 +00:00
|
|
|
return activate;
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
2002-01-29 09:26:24 +00:00
|
|
|
|