]> git.lyx.org Git - lyx.git/blob - src/insets/InsetTabular.h
remove remaining MailInsets.
[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                 SET_SPECIAL_COLUMN,
164                 ///
165                 SET_SPECIAL_MULTI,
166                 ///
167                 SET_BOOKTABS,
168                 ///
169                 UNSET_BOOKTABS,
170                 ///
171                 SET_TOP_SPACE,
172                 ///
173                 SET_BOTTOM_SPACE,
174                 ///
175                 SET_INTERLINE_SPACE,
176                 ///
177                 SET_BORDER_LINES,
178                 ///
179                 LAST_ACTION
180         };
181         ///
182         enum {
183                 ///
184                 CELL_NORMAL = 0,
185                 ///
186                 CELL_BEGIN_OF_MULTICOLUMN,
187                 ///
188                 CELL_PART_OF_MULTICOLUMN
189         };
190
191         ///
192         enum VAlignment {
193                 ///
194                 LYX_VALIGN_TOP = 0,
195                 ///
196                 LYX_VALIGN_BOTTOM = 1,
197                 ///
198                 LYX_VALIGN_MIDDLE = 2
199         };
200
201         enum BoxType {
202                 ///
203                 BOX_NONE = 0,
204                 ///
205                 BOX_PARBOX = 1,
206                 ///
207                 BOX_MINIPAGE = 2
208         };
209
210         class ltType {
211         public:
212                 // constructor
213                 ltType();
214                 // we have this header type (is set in the getLT... functions)
215                 bool set;
216                 // double borders on top
217                 bool topDL;
218                 // double borders on bottom
219                 bool bottomDL;
220                 // used for FirstHeader & LastFooter and if this is true
221                 // all the rows marked as FirstHeader or LastFooter are
222                 // ignored in the output and it is set to be empty!
223                 bool empty;
224         };
225
226         /// type for row numbers
227         typedef size_t row_type;
228         /// type for column numbers
229         typedef size_t col_type;
230         /// type for cell indices
231         typedef size_t idx_type;
232         /// index indicating an invalid position
233         static const idx_type npos = static_cast<idx_type>(-1);
234
235         /// constructor
236         Tabular();
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         Length const getColumnPWidth(idx_type cell) const;
320         ///
321         Length const getMColumnPWidth(idx_type cell) const;
322         ///
323         docstring const getAlignSpecial(idx_type cell, int what) const;
324         ///
325         int cellWidth(idx_type cell) const;
326         ///
327         int getBeginningOfTextInCell(idx_type cell) const;
328         ///
329         void appendRow(idx_type cell);
330         ///
331         void deleteRow(row_type row);
332         ///
333         void copyRow(row_type);
334         ///
335         void appendColumn(idx_type cell);
336         ///
337         void deleteColumn(col_type column);
338         ///
339         void copyColumn(col_type);
340         ///
341         bool isFirstCellInRow(idx_type cell) const;
342         ///
343         idx_type getFirstCellInRow(row_type row) const;
344         ///
345         bool isLastCellInRow(idx_type cell) const;
346         ///
347         idx_type getLastCellInRow(row_type row) const;
348         ///
349         idx_type cellCount() const;
350         ///
351         idx_type numberOfCellsInRow(idx_type cell) const;
352         ///
353         void write(std::ostream &) const;
354         ///
355         void read(Lexer &);
356         ///
357         int latex(odocstream &, OutputParams const &) const;
358         //
359         int docbook(odocstream & os, OutputParams const &) const;
360         ///
361         void plaintext(odocstream &,
362                        OutputParams const & runparams, int const depth,
363                        bool onlydata, char_type delim) const;
364         ///
365         bool isMultiColumn(idx_type cell) const;
366         ///
367         bool isMultiColumnReal(idx_type cell) const;
368         ///
369         void setMultiColumn(idx_type cell, idx_type number);
370         ///
371         idx_type unsetMultiColumn(idx_type cell); // returns number of new cells
372         ///
373         bool isPartOfMultiColumn(row_type row, col_type column) const;
374         ///
375         row_type cellRow(idx_type cell) const;
376         ///
377         col_type cellColumn(idx_type cell) const;
378         ///
379         col_type cellRightColumn(idx_type cell) const;
380         ///
381         void setBookTabs(bool);
382         ///
383         bool useBookTabs() const;
384         ///
385         void setLongTabular(bool);
386         ///
387         bool isLongTabular() const;
388         ///
389         void setRotateTabular(bool);
390         ///
391         bool getRotateTabular() const;
392         ///
393         void setRotateCell(idx_type cell, bool);
394         ///
395         bool getRotateCell(idx_type cell) const;
396         ///
397         bool needRotating() const;
398         ///
399         bool isLastCell(idx_type cell) const;
400         ///
401         idx_type cellAbove(idx_type cell) const;
402         ///
403         idx_type cellBelow(idx_type cell) const;
404         ///
405         idx_type cellIndex(row_type row, col_type column) const;
406         ///
407         void setUsebox(idx_type cell, BoxType);
408         ///
409         BoxType getUsebox(idx_type cell) const;
410         //
411         // Long Tabular Options support functions
412         ///
413         bool checkLTType(row_type row, ltType const &) const;
414         ///
415         void setLTHead(row_type row, bool flag, ltType const &, bool first);
416         ///
417         bool getRowOfLTHead(row_type row, ltType &) const;
418         ///
419         bool getRowOfLTFirstHead(row_type row, ltType &) const;
420         ///
421         void setLTFoot(row_type row, bool flag, ltType const &, bool last);
422         ///
423         bool getRowOfLTFoot(row_type row, ltType &) const;
424         ///
425         bool getRowOfLTLastFoot(row_type row, ltType &) const;
426         ///
427         void setLTNewPage(row_type row, bool what);
428         ///
429         bool getLTNewPage(row_type row) const;
430         ///
431         bool haveLTHead() const;
432         ///
433         bool haveLTFirstHead() const;
434         ///
435         bool haveLTFoot() const;
436         ///
437         bool haveLTLastFoot() const;
438         ///
439         // end longtable support
440         ///
441         boost::shared_ptr<InsetTableCell> cellInset(idx_type cell) const;
442         ///
443         boost::shared_ptr<InsetTableCell> cellInset(row_type row,
444                                                   col_type column) const;
445         ///
446         void setCellInset(row_type row, col_type column,
447                           boost::shared_ptr<InsetTableCell>) const;
448         /// Search for \param inset in the tabular, with the
449         ///
450         idx_type cellFromInset(Inset const * inset) const;
451         ///
452         row_type rowCount() const { return row_info.size(); }
453         ///
454         col_type columnCount() const { return column_info.size();}
455         ///
456         void validate(LaTeXFeatures &) const;
457         ///
458 //private:
459         ///
460         class CellData {
461         public:
462                 ///
463                 CellData(Buffer const &, Tabular const &);
464                 ///
465                 CellData(CellData const &);
466                 ///
467                 CellData & operator=(CellData);
468                 ///
469                 void swap(CellData & rhs);
470                 ///
471                 idx_type cellno;
472                 ///
473                 int width;
474                 ///
475                 int multicolumn;
476                 ///
477                 LyXAlignment alignment;
478                 ///
479                 VAlignment valignment;
480                 ///
481                 bool top_line;
482                 ///
483                 bool bottom_line;
484                 ///
485                 bool left_line;
486                 ///
487                 bool right_line;
488                 ///
489                 BoxType usebox;
490                 ///
491                 bool rotate;
492                 ///
493                 docstring align_special;
494                 ///
495                 Length p_width; // this is only set for multicolumn!!!
496                 ///
497                 boost::shared_ptr<InsetTableCell> inset;
498         };
499         CellData & cellInfo(idx_type cell) const;
500         ///
501         typedef std::vector<CellData> cell_vector;
502         ///
503         typedef std::vector<cell_vector> cell_vvector;
504
505         ///
506         class RowData {
507         public:
508                 ///
509                 RowData();
510                 ///
511                 int ascent;
512                 ///
513                 int descent;
514                 ///
515                 bool top_line;
516                 ///
517                 bool bottom_line;
518                 /// Extra space between the top line and this row
519                 Length top_space;
520                 /// Ignore top_space if true and use the default top space
521                 bool top_space_default;
522                 /// Extra space between this row and the bottom line
523                 Length bottom_space;
524                 /// Ignore bottom_space if true and use the default bottom space
525                 bool bottom_space_default;
526                 /// Extra space between the bottom line and the next top line
527                 Length interline_space;
528                 /// Ignore interline_space if true and use the default interline space
529                 bool interline_space_default;
530                 /// This are for longtabulars only
531                 /// a row of endhead
532                 bool endhead;
533                 /// a row of endfirsthead
534                 bool endfirsthead;
535                 /// a row of endfoot
536                 bool endfoot;
537                 /// row of endlastfoot
538                 bool endlastfoot;
539                 /// row for a newpage
540                 bool newpage;
541         };
542         ///
543         typedef std::vector<RowData> row_vector;
544
545         ///
546         class ColumnData {
547                 public:
548                 ///
549                 ColumnData();
550                 ///
551                 LyXAlignment alignment;
552                 ///
553                 VAlignment valignment;
554                 ///
555                 bool left_line;
556                 ///
557                 bool right_line;
558                 ///
559                 int width;
560                 ///
561                 Length p_width;
562                 ///
563                 docstring align_special;
564         };
565         ///
566         typedef std::vector<ColumnData> column_vector;
567
568         ///
569         idx_type numberofcells;
570         ///
571         std::vector<row_type> rowofcell;
572         ///
573         std::vector<col_type> columnofcell;
574         ///
575         row_vector row_info;
576         ///
577         column_vector column_info;
578         ///
579         mutable cell_vvector cell_info;
580         ///
581         bool use_booktabs;
582         ///
583         bool rotate;
584         //
585         // for long tabulars
586         //
587         bool is_long_tabular;
588         /// endhead data
589         ltType endhead;
590         /// endfirsthead data
591         ltType endfirsthead;
592         /// endfoot data
593         ltType endfoot;
594         /// endlastfoot data
595         ltType endlastfoot;
596
597         ///
598         void init(Buffer const &, row_type rows_arg,
599                   col_type columns_arg);
600         ///
601         void updateIndexes();
602         /// return true of update is needed
603         bool updateColumnWidths();
604         ///
605         idx_type columnSpan(idx_type cell) const;
606         ///
607         BoxType useParbox(idx_type cell) const;
608         ///
609         // helper function for Latex returns number of newlines
610         ///
611         int TeXTopHLine(odocstream &, row_type row) const;
612         ///
613         int TeXBottomHLine(odocstream &, row_type row) const;
614         ///
615         int TeXCellPreamble(odocstream &, idx_type cell, bool & ismulticol) const;
616         ///
617         int TeXCellPostamble(odocstream &, idx_type cell, bool ismulticol) const;
618         ///
619         int TeXLongtableHeaderFooter(odocstream &, OutputParams const &) const;
620         ///
621         bool isValidRow(row_type const row) const;
622         ///
623         int TeXRow(odocstream &, row_type const row,
624                    OutputParams const &) const;
625         ///
626         // helper functions for plain text
627         ///
628         bool plaintextTopHLine(odocstream &, row_type row,
629                                std::vector<unsigned int> const &) const;
630         ///
631         bool plaintextBottomHLine(odocstream &, row_type row,
632                                   std::vector<unsigned int> const &) const;
633         ///
634         void plaintextPrintCell(odocstream &,
635                                 OutputParams const &,
636                                 idx_type cell, row_type row, col_type column,
637                                 std::vector<unsigned int> const &,
638                                 bool onlydata) const;
639         /// auxiliary function for docbook
640         int docbookRow(odocstream & os, row_type, OutputParams const &) const;
641
642         /// change associated Buffer
643         void setBuffer(Buffer const & buffer) { buffer_ = &buffer; }
644         /// retrieve associated Buffer
645         Buffer const & buffer() const { return *buffer_; }
646
647 private:
648         Buffer const * buffer_;
649
650 }; // Tabular
651
652
653 ///
654 class InsetTableCell : public InsetText
655 {
656 public:
657         ///
658         InsetTableCell(Buffer const & buf,
659                 Tabular::CellData const * cd, Tabular const * t);
660         ///
661         InsetCode lyxCode() const { return CELL_CODE; }
662         ///
663         Inset * clone() { return new InsetTableCell(*this); }
664         ///
665         virtual bool useEmptyLayout() const { return true; }
666         /// 
667         virtual bool forceEmptyLayout(idx_type = 0) const;
668         /// 
669         virtual bool allowParagraphCustomization(idx_type = 0) const;
670         ///
671         bool getStatus(Cursor & cur, FuncRequest const & cmd,
672                 FuncStatus & status) const;
673         ///
674         virtual bool neverIndent() { return true; }
675         ///
676         void setCellData(Tabular::CellData const * cd) { cell_data_ = cd; }
677         ///
678         void setTabular(Tabular const * t) { table_ = t; }
679 private:
680         /// unimplemented
681         InsetTableCell();
682         /// unimplemented
683         void operator=(InsetTableCell const &);
684
685         /// 
686         Tabular::CellData const * cell_data_;
687         /// 
688         Tabular const * table_;
689 };
690
691
692 class InsetTabular : public Inset
693 {
694 public:
695         ///
696         InsetTabular(Buffer const &, row_type rows = 1,
697                      col_type columns = 1);
698         ///
699         ~InsetTabular();
700         ///
701         static void string2params(std::string const &, InsetTabular &);
702         ///
703         static std::string params2string(InsetTabular const &);
704         ///
705         void read(Lexer &);
706         ///
707         void write(std::ostream &) const;
708         ///
709         void metrics(MetricsInfo &, Dimension &) const;
710         ///
711         void draw(PainterInfo & pi, int x, int y) const;
712         ///
713         void drawSelection(PainterInfo & pi, int x, int y) const;
714         ///
715         docstring editMessage() const;
716         ///
717         EDITABLE editable() const { return HIGHLY_EDITABLE; }
718         ///
719         bool insetAllowed(InsetCode code) const;
720         ///
721         bool allowSpellCheck() const { return true; }
722         ///
723         bool canTrackChanges() const { return true; }
724         /** returns true if, when outputing LaTeX, font changes should
725             be closed before generating this inset. This is needed for
726             insets that may contain several paragraphs */
727         bool noFontChange() const { return true; }
728         ///
729         DisplayType display() const { return tabular.isLongTabular() ? AlignCenter : Inline; }
730         ///
731         int latex(odocstream &, OutputParams const &) const;
732         ///
733         int plaintext(odocstream &, OutputParams const &) const;
734         ///
735         int docbook(odocstream &, OutputParams const &) const;
736         ///
737         void validate(LaTeXFeatures & features) const;
738         ///
739         InsetCode lyxCode() const { return TABULAR_CODE; }
740         /// get offset of this cursor slice relative to our upper left corner
741         void cursorPos(BufferView const & bv, CursorSlice const & sl,
742                 bool boundary, int & x, int & y) const;
743         ///
744         bool tabularFeatures(Cursor & cur, std::string const & what);
745         ///
746         void tabularFeatures(Cursor & cur, Tabular::Feature feature,
747                              std::string const & val = std::string());
748         ///
749         void openLayoutDialog(BufferView *) const;
750         ///
751         bool showInsetDialog(BufferView *) const;
752         /// number of cells
753         size_t nargs() const { return tabular.cellCount(); }
754         ///
755         boost::shared_ptr<InsetTableCell const> cell(idx_type) const;
756         ///
757         boost::shared_ptr<InsetTableCell> cell(idx_type);
758         ///
759         Text * getText(int) const;
760
761         /// set the change for the entire inset
762         void setChange(Change const & change);
763         /// accept the changes within the inset
764         void acceptChanges(BufferParams const & bparams);
765         /// reject the changes within the inset
766         void rejectChanges(BufferParams const & bparams);
767
768         // this should return true if we have a "normal" cell, otherwise false.
769         // "normal" means without width set!
770         /// should all paragraphs be output with "Standard" layout?
771         virtual bool allowParagraphCustomization(idx_type cell = 0) const;
772         ///
773         virtual bool forceEmptyLayout(idx_type cell = 0) const;
774         ///
775         virtual bool useEmptyLayout() { return true; }
776         ///
777         void addPreview(graphics::PreviewLoader &) const;
778
779         /// lock cell with given index
780         void edit(Cursor & cur, bool front, EntryDirection entry_from);
781         /// get table row from x coordinate
782         int rowFromY(Cursor & cur, int y) const;
783         /// get table column from y coordinate
784         int columnFromX(Cursor & cur, int x) const;
785         ///
786         Inset * editXY(Cursor & cur, int x, int y);
787         /// can we go further down on mouse click?
788         bool descendable() const { return true; }
789         // Update the counters of this inset and of its contents
790         void updateLabels(ParIterator const &);
791
792         ///
793         bool completionSupported(Cursor const &) const;
794         ///
795         bool inlineCompletionSupported(Cursor const & cur) const;
796         ///
797         bool automaticInlineCompletion() const;
798         ///
799         bool automaticPopupCompletion() const;
800         ///
801         bool showCompletionCursor() const;
802         ///
803         CompletionList const * createCompletionList(Cursor const & cur) const;
804         ///
805         docstring completionPrefix(Cursor const & cur) const;
806         ///
807         bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
808         ///
809         void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
810
811         //
812         // Public structures and variables
813         ///
814         mutable Tabular tabular;
815
816 private:
817         ///
818         InsetTabular(InsetTabular const &);
819         ///
820         void doDispatch(Cursor & cur, FuncRequest & cmd);
821         ///
822         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
823         ///
824         int scroll() const { return scx_; }
825         ///
826         Inset * clone() const { return new InsetTabular(*this); }
827
828         ///
829         void drawCellLines(frontend::Painter &, int x, int y, row_type row,
830                            idx_type cell, bool erased) const;
831         ///
832         void setCursorFromCoordinates(Cursor & cur, int x, int y) const;
833
834         ///
835         void moveNextCell(Cursor & cur);
836         ///
837         void movePrevCell(Cursor & cur);
838         ///
839         int cellXPos(idx_type cell) const;
840         ///
841         void resetPos(Cursor & cur) const;
842         ///
843         void removeTabularRow();
844         ///
845         bool copySelection(Cursor & cur);
846         ///
847         bool pasteClipboard(Cursor & cur);
848         ///
849         void cutSelection(Cursor & cur);
850         ///
851         bool isRightToLeft(Cursor & cur) const;
852         ///
853         void getSelection(Cursor & cur, row_type & rs, row_type & re,
854                           col_type & cs, col_type & ce) const;
855         ///
856         bool insertPlaintextString(BufferView &, docstring const & buf, bool usePaste);
857         /// are we operating on several cells?
858         bool tablemode(Cursor & cur) const;
859
860         /// return the "Manhattan distance" to nearest corner
861         int dist(BufferView &, idx_type cell, int x, int y) const;
862         /// return the cell nearest to x, y
863         idx_type getNearestCell(BufferView &, int x, int y) const;
864
865         /// test the rotation state of the give cell range.
866         bool oneCellHasRotationState(bool rotated,
867                                 row_type row_start, row_type row_end,
868                                 col_type col_start, col_type col_end) const;
869         ///
870         mutable idx_type first_visible_cell;
871         ///
872         mutable int scx_;
873         /// true when selecting rows with the mouse
874         bool rowselect_;
875         /// true when selecting columns with the mouse
876         bool colselect_;
877 };
878
879 std::string const featureAsString(Tabular::Feature feature);
880
881 } // namespace lyx
882
883 #endif // INSET_TABULAR_H