2000-04-19 14:42:19 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995-2000 The LyX Team.
|
|
|
|
*
|
|
|
|
*======================================================
|
|
|
|
*/
|
|
|
|
// 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-04-19 14:42:19 +00:00
|
|
|
|
|
|
|
class LyXLex;
|
|
|
|
class Painter;
|
|
|
|
class BufferView;
|
|
|
|
class Buffer;
|
|
|
|
|
|
|
|
class InsetTabular : public UpdatableInset {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
InsetTabular(Buffer *, int rows=1, int columns=1);
|
|
|
|
///
|
|
|
|
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
|
|
|
///
|
|
|
|
int ascent(Painter &, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int descent(Painter &, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int width(Painter &, LyXFont const & f) const;
|
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
void draw(BufferView *, const LyXFont &, int , float &) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-06-21 15:07:57 +00:00
|
|
|
void update(BufferView *, LyXFont const &, bool);
|
2000-06-16 15:13:25 +00:00
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
const char * EditMessage() const;
|
|
|
|
///
|
|
|
|
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-06-16 15:13:25 +00:00
|
|
|
void UpdateLocal(BufferView *, bool what, bool mark_dirty);
|
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-05-04 08:14:34 +00:00
|
|
|
bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr=false);
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
bool UpdateInsetInInset(BufferView *, Inset *);
|
|
|
|
///
|
2000-05-04 08:14:34 +00:00
|
|
|
int InsetInInsetY();
|
|
|
|
///
|
2000-05-15 14:49:36 +00:00
|
|
|
UpdatableInset * GetLockingInset();
|
|
|
|
///
|
|
|
|
UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
|
|
|
|
///
|
|
|
|
bool InsertInset(BufferView *, Inset *);
|
|
|
|
///
|
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-06-12 11:27:15 +00:00
|
|
|
int Ascii(Buffer const *, std::ostream &) 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-06-22 10:43:59 +00:00
|
|
|
void GetCursorPos(BufferView *, int & x, int & y) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
void ToggleInsetCursor(BufferView *);
|
|
|
|
///
|
2000-05-05 14:45:59 +00:00
|
|
|
void TabularFeatures(BufferView * bv, int feature, string val="");
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
int GetActCell() { return actcell; }
|
|
|
|
///
|
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-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
/// Public structures and variables
|
|
|
|
///
|
2000-04-21 15:16:22 +00:00
|
|
|
LyXTabular * tabular;
|
2000-04-19 14:42:19 +00:00
|
|
|
|
|
|
|
private:
|
2000-06-21 15:07:57 +00:00
|
|
|
void calculate_width_of_cells(BufferView *, LyXFont const &, bool =false) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-05-22 15:20:02 +00:00
|
|
|
void DrawCellLines(Painter &, int x, int baseline, int row, int cell)
|
|
|
|
const;
|
|
|
|
///
|
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
|
|
|
///
|
|
|
|
void ShowInsetCursor(BufferView *);
|
|
|
|
///
|
|
|
|
void HideInsetCursor(BufferView *);
|
|
|
|
///
|
2000-04-21 15:16:22 +00:00
|
|
|
void setPos(Painter &, int x, int y) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-05-04 08:14:34 +00:00
|
|
|
bool SetCellDimensions(Painter & pain, int cell, int row);
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
2000-05-04 08:14:34 +00:00
|
|
|
UpdatableInset::RESULT moveRight(BufferView *, bool lock=true);
|
|
|
|
UpdatableInset::RESULT moveLeft(BufferView *, bool lock=true);
|
2000-05-22 15:20:02 +00:00
|
|
|
UpdatableInset::RESULT moveUp(BufferView *);
|
|
|
|
UpdatableInset::RESULT moveDown(BufferView *);
|
|
|
|
bool moveNextCell(BufferView *);
|
|
|
|
bool movePrevCell(BufferView *);
|
2000-04-19 14:42:19 +00:00
|
|
|
bool Delete();
|
|
|
|
///
|
2000-05-15 14:49:36 +00:00
|
|
|
int getCellXPos(int cell) const;
|
2000-05-04 08:14:34 +00:00
|
|
|
void resetPos(Painter &) 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-05-22 15:20:02 +00:00
|
|
|
bool hasSelection() const {return ((sel_pos_start != sel_pos_end) ||
|
|
|
|
(sel_cell_start != sel_cell_end));}
|
2000-05-04 08:14:34 +00:00
|
|
|
///
|
2000-05-15 14:49:36 +00:00
|
|
|
bool ActivateCellInset(BufferView *, int x=0, int y=0, int button=0,
|
|
|
|
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-06-16 15:13:25 +00:00
|
|
|
void recomputeTextInsets(BufferView *, const LyXFont &) const;
|
2000-05-04 08:14:34 +00:00
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
/// Private structures and variables
|
|
|
|
///
|
2000-05-04 08:14:34 +00:00
|
|
|
InsetText
|
2000-04-19 14:42:19 +00:00
|
|
|
* the_locking_inset;
|
|
|
|
Buffer
|
|
|
|
* buffer;
|
2000-04-21 15:16:22 +00:00
|
|
|
mutable LyXCursor
|
|
|
|
cursor,
|
|
|
|
old_cursor;
|
|
|
|
mutable int
|
2000-04-19 14:42:19 +00:00
|
|
|
inset_pos,
|
|
|
|
inset_x, inset_y,
|
|
|
|
sel_pos_start,
|
|
|
|
sel_pos_end,
|
|
|
|
sel_cell_start,
|
|
|
|
sel_cell_end,
|
|
|
|
actcell,
|
2000-05-16 15:17:19 +00:00
|
|
|
oldcell,
|
2000-04-19 14:42:19 +00:00
|
|
|
actcol,
|
|
|
|
actrow;
|
|
|
|
bool
|
2000-05-16 15:17:19 +00:00
|
|
|
locked,
|
2000-04-19 14:42:19 +00:00
|
|
|
no_selection;
|
|
|
|
mutable bool
|
2000-05-15 14:49:36 +00:00
|
|
|
init_inset;
|
2000-04-19 14:42:19 +00:00
|
|
|
};
|
|
|
|
#endif
|