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"
63 class InsetTabular : public UpdatableInset {
75 InsetTabular(Buffer *, int rows=1, int columns=1);
77 InsetTabular(InsetTabular const &, Buffer *);
81 Inset * Clone() const;
83 void Read(Buffer const *, LyXLex &);
85 void Write(Buffer const *, std::ostream &) const;
87 int ascent(BufferView *, LyXFont const &) const;
89 int descent(BufferView *, LyXFont const &) const;
91 int width(BufferView *, LyXFont const & f) const;
93 void draw(BufferView *, const LyXFont &, int , float &, bool) const;
95 void update(BufferView *, LyXFont const &, bool =false);
97 const char * EditMessage() const;
99 void Edit(BufferView *, int x, int y, unsigned int);
101 bool doClearArea() const { return !locked; };
103 void InsetUnlock(BufferView *);
105 void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty);
107 bool LockInsetInInset(BufferView *, UpdatableInset *);
109 bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr=false);
111 bool UpdateInsetInInset(BufferView *, Inset *);
115 UpdatableInset * GetLockingInset();
117 UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
119 bool InsertInset(BufferView *, Inset *);
121 bool IsTextInset() const { return true; }
123 bool display() const { return tabular->IsLongTabular(); }
125 void InsetButtonRelease(BufferView *, int, int, int);
127 void InsetButtonPress(BufferView *, int, int, int);
129 void InsetMotionNotify(BufferView *, int, int, int);
131 void InsetKeyPress(XKeyEvent *);
133 UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
135 int Latex(Buffer const *, std::ostream &, bool, bool) const;
137 int Ascii(Buffer const *, std::ostream &) const;
139 int Linuxdoc(Buffer const *, std::ostream &) const;
141 int DocBook(Buffer const *, std::ostream &) const;
143 void Validate(LaTeXFeatures & features) const;
145 Inset::Code LyxCode() const { return Inset::TABULAR_CODE; }
147 void GetCursorPos(BufferView *, int & x, int & y) const;
149 void ToggleInsetCursor(BufferView *);
151 void TabularFeatures(BufferView * bv, int feature, string val="");
153 int GetActCell() { return actcell; }
155 void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
157 int getMaxWidth(Painter & pain, UpdatableInset const *) const;
159 Buffer * BufferOwner() const { return buffer; }
161 void resizeLyXText(BufferView *) const;
164 /// Public structures and variables
166 LyXTabular * tabular;
169 bool calculate_dimensions_of_cells(BufferView *, LyXFont const &, bool =false) const;
171 void DrawCellLines(Painter &, int x, int baseline, int row, int cell)
174 void DrawCellSelection(Painter &, int x, int baseline,
175 int row, int column, int cell) const;
177 void ShowInsetCursor(BufferView *);
179 void HideInsetCursor(BufferView *);
181 void setPos(BufferView *, int x, int y) const;
183 UpdatableInset::RESULT moveRight(BufferView *, bool lock=true);
184 UpdatableInset::RESULT moveLeft(BufferView *, bool lock=true);
185 UpdatableInset::RESULT moveUp(BufferView *);
186 UpdatableInset::RESULT moveDown(BufferView *);
187 bool moveNextCell(BufferView *);
188 bool movePrevCell(BufferView *);
191 int getCellXPos(int cell) const;
192 void resetPos(BufferView *) const;
194 void RemoveTabularRow();
196 bool hasSelection() const {return ((sel_pos_start != sel_pos_end) ||
197 (sel_cell_start != sel_cell_end));}
199 bool ActivateCellInset(BufferView *, int x=0, int y=0, int button=0,
200 bool behind = false);
202 bool InsetHit(BufferView * bv, int x, int y) const;
204 int GetMaxWidthOfCell(Painter &, int cell) const;
206 void recomputeTextInsets(BufferView *, const LyXFont &) const;
209 /// Private structures and variables
231 mutable UpdateCodes need_update;
232 mutable Dialogs * dialogs_;