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