]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
aarrrgghh
[lyx.git] / src / BufferView.h
1 // -*- C++ -*-
2 /**
3  * \file BufferView.h
4  * Copyright 2002 the LyX Team
5  * Read the file COPYING
6  *
7  *  \author Lars Gullik Bjønnes
8 */
9
10 #ifndef BUFFER_VIEW_H
11 #define BUFFER_VIEW_H
12
13 #ifdef __GNUG__
14 #pragma interface
15 #endif
16
17 #include "LString.h"
18 #include "undo.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 LyXScreen;
29 class Language;
30 class Painter;
31 class UpdatableInset;
32 class WordLangTuple;
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() const;
57         ///
58         LyXScreen & screen() const;
59         ///
60         void buffer(Buffer * b);
61         ///
62         void resize();
63         /**
64          * Repaint the pixmap. Used for when we don't want
65          * to go through the full update() logic, just a simple
66          * repaint of the whole screen.
67          */
68         void repaint();
69         ///
70         bool fitCursor();
71         ///
72         void update();
73         //
74         void update(LyXText *, UpdateCodes uc);
75         ///
76         void updateScrollbar();
77         ///
78         void redoCurrentBuffer();
79         ///
80         bool available() const;
81         ///
82         LyXView * owner() const;
83         ///
84         void beforeChange(LyXText *);
85         ///
86         void savePosition(unsigned int i);
87         ///
88         void restorePosition(unsigned int i);
89         ///
90         bool isSavedPosition(unsigned int i);
91         /** This holds the mapping between buffer paragraphs and screen rows.
92             This should be private...but not yet. (Lgb)
93         */
94         LyXText * text;
95         ///
96         LyXText * getLyXText() const;
97         ///
98         LyXText * getParentText(Inset * inset) const;
99         ///
100         Language const * getParentLanguage(Inset * inset) const;
101         ///
102         int workWidth() const;
103         ///
104         UpdatableInset * theLockingInset() const;
105         ///
106         void theLockingInset(UpdatableInset * inset);
107         ///
108         void updateInset(Inset * inset, bool mark_dirty);
109         ///
110         int slx;
111         ///
112         int sly;
113         ///
114         void insetUnlock();
115         ///
116         void replaceWord(string const & replacestring);
117         ///
118         void endOfSpellCheck();
119         ///
120         void selectLastWord();
121         /// return the next word
122         WordLangTuple const nextWord(float & value);
123         ///
124         bool gotoLabel(string const & label);
125         ///
126         void pasteEnvironment();
127         ///
128         void copyEnvironment();
129         ///
130         void menuUndo();
131         ///
132         void menuRedo();
133         /// removes all autodeletable insets
134         bool removeAutoInsets();
135         ///
136         void insertErrors(TeXErrors & terr);
137         ///
138         void setCursorFromRow(int row);
139         /** Insert an inset into the buffer.
140             Place it in a layout of lout,
141             if no_table make sure that it doesn't end up in a table.
142         */
143         bool insertInset(Inset * inset, string const & lout = string());
144         /// Inserts a lyx file at cursor position. return #false# if it fails
145         bool insertLyXFile(string const & file);
146         ///
147         bool lockInset(UpdatableInset * inset);
148         ///
149         void showLockedInsetCursor(int x, int y, int asc, int desc);
150         ///
151         void hideLockedInsetCursor();
152         ///
153         bool fitLockedInsetCursor(int x, int y, int asc, int desc);
154         ///
155         int unlockInset(UpdatableInset * inset);
156         ///
157         void lockedInsetStoreUndo(Undo::undo_kind kind);
158         ///
159         void showCursor();
160         ///
161         void hideCursor();
162         ///
163         void toggleSelection(bool = true);
164         ///
165         void toggleToggle();
166         ///
167         void center();
168         ///
169         int scroll(long time);
170
171         /// Scroll the view by a number of pixels
172         void scrollDocView(int);
173
174         ///
175         void switchKeyMap();
176
177         ///
178         bool ChangeInsets(Inset::Code code, string const & from,
179                           string const & to);
180         ///
181         bool ChangeRefsIfUnique(string const & from, string const & to);
182         ///
183         bool ChangeCitationsIfUnique(string const & from, string const & to);
184         ///
185         string const getClipboard() const;
186         ///
187         void stuffClipboard(string const &) const;
188         ///
189         bool dispatch(FuncRequest const & argument);
190         /// height of a normal line in pixels (zoom factor considered)
191         int defaultHeight() const;
192         /// 
193         void haveSelection(bool sel);
194         ///
195         int workHeight() const;
196
197 private:
198         ///
199         struct Pimpl;
200         ///
201         friend struct BufferView::Pimpl;
202         ///
203         Pimpl * pimpl_;
204 };
205
206
207 ///
208 BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
209                                   BufferView::UpdateCodes uc2);
210
211 #endif