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