]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
Painter and scrollbar API patches
[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 LScreen;
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         LScreen & screen() 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         bool fitCursor();
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         ///
77         void redoCurrentBuffer();
78         ///
79         int resizeCurrentBuffer();
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         ///
185         bool focus() const;
186         ///
187         void focus(bool);
188         /// Scroll the view by a number of pixels
189         void scrollDocView(int);
190
191         ///
192         void setState();
193
194         ///
195         bool ChangeInsets(Inset::Code code, string const & from,
196                           string const & to);
197         ///
198         bool ChangeRefsIfUnique(string const & from, string const & to);
199         ///
200         bool ChangeCitationsIfUnique(string const & from, string const & to);
201         ///
202         string const getClipboard() const;
203         ///
204         void pasteClipboard(bool asPara);
205         ///
206         void stuffClipboard(string const &) const;
207         ///
208         bool Dispatch(kb_action action, string const & argument);
209 private:
210         ///
211         struct Pimpl;
212         ///
213         friend struct BufferView::Pimpl;
214         ///
215         Pimpl * pimpl_;
216 };
217
218
219 ///
220 BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
221                                   BufferView::UpdateCodes uc2);
222
223 #endif