]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettext.h
static_cast-based key/mouse-state. Kill insetKeyPress.
[lyx.git] / src / insets / insettext.h
index ab981c6a639e48fa6e4bf4229d22eebda35f5da6..de1e96c9fb73d047c3bee15fa64104c6514799e5 100644 (file)
@@ -1,7 +1,7 @@
 // -*- C++ -*-
 /* This file is part of
  * ======================================================
- * 
+ *
  *           LyX, The Document Processor
  *
  *           Copyright 1998 The LyX Team.
 #include "LColor.h"
 #include "paragraph.h"
 #include "lyxcursor.h"
-#include <boost/smart_ptr.hpp>
+
+#include <boost/shared_ptr.hpp>
 
 class Painter;
 class BufferView;
 class Buffer;
+class BufferParams;
 class LyXCursor;
 class LyXText;
 class LyXScreen;
@@ -36,7 +38,7 @@ class Row;
 
 /**
  A text inset is like a TeX box to write full text
- (including styles and other insets) in a given space. 
+ (including styles and other insets) in a given space.
  @author: Jürgen Vigna
  */
 class InsetText : public UpdatableInset {
@@ -72,7 +74,7 @@ public:
                ALWAYS
        };
        ///
-       InsetText();
+       InsetText(BufferParams const &);
        ///
        explicit
        InsetText(InsetText const &, bool same_id = false);
@@ -99,13 +101,13 @@ public:
        ///
        void draw(BufferView *, LyXFont const &, int , float &, bool) const;
        ///
-       void update(BufferView *, LyXFont const &, bool =false);
+       void update(BufferView *, LyXFont const &, bool = false);
        ///
        void setUpdateStatus(BufferView *, int what) const;
        ///
        string const editMessage() const;
        ///
-       void edit(BufferView *, int, int, unsigned int);
+       void edit(BufferView *, int, int, mouse_button::state);
        ///
        void edit(BufferView *, bool front = true);
        ///
@@ -122,13 +124,11 @@ public:
        ///
        bool updateInsetInInset(BufferView *, Inset *);
        ///
-       void insetButtonRelease(BufferView *, int, int, int);
+       bool insetButtonRelease(BufferView *, int, int, mouse_button::state);
        ///
-       void insetButtonPress(BufferView *, int, int, int);
+       void insetButtonPress(BufferView *, int, int, mouse_button::state);
        ///
-       void insetMotionNotify(BufferView *, int, int, int);
-       ///
-       void insetKeyPress(XKeyEvent *);
+       void insetMotionNotify(BufferView *, int, int, mouse_button::state);
        ///
        UpdatableInset::RESULT localDispatch(BufferView *,
                                             kb_action, string const &);
@@ -148,11 +148,11 @@ public:
        ///
        void getCursorPos(BufferView *, int & x, int & y) const;
        ///
-       unsigned int insetInInsetY();
+       int insetInInsetY() const;
        ///
        void toggleInsetCursor(BufferView *);
        ///
-       void showInsetCursor(BufferView *, bool show=true);
+       void showInsetCursor(BufferView *, bool show = true);
        ///
        void hideInsetCursor(BufferView *);
        ///
@@ -168,7 +168,7 @@ public:
        ///
        void setFont(BufferView *, LyXFont const &,
                     bool toggleall = false,
-                    bool selectall = false);
+                    bool selectall = false);
        ///
        int getMaxWidth(BufferView *, UpdatableInset const *) const;
        ///
@@ -178,7 +178,7 @@ public:
        ///
        void setParagraphData(Paragraph *, bool same_id = false);
        ///
-       void setText(string const &);
+       void setText(string const &, LyXFont const &);
        ///
        void setAutoBreakRows(bool);
        ///
@@ -201,19 +201,19 @@ public:
        ///
        bool nodraw() const;
        ///
-       int scroll(bool recursive=true) const;
+       int scroll(bool recursive = true) const;
        ///
-       void scroll(BufferView *bv, float sx) const {
+       void scroll(BufferView * bv, float sx) const {
                UpdatableInset::scroll(bv, sx);
        }
        ///
-       void scroll(BufferView *bv, int offset) const {
+       void scroll(BufferView * bv, int offset) const {
                UpdatableInset::scroll(bv, offset);
        }
        ///
-       void selectAll(BufferView *bv);
+       void selectAll(BufferView * bv);
        ///
-       void clearSelection(BufferView *bv);
+       void clearSelection(BufferView * bv);
        ///
        Paragraph * getParFromID(int id) const;
        ///
@@ -230,17 +230,25 @@ public:
        void paragraph(Paragraph *);
        ///
        bool allowSpellcheck() { return true; }
-       string const selectNextWordToSpellcheck(BufferView *, float & value) const;
+       ///
+       string const selectNextWordToSpellcheck(BufferView *,
+                                               float & value) const;
        void selectSelectedWord(BufferView *);
+       ///
        void toggleSelection(BufferView *, bool kill_selection);
        ///
        bool searchForward(BufferView *, string const &,
-                          bool const & = true, bool const & = false);
+                          bool = true, bool = false);
+       ///
        bool searchBackward(BufferView *, string const &,
-                           bool const & = true, bool const & = false);
+                           bool = true, bool = false);
        ///
        bool checkInsertChar(LyXFont &);
        ///
