]> git.lyx.org Git - lyx.git/blob - src/WorkArea.h
2dbfd3878346b37e432dd2ed0695a70a7e3eb973
[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 USE_FL_SCROLLBAR 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 #ifndef USE_FL_SCROLLBAR
53                 fl_redraw_object(button_down);
54                 fl_redraw_object(button_up);
55 #endif
56         }
57         ///
58         void setFocus() const;
59         ///
60         Window getWin() const { return work_area->form->window; }
61         ///
62         bool hasFocus() const { return work_area->focus; }
63         ///
64         bool active() const { return work_area->active; }
65         ///
66         bool belowMouse() const;
67         ///
68         bool visible() const { return work_area->form->visible; }
69         ///
70         void greyOut() const;
71         ///
72         void setScrollbar(double pos, double length_fraction) const;
73         ///
74         void setScrollbarValue(double y) const {
75 #ifdef USE_FL_SCROLLBAR
76                 fl_set_scrollbar_value(scrollbar, y);
77 #else
78                 fl_set_slider_value(scrollbar, y);
79 #endif
80         }
81         ///
82         void setScrollbarBounds(double, double) const;
83         ///
84         void setScrollbarIncrements(double inc) const;
85         ///
86         double getScrollbarValue() const {
87 #ifdef USE_FL_SCROLLBAR
88                 return fl_get_scrollbar_value(scrollbar);
89 #else
90                 return fl_get_slider_value(scrollbar);
91 #endif
92         }
93 #ifdef USE_FL_SCROLLBAR
94         ///
95         std::pair<float, float> getScrollbarBounds() const {
96                 std::pair<float, float> p;
97                 fl_get_scrollbar_bounds(scrollbar, &p.first, &p.second);
98                 return p;
99         }
100 #else
101         ///
102         std::pair<double, double> getScrollbarBounds() const {
103                 std::pair<double, double> p;
104                 fl_get_slider_bounds(scrollbar, &p.first, &p.second);
105                 return p;
106         }
107 #endif
108         ///
109         Pixmap getPixmap() const { return workareapixmap; }
110         /// xforms callback
111         static int work_area_handler(FL_OBJECT *, int event,
112                                      FL_Coord, FL_Coord,
113                                      int /*key*/, void * xev);
114 #ifndef USE_FL_SCROLLBAR
115         /// xforms callback
116         static void up_cb(FL_OBJECT *, long);
117         /// xforms callback
118         static void down_cb(FL_OBJECT *, long);
119 #endif
120         /// xforms callback
121         static void scroll_cb(FL_OBJECT *, long);
122 private:
123         ///
124         void createPixmap(int, int);
125         ///
126         FL_OBJECT * backgroundbox;
127         ///     
128         FL_OBJECT * work_area;
129         ///
130         FL_OBJECT * scrollbar;
131 #ifndef USE_FL_SCROLLBAR
132         ///
133         FL_OBJECT * button_down;
134         ///
135         FL_OBJECT * button_up;
136 #endif
137         ///
138         BufferView * owner;
139         /// The pixmap overlay on the workarea
140         Pixmap workareapixmap;
141         ///
142         Painter painter_;
143         ///
144         FL_OBJECT * figinset_canvas;
145 };
146 #endif