]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettabular.h
fix #832
[lyx.git] / src / insets / insettabular.h
index 5014ab164116af8282f24b6f619f838d14dacccc..b1992c9ccadb16782fcc5ffbd7bf8eebfad9b231 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 "FuncStatus.h"
 
 #include <boost/scoped_ptr.hpp>
-
-#include <boost/signals/signal0.hpp>
+#include <boost/weak_ptr.hpp>
 
 class LyXLex;
 class Painter;
 class BufferView;
 class Buffer;
+class BufferParams;
 class Paragraph;
 
 class InsetTabular : public UpdatableInset {
@@ -95,21 +91,15 @@ public:
        ///
        int width(BufferView *, LyXFont const & f) const;
        ///
-       void draw(BufferView *, const LyXFont &, int , float &, bool) const;
+       void draw(BufferView *, const LyXFont &, int , float &) const;
        ///
-       void update(BufferView *, LyXFont const &, bool = false);
+       void update(BufferView *, 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 insetUnlock(BufferView *);
        ///
-       void updateLocal(BufferView *, UpdateCodes, bool mark_dirty) const;
+       void updateLocal(BufferView *, UpdateCodes) const;
        ///
        bool lockInsetInInset(BufferView *, UpdatableInset *);
        ///
@@ -129,17 +119,14 @@ public:
        bool insetAllowed(Inset::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 */
+       bool noFontChange() const { return true; }
        ///
        bool display() const { return tabular->IsLongTabular(); }
        ///
-       bool insetButtonRelease(BufferView *, int, int, mouse_button::state);
-       ///
-       void insetButtonPress(BufferView *, int, int, mouse_button::state);
-       ///
-       void insetMotionNotify(BufferView *, int, int, mouse_button::state);
-       ///
-       UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
-                                            string const &);
+       RESULT localDispatch(FuncRequest const &);
        ///
        int latex(Buffer const *, std::ostream &, bool, bool) const;
        ///
@@ -152,10 +139,10 @@ public:
        void validate(LaTeXFeatures & features) const;
        ///
        Inset::Code lyxCode() const { return Inset::TABULAR_CODE; }
-       ///
+       /// FIXME, document
        void getCursorPos(BufferView *, int & x, int & y) const;
-       ///
-       void toggleInsetCursor(BufferView *);
+       /// Get the absolute document x,y of the cursor
+       virtual void getCursor(BufferView &, int &, int &) const;
        ///
        bool tabularFeatures(BufferView * bv, string const & what);
        ///
@@ -201,20 +188,25 @@ public:
                UpdatableInset::scroll(bv, offset);
        }
        ///
-       Paragraph * getParFromID(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; }
-       string const selectNextWordToSpellcheck(BufferView *, float & value) const;
+       bool allowSpellcheck() const { return true; }
+       ///
+       WordLangTuple const
+       selectNextWordToSpellcheck(BufferView *, float & value) const;
+       ///
        void selectSelectedWord(BufferView *);
+       ///
        void toggleSelection(BufferView *, bool kill_selection);
+
+       void markErased();
+
+       /// find next change
+       bool nextChange(BufferView *, lyx::pos_type & length);
        ///
        bool searchForward(BufferView *, string const &,
                           bool = true, bool = false);
@@ -225,17 +217,34 @@ public:
        // "normal" means without width set!
        bool forceDefaultParagraphs(Inset const * in) const;
 
+       ///
+       void addPreview(grfx::PreviewLoader &) const;
+
        //
        // Public structures and variables
        ///
        boost::scoped_ptr<LyXTabular> tabular;
-       ///
-       boost::signal0<void> hideDialog;
 
+       /// are some cells selected ?
+       bool hasSelection() const {
+               return has_selection;
+       }
+
+       ///
+       virtual BufferView * view() const;
 private:
        ///
-       bool calculate_dimensions_of_cells(BufferView *, LyXFont const &,
-                                          bool = false) const;
+       void lfunMousePress(FuncRequest const &);
+       ///
+       // the bool return is used to see if we opened a dialog so that we can
+       // check this from an outer inset and open the dialog of the outer inset
+       // if that one has one!
+       ///
+       bool lfunMouseRelease(FuncRequest const &);
+       ///
+       void lfunMouseMotion(FuncRequest const &);
+       ///
+       bool calculate_dimensions_of_cells(BufferView *, bool = false) const;
        ///
        void drawCellLines(Painter &, int x, int baseline,
                           int row, int cell) const;
@@ -243,38 +252,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;
        ///
-       UpdatableInset::RESULT moveRight(BufferView *, bool lock = true);
+       RESULT moveRight(BufferView *, bool lock = true);
        ///
-       UpdatableInset::RESULT moveLeft(BufferView *, bool lock = true);
+       RESULT moveLeft(BufferView *, bool lock = true);
        ///
-       UpdatableInset::RESULT moveUp(BufferView *, bool lock = true);
+       RESULT moveUp(BufferView *, bool lock = true);
        ///
-       UpdatableInset::RESULT moveDown(BufferView *, bool lock = true);
+       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;
@@ -302,14 +301,14 @@ private:
        ///
        bool pasteSelection(BufferView *);
        ///
-       bool cutSelection();
+       bool cutSelection(BufferParams const & bp);
        ///
        bool isRightToLeft(BufferView *);
        ///
        void getSelection(int & scol, int & ecol,
                          int & srow, int & erow) const;
        ///
-       string selectNextWordInt(BufferView *, float & value) const;
+       WordLangTuple selectNextWordInt(BufferView *, float & value) const;
        ///
        bool insertAsciiString(BufferView *, string const & buf, bool usePaste);
 
@@ -354,4 +353,32 @@ private:
        ///
        mutable int in_reset_pos;
 };
+
+
+#include "mailinset.h"
+
+
+class InsetTabularMailer : public MailInset {
+public:
+       ///
+       InsetTabularMailer(InsetTabular & inset);
+       ///
+       virtual InsetBase & inset() const { return inset_; }
+       ///
+       virtual string const & name() const { return name_; }
+       ///
+       virtual string const inset2string() const;
+       /// Returns the active cell if successful, else -1.
+       static int string2params(string const &, InsetTabular &);
+       ///
+       static string const params2string(InsetTabular const &);
+private:
+       ///
+       static string const name_;
+       ///
+       InsetTabular & inset_;
+};
+
+string const featureAsString(LyXTabular::Feature feature);
+
 #endif