]> git.lyx.org Git - features.git/blob - src/BufferView.h
doubleClick, trippleClick, new UpdateInsetList some other small stuff
[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 #include "UpdateInset.h"
24
25 class LyXView;
26 class Buffer;
27 class LyXScreen;
28 class Inset;
29 class LyXText;
30 class WorkArea;
31
32 ///
33 class BufferView {
34 public:
35         ///
36         BufferView(LyXView * owner, int , int , int, int);
37         ///
38         ~BufferView();
39         ///
40         Buffer * buffer() const { return buffer_; }
41         ///
42         Painter & painter();
43         ///
44         void buffer(Buffer * b);
45         ///
46         void resize(int, int, int, int);
47         ///
48         void resize();
49         ///
50         void redraw();
51         ///
52         void fitCursor();
53         ///
54         void update();
55         ///
56         void update(signed char f);
57         ///
58         void smallUpdate(signed char f);
59         ///
60         void updateScrollbar();
61         ///
62         void redoCurrentBuffer();
63         ///
64         int resizeCurrentBuffer();
65         ///
66         void gotoError();
67         ///
68         void cursorPrevious();
69         ///
70         void cursorNext();
71         /// 
72         bool available() const;
73         ///
74         LyXView * owner() const { return owner_; }
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();
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         ///
177         void showCursor();
178         ///
179         void hideCursor();
180         ///
181         void toggleSelection(bool = true);
182         ///
183         void toggleToggle();
184         ///
185         void center();
186         
187 private:
188         friend class WorkArea;
189         
190         /// Update pixmap of screen
191         void updateScreen();
192         ///
193         void workAreaExpose();
194         ///
195         void scrollUpOnePage();
196         ///
197         void scrollDownOnePage();
198         ///
199         void create_view();
200         ///
201         Inset * checkInsetHit(int & x, int & y);
202         /// 
203         int scrollUp(long time);
204         ///
205         int scrollDown(long time);
206
207 public:
208         ///
209         bool focus() const;
210         ///
211         void focus(bool);
212         ///
213         bool active() const;
214         ///
215         bool belowMouse() const;
216         /// A callback for the up arrow in the scrollbar.
217         void upCB(long time, int button);
218         /// A callback for the slider in the scrollbar.
219         void scrollCB(double);
220         /// A callback for the down arrow in the scrollbar.
221         void downCB(long time, int button);
222
223         ///
224         static void cursorToggleCB(FL_OBJECT * ob, long);
225
226         ///
227         void setState();
228
229 private:
230         ///
231         void workAreaMotionNotify(int x, int y, unsigned int state);
232         ///
233         void workAreaButtonPress(int x, int y, unsigned int button);
234         ///
235         void workAreaButtonRelease(int x, int y, unsigned int button);
236         ///
237         void workAreaSelectionNotify(Window win, XEvent * event);
238         ///
239         void doubleClick(int x, int y, unsigned int button);
240         ///
241         void trippleClick(int x, int y, unsigned int button);
242         ///
243         LyXView * owner_;
244         ///
245         Buffer * buffer_;
246         ///
247         LyXScreen * screen;
248         ///
249         long current_scrollbar_value;
250         ///
251         bool lyx_focus;
252         ///
253         bool work_area_focus;
254         ///
255         FL_OBJECT * figinset_canvas;
256         ///
257         FL_OBJECT * timer_cursor;
258         ///
259         BackStack backstack;
260         ///
261         int last_click_x, last_click_y;
262         ///
263         WorkArea * workarea;
264         ///
265         UpdateInset updatelist;
266 public:
267         ///
268         void updateInset(Inset *, bool);
269         ///
270         void pushIntoUpdateList(Inset * i) {
271                 updatelist.push(i);
272         }
273 };
274
275 #endif