]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.h
Fix GRAPHICS_EDIT of InsetGraphics
[lyx.git] / src / insets / InsetTabular.h
index a4ec860ba4a73ef275c12c7c0d90eb95a559f37d..f71a9e59854b487cfba6cd8fb88a48242418a350 100644 (file)
@@ -4,7 +4,6 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Jürgen Vigna
  * \author Lars Gullik Bjønnes
  * \author Matthias Ettrich
  * \author André Pönitz
 
 namespace lyx {
 
-class FuncStatus;
-class Lexer;
-class BufferView;
 class Buffer;
 class BufferParams;
-class Paragraph;
+class BufferView;
 class CompletionList;
 class CursorSlice;
+class InsetTableCell;
+class FuncStatus;
+class Lexer;
+class Paragraph;
 
 namespace frontend { class Painter; }
 
@@ -107,14 +107,6 @@ public:
                ///
                VALIGN_MIDDLE,
                ///
-               M_TOGGLE_LINE_TOP,
-               ///
-               M_TOGGLE_LINE_BOTTOM,
-               ///
-               M_TOGGLE_LINE_LEFT,
-               ///
-               M_TOGGLE_LINE_RIGHT,
-               ///
                M_ALIGN_LEFT,
                ///
                M_ALIGN_RIGHT,
@@ -183,6 +175,8 @@ public:
                ///
                SET_INTERLINE_SPACE,
                ///
+               SET_BORDER_LINES,
+               ///
                LAST_ACTION
        };
        ///
@@ -245,13 +239,13 @@ public:
        Tabular(Buffer const &, col_type columns_arg, row_type rows_arg);
 
        /// Returns true if there is a topline, returns false if not
-       bool topLine(idx_type cell, bool wholerow = false) const;
+       bool topLine(idx_type cell) const;
        /// Returns true if there is a topline, returns false if not
-       bool bottomLine(idx_type cell, bool wholerow = false) const;
+       bool bottomLine(idx_type cell) const;
        /// Returns true if there is a topline, returns false if not
-       bool leftLine(idx_type cell, bool wholecolumn = false) const;
+       bool leftLine(idx_type cell) const;
        /// Returns true if there is a topline, returns false if not
-       bool rightLine(idx_type cell, bool wholecolumn = false) const;
+       bool rightLine(idx_type cell) const;
 
        ///
        bool topAlreadyDrawn(idx_type cell) const;
@@ -286,14 +280,22 @@ public:
        ///
        void setAllLines(idx_type cell, bool line);
        ///
-       void setTopLine(idx_type cell, bool line, bool wholerow = false);
+       void setTopLine(idx_type cell, bool line);
+       ///
+       void setBottomLine(idx_type cell, bool line);
+       ///
+       void setLeftLine(idx_type cell, bool line);
+       ///
+       void setRightLine(idx_type cell, bool line);
        ///
-       void setBottomLine(idx_type cell, bool line, bool wholerow = false);
+       bool rowTopLine(row_type row) const;
        ///
-       void setLeftLine(idx_type cell, bool line, bool wholecolumn = false);
+       bool rowBottomLine(row_type row) const;
        ///
-       void setRightLine(idx_type cell, bool line, bool wholecolumn = false);
+       bool columnLeftLine(col_type column) const;
        ///
+       bool columnRightLine(col_type column) const;
+
        void setAlignment(idx_type cell, LyXAlignment align,
                          bool onlycolumn = false);
        ///
@@ -401,10 +403,6 @@ public:
        ///
        idx_type getCellBelow(idx_type cell) const;
        ///
-       idx_type getLastCellAbove(idx_type cell) const;
-       ///
-       idx_type getLastCellBelow(idx_type cell) const;
-       ///
        idx_type cellIndex(row_type row, col_type column) const;
        ///
        void setUsebox(idx_type cell, BoxType);
@@ -441,13 +439,13 @@ public:
        ///
        // end longtable support
        ///
-       boost::shared_ptr<InsetText> getCellInset(idx_type cell) const;
+       boost::shared_ptr<InsetTableCell> getCellInset(idx_type cell) const;
        ///
