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