]> git.lyx.org Git - lyx.git/blob - src/WorkArea.h
85aaee9a079e032f798560a2bb392ca02ce67e9b
[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 class WorkArea {
27 public:
28         ///
29         WorkArea(BufferView *, int xpos, int ypos, int width, int height);
30         ///
31         ~WorkArea();
32         ///
33         Painter & getPainter() { return painter_; }
34         ///
35         int workWidth() const { return work_area->w; }
36         ///
37         int width() const { return work_area->w + scrollbar->w; }
38         ///
39         int height() const { return work_area->h; }
40         ///
41         int xpos() const { return work_area->x; }
42         ///
43         int ypos() const { return work_area->y; }
44         ///
45         void resize(int xpos, int ypos, int width, int height);
46         ///
47         void redraw() const {
48                 fl_redraw_object(work_area);
49                 fl_redraw_object(scrollbar);
50                 fl_redraw_object(button_down);
51                 fl_redraw_object(button_up);
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 { fl_set_slider_value(scrollbar, y); }
71         ///
72         void setScrollbarBounds(double, double) const;
73         ///
74         void setScrollbarIncrements(float inc) const;
75         ///
76         double getScrollbarValue() const {
77                 return fl_get_slider_value(scrollbar);
78         }
79         ///
80         std::pair<double, double> getScrollbarBounds() const {
81                 std::pair<double, double> p;
82                 fl_get_slider_bounds(scrollbar, &p.first, &p.second);
83                 return p;
84         }
85         ///
86         Pixmap getPixmap() const { return workareapixmap; }
87         /// xforms callback
88         static int work_area_handler(FL_OBJECT *, int event,
89                                      FL_Coord, FL_Coord,
90                                      int /*key*/, void * xev);
91         /// xforms callback
92         static void up_cb(FL_OBJECT *, long);
93         /// xforms callback
94         static void down_cb(FL_OBJECT *, long);
95         /// xforms callback
96         static void scroll_cb(FL_OBJECT *, long);
97 private:
98         ///
99         void createPixmap(int, int);
100         ///
101         FL_OBJECT * backgroundbox;
102         ///     
103         FL_OBJECT * work_area;
104         ///
105         FL_OBJECT * scrollbar;
106         ///
107         FL_OBJECT * button_down;
108         ///
109         FL_OBJECT * button_up;
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