2000-04-19 14:42:19 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-09-14 17:53:12 +00:00
|
|
|
* Copyright 1995-2000 The LyX Team.
|
2000-04-19 14:42:19 +00:00
|
|
|
*
|
|
|
|
*======================================================
|
|
|
|
*/
|
|
|
|
// This is the rewrite of the tabular (table) support.
|
|
|
|
|
|
|
|
// It will probably be a lot of work.
|
|
|
|
|
|
|
|
// One first goal could be to make the inset read the old table format
|
|
|
|
// and just output it again... no viewing at all.
|
|
|
|
|
|
|
|
// When making the internal structure of tabular support I really think
|
|
|
|
// that STL containers should be used. This will separate the container from
|
|
|
|
// the rest of the code, which is a good thing.
|
|
|
|
|
|
|
|
// Ideally the tabular support should do as the mathed and use
|
|
|
|
// LaTeX in the .lyx file too.
|
|
|
|
|
|
|
|
// Things to think of when desingning the new tabular support:
|
|
|
|
// - color support (colortbl, color)
|
|
|
|
// - decimal alignment (dcloumn)
|
|
|
|
// - custom lines (hhline)
|
|
|
|
// - rotation
|
|
|
|
// - multicolumn
|
|
|
|
// - multirow
|
|
|
|
// - column styles
|
|
|
|
|
|
|
|
// This is what I have written about tabular support in the LyX3-Tasks file:
|
|
|
|
//
|
|
|
|
// o rewrite of table code. Should probably be written as some
|
|
|
|
// kind of an inset. At least get the code out of the kernel.
|
|
|
|
// - colortbl -multirow
|
|
|
|
// - hhline -multicolumn
|
|
|
|
// - dcolumn
|
|
|
|
// o enhance longtable support
|
|
|
|
|
|
|
|
// Lgb
|
|
|
|
|
|
|
|
#ifndef INSETTABULAR_H
|
|
|
|
#define INSETTABULAR_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "lyxinset.h"
|
2000-04-21 15:16:22 +00:00
|
|
|
#include "tabular.h"
|
2000-04-19 14:42:19 +00:00
|
|
|
#include "LString.h"
|
2000-04-21 15:16:22 +00:00
|
|
|
#include "lyxcursor.h"
|
2000-08-18 15:32:42 +00:00
|
|
|
#include "lyxfunc.h"
|
2000-04-19 14:42:19 +00:00
|
|
|
|
|
|
|
class LyXLex;
|
|
|
|
class Painter;
|
|
|
|
class BufferView;
|
|
|
|
class Buffer;
|
2000-07-11 15:08:54 +00:00
|
|
|
class Dialogs;
|
2000-04-19 14:42:19 +00:00
|
|
|
|
|
|
|
class InsetTabular : public UpdatableInset {
|
|
|
|
public:
|
2000-06-23 15:02:46 +00:00
|
|
|
///
|
|
|
|
enum UpdateCodes {
|
|
|
|
NONE = 0,
|
|
|
|
INIT,
|
|
|
|
FULL,
|
|
|
|
CELL,
|
|
|
|
CURSOR,
|
|
|
|
SELECTION
|
|
|
|
};
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-07-15 23:51:46 +00:00
|
|
|
InsetTabular(Buffer *, int rows = 1, int columns = 1);
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
InsetTabular(InsetTabular const &, Buffer *);
|
|
|
|
///
|
|
|
|
~InsetTabular();
|
|
|
|
///
|
2000-04-26 14:56:50 +00:00
|
|
|
Inset * Clone() const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
void Read(Buffer const *, LyXLex &);
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
void Write(Buffer const *, std::ostream &) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
int ascent(BufferView *, LyXFont const &) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
int descent(BufferView *, LyXFont const &) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
int width(BufferView *, LyXFont const & f) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-06-23 15:02:46 +00:00
|
|
|
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-07-15 23:51:46 +00:00
|
|
|
void update(BufferView *, LyXFont const &, bool = false);
|
2000-06-16 15:13:25 +00:00
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
string const EditMessage() const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
void Edit(BufferView *, int x, int y, unsigned int);
|
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
bool doClearArea() const { return !locked; };
|
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
void InsetUnlock(BufferView *);
|
|
|
|
///
|
2000-08-07 15:21:05 +00:00
|
|
|
void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-05-04 08:14:34 +00:00
|
|
|
bool LockInsetInInset(BufferView *, UpdatableInset *);
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-07-15 23:51:46 +00:00
|
|
|
bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
bool UpdateInsetInInset(BufferView *, Inset *);
|
|
|
|
///
|
2000-09-29 18:44:07 +00:00
|
|
|
unsigned int InsetInInsetY();
|
2000-05-04 08:14:34 +00:00
|
|
|
///
|
2000-05-15 14:49:36 +00:00
|
|
|
UpdatableInset * GetLockingInset();
|
|
|
|
///
|
|
|
|
UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
|
|
|
|
///
|
|
|
|
bool InsertInset(BufferView *, Inset *);
|
|
|
|
///
|
2000-07-14 14:57:20 +00:00
|
|
|
bool IsTextInset() const { return true; }
|
|
|
|
///
|
2000-04-21 15:16:22 +00:00
|
|
|
bool display() const { return tabular->IsLongTabular(); }
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
void InsetButtonRelease(BufferView *, int, int, int);
|
|
|
|
///
|
|
|
|
void InsetButtonPress(BufferView *, int, int, int);
|
|
|
|
///
|
|
|
|
void InsetMotionNotify(BufferView *, int, int, int);
|
|
|
|
///
|
|
|
|
void InsetKeyPress(XKeyEvent *);
|
|
|
|
///
|
|
|
|
UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
|
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
int Latex(Buffer const *, std::ostream &, bool, bool) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-09-26 15:25:14 +00:00
|
|
|
int Ascii(Buffer const *, std::ostream &, int linelen) const;
|
2000-04-24 20:58:23 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
int Linuxdoc(Buffer const *, std::ostream &) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
int DocBook(Buffer const *, std::ostream &) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
void Validate(LaTeXFeatures & features) const;
|
|
|
|
///
|
|
|
|
Inset::Code LyxCode() const { return Inset::TABULAR_CODE; }
|
|
|
|
///
|
2000-09-29 18:44:07 +00:00
|
|
|
void GetCursorPos(BufferView *, int & x, int & y) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
void ToggleInsetCursor(BufferView *);
|
|
|
|
///
|
2000-09-26 13:54:57 +00:00
|
|
|
bool TabularFeatures(BufferView * bv, string const & what);
|
2000-07-28 14:28:54 +00:00
|
|
|
///
|
2000-09-28 14:05:24 +00:00
|
|
|
void TabularFeatures(BufferView * bv, LyXTabular::Feature feature,
|
2000-09-26 13:54:57 +00:00
|
|
|
string const & val = string());
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-09-26 13:54:57 +00:00
|
|
|
int GetActCell() const { return actcell; }
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-05-04 08:14:34 +00:00
|
|
|
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
|
2000-05-15 14:49:36 +00:00
|
|
|
///
|
|
|
|
int getMaxWidth(Painter & pain, UpdatableInset const *) const;
|
|
|
|
///
|
|
|
|
Buffer * BufferOwner() const { return buffer; }
|
2000-07-14 14:57:20 +00:00
|
|
|
///
|
2000-07-19 08:37:26 +00:00
|
|
|
LyXText * getLyXText(BufferView *) const;
|
2000-09-26 13:54:57 +00:00
|
|
|
///
|
2000-07-14 14:57:20 +00:00
|
|
|
void resizeLyXText(BufferView *) const;
|
2000-09-26 13:54:57 +00:00
|
|
|
///
|
2000-08-01 09:35:42 +00:00
|
|
|
void OpenLayoutDialog(BufferView *) const;
|
2000-09-26 13:54:57 +00:00
|
|
|
///
|
|
|
|
LyXFunc::func_status getStatus(string const & argument) const;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
//
|
|
|
|
// Public structures and variables
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-04-21 15:16:22 +00:00
|
|
|
LyXTabular * tabular;
|
2000-04-19 14:42:19 +00:00
|
|
|
|
|
|
|
private:
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-07-15 23:51:46 +00:00
|
|
|
bool calculate_dimensions_of_cells(BufferView *, LyXFont const &,
|
2000-09-26 13:54:57 +00:00
|
|
|
bool = false) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-07-15 23:51:46 +00:00
|
|
|
void DrawCellLines(Painter &, int x, int baseline,
|
|
|
|
int row, int cell) const;
|
2000-05-22 15:20:02 +00:00
|
|
|
///
|
2000-05-26 13:09:14 +00:00
|
|
|
void DrawCellSelection(Painter &, int x, int baseline,
|
|
|
|
int row, int column, int cell) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-10-02 15:20:53 +00:00
|
|
|
void ShowInsetCursor(BufferView *, bool show=true);
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
void HideInsetCursor(BufferView *);
|
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
void setPos(BufferView *, int x, int y) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-07-15 23:51:46 +00:00
|
|
|
UpdatableInset::RESULT moveRight(BufferView *, bool lock = true);
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-07-15 23:51:46 +00:00
|
|
|
UpdatableInset::RESULT moveLeft(BufferView *, bool lock = true);
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-05-22 15:20:02 +00:00
|
|
|
UpdatableInset::RESULT moveUp(BufferView *);
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-05-22 15:20:02 +00:00
|
|
|
UpdatableInset::RESULT moveDown(BufferView *);
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-05-22 15:20:02 +00:00
|
|
|
bool moveNextCell(BufferView *);
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-05-22 15:20:02 +00:00
|
|
|
bool movePrevCell(BufferView *);
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
bool Delete();
|
|
|
|
///
|
2000-05-15 14:49:36 +00:00
|
|
|
int getCellXPos(int cell) const;
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-07-05 14:57:48 +00:00
|
|
|
void resetPos(BufferView *) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-04-21 15:16:22 +00:00
|
|
|
void RemoveTabularRow();
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-09-26 13:54:57 +00:00
|
|
|
bool hasSelection() const { return ((sel_pos_start != sel_pos_end) ||
|
2000-05-22 15:20:02 +00:00
|
|
|
(sel_cell_start != sel_cell_end));}
|
2000-05-04 08:14:34 +00:00
|
|
|
///
|
2000-07-15 23:51:46 +00:00
|
|
|
bool ActivateCellInset(BufferView *, int x = 0, int y = 0, int button = 0,
|
2000-05-15 14:49:36 +00:00
|
|
|
bool behind = false);
|
2000-05-04 08:14:34 +00:00
|
|
|
///
|
|
|
|
bool InsetHit(BufferView * bv, int x, int y) const;
|
2000-05-15 14:49:36 +00:00
|
|
|
///
|
|
|
|
int GetMaxWidthOfCell(Painter &, int cell) const;
|
2000-08-23 15:18:19 +00:00
|
|
|
///
|
2000-09-19 13:50:47 +00:00
|
|
|
bool hasPasteBuffer() const;
|
2000-08-23 15:18:19 +00:00
|
|
|
///
|
|
|
|
bool copySelection();
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-08-23 15:18:19 +00:00
|
|
|
bool pasteSelection(BufferView *);
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-08-23 15:18:19 +00:00
|
|
|
bool cutSelection();
|
2000-05-04 08:14:34 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
//
|
|
|
|
// Private structures and variables
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-07-15 23:51:46 +00:00
|
|
|
InsetText * the_locking_inset;
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-07-15 23:51:46 +00:00
|
|
|
Buffer * buffer;
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
|
|
|
mutable LyXCursor cursor;
|
|
|
|
///
|
|
|
|
mutable LyXCursor old_cursor;
|
|
|
|
///
|
|
|
|
mutable int inset_pos;
|
|
|
|
///
|
2000-09-29 18:44:07 +00:00
|
|
|
mutable unsigned int inset_x;
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-09-29 18:44:07 +00:00
|
|
|
mutable unsigned int inset_y;
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
|
|
|
mutable int sel_pos_start;
|
|
|
|
///
|
|
|
|
mutable int sel_pos_end;
|
|
|
|
///
|
|
|
|
mutable int sel_cell_start;
|
|
|
|
///
|
|
|
|
mutable int sel_cell_end;
|
|
|
|
///
|
|
|
|
mutable int actcell;
|
|
|
|
///
|
|
|
|
mutable int oldcell;
|
|
|
|
///
|
|
|
|
mutable int actcol;
|
|
|
|
///
|
|
|
|
mutable int actrow;
|
|
|
|
///
|
2000-06-22 14:55:46 +00:00
|
|
|
bool no_selection;
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-06-22 14:55:46 +00:00
|
|
|
mutable bool locked;
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-06-23 15:02:46 +00:00
|
|
|
mutable UpdateCodes need_update;
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-07-12 15:09:01 +00:00
|
|
|
mutable Dialogs * dialogs_;
|
2000-04-19 14:42:19 +00:00
|
|
|
};
|
|
|
|
#endif
|