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