]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/XWorkArea.h
Remove enter/leaveView since core has no right to know when
[lyx.git] / src / frontends / xforms / XWorkArea.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-2001 The LyX Team.
9  *
10  * ======================================================*/
11
12 #ifndef XWORKAREA_H
13 #define XWORKAREA_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include FORMS_H_LOCATION
20 #include "frontends/Painter.h"
21 #include "frontends/mouse_state.h"
22 #include "frontends/key_state.h"
23
24 #include <boost/signals/signal0.hpp>
25 #include <boost/signals/signal1.hpp>
26 #include <boost/signals/signal2.hpp>
27 #include <boost/signals/signal3.hpp>
28
29 #include <utility>
30
31 ///
32 class WorkArea {
33 public:
34         ///
35         WorkArea(int xpos, int ypos, int width, int height);
36         ///
37         ~WorkArea();
38         ///
39         Painter & getPainter() { return painter_; }
40         ///
41         int workWidth() const { return work_area->w; }
42         ///
43         int workHeight() const { return work_area->h; }
44         ///
45         unsigned int width() const { return work_area->w + scrollbar->w; }
46         //unsigned int width() const { return backgroundbox->w + 15; }
47         ///
48         int xpos() const { return work_area->x; }
49         //int xpos() const { return backgroundbox->x; }
50         ///
51         int ypos() const { return work_area->y; }
52         //int ypos() const { return backgroundbox->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 visible() const { return work_area->form->visible; }
68         ///
69         void greyOut() const;
70         ///
71         void setScrollbar(double pos, double length_fraction) const;
72         ///
73         void setScrollbarValue(double y) const {
74                 fl_set_scrollbar_value(scrollbar, y);
75         }
76         ///
77         void setScrollbarBounds(double, double) const;
78         ///
79         void setScrollbarIncrements(double inc) const;
80         ///
81         double getScrollbarValue() const {
82                 return fl_get_scrollbar_value(scrollbar);
83         }
84         ///
85         std::pair<float, float> const getScrollbarBounds() const {
86                 std::pair<float, float> p;
87                 fl_get_scrollbar_bounds(scrollbar, &p.first, &p.second);
88                 return p;
89         }
90         ///
91         Pixmap getPixmap() const { return workareapixmap; }
92         /// xforms callback
93         static int work_area_handler(FL_OBJECT *, int event,
94                                      FL_Coord, FL_Coord,
95                                      int /*key*/, void * xev);
96         /// xforms callback
97         static void scroll_cb(FL_OBJECT *, long);
98         /// a selection exists
99         void haveSelection(bool) const;
100         ///
101         string const getClipboard() const;
102         ///
103         void putClipboard(string const &) const;
104         // Signals
105         ///
106         boost::signal0<void> workAreaExpose;
107         ///
108         boost::signal1<void, double> scrollCB;
109         ///
110         boost::signal2<void, KeySym, key_modifier::state> workAreaKeyPress;
111         ///
112         boost::signal3<void, int, int, mouse_button::state> workAreaButtonPress;
113         ///
114         boost::signal3<void, int, int, mouse_button::state> workAreaButtonRelease;
115         ///
116         boost::signal3<void, int, int, mouse_button::state> workAreaMotionNotify;
117         ///
118         boost::signal0<void> workAreaFocus;
119         ///
120         boost::signal0<void> workAreaUnfocus;
121         ///
122         boost::signal3<void, int, int, mouse_button::state> workAreaDoubleClick;
123         ///
124         boost::signal3<void, int, int, mouse_button::state> workAreaTripleClick;
125         /// emitted when an X client has requested our selection
126         boost::signal0<void> selectionRequested;
127         /// emitted when another X client has stolen our selection
128         boost::signal0<void> selectionLost;
129
130         /// handles SelectionRequest X Event, to fill the clipboard
131         int event_cb(XEvent * xev);
132 private:
133         ///
134         void createPixmap(int, int);
135
136         ///
137         FL_OBJECT * backgroundbox;
138         ///
139         FL_OBJECT * work_area;
140         ///
141         FL_OBJECT * scrollbar;
142         ///
143         mutable FL_OBJECT * splash_;
144         ///
145         mutable FL_OBJECT * splash_text_;
146         /// The pixmap overlay on the workarea
147         Pixmap workareapixmap;
148         ///
149         Painter painter_;
150         /// if we call redraw with true needed for locking-insets
151         bool screen_cleared;
152 };
153 #endif