dillo  3.0.5
About: dillo is a small, fast, extensible Web browser particularly suitable for older or smaller computers and embedded systems (but only limited or no support for frames, CSS, JavaScript, Java).
  Fossies Dox: dillo-3.0.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

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 
73  void setLayout (core::Layout *layout);
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 
dw::fltk::FltkViewBase::handle
int handle(int event)
Definition: fltkviewbase.cc:287
dw::fltk::FltkViewBase::drawLine
void drawLine(core::style::Color *color, core::style::Color::Shading shading, int x1, int y1, int x2, int y2)
Definition: fltkviewbase.cc:455
dw::fltk::FltkViewBase::drawRegion
core::Region drawRegion
Definition: fltkviewbase.hh:35
dw::core::Point
Definition: types.hh:49
dw::core::style::Cursor
Cursor
Definition: style.hh:198
fltkcore.hh
dw::fltk::FltkView
This interface adds some more methods for all flkt-based views.
Definition: fltkplatform.hh:78
dw::fltk::FltkViewBase::mouse_y
int mouse_y
Definition: fltkviewbase.hh:58
dw::fltk::FltkViewBase::DRAW_BUFFERED
Definition: fltkviewbase.hh:32
dw::fltk::FltkViewBase::canvasHeight
int canvasHeight
Definition: fltkviewbase.hh:57
dw::fltk::FltkViewBase::translateCanvasYToViewY
virtual int translateCanvasYToViewY(int y)=0
dw::fltk::FltkWidgetView::addFltkWidget
void addFltkWidget(Fl_Widget *widget, core::Allocation *allocation)
Definition: fltkviewbase.cc:707
dw::fltk::FltkWidgetView::FltkWidgetView
FltkWidgetView(int x, int y, int w, int h, const char *label=0)
Definition: fltkviewbase.cc:602
dw::fltk::FltkViewBase::manageTabToFocus
int manageTabToFocus()
Definition: fltkviewbase.cc:223
dw::fltk::FltkViewBase::DRAW_CLIPPED
Definition: fltkviewbase.hh:32
dw::fltk::FltkViewBase::setBgColor
void setBgColor(core::style::Color *color)
Set the background of the view.
Definition: fltkviewbase.cc:419
dw::core::style::Color
Definition: style.hh:709
dw::fltk::FltkViewBase::focused_child
Fl_Widget * focused_child
Definition: fltkviewbase.hh:59
dw::fltk::FltkViewBase::setCanvasSize
void setCanvasSize(int width, int ascent, int descent)
Set the canvas size.
Definition: fltkviewbase.cc:390
dw::fltk::FltkViewBase::BackBuffer::w
int w
Definition: fltkviewbase.hh:20
dw::fltk::FltkViewBase::getClippingView
core::View * getClippingView(int x, int y, int width, int height)
Definition: fltkviewbase.cc:588
dw::fltk::FltkViewBase::draw
void draw()
Definition: fltkviewbase.cc:95
dw::fltk::FltkWidgetView::drawFltkWidget
void drawFltkWidget(Fl_Widget *widget, core::Rectangle *area)
Definition: fltkviewbase.cc:728
dw::fltk::FltkViewBase::drawTypedLine
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
dw::fltk::FltkViewBase::BackBuffer::~BackBuffer
~BackBuffer()
Definition: fltkviewbase.cc:43
dw::fltk::FltkViewBase::mouse_x
int mouse_x
Definition: fltkviewbase.hh:58
dw::core::style::LineType
LineType
Definition: style.hh:289
dw::core::Rectangle::x
int x
Definition: types.hh:72
dw::fltk::FltkViewBase::BackBuffer
Definition: fltkviewbase.hh:18
dw::core::Allocation
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
dw::fltk::FltkViewBase::theLayout
core::Layout * theLayout
Definition: fltkviewbase.hh:56
dw::core::style::Color::Shading
Shading
Definition: style.hh:725
dw::fltk::FltkViewBase::setCursor
void setCursor(core::style::Cursor cursor)
Set the cursor appearance.
Definition: fltkviewbase.cc:396
dw::fltk::FltkViewBase::drawArc
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
dw::fltk::FltkViewBase::DrawType
DrawType
Definition: fltkviewbase.hh:32
dw::fltk::FltkViewBase::translateViewXToCanvasX
virtual int translateViewXToCanvasX(int x)=0
dw::fltk::FltkViewBase::startDrawing
void startDrawing(core::Rectangle *area)
Called before drawing.
Definition: fltkviewbase.cc:426
dw::fltk::FltkWidgetView
Definition: fltkviewbase.hh:111
dw::fltk::FltkViewBase::bgColor
int bgColor
Definition: fltkviewbase.hh:34
dw::core::style::Font
Definition: style.hh:656
dw::core::Rectangle::height
int height
Definition: types.hh:75
dw::fltk::FltkWidgetView::drawSimpleWrappedText
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
dw::fltk::FltkViewBase::queueDraw
void queueDraw(core::Rectangle *area)
Queue a region, which is given in canvas coordinates, for drawing.
Definition: fltkviewbase.cc:434
dw::fltk::FltkViewBase::translateViewYToCanvasY
virtual int translateViewYToCanvasY(int y)=0
dw::fltk::FltkViewBase::drawRectangle
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
dw::core::Layout
The central class for managing and drawing a widget tree.
Definition: layout.hh:16
dw::fltk::FltkViewBase::BackBuffer::offscreen
Fl_Offscreen offscreen
Definition: fltkviewbase.hh:25
dw::fltk::FltkViewBase
Definition: fltkviewbase.hh:15
dw::fltk::FltkViewBase::canvasWidth
int canvasWidth
Definition: fltkviewbase.hh:57
dw::core::Imgbuf
The platform independent interface for image buffers.
Definition: imgbuf.hh:161
dw::fltk::FltkWidgetView::allocateFltkWidget
void allocateFltkWidget(Fl_Widget *widget, core::Allocation *allocation)
Definition: fltkviewbase.cc:719
dw::fltk::FltkViewBase::drawPoint
void drawPoint(core::style::Color *color, core::style::Color::Shading shading, int x, int y)
Definition: fltkviewbase.cc:449
dw::core::Rectangle
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
dw::fltk::FltkViewBase::backBuffer
static BackBuffer * backBuffer
Definition: fltkviewbase.hh:37
dw::fltk::FltkViewBase::queueDrawTotal
void queueDrawTotal()
Queue the total viewport for drawing.
Definition: fltkviewbase.cc:440
dw::fltk::FltkViewBase::setLayout
void setLayout(core::Layout *layout)
This methods notifies the view, that it has been attached to a layout.
Definition: fltkviewbase.cc:383
dw::core::View
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
dw::fltk::FltkViewBase::mergeClippingView
void mergeClippingView(core::View *clippingView)
Definition: fltkviewbase.cc:595
dw::fltk::FltkViewBase::FltkViewBase
FltkViewBase(int x, int y, int w, int h, const char *label=0)
Definition: fltkviewbase.cc:64
dw::fltk::FltkWidgetView::removeFltkWidget
void removeFltkWidget(Fl_Widget *widget)
Definition: fltkviewbase.cc:714
dw::fltk::FltkWidgetView::usesFltkWidgets
bool usesFltkWidgets()
Definition: fltkviewbase.cc:702
dw::fltk::FltkViewBase::clipPoint
void clipPoint(int *x, int *y, int border)
Definition: fltkviewbase.hh:43
dw::fltk::FltkViewBase::drawChildWidgets
void drawChildWidgets()
Definition: fltkviewbase.cc:188
dw::fltk::FltkViewBase::setBufferedDrawing
void setBufferedDrawing(bool b)
Definition: fltkviewbase.cc:86
dw::fltk::FltkViewBase::finishDrawing
void finishDrawing(core::Rectangle *area)
Called after drawing.
Definition: fltkviewbase.cc:430
dw::fltk::FltkViewBase::BackBuffer::BackBuffer
BackBuffer()
Definition: fltkviewbase.cc:36
dw::fltk::FltkViewBase::DRAW_PLAIN
Definition: fltkviewbase.hh:32
dw::fltk::FltkWidgetView::drawImage
void drawImage(core::Imgbuf *imgbuf, int xRoot, int yRoot, int x, int y, int width, int height)
Definition: fltkviewbase.cc:693
dw
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtextblock.cc:26
dw::fltk::FltkWidgetView::drawText
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
dw::fltk::FltkViewBase::translateCanvasXToViewX
virtual int translateCanvasXToViewX(int x)=0
dw::fltk::FltkViewBase::~FltkViewBase
~FltkViewBase()
Definition: fltkviewbase.cc:81
dw::fltk::FltkViewBase::backBufferInUse
static bool backBufferInUse
Definition: fltkviewbase.hh:38
dw::fltk::FltkWidgetView::~FltkWidgetView
~FltkWidgetView()
Definition: fltkviewbase.cc:608
dw::fltk::FltkViewBase::BackBuffer::created
bool created
Definition: fltkviewbase.hh:22
dw::core::Region
Definition: types.hh:140
dw::core::Rectangle::width
int width
Definition: types.hh:74
dw::fltk::FltkViewBase::BackBuffer::setSize
void setSize(int w, int h)
Definition: fltkviewbase.cc:49
dw::core::Rectangle::y
int y
Definition: types.hh:73
dw::fltk::FltkViewBase::exposeArea
core::Rectangle * exposeArea
Definition: fltkviewbase.hh:36
dw::fltk::FltkViewBase::cancelQueueDraw
void cancelQueueDraw()
Cancel a draw queue request.
Definition: fltkviewbase.cc:445
dw::fltk::FltkViewBase::BackBuffer::h
int h
Definition: fltkviewbase.hh:21
dw::fltk::FltkViewBase::drawPolygon
void drawPolygon(core::style::Color *color, core::style::Color::Shading shading, bool filled, bool convex, core::Point *points, int npoints)
Definition: fltkviewbase.cc:558