]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.h
* ANNOUNCE
[lyx.git] / src / insets / InsetTabular.h
index e0c4326c4e40c8834315e8e16dc5e06710e72901..1c97c173aaee7af8e41d9ed6781885ceea671b16 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "Inset.h"
 #include "InsetText.h"
-#include "Layout.h"
 #include "Length.h"
 
 #include "support/shared_ptr.h"
@@ -38,19 +37,84 @@ namespace lyx {
 class Buffer;
 class BufferView;
 class CompletionList;
+class Cursor;
 class CursorSlice;
-class InsetTableCell;
 class FuncStatus;
 class Lexer;
+class OutputParams;
 class Paragraph;
 class XHTMLStream;
 
-namespace frontend { class Painter; }
 
+///
+class InsetTableCell : public InsetText
+{
+public:
+       ///
+       InsetTableCell(Buffer * buf);
+       ///
+       InsetCode lyxCode() const { return CELL_CODE; }
+       ///
+       Inset * clone() { return new InsetTableCell(*this); }
+       ///
+       bool getStatus(Cursor & cur, FuncRequest const & cmd,
+               FuncStatus & status) const;
+       ///
+       void toggleFixedWidth(bool fw) { isFixedWidth = fw; }
+       ///
+       void setContentAlignment(LyXAlignment al) {contentAlign = al; }
+       /// writes the contents of the cell as a string, optionally
+       /// descending into insets
+       docstring asString(bool intoInsets = true);
+       ///
+       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+private:
+       /// unimplemented
+       InsetTableCell();
+       /// unimplemented
+       void operator=(InsetTableCell const &);
+       // FIXME
+       // This boolean is supposed to track whether the cell has had its
+       // width explicitly set. We need to know this to determine whether
+       // layout changes and paragraph customization are allowed---that is,
+       // we need it in forcePlainLayout() and allowParagraphCustomization(). 
+       // Unfortunately, that information is not readily available in 
+       // InsetTableCell. In the case of multicolumn cells, it is present
+       // in CellData, and so would be available here if CellData were to
+       // become a member of InsetTableCell. But in the other case, it isn't
+       // even available there, but is held in Tabular::ColumnData.
+       // So, the present solution uses this boolean to track the information
+       // we need to track, and tries to keep it updated. This is not ideal,
+       // but the other solutions are no better. These are:
+       // (i)  Keep a pointer in InsetTableCell to the table;
+       // (ii) Find the table by iterating over the Buffer's insets.
+       // Solution (i) raises the problem of updating the pointer when an 
+       // InsetTableCell is copied, and we'd therefore need a copy constructor
+       // in InsetTabular and then in Tabular, which seems messy, given how 
+       // complicated those classes are. Solution (ii) involves a lot of 
+       // iterating, since this information is needed quite often, and so may
+       // be quite slow.
+       // So, well, if someone can do better, please do!
+       // --rgh
+       ///
+       bool isFixedWidth;
+       // FIXME: Here the thoughts from the comment above also apply.
+       ///
+       LyXAlignment contentAlign;
+       /// should paragraph indendation be omitted in any case?
+       bool neverIndent() const { return true; }
+       ///
+       LyXAlignment contentAlignment() const { return contentAlign; }
+       ///
+       virtual bool usePlainLayout() const { return true; }
+       /// 
+       virtual bool forcePlainLayout(idx_type = 0) const;
+       /// 
+       virtual bool allowParagraphCustomization(idx_type = 0) const;
+       /// Is the width forced to some value?
+       bool hasFixedWidth() const { return isFixedWidth; }
+};
 
-class InsetTabular;
-class Cursor;
-class OutputParams;
 
 //
 // A helper struct for tables
@@ -96,6 +160,8 @@ public:
                ///
                ALIGN_BLOCK,
                ///
+               ALIGN_DECIMAL,
+               ///
                VALIGN_TOP,
                ///
                VALIGN_BOTTOM,
@@ -116,8 +182,16 @@ public:
                ///
                MULTICOLUMN,
                ///
+               SET_MULTICOLUMN,
+               ///
+               UNSET_MULTICOLUMN,
+               ///
                MULTIROW,
                ///
+               SET_MULTIROW,
+               ///
+               UNSET_MULTIROW,
+               ///
                SET_ALL_LINES,
                ///
                UNSET_ALL_LINES,
@@ -160,12 +234,14 @@ public:
                ///
                TOGGLE_LTCAPTION,
                ///
+               SET_LTCAPTION,
+               ///
+               UNSET_LTCAPTION,
+               ///
                SET_SPECIAL_COLUMN,
                ///
                SET_SPECIAL_MULTICOLUMN,
                ///
-               SET_SPECIAL_MULTIROW,
-               ///
                SET_BOOKTABS,
                ///
                UNSET_BOOKTABS,
@@ -190,6 +266,8 @@ public:
                ///
                LONGTABULAR_ALIGN_RIGHT,
                ///
+               SET_DECIMAL_POINT,
+               ///
                LAST_ACTION
        };
        ///
@@ -280,7 +358,7 @@ public:
 
        /* returns the maximum over all rows */
        ///
