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  int manageTabToFocus();
43  inline void clipPoint (int *x, int *y, int border) {
44  if (exposeArea) {
45  if (*x < exposeArea->x - border)
46  *x = exposeArea->x - border;
47  if (*x > exposeArea->x + exposeArea->width + border)
48  *x = exposeArea->x + exposeArea->width + border;
49  if (*y < exposeArea->y - border)
50  *y = exposeArea->y - border;
51  if (*y > exposeArea->y + exposeArea->height + border)
52  *y = exposeArea->y + exposeArea->height + border;
53  }
54  }
55 protected:
59  Fl_Widget *focused_child;
60 
61  virtual int translateViewXToCanvasX (int x) = 0;
62  virtual int translateViewYToCanvasY (int y) = 0;
63  virtual int translateCanvasXToViewX (int x) = 0;
64  virtual int translateCanvasYToViewY (int y) = 0;
65 
66 public:
67  FltkViewBase (int x, int y, int w, int h, const char *label = 0);
68  ~FltkViewBase ();
69 
70  void draw();
71  int handle (int event);
72 
74  void setCanvasSize (int width, int ascent, int descent);
75  void setCursor (core::style::Cursor cursor);
76  void setBgColor (core::style::Color *color);
77 
78  void startDrawing (core::Rectangle *area);
79  void finishDrawing (core::Rectangle *area);
80  void queueDraw (core::Rectangle *area);
81  void queueDrawTotal ();
82  void cancelQueueDraw ();
83  void drawPoint (core::style::Color *color,
85  int x, int y);
86  void drawLine (core::style::Color *color,
88  int x1, int y1, int x2, int y2);
89  void drawTypedLine (core::style::Color *color,
91  core::style::LineType type, int width,
92  int x1, int y1, int x2, int y2);
93  void drawRectangle (core::style::Color *color,
94  core::style::Color::Shading shading, bool filled,
95  int x, int y, int width, int height);
96  void drawArc (core::style::Color *color,
97  core::style::Color::Shading shading, bool filled,
98  int centerX, int centerY, int width, int height,
99  int angle1, int angle2);
100  void drawPolygon (core::style::Color *color,
102  bool filled, bool convex,
103  core::Point *points, int npoints);
104 
105  core::View *getClippingView (int x, int y, int width, int height);
106  void mergeClippingView (core::View *clippingView);
107  void setBufferedDrawing (bool b);
108 };
109 
110 
112 {
113 public:
114  FltkWidgetView (int x, int y, int w, int h, const char *label = 0);
115  ~FltkWidgetView ();
116 
117  void drawText (core::style::Font *font,
118  core::style::Color *color,
120  int x, int y, const char *text, int len);
122  core::style::Color *color,
124  int x, int y, int w, int h,
125  const char *text);
126  void drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot,
127  int x, int y, int width, int height);
128 
129  bool usesFltkWidgets ();
130  void addFltkWidget (Fl_Widget *widget, core::Allocation *allocation);
131  void removeFltkWidget (Fl_Widget *widget);
132  void allocateFltkWidget (Fl_Widget *widget,
133  core::Allocation *allocation);
134  void drawFltkWidget (Fl_Widget *widget, core::Rectangle *area);
135 };
136 
137 } // namespace fltk
138 } // namespace dw
139 
140 #endif // __DW_FLTKVIEWBASE_HH__
141 
void drawFltkWidget(Fl_Widget *widget, core::Rectangle *area)
Definition: fltkviewbase.cc:728
void drawArc(core::style::Color *color, core::style::Color::Shading shading, bool filled, int centerX, int centerY, int width, int height, int angle1, int angle2)
Definition: fltkviewbase.cc:541
Cursor
Definition: style.hh:200
Definition: fltkviewbase.hh:15
void startDrawing(core::Rectangle *area)
Called before drawing.
Definition: fltkviewbase.cc:426
Definition: fltkviewbase.hh:111
core::Layout * theLayout
Definition: fltkviewbase.hh:56
virtual int translateViewYToCanvasY(int y)=0
static BackBuffer * backBuffer
Definition: fltkviewbase.hh:37
void setCursor(core::style::Cursor cursor)
Set the cursor appearance.
Definition: fltkviewbase.cc:396
void queueDraw(core::Rectangle *area)
Queue a region, which is given in canvas coordinates, for drawing.
Definition: fltkviewbase.cc:434
Definition: style.hh:751
Shading
Definition: style.hh:767
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
int handle(int event)
Definition: fltkviewbase.cc:287
BackBuffer()
Definition: fltkviewbase.cc:36
core::Region drawRegion
Definition: fltkviewbase.hh:35
void drawChildWidgets()
Definition: fltkviewbase.cc:188
virtual int translateViewXToCanvasX(int x)=0
LineType
Definition: style.hh:291
The central class for managing and drawing a widget tree.
Definition: layout.hh:16
void finishDrawing(core::Rectangle *area)
Called after drawing.
Definition: fltkviewbase.cc:430
Definition: fltkviewbase.hh:32
int x
Definition: types.hh:72
void drawImage(core::Imgbuf *imgbuf, int xRoot, int yRoot, int x, int y, int width, int height)
Definition: fltkviewbase.cc:693
void setBufferedDrawing(bool b)
Definition: fltkviewbase.cc:86
Definition: fltkviewbase.hh:32
FltkViewBase(int x, int y, int w, int h, const char *label=0)
Definition: fltkviewbase.cc:64
static Layout * layout
Definition: dw_anchors_test.cc:38
Fl_Offscreen offscreen
Definition: fltkviewbase.hh:25
void setSize(int w, int h)
Definition: fltkviewbase.cc:49
void queueDrawTotal()
Queue the total viewport for drawing.
Definition: fltkviewbase.cc:440
void drawTypedLine(core::style::Color *color, core::style::Color::Shading shading, core::style::LineType type, int width, int x1, int y1, int x2, int y2)
Definition: fltkviewbase.cc:471
int h
Definition: fltkviewbase.hh:21
Definition: style.hh:698
void removeFltkWidget(Fl_Widget *widget)
Definition: fltkviewbase.cc:714
void cancelQueueDraw()
Cancel a draw queue request.
Definition: fltkviewbase.cc:445
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
void setLayout(core::Layout *layout)
This methods notifies the view, that it has been attached to a layout.
Definition: fltkviewbase.cc:383
FltkWidgetView(int x, int y, int w, int h, const char *label=0)
Definition: fltkviewbase.cc:602
void mergeClippingView(core::View *clippingView)
Definition: fltkviewbase.cc:595
bool usesFltkWidgets()
Definition: fltkviewbase.cc:702
Definition: types.hh:140
int mouse_x
Definition: fltkviewbase.hh:58
This interface adds some more methods for all flkt-based views.
Definition: fltkplatform.hh:78
int canvasHeight
Definition: fltkviewbase.hh:57
void setCanvasSize(int width, int ascent, int descent)
Set the canvas size.
Definition: fltkviewbase.cc:390
virtual int translateCanvasYToViewY(int y)=0
Fl_Widget * focused_child
Definition: fltkviewbase.hh:59
int mouse_y
Definition: fltkviewbase.hh:58
int w
Definition: fltkviewbase.hh:20
void draw()
Definition: fltkviewbase.cc:95
void drawText(core::style::Font *font, core::style::Color *color, core::style::Color::Shading shading, int x, int y, const char *text, int len)
Definition: fltkviewbase.cc:612
void drawPolygon(core::style::Color *color, core::style::Color::Shading shading, bool filled, bool convex, core::Point *points, int npoints)
Definition: fltkviewbase.cc:558
int height
Definition: types.hh:75
bool created
Definition: fltkviewbase.hh:22
int bgColor
Definition: fltkviewbase.hh:34
~FltkWidgetView()
Definition: fltkviewbase.cc:608
core::View * getClippingView(int x, int y, int width, int height)
Definition: fltkviewbase.cc:588
void drawLine(core::style::Color *color, core::style::Color::Shading shading, int x1, int y1, int x2, int y2)
Definition: fltkviewbase.cc:455
int manageTabToFocus()
Definition: fltkviewbase.cc:223
The platform independent interface for image buffers.
Definition: imgbuf.hh:161
Definition: fltkviewbase.hh:32
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtablecell.cc:28
static core::Imgbuf * imgbuf
Definition: dw_images_scaled.cc:38
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
void addFltkWidget(Fl_Widget *widget, core::Allocation *allocation)
Definition: fltkviewbase.cc:707
void setBgColor(core::style::Color *color)
Set the background of the view.
Definition: fltkviewbase.cc:419
int width
Definition: types.hh:74
void drawPoint(core::style::Color *color, core::style::Color::Shading shading, int x, int y)
Definition: fltkviewbase.cc:449
DrawType
Definition: fltkviewbase.hh:32
int canvasWidth
Definition: fltkviewbase.hh:57
virtual int translateCanvasXToViewX(int x)=0
Definition: types.hh:49
void drawSimpleWrappedText(core::style::Font *font, core::style::Color *color, core::style::Color::Shading shading, int x, int y, int w, int h, const char *text)
Definition: fltkviewbase.cc:679
static bool backBufferInUse
Definition: fltkviewbase.hh:38
int y
Definition: types.hh:73
void clipPoint(int *x, int *y, int border)
Definition: fltkviewbase.hh:43
core::Rectangle * exposeArea
Definition: fltkviewbase.hh:36
Definition: fltkviewbase.hh:18
~BackBuffer()
Definition: fltkviewbase.cc:43
void allocateFltkWidget(Fl_Widget *widget, core::Allocation *allocation)
Definition: fltkviewbase.cc:719
void drawRectangle(core::style::Color *color, core::style::Color::Shading shading, bool filled, int x, int y, int width, int height)
Definition: fltkviewbase.cc:504
~FltkViewBase()
Definition: fltkviewbase.cc:81