]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
fb7b2983419e3521b04476c3d072b49ba8ca5fd4
[lyx.git] / src / BufferView.h
1 // -*- C++ -*-
2 /**
3  * \file BufferView.h
4  * Copyright 2002 the LyX Team
5  * Read the file COPYING
6  *
7  *  \author Lars Gullik Bjønnes
8 */
9
10 #ifndef BUFFER_VIEW_H
11 #define BUFFER_VIEW_H
12
13 #ifdef __GNUG__
14 #pragma interface
15 #endif
16
17 #include "LString.h"
18 #include "undo.h"
19 #include "commandtags.h"
20
21 #include "insets/inset.h"
22 #include "WordLangTuple.h"
23
24 #include <boost/utility.hpp>
25
26 class LyXView;
27 class LyXText;
28 class TeXErrors;
29 class Buffer;
30 class LyXScreen;
31 class Language;
32 class Painter;
33 class UpdatableInset;
34
35 ///
36 class BufferView : boost::noncopyable {
37 public:
38         ///
39         enum UpdateCodes {
40                 ///
41                 UPDATE = 0,
42                 ///
43                 SELECT = 1,
44                 ///
45                 FITCUR = 2,
46                 ///
47                 CHANGE = 4
48         };
49
50         ///
51         BufferView(LyXView * owner, int , int , int, int);
52         ///
53         ~BufferView();
54         ///
55         Buffer * buffer() const;
56         ///
57         Painter & painter() const;
58         ///
59         LyXScreen & screen() const;
60         ///
61         void buffer(Buffer * b);
62         ///
63         void resize();
64         /**
65          * Repaint the pixmap. Used for when we don't want
66          * to go through the full update() logic, just a simple
67          * repaint of the whole screen.
68          */
69         void repaint();
70         ///
71         bool fitCursor();
72         ///
73         void update();
74         //
75         void update(LyXText *, UpdateCodes uc);
76         ///
77         void updateScrollbar();
78         ///
79         Inset * checkInsetHit(LyXText *, int & x, int & y);
80         ///
81         void redoCurrentBuffer();
82         ///
83         void cursorPrevious(LyXText *);
84         ///
85         void cursorNext(LyXText *);
86         ///
87         bool available() const;
88         ///
89         LyXView * owner() const;
90         ///
91         void beforeChange(LyXText *);
92         ///
93         void savePosition(unsigned int i);
94         ///
95         void restorePosition(unsigned int i);
96         ///
97         bool isSavedPosition(unsigned int i);
98         /** This holds the mapping between buffer paragraphs and screen rows.
99             This should be private...but not yet. (Lgb)
100         */
101         LyXText * text;
102         ///
103         LyXText * getLyXText() const;
104         ///
105         LyXText * getParentText(Inset * inset) const;
106         ///
107         Language const * getParentLanguage(Inset * inset) const;
108         ///
109         int workWidth() const;
110         ///
111         UpdatableInset * theLockingInset() const;
112         ///
113         void theLockingInset(UpdatableInset * inset);
114         ///
115         void updateInset(Inset * inset, bool mark_dirty);
116         ///
117         int slx;
118         ///
119         int sly;
120         ///
121         void insetUnlock();
122         ///
123         void replaceWord(string const & replacestring);
124         ///
125         void endOfSpellCheck();
126         ///
127         void selectLastWord();
128         /// return the next word
129         WordLangTuple const nextWord(float & value);
130         ///
131         bool gotoLabel(string const & label);
132         ///
133         void paste();
134         ///
135         void cut(bool realcut = true);
136         ///
137         void copy();
138         ///
139         void pasteEnvironment();
140         ///
141         void copyEnvironment();
142         ///
143         void menuUndo();
144         ///
145         void menuRedo();
146         /// removes all autodeletable insets
147         bool removeAutoInsets();
148         ///
149         void insertErrors(TeXErrors & terr);
150         ///
151         void setCursorFromRow(int row);
152         /** Insert an inset into the buffer.
153             Placie it in a layout of lout,
154             if no_table make sure that it doesn't end up in a table.
155         */
156         //bool insertInset(Inset * inset, string const & lout = string(),
157         //               bool no_table = false);
158         bool insertInset(Inset * inset, string const & lout = string());
159         /** Inserts a lyx file at cursor position.
160             \return #false# if it fails.
161         */
162         bool insertLyXFile(string const & file);
163         ///
164         bool lockInset(UpdatableInset * inset);
165         ///
166         void showLockedInsetCursor(int x, int y, int asc, int desc);
167         ///
168         void hideLockedInsetCursor();
169         ///
170         bool fitLockedInsetCursor(int x, int y, int asc, int desc);
171         ///
172         int unlockInset(UpdatableInset * inset);
173         ///
174         void lockedInsetStoreUndo(Undo::undo_kind kind);
175         ///
176         void showCursor();
177         ///
178         void hideCursor();
179         ///
180         void toggleSelection(bool = true);
181         ///
182         void toggleToggle();
183         ///
184         void center();
185
186         /// Scroll the view by a number of pixels
187         void scrollDocView(int);
188
189         ///
190         void switchKeyMap();
191
192         ///
193         bool ChangeInsets(Inset::Code code, string const & from,
194                           string const & to);
195         ///
196         bool ChangeRefsIfUnique(string const & from, string const & to);
197         ///
198         bool ChangeCitationsIfUnique(string const & from, string const & to);
199         ///
200         string const getClipboard() const;
201         ///
202         void pasteClipboard(bool asPara);
203         ///
204         void stuffClipboard(string const &) const;
205         ///
206         bool dispatch(kb_action action, string const & argument);
207 private:
208         ///
209         struct Pimpl;
210         ///
211         friend struct BufferView::Pimpl;
212         ///
213         Pimpl * pimpl_;
214 };
215
216
217 ///
218 BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
219                                   BufferView::UpdateCodes uc2);
220
221 #endif