]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
mathed31.diff
[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-2000 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 FORMS_H_LOCATION
20 #include "undo.h"
21 #include <boost/utility.hpp>
22
23 class LyXView;
24 class LyXText;
25 class TeXErrors;
26 class Buffer;
27 class LyXScreen;
28 class WorkArea;
29 class Language;
30
31 ///
32 class BufferView : public noncopyable {
33 public:
34         ///
35         enum UpdateCodes {
36                 ///
37                 UPDATE = 0,
38                 ///
39                 SELECT = 1,
40                 ///
41                 FITCUR = 2,
42                 ///
43                 CHANGE = 4
44         };
45                                             
46         ///
47         BufferView(LyXView * owner, int , int , int, int);
48         ///
49         ~BufferView();
50         ///
51         Buffer * buffer() const;
52         ///
53         Painter & painter();
54         ///
55         LyXScreen * screen() const;
56         ///
57         WorkArea * workarea() const;
58         ///
59         void buffer(Buffer * b);
60         ///
61         void resize(int, int, int, int);
62         ///
63         void resize();
64         ///
65         void redraw();
66         ///
67         void fitCursor(LyXText *);
68         ///
69         void update();
70         //
71         void update(LyXText *, UpdateCodes uc);
72         ///
73         void updateScrollbar();
74         ///
75         Inset * checkInsetHit(LyXText *, int & x, int & y,
76                               unsigned int button);
77         /// 
78         void redoCurrentBuffer();
79         ///
80         int resizeCurrentBuffer();
81         ///
82         void gotoInset(std::vector<Inset::Code> const & codes,
83                        bool same_content);
84         ///
85         void gotoInset(Inset::Code codes, bool same_content);
86         ///
87         void cursorPrevious(LyXText *);
88         ///
89         void cursorNext(LyXText *);
90         /// 
91         bool available() const;
92         ///
93         LyXView * owner() const;
94         ///
95         void beforeChange(LyXText *);
96         ///
97         void savePosition(unsigned int i);
98         ///
99         void restorePosition(unsigned int i);
100         ///
101         bool isSavedPosition(unsigned int i);
102         /** This holds the mapping between buffer paragraphs and screen rows.
103             This should be private...but not yet. (Lgb)
104         */
105         LyXText * text;
106         ///
107         LyXText * getLyXText() const;
108         ///
109         LyXText * getParentText(Inset * inset) const;
110         ///
111         Language const * getParentLanguage(Inset * inset) const;
112         ///
113         int workWidth() const;
114         ///
115         UpdatableInset * theLockingInset() const;
116         ///
117         void theLockingInset(UpdatableInset * inset); 
118         ///
119         void updateInset(Inset * inset, bool mark_dirty);
120         ///
121         bool inset_slept;
122         ///
123         int slx;
124         ///
125         int sly;
126         ///
127         void insetUnlock();
128         ///
129         void insetSleep();
130         ///
131         void insetWakeup();
132         ///
133         void replaceWord(string const & replacestring);
134         ///
135         void endOfSpellCheck();
136         ///
137         void selectLastWord();
138         ///
139         string const nextWord(float & value);
140         ///
141         void insertCorrectQuote();
142         ///
143         bool gotoLabel(string const & label);
144         ///
145         void paste();
146         ///
147         void cut();
148         ///
149         void copy();
150         ///
151         void pasteEnvironment();
152         ///
153         void copyEnvironment();
154         ///
155         void hfill();
156         ///
157         void protectedBlank(LyXText *);
158         ///
159         void newline();
160         ///
161         void menuSeparator();
162         ///
163         void endOfSentenceDot();
164         ///
165         void ldots();
166         ///
167         void hyphenationPoint();
168         ///
169         void menuUndo();
170         ///
171         void menuRedo();
172 #ifndef NEW_INSETS
173         ///
174         void toggleFloat();
175         ///
176         void openStuff();
177 #endif
178         ///
179         void insertNote();
180 #ifndef NEW_INSETS
181         ///
182         void allFloats(char flag, char figmar);
183 #endif
184         /// removes all autodeletable insets
185         bool removeAutoInsets();
186         ///
187         void insertErrors(TeXErrors & terr);
188         ///
189         void setCursorFromRow(int row);
190         /** Insert an inset into the buffer.
191             Placie it in a layout of lout,
192             if no_table make sure that it doesn't end up in a table.
193         */
194         bool insertInset(Inset * inset, string const & lout = string(),
195                          bool no_table = false);
196         /// open and lock an updatable inset
197         bool open_new_inset(UpdatableInset * new_inset, bool behind = false);
198         /** Inserts a lyx file at cursor position.
199             @return #false# if it fails.
200         */
201         bool insertLyXFile(string const & file);
202         ///
203         bool lockInset(UpdatableInset * inset);
204         ///
205         void showLockedInsetCursor(int x, int y, int asc, int desc);
206         ///
207         void hideLockedInsetCursor();
208         ///
209         void fitLockedInsetCursor(int x, int y, int asc, int desc);
210         ///
211         int unlockInset(UpdatableInset * inset);
212         ///
213         void lockedInsetStoreUndo(Undo::undo_kind kind);
214         ///
215         void showCursor();
216         ///
217         void hideCursor();
218         ///
219         void toggleSelection(bool = true);
220         ///
221         void toggleToggle();
222         ///
223         void center();
224         
225         ///
226         bool focus() const;
227         ///
228         void focus(bool);
229         ///
230         bool active() const;
231         ///
232         bool belowMouse() const;
233         /// A callback for the slider in the scrollbar.
234         void scrollCB(double);
235
236         ///
237         void setState();
238
239         ///
240         void pushIntoUpdateList(Inset * i);
241         ///
242         bool ChangeInsets(Inset::Code code, string const & from, 
243                           string const & to);
244         ///
245         bool ChangeRefsIfUnique(string const & from, string const & to);
246         ///
247         bool ChangeCitationsIfUnique(string const & from, string const & to);
248         ///
249         void pasteClipboard(bool asPara);
250         ///
251         void stuffClipboard(string const &) const;
252 private:
253         struct Pimpl;
254         ///
255         friend struct BufferView::Pimpl;
256         ///
257         Pimpl * pimpl_;
258 };
259
260
261 ///
262 BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
263                                   BufferView::UpdateCodes uc2);
264
265 #endif