2000-04-19 14:42:19 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insettabular.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
2000-04-19 14:42:19 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-04-19 14:42:19 +00:00
|
|
|
|
*/
|
|
|
|
|
// This is the rewrite of the tabular (table) support.
|
|
|
|
|
|
|
|
|
|
// It will probably be a lot of work.
|
|
|
|
|
|
|
|
|
|
// One first goal could be to make the inset read the old table format
|
|
|
|
|
// and just output it again... no viewing at all.
|
|
|
|
|
|
|
|
|
|
// When making the internal structure of tabular support I really think
|
|
|
|
|
// that STL containers should be used. This will separate the container from
|
|
|
|
|
// the rest of the code, which is a good thing.
|
|
|
|
|
|
|
|
|
|
// Ideally the tabular support should do as the mathed and use
|
|
|
|
|
// LaTeX in the .lyx file too.
|
|
|
|
|
|
|
|
|
|
// Things to think of when desingning the new tabular support:
|
|
|
|
|
// - color support (colortbl, color)
|
|
|
|
|
// - decimal alignment (dcloumn)
|
|
|
|
|
// - custom lines (hhline)
|
|
|
|
|
// - rotation
|
|
|
|
|
// - multicolumn
|
|
|
|
|
// - multirow
|
|
|
|
|
// - column styles
|
|
|
|
|
|
|
|
|
|
// This is what I have written about tabular support in the LyX3-Tasks file:
|
|
|
|
|
//
|
|
|
|
|
// o rewrite of table code. Should probably be written as some
|
|
|
|
|
// kind of an inset. At least get the code out of the kernel.
|
|
|
|
|
// - colortbl -multirow
|
|
|
|
|
// - hhline -multicolumn
|
|
|
|
|
// - dcolumn
|
|
|
|
|
// o enhance longtable support
|
|
|
|
|
|
|
|
|
|
// Lgb
|
|
|
|
|
|
|
|
|
|
#ifndef INSETTABULAR_H
|
|
|
|
|
#define INSETTABULAR_H
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "inset.h"
|
2000-04-21 15:16:22 +00:00
|
|
|
|
#include "tabular.h"
|
2003-05-19 17:03:12 +00:00
|
|
|
|
#include "frontends/mouse_state.h"
|
2000-10-24 13:13:59 +00:00
|
|
|
|
|
2003-09-04 01:18:42 +00:00
|
|
|
|
class FuncStatus;
|
2000-04-19 14:42:19 +00:00
|
|
|
|
class LyXLex;
|
|
|
|
|
class Painter;
|
|
|
|
|
class BufferView;
|
|
|
|
|
class Buffer;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
class BufferParams;
|
2001-07-06 15:57:54 +00:00
|
|
|
|
class Paragraph;
|
2000-04-19 14:42:19 +00:00
|
|
|
|
|
|
|
|
|
class InsetTabular : public UpdatableInset {
|
|
|
|
|
public:
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
|
|
|
|
InsetTabular(Buffer const &, int rows = 1, int columns = 1);
|
|
|
|
|
///
|
2003-06-03 15:10:14 +00:00
|
|
|
|
InsetTabular(InsetTabular const &);
|
2003-05-26 09:13:55 +00:00
|
|
|
|
///
|
2001-04-04 09:42:56 +00:00
|
|
|
|
~InsetTabular();
|
|
|
|
|
///
|
2003-07-25 17:11:25 +00:00
|
|
|
|
virtual std::auto_ptr<InsetBase> clone() const;
|
2003-05-26 09:13:55 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void read(Buffer const &, LyXLex &);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void write(Buffer const &, std::ostream &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void metrics(MetricsInfo &, Dimension &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const editMessage() const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-08-05 12:35:25 +00:00
|
|
|
|
void updateLocal(BufferView *) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
bool insetAllowed(InsetOld::Code code) const;
|
2001-07-09 14:19:41 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool isTextInset() const { return true; }
|
2002-07-23 21:03:38 +00:00
|
|
|
|
/** returns true if, when outputing LaTeX, font changes should
|
2002-12-01 22:59:25 +00:00
|
|
|
|
be closed before generating this inset. This is needed for
|
|
|
|
|
insets that may contain several paragraphs */
|
2002-07-23 21:03:38 +00:00
|
|
|
|
bool noFontChange() const { return true; }
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-06-13 07:37:48 +00:00
|
|
|
|
bool display() const { return tabular.isLongTabular(); }
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int latex(Buffer const &, std::ostream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-11-05 12:06:20 +00:00
|
|
|
|
int plaintext(Buffer const &, std::ostream &,
|
|
|
|
|
OutputParams const &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int linuxdoc(Buffer const &, std::ostream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int docbook(Buffer const &, std::ostream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void validate(LaTeXFeatures & features) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld::Code lyxCode() const { return InsetOld::TABULAR_CODE; }
|
2003-11-10 09:06:48 +00:00
|
|
|
|
/// get the absolute screen x,y of the cursor
|
2003-11-21 14:59:24 +00:00
|
|
|
|
void getCursorPos(int & x, int & y) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
bool tabularFeatures(BufferView * bv, std::string const & what);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void tabularFeatures(BufferView * bv, LyXTabular::Feature feature,
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const & val = std::string());
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
int getActCell() const { return actcell; }
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void openLayoutDialog(BufferView *) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool showInsetDialog(BufferView *) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
FuncStatus getStatus(std::string const & argument) const;
|
2003-09-18 20:18:39 +00:00
|
|
|
|
/// Appends \c list with all labels found within this inset.
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void getLabelList(Buffer const &, std::vector<std::string> & list) const;
|
2001-04-27 14:03:25 +00:00
|
|
|
|
///
|
2003-12-03 18:17:20 +00:00
|
|
|
|
int scroll(bool recursive = true) const;
|
2001-06-28 10:25:20 +00:00
|
|
|
|
///
|
2003-12-03 18:17:20 +00:00
|
|
|
|
void scroll(BufferView * bv, float sx) const {
|
2001-04-27 14:03:25 +00:00
|
|
|
|
UpdatableInset::scroll(bv, sx);
|
|
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
|
///
|
2003-12-03 18:17:20 +00:00
|
|
|
|
void scroll(BufferView * bv, int offset) const {
|
2001-04-27 14:03:25 +00:00
|
|
|
|
UpdatableInset::scroll(bv, offset);
|
|
|
|
|
}
|
2001-07-06 15:57:54 +00:00
|
|
|
|
///
|
2003-11-01 09:56:18 +00:00
|
|
|
|
int numParagraphs() const;
|
|
|
|
|
///
|
2003-10-14 13:01:49 +00:00
|
|
|
|
LyXText * getText(int) const;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
2003-11-04 11:36:28 +00:00
|
|
|
|
///
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void markErased();
|
|
|
|
|
|
2002-01-08 14:24:49 +00:00
|
|
|
|
// this should return true if we have a "normal" cell, otherwise true.
|
|
|
|
|
// "normal" means without width set!
|
2003-07-25 21:20:24 +00:00
|
|
|
|
bool forceDefaultParagraphs(InsetOld const * in) const;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2002-08-02 16:39:43 +00:00
|
|
|
|
///
|
2003-07-04 08:23:23 +00:00
|
|
|
|
void addPreview(lyx::graphics::PreviewLoader &) const;
|
2002-08-02 16:39:43 +00:00
|
|
|
|
|
2002-09-16 12:52:58 +00:00
|
|
|
|
/// are some cells selected ?
|
2003-11-10 09:06:48 +00:00
|
|
|
|
bool hasSelection() const { return has_selection; }
|
2003-07-10 12:26:40 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
Buffer const & buffer() const;
|
2003-06-03 15:10:14 +00:00
|
|
|
|
|
|
|
|
|
/// set the owning buffer
|
2003-10-15 08:49:44 +00:00
|
|
|
|
void buffer(Buffer * buf);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
/// lock cell with given index
|
|
|
|
|
void edit(BufferView * bv, bool);
|
|
|
|
|
///
|
|
|
|
|
void edit(BufferView * bv, int, int);
|
2003-11-17 12:53:44 +00:00
|
|
|
|
/// can we go further down on mouse click?
|
|
|
|
|
bool descendable() const { return true; }
|
2003-12-10 09:45:32 +00:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Public structures and variables
|
|
|
|
|
///
|
|
|
|
|
mutable LyXTabular tabular;
|
|
|
|
|
|
2003-10-17 18:01:15 +00:00
|
|
|
|
protected:
|
|
|
|
|
///
|
|
|
|
|
virtual
|
2003-10-29 10:47:21 +00:00
|
|
|
|
DispatchResult
|
2003-10-17 18:01:15 +00:00
|
|
|
|
priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
|
2000-04-19 14:42:19 +00:00
|
|
|
|
private:
|
2002-08-19 10:11:13 +00:00
|
|
|
|
///
|
|
|
|
|
void lfunMousePress(FuncRequest const &);
|
|
|
|
|
///
|
2003-11-10 09:06:48 +00:00
|
|
|
|
void lfunMouseRelease(FuncRequest const &);
|
2002-08-19 10:11:13 +00:00
|
|
|
|
///
|
|
|
|
|
void lfunMouseMotion(FuncRequest const &);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-07-18 07:47:07 +00:00
|
|
|
|
void calculate_dimensions_of_cells(MetricsInfo & mi) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void drawCellLines(Painter &, int x, int baseline,
|
2001-04-06 12:47:50 +00:00
|
|
|
|
int row, int cell) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void drawCellSelection(Painter &, int x, int baseline,
|
2001-04-06 12:47:50 +00:00
|
|
|
|
int row, int column, int cell) const;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
|
|
|
|
void setPos(BufferView *, int x, int y) const;
|
|
|
|
|
///
|
2003-11-10 09:06:48 +00:00
|
|
|
|
DispatchResult moveRight(BufferView *, bool lock);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-11-10 09:06:48 +00:00
|
|
|
|
DispatchResult moveLeft(BufferView *, bool lock);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-11-10 09:06:48 +00:00
|
|
|
|
DispatchResult moveUp(BufferView *, bool lock);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-11-10 09:06:48 +00:00
|
|
|
|
DispatchResult moveDown(BufferView *, bool lock);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
|
|
|
|
bool moveNextCell(BufferView *, bool lock = false);
|
|
|
|
|
///
|
|
|
|
|
bool movePrevCell(BufferView *, bool lock = false);
|
2001-07-24 22:08:49 +00:00
|
|
|
|
///
|
2001-04-04 09:42:56 +00:00
|
|
|
|
int getCellXPos(int cell) const;
|
|
|
|
|
///
|
|
|
|
|
void resetPos(BufferView *) const;
|
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void removeTabularRow();
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
|
|
|
|
void clearSelection() const {
|
2001-12-14 11:55:58 +00:00
|
|
|
|
sel_cell_start = sel_cell_end = 0;
|
|
|
|
|
has_selection = false;
|
|
|
|
|
}
|
|
|
|
|
void setSelection(int start, int end) const {
|
|
|
|
|
sel_cell_start = start;
|
|
|
|
|
sel_cell_end = end;
|
|
|
|
|
has_selection = true;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
}
|
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool activateCellInset(BufferView *, int x = 0, int y = 0,
|
2001-04-06 12:47:50 +00:00
|
|
|
|
bool behind = false);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
|
|
|
|
bool hasPasteBuffer() const;
|
|
|
|
|
///
|
|
|
|
|
bool copySelection(BufferView *);
|
|
|
|
|
///
|
|
|
|
|
bool pasteSelection(BufferView *);
|
|
|
|
|
///
|
2003-02-08 19:18:01 +00:00
|
|
|
|
bool cutSelection(BufferParams const & bp);
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
|
|
|
|
bool isRightToLeft(BufferView *);
|
2001-05-28 15:11:24 +00:00
|
|
|
|
///
|
2003-11-10 09:06:48 +00:00
|
|
|
|
void getSelection(int & scol, int & ecol, int & srow, int & erow) const;
|
2001-07-17 15:39:12 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
bool insertAsciiString(BufferView *, std::string const & buf, bool usePaste);
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2001-04-04 09:42:56 +00:00
|
|
|
|
//
|
|
|
|
|
// Private structures and variables
|
|
|
|
|
///
|
|
|
|
|
InsetText * the_locking_inset;
|
|
|
|
|
///
|
2003-06-03 15:10:14 +00:00
|
|
|
|
Buffer const * buffer_;
|
2001-04-04 09:42:56 +00:00
|
|
|
|
///
|
2003-07-18 16:23:17 +00:00
|
|
|
|
mutable int cursorx_;
|
|
|
|
|
///
|
|
|
|
|
mutable int cursory_;
|
2001-12-14 11:55:58 +00:00
|
|
|
|
/// true if a set of cells are selected
|
|
|
|
|
mutable bool has_selection;
|
|
|
|
|
/// the starting cell selection nr
|
2001-04-04 09:42:56 +00:00
|
|
|
|
mutable int sel_cell_start;
|
2001-12-14 11:55:58 +00:00
|
|
|
|
/// the ending cell selection nr
|
2001-04-04 09:42:56 +00:00
|
|
|
|
mutable int sel_cell_end;
|
|
|
|
|
///
|
|
|
|
|
mutable int actcell;
|
|
|
|
|
///
|
|
|
|
|
mutable int actcol;
|
|
|
|
|
///
|
|
|
|
|
mutable int actrow;
|
|
|
|
|
///
|
|
|
|
|
mutable int first_visible_cell;
|
|
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
|
mutable int in_reset_pos;
|
2000-04-19 14:42:19 +00:00
|
|
|
|
};
|
2003-03-09 18:11:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "mailinset.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InsetTabularMailer : public MailInset {
|
|
|
|
|
public:
|
|
|
|
|
///
|
2003-07-18 16:13:33 +00:00
|
|
|
|
InsetTabularMailer(InsetTabular const & inset);
|
2003-03-09 18:11:57 +00:00
|
|
|
|
///
|
2003-03-10 13:33:39 +00:00
|
|
|
|
virtual InsetBase & inset() const { return inset_; }
|
2003-03-09 18:11:57 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const & name() const { return name_; }
|
2003-03-09 18:11:57 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const inset2string(Buffer const &) const;
|
2003-03-09 18:11:57 +00:00
|
|
|
|
/// Returns the active cell if successful, else -1.
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static int string2params(std::string const &, InsetTabular &);
|
2003-03-09 18:11:57 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static std::string const params2string(InsetTabular const &);
|
2003-03-09 18:11:57 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static std::string const name_;
|
2003-03-09 18:11:57 +00:00
|
|
|
|
///
|
|
|
|
|
InsetTabular & inset_;
|
|
|
|
|
};
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const featureAsString(LyXTabular::Feature feature);
|
2003-03-09 18:11:57 +00:00
|
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
|
#endif
|