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