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