Dillo
fltkviewbase.hh
Go to the documentation of this file.
1 #ifndef __DW_FLTKVIEWBASE_HH__
2 #define __DW_FLTKVIEWBASE_HH__
3 
4 #include <time.h> // for time_t
5 #include <sys/time.h> // for time_t in FreeBSD
6 
7 #include <FL/Fl_Group.H>
8 #include <FL/x.H>
9 
10 #include "fltkcore.hh"
11 
12 namespace dw {
13 namespace fltk {
14 
15 class FltkViewBase: public FltkView, public Fl_Group
16 {
17 private:
18  class BackBuffer {
19  private:
20  int w;
21  int h;
22  bool created;
23 
24  public:
25  Fl_Offscreen offscreen;
26 
27  BackBuffer ();
28  ~BackBuffer ();
29  void setSize(int w, int h);
30  };
31 
33 
34  int bgColor;
38  static bool backBufferInUse;
39 
40  void draw (const core::Rectangle *rect, DrawType type);
41  void drawChildWidgets ();
42  inline void clipPoint (int *x, int *y, int border) {
43  if (exposeArea) {
44  if (*x < exposeArea->x - border)
45  *x = exposeArea->x - border;
46  if (*x > exposeArea->x + exposeArea->width + border)
47  *x = exposeArea->x + exposeArea->width + border;
48  if (*y < exposeArea->y - border)
49  *y = exposeArea->y - border;
50  if (*y > exposeArea->y + exposeArea->height + border)
51  *y = exposeArea->y + exposeArea->height + border;
52  }
53  }
54 protected:
58  Fl_Widget *focused_child;
59 
60  virtual int translateViewXToCanvasX (int x) = 0;
61  virtual int translateViewYToCanvasY (int y) = 0;
62  virtual int translateCanvasXToViewX (int x) = 0;
63  virtual int translateCanvasYToViewY (int y) = 0;
64 
65 public:
66  FltkViewBase (int x, int y, int w, int h, const char *label = 0);
67  ~FltkViewBase ();
68 
69  void draw();
70  int handle (int event);
71 
72  void setLayout (core::Layout *layout);
73  void setCanvasSize (int width, int ascent, int descent);
74  void setCursor (core::style::Cursor cursor);
75  void setBgColor (core::style::Color *color);
76 
77  void startDrawing (core::Rectangle *area);
78  void finishDrawing (core::Rectangle *area);
79  void queueDraw (core::Rectangle *area);
80  void queueDrawTotal ();
81  void cancelQueueDraw ();
82  void drawPoint (core::style::Color *color,
84  int x, int y);
85  void drawLine (core::style::Color *color,
87  int x1, int y1, int x2, int y2);
88  void drawTypedLine (core::style::Color *color,
90  core::style::LineType type, int width,
91  int x1, int y1, int x2, int y2);
92  void drawRectangle (core::style::Color *color,
93  core::style::Color::Shading shading, bool filled,
94  int x, int y, int width, int height);
95  void drawArc (core::style::Color *color,
96  core::style::Color::Shading shading, bool filled,
97  int centerX, int centerY, int width, int height,
98  int angle1, int angle2);
99  void drawPolygon (core::style::Color *color,
101  bool filled, bool convex,
102  core::Point *points, int npoints);
103 
104  core::View *getClippingView (int x, int y, int width, int height);
105  void mergeClippingView (core::View *clippingView);
106  void setBufferedDrawing (bool b);
107 };
108 
109 
111 {
112 public:
113  FltkWidgetView (int x, int y, int w, int h, const char *label = 0);
114  ~FltkWidgetView ();
115 
116  void drawText (core::style::Font *font,
117  core::style::Color *color,
119  int x, int y, const char *text, int len);
121  core::style::Color *color,
123  int x, int y, int w, int h,
124  const char *text);
125  void drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot,
126  int x, int y, int width, int height);
127 
128  bool usesFltkWidgets ();
129  void addFltkWidget (Fl_Widget *widget, core::Allocation *allocation);
130  void removeFltkWidget (Fl_Widget *widget);
131  void allocateFltkWidget (Fl_Widget *widget,
132  core::Allocation *allocation);
133  void drawFltkWidget (Fl_Widget *widget, core::Rectangle *area);
134 };
135 
136 } // namespace fltk
137 } // namespace dw
138 
139 #endif // __DW_FLTKVIEWBASE_HH__
140