]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.h
* src/insets/InsetTabular.h:
[lyx.git] / src / insets / InsetTabular.h
index 27b059dd0ecad5a816f07a876a3420b877b0c994..5cf3d7eb3deac7915b087557c3fca708638e2646 100644 (file)
@@ -431,16 +431,18 @@ public:
                          boost::shared_ptr<InsetTableCell>) const;
        /// Search for \param inset in the tabular, with the
        ///
-       idx_type cellFromInset(Inset const * inset) const;
-       ///
        void validate(LaTeXFeatures &) const;
-       ///
 //private:
+  // FIXME Now that cells have an InsetTableCell as their insets, rather
+  // than an InsetText, it'd be possible to reverse the relationship here,
+  // so that cell_vector was a vector<InsetTableCell> rather than a 
+  // vector<CellData>, and an InsetTableCell had a CellData as a member,
+  // or perhaps just had its members as members.
        ///
        class CellData {
        public:
                ///
-               CellData(Buffer const &, Tabular const &);
+               CellData(Buffer const &);
                ///
                CellData(CellData const &);
                ///
@@ -573,6 +575,8 @@ public:
                  col_type columns_arg);
        ///
        void updateIndexes();
+       ///
+       bool setFixedWidth(row_type r, col_type c);
        /// return true of update is needed
        bool updateColumnWidths();
        ///
@@ -629,37 +633,54 @@ class InsetTableCell : public InsetText
 {
 public:
        ///
-       InsetTableCell(Buffer const & buf,
-               Tabular::CellData const * cd, Tabular const * t);
+       InsetTableCell(Buffer const & buf);
        ///
        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; }
+       void toggleFixedWidth(bool fw) { isFixedWidth = fw; }
 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;
+       /// should paragraph indendation be omitted in any case?
+       bool neverIndent() const { return true; }
+       ///
+       virtual bool usePlainLayout() const { return true; }
        /// 
-       Tabular::CellData const * cell_data_;
+       virtual bool forcePlainLayout(idx_type = 0) const;
        /// 
-       Tabular const * table_;
+       virtual bool allowParagraphCustomization(idx_type = 0) const;
 };
 
 
@@ -746,9 +767,9 @@ public:
        /// should all paragraphs be output with "Standard" layout?
        virtual bool allowParagraphCustomization(idx_type cell = 0) const;
        ///
-       virtual bool forceEmptyLayout(idx_type cell = 0) const;
+       virtual bool forcePlainLayout(idx_type cell = 0) const;
        ///
-       virtual bool useEmptyLayout() { return true; }
+       virtual bool usePlainLayout() { return true; }
        ///
        void addPreview(graphics::PreviewLoader &) const;