]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/XWorkArea.h
apply workarea() patch. Most of it is orthogonal to the scoped_ptr
[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         unsigned int width() const { return work_area->w + scrollbar->w; }
44         //unsigned int width() const { return backgroundbox->w + 15; }
45         ///
46         unsigned int height() const { return work_area->h; }
47         //unsigned int height() const { return backgroundbox->h; }
48         ///
49         int xpos() const { return work_area->x; }
50         //int xpos() const { return backgroundbox->x; }
51         ///
52         int ypos() const { return work_area->y; }
53         //int ypos() const { return backgroundbox->y; }
54         ///
55         void resize(int xpos, int ypos, int width, int height);
56         ///
57         void redraw() const {
58                 fl_redraw_object(work_area);
59                 fl_redraw_object(scrollbar);
60         }
61         ///
62         void setFocus() const;
63         ///
64         Window getWin() const { return work_area->form->window; }
65         ///
66         bool hasFocus() const { return work_area->focus; }
67         ///
68         bool visible() const { return work_area->form->visible; }
69         ///
70         void greyOut() const;
71         ///
72         void setScrollbar(double pos, double length_fraction) const;
73         ///
74         void setScrollbarValue(double y) const {
75                 fl_set_scrollbar_value(scrollbar, y);
76         }
77         ///
78         void setScrollbarBounds(double, double) const;
79         ///
80         void setScrollbarIncrements(double inc) const;
81         ///
82         double getScrollbarValue() const {
83                 return fl_get_scrollbar_value(scrollbar);
84         }
85         ///
86         std::pair<float, float> const getScrollbarBounds() const {
87                 std::pair<float, float> p;
88                 fl_get_scrollbar_bounds(scrollbar, &p.first, &p.second);
89                 return p;
90         }
91         ///
92         Pixmap getPixmap() const { return workareapixmap; }
93         /// xforms callback
94         static int work_area_handler(FL_OBJECT *, int event,
95                                      FL_Coord, FL_Coord,
96                                      int /*key*/, void * xev);
97         /// xforms callback
98         static void scroll_cb(FL_OBJECT *, long);
99         /// a selection exists
100         void haveSelection(bool) const;
101         ///
102         string const getClipboard() const;
103         ///
104         void putClipboard(string const &) const;
105         // Signals
106         ///
107         boost::signal0<void> workAreaExpose;
108         ///
109         boost::signal1<void, double> scrollCB;
110         ///
111         boost::signal2<void, KeySym, key_modifier::state> workAreaKeyPress;
112         ///
113         boost::signal3<void, int, int, mouse_button::state> workAreaButtonPress;
114         ///
115         boost::signal3<void, int, int, mouse_button::state> workAreaButtonRelease;
116         ///
117         boost::signal3<void, int, int, mouse_button::state> workAreaMotionNotify;
118         ///
119         boost::signal0<void> workAreaFocus;
120         ///
121         boost::signal0<void> workAreaUnfocus;
122         ///
123         boost::signal0<void> workAreaEnter;
124         ///
125         boost::signal0<void> workAreaLeave;
126         ///
127         boost::signal3<void, int, int, mouse_button::state> workAreaDoubleClick;
128         ///
129         boost::signal3<void, int, int, mouse_button::state> workAreaTripleClick;
130         /// emitted when an X client has requested our selection
131         boost::signal0<void> selectionRequested;
132         /// emitted when another X client has stolen our selection
133         boost::signal0<void> selectionLost;
134
135         /// handles SelectionRequest X Event, to fill the clipboard
136         int event_cb(XEvent * xev);
137 private:
138         ///
139         void createPixmap(int, int);
140
141         ///
142         FL_OBJECT * backgroundbox;
143         ///
144         FL_OBJECT * work_area;
145         ///
146         FL_OBJECT * scrollbar;
147         ///
148         mutable FL_OBJECT * splash_;
149         ///
150         mutable FL_OBJECT * splash_text_;
151         /// The pixmap overlay on the workarea
152         Pixmap workareapixmap;
153         ///
154         Painter painter_;
155         /// if we call redraw with true needed for locking-insets
156         bool screen_cleared;
157 };
158 #endif