+       void getDrawFont(LyXFont &) const;
+       ///
+       void appendParagraphs(BufferParams const & bparams, Paragraph *);
+       ///
        //
        // Public structures and variables
        ///
@@ -249,6 +257,10 @@ public:
 protected:
        ///
        void updateLocal(BufferView *, int what, bool mark_dirty) const;
+       /// set parameters for an initial lock of this inset
+       void lockInset(BufferView *);
+       /// lock an inset inside this one
+       void lockInset(BufferView *, UpdatableInset *);
        ///
        mutable int drawTextXOffset;
        ///
@@ -261,14 +273,17 @@ protected:
        LColor::color frame_color;
 
 private:
+       ///
        struct InnerCache {
+               ///
                InnerCache(boost::shared_ptr<LyXText>);
-
+               ///
                boost::shared_ptr<LyXText> text;
+               ///
                bool remove;
        };
        ///
-       typedef std::map<BufferView *, struct InnerCache > Cache;
+       typedef std::map<BufferView *, InnerCache> Cache;
        ///
        typedef Cache::value_type value_type;
        ///
@@ -282,11 +297,11 @@ private:
                                        bool activate_inset = true,
                                        bool selecting = false);
        ///
-       UpdatableInset::RESULT moveRightIntern(BufferView *, bool behind,
+       UpdatableInset::RESULT moveRightIntern(BufferView *, bool front,
                                               bool activate_inset = true,
                                               bool selecting = false);
        ///
-       UpdatableInset::RESULT moveLeftIntern(BufferView *, bool behind, 
+       UpdatableInset::RESULT moveLeftIntern(BufferView *, bool front,
                                              bool activate_inset = true,
                                              bool selecting = false);
 
@@ -297,17 +312,21 @@ private:
        ///
        void setCharFont(Buffer const *, int pos, LyXFont const & font);
        ///
-       bool checkAndActivateInset(BufferView * bv, bool behind);
+       bool checkAndActivateInset(BufferView * bv, bool front);
        ///
        bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
-                                  int button = 0);
+                                  mouse_button::state button = mouse_button::none);
        ///
        void removeNewlines();
        ///
        int cx(BufferView *) const;
        ///
+       int cix(BufferView *) const;
+       ///
        int cy(BufferView *) const;
        ///
+       int ciy(BufferView *) const;
+       ///
        lyx::pos_type cpos(BufferView *) const;
        ///
        Paragraph * cpar(BufferView *) const;
@@ -323,10 +342,13 @@ private:
        void clearInset(BufferView *, int baseline, bool & cleared) const;
        ///
        void saveLyXTextState(LyXText *) const;
+       ///
        void restoreLyXTextState(BufferView *, LyXText *) const;
        ///
        void reinitLyXText() const;
-       
+       ///
+       void collapseParagraphs(BufferView *) const;
+
        /* Private structures and variables */
        ///
        Paragraph * par;
@@ -339,10 +361,6 @@ private:
        ///
        mutable int insetWidth;
        ///
-       mutable int last_width;
-       ///
-       mutable int last_height;
-       ///
        mutable int top_y;
        ///
        Paragraph * inset_par;
@@ -375,7 +393,7 @@ private:
        ///
        mutable boost::shared_ptr<LyXText> cached_text;
        ///
-       mutable struct save_state {
+       struct save_state {
                Paragraph * lpar;
                Paragraph * selstartpar;
                Paragraph * selendpar;
@@ -388,7 +406,10 @@ private:
                bool selection;
                bool mark_set;
                bool refresh;
-       } sstate;
+       };
+       ///
+       mutable save_state sstate;
+
        ///
        // this is needed globally so we know that we're using it actually and
        // so the LyXText-Cache is not erased until used!
@@ -404,5 +425,11 @@ private:
        bool in_update; /* as update is not reentrant! */
        mutable BufferView * do_resize;
        mutable bool do_reinit;
+       mutable bool in_insetAllowed;
+       ///
+       // these are used to check for mouse movement in Motion selection code
+       ///
+       int mouse_x;
+       int mouse_y;
 };
 #endif