2000-02-29 02:19:17 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
/**
|
|
|
|
* \file insetgraphics.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2000-02-29 02:19:17 +00:00
|
|
|
*
|
2002-01-29 09:26:24 +00:00
|
|
|
* \author Baruch Even
|
2002-09-25 14:26:13 +00:00
|
|
|
* \author Herbert Voss
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
*/
|
2000-02-29 02:19:17 +00:00
|
|
|
|
|
|
|
#ifndef INSET_GRAPHICS_H
|
|
|
|
#define INSET_GRAPHICS_H
|
|
|
|
|
2000-08-08 09:18:39 +00:00
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "insets/inset.h"
|
2000-07-31 12:30:10 +00:00
|
|
|
#include "insets/insetgraphicsParams.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
|
|
|
#include <boost/signals/trackable.hpp>
|
2002-06-26 16:57:59 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2002-06-25 15:59:10 +00:00
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
class Dialogs;
|
2002-02-27 09:59:52 +00:00
|
|
|
class LaTeXFeatures;
|
2000-03-09 23:58:55 +00:00
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2002-05-29 16:21:03 +00:00
|
|
|
class InsetGraphics : public Inset, public boost::signals::trackable {
|
2000-02-29 02:19:17 +00:00
|
|
|
public:
|
2000-03-09 23:58:55 +00:00
|
|
|
///
|
|
|
|
InsetGraphics();
|
2000-08-14 09:44:53 +00:00
|
|
|
///
|
2002-03-22 16:37:52 +00:00
|
|
|
InsetGraphics(InsetGraphics const &, string const & filepath,
|
|
|
|
bool same_id = false);
|
2001-07-14 20:11:35 +00:00
|
|
|
///
|
2000-08-14 09:44:53 +00:00
|
|
|
~InsetGraphics();
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2003-03-07 18:44:57 +00:00
|
|
|
virtual dispatch_result localDispatch(FuncRequest const & cmd);
|
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
int ascent(BufferView *, LyXFont const &) const;
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
int descent(BufferView *, LyXFont const &) const;
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
int width(BufferView *, LyXFont const &) const;
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2003-03-17 01:34:36 +00:00
|
|
|
void draw(BufferView *, LyXFont const &, int, float &) const;
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
void edit(BufferView *, int, int, mouse_button::state);
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2001-07-20 14:18:48 +00:00
|
|
|
void edit(BufferView * bv, bool front = true);
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
EDITABLE editable() const;
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void write(Buffer const *, std::ostream &) const;
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void read(Buffer const *, LyXLex & lex);
|
2000-07-31 12:30:10 +00:00
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
/** returns the number of rows (\n's) of generated tex code.
|
2000-09-14 17:53:12 +00:00
|
|
|
#fragile == true# means, that the inset should take care about
|
|
|
|
fragile commands by adding a #\protect# before.
|
2000-02-29 02:19:17 +00:00
|
|
|
*/
|
2001-06-28 10:25:20 +00:00
|
|
|
int latex(Buffer const *, std::ostream &,
|
2002-03-21 17:09:55 +00:00
|
|
|
bool fragile, bool free_spc) const;
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
int ascii(Buffer const *, std::ostream &, int linelen) const;
|
2000-04-24 20:58:23 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
int linuxdoc(Buffer const *, std::ostream &) const;
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
int docbook(Buffer const *, std::ostream &, bool mixcont) const;
|
2000-03-09 23:58:55 +00:00
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
/** Tell LyX what the latex features you need i.e. what latex packages
|
2000-09-14 17:53:12 +00:00
|
|
|
you need to be included.
|
|
|
|
*/
|
2001-06-28 10:25:20 +00:00
|
|
|
void validate(LaTeXFeatures & features) const;
|
2000-02-29 02:19:17 +00:00
|
|
|
|
|
|
|
/// returns LyX code associated with the inset. Used for TOC, ...)
|
2001-06-28 10:25:20 +00:00
|
|
|
Inset::Code lyxCode() const { return Inset::GRAPHICS_CODE; }
|
2000-08-14 09:44:53 +00:00
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2001-07-06 15:57:54 +00:00
|
|
|
virtual Inset * clone(Buffer const &, bool same_id = false) const;
|
2000-07-31 12:30:10 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
/** Set the inset parameters, used by the GUIndependent dialog.
|
|
|
|
Return true of new params are different from what was so far.
|
|
|
|
*/
|
2002-03-22 16:37:52 +00:00
|
|
|
bool setParams(InsetGraphicsParams const & params,
|
|
|
|
string const & filepath);
|
2000-07-31 12:30:10 +00:00
|
|
|
|
2000-08-14 09:44:53 +00:00
|
|
|
/// Get the inset parameters, used by the GUIndependent dialog.
|
2002-02-27 09:59:52 +00:00
|
|
|
InsetGraphicsParams const & params() const;
|
2000-07-31 12:30:10 +00:00
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
private:
|
2003-03-07 18:44:57 +00:00
|
|
|
/// Returns the cached BufferView.
|
|
|
|
BufferView * view() const;
|
|
|
|
|
|
|
|
///
|
|
|
|
friend class InsetGraphicsMailer;
|
|
|
|
|
2002-02-27 09:59:52 +00:00
|
|
|
/// Is the image ready to draw, or should we display a message instead?
|
2002-06-25 15:59:10 +00:00
|
|
|
bool imageIsDrawable() const;
|
|
|
|
|
|
|
|
/** This method is connected to cache_->statusChanged, so we are
|
|
|
|
informed when the image has been loaded.
|
|
|
|
*/
|
|
|
|
void statusChanged();
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2001-07-28 12:24:16 +00:00
|
|
|
/// Read the inset native format
|
2002-03-22 16:37:52 +00:00
|
|
|
void readInsetGraphics(LyXLex & lex);
|
2002-03-21 17:09:55 +00:00
|
|
|
|
2000-10-12 10:46:06 +00:00
|
|
|
/// Get the status message, depends on the image loading status.
|
2001-05-31 02:23:46 +00:00
|
|
|
string const statusMessage() const;
|
2001-02-08 13:06:55 +00:00
|
|
|
/// Create the options for the latex command.
|
|
|
|
string const createLatexOptions() const;
|
|
|
|
/// Convert the file if needed, and return the location of the file.
|
|
|
|
string const prepareFile(Buffer const * buf) const;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
InsetGraphicsParams params_;
|
|
|
|
|
2002-02-20 09:04:56 +00:00
|
|
|
/// holds the entity name that defines the graphics location (SGML).
|
|
|
|
string const graphic_label;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
/// The cached variables
|
2002-06-25 15:59:10 +00:00
|
|
|
class Cache;
|
|
|
|
friend class Cache;
|
2002-06-26 16:57:59 +00:00
|
|
|
/// The pointer never changes although *cache_'s contents may.
|
|
|
|
boost::scoped_ptr<Cache> const cache_;
|
2000-02-29 02:19:17 +00:00
|
|
|
};
|
|
|
|
|
2003-03-07 18:44:57 +00:00
|
|
|
|
|
|
|
#include "mailinset.h"
|
|
|
|
|
|
|
|
class InsetGraphicsMailer : public MailInset {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
InsetGraphicsMailer(InsetGraphics & inset);
|
|
|
|
///
|
2003-03-10 13:33:39 +00:00
|
|
|
virtual InsetBase & inset() const { return inset_; }
|
2003-03-07 18:44:57 +00:00
|
|
|
///
|
|
|
|
virtual string const & name() const { return name_; }
|
|
|
|
///
|
|
|
|
virtual string const inset2string() const;
|
|
|
|
///
|
|
|
|
static void string2params(string const &, InsetGraphicsParams &);
|
|
|
|
///
|
|
|
|
static string const params2string(InsetGraphicsParams const &);
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
static string const name_;
|
|
|
|
///
|
|
|
|
InsetGraphics & inset_;
|
|
|
|
};
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
#endif
|