]> git.lyx.org Git - lyx.git/blob - src/insets/updatableinset.h
Re-add the RasterImage template.
[lyx.git] / src / insets / updatableinset.h
1 // -*- C++ -*-
2 /**
3  * \file updatableinset.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alejandro Aguilar Sierra
8  * \author Jürgen Vigna
9  * \author Lars Gullik Bjønnes
10  * \author Matthias Ettrich
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef UPDATABLEINSET_H
16 #define UPDATABLEINSET_H
17
18 //  Updatable Insets. These insets can be locked and receive
19 //  directly user interaction. Currently used only for mathed.
20 //  Note that all pure methods from Inset class are pure here too.
21 //  [Alejandro 080596]
22
23 #include "inset.h"
24
25 #include "support/types.h"
26
27
28 /** Extracted from Matthias notes:
29  *
30  * An inset can simple call LockInset in it's edit call and *ONLY*
31  * in it's edit call.
32  *
33  * Unlocking is either done by LyX or the inset itself with a
34  * UnlockInset-call
35  *
36  * During the lock, all button and keyboard events will be modified
37  * and send to the inset through the following inset-features. Note that
38  * InsetOld::insetUnlock will be called from inside UnlockInset. It is meant
39  * to contain the code for restoring the menus and things like this.
40  *
41  * If a inset wishes any redraw and/or update it just has to call
42  * updateInset(this).
43  *
44  * It's is completly irrelevant, where the inset is. UpdateInset will
45  * find it in any paragraph in any buffer.
46  * Of course the_locking_inset and the insets in the current paragraph/buffer
47  *  are checked first, so no performance problem should occur.
48  */
49 class UpdatableInset : public InsetOld {
50 public:
51         ///
52         UpdatableInset();
53         ///
54         UpdatableInset(UpdatableInset const & in);
55
56         /// check if the font of the char we want inserting is correct
57         /// and modify it if it is not.
58         virtual bool checkInsertChar(LyXFont &) { return true; }
59         ///
60         virtual EDITABLE editable() const;
61
62         ///
63         virtual void fitInsetCursor(BufferView *) const;
64         /// FIXME
65         virtual void getCursorPos(BufferView *, int &, int &) const {}
66         /// Get the absolute document x,y of the cursor
67         virtual void getCursor(BufferView &, int &, int &) const = 0;
68         ///
69         virtual void insetUnlock(BufferView *);
70         ///
71         virtual void draw(PainterInfo & pi, int x, int y) const;
72         ///
73         virtual bool insertInset(BufferView *, InsetOld *) { return false; }
74         ///
75         virtual UpdatableInset * getLockingInset() const
76                 { return const_cast<UpdatableInset *>(this); }
77         ///
78         virtual UpdatableInset * getFirstLockingInsetOfType(InsetOld::Code c)
79                 { return (c == lyxCode()) ? this : 0; }
80         ///
81         virtual int insetInInsetY() const { return 0; }
82         ///
83         virtual bool lockInsetInInset(BufferView *, UpdatableInset *)
84                 { return false; }
85         ///
86         virtual bool unlockInsetInInset(BufferView *, UpdatableInset *,
87                                         bool /*lr*/ = false)
88                 { return false; }
89         ///  An updatable inset could handle lyx editing commands
90         virtual RESULT localDispatch(FuncRequest const & cmd);
91         // We need this method to not clobber the real method in Inset
92         int scroll(bool recursive = true) const
93                 { return InsetOld::scroll(recursive); }
94         ///
95         virtual bool showInsetDialog(BufferView *) const { return false; }
96         ///
97         // needed for spellchecking text
98         ///
99         virtual bool allowSpellcheck() const { return false; }
100         ///
101         virtual WordLangTuple const
102         selectNextWordToSpellcheck(BufferView *, float & value) const;
103         ///
104         virtual void selectSelectedWord(BufferView *) {}
105         ///
106         virtual void toggleSelection(BufferView *, bool /*kill_selection*/) {}
107
108         /// find the next change in the inset
109         virtual bool nextChange(BufferView * bv, lyx::pos_type & length);
110
111         ///
112         // needed for search/replace functionality
113         ///
114         virtual bool searchForward(BufferView *, string const &,
115                                    bool = true, bool = false);
116         ///
117         virtual bool searchBackward(BufferView *, string const &,
118                                     bool = true, bool = false);
119
120 protected:
121         /// scrolls to absolute position in bufferview-workwidth * sx units
122         void scroll(BufferView *, float sx) const;
123         /// scrolls offset pixels
124         void scroll(BufferView *, int offset) const;
125 };
126
127 #endif