]> git.lyx.org Git - lyx.git/blob - src/WorkArea.h
two patches from john
[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-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 "Painter.h"
25
26 ///
27 class WorkArea {
28 public:
29         ///
30         WorkArea(int xpos, int ypos, int width, int height);
31         ///
32         ~WorkArea();
33         ///
34         Painter & getPainter() { return painter_; }
35         ///
36         int workWidth() const { return work_area->w; }
37         ///
38         unsigned int width() const { return work_area->w + scrollbar->w; }
39         //unsigned int width() const { return backgroundbox->w + 15; }
40         ///
41         unsigned int height() const { return work_area->h; }
42         //unsigned int height() const { return backgroundbox->h; }
43         ///
44         int xpos() const { return work_area->x; }
45         //int xpos() const { return backgroundbox->x; }
46         ///
47         int ypos() const { return work_area->y; }
48         //int ypos() const { return backgroundbox->y; }
49         ///
50         void resize(int xpos, int ypos, int width, int height);
51         ///
52         void redraw() const {
53                 fl_redraw_object(work_area);
54                 fl_redraw_object(scrollbar);
55         }
56         ///
57         void setFocus() const;
58         ///
59         Window getWin() const { return work_area->form->window; }
60         ///
61         bool hasFocus() const { return work_area->focus; }
62         ///
63         bool active() const { return work_area->active; }
64         ///
65         bool belowMouse() const;
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         SigC::Signal0<void> workAreaExpose;
107         ///
108         SigC::Signal1<void, double> scrollCB;
109         ///
110         SigC::Signal2<void, KeySym, unsigned int> workAreaKeyPress;
111         ///
112         SigC::Signal3<void, int, int, unsigned int> workAreaButtonPress;
113         ///
114         SigC::Signal3<void, int, int, unsigned int> workAreaButtonRelease;
115         ///
116         SigC::Signal3<void, int, int, unsigned int> workAreaMotionNotify;
117         ///
118         SigC::Signal0<void> workAreaFocus;
119         ///
120         SigC::Signal0<void> workAreaUnfocus;
121         ///
122         SigC::Signal0<void> workAreaEnter;
123         ///
124         SigC::Signal0<void> workAreaLeave;
125         ///
126         SigC::Signal3<void, int, int, unsigned int> workAreaDoubleClick;
127         ///
128         SigC::Signal3<void, int, int, unsigned int> workAreaTripleClick;
129         /// emitted when an X client has requested our selection
130         SigC::Signal0<void> selectionRequested;
131  
132         /// handles SelectionRequest X Event, to fill the clipboard
133         void event_cb(XEvent * xev);
134 private:
135         ///
136         void createPixmap(int, int);
137  
138         ///
139         FL_OBJECT * backgroundbox;
140         ///     
141         FL_OBJECT * work_area;
142         ///
143         FL_OBJECT * scrollbar;
144         ///
145         mutable FL_OBJECT * splash_;
146         ///
147         mutable FL_OBJECT * splash_text_;
148         /// The pixmap overlay on the workarea
149         Pixmap workareapixmap;
150         ///
151         Painter painter_;
152         ///
153         FL_OBJECT * figinset_canvas;
154         /// if we call redraw with true needed for locking-insets
155         bool screen_cleared;
156 };
157 #endif