+2001-07-30 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * ControlFloat.h: add a != operator for FloatParams.
+ Lars, how did you get this to compile!!!
+
+ * ControlMinipage.[Ch]: uncommented someone's commenting out of
+ operator != for MinipageParams. Who's changing stuff and not compiling?
+
2001-07-30 Lars Gullik Bjønnes <larsbj@birdstep.com>
* Makefile.am (libcontrollers_la_SOURCES): add ControlFloat.h and
}
+inline
+bool operator!=(FloatParams const & p1, FloatParams const & p2)
+{
+ return !(p1 == p2);
+}
+
+
/** A controller for Minipage dialogs.
*/
class ControlFloat : public ControlInset<InsetFloat, FloatParams> {
}
-//bool operator!=(MinipageParams const & p1, MinipageParams const & p2)
-//{
-// return !(p1 == p2);
-//}
+bool operator!=(MinipageParams const & p1, MinipageParams const & p2)
+{
+ return !(p1 == p2);
+}
namespace minipage {
///
bool operator==(MinipageParams const &, MinipageParams const &);
///
-//bool operator!=(MinipageParams const &, MinipageParams const &);
+bool operator!=(MinipageParams const &, MinipageParams const &);
/** A controller for Minipage dialogs.
+2001-07-29 John Levon <moz@compsoc.man.ac.uk>
+
+ * FormMathsBitmap.C: initialise form_
+
+2001-07-29 Baruch Even <baruch@lyx.org>
+
+ * src/forms/form_graphics.fd:
+ * src/FormGraphics.C: Added support for the new horizontal scale factor.
+
2001-07-30 Lars Gullik Bjønnes <larsbj@birdstep.com>
* forms/makefile (SRCS): add form_float.fd
2001-07-26 John Levon <moz@compsoc.man.ac.uk>
* Dialogs.C:
- * Makefile.am:
+ * Makefile.am:
* FormThesaurus.h:
* FormThesaurus.C:
* form_thesaurus.h:
* form_thesaurus.C:
* forms/makefile:
* forms/form_thesaurus.fd: add thesaurus
-
+
2001-07-26 Baruch Even <baruch@lyx.org>
* FormGraphics.h:
InsetGraphicsParams::INCH);
heightButtons.registerRadioButton(dialog_->radio_height_percent_page,
InsetGraphicsParams::PERCENT_PAGE);
+ heightButtons.registerRadioButton(dialog_->radio_height_scale,
+ InsetGraphicsParams::SCALE);
// Add the widgets of the display radio buttons to their group
displayButtons.reset();
FormMathsPanel const & p,
vector<string> const & l)
: FormMathsSub(lv, d, p, _("Maths Bitmaps")),
- latex_(l), ww_(0), x_(0), y_(0), w_(0), h_(0)
+ latex_(l), form_(0), ww_(0), x_(0), y_(0), w_(0), h_(0)
{
ww_ = 2 * FL_abs(FL_BOUND_WIDTH);
x_ = y_ = ww_;
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
+ fdui->radio_height_scale = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 140, 160, 96, 30, _("Scale"));
+ fl_set_object_callback(obj, C_FormBaseInputCB, CHECKINPUT);
fl_end_form();
fdui->form->fdui = fdui;
FL_OBJECT *button_ok;
FL_OBJECT *button_apply;
FL_OBJECT *button_cancel;
+ FL_OBJECT *radio_height_scale;
};
#endif /* FD_form_graphics_h_ */
Name: form_graphics
Width: 490
Height: 390
-Number of Objects: 36
+Number of Objects: 37
--------------------
class: FL_BOX
callback: C_FormBaseCancelCB
argument: 0
+--------------------
+class: FL_CHECKBUTTON
+type: RADIO_BUTTON
+box: 140 160 96 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Scale
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: radio_height_scale
+callback: C_FormBaseInputCB
+argument: CHECKINPUT
+
==============================
create_the_forms
* insetfoot.h: remove InsetFoot:: qualifier.
-2001-07-30 Baruch Even <baruch@lyx.org>
+2001-07-29 Baruch Even <baruch@lyx.org>
+
+ * ChangeLog: Hiding time travel evidence.
+
+ * insetgraphicsParams.h:
+ * insetgraphicsParams.C:
+ * insetgraphics.C: Added horizontal scale option, it actually scales both
+ directions since it keeps image proportions.
+
+ * insetgraphics.C: Fixed EPS detection to be non-hacky.
+
+2001-07-29 Baruch Even <baruch@lyx.org>
* insetgraphics.C (decideOutputImageFormat): when doing postscript output
convert PNG/GIF/JPG to EPS, assume the rest are EPS already.
HACKY! Will need to add an EPS detection routine like old InsetFig does!
-2001-07-30 Baruch Even <baruch@lyx.org>
+2001-07-29 Baruch Even <baruch@lyx.org>
* insetgraphics.C: Added EPSI to be an alias of EPS.
* We do not dither or resize the image in a WYSIWYM way, we load it at
its original size and color, resizing is done in the final output,
but not in the LyX window.
+
+ * The scale option is only handled for the horizontal part, the vertical
+ part will not work. For now it is also shown only for horizontal
+ resizing on the form.
+
+ * EPS figures are not fully detected, they may have a lot of possible
+ suffixes so we need to read the file and detect if it's EPS or not.
+ [Implemented, need testing]
TODO Before initial production release:
* Replace insetfig everywhere
#include "lyxtext.h"
#include "lyxrc.h"
#include "font.h" // For the lyxfont class.
+#include "fstream" // for ifstream in isEPS
#include <algorithm> // For the std::max
#include "support/lyxmanip.h"
#include "debug.h"
extern string system_tempdir;
+using std::ifstream;
using std::ostream;
using std::endl;
os << key << '=' << size / 100 << "\\column" << key << ',';
break;
+ case InsetGraphicsParams::SCALE:
+ os << "scale" << '=' << size << ',';
}
}
}
namespace {
-
-string decideOutputImageFormat(string const & in_fmt)
+
+enum FileType {
+ EPS,
+ PNG,
+ JPEG,
+ GIF,
+ PDF,
+ UNKNOWN
+};
+
+bool isEPS(string const & filename)
+{
+ if (filename.empty() || !IsFileReadable(filename)) return false;
+
+ ifstream ifs(filename.c_str());
+
+ if (!ifs) return false; // Couldn't open file...
+
+ bool is_eps = false; // Have we recognized the file as EPS?
+ string to_find = "%!PS-Adobe-"; // The string we use to recognize
+ int const max_attempts = 500; // Maximum strings to read to attempt recognition
+ int count = 0; // Counter of attempts.
+ string str;
+ for (; count < max_attempts; ++count) {
+ if (ifs.eof()) {
+ lyxerr[Debug::INFO] << "InsetGraphics (isEPS)"
+ " End of file reached and it wasn't found to be EPS!" << endl;
+ break;
+ }
+
+ ifs >> str;
+ if (str.find(to_find)) {
+ is_eps = true;
+ break;
+ }
+ }
+
+ return is_eps;
+}
+
+enum FileType classifyFileType(string const & filename, string const & suffix)
+{
+ if (suffix == "png")
+ return PNG;
+ else if (suffix == "jpg" || suffix == "jpeg")
+ return JPEG;
+ else if (suffix == "gif")
+ return GIF;
+ else if (suffix == "pdf")
+ return PDF;
+ else if (isEPS(filename))
+ return EPS;
+
+ return UNKNOWN;
+}
+
+string decideOutputImageFormat(string const & suffix, enum FileType type)
{
// lyxrc.pdf_mode means:
// Are we creating a PDF or a PS file?
// (Should actually mean, are we using latex or pdflatex).
if (lyxrc.pdf_mode) {
- if (in_fmt == "eps" || in_fmt == "epsi" || in_fmt == "pdf")
+ if (type == EPS || type == EPS || type == PDF)
return "pdf";
- else if (in_fmt == "jpg" || in_fmt == "jpeg")
- return in_fmt;
+ else if (type == JPEG)
+ return suffix;
else
return "png";
}
// If it's postscript, we always do eps.
- // Garst has many eps files with various extensions, we just assume
- // whatever goes in (except those we know to be otherwise) is eps
- if (in_fmt == "gif" || in_fmt == "png" || in_fmt == "jpg")
- return "eps";
- return in_fmt;
+ // There are many suffixes that are actually EPS (ask Garst for example)
+ // so we detect if it's an EPS by looking in the file, if it is, we return
+ // the same suffix of the file so it won't be converted.
+ if (type == EPS)
+ return suffix;
+
+ return "eps";
}
} // Anon. namespace
// Get the extension (format) of the original file.
string const extension = GetExtension(params.filename);
+ FileType type = classifyFileType(params.filename, extension);
// Are we creating a PDF or a PS file?
// (Should actually mean, are we usind latex or pdflatex).
- string const image_target = decideOutputImageFormat(extension);
+ string const image_target = decideOutputImageFormat(extension, type);
if (extension == image_target)
return params.filename;
resizeTranslator.addPair(INCH, "inch");
resizeTranslator.addPair(PERCENT_PAGE, "percentOfPage");
resizeTranslator.addPair(PERCENT_COLUMN, "percentOfColumn");
+ resizeTranslator.addPair(SCALE, "scale");
// Fill the origin translator
originTranslator.addPair(DEFAULT, "default");
widthResize == CM ||
widthResize == INCH ||
widthResize == PERCENT_PAGE ||
- widthResize == PERCENT_COLUMN
+ widthResize == PERCENT_COLUMN ||
+ widthResize == SCALE
);
lyx::Assert(heightResize == DEFAULT_SIZE ||
heightResize == CM ||
heightResize == INCH ||
- heightResize == PERCENT_PAGE
+ heightResize == PERCENT_PAGE ||
+ heightResize == SCALE
);
- lyx::Assert(widthSize >= 0.0);
- lyx::Assert(heightSize >= 0.0);
+ // For SCALE these can be negative.
+ //lyx::Assert(widthSize >= 0.0);
+ //lyx::Assert(heightSize >= 0.0);
// Angle is in degrees and ranges -360 < angle < 360
// The reason for this is that in latex there is a meaning for the
CM,
INCH,
PERCENT_PAGE,
- PERCENT_COLUMN
+ PERCENT_COLUMN,
+ SCALE
};
#include "support/filetools.h"
#include "BufferView.h"
#include "LyXView.h"
+#include "support/LOstream.h"
#include "commandtags.h"
#include "buffer.h"
#include "gettext.h"