-       boost::shared_ptr<InsetText> getCellInset(row_type row,
+       boost::shared_ptr<InsetTableCell> getCellInset(row_type row,
                                                  col_type column) const;
        ///
        void setCellInset(row_type row, col_type column,
-                         boost::shared_ptr<InsetText>) const;
+                         boost::shared_ptr<InsetTableCell>) const;
        /// Search for \param inset in the tabular, with the
        ///
        idx_type getCellFromInset(Inset const * inset) const;
@@ -463,7 +461,7 @@ public:
        class CellData {
        public:
                ///
-               CellData(Buffer const &);
+               CellData(Buffer const &, Tabular const &);
                ///
                CellData(CellData const &);
                ///
@@ -497,7 +495,7 @@ public:
                ///
                Length p_width; // this is only set for multicolumn!!!
                ///
-               boost::shared_ptr<InsetText> inset;
+               boost::shared_ptr<InsetTableCell> inset;
        };
        CellData & cellinfo_of_cell(idx_type cell) const;
        ///
@@ -611,7 +609,7 @@ public:
        ///
        bool calculate_width_of_column_NMC(col_type column); // no multi cells
        ///
-       idx_type cells_in_multicolumn(idx_type cell) const;
+       idx_type columnSpan(idx_type cell) const;
        ///
        BoxType useParbox(idx_type cell) const;
        ///
@@ -658,9 +656,45 @@ private:
 
        /// renumber cells after structural changes
        void fixCellNums();
-};
+}; // Tabular
 
 
+///
+class InsetTableCell : public InsetText {
+public:
+       ///
+       explicit InsetTableCell(Buffer const & buf,
+               Tabular::CellData const * cd, Tabular const * t);
+       ///
+       virtual InsetCode lyxCode() const { return CELL_CODE; }
+       ///
+       Inset * clone() { return new InsetTableCell(*this); }
+       ///
+       virtual bool useEmptyLayout() const { return true; }
+       /// 
+       virtual bool forceEmptyLayout(idx_type = 0) const;
+       /// 
+       virtual bool allowParagraphCustomization(idx_type = 0) const;
+       ///
+       bool getStatus(Cursor & cur, FuncRequest const & cmd,
+               FuncStatus & status) const;
+       ///
+       virtual bool neverIndent() { return true; }
+       ///
+       void setCellData(Tabular::CellData const * cd) { cell_data_ = cd; }
+       ///
+       void setTabular(Tabular const * t) { table_ = t; }
+private:
+       /// 
+       Tabular::CellData const * cell_data_;
+       /// 
+       Tabular const * table_;
+       /// unimplemented
+       InsetTableCell();
+       /// unimplemented
+       void operator=(InsetTableCell const &);
+};
+
 
 class InsetTabular : public Inset {
 public:
@@ -720,9 +754,9 @@ public:
        /// number of cells
        size_t nargs() const { return tabular.cellCount(); }
        ///
-       boost::shared_ptr<InsetText const> cell(idx_type) const;
+       boost::shared_ptr<InsetTableCell const> cell(idx_type) const;
        ///
-       boost::shared_ptr<InsetText> cell(idx_type);
+       boost::shared_ptr<InsetTableCell> cell(idx_type);
        ///
        Text * getText(int) const;
 
@@ -738,12 +772,18 @@ public:
        /// should all paragraphs be output with "Standard" layout?
        virtual bool allowParagraphCustomization(idx_type cell = 0) const;
        ///
-       virtual bool forceEmptyLayout() { return true; }
+       virtual bool forceEmptyLayout(idx_type cell = 0) const;
+       ///
+       virtual bool useEmptyLayout() { return true; }
        ///
        void addPreview(graphics::PreviewLoader &) const;
 
        /// lock cell with given index
        void edit(Cursor & cur, bool front, EntryDirection entry_from);
+       /// get table row from x coordinate
+       int rowFromY(Cursor & cur, int y) const;
+       /// get table column from y coordinate
+       int columnFromX(Cursor & cur, int x) const;
        ///
        Inset * editXY(Cursor & cur, int x, int y);
        /// can we go further down on mouse click?