1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/*
|
|
|
|
figinset.h - Figure inset header - part of LyX project
|
2000-03-09 03:36:48 +00:00
|
|
|
Copyright 1996 by Ivan Schreter
|
1999-09-27 18:44:28 +00:00
|
|
|
*/
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
#ifndef FIGINSET_H
|
|
|
|
#define FIGINSET_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-28 14:51:25 +00:00
|
|
|
#include "figure_form.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "LString.h"
|
1999-12-13 07:33:00 +00:00
|
|
|
#include "buffer.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "insets/inset.h"
|
2000-11-28 06:46:06 +00:00
|
|
|
#include <sigc++/signal_system.h>
|
1999-09-27 18:44:28 +00:00
|
|
|
/* the rest is figure stuff */
|
|
|
|
|
|
|
|
struct Figref;
|
|
|
|
|
|
|
|
///
|
2001-03-15 18:21:56 +00:00
|
|
|
class InsetFig: public Inset, public SigC::Object {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
|
|
|
///
|
2000-10-10 11:50:43 +00:00
|
|
|
InsetFig(int tmpx, int tmpy, Buffer const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
~InsetFig();
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
int ascent(BufferView *, LyXFont const & font) const;
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
int descent(BufferView *, LyXFont const & font) const;
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
int width(BufferView *, LyXFont const & font) const;
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2000-06-23 15:02:46 +00:00
|
|
|
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void write(Buffer const *, std::ostream &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void read(Buffer const *, LyXLex & lex);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
int latex(Buffer const *, std::ostream &, bool fragile, bool free_space) 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-06-28 10:25:20 +00:00
|
|
|
int docBook(Buffer const *, std::ostream &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Updates needed features for this inset.
|
2001-06-28 10:25:20 +00:00
|
|
|
void validate(LaTeXFeatures & features) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// what appears in the minibuffer when opening
|
2001-06-28 10:25:20 +00:00
|
|
|
string const editMessage() const;
|
2000-04-04 00:19:15 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void edit(BufferView *, int, int, unsigned int);
|
1999-09-27 18:44:28 +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;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
bool deletable() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
Inset::Code lyxCode() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-07-06 15:57:54 +00:00
|
|
|
Inset * clone(Buffer const &, bool same_id = false) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void callbackFig(long arg);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void preview(string const & p);
|
1999-09-27 18:44:28 +00:00
|
|
|
/// browse for file
|
2001-06-28 10:25:20 +00:00
|
|
|
void browseFile();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// form for user input
|
1999-11-24 22:14:46 +00:00
|
|
|
FD_Figure * form;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// width and height in pixels on screen
|
2001-06-28 10:25:20 +00:00
|
|
|
int wid;
|
|
|
|
int hgh;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// width and height in postscript units (1/72 inch)
|
2001-06-28 10:25:20 +00:00
|
|
|
int pswid;
|
|
|
|
int pshgh;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// width of raw figure w/o rotation
|
|
|
|
int raw_wid;
|
|
|
|
/// heigt of raw figure w/o rotation
|
|
|
|
int raw_hgh;
|
|
|
|
/// x and y coordinate in ps units
|
2001-06-28 10:25:20 +00:00
|
|
|
int psx;
|
|
|
|
int psy;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// .eps file name
|
1999-10-02 16:21:10 +00:00
|
|
|
string fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// changed filename -> for recompute
|
|
|
|
bool changedfname;
|
|
|
|
|
|
|
|
///
|
|
|
|
enum HWTYPE {
|
|
|
|
///
|
|
|
|
DEF,
|
|
|
|
///
|
|
|
|
CM,
|
|
|
|
///
|
|
|
|
IN,
|
|
|
|
///
|
|
|
|
PER_PAGE,
|
|
|
|
///
|
|
|
|
PER_COL
|
|
|
|
};
|
|
|
|
|
|
|
|
/// width and height types: 0-default, 1-cm, 2-in, 3-%of page
|
|
|
|
/// For width, there is also: 4-% of col
|
|
|
|
HWTYPE wtype;
|
|
|
|
///
|
|
|
|
HWTYPE htype;
|
|
|
|
|
|
|
|
/// temporary w and h type
|
|
|
|
HWTYPE twtype;
|
|
|
|
///
|
|
|
|
HWTYPE thtype;
|
|
|
|
|
|
|
|
/// width and height
|
2001-06-28 10:25:20 +00:00
|
|
|
float xwid;
|
|
|
|
float xhgh;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// rotation angle
|
|
|
|
float angle;
|
|
|
|
|
|
|
|
/// graphics command, latex version
|
2000-02-18 22:22:42 +00:00
|
|
|
mutable string cmd;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Caption for subfigure package
|
1999-10-02 16:21:10 +00:00
|
|
|
string subcaption;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// various flags
|
|
|
|
int flags;
|
2000-03-12 10:35:05 +00:00
|
|
|
///
|
|
|
|
bool subfigure;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// figure reference
|
1999-11-24 22:14:46 +00:00
|
|
|
Figref * figure;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// temporary flags
|
|
|
|
int pflags;
|
2000-03-12 10:35:05 +00:00
|
|
|
///
|
|
|
|
bool psubfigure;
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
2000-11-28 06:46:06 +00:00
|
|
|
/** Redraw the form (on receipt of a Signal indicating, for example,
|
|
|
|
that the xform colors have been re-mapped).
|
|
|
|
*/
|
|
|
|
void redraw();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
2000-10-10 11:50:43 +00:00
|
|
|
Buffer const * owner;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// restore values on the form
|
2001-06-28 10:25:20 +00:00
|
|
|
void restoreForm();
|
1999-09-27 18:44:28 +00:00
|
|
|
/// recompute screen params
|
2001-06-28 10:25:20 +00:00
|
|
|
void recompute();
|
1999-09-27 18:44:28 +00:00
|
|
|
/// regenerate \includegraphics{} command
|
2001-06-28 10:25:20 +00:00
|
|
|
void regenerate() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// regenerate \inlcudegraphics{} command in temporary buffer
|
2001-06-28 10:25:20 +00:00
|
|
|
void tempRegenerate();
|
1999-09-27 18:44:28 +00:00
|
|
|
/// get sizes from .eps file
|
2001-06-28 10:25:20 +00:00
|
|
|
void getPSSizes();
|
2000-11-28 06:46:06 +00:00
|
|
|
/// Redraw connection.
|
2001-03-15 18:21:56 +00:00
|
|
|
SigC::Connection r_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
struct figdata {
|
|
|
|
/// bitmap data
|
|
|
|
Pixmap bitmap;
|
|
|
|
/// reference count for this bitmap
|
|
|
|
int ref;
|
|
|
|
/// rotation angle
|
|
|
|
float angle;
|
|
|
|
/// width of raw figure w/o rotation
|
|
|
|
int raw_wid;
|
|
|
|
/// heigt of raw figure w/o rotation
|
|
|
|
int raw_hgh;
|
|
|
|
/// width and height on screen
|
|
|
|
int wid, hgh;
|
|
|
|
/// pointer to file name
|
1999-10-02 16:21:10 +00:00
|
|
|
string fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// type; 0-none, 1-B/W, 2-Grayscale, 3-Color
|
|
|
|
char flags;
|
|
|
|
/// reading request is pending on this figure
|
|
|
|
bool reading;
|
|
|
|
/// could not read it, because it's broken
|
|
|
|
bool broken;
|
|
|
|
/// when gs was killed, this says that image is ok
|
|
|
|
bool gsdone;
|
|
|
|
/// gs pid for reading
|
|
|
|
int gspid;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
struct Figref {
|
|
|
|
/// figure data (image)
|
1999-11-24 22:14:46 +00:00
|
|
|
figdata * data;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// inset of this figure
|
1999-11-24 22:14:46 +00:00
|
|
|
InsetFig * inset;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|