]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/XWorkArea.h
Painter and scrollbar API patches
[lyx.git] / src / frontends / xforms / XWorkArea.h
1 // -*- C++ -*-
2 /**
3  * \file XWorkArea.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author unknown
8  * \author John Levon <moz@compsoc.man.ac.uk>
9  */
10
11 #ifndef XWORKAREA_H
12 #define XWORKAREA_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include FORMS_H_LOCATION
19 #include "XPainter.h"
20 #include "frontends/mouse_state.h"
21 #include "frontends/key_state.h"
22
23 #include <boost/signals/signal0.hpp>
24 #include <boost/signals/signal1.hpp>
25 #include <boost/signals/signal2.hpp>
26 #include <boost/signals/signal3.hpp>
27
28 #include <utility>
29
30 ///
31 class WorkArea {
32 public:
33         ///
34         WorkArea(int xpos, int ypos, int width, int height);
35         ///
36         ~WorkArea();
37         ///
38         Painter & getPainter() { return painter_; }
39         ///
40         int workWidth() const { return work_area->w; }
41         ///
42         int workHeight() const { return work_area->h; }
43         ///
44         unsigned int width() const { return work_area->w + scrollbar->w; }
45         //unsigned int width() const { return backgroundbox->w + 15; }
46         ///
47         int xpos() const { return work_area->x; }
48         //int xpos() const { return backgroundbox->x; }
49         ///
50         int ypos() const { return work_area->y; }
51         //int ypos() const { return backgroundbox->y; }
52         ///
53         void resize(int xpos, int ypos, int width, int height);
54         ///
55         void redraw() const {
56                 fl_redraw_object(work_area);
57                 fl_redraw_object(scrollbar);
58         }
59         ///
60         void setFocus() const;
61         ///
62         Window getWin() const { return work_area->form->window; }
63         ///
64         bool hasFocus() const { return work_area->focus; }
65         ///
66         bool visible() const { return work_area->form->visible; }
67         ///
68         void greyOut() const;
69         ///
70         void setScrollbarParams(int height, int pos, int line_height);
71         ///
72         Pixmap getPixmap() const { return workareapixmap; }
73         /// xforms callback
74         static int work_area_handler(FL_OBJECT *, int event,
75                                      FL_Coord, FL_Coord,
76                                      int /*key*/, void * xev);
77  
78         /// xforms callback from scrollbar
79         void scroll_cb();
80         /// a selection exists
81         void haveSelection(bool) const;
82         ///
83         string const getClipboard() const;
84         ///
85         void putClipboard(string const &) const;
86         // Signals
87         ///
88         boost::signal0<void> workAreaExpose;
89         ///
90         boost::signal1<void, int> scrollDocView;
91         ///
92         boost::signal2<void, KeySym, key_modifier::state> workAreaKeyPress;
93         ///
94         boost::signal3<void, int, int, mouse_button::state> workAreaButtonPress;
95         ///
96         boost::signal3<void, int, int, mouse_button::state> workAreaButtonRelease;
97         ///
98         boost::signal3<void, int, int, mouse_button::state> workAreaMotionNotify;
99         ///
100         boost::signal0<void> workAreaFocus;
101         ///
102         boost::signal0<void> workAreaUnfocus;
103         ///
104         boost::signal3<void, int, int, mouse_button::state> workAreaDoubleClick;
105         ///
106         boost::signal3<void, int, int, mouse_button::state> workAreaTripleClick;
107         /// emitted when an X client has requested our selection
108         boost::signal0<void> selectionRequested;
109         /// emitted when another X client has stolen our selection
110         boost::signal0<void> selectionLost;
111
112         /// handles SelectionRequest X Event, to fill the clipboard
113         int event_cb(XEvent * xev);
114 private:
115         ///
116         void createPixmap(int, int);
117
118         ///
119         FL_OBJECT * backgroundbox;
120         ///
121         FL_OBJECT * work_area;
122         ///
123         FL_OBJECT * scrollbar;
124         ///
125         mutable FL_OBJECT * splash_;
126         ///
127         mutable FL_OBJECT * splash_text_;
128         /// The pixmap overlay on the workarea
129         Pixmap workareapixmap;
130         ///
131         XPainter painter_;
132         /// if we call redraw with true needed for locking-insets
133         bool screen_cleared;
134         /// the current document's height (for scrollbar)
135         int doc_height_;
136 };
137  
138 #endif // XWORKAREA_H