]> git.lyx.org Git - lyx.git/blob - src/WorkArea.h
Fixed redraw problem when resizing vertically and cursor inside a inset.
[lyx.git] / src / WorkArea.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 WORKAREA_H
13 #define WORKAREA_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include <utility>
20
21 #include <sigc++/signal_system.h>
22
23 #include FORMS_H_LOCATION
24 #include "Painter.h"
25
26 #ifdef SIGC_CXX_NAMESPACES
27 using SigC::Signal0;
28 using SigC::Signal2;
29 using SigC::Signal3;
30 #endif
31
32 class BufferView;
33
34 ///
35 class WorkArea {
36 public:
37         ///
38         WorkArea(BufferView *, int xpos, int ypos, int width, int height);
39         ///
40         ~WorkArea();
41         ///
42         Painter & getPainter() { return painter_; }
43         ///
44         int workWidth() const { return work_area->w; }
45         ///
46         unsigned int width() const { return work_area->w + scrollbar->w; }
47         ///
48         unsigned int height() const { return work_area->h; }
49         ///
50         int xpos() const { return work_area->x; }
51         ///
52         int ypos() const { return work_area->y; }
53         ///
54         void resize(int xpos, int ypos, int width, int height);
55         ///
56         void redraw() const {
57                 fl_redraw_object(work_area);
58                 fl_redraw_object(scrollbar);
59         }
60         ///
61         void setFocus() const;
62         ///
63         Window getWin() const { return work_area->form->window; }
64         ///
65         bool hasFocus() const { return work_area->focus; }
66         ///
67         bool active() const { return work_area->active; }
68         ///
69         bool belowMouse() const;
70         ///
71         bool visible() const { return work_area->form->visible; }
72         ///
73         void greyOut() const;
74         ///
75         void setScrollbar(double pos, double length_fraction) const;
76         ///
77         void setScrollbarValue(double y) const {
78                 fl_set_scrollbar_value(scrollbar, y);
79         }
80         ///
81         void setScrollbarBounds(double, double) const;
82         ///
83         void setScrollbarIncrements(double inc) const;
84         ///
85         double getScrollbarValue() const {
86                 return fl_get_scrollbar_value(scrollbar);
87         }
88         ///
89         std::pair<float, float> getScrollbarBounds() const {
90                 std::pair<float, float> p;
91                 fl_get_scrollbar_bounds(scrollbar, &p.first, &p.second);
92                 return p;
93         }
94         ///
95         Pixmap getPixmap() const { return workareapixmap; }
96         /// xforms callback
97         static int work_area_handler(FL_OBJECT *, int event,
98                                      FL_Coord, FL_Coord,
99                                      int /*key*/, void * xev);
100         /// xforms callback
101         static void scroll_cb(FL_OBJECT *, long);
102         ///
103         string getClipboard() const;
104         ///
105         void putClipboard(string const &) const;
106         ///
107         BufferView * owner() const { return owner_; }
108
109         // Signals
110         ///
111         Signal0<void> workAreaExpose;
112         ///
113         Signal2<void, KeySym, unsigned int> workAreaKeyPress;
114         ///
115         Signal3<void, int, int, unsigned int> workAreaButtonPress;
116         ///
117         Signal3<void, int, int, unsigned int> workAreaButtonRelease;
118         ///
119         Signal3<void, int, int, unsigned int> workAreaMotionNotify;
120         ///
121         Signal0<void> workAreaFocus;
122         ///
123         Signal0<void> workAreaUnfocus;
124         ///
125         Signal0<void> workAreaEnter;
126         ///
127         Signal0<void> workAreaLeave;
128         ///
129         Signal3<void, int, int, unsigned int> workAreaDoubleClick;
130         ///
131         Signal3<void, int, int, unsigned int> workAreaTripleClick;
132 private:
133         ///
134         void createPixmap(int, int);
135         ///
136         FL_OBJECT * backgroundbox;
137         ///     
138         FL_OBJECT * work_area;
139         ///
140         FL_OBJECT * scrollbar;
141         ///
142         BufferView * owner_;
143         /// The pixmap overlay on the workarea
144         Pixmap workareapixmap;
145         ///
146         Painter painter_;
147         ///
148         FL_OBJECT * figinset_canvas;
149         /// if we call redraw with true needed for locking-insets
150         bool screen_cleared;
151 };
152 #endif