4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
13 // This is Juergen's rewrite of the tabular (table) support.
15 // Things to think of when designing the new tabular support:
16 // - color support (colortbl, color)
17 // - decimal alignment (dcloumn)
18 // - custom lines (hhline)
24 // This is what I have written about tabular support in the LyX3-Tasks file:
26 // o rewrite of table code. Should probably be written as some
27 // kind of an inset. [Done]
28 // o enhance longtable support
32 #ifndef INSETTABULAR_H
33 #define INSETTABULAR_H
48 class InsetTabular : public UpdatableInset {
51 InsetTabular(Buffer const &, int rows = 1, int columns = 1);
53 InsetTabular(InsetTabular const &);
57 virtual std::auto_ptr<InsetBase> clone() const;
59 void read(Buffer const &, LyXLex &);
61 void write(Buffer const &, std::ostream &) const;
63 void metrics(MetricsInfo &, Dimension &) const;
65 void draw(PainterInfo & pi, int x, int y) const;
67 std::string const editMessage() const;
69 bool insetAllowed(InsetOld::Code) const { return true; }
71 bool isTextInset() const { return true; }
72 /** returns true if, when outputing LaTeX, font changes should
73 be closed before generating this inset. This is needed for
74 insets that may contain several paragraphs */
75 bool noFontChange() const { return true; }
77 bool display() const { return tabular.isLongTabular(); }
79 int latex(Buffer const &, std::ostream &,
80 OutputParams const &) const;
82 int plaintext(Buffer const &, std::ostream &,
83 OutputParams const &) const;
85 int linuxdoc(Buffer const &, std::ostream &,
86 OutputParams const &) const;
88 int docbook(Buffer const &, std::ostream &,
89 OutputParams const &) const;
91 void validate(LaTeXFeatures & features) const;
93 Code lyxCode() const { return InsetOld::TABULAR_CODE; }
94 /// get the absolute screen x,y of the cursor
95 void getCursorPos(LCursor const & cur, int & x, int & y) const;
97 bool tabularFeatures(LCursor & cur, std::string const & what);
99 void tabularFeatures(LCursor & cur, LyXTabular::Feature feature,
100 std::string const & val = std::string());
102 void openLayoutDialog(BufferView *) const;
104 bool showInsetDialog(BufferView *) const;
105 /// Appends \c list with all labels found within this inset.
106 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
108 size_t nargs() const;
110 InsetText const & cell(int) const;
112 InsetText & cell(int);
114 LyXText * getText(int) const;
119 // this should return true if we have a "normal" cell, otherwise true.
120 // "normal" means without width set!
121 bool forceDefaultParagraphs(InsetBase const * in) const;
124 void addPreview(lyx::graphics::PreviewLoader &) const;
127 Buffer const & buffer() const;
129 /// set the owning buffer
130 void buffer(Buffer const * buf);
131 /// lock cell with given index
132 void edit(LCursor & cur, bool left);
134 InsetBase * editXY(LCursor & cur, int x, int y) const;
135 /// can we go further down on mouse click?
136 bool descendable() const { return true; }
139 // Public structures and variables
141 mutable LyXTabular tabular;
145 void priv_dispatch(LCursor & cur, FuncRequest & cmd);
147 bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
150 void drawCellLines(Painter &, int x, int baseline,
151 int row, int cell) const;
153 void drawCellSelection(PainterInfo &, int x, int baseline,
154 int row, int column, int cell) const;
156 InsetBase * setPos(LCursor & cur, int x, int y) const;
159 void moveNextCell(LCursor & cur);
161 void movePrevCell(LCursor & cur);
163 int getCellXPos(int cell) const;
165 void resetPos(LCursor & cur) const;
167 void removeTabularRow();
169 bool hasPasteBuffer() const;
171 bool copySelection(LCursor & cur);
173 bool pasteSelection(LCursor & cur);
175 void cutSelection(LCursor & cur);
177 bool isRightToLeft(LCursor & cur) const;
179 void getSelection(LCursor & cur,
180 int & rs, int & re, int & cs, int & ce) const;
182 bool insertAsciiString(BufferView &, std::string const & buf, bool usePaste);
183 /// are we operating on several cells?
184 bool tablemode(LCursor & cur) const;
187 Buffer const * buffer_;
189 mutable int cursorx_;
191 mutable int first_visible_cell;
195 #include "mailinset.h"
198 class InsetTabularMailer : public MailInset {
201 InsetTabularMailer(InsetTabular const & inset);
203 virtual InsetBase & inset() const { return inset_; }
205 virtual std::string const & name() const { return name_; }
207 virtual std::string const inset2string(Buffer const &) const;
209 static void string2params(std::string const &, InsetTabular &);
211 static std::string const params2string(InsetTabular const &);
214 static std::string const name_;
216 InsetTabular & inset_;
219 std::string const featureAsString(LyXTabular::Feature feature);