]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
548306dbac80fb9af1fb991ec66b5ab2189f6fd9
[lyx.git] / src / BufferView.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *        
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef BUFFER_VIEW_H
13 #define BUFFER_VIEW_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "LString.h"
20 #include "undo.h"
21 #include "commandtags.h"
22 #include "insets/inset.h"
23 #include <boost/utility.hpp>
24
25 class LyXView;
26 class LyXText;
27 class TeXErrors;
28 class Buffer;
29 class LyXScreen;
30 class WorkArea;
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();
58         ///
59         LyXScreen * screen() const;
60         ///
61         void buffer(Buffer * b);
62         ///
63         void resize(int, int, int, int);
64         ///
65         void resize();
66         ///
67         void redraw();
68         ///
69         void fitCursor(LyXText *);
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                               unsigned int button);
79         /// 
80         void redoCurrentBuffer();
81         ///
82         int resizeCurrentBuffer();
83         ///
84         void cursorPrevious(LyXText *);
85         ///
86         void cursorNext(LyXText *);
87         /// 
88         bool available() const;
89         ///
90         LyXView * owner() const;
91         ///
92         void beforeChange(LyXText *);
93         ///
94         void savePosition(unsigned int i);
95         ///
96         void restorePosition(unsigned int i);
97         ///
98         bool isSavedPosition(unsigned int i);
99         /** This holds the mapping between buffer paragraphs and screen rows.
100             This should be private...but not yet. (Lgb)
101         */
102         LyXText * text;
103         ///
104         LyXText * getLyXText() const;
105         ///
106         LyXText * getParentText(Inset * inset) const;
107         ///
108         Language const * getParentLanguage(Inset * inset) const;
109         ///
110         int workWidth() const;
111         ///
112         UpdatableInset * theLockingInset() const;
113         ///
114         void theLockingInset(UpdatableInset * inset); 
115         ///
116         void updateInset(Inset * inset, bool mark_dirty);
117         ///
118         int slx;
119         ///
120         int sly;
121         ///
122         void insetUnlock();
123         ///
124         void insetSleep();
125         ///
126         void insetWakeup();
127         ///
128         void replaceWord(string const & replacestring);
129         ///
130         void endOfSpellCheck();
131         ///
132         void selectLastWord();
133         ///
134         string const nextWord(float & value);
135         ///
136         bool gotoLabel(string const & label);
137         ///
138         void paste();
139         ///
140         void cut();
141         ///
142         void copy();
143         ///
144         void pasteEnvironment();
145         ///
146         void copyEnvironment();
147         ///
148         void menuUndo();
149         ///
150         void menuRedo();
151         /// removes all autodeletable insets
152         bool removeAutoInsets();
153         ///
154         void insertErrors(TeXErrors & terr);
155         ///
156         void setCursorFromRow(int row);
157         /** Insert an inset into the buffer.
158             Placie it in a layout of lout,
159             if no_table make sure that it doesn't end up in a table.
160         */
161         //bool insertInset(Inset * inset, string const & lout = string(),
162         //               bool no_table = false);
163         bool insertInset(Inset * inset, string const & lout = string());
164         /** Inserts a lyx file at cursor position.
165             @return #false# if it fails.
166         */
167         bool insertLyXFile(string const & file);
168         ///
169         bool lockInset(UpdatableInset * inset);
170         ///
171         void showLockedInsetCursor(int x, int y, int asc, int desc);
172         ///
173         void hideLockedInsetCursor();
174         ///
175         void fitLockedInsetCursor(int x, int y, int asc, int desc);
176         ///
177         int unlockInset(UpdatableInset * inset);
178         ///
179         void lockedInsetStoreUndo(Undo::undo_kind kind);
180         ///
181         void showCursor();
182         ///
183         void hideCursor();
184         ///
185         void toggleSelection(bool = true);
186         ///
187         void toggleToggle();
188         ///
189         void center();
190         
191         ///
192         bool focus() const;
193         ///
194         void focus(bool);
195         ///
196         bool active() const;
197         ///
198         bool belowMouse() const;
199         /// A callback for the slider in the scrollbar.
200         void scrollCB(double);
201
202         ///
203         void setState();
204
205         ///
206         void pushIntoUpdateList(Inset * i);
207         ///
208         bool ChangeInsets(Inset::Code code, string const & from, 
209                           string const & to);
210         ///
211         bool ChangeRefsIfUnique(string const & from, string const & to);
212         ///
213         bool ChangeCitationsIfUnique(string const & from, string const & to);
214         ///
215         string const getClipboard() const;
216         ///
217         void pasteClipboard(bool asPara);
218         ///
219         void stuffClipboard(string const &) const;
220         ///
221         bool Dispatch(kb_action action, string const & argument);
222 private:
223         struct Pimpl;
224         ///
225         friend struct BufferView::Pimpl;
226         ///
227         Pimpl * pimpl_;
228 };
229
230
231 ///
232 BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
233                                   BufferView::UpdateCodes uc2);
234
235 #endif