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