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
|
|
|
///
|
|
|
|
void Read(LyXLex &);
|
|
|
|
///
|
|
|
|
void Write(std::ostream &) const;
|
|
|
|
///
|
|
|
|
int ascent(Painter &, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int descent(Painter &, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int width(Painter &, LyXFont const & f) const;
|
|
|
|
///
|
|
|
|
void draw(Painter & pain, const LyXFont &, int , float &) const;
|
|
|
|
///
|
|
|
|
const char * EditMessage() const;
|
|
|
|
///
|
|
|
|
void Edit(BufferView *, int x, int y, unsigned int);
|
|
|
|
///
|
|
|
|
void InsetUnlock(BufferView *);
|
|
|
|
///
|
2000-05-04 08:14:34 +00:00
|
|
|
void UpdateLocal(BufferView *, bool flag = true);
|
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-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 &);
|
|
|
|
///
|
|
|
|
int Latex(std::ostream &, bool, bool) const;
|
|
|
|
///
|
2000-04-24 20:58:23 +00:00
|
|
|
int Ascii(std::ostream &) const;
|
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
int Linuxdoc(std::ostream &) const;
|
|
|
|
///
|
|
|
|
int DocBook(std::ostream &) const;
|
|
|
|
///
|
|
|
|
void Validate(LaTeXFeatures & features) const;
|
|
|
|
///
|
|
|
|
Inset::Code LyxCode() const { return Inset::TABULAR_CODE; }
|
|
|
|
///
|
2000-05-04 08:14:34 +00:00
|
|
|
void GetCursorPos(int & x, int & y) const;
|
2000-04-19 14:42:19 +00:00
|
|
|
///
|
|
|
|
void ToggleInsetCursor(BufferView *);
|
|
|
|
///
|
2000-04-21 15:16:22 +00:00
|
|
|
void TabularFeatures(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-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:
|
|
|
|
void calculate_width_of_cells(Painter &, LyXFont const &) const;
|
|
|
|
///
|
2000-04-21 15:16:22 +00:00
|
|
|
void DrawCellLines(Painter &, int x, int baseline, int row, 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-04-21 15:16:22 +00:00
|
|
|
UpdatableInset::RESULT moveUp();
|
|
|
|
UpdatableInset::RESULT moveDown();
|
2000-04-19 14:42:19 +00:00
|
|
|
bool moveNextCell();
|
|
|
|
bool movePrevCell();
|
|
|
|
bool Delete();
|
|
|
|
///
|
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
|
|
|
///
|
|
|
|
bool hasCharSelection() const {return (sel_pos_start != sel_pos_end);}
|
|
|
|
bool hasCellSelection() const {return hasCharSelection() &&
|
|
|
|
(sel_cell_start != sel_cell_end);}
|
2000-05-04 08:14:34 +00:00
|
|
|
///
|
|
|
|
bool ActivateCellInset(BufferView *, int x=0, int y=0, int button=0);
|
|
|
|
///
|
|
|
|
bool InsetHit(BufferView * bv, int x, int y) const;
|
|
|
|
|
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,
|
|
|
|
actcol,
|
|
|
|
actrow;
|
|
|
|
bool
|
|
|
|
no_selection;
|
|
|
|
mutable bool
|
|
|
|
init;
|
|
|
|
};
|
|
|
|
#endif
|