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