]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
1d10fc9db451713740a4c38d5f452cf0c45159cb
[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 "BackStack.h"
21 #include "LaTeX.h"
22 #include "undo.h"
23
24 class LyXView;
25 class Buffer;
26 class LyXScreen;
27 class Inset;
28 class LyXText;
29 class WorkArea;
30
31 ///
32 class BufferView {
33 public:
34         ///
35         BufferView(LyXView * owner, int , int , int, int);
36         ///
37         ~BufferView();
38         ///
39         Buffer * buffer() const { return buffer_; }
40 #ifdef USE_PAINTER
41         ///
42         Painter & painter();
43 #endif
44         ///
45         WorkArea * getWorkArea() { return workarea; }
46         ///
47         void buffer(Buffer * b);
48         ///
49         void resize(int, int, int, int);
50         ///
51         void resize();
52         ///
53         void redraw();
54         ///
55         void fitCursor();
56         ///
57         void update();
58         ///
59         void update(signed char f);
60         ///
61         void smallUpdate(signed char f);
62         ///
63         void updateScrollbar();
64         ///
65         void redoCurrentBuffer();
66         ///
67         int resizeCurrentBuffer();
68         ///
69         void gotoError();
70         ///
71         void cursorPrevious();
72         ///
73         void cursorNext();
74         /// 
75         bool available() const;
76         ///
77         LyXView * owner() const { return owner_; }
78         ///
79         LyXScreen * getScreen() {
80                 fl_set_timer(timer_cursor, 0.4);
81                 return screen;
82         }
83         ///
84         void beforeChange();
85         ///
86         void savePosition();
87         ///
88         void restorePosition();
89         /** This holds the mapping between buffer paragraphs and screen rows.
90             This should be private...but not yet. (Lgb)
91         */
92         LyXText * text;
93         ///
94         UpdatableInset * the_locking_inset;
95         ///
96         bool inset_slept;
97         ///
98         int slx;
99         ///
100         int sly;
101         ///
102         void insetUnlock();
103         ///
104         void insetSleep();
105         ///
106         void insetWakeup();
107         ///
108         void replaceWord(string const & replacestring);
109         ///
110         void endOfSpellCheck();
111         ///
112         void selectLastWord();
113         ///
114         char * nextWord(float & value);
115         ///
116         void insertCorrectQuote();
117         ///
118         void gotoNote();
119         ///
120         bool gotoLabel(string const & label);
121         ///
122         void paste();
123         ///
124         void cut();
125         ///
126         void copy();
127         ///
128         void pasteEnvironment();
129         ///
130         void copyEnvironment();
131         ///
132         void hfill();
133         ///
134         void protectedBlank();
135         ///
136         void newline();
137         ///
138         void menuSeparator();
139         ///
140         void endOfSentenceDot();
141         ///
142         void ldots();
143         ///
144         void hyphenationPoint();
145         ///
146         void menuUndo();
147         ///
148         void menuRedo();
149         ///
150         void toggleFloat();
151         ///
152         void openStuff();
153         ///
154         void insertNote();
155         ///
156         void allFloats(char flag, char figmar);
157         /// removes all autodeletable insets
158         bool removeAutoInsets();
159         ///
160         void insertErrors(TeXErrors & terr);
161         ///
162         void setCursorFromRow(int row);
163         /** Insert an inset into the buffer
164             Insert inset into buffer, placing it in a layout of lout,
165             if no_table make sure that it doesn't end up in a table. */
166         void insertInset(Inset * inset, string const & lout = string(),
167                          bool no_table = false);
168         /// open and lock an updatable inset
169         void open_new_inset(UpdatableInset * new_inset);
170         /// Inserts a lyx file at cursor position. Returns false if it fails.
171         bool insertLyXFile(string const & file);
172         ///
173         int lockInset(UpdatableInset * inset);
174         ///
175         void showLockedInsetCursor(long x, long y, int asc, int desc);
176         ///
177         void hideLockedInsetCursor(long x, long y, int asc, int desc);
178         ///
179         void fitLockedInsetCursor(long x, long y, int asc, int desc);
180         ///
181         int unlockInset(UpdatableInset * inset);
182         ///
183         void lockedInsetStoreUndo(Undo::undo_kind kind);
184 private:
185         friend class WorkArea;
186         
187         /// Update pixmap of screen
188         void updateScreen();
189         ///
190         void workAreaExpose();
191         ///
192         void ScrollUpOnePage();
193         ///
194         void ScrollDownOnePage();
195         ///
196         void create_view();
197         ///
198         Inset * checkInsetHit(int & x, int & y);
199         /// 
200         int ScrollUp(long time);
201         ///
202         int ScrollDown(long time);
203
204 public:
205         ///
206         bool focus() const;
207         ///
208         void focus(bool);
209         ///
210         bool active() const;
211         /// A callback for the up arrow in the scrollbar.
212         void UpCB(long time, int button);
213         /// A callback for the slider in the scrollbar.
214         void ScrollCB(double);
215         /// A callback for the down arrow in the scrollbar.
216         void DownCB(long time, int button);
217
218         ///
219         static void CursorToggleCB(FL_OBJECT * ob, long);
220 #if 0
221         /** Work area free object handler
222          */
223         static int work_area_handler(FL_OBJECT *, int event,
224                                      FL_Coord, FL_Coord, int key, void *xev);
225 #endif
226
227         ///
228         void SetState();
229
230 private:
231         ///
232         void WorkAreaMotionNotify(int x, int y, unsigned int state);
233         ///
234         void WorkAreaButtonPress(int x, int y, unsigned int button);
235         ///
236         void WorkAreaButtonRelease(int x, int y, unsigned int button);
237         ///
238         void WorkAreaSelectionNotify(Window win, XEvent * event);
239         ///
240         LyXView * owner_;
241         ///
242         Buffer * buffer_;
243         ///
244         LyXScreen * screen;
245         ///
246         long current_scrollbar_value;
247         ///
248         bool lyx_focus;
249         ///
250         bool work_area_focus;
251         ///
252         FL_OBJECT * figinset_canvas;
253         ///
254         FL_OBJECT * timer_cursor;
255         ///
256         BackStack backstack;
257         ///
258         int last_click_x, last_click_y;
259         ///
260         WorkArea * workarea;
261 };
262
263 #endif