From af9352a2e7213022c3c7db834184a0da3af2d48a Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 22 Jul 2002 12:36:41 +0000 Subject: [PATCH] latest graphics jumbo patch from herbert git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4741 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 5 + lib/scripts/convertDefault.sh | 10 + src/ChangeLog | 5 + src/frontends/controllers/ChangeLog | 4 + src/frontends/controllers/ControlGraphics.C | 11 +- src/frontends/xforms/ChangeLog | 5 + src/frontends/xforms/FormGraphics.C | 242 +++++++++++++++----- src/graphics/ChangeLog | 4 + src/graphics/GraphicsConverter.C | 63 +++-- src/insets/ChangeLog | 6 + src/insets/insetgraphics.C | 44 ++-- src/insets/insetgraphicsParams.C | 95 ++++---- src/insets/insetgraphicsParams.h | 12 +- src/lengthcommon.C | 3 +- src/lyxlength.C | 15 +- src/lyxlength.h | 6 +- 16 files changed, 374 insertions(+), 156 deletions(-) create mode 100644 lib/scripts/convertDefault.sh diff --git a/lib/ChangeLog b/lib/ChangeLog index c2dea3baaf..8aa516f242 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2002-07-22 Herbert Voss + + * scripts/convertDefault.sh: defines a converter which is used + when no userdefined was found + 2002-07-20 Jean-Marc Lasgouttes * ui/default.ui: cleanup after change of Menu syntax. the diff --git a/lib/scripts/convertDefault.sh b/lib/scripts/convertDefault.sh new file mode 100644 index 0000000000..53bf117141 --- /dev/null +++ b/lib/scripts/convertDefault.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# this is the default converter if no one other was +# defined by the user in edit->preferences->converter +# +# the user can also redefine this default converter +# with an own shell script in ~/.lyx/scripts +# +# converts an image from $1 to $2 format +convert -depth 8 $1 $2 +exit 0 diff --git a/src/ChangeLog b/src/ChangeLog index 228b37eea2..56b9ae453d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2002-07-22 Herbert Voss + + * lengthcommon.C: + * lyxlength.[Ch]: add support for the vertical lengths + 2002-07-21 John Levon * toc.[Ch]: std:: fixes diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 2fe29e1e87..6b7b88d839 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2002-07-22 Herbert Voss + + * ControlGraphics.C: small changes + 2002-07-21 Jean-Marc Lasgouttes * ControlToc.C: remove getType diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index f154cc197e..c0a93a83a2 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -68,6 +68,7 @@ void ControlGraphics::applyParamsToInset() // Set the parameters in the inset, it also returns true if the new // parameters are different from what was in the inset already. bool changed = inset()->setParams(params(), lv_.buffer()->filePath()); + // Tell LyX we've got a change, and mark the document dirty, // if it changed. lv_.view()->updateInset(inset(), changed); @@ -105,10 +106,11 @@ string const ControlGraphics::readBB(string const & file) { string const abs_file = MakeAbsPath(file, lv_.buffer()->filePath()); - string const from = getExtFromContents(abs_file); - // Check if we have a Postscript file, then it's easy - if (contains(from, "ps")) - return readBB_from_PSFile(abs_file); + // try to get it from the file, if possible. Zipped files are + // unzipped in the readBB_from_PSFile-Function + string const bb = readBB_from_PSFile(abs_file); + if (!bb.empty()) + return bb; // we don't, so ask the Graphics Cache if it has loaded the file int width = 0; @@ -144,6 +146,7 @@ namespace { // correspond to the LaTeX identifiers shown in the comments at the // end of each line. char const * const rorigin_lyx_strs[] = { + // the LaTeX default is leftBaseline "center", // c "leftTop", "leftBottom", "leftBaseline", // lt lb lB "centerTop", "centerBottom", "centerBaseline", // ct cb cB diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 97f0e28ee8..a814b06b22 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2002-07-22 Herbert Voss + + * FormGraphics.C: add tooltips, changesize_type to size_kind. + some rearrangements to the code + 2002-07-21 John Levon * FormToc.C: std:: fix diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index dc93935c0d..54f4454512 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -18,6 +18,7 @@ #include "FormGraphics.h" #include "forms/form_graphics.h" #include "Alert.h" +#include "Tooltips.h" #include "xforms_helpers.h" #include "helper_funcs.h" @@ -113,6 +114,33 @@ void FormGraphics::build() bc().addReadOnly(file_->check_draft); bc().addReadOnly(file_->check_nounzip); + // set up the tooltips for the filesection + string str = _("The file you want to insert."); + tooltips().init(file_->input_filename, str); + str = _("Browse the directories."); + tooltips().init(file_->button_browse, str); + + str = _("Enables use of subfigure with an own caption."); + tooltips().init(file_->check_subcaption, str); + str = _("Insert the an optional subfigure caption"); + tooltips().init(file_->input_subcaption, str); + + str = _("Enables use of rotating for the image."); + tooltips().init(file_->check_rotate, str); + str = _("Insert the rotating angle in degrees (max 5 characters like 270.1)"); + tooltips().init(file_->input_rotate_angle, str); + + str = _("Insert the rotating origin point."); + tooltips().init(file_->choice_origin, str); + + str = _("Pass a filename like \"file.eps.gz\" to the LaTeX output. " + "This is useful when LaTeX should unzip the file. Needs an additional file " + "like \"file.eps.bb\" which holds the values for the bounding box"); + tooltips().init(file_->check_nounzip, str); + + str = _("Show image only as a rectangle of the original size."); + tooltips().init(file_->check_draft, str); + // the lyxview section lyxview_.reset(build_graphics_lyxview(this)); @@ -134,6 +162,45 @@ void FormGraphics::build() bc().addReadOnly(lyxview_->radio_nodisplay); bc().addReadOnly(lyxview_->check_lyxaspectratio); + // set up the tooltips for the lyxview section + str = _("Take the definition from the Preferences->Look&Feel->Misc as default."); + tooltips().init(lyxview_->radio_pref, str); + str = _("Show this image in black and white (monochrome)."); + tooltips().init(lyxview_->radio_mono, str); + str = _("Show this image in grayscale."); + tooltips().init(lyxview_->radio_gray, str); + str = _("Show this image in color."); + tooltips().init(lyxview_->radio_color, str); + str = _("Do not display this image."); + tooltips().init(lyxview_->radio_nodisplay, str); + + str = _("Copies all values from the LaTeX tab"); + tooltips().init(lyxview_->button_latex_values, str); + + str = _("Show this image in it's original size."); + tooltips().init(lyxview_->radio_lyxasis, str); + str = _("Scale the image down to the inserted values."); + tooltips().init(lyxview_->radio_lyxwh, str); + str = _("Scale the image down to the inserted value and keep aspectratio."); + tooltips().init(lyxview_->radio_lyxscale, str); + + str = _("Insert a width in any valid unit to which the image in the LyX-view " + "should be scaled up/down"); + tooltips().init(lyxview_->input_lyxwidth, str); + str = _("Insert a height in any valid unit to which the image in the LyX-view " + "should be scaled up/down"); + tooltips().init(lyxview_->input_lyxheight, str); + str = _("Insert a value > 0 in persent to which the image should be scaled up/down"); + tooltips().init(lyxview_->input_lyxscale, str); + str = _("Shows all possible units for the length"); + tooltips().init(lyxview_->choice_lyxwidth, str); + tooltips().init(lyxview_->choice_lyxheight, str); + str = _("Modifies the meaning of the \"width\" and \"height\" (and " + "\"totalheight\") keys such that if both are specified then rather than " + "distort the figure the figure is scaled such that neither dimension " + "exceeds the stated dimensions."); + tooltips().init(lyxview_->check_lyxaspectratio, str); + // the size section size_.reset(build_graphics_size(this)); @@ -159,6 +226,35 @@ void FormGraphics::build() bc().addReadOnly(size_->radio_scale); bc().addReadOnly(size_->check_aspectratio); + // set up the tooltips for the size section + str = _("Copies all values from the LyX tab"); + tooltips().init(size_->button_lyx_values, str); + + str = _("Show this image in it's original size."); + tooltips().init(size_->radio_asis, str); + str = _("Scale the image down to the inserted values."); + tooltips().init(size_->radio_wh, str); + str = _("Scale the image down to the inserted value and keep aspectratio."); + tooltips().init(size_->radio_scale, str); + + str = _("Modifies the meaning of the \"width\" and \"height\" (and " + "\"totalheight\") keys such that if both are specified then rather than " + "distort the figure the figure is scaled such that neither dimension " + "exceeds the stated dimensions."); + tooltips().init(size_->check_aspectratio, str); + + str = _("Insert a width in any valid unit to which the image in the LyX-view " + "should be scaled up/down"); + tooltips().init(lyxview_->input_lyxwidth, str); + str = _("Insert a height in any valid unit to which the image in the LyX-view " + "should be scaled up/down"); + tooltips().init(lyxview_->input_lyxheight, str); + str = _("Insert a value > 0 in persent to which the image should be scaled up/down"); + tooltips().init(lyxview_->input_lyxscale, str); + str = _("Shows all possible units for the length"); + tooltips().init(lyxview_->choice_lyxwidth, str); + tooltips().init(lyxview_->choice_lyxheight, str); + // the bounding box selection bbox_.reset(build_graphics_bbox(this)); fl_set_input_return (bbox_->input_bb_x0, FL_RETURN_CHANGED); @@ -181,18 +277,45 @@ void FormGraphics::build() bc().addReadOnly(bbox_->button_getBB); bc().addReadOnly(bbox_->check_clip); + // set up the tooltips for the bounding-box-section + str = _("The lower left x-value of the bounding box"); + tooltips().init(bbox_->input_bb_x0, str); + str = _("The lower left y-value of the bounding box"); + tooltips().init(bbox_->input_bb_y0, str); + str = _("The upper right x-value of the bounding box"); + tooltips().init(bbox_->input_bb_x1, str); + str = _("The upper right y-value of the bounding box"); + tooltips().init(bbox_->input_bb_y1, str); + str = _("Shows all possible units for the bounding box values"); + tooltips().init(bbox_->choice_bb_units, str); + + str = _("Read the image coordinates new from file. If it's an (e)ps-file " + "than the bounding box is read otherwise the imagesize in pixels. " + "The default unit is \"bp\" the PostScript b)ig p)oint."); + tooltips().init(bbox_->button_getBB, str); + + str = _("Enable this checkbox when the image should be clipped to the " + "bounding box values."); + tooltips().init(bbox_->check_clip, str); + // the rotate section special_.reset(build_graphics_special(this)); fl_set_input_return (special_->input_special, FL_RETURN_CHANGED); setPrehandler(special_->input_special); + // set up the tooltips for the special section + str = _("Any additional option, which is defined in the graphicx-package " + "and not mentioned in the gui's tabfolders can be defined."); + tooltips().init(special_->input_special, str); + // add the different tabfolders fl_addto_tabfolder(dialog_->tabfolder, _("File"), file_->form); fl_addto_tabfolder(dialog_->tabfolder, _("LyX View"), lyxview_->form); fl_addto_tabfolder(dialog_->tabfolder, _("LaTeX Size"), size_->form); fl_addto_tabfolder(dialog_->tabfolder, _("Bounding Box"), bbox_->form); fl_addto_tabfolder(dialog_->tabfolder, _("Extras"), special_->form); + // set the right default unit if (lyxrc.default_papersize < 3) defaultUnit = "in"; @@ -240,11 +363,11 @@ void FormGraphics::apply() igp.display = InsetGraphicsParams::NONE; if (fl_get_button(lyxview_->radio_lyxasis)) - igp.lyxsize_type = InsetGraphicsParams::DEFAULT_SIZE; + igp.lyxsize_kind = InsetGraphicsParams::DEFAULT_SIZE; else if (fl_get_button(lyxview_->radio_lyxwh)) - igp.lyxsize_type = InsetGraphicsParams::WH; + igp.lyxsize_kind = InsetGraphicsParams::WH; else - igp.lyxsize_type = InsetGraphicsParams::SCALE; + igp.lyxsize_kind = InsetGraphicsParams::SCALE; igp.lyxwidth = getLyXLengthFromWidgets(lyxview_->input_lyxwidth, lyxview_->choice_lyxwidth); @@ -257,11 +380,11 @@ void FormGraphics::apply() // the size section if (fl_get_button(size_->radio_asis)) - igp.size_type = InsetGraphicsParams::DEFAULT_SIZE; + igp.size_kind = InsetGraphicsParams::DEFAULT_SIZE; else if (fl_get_button(size_->radio_wh)) - igp.size_type = InsetGraphicsParams::WH; + igp.size_kind = InsetGraphicsParams::WH; else - igp.size_type = InsetGraphicsParams::SCALE; + igp.size_kind = InsetGraphicsParams::SCALE; igp.width = getLyXLengthFromWidgets(size_->input_width, size_->choice_width); @@ -356,7 +479,7 @@ void FormGraphics::update() { updateWidgetsFromLength(lyxview_->input_lyxheight, lyxview_->choice_lyxheight, igp.lyxheight, defaultUnit); fl_set_input(lyxview_->input_lyxscale, tostr(igp.lyxscale).c_str()); - switch (igp.lyxsize_type) { + switch (igp.lyxsize_kind) { case InsetGraphicsParams::DEFAULT_SIZE: { fl_set_button(lyxview_->radio_lyxasis,1); setEnabled(lyxview_->input_lyxwidth, 0); @@ -367,6 +490,15 @@ void FormGraphics::update() { setEnabled(lyxview_->input_lyxscale, 0); break; } + case InsetGraphicsParams::SCALE: { + fl_set_button(lyxview_->radio_lyxscale, 1); + setEnabled(lyxview_->input_lyxwidth, 0); + setEnabled(lyxview_->choice_lyxwidth, 0); + setEnabled(lyxview_->input_lyxheight, 0); + setEnabled(lyxview_->choice_lyxheight, 0); + setEnabled(lyxview_->input_lyxscale, 1); + break; + } case InsetGraphicsParams::WH: { fl_set_button(lyxview_->radio_lyxwh, 1); setEnabled(lyxview_->input_lyxwidth, 1); @@ -377,17 +509,8 @@ void FormGraphics::update() { setEnabled(lyxview_->input_lyxscale, 0); break; } - case InsetGraphicsParams::SCALE: { - fl_set_button(lyxview_->radio_lyxscale, 1); - setEnabled(lyxview_->input_lyxwidth, 0); - setEnabled(lyxview_->choice_lyxwidth, 0); - setEnabled(lyxview_->input_lyxheight, 0); - setEnabled(lyxview_->choice_lyxheight, 0); - setEnabled(lyxview_->check_lyxaspectratio, 0); - setEnabled(lyxview_->input_lyxscale, 1); - break; - } } + fl_set_button(lyxview_->check_lyxaspectratio, igp.keepLyXAspectRatio); fl_set_button(lyxview_->check_lyxaspectratio, igp.keepLyXAspectRatio); @@ -398,7 +521,9 @@ void FormGraphics::update() { updateWidgetsFromLength(size_->input_height, size_->choice_height, igp.height, defaultUnit); fl_set_input(size_->input_scale, tostr(igp.scale).c_str()); - switch (igp.size_type) { + lyxerr[Debug::GRAPHICS] << "FormGraphics::update: igp.size_kind = " + << igp.size_kind << endl; + switch (igp.size_kind) { case InsetGraphicsParams::DEFAULT_SIZE: { fl_set_button(size_->radio_asis,1); setEnabled(size_->input_width, 0); @@ -409,16 +534,6 @@ void FormGraphics::update() { setEnabled(size_->input_scale, 0); break; } - case InsetGraphicsParams::WH: { - fl_set_button(size_->radio_wh, 1); - setEnabled(size_->input_width, 1); - setEnabled(size_->choice_width, 1); - setEnabled(size_->input_height, 1); - setEnabled(size_->choice_height, 1); - setEnabled(size_->check_aspectratio, 1); - setEnabled(size_->input_scale, 0); - break; - } case InsetGraphicsParams::SCALE: { fl_set_button(size_->radio_scale, 1); setEnabled(size_->input_width, 0); @@ -429,6 +544,16 @@ void FormGraphics::update() { setEnabled(size_->input_scale, 1); break; } + case InsetGraphicsParams::WH: { + fl_set_button(size_->radio_wh, 1); + setEnabled(size_->input_width, 1); + setEnabled(size_->choice_width, 1); + setEnabled(size_->input_height, 1); + setEnabled(size_->choice_height, 1); + setEnabled(size_->check_aspectratio, 1); + setEnabled(size_->input_scale, 0); + break; + } } fl_set_button(size_->check_aspectratio, igp.keepAspectRatio); @@ -539,13 +664,6 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(lyxview_->choice_lyxheight, 0); setEnabled(lyxview_->check_lyxaspectratio, 0); setEnabled(lyxview_->input_lyxscale, 0); - } else if (ob == lyxview_->radio_lyxwh) { - setEnabled(lyxview_->input_lyxwidth, 1); - setEnabled(lyxview_->choice_lyxwidth, 1); - setEnabled(lyxview_->input_lyxheight, 1); - setEnabled(lyxview_->choice_lyxheight, 1); - setEnabled(lyxview_->check_lyxaspectratio, 1); - setEnabled(lyxview_->input_lyxscale, 0); } else if (ob == lyxview_->radio_lyxscale) { setEnabled(lyxview_->input_lyxwidth, 0); setEnabled(lyxview_->choice_lyxwidth, 0); @@ -553,6 +671,13 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(lyxview_->choice_lyxheight, 0); setEnabled(lyxview_->check_lyxaspectratio, 0); setEnabled(lyxview_->input_lyxscale, 1); + } else if (ob == lyxview_->radio_lyxwh) { + setEnabled(lyxview_->input_lyxwidth, 1); + setEnabled(lyxview_->choice_lyxwidth, 1); + setEnabled(lyxview_->input_lyxheight, 1); + setEnabled(lyxview_->choice_lyxheight, 1); + setEnabled(lyxview_->check_lyxaspectratio, 1); + setEnabled(lyxview_->input_lyxscale, 0); } else if (ob == lyxview_->button_latex_values) { if (contains(fl_get_choice_text(size_->choice_width),'%') || contains(fl_get_choice_text(size_->choice_height),'%')) @@ -582,14 +707,6 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(lyxview_->choice_lyxheight, 0); setEnabled(lyxview_->check_lyxaspectratio, 0); setEnabled(lyxview_->input_lyxscale, 0); - } else if (fl_get_button (size_->radio_wh) == 1) { - fl_set_button (lyxview_->radio_lyxwh, 1); - setEnabled(lyxview_->input_lyxwidth, 1); - setEnabled(lyxview_->choice_lyxwidth, 1); - setEnabled(lyxview_->input_lyxheight, 1); - setEnabled(lyxview_->choice_lyxheight, 1); - setEnabled(lyxview_->check_lyxaspectratio, 1); - setEnabled(lyxview_->input_lyxscale, 0); } else if (fl_get_button (size_->radio_scale) ==1) { fl_set_button (lyxview_->radio_lyxscale, 1); setEnabled(lyxview_->input_lyxwidth, 0); @@ -598,6 +715,15 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(lyxview_->choice_lyxheight, 0); setEnabled(lyxview_->check_lyxaspectratio, 0); setEnabled(lyxview_->input_lyxscale, 1); + } else if (fl_get_button (size_->radio_wh) == 1) { + fl_set_button (lyxview_->radio_lyxwh, 1); + setEnabled(lyxview_->input_lyxwidth, 1); + setEnabled(lyxview_->choice_lyxwidth, 1); + setEnabled(lyxview_->input_lyxheight, 1); + setEnabled(lyxview_->choice_lyxheight, 1); + setEnabled(lyxview_->check_lyxaspectratio, 1); + setEnabled(lyxview_->input_lyxscale, 0); + setEnabled(lyxview_->check_lyxaspectratio, 1); } } fl_set_button(lyxview_->check_lyxaspectratio, @@ -638,13 +764,6 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(size_->choice_height, 0); setEnabled(size_->check_aspectratio, 0); setEnabled(size_->input_scale, 0); - } else if (ob == size_->radio_wh) { - setEnabled(size_->input_width, 1); - setEnabled(size_->choice_width, 1); - setEnabled(size_->input_height, 1); - setEnabled(size_->choice_height, 1); - setEnabled(size_->check_aspectratio, 1); - setEnabled(size_->input_scale, 0); } else if (ob == size_->radio_scale) { setEnabled(size_->input_width, 0); setEnabled(size_->choice_width, 0); @@ -652,6 +771,13 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(size_->choice_height, 0); setEnabled(size_->check_aspectratio, 0); setEnabled(size_->input_scale, 1); + } else if (ob == size_->radio_wh) { + setEnabled(size_->input_width, 1); + setEnabled(size_->choice_width, 1); + setEnabled(size_->input_height, 1); + setEnabled(size_->choice_height, 1); + setEnabled(size_->check_aspectratio, 1); + setEnabled(size_->input_scale, 0); } else if (ob == size_->button_lyx_values) { LyXLength dummy = getLyXLengthFromWidgets(lyxview_->input_lyxwidth, lyxview_->choice_lyxwidth); @@ -673,14 +799,6 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(size_->choice_height, 0); setEnabled(size_->check_aspectratio, 0); setEnabled(size_->input_scale, 0); - } else if (fl_get_button (lyxview_->radio_lyxwh) == 1) { - fl_set_button (size_->radio_wh, 1); - setEnabled(size_->input_width, 1); - setEnabled(size_->choice_width, 1); - setEnabled(size_->input_height, 1); - setEnabled(size_->choice_height, 1); - setEnabled(size_->check_aspectratio, 1); - setEnabled(size_->input_scale, 0); } else if (fl_get_button (lyxview_->radio_lyxscale) ==1) { fl_set_button (size_->radio_scale, 1); setEnabled(size_->input_width, 0); @@ -689,6 +807,14 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(size_->choice_height, 0); setEnabled(size_->check_aspectratio, 0); setEnabled(size_->input_scale, 1); + } else if (fl_get_button (lyxview_->radio_lyxwh) == 1) { + fl_set_button (size_->radio_wh, 1); + setEnabled(size_->input_width, 1); + setEnabled(size_->choice_width, 1); + setEnabled(size_->input_height, 1); + setEnabled(size_->choice_height, 1); + setEnabled(size_->check_aspectratio, 1); + setEnabled(size_->input_scale, 0); } fl_set_button(size_->check_aspectratio, fl_get_button(lyxview_->check_lyxaspectratio)); diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index d8be60dbb6..70ad150205 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,7 @@ +2002-07-22 Herbert Voss + + * GraphicsConverter.C: get the "default converter" run again + 2002-07-21 Jean-Marc Lasgouttes * PreviewLoader.C: use BufferParams::getLyXTextClass diff --git a/src/graphics/GraphicsConverter.C b/src/graphics/GraphicsConverter.C index 149b94d3ca..4b689bdde1 100644 --- a/src/graphics/GraphicsConverter.C +++ b/src/graphics/GraphicsConverter.C @@ -137,38 +137,53 @@ Converter::Impl::Impl(string const & from_file, string const & to_file_base, bool const success = build_script(from_file, to_file_base, from_format, to_format, script); - if (!success) - return; + // The converted image is to be stored in this file + to_file_ = ChangeExtension(to_file_base, formats.extension(to_format)); - lyxerr[Debug::GRAPHICS] << "\tConversion script:" + if (!success) { + script_file_ = string(); + if (from_format == "lyxpreview") { + script_command_ = + LibFileSearch("scripts", "lyxpreview2xpm.sh") + + " " +from_file + " " + to_file_; + lyxerr[Debug::GRAPHICS] + << "\tI use lyxpreview2xpm for the conversion\n\t" + << script_command_ << endl; + } else { + script_command_ = + LibFileSearch("scripts", "convertDefault.sh") + + ' ' + from_format + ':' + from_file + ' ' + + to_format + ':' + to_file_; + lyxerr[Debug::GRAPHICS] + << "\tNo converter defined! I use convertDefault.sh\n\t" + << script_command_ << endl; + } + } else { + + lyxerr[Debug::GRAPHICS] << "\tConversion script:" << "\n--------------------------------------\n" << script.str().c_str() << "\n--------------------------------------\n"; - // Output the script to file. - static int counter = 0; - script_file_ = OnlyPath(to_file_base) + "lyxconvert" + - tostr(counter++) + ".sh"; + // Output the script to file. + static int counter = 0; + script_file_ = OnlyPath(to_file_base) + "lyxconvert" + + tostr(counter++) + ".sh"; - std::ofstream fs(script_file_.c_str()); - if (!fs.good()) - return; + std::ofstream fs(script_file_.c_str()); + if (!fs.good()) + return; - fs << script.str().c_str(); - fs.close(); - - // The converted image is to be stored in this file - // We do not use ChangeExtension here because this is a - // basename, which may nevertheless contain a dot - to_file_ = to_file_base + '.' + formats.extension(to_format); - - // The command needed to run the conversion process - // We create a dummy command for ease of understanding of the - // list of forked processes. - // Note that 'sh ' is absolutely essential, or execvp will fail. - script_command_ = "sh " + script_file_ + " " + - OnlyFilename(from_file) + " " + to_format; + fs << script.str().c_str(); + fs.close(); + // The command needed to run the conversion process + // We create a dummy command for ease of understanding of the + // list of forked processes. + // Note that 'sh ' is absolutely essential, or execvp will fail. + script_command_ = "sh " + script_file_ + " " + + OnlyFilename(from_file) + " " + to_format; + } // All is ready to go valid_process_ = true; } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 28f49362ae..c91e1dffd2 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2002-07-22 Herbert Voss + + * insetgraphics.C: + * insetgraphicsParams.[Ch]: change size_type to size_kind and + other small changes + 2002-07-21 Jean-Marc Lasgouttes * insettext.h: do not include "paragraph.h" and "lyxcursor.h" diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index a8d4a9f4c8..0d7d406164 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -446,8 +446,10 @@ void InsetGraphics::readInsetGraphics(LyXLex & lex) // FormatVersion < 1.0 (LyX < 1.2) void InsetGraphics::readFigInset(LyXLex & lex) { - std::vector const oldUnits = - getVectorFromString("pt,cm,in,p%,c%"); + std::vector const oldUnitsWidth = + getVectorFromString("pt, cm, in, text%, col%"); + std::vector const oldUnitsHeight = + getVectorFromString("pt, cm, in, theight%"); bool finished = false; // set the display default if (lyxrc.display_graphics == "mono") @@ -491,7 +493,7 @@ void InsetGraphics::readFigInset(LyXLex & lex) params_.lyxwidth = LyXLength(lex.getString()+"pt"); if (lex.next()) params_.lyxheight = LyXLength(lex.getString()+"pt"); - params_.lyxsize_type = InsetGraphicsParams::WH; + params_.lyxsize_kind = InsetGraphicsParams::WH; } else if (token == "flags") { if (lex.next()) switch (lex.getInteger()) { @@ -501,6 +503,8 @@ void InsetGraphics::readFigInset(LyXLex & lex) break; case 3: params_.display = InsetGraphicsParams::COLOR; break; + case 8: params_.display = InsetGraphicsParams::NONE; + break; } } else if (token == "subfigure") { params_.subcaption = true; @@ -510,10 +514,15 @@ void InsetGraphics::readFigInset(LyXLex & lex) if (lex.next()) { if (i == 5) { params_.scale = lex.getInteger(); - params_.size_type = InsetGraphicsParams::SCALE; + params_.size_kind = InsetGraphicsParams::SCALE; } else { - params_.width = LyXLength(lex.getString()+oldUnits[i]); - params_.size_type = InsetGraphicsParams::WH; + string const value = lex.getString(); + lyxerr[Debug::GRAPHICS] << "readFiginset::oldWidth: " + << value << oldUnitsWidth[i] << endl; + params_.width = LyXLength(value + oldUnitsWidth[i]); + lyxerr[Debug::GRAPHICS] << "readFiginset::newWidth: " + << params_.width.asString() << endl; + params_.size_kind = InsetGraphicsParams::WH; } } } @@ -521,8 +530,13 @@ void InsetGraphics::readFigInset(LyXLex & lex) if (lex.next()) { int i = lex.getInteger(); if (lex.next()) { - params_.height = LyXLength(lex.getString()+oldUnits[i]); - params_.size_type = InsetGraphicsParams::WH; + string const value = lex.getString(); + lyxerr[Debug::GRAPHICS] << "readFiginset::oldHeight: " + << value << oldUnitsHeight[i] << endl; + params_.height = LyXLength(value + oldUnitsHeight[i]); + lyxerr[Debug::GRAPHICS] << "readFiginset::newHeight: " + << params_.height.asString() << endl; + params_.size_kind = InsetGraphicsParams::WH; } } } @@ -541,12 +555,12 @@ string const InsetGraphics::createLatexOptions() const options << " draft,\n"; if (params().clip) options << " clip,\n"; - if (params().size_type == InsetGraphicsParams::WH) { + if (params().size_kind == InsetGraphicsParams::WH) { if (!params().width.zero()) options << " width=" << params().width.asLatexString() << ",\n"; if (!params().height.zero()) options << " height=" << params().height.asLatexString() << ",\n"; - } else if (params().size_type == InsetGraphicsParams::SCALE) { + } else if (params().size_kind == InsetGraphicsParams::SCALE) { if (params().scale > 0) options << " scale=" << double(params().scale)/100.0 << ",\n"; } @@ -581,7 +595,7 @@ string findTargetFormat(string const & suffix) // (Should actually mean, are we using latex or pdflatex). if (lyxrc.pdf_mode) { lyxerr[Debug::GRAPHICS] << "findTargetFormat: PDF mode\n"; - if (contains(suffix,"ps") || suffix == "pdf") + if (contains(suffix, "ps") || suffix == "pdf") return "pdf"; else if (suffix == "jpg") // pdflatex can use jpeg return suffix; @@ -729,11 +743,11 @@ string const InsetGraphics::prepareFile(Buffer const *buf) const // from ImageMagic: convert from:inname.from to:outname.to if (!converters.convert(buf, temp_file, outfile_base, from, to)) { string const command = - "convert " + - from + ':' + temp_file + ' ' + - to + ':' + outfile_base + '.' + to; + LibFileSearch("scripts", "convertDefault.sh") + + ' ' + from + ':' + temp_file + ' ' + + to + ':' + outfile_base + '.' + to; lyxerr[Debug::GRAPHICS] - << "No converter defined! I use convert from ImageMagic:\n\t" + << "No converter defined! I use convertDefault.sh:\n\t" << command << endl; Systemcall one; one.startscript(Systemcall::Wait, command); diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index 3f699fd393..71b5550fb3 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -19,7 +19,6 @@ #include "insetgraphicsParams.h" #include "graphics/GraphicsParams.h" -#include "graphics/GraphicsCache.h" #include "support/translator.h" #include "support/filetools.h" @@ -97,12 +96,12 @@ void InsetGraphicsParams::init() lyxheight = LyXLength(); // also set to 0pt scale = 0; // unit is % lyxscale = 0; // same for lyxview - size_type = DEFAULT_SIZE; // do nothing - lyxsize_type = DEFAULT_SIZE; // do nothing - keepLyXAspectRatio = false; // only for LyXview - keepAspectRatio = false; // only for latex + size_kind = DEFAULT_SIZE; // do nothing + lyxsize_kind = DEFAULT_SIZE; // do nothing + keepAspectRatio = false; // for latex + keepLyXAspectRatio = false; // for lyx rotate = false; // Rotating - rotateOrigin = "center"; // Origin + rotateOrigin = "leftBaseline"; // Origin rotateAngle = 0.0; // in degrees special = string(); // userdefined stuff } @@ -121,12 +120,13 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp) width = igp.width; height = igp.height; scale = igp.scale; - size_type = igp.size_type; - lyxsize_type = igp.lyxsize_type; + size_kind = igp.size_kind; + lyxsize_kind = igp.lyxsize_kind; lyxwidth = igp.lyxwidth; lyxheight = igp.lyxheight; keepLyXAspectRatio = igp.keepLyXAspectRatio; lyxscale = igp.lyxscale; + keepLyXAspectRatio = igp.keepLyXAspectRatio; rotate = igp.rotate; rotateOrigin = igp.rotateOrigin; rotateAngle = igp.rotateAngle; @@ -148,12 +148,13 @@ bool operator==(InsetGraphicsParams const & left, left.width == right.width && left.height == right.height && left.scale == right.scale && - left.size_type == right.size_type && - left.lyxsize_type == right.lyxsize_type && + left.size_kind == right.size_kind && + left.lyxsize_kind == right.lyxsize_kind && left.lyxwidth == right.lyxwidth && left.lyxheight == right.lyxheight && left.keepLyXAspectRatio == right.keepLyXAspectRatio && left.lyxscale == right.lyxscale && + left.keepLyXAspectRatio == right.keepLyXAspectRatio && left.rotate == right.rotate && left.rotateOrigin == right.rotateOrigin && lyx::float_equal(left.rotateAngle, right.rotateAngle, 0.001 && @@ -171,6 +172,34 @@ bool operator!=(InsetGraphicsParams const & left, } +namespace { + +InsetGraphicsParams::sizeKind getSizeKind(string const & str_in) +{ + if (str_in == "width_height") + return InsetGraphicsParams::WH; + if (str_in == "scale") + return InsetGraphicsParams::SCALE; + + // all other like "original" + return InsetGraphicsParams::DEFAULT_SIZE; +} + + +string const getSizeKindStr(InsetGraphicsParams::sizeKind sK_in) +{ + if (sK_in == InsetGraphicsParams::SCALE) + return "scale"; + if (sK_in == InsetGraphicsParams::WH) + return "width_height"; + + // all other like DEFAULT_SIZE" + return "original"; +} + +} //anon + + void InsetGraphicsParams::Write(ostream & os) const { // If there is no filename, write nothing for it. @@ -192,11 +221,7 @@ void InsetGraphicsParams::Write(ostream & os) const os << "\tsubcaptionText \"" << subcaptionText << '\"' << '\n'; if (noUnzip) os << "\tnoUnzip\n"; - // we always need the size type - // 0: no special - // 1: width/height combination - // 2: scale - os << "\tsize_type " << size_type << '\n'; + os << "\tsize_kind " << getSizeKindStr(size_kind) << '\n'; if (!width.zero()) os << "\twidth " << width.asString() << '\n'; if (!height.zero()) @@ -214,7 +239,7 @@ void InsetGraphicsParams::Write(ostream & os) const if (!special.empty()) os << "\tspecial " << special << '\n'; // the values for the view in lyx - os << "\tlyxsize_type " << lyxsize_type << '\n'; + os << "\tlyxsize_kind " << getSizeKindStr(lyxsize_kind) << '\n'; if (!lyxwidth.zero()) // the lyx-viewsize os << "\tlyxwidth " << lyxwidth.asString() << '\n'; if (!lyxheight.zero()) @@ -251,19 +276,9 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token) subcaptionText = lex.getString(); } else if (token == "noUnzip") { noUnzip = true; - } else if (token == "size_type") { + } else if (token == "size_kind") { lex.next(); - switch (lex.getInteger()) { - case 0: - size_type = DEFAULT_SIZE; - break; - case 1: - size_type = WH; - break; - case 2: - size_type = SCALE; - break; - } + size_kind = getSizeKind(lex.getString()); } else if (token == "width") { lex.next(); width = LyXLength(lex.getString()); @@ -283,19 +298,9 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token) } else if (token == "rotateOrigin") { lex.next(); rotateOrigin=lex.getString(); - } else if (token == "lyxsize_type") { + } else if (token == "lyxsize_kind") { lex.next(); - switch (lex.getInteger()) { - case 0: - lyxsize_type = DEFAULT_SIZE; - break; - case 1: - lyxsize_type = WH; - break; - case 2: - lyxsize_type = SCALE; - break; - } + lyxsize_kind = getSizeKind(lex.getString()); } else if (token == "lyxwidth") { lex.next(); lyxwidth = LyXLength(lex.getString()); @@ -399,15 +404,15 @@ grfx::Params InsetGraphicsParams::as_grfxParams(string const & filepath) const if (!lyxrc.use_gui) { pars.display = grfx::NoDisplay; } - - if (lyxsize_type == InsetGraphicsParams::SCALE) { + + if (lyxsize_kind == InsetGraphicsParams::SCALE) { pars.scale = lyxscale; - - } else if (lyxsize_type == InsetGraphicsParams::WH) { + + } else if (lyxsize_kind == InsetGraphicsParams::WH) { pars.width = lyxwidth.inBP(); pars.height = lyxheight.inBP(); pars.keepLyXAspectRatio = keepLyXAspectRatio; - } + } return pars; } diff --git a/src/insets/insetgraphicsParams.h b/src/insets/insetgraphicsParams.h index aadc417d9f..63f25aedf3 100644 --- a/src/insets/insetgraphicsParams.h +++ b/src/insets/insetgraphicsParams.h @@ -38,10 +38,10 @@ struct InsetGraphicsParams NONE // only keep a frame in place. }; /// - enum sizeType { // for latex and/or lyx + enum sizeKind { // for latex and/or lyx DEFAULT_SIZE, // like none - WH, // width/height values - SCALE // percentage value + SCALE, // percentage value + WH // width/height values }; /// Image filename. string filename; @@ -64,7 +64,7 @@ struct InsetGraphicsParams /// The bounding box with "xLB yLB yRT yRT ", divided by a space! string bb; /// Type of rescaling - sizeType size_type; + sizeKind size_kind; /// three possible values for rescaling (latex) LyXLength width; /// @@ -77,10 +77,10 @@ struct InsetGraphicsParams string special; /// How to display the image inside lyx DisplayType display; - /// Typ of the LyXView, same as for latex - sizeType lyxsize_type; /// the size for the view inside lyx LyXLength lyxwidth; + /// Typ of the LyXView, same as for latex + sizeKind lyxsize_kind; /// LyXLength lyxheight; /// Keep the ratio between lyxheight and lyxwidth when resizing. diff --git a/src/lengthcommon.C b/src/lengthcommon.C index 3324a53bf3..cc35cef07c 100644 --- a/src/lengthcommon.C +++ b/src/lengthcommon.C @@ -8,7 +8,8 @@ int const num_units = LyXLength::UNIT_NONE; char const * unit_name[num_units] = { "sp", "pt", "bp", "dd", "mm", "pc", "cc", "cm", "in", "ex", "em", "mu", - "text%", "col%", "page%", "line%" }; + "text%", "col%", "page%", "line%", + "theight%", "pheight%" }; LyXLength::UNIT unitFromString(string const & data) diff --git a/src/lyxlength.C b/src/lyxlength.C index c21bd86766..fea213df89 100644 --- a/src/lyxlength.C +++ b/src/lyxlength.C @@ -47,7 +47,8 @@ string const convertOldRelLength(string const & oldLength) return subst(oldLength,"c%","col%"); } else if (oldLength.find("t%") != string::npos) { - if (oldLength.find("text%") != string::npos) + if (oldLength.find("text%") != string::npos || + oldLength.find("height%") != string::npos) return oldLength; else return subst(oldLength,"t%","text%"); @@ -113,6 +114,14 @@ string const LyXLength::asLatexString() const buffer << abs(static_cast(val_/100)) << "." << abs(static_cast(val_)%100) << "\\linewidth"; break; + case PH: + buffer << abs(static_cast(val_/100)) << "." + << abs(static_cast(val_)%100) << "\\paperheight"; + break; + case TH: + buffer << abs(static_cast(val_/100)) << "." + << abs(static_cast(val_)%100) << "\\textheight"; + break; default: buffer << val_ << unit_name[unit_]; // setw? break; @@ -235,6 +244,10 @@ int LyXLength::inPixels(int default_width, int default_height) const case LyXLength::PL: result = val_ * default_width / 100; break; + case LyXLength::PH: + case LyXLength::TH: + result = val_ * default_height / 100; + break; case LyXLength::UNIT_NONE: result = 0; // this cannot happen break; diff --git a/src/lyxlength.h b/src/lyxlength.h index 86fc886769..1d84408fbc 100644 --- a/src/lyxlength.h +++ b/src/lyxlength.h @@ -36,10 +36,12 @@ public: EX, ///< Height of a small "x" for the current font. EM, ///< Width of capital "M" in current font. MU, ///< Math unit (18mu = 1em) for positioning in math mode - PW, ///< Percent of columnwidth both "%" or "%c" - PE, ///< FIXME + PW, ///< Percent of columnwidth + PE, ///< Percent of textwidth PP, ///< Percent of pagewidth PL, ///< Percent of linewidth + TH, ///< Percent of textheight // Herbert 2002-05-16 + PH, ///< Percent of paperheight // Herbert 2002-05-16 UNIT_NONE ///< no unit };