2000-02-29 02:19:17 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 the LyX Team.
|
2000-02-29 02:19:17 +00:00
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#ifndef INSET_GRAPHICS_H
|
|
|
|
#define INSET_GRAPHICS_H
|
|
|
|
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
2000-08-14 09:44:53 +00:00
|
|
|
#endif
|
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"
|
2000-08-10 13:15:05 +00:00
|
|
|
#include "graphics/GraphicsCacheItem.h"
|
2001-02-22 16:53:59 +00:00
|
|
|
#include <boost/smart_ptr.hpp>
|
2000-07-31 12:30:10 +00:00
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
// We need a signal here to hide an active dialog when we are deleted.
|
|
|
|
#include "sigc++/signal_system.h"
|
|
|
|
|
|
|
|
class Dialogs;
|
2000-10-12 10:46:06 +00:00
|
|
|
class LyXImage;
|
2000-03-09 23:58:55 +00:00
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2001-03-15 18:21:56 +00:00
|
|
|
class InsetGraphics : public Inset, public SigC::Object {
|
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
|
|
|
///
|
2001-07-14 20:11:35 +00:00
|
|
|
InsetGraphics(InsetGraphics const &, bool same_id = false);
|
|
|
|
///
|
2000-08-14 09:44:53 +00:00
|
|
|
~InsetGraphics();
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
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
|
|
|
///
|
2000-07-31 12:30:10 +00:00
|
|
|
bool display() const { return true; }
|
|
|
|
///
|
2000-06-23 15:02:46 +00:00
|
|
|
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void edit(BufferView *, int, int, unsigned int);
|
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 &,
|
2000-08-14 09:44:53 +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
|
|
|
///
|
2001-09-04 11:02:09 +00:00
|
|
|
int docbook(Buffer const *, std::ostream &) 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.
|
|
|
|
*/
|
2000-08-14 09:44:53 +00:00
|
|
|
bool setParams(InsetGraphicsParams const & params);
|
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.
|
|
|
|
InsetGraphicsParams getParams() const;
|
2000-07-31 12:30:10 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
/** This signal is connected by our dialog and called when the inset
|
|
|
|
is deleted.
|
|
|
|
*/
|
2001-03-15 18:21:56 +00:00
|
|
|
SigC::Signal0<void> hideDialog;
|
2001-02-19 16:01:31 +00:00
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
private:
|
2001-07-28 12:24:16 +00:00
|
|
|
/// Read the inset native format
|
|
|
|
void readInsetGraphics(Buffer const * buf, LyXLex & lex);
|
|
|
|
/// Read the FigInset file format
|
|
|
|
void readFigInset(Buffer const * buf, LyXLex & lex);
|
|
|
|
|
2000-08-14 09:44:53 +00:00
|
|
|
/// Update the inset after parameter change.
|
2000-10-12 10:46:06 +00:00
|
|
|
void updateInset() const;
|
|
|
|
/// 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;
|
2000-08-14 09:44:53 +00:00
|
|
|
/// The graphics cache handle.
|
2001-02-22 16:53:59 +00:00
|
|
|
mutable boost::shared_ptr<GraphicsCacheItem> cacheHandle;
|
2000-08-14 09:44:53 +00:00
|
|
|
/// is the pixmap initialized?
|
2001-02-20 09:08:56 +00:00
|
|
|
mutable bool imageLoaded;
|
2001-06-28 10:25:20 +00:00
|
|
|
///
|
2000-08-14 09:44:53 +00:00
|
|
|
InsetGraphicsParams params;
|
2000-02-29 02:19:17 +00:00
|
|
|
};
|
|
|
|
|
2000-08-14 09:44:53 +00:00
|
|
|
#endif
|