]> git.lyx.org Git - lyx.git/blob - src/insets/InsetTabular.h
Change inset label from ": filename" to "Program Listing: filename" for listings...
[lyx.git] / src / insets / InsetTabular.h
1 // -*- C++ -*-
2 /**
3  * \file InsetTabular.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Matthias Ettrich
9  * \author André Pönitz
10  * \author Jürgen Vigna
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15
16 // This is Juergen's rewrite of the tabular (table) support.
17
18 // Things to think of when designing the new tabular support:
19 // - color support (colortbl, color)
20 // - decimal alignment (dcloumn)
21 // - custom lines (hhline)
22 // - rotation
23 // - multicolumn
24 // - multirow
25 // - column styles
26
27 // This is what I have written about tabular support in the LyX3-Tasks file:
28 //
29 //  o rewrite of table code. Should probably be written as some
30 //    kind of an inset. [Done]
31 // o enhance longtable support
32
33 // Lgb
34
35 #ifndef INSET_TABULAR_H
36 #define INSET_TABULAR_H
37
38 #include "Inset.h"
39 #include "InsetText.h"
40 #include "Layout.h"
41 #include "Length.h"
42
43 #include <boost/shared_ptr.hpp>
44
45 #include <iosfwd>
46 #include <vector>
47
48 namespace lyx {
49
50 class Buffer;
51 class BufferParams;
52 class BufferView;
53 class CompletionList;
54 class CursorSlice;
55 class InsetTableCell;
56 class FuncStatus;
57 class Lexer;
58 class Paragraph;
59
60 namespace frontend { class Painter; }
61
62
63 class InsetTabular;
64 class Cursor;
65 class OutputParams;
66
67 //
68 // A helper struct for tables
69 //
70 class Tabular {
71 public:
72         ///
73         enum Feature {
74                 ///
75                 APPEND_ROW = 0,
76                 ///
77                 APPEND_COLUMN,
78                 ///
79                 DELETE_ROW,
80                 ///
81                 DELETE_COLUMN,
82                 ///
83                 COPY_ROW,
84                 ///
85                 COPY_COLUMN,
86                 ///
87                 TOGGLE_LINE_TOP,
88                 ///
89                 TOGGLE_LINE_BOTTOM,
90                 ///
91                 TOGGLE_LINE_LEFT,
92                 ///
93                 TOGGLE_LINE_RIGHT,
94                 ///
95                 ALIGN_LEFT,
96                 ///
97                 ALIGN_RIGHT,
98                 ///
99                 ALIGN_CENTER,
100                 ///
101                 ALIGN_BLOCK,
102                 ///
103                 VALIGN_TOP,
104                 ///
105                 VALIGN_BOTTOM,
106                 ///
107                 VALIGN_MIDDLE,
108                 ///
109                 M_ALIGN_LEFT,
110                 ///
111                 M_ALIGN_RIGHT,
112                 ///
113                 M_ALIGN_CENTER,
114                 ///
115                 M_VALIGN_TOP,
116                 ///
117                 M_VALIGN_BOTTOM,
118                 ///
119                 M_VALIGN_MIDDLE,
120                 ///
121                 MULTICOLUMN,
122                 ///
123                 SET_ALL_LINES,
124                 ///
125                 UNSET_ALL_LINES,
126                 ///
127                 SET_LONGTABULAR,
128                 ///
129                 UNSET_LONGTABULAR,
130                 ///
131                 SET_PWIDTH,
132                 ///
133                 SET_MPWIDTH,
134                 ///
135                 SET_ROTATE_TABULAR,
136                 ///
137                 UNSET_ROTATE_TABULAR,
138                 ///
139                 TOGGLE_ROTATE_TABULAR,
140                 ///
141                 SET_ROTATE_CELL,
142                 ///
143                 UNSET_ROTATE_CELL,
144                 ///
145                 TOGGLE_ROTATE_CELL,
146                 ///
147                 SET_USEBOX,
148                 ///
149                 SET_LTHEAD,
150                 UNSET_LTHEAD,
151                 ///
152                 SET_LTFIRSTHEAD,
153                 UNSET_LTFIRSTHEAD,
154                 ///
155                 SET_LTFOOT,
156                 UNSET_LTFOOT,
157                 ///
158                 SET_LTLASTFOOT,
159                 UNSET_LTLASTFOOT,
160                 ///
161                 SET_LTNEWPAGE,
162                 ///
163                 TOGGLE_LTCAPTION,
164                 ///
165                 SET_SPECIAL_COLUMN,
166                 ///
167                 SET_SPECIAL_MULTI,
168                 ///
169                 SET_BOOKTABS,
170                 ///
171                 UNSET_BOOKTABS,
172                 ///
173                 SET_TOP_SPACE,
174                 ///
175                 SET_BOTTOM_SPACE,
176                 ///
177                 SET_INTERLINE_SPACE,
178                 ///
179                 SET_BORDER_LINES,
180                 ///
181                 LAST_ACTION
182         };
183         ///
184         enum {
185                 ///
186                 CELL_NORMAL = 0,
187                 ///
188                 CELL_BEGIN_OF_MULTICOLUMN,
189                 ///
190                 CELL_PART_OF_MULTICOLUMN
191         };
192
193         ///
194         enum VAlignment {
195                 ///
196                 LYX_VALIGN_TOP = 0,
197                 ///
198                 LYX_VALIGN_BOTTOM = 1,
199                 ///
200                 LYX_VALIGN_MIDDLE = 2
201         };
202
203         enum BoxType {
204                 ///
205                 BOX_NONE = 0,
206                 ///
207                 BOX_PARBOX = 1,
208                 ///
209                 BOX_MINIPAGE = 2
210         };
211
212         class ltType {
213         public:
214                 // constructor
215                 ltType();
216                 // we have this header type (is set in the getLT... functions)
217                 bool set;
218                 // double borders on top
219                 bool topDL;
220                 // double borders on bottom
221                 bool bottomDL;
222                 // used for FirstHeader & LastFooter and if this is true
223                 // all the rows marked as FirstHeader or LastFooter are
224                 // ignored in the output and it is set to be empty!
225                 bool empty;
226         };
227
228         /// type for row numbers
229         typedef size_t row_type;
230         /// type for column numbers
231         typedef size_t col_type;
232         /// type for cell indices
233         typedef size_t idx_type;
234         /// index indicating an invalid position
235         static const idx_type npos = static_cast<idx_type>(-1);
236
237         /// constructor
238         Tabular(Buffer const &, col_type columns_arg, row_type rows_arg);
239
240         /// Returns true if there is a topline, returns false if not
241         bool topLine(idx_type cell) const;
242         /// Returns true if there is a topline, returns false if not
243         bool bottomLine(idx_type cell) const;
244         /// Returns true if there is a topline, returns false if not
245         bool leftLine(idx_type cell) const;
246         /// Returns true if there is a topline, returns false if not
247         bool rightLine(idx_type cell) const;
248
249         ///
250         bool topAlreadyDrawn(idx_type cell) const;
251         ///
252         bool leftAlreadyDrawn(idx_type cell) const;
253         ///
254         bool isLastRow(idx_type cell) const;
255
256         /// return space occupied by the second horizontal line and
257         /// interline space above row \p row in pixels
258         int getAdditionalHeight(row_type row) const;
259         ///
260         int getAdditionalWidth(idx_type cell) const;
261
262         /* returns the maximum over all rows */
263         ///
264         int columnWidth(idx_type cell) const;
265         ///
266         int width() const;
267         ///
268         int height() const;
269         ///
270         int rowAscent(row_type row) const;
271         ///
272         int rowDescent(row_type row) const;
273         ///
274         void setRowAscent(row_type row, int height);
275         ///
276         void setRowDescent(row_type row, int height);
277         ///
278         void setCellWidth(idx_type cell, int new_width);
279         ///
280         void setAllLines(idx_type cell, bool line);
281         ///
282         void setTopLine(idx_type cell, bool line);
283         ///
284         void setBottomLine(idx_type cell, bool line);
285         ///
286         void setLeftLine(idx_type cell, bool line);
287         ///
288         void setRightLine(idx_type cell, bool line);
289         ///
290         bool rowTopLine(row_type row) const;
291         ///
292         bool rowBottomLine(row_type row) const;
293         ///
294         bool columnLeftLine(col_type column) const;
295         ///
296         bool columnRightLine(col_type column) const;
297
298         void setAlignment(idx_type cell, LyXAlignment align,
299                           bool onlycolumn = false);
300         ///
301         void setVAlignment(idx_type cell, VAlignment align,
302                            bool onlycolumn = false);
303         ///
304         void setColumnPWidth(Cursor &, idx_type, Length const &);
305         ///
306         bool setMColumnPWidth(Cursor &, idx_type, Length const &);
307         ///
308         void setAlignSpecial(idx_type cell, docstring const & special,
309                              Feature what);
310         ///
311         LyXAlignment getAlignment(idx_type cell,
312                                   bool onlycolumn = false) const;
313         ///
314         VAlignment getVAlignment(idx_type cell,
315                                  bool onlycolumn = false) const;
316         ///
317         Length const getPWidth(idx_type cell) const;
318         ///
319         int cellWidth(idx_type cell) const;
320         ///
321         int getBeginningOfTextInCell(idx_type cell) const;
322         ///
323         void appendRow(idx_type cell);
324         ///
325         void deleteRow(row_type row);
326         ///
327         void copyRow(row_type);
328         ///
329         void appendColumn(idx_type cell);
330         ///
331         void deleteColumn(col_type column);
332         ///
333         void copyColumn(col_type);
334         ///
335         bool isFirstCellInRow(idx_type cell) const;
336         ///
337         idx_type getFirstCellInRow(row_type row) const;
338         ///
339         bool isLastCellInRow(idx_type cell) const;
340         ///
341         idx_type getLastCellInRow(row_type row) const;
342         ///
343         idx_type numberOfCellsInRow(idx_type cell) const;
344         ///
345         void write(std::ostream &) const;
346         ///
347         void read(Lexer &);
348         ///
349         int latex(odocstream &, OutputParams const &) const;
350         //
351         int docbook(odocstream & os, OutputParams const &) const;
352         ///
353         void plaintext(odocstream &,
354                        OutputParams const & runparams, int const depth,
355                        bool onlydata, char_type delim) const;
356         ///
357         bool isMultiColumn(idx_type cell) const;
358         ///
359         bool isMultiColumnReal(idx_type cell) const;
360         ///
361         void setMultiColumn(idx_type cell, idx_type number);
362         ///
363         idx_type unsetMultiColumn(idx_type cell); // returns number of new cells
364         ///
365         bool isPartOfMultiColumn(row_type row, col_type column) const;
366         ///
367         row_type cellRow(idx_type cell) const;
368         ///
369         col_type cellColumn(idx_type cell) const;
370         ///
371         col_type cellRightColumn(idx_type cell) const;
372         ///
373         void setRotateCell(idx_type cell, bool);
374         ///
375         bool getRotateCell(idx_type cell) const;
376         ///
377         bool needRotating() const;
378         ///
379         bool isLastCell(idx_type cell) const;
380         ///
381         idx_type cellAbove(idx_type cell) const;
382         ///
383         idx_type cellBelow(idx_type cell) const;
384         ///
385         idx_type cellIndex(row_type row, col_type column) const;
386         ///
387         void setUsebox(idx_type cell, BoxType);
388         ///
389         BoxType getUsebox(idx_type cell) const;
390         //
391         // Long Tabular Options support functions
392         ///
393         bool checkLTType(row_type row, ltType const &) const;
394         ///
395         void setLTHead(row_type row, bool flag, ltType const &, bool first);
396         ///
397         bool getRowOfLTHead(row_type row, ltType &) const;
398         ///
399         bool getRowOfLTFirstHead(row_type row, ltType &) const;
400         ///
401         void setLTFoot(row_type row, bool flag, ltType const &, bool last);
402         ///
403         bool getRowOfLTFoot(row_type row, ltType &) const;
404         ///
405         bool getRowOfLTLastFoot(row_type row, ltType &) const;
406         ///
407         void setLTNewPage(row_type row, bool what);
408         ///
409         bool getLTNewPage(row_type row) const;
410         ///
411         idx_type setLTCaption(row_type row, bool what);
412         ///
413         bool ltCaption(row_type row) const;
414         ///
415         bool haveLTHead() const;
416         ///
417         bool haveLTFirstHead() const;
418         ///
419         bool haveLTFoot() const;
420         ///
421         bool haveLTLastFoot() const;
422         ///
423         // end longtable support
424         ///
425         boost::shared_ptr<InsetTableCell> cellInset(idx_type cell) const;
426         ///
427         boost::shared_ptr<InsetTableCell> cellInset(row_type row,
428                                                   col_type column) const;
429         ///
430         void setCellInset(row_type row, col_type column,
431                           boost::shared_ptr<InsetTableCell>) const;
432         /// Search for \param inset in the tabular, with the
433         ///
434         idx_type cellFromInset(Inset const * inset) const;
435         ///
436         void validate(LaTeXFeatures &) const;
437         ///
438 //private:
439         ///
440         class CellData {
441         public:
442                 ///
443                 CellData(Buffer const &, Tabular const &);
444                 ///
445                 CellData(CellData const &);
446                 ///
447                 CellData & operator=(CellData);
448                 ///
449                 void swap(CellData & rhs);
450                 ///
451                 idx_type cellno;
452                 ///
453                 int width;
454                 ///
455                 int multicolumn;
456                 ///
457                 LyXAlignment alignment;
458                 ///
459                 VAlignment valignment;
460                 ///
461                 bool top_line;
462                 ///
463                 bool bottom_line;
464                 ///
465                 bool left_line;
466                 ///
467                 bool right_line;
468                 ///
469                 BoxType usebox;
470                 ///
471                 bool rotate;
472                 ///
473                 docstring align_special;
474                 ///
475                 Length p_width; // this is only set for multicolumn!!!
476                 ///
477                 boost::shared_ptr<InsetTableCell> inset;
478         };
479         CellData & cellInfo(idx_type cell) const;
480         ///
481         typedef std::vector<CellData> cell_vector;
482         ///
483         typedef std::vector<cell_vector> cell_vvector;
484
485         ///
486         class RowData {
487         public:
488                 ///
489                 RowData();
490                 ///
491                 int ascent;
492                 ///
493                 int descent;
494                 /// Extra space between the top line and this row
495                 Length top_space;
496                 /// Ignore top_space if true and use the default top space
497                 bool top_space_default;
498                 /// Extra space between this row and the bottom line
499                 Length bottom_space;
500                 /// Ignore bottom_space if true and use the default bottom space
501                 bool bottom_space_default;
502                 /// Extra space between the bottom line and the next top line
503                 Length interline_space;
504                 /// Ignore interline_space if true and use the default interline space
505                 bool interline_space_default;
506                 /// This are for longtabulars only
507                 /// a row of endhead
508                 bool endhead;
509                 /// a row of endfirsthead
510                 bool endfirsthead;
511                 /// a row of endfoot
512                 bool endfoot;
513                 /// row of endlastfoot
514                 bool endlastfoot;
515                 /// row for a newpage
516                 bool newpage;
517                 /// caption
518                 bool caption;
519         };
520         ///
521         typedef std::vector<RowData> row_vector;
522
523         ///
524         class ColumnData {
525                 public:
526                 ///
527                 ColumnData();
528                 ///
529                 LyXAlignment alignment;
530                 ///
531                 VAlignment valignment;
532                 ///
533                 int width;
534                 ///
535                 Length p_width;
536                 ///
537                 docstring align_special;
538         };
539         ///
540         typedef std::vector<ColumnData> column_vector;
541
542         ///
543         idx_type numberofcells;
544         ///
545         std::vector<row_type> rowofcell;
546         ///
547         std::vector<col_type> columnofcell;
548         ///
549         row_vector row_info;
550         ///
551         column_vector column_info;
552         ///
553         mutable cell_vvector cell_info;
554         ///
555         bool use_booktabs;
556         ///
557         bool rotate;
558         //
559         // for long tabulars
560         //
561         bool is_long_tabular;
562         /// endhead data
563         ltType endhead;
564         /// endfirsthead data
565         ltType endfirsthead;
566         /// endfoot data
567         ltType endfoot;
568         /// endlastfoot data
569         ltType endlastfoot;
570
571         ///
572         void init(Buffer const &, row_type rows_arg,
573                   col_type columns_arg);
574         ///
575         void updateIndexes();
576         /// return true of update is needed
577         bool updateColumnWidths();
578         ///
579         idx_type columnSpan(idx_type cell) const;
580         ///
581         BoxType useParbox(idx_type cell) const;
582         ///
583         // helper function for Latex returns number of newlines
584         ///
585         int TeXTopHLine(odocstream &, row_type row) const;
586         ///
587         int TeXBottomHLine(odocstream &, row_type row) const;
588         ///
589         int TeXCellPreamble(odocstream &, idx_type cell, bool & ismulticol) const;
590         ///
591         int TeXCellPostamble(odocstream &, idx_type cell, bool ismulticol) const;
592         ///
593         int TeXLongtableHeaderFooter(odocstream &, OutputParams const &) const;
594         ///
595         bool isValidRow(row_type const row) const;
596         ///
597         int TeXRow(odocstream &, row_type const row,
598                    OutputParams const &) const;
599         ///
600         // helper functions for plain text
601         ///
602         bool plaintextTopHLine(odocstream &, row_type row,
603                                std::vector<unsigned int> const &) const;
604         ///
605         bool plaintextBottomHLine(odocstream &, row_type row,
606                                   std::vector<unsigned int> const &) const;
607         ///
608         void plaintextPrintCell(odocstream &,
609                                 OutputParams const &,
610                                 idx_type cell, row_type row, col_type column,
611                                 std::vector<unsigned int> const &,
612                                 bool onlydata) const;
613         /// auxiliary function for docbook
614         int docbookRow(odocstream & os, row_type, OutputParams const &) const;
615
616         /// change associated Buffer
617         void setBuffer(Buffer const & buffer) { buffer_ = &buffer; }
618         /// retrieve associated Buffer
619         Buffer const & buffer() const { return *buffer_; }
620
621 private:
622         Buffer const * buffer_;
623
624 }; // Tabular
625
626
627 ///
628 class InsetTableCell : public InsetText
629 {
630 public:
631         ///
632         InsetTableCell(Buffer const & buf,
633                 Tabular::CellData const * cd, Tabular const * t);
634         ///
635         InsetCode lyxCode() const { return CELL_CODE; }
636         ///
637         Inset * clone() { return new InsetTableCell(*this); }
638         ///
639         virtual bool useEmptyLayout() const { return true; }
640         /// 
641         virtual bool forceEmptyLayout(idx_type = 0) const;
642         /// 
643         virtual bool allowParagraphCustomization(idx_type = 0) const;
644         ///
645         bool getStatus(Cursor & cur, FuncRequest const & cmd,
646                 FuncStatus & status) const;
647         ///
648         virtual bool neverIndent() { return true; }
649         ///
650         void setCellData(Tabular::CellData const * cd) { cell_data_ = cd; }
651         ///
652         void setTabular(Tabular const * t) { table_ = t; }
653 private:
654         /// unimplemented
655         InsetTableCell();
656         /// unimplemented
657         void operator=(InsetTableCell const &);
658
659         /// 
660         Tabular::CellData const * cell_data_;
661         /// 
662         Tabular const * table_;
663 };
664
665
666 class InsetTabular : public Inset
667 {
668 public:
669         ///
670         InsetTabular(Buffer const &, row_type rows = 1,
671                      col_type columns = 1);
672         ///
673         ~InsetTabular();
674         ///
675         static void string2params(std::string const &, InsetTabular &);
676         ///
677         static std::string params2string(InsetTabular const &);
678         ///
679         void read(Lexer &);
680         ///
681         void write(std::ostream &) const;
682         ///
683         void metrics(MetricsInfo &, Dimension &) const;
684         ///
685         void draw(PainterInfo & pi, int x, int y) const;
686         ///
687         void drawSelection(PainterInfo & pi, int x, int y) const;
688         ///
689         docstring editMessage() const;
690         ///
691         EDITABLE editable() const { return HIGHLY_EDITABLE; }
692         ///
693         bool insetAllowed(InsetCode code) const;
694         ///
695         bool allowSpellCheck() const { return true; }
696         ///
697         bool canTrackChanges() const { return true; }
698         /** returns true if, when outputing LaTeX, font changes should
699             be closed before generating this inset. This is needed for
700             insets that may contain several paragraphs */
701         bool noFontChange() const { return true; }
702         ///
703         DisplayType display() const { return tabular.is_long_tabular ? AlignCenter : Inline; }
704         ///
705         int latex(odocstream &, OutputParams const &) const;
706         ///
707         int plaintext(odocstream &, OutputParams const &) const;
708         ///
709         int docbook(odocstream &, OutputParams const &) const;
710         ///
711         void validate(LaTeXFeatures & features) const;
712         ///
713         InsetCode lyxCode() const { return TABULAR_CODE; }
714         ///
715         docstring contextMenu(BufferView const & bv, int x, int y) const;
716         /// get offset of this cursor slice relative to our upper left corner
717         void cursorPos(BufferView const & bv, CursorSlice const & sl,
718                 bool boundary, int & x, int & y) const;
719         ///
720         bool tabularFeatures(Cursor & cur, std::string const & what);
721         ///
722         void tabularFeatures(Cursor & cur, Tabular::Feature feature,
723                              std::string const & val = std::string());
724         ///
725         void openLayoutDialog(BufferView *) const;
726         ///
727         bool showInsetDialog(BufferView *) const;
728         /// number of cells
729         size_t nargs() const { return tabular.numberofcells; }
730         ///
731         boost::shared_ptr<InsetTableCell const> cell(idx_type) const;
732         ///
733         boost::shared_ptr<InsetTableCell> cell(idx_type);
734         ///
735         Text * getText(int) const;
736
737         /// set the change for the entire inset
738         void setChange(Change const & change);
739         /// accept the changes within the inset
740         void acceptChanges(BufferParams const & bparams);
741         /// reject the changes within the inset
742         void rejectChanges(BufferParams const & bparams);
743
744         // this should return true if we have a "normal" cell, otherwise false.
745         // "normal" means without width set!
746         /// should all paragraphs be output with "Standard" layout?
747         virtual bool allowParagraphCustomization(idx_type cell = 0) const;
748         ///
749         virtual bool forceEmptyLayout(idx_type cell = 0) const;
750         ///
751         virtual bool useEmptyLayout() { return true; }
752         ///
753         void addPreview(graphics::PreviewLoader &) const;
754
755         /// lock cell with given index
756         void edit(Cursor & cur, bool front, EntryDirection entry_from);
757         /// get table row from x coordinate
758         int rowFromY(Cursor & cur, int y) const;
759         /// get table column from y coordinate
760         int columnFromX(Cursor & cur, int x) const;
761         ///
762         Inset * editXY(Cursor & cur, int x, int y);
763         /// can we go further down on mouse click?
764         bool descendable() const { return true; }
765         // Update the counters of this inset and of its contents
766         void updateLabels(ParIterator const &);
767
768         ///
769         bool completionSupported(Cursor const &) const;
770         ///
771         bool inlineCompletionSupported(Cursor const & cur) const;
772         ///
773         bool automaticInlineCompletion() const;
774         ///
775         bool automaticPopupCompletion() const;
776         ///
777         bool showCompletionCursor() const;
778         ///
779         CompletionList const * createCompletionList(Cursor const & cur) const;
780         ///
781         docstring completionPrefix(Cursor const & cur) const;
782         ///
783         bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
784         ///
785         void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
786
787         ///
788         virtual InsetTabular * asInsetTabular() { return this; }
789         ///
790         virtual InsetTabular const * asInsetTabular() const { return this; }
791         ///
792         bool isRightToLeft(Cursor & cur) const;
793
794         //
795         // Public structures and variables
796         ///
797         mutable Tabular tabular;
798
799 private:
800         ///
801         InsetTabular(InsetTabular const &);
802         ///
803         void doDispatch(Cursor & cur, FuncRequest & cmd);
804         ///
805         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
806         ///
807         int scroll() const { return scx_; }
808         ///
809         Inset * clone() const { return new InsetTabular(*this); }
810
811         ///
812         void drawCellLines(frontend::Painter &, int x, int y, row_type row,
813                            idx_type cell, bool erased) const;
814         ///
815         void setCursorFromCoordinates(Cursor & cur, int x, int y) const;
816
817         ///
818         void moveNextCell(Cursor & cur, 
819                                 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
820         ///
821         void movePrevCell(Cursor & cur,
822                                 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
823         ///
824         int cellXPos(idx_type cell) const;
825         ///
826         void resetPos(Cursor & cur) const;
827         ///
828         void removeTabularRow();
829         ///
830         bool copySelection(Cursor & cur);
831         ///
832         bool pasteClipboard(Cursor & cur);
833         ///
834         void cutSelection(Cursor & cur);
835         ///
836         void getSelection(Cursor & cur, row_type & rs, row_type & re,
837                           col_type & cs, col_type & ce) const;
838         ///
839         bool insertPlaintextString(BufferView &, docstring const & buf, bool usePaste);
840         /// are we operating on several cells?
841         bool tablemode(Cursor & cur) const;
842
843         /// return the "Manhattan distance" to nearest corner
844         int dist(BufferView &, idx_type cell, int x, int y) const;
845         /// return the cell nearest to x, y
846         idx_type getNearestCell(BufferView &, int x, int y) const;
847
848         /// test the rotation state of the give cell range.
849         bool oneCellHasRotationState(bool rotated,
850                                 row_type row_start, row_type row_end,
851                                 col_type col_start, col_type col_end) const;
852         ///
853         mutable idx_type first_visible_cell;
854         ///
855         mutable int scx_;
856         /// true when selecting rows with the mouse
857         bool rowselect_;
858         /// true when selecting columns with the mouse
859         bool colselect_;
860 };
861
862 std::string const featureAsString(Tabular::Feature feature);
863
864 } // namespace lyx
865
866 #endif // INSET_TABULAR_H