]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
e89b6b2cfea1886952ba3fbb29469f26483780a0
[lyx.git] / src / BufferView.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *        
7  *           Copyright (C) 1995 Matthias Ettrich
8  *           Copyright (C) 1995-1998 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
23 #define MOVE_TEXT 1
24
25 class LyXView;
26 class Buffer;
27 class LyXScreen;
28 class Inset;
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 #ifdef MOVE_TEXT
52         ///
53         void update(signed char f);
54 #endif
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         {
74                 fl_set_timer(timer_cursor, 0.4);
75                 return screen;
76         }
77         ///
78         void savePosition();
79         ///
80         void restorePosition();
81 #ifdef MOVE_TEXT
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 #endif
87 private:
88         /// Update pixmap of screen
89         void updateScreen();
90         ///
91         int workAreaExpose();
92         ///
93         void create_view(int, int, int, int);
94         ///
95         Inset * checkInsetHit(int & x, int & y);
96         /// 
97         int ScrollUp(long time);
98         ///
99         int ScrollDown(long time);
100         ///
101         void ScrollUpOnePage(long /*time*/);
102         ///
103         void ScrollDownOnePage(long /*time*/);
104
105 public:
106         /// A callback for the up arrow in the scrollbar.
107         static void UpCB(FL_OBJECT * ob, long);
108
109         /// A callback for the slider in the scrollbar.
110         static void ScrollCB(FL_OBJECT * ob, long);
111
112         /// A callback for the down arrow in the scrollbar.
113         static void DownCB(FL_OBJECT * ob, long);
114
115         ///
116         static void CursorToggleCB(FL_OBJECT * ob, long);
117         /** Work area free object handler
118          */
119         static int work_area_handler(FL_OBJECT *, int event,
120                                      FL_Coord, FL_Coord, int key, void *xev);
121 private:
122         ///
123         int WorkAreaMotionNotify(FL_OBJECT * ob,
124                                  Window win,
125                                  int w, int h,
126                                  XEvent * ev, void * d);
127         ///
128         int WorkAreaSelectionNotify(FL_OBJECT *, Window win,
129                                     int /*w*/, int /*h*/,
130                                     XEvent * event, void * /*d*/);
131         ///
132         int WorkAreaButtonPress(FL_OBJECT * ob,
133                                 Window win,
134                                 int w, int h,
135                                 XEvent * ev, void * d);
136         ///
137         int WorkAreaButtonRelease(FL_OBJECT * ob,
138                                   Window win,
139                                   int w, int h,
140                                   XEvent * ev, void * d);
141         ///
142         LyXView * owner_;
143         ///
144         Buffer * buffer_;
145         ///
146         LyXScreen * screen;
147         ///
148         long current_scrollbar_value;
149         ///
150         int work_area_width;
151         ///
152         bool lyx_focus;
153         ///
154         bool work_area_focus;
155         ///
156         FL_OBJECT * work_area;
157         ///
158         FL_OBJECT * figinset_canvas;
159         ///
160         FL_OBJECT * scrollbar;
161         ///
162         FL_OBJECT * button_down;
163         ///
164         FL_OBJECT * button_up;
165         ///
166         FL_OBJECT * timer_cursor;
167         ///
168         BackStack backstack;
169         ///
170         int last_click_x, last_click_y;
171 };
172
173 #endif