]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettabular.h
ws changes only
[lyx.git] / src / insets / insettabular.h
index 338b9c6b8721658182f2221cdb9f039ac079c3ef..7878be10d1e5bc149b5a60b0d7f3e81198250fce 100644 (file)
@@ -1,12 +1,12 @@
 // -*- C++ -*-
-/* This file is part of
- * ======================================================
+/**
+ * \file insettabular.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
+ * \author Jürgen Vigna
  *
- *           Copyright 1995-2001 The LyX Team.
- *
- *======================================================
+ * Full author contact details are available in file CREDITS.
  */
 // This is the rewrite of the tabular (table) support.
 
 #ifndef INSETTABULAR_H
 #define INSETTABULAR_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
-
 #include "inset.h"
 #include "tabular.h"
-#include "LString.h"
-#include "lyxcursor.h"
-#include "FuncStatus.h"
-
-#include <boost/scoped_ptr.hpp>
-
-#include <boost/signals/signal0.hpp>
+#include "frontends/mouse_state.h"
 
+class FuncStatus;
 class LyXLex;
 class Painter;
 class BufferView;
 class Buffer;
+class BufferParams;
 class Paragraph;
 
 class InsetTabular : public UpdatableInset {
 public:
-       ///
-       enum UpdateCodes {
-               NONE = 0,
-               CURSOR = 1,
-               CELL = 2,
-               SELECTION = 3,
-               FULL = 4,
-               INIT = 5
-       };
        ///
        InsetTabular(Buffer const &, int rows = 1, int columns = 1);
        ///
-       InsetTabular(InsetTabular const &, Buffer const &, bool same_id = false);
+       InsetTabular(InsetTabular const &);
        ///
        ~InsetTabular();
        ///
-       Inset * clone(Buffer const &, bool same_id = false) const;
-       ///
-       void read(Buffer const *, LyXLex &);
-       ///
-       void write(Buffer const *, std::ostream &) const;
+       virtual std::auto_ptr<InsetBase> clone() const;
        ///
-       int ascent(BufferView *, LyXFont const &) const;
+       void read(Buffer const &, LyXLex &);
        ///
-       int descent(BufferView *, LyXFont const &) const;
+       void write(Buffer const &, std::ostream &) const;
        ///
-       int width(BufferView *, LyXFont const & f) const;
+       void metrics(MetricsInfo &, Dimension &) const;
        ///
-       void draw(BufferView *, const LyXFont &, int , float &, bool) const;
-       ///
-       void update(BufferView *, LyXFont const &, bool = false);
-       ///
-       string const editMessage() const;
-       ///
-       void edit(BufferView *, int x, int y, mouse_button::state);
-       ///
-       void edit(BufferView * bv, bool front = true);
-       ///
-       bool doClearArea() const;
+       void draw(PainterInfo & pi, int x, int y) const;
        ///
+       std::string const editMessage() const;
+       //
        void insetUnlock(BufferView *);
        ///
-       void updateLocal(BufferView *, UpdateCodes, bool mark_dirty) const;
+       void updateLocal(BufferView *) const;
        ///
        bool lockInsetInInset(BufferView *, UpdatableInset *);
        ///
        bool unlockInsetInInset(BufferView *, UpdatableInset *,
                                bool lr = false);
        ///
-       bool updateInsetInInset(BufferView *, Inset *);
-       ///
        int insetInInsetY() const;
        ///
        UpdatableInset * getLockingInset() const;
        ///
-       UpdatableInset * getFirstLockingInsetOfType(Inset::Code);
+       UpdatableInset * getFirstLockingInsetOfType(InsetOld::Code);
        ///
-       bool insertInset(BufferView *, Inset *);
+       bool insertInset(BufferView *, InsetOld *);
        ///
-       bool insetAllowed(Inset::Code code) const;
+       bool insetAllowed(InsetOld::Code code) const;
        ///
        bool isTextInset() const { return true; }
        /** returns true if, when outputing LaTeX, font changes should
-            be closed before generating this inset. This is needed for
-            insets that may contain several paragraphs */
+           be closed before generating this inset. This is needed for
+           insets that may contain several paragraphs */
        bool noFontChange() const { return true; }
        ///
-       bool display() const { return tabular->IsLongTabular(); }
+       bool display() const { return tabular.isLongTabular(); }
        ///
-       RESULT localDispatch(FuncRequest const &);
+       dispatch_result localDispatch(FuncRequest const &);
        ///
-       int latex(Buffer const *, std::ostream &, bool, bool) const;
+       int latex(Buffer const &, std::ostream &,
+                 LatexRunParams const &) const;
        ///
-       int ascii(Buffer const *, std::ostream &, int linelen) const;
+       int ascii(Buffer const &, std::ostream &, int linelen) const;
        ///
-       int linuxdoc(Buffer const *, std::ostream &) const;
+       int linuxdoc(Buffer const &, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
+       int docbook(Buffer const &, std::ostream &, bool mixcont) const;
        ///
        void validate(LaTeXFeatures & features) const;
        ///
-       Inset::Code lyxCode() const { return Inset::TABULAR_CODE; }
-       ///
+       InsetOld::Code lyxCode() const { return InsetOld::TABULAR_CODE; }
+       /// FIXME, document
        void getCursorPos(BufferView *, int & x, int & y) const;
+       /// Get the absolute document x,y of the cursor
+       virtual void getCursor(BufferView &, int &, int &) const;
        ///
-       void toggleInsetCursor(BufferView *);
-       ///
-       bool tabularFeatures(BufferView * bv, string const & what);
+       bool tabularFeatures(BufferView * bv, std::string const & what);
        ///
        void tabularFeatures(BufferView * bv, LyXTabular::Feature feature,
-                            string const & val = string());
+                            std::string const & val = std::string());
        ///
        int getActCell() const { return actcell; }
        ///
        void setFont(BufferView *, LyXFont const &, bool toggleall = false,
                     bool selectall = false);
        ///
-       int getMaxWidth(BufferView *, UpdatableInset const *) const;
-       ///
-       Buffer * bufferOwner() const { return const_cast<Buffer *>(buffer); }
-       ///
        LyXText * getLyXText(BufferView const *,
                             bool const recursive = false) const;
        ///
        void deleteLyXText(BufferView *, bool recursive = true) const;
        ///
-       void resizeLyXText(BufferView *, bool force = false) const;
-       ///
        void openLayoutDialog(BufferView *) const;
        ///
        bool showInsetDialog(BufferView *) const;
        ///
-       FuncStatus getStatus(string const & argument) const;
-       ///
-       std::vector<string> const getLabelList() const;
-       ///
-       void nodraw(bool b) const {
-               UpdatableInset::nodraw(b);
-       }
-       bool nodraw() const;
+       FuncStatus getStatus(std::string const & argument) const;
+       /// Appends \c list with all labels found within this inset.
+       void getLabelList(Buffer const &, std::vector<std::string> & list) const;
        ///
        int scroll(bool recursive=true) const;
        ///
@@ -198,43 +157,53 @@ public:
                UpdatableInset::scroll(bv, offset);
        }
        ///