-       int columnWidth(idx_type cell) const;
+       int cellWidth(idx_type cell) const;
        ///
        int cellHeight(idx_type cell) const;
        ///
@@ -300,8 +378,6 @@ public:
        ///
        void setRowDescent(row_type row, int height);
        ///
-       void setCellWidth(idx_type cell, int new_width);
-       ///
        void setTopLine(idx_type cell, bool line);
        ///
        void setBottomLine(idx_type cell, bool line);
@@ -339,8 +415,6 @@ public:
        ///
        Length const getPWidth(idx_type cell) const;
        ///
-       int cellWidth(idx_type cell) const;
-       ///
        int textHOffset(idx_type cell) const;
        ///
        int textVOffset(idx_type cell) const;
@@ -490,6 +564,10 @@ public:
                LyXAlignment alignment;
                ///
                VAlignment valignment;
+               /// width of the part before the decimal
+               int decimal_hoffset;
+               /// width of the decimal part
+               int decimal_width;
                ///
                int voffset;
                ///
@@ -570,6 +648,8 @@ public:
                Length p_width;
                ///
                docstring align_special;
+               ///
+               docstring decimal_point;
        };
        ///
        typedef std::vector<ColumnData> column_vector;
@@ -614,8 +694,6 @@ public:
        void updateIndexes();
        ///
        bool setFixedWidth(row_type r, col_type c);
-       ///
-       void updateContentAlignment(row_type r, col_type c);
        /// return true of update is needed
        bool updateColumnWidths();
        ///
@@ -671,76 +749,6 @@ private:
 }; // Tabular
 
 
-///
-class InsetTableCell : public InsetText
-{
-public:
-       ///
-       InsetTableCell(Buffer * buf);
-       ///
-       InsetCode lyxCode() const { return CELL_CODE; }
-       ///
-       Inset * clone() { return new InsetTableCell(*this); }
-       ///
-       bool getStatus(Cursor & cur, FuncRequest const & cmd,
-               FuncStatus & status) const;
-       ///
-       void toggleFixedWidth(bool fw) { isFixedWidth = fw; }
-       ///
-       void setContentAlignment(LyXAlignment al) {contentAlign = al; }
-       /// writes the contents of the cell as a string, optionally
-       /// descending into insets
-       docstring asString(bool intoInsets = true);
-       ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
-private:
-       /// unimplemented
-       InsetTableCell();
-       /// unimplemented
-       void operator=(InsetTableCell const &);
-       // FIXME
-       // This boolean is supposed to track whether the cell has had its
-       // width explicitly set. We need to know this to determine whether
-       // layout changes and paragraph customization are allowed---that is,
-       // we need it in forcePlainLayout() and allowParagraphCustomization(). 
-       // Unfortunately, that information is not readily available in 
-       // InsetTableCell. In the case of multicolumn cells, it is present
-       // in CellData, and so would be available here if CellData were to
-       // become a member of InsetTableCell. But in the other case, it isn't
-       // even available there, but is held in Tabular::ColumnData.
-       // So, the present solution uses this boolean to track the information
-       // we need to track, and tries to keep it updated. This is not ideal,
-       // but the other solutions are no better. These are:
-       // (i)  Keep a pointer in InsetTableCell to the table;
-       // (ii) Find the table by iterating over the Buffer's insets.
-       // Solution (i) raises the problem of updating the pointer when an 
-       // InsetTableCell is copied, and we'd therefore need a copy constructor
-       // in InsetTabular and then in Tabular, which seems messy, given how 
-       // complicated those classes are. Solution (ii) involves a lot of 
-       // iterating, since this information is needed quite often, and so may
-       // be quite slow.
-       // So, well, if someone can do better, please do!
-       // --rgh
-       ///
-       bool isFixedWidth;
-       // FIXME: Here the thoughts from the comment above also apply.
-       ///
-       LyXAlignment contentAlign;
-       /// should paragraph indendation be omitted in any case?
-       bool neverIndent() const { return true; }
-       ///
-       LyXAlignment contentAlignment() const { return contentAlign; }
-       ///
-       virtual bool usePlainLayout() const { return true; }
-       /// 
-       virtual bool forcePlainLayout(idx_type = 0) const;
-       /// 
-       virtual bool allowParagraphCustomization(idx_type = 0) const;
-       /// Is the width forced to some value?
-       bool hasFixedWidth() const { return isFixedWidth; }
-};
-
-
 class InsetTabular : public Inset
 {
 public:
@@ -896,8 +904,8 @@ private:
        Inset * clone() const { return new InsetTabular(*this); }
 
        ///
-       void drawCellLines(frontend::Painter &, int x, int y, row_type row,
-                          idx_type cell, Change const & change) const;
+       void drawCellLines(PainterInfo &, int x, int y, row_type row,
+                          idx_type cell) const;
        ///
        void setCursorFromCoordinates(Cursor & cur, int x, int y) const;
 
@@ -944,6 +952,9 @@ private:
 
 std::string const featureAsString(Tabular::Feature feature);
 
+/// Split cell on decimal symbol
+InsetTableCell splitCell(InsetTableCell & head, docstring const decimal_sym, bool & hassep);
+
 } // namespace lyx
 
 #endif // INSET_TABULAR_H