]> git.lyx.org Git - lyx.git/blob - src/WorkArea.h
some new clipboard code
[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-2000 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 FORMS_H_LOCATION
22 #include "Painter.h"
23
24 class BufferView;
25
26 #define XFORMS_CLIPBOARD 1
27
28 class WorkArea {
29 public:
30         ///
31         WorkArea(BufferView *, int xpos, int ypos, int width, int height);
32         ///
33         ~WorkArea();
34         ///
35         Painter & getPainter() { return painter_; }
36         ///
37         unsigned int workWidth() const { return work_area->w; }
38         ///
39         unsigned int width() const { return work_area->w + scrollbar->w; }
40         ///
41         unsigned int height() const { return work_area->h; }
42         ///
43         int xpos() const { return work_area->x; }
44         ///
45         int ypos() const { return work_area->y; }
46         ///
47         void resize(int xpos, int ypos, int width, int height);
48         ///
49         void redraw() const {
50                 fl_redraw_object(work_area);
51                 fl_redraw_object(scrollbar);
52         }
53         ///
54         void setFocus() const;
55         ///
56         Window getWin() const { return work_area->form->window; }
57         ///
58         bool hasFocus() const { return work_area->focus; }
59         ///
60         bool active() const { return work_area->active; }
61         ///
62         bool belowMouse() const;
63         ///
64         bool visible() const { return work_area->form->visible; }
65         ///
66         void greyOut() const;
67         ///
68         void setScrollbar(double pos, double length_fraction) const;
69         ///
70         void setScrollbarValue(double y) const {
71                 fl_set_scrollbar_value(scrollbar, y);
72         }
73         ///
74         void setScrollbarBounds(double, double) const;
75         ///
76         void setScrollbarIncrements(double inc) const;
77         ///
78         double getScrollbarValue() const {
79                 return fl_get_scrollbar_value(scrollbar);
80         }
81         ///
82         std::pair<float, float> getScrollbarBounds() const {
83                 std::pair<float, float> p;
84                 fl_get_scrollbar_bounds(scrollbar, &p.first, &p.second);
85                 return p;
86         }
87         ///
88         Pixmap getPixmap() const { return workareapixmap; }
89         /// xforms callback
90         static int work_area_handler(FL_OBJECT *, int event,
91                                      FL_Coord, FL_Coord,
92                                      int /*key*/, void * xev);
93         /// xforms callback
94         static void scroll_cb(FL_OBJECT *, long);
95 #ifdef XFORMS_CLIPBOARD
96         ///
97         string getClipboard() const;
98         ///
99         void putClipboard(string const &) const;
100 #endif
101 private:
102         ///
103         void createPixmap(int, int);
104         ///
105         FL_OBJECT * backgroundbox;
106         ///     
107         FL_OBJECT * work_area;
108         ///
109         FL_OBJECT * scrollbar;
110         ///
111         BufferView * owner;
112         /// The pixmap overlay on the workarea
113         Pixmap workareapixmap;
114         ///
115         Painter painter_;
116         ///
117         FL_OBJECT * figinset_canvas;
118 };
119 #endif