]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
45e4cce06be4fc8dc434bb7dfde64c37f1812334
[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
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 updateScrollbar();
54         ///
55         void redoCurrentBuffer();
56         ///
57         int resizeCurrentBuffer();
58         ///
59         void gotoError();
60         ///
61         void cursorPrevious();
62         ///
63         void cursorNext();
64         /// 
65         bool available() const;
66         ///
67         LyXView * owner() const { return owner_; }
68         ///
69         LyXScreen * getScreen()
70                 {
71                         fl_set_timer(timer_cursor, 0.4);
72                         return screen;
73                 }
74         ///
75         void savePosition();
76         ///
77         void restorePosition();
78         /** This holds the mapping between buffer paragraphs and screen rows.
79             This should be private...but not yet. (Lgb)
80         */
81         LyXText * text;
82 private:
83         /// Update pixmap of screen
84         void updateScreen();
85         ///
86         int workAreaExpose();
87         ///
88         void create_view(int, int, int, int);
89         ///
90         Inset * checkInsetHit(int & x, int & y);
91         /// 
92         int ScrollUp(long time);
93         ///
94         int ScrollDown(long time);
95         ///
96         void ScrollUpOnePage(long /*time*/);
97         ///
98         void ScrollDownOnePage(long /*time*/);
99
100 public:
101         /// A callback for the up arrow in the scrollbar.
102         static void UpCB(FL_OBJECT * ob, long);
103
104         /// A callback for the slider in the scrollbar.
105         static void ScrollCB(FL_OBJECT * ob, long);
106
107         /// A callback for the down arrow in the scrollbar.
108         static void DownCB(FL_OBJECT * ob, long);
109
110         ///
111         static void CursorToggleCB(FL_OBJECT * ob, long);
112         /** Work area free object handler
113          */
114         static int work_area_handler(FL_OBJECT *, int event,
115                                      FL_Coord, FL_Coord, int key, void *xev);
116 private:
117         ///
118         int WorkAreaMotionNotify(FL_OBJECT * ob,
119                                  Window win,
120                                  int w, int h,
121                                  XEvent * ev, void * d);
122         ///
123         int WorkAreaSelectionNotify(FL_OBJECT *, Window win,
124                                     int /*w*/, int /*h*/,
125                                     XEvent * event, void * /*d*/);
126         ///
127         int WorkAreaButtonPress(FL_OBJECT * ob,
128                                 Window win,
129                                 int w, int h,
130                                 XEvent * ev, void * d);
131         ///
132         int WorkAreaButtonRelease(FL_OBJECT * ob,
133                                   Window win,
134                                   int w, int h,
135                                   XEvent * ev, void * d);
136         ///
137         LyXView * owner_;
138         ///
139         Buffer * buffer_;
140         ///
141         LyXScreen * screen;
142         ///
143         long current_scrollbar_value;
144         ///
145         int work_area_width;
146         ///
147         bool lyx_focus;
148         ///
149         bool work_area_focus;
150         ///
151         FL_OBJECT * work_area;
152         ///
153         FL_OBJECT * figinset_canvas;
154         ///
155         FL_OBJECT * scrollbar;
156         ///
157         FL_OBJECT * button_down;
158         ///
159         FL_OBJECT * button_up;
160         ///
161         FL_OBJECT * timer_cursor;
162         ///
163         BackStack backstack;
164         ///
165         int last_click_x, last_click_y;
166 };
167
168 #endif