Dillo v3.1.1-98-g318d1f14
Loading...
Searching...
No Matches
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
12namespace dw {
13namespace fltk {
14
15class FltkViewBase: public FltkView, public Fl_Group
16{
17private:
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
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 }
55protected:
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
66public:
67 FltkViewBase (int x, int y, int w, int h, const char *label = 0);
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);
91 core::style::LineType type, int width,
92 int x1, int y1, int x2, int y2);
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{
113public:
114 FltkWidgetView (int x, int y, int w, int h, const char *label = 0);
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
The platform independent interface for image buffers.
Definition imgbuf.hh:162
The central class for managing and drawing a widget tree.
Definition layout.hh:17
dw::core::Shape implemtation for simple rectangles.
Definition types.hh:70
Implementation for a point set.
Definition types.hh:141
An interface to encapsulate platform dependent drawing.
Definition view.hh:17
void setBgColor(core::style::Color *color)
Set the background of the view.
virtual int translateCanvasXToViewX(int x)=0
void clipPoint(int *x, int *y, int border)
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)
void queueDraw(core::Rectangle *area)
Queue a region, which is given in canvas coordinates, for drawing.
void drawRectangle(core::style::Color *color, core::style::Color::Shading shading, bool filled, int x, int y, int width, int height)
static bool backBufferInUse
void drawLine(core::style::Color *color, core::style::Color::Shading shading, int x1, int y1, int x2, int y2)
void startDrawing(core::Rectangle *area)
Called before drawing.
void cancelQueueDraw()
Cancel a draw queue request.
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)
void drawPoint(core::style::Color *color, core::style::Color::Shading shading, int x, int y)
void setCanvasSize(int width, int ascent, int descent)
Set the canvas size.
static BackBuffer * backBuffer
void finishDrawing(core::Rectangle *area)
Called after drawing.
void drawPolygon(core::style::Color *color, core::style::Color::Shading shading, bool filled, bool convex, core::Point *points, int npoints)
void setLayout(core::Layout *layout)
This methods notifies the view, that it has been attached to a layout.
void setBufferedDrawing(bool b)
void mergeClippingView(core::View *clippingView)
core::View * getClippingView(int x, int y, int width, int height)
virtual int translateViewXToCanvasX(int x)=0
virtual int translateCanvasYToViewY(int y)=0
void queueDrawTotal()
Queue the total viewport for drawing.
void setCursor(core::style::Cursor cursor)
Set the cursor appearance.
virtual int translateViewYToCanvasY(int y)=0
core::Layout * theLayout
core::Rectangle * exposeArea
This interface adds some more methods for all flkt-based views.
void drawFltkWidget(Fl_Widget *widget, core::Rectangle *area)
void removeFltkWidget(Fl_Widget *widget)
void drawImage(core::Imgbuf *imgbuf, int xRoot, int yRoot, int x, int y, int width, int height)
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)
void allocateFltkWidget(Fl_Widget *widget, core::Allocation *allocation)
void addFltkWidget(Fl_Widget *widget, core::Allocation *allocation)
void drawText(core::style::Font *font, core::style::Color *color, core::style::Color::Shading shading, int x, int y, const char *text, int len)
static Layout * layout
static core::Imgbuf * imgbuf
Dw is in this namespace, or sub namespaces of this one.
Represents the allocation, i.e.
Definition types.hh:164