2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright (C) 1995-2000 The LyX Team.
9 *======================================================
11 // This is the rewrite of the tabular (table) support.
13 // It will probably be a lot of work.
15 // One first goal could be to make the inset read the old table format
16 // and just output it again... no viewing at all.
18 // When making the internal structure of tabular support I really think
19 // that STL containers should be used. This will separate the container from
20 // the rest of the code, which is a good thing.
22 // Ideally the tabular support should do as the mathed and use
23 // LaTeX in the .lyx file too.
25 // Things to think of when desingning the new tabular support:
26 // - color support (colortbl, color)
27 // - decimal alignment (dcloumn)
28 // - custom lines (hhline)
34 // This is what I have written about tabular support in the LyX3-Tasks file:
36 // o rewrite of table code. Should probably be written as some
37 // kind of an inset. At least get the code out of the kernel.
38 // - colortbl -multirow
39 // - hhline -multicolumn
41 // o enhance longtable support
45 #ifndef INSETTABULAR_H
46 #define INSETTABULAR_H
55 #include "lyxcursor.h"
62 class InsetTabular : public UpdatableInset {
65 InsetTabular(Buffer *, int rows=1, int columns=1);
67 InsetTabular(InsetTabular const &, Buffer *);
71 Inset * Clone() const;
75 void Write(std::ostream &) const;
77 int ascent(Painter &, LyXFont const &) const;
79 int descent(Painter &, LyXFont const &) const;
81 int width(Painter &, LyXFont const & f) const;
83 void draw(Painter & pain, const LyXFont &, int , float &) const;
85 const char * EditMessage() const;
87 void Edit(BufferView *, int x, int y, unsigned int);
89 void InsetUnlock(BufferView *);
91 void UpdateLocal(BufferView *, bool flag = true);
93 bool LockInsetInInset(BufferView *, UpdatableInset *);
95 bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr=false);
97 bool UpdateInsetInInset(BufferView *, Inset *);
101 bool display() const { return tabular->IsLongTabular(); }
103 void InsetButtonRelease(BufferView *, int, int, int);
105 void InsetButtonPress(BufferView *, int, int, int);
107 void InsetMotionNotify(BufferView *, int, int, int);
109 void InsetKeyPress(XKeyEvent *);
111 UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
113 int Latex(std::ostream &, bool, bool) const;
115 int Ascii(std::ostream &) const;
117 int Linuxdoc(std::ostream &) const;
119 int DocBook(std::ostream &) const;
121 void Validate(LaTeXFeatures & features) const;
123 Inset::Code LyxCode() const { return Inset::TABULAR_CODE; }
125 void GetCursorPos(int & x, int & y) const;
127 void ToggleInsetCursor(BufferView *);
129 void TabularFeatures(int feature, string val="");
131 int GetActCell() { return actcell; }
133 void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
135 /// Public structures and variables
137 LyXTabular * tabular;
140 void calculate_width_of_cells(Painter &, LyXFont const &) const;
142 void DrawCellLines(Painter &, int x, int baseline, int row, int cell) const;
144 void ShowInsetCursor(BufferView *);
146 void HideInsetCursor(BufferView *);
148 void setPos(Painter &, int x, int y) const;
150 bool SetCellDimensions(Painter & pain, int cell, int row);
152 UpdatableInset::RESULT moveRight(BufferView *, bool lock=true);
153 UpdatableInset::RESULT moveLeft(BufferView *, bool lock=true);
154 UpdatableInset::RESULT moveUp();
155 UpdatableInset::RESULT moveDown();
160 void resetPos(Painter &) const;
162 void RemoveTabularRow();
164 bool hasCharSelection() const {return (sel_pos_start != sel_pos_end);}
165 bool hasCellSelection() const {return hasCharSelection() &&
166 (sel_cell_start != sel_cell_end);}
168 bool ActivateCellInset(BufferView *, int x=0, int y=0, int button=0);
170 bool InsetHit(BufferView * bv, int x, int y) const;
173 /// Private structures and variables