]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
whitespace changes;
[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 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();
57         ///
58         LyXScreen * screen() const;
59         ///
60         void buffer(Buffer * b);
61         ///
62         void resize(int, int, int, int);
63         ///
64         void resize();
65         ///
66         void redraw();
67         ///
68         void fitCursor();
69         ///
70         void update();
71         //
72         void update(LyXText *, UpdateCodes uc);
73         ///
74         void updateScrollbar();
75         ///
76         Inset * checkInsetHit(LyXText *, int & x, int & y,
77                               unsigned int button);
78         /// 
79         void redoCurrentBuffer();
80         ///
81         int resizeCurrentBuffer();
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 insetSleep();
124         ///
125         void insetWakeup();
126         ///
127         void replaceWord(string const & replacestring);
128         ///
129         void endOfSpellCheck();
130         ///
131         void selectLastWord();
132         ///
133         string const nextWord(float & value);
134         ///
135         bool gotoLabel(string const & label);
136         ///
137         void paste();
138         ///
139         void cut(bool realcut = true);
140         ///
141         void copy();
142         ///
143         void pasteEnvironment();
144         ///
145         void copyEnvironment();
146         ///
147         void menuUndo();
148         ///
149         void menuRedo();
150         /// removes all autodeletable insets
151         bool removeAutoInsets();
152         ///
153         void insertErrors(TeXErrors & terr);
154         ///
155         void setCursorFromRow(int row);
156         /** Insert an inset into the buffer.
157             Placie it in a layout of lout,
158             if no_table make sure that it doesn't end up in a table.
159         */
160         //bool insertInset(Inset * inset, string const & lout = string(),
161         //               bool no_table = false);
162         bool insertInset(Inset * inset, string const & lout = string());
163         /** Inserts a lyx file at cursor position.
164             @return #false# if it fails.
165         */
166         bool insertLyXFile(string const & file);
167         ///
168         bool lockInset(UpdatableInset * inset);
169         ///
170         void showLockedInsetCursor(int x, int y, int asc, int desc);
171         ///
172         void hideLockedInsetCursor();
173         ///
174         void fitLockedInsetCursor(int x, int y, int asc, int desc);
175         ///
176         int unlockInset(UpdatableInset * inset);
177         ///
178         void lockedInsetStoreUndo(Undo::undo_kind kind);
179         ///
180         void showCursor();
181         ///
182         void hideCursor();
183         ///
184         void toggleSelection(bool = true);
185         ///
186         void toggleToggle();
187         ///
188         void center();
189         
190         ///
191         bool focus() const;
192         ///
193         void focus(bool);
194         ///
195         bool active() const;
196         ///
197         bool belowMouse() const;
198         /// A callback for the slider in the scrollbar.
199         void scrollCB(double);
200
201         ///
202         void setState();
203
204         ///
205         void pushIntoUpdateList(Inset * i);
206         ///
207         bool ChangeInsets(Inset::Code code, string const & from, 
208                           string const & to);
209         ///
210         bool ChangeRefsIfUnique(string const & from, string const & to);
211         ///
212         bool ChangeCitationsIfUnique(string const & from, string const & to);
213         ///
214         string const getClipboard() const;
215         ///
216         void pasteClipboard(bool asPara);
217         ///
218         void stuffClipboard(string const &) const;
219         ///
220         bool Dispatch(kb_action action, string const & argument);
221 private:
222         struct Pimpl;
223         ///
224         friend struct BufferView::Pimpl;
225         ///
226         Pimpl * pimpl_;
227 };
228
229
230 ///
231 BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
232                                   BufferView::UpdateCodes uc2);
233
234 #endif