-       Paragraph * getParFromID(int id) const;
+       InsetOld * getInsetFromID(int id) const;
        ///
-       Inset * getInsetFromID(int id) const;
-       ///
-       Paragraph * firstParagraph() const;
-       ///
-       Paragraph * getFirstParagraph(int) const;
+       ParagraphList * getParagraphs(int) const;
        ///
        LyXCursor const & cursor(BufferView *) const;
        ///
-       bool allowSpellcheck() { return true; }
+       bool allowSpellcheck() const { return true; }
        ///
        WordLangTuple const
        selectNextWordToSpellcheck(BufferView *, float & value) const;
        ///
        void selectSelectedWord(BufferView *);
+
+       void markErased();
+
+       /// find next change
+       bool nextChange(BufferView *, lyx::pos_type & length);
        ///
-       void toggleSelection(BufferView *, bool kill_selection);
-       ///
-       bool searchForward(BufferView *, string const &,
+       bool searchForward(BufferView *, std::string const &,
                           bool = true, bool = false);
-       bool searchBackward(BufferView *, string const &,
+       bool searchBackward(BufferView *, std::string const &,
                            bool = true, bool = false);
 
        // this should return true if we have a "normal" cell, otherwise true.
        // "normal" means without width set!
-       bool forceDefaultParagraphs(Inset const * in) const;
+       bool forceDefaultParagraphs(InsetOld const * in) const;
 
        ///
-       void addPreview(grfx::PreviewLoader &) const;
+       void addPreview(lyx::graphics::PreviewLoader &) const;
 
        //
        // Public structures and variables
        ///
-       boost::scoped_ptr<LyXTabular> tabular;
+       mutable LyXTabular tabular;
+
+       /// are some cells selected ?
+       bool hasSelection() const {
+               return has_selection;
+       }
+
+       ///
+       virtual BufferView * view() const;
        ///
-       boost::signal0<void> hideDialog;
+       Buffer const & buffer() const;
+
+       /// set the owning buffer
+       void buffer(Buffer * b);
 
 private:
        ///
@@ -248,8 +217,7 @@ private:
        ///
        void lfunMouseMotion(FuncRequest const &);
        ///
-       bool calculate_dimensions_of_cells(BufferView *, LyXFont const &,
-                                          bool = false) const;
+       void calculate_dimensions_of_cells(MetricsInfo & mi) const;
        ///
        void drawCellLines(Painter &, int x, int baseline,
                           int row, int cell) const;
@@ -257,38 +225,28 @@ private:
        void drawCellSelection(Painter &, int x, int baseline,
                               int row, int column, int cell) const;
        ///
-       void showInsetCursor(BufferView *, bool show=true);
-       ///
-       void hideInsetCursor(BufferView *);
-       ///
        void fitInsetCursor(BufferView *) const;
        ///
        void setPos(BufferView *, int x, int y) const;
        ///
-       RESULT moveRight(BufferView *, bool lock = true);
+       dispatch_result moveRight(BufferView *, bool lock = true);
        ///
-       RESULT moveLeft(BufferView *, bool lock = true);
+       dispatch_result moveLeft(BufferView *, bool lock = true);
        ///
-       RESULT moveUp(BufferView *, bool lock = true);
+       dispatch_result moveUp(BufferView *, bool lock = true);
        ///
-       RESULT moveDown(BufferView *, bool lock = true);
+       dispatch_result moveDown(BufferView *, bool lock = true);
        ///
        bool moveNextCell(BufferView *, bool lock = false);
        ///
        bool movePrevCell(BufferView *, bool lock = false);
        ///
-       bool deletable() const;
-       ///
        int getCellXPos(int cell) const;
        ///
        void resetPos(BufferView *) const;
        ///
        void removeTabularRow();
        ///
-       bool hasSelection() const {
-               return has_selection;
-       }
-       ///
        void clearSelection() const {
                sel_cell_start = sel_cell_end = 0;
                has_selection = false;
@@ -308,15 +266,13 @@ private:
        ///
        bool insetHit(BufferView * bv, int x, int y) const;
        ///
-       int getMaxWidthOfCell(BufferView * bv, int cell) const;
-       ///
        bool hasPasteBuffer() const;
        ///
        bool copySelection(BufferView *);
        ///
        bool pasteSelection(BufferView *);
        ///
-       bool cutSelection();
+       bool cutSelection(BufferParams const & bp);
        ///
        bool isRightToLeft(BufferView *);
        ///
@@ -325,7 +281,7 @@ private:
        ///
        WordLangTuple selectNextWordInt(BufferView *, float & value) const;
        ///
-       bool insertAsciiString(BufferView *, string const & buf, bool usePaste);
+       bool insertAsciiString(BufferView *, std::string const & buf, bool usePaste);
 
        //
        // Private structures and variables
@@ -334,9 +290,11 @@ private:
        ///
        InsetText * old_locking_inset;
        ///
-       Buffer const * buffer;
+       Buffer const * buffer_;
+       ///
+       mutable int cursorx_;
        ///
-       mutable LyXCursor cursor_;
+       mutable int cursory_;
        ///
        mutable unsigned int inset_x;
        ///
@@ -362,10 +320,34 @@ private:
        ///
        mutable bool locked;
        ///
-       mutable UpdateCodes need_update;
+       mutable int in_reset_pos;
+};
+
+
+#include "mailinset.h"
+
+
+class InsetTabularMailer : public MailInset {
+public:
+       ///
+       InsetTabularMailer(InsetTabular const & inset);
        ///
-       bool in_update;
+       virtual InsetBase & inset() const { return inset_; }
        ///
-       mutable int in_reset_pos;
+       virtual std::string const & name() const { return name_; }
+       ///
+       virtual std::string const inset2string(Buffer const &) const;
+       /// Returns the active cell if successful, else -1.
+       static int string2params(std::string const &, InsetTabular &);
+       ///
+       static std::string const params2string(InsetTabular const &);
+private:
+       ///
+       static std::string const name_;
+       ///
+       InsetTabular & inset_;
 };
+
+std::string const featureAsString(LyXTabular::Feature feature);
+
 #endif