annotate dw/fltkviewbase.hh @ 2104:3e7e5395f0bc

non-ASCII keybindings Alexander Voigt has kindly done some testing, and it seems that this makes bindings to most keys on a German keyboard possible -- except those that need AltGr don't work yet.
author corvid <corvid@lavabit.com>
date Thu, 23 Jun 2011 19:24:11 +0000
parents a91ca614763a
children
rev   line source
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
1 #ifndef __DW_FLTKVIEWBASE_HH__
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
2 #define __DW_FLTKVIEWBASE_HH__
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
3
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
4 #include <time.h> // for time_t
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
5 #include <sys/time.h> // for time_t in FreeBSD
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
6
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1760
diff changeset
7 #include <FL/Fl_Group.H>
1903
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
8 #include <FL/x.H>
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
9
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
10 #include "fltkcore.hh"
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
11
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
12 namespace dw {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
13 namespace fltk {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
14
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1760
diff changeset
15 class FltkViewBase: public FltkView, public Fl_Group
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
16 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
17 private:
1903
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
18 class BackBuffer {
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
19 private:
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
20 int w;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
21 int h;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
22 bool created;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
23
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
24 public:
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
25 Fl_Offscreen offscreen;
2024
f542084fa707 rm spaces
corvid <corvid@lavabit.com>
parents: 2010
diff changeset
26
1903
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
27 BackBuffer ();
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
28 ~BackBuffer ();
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
29 void setSize(int w, int h);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
30 };
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
31
1248
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
32 typedef enum { DRAW_PLAIN, DRAW_CLIPPED, DRAW_BUFFERED } DrawType;
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
33
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
34 int bgColor;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
35 core::Region drawRegion;
1905
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
36 core::Rectangle *exposeArea;
1903
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1860
diff changeset
37 static BackBuffer *backBuffer;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
38 static bool backBufferInUse;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
39
1248
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
40 void draw (const core::Rectangle *rect, DrawType type);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
41 void drawChildWidgets ();
1616
29662d35e068 fix clipped drawing of non-filled rectangles
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1293
diff changeset
42 inline void clipPoint (int *x, int *y, int border) {
1293
090cc554fefb further reduce size of rectangles before drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1290
diff changeset
43 if (exposeArea) {
1905
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
44 if (*x < exposeArea->x - border)
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
45 *x = exposeArea->x - border;
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
46 if (*x > exposeArea->x + exposeArea->width + border)
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
47 *x = exposeArea->x + exposeArea->width + border;
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
48 if (*y < exposeArea->y - border)
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
49 *y = exposeArea->y - border;
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
50 if (*y > exposeArea->y + exposeArea->height + border)
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
51 *y = exposeArea->y + exposeArea->height + border;
1293
090cc554fefb further reduce size of rectangles before drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1290
diff changeset
52 }
1290
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
53 }
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
54 protected:
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
55 core::Layout *theLayout;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
56 int canvasWidth, canvasHeight;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
57 int mouse_x, mouse_y;
1907
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
58 Fl_Widget *focused_child;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
59
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
60 virtual int translateViewXToCanvasX (int x) = 0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
61 virtual int translateViewYToCanvasY (int y) = 0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
62 virtual int translateCanvasXToViewX (int x) = 0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
63 virtual int translateCanvasYToViewY (int y) = 0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
64
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
65 public:
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
66 FltkViewBase (int x, int y, int w, int h, const char *label = 0);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
67 ~FltkViewBase ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
68
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
69 void draw();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
70 int handle (int event);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
71
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
72 void setLayout (core::Layout *layout);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
73 void setCanvasSize (int width, int ascent, int descent);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
74 void setCursor (core::style::Cursor cursor);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
75 void setBgColor (core::style::Color *color);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
76
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
77 void startDrawing (core::Rectangle *area);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
78 void finishDrawing (core::Rectangle *area);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
79 void queueDraw (core::Rectangle *area);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
80 void queueDrawTotal ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
81 void cancelQueueDraw ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
82 void drawPoint (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
83 core::style::Color::Shading shading,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
84 int x, int y);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
85 void drawLine (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
86 core::style::Color::Shading shading,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
87 int x1, int y1, int x2, int y2);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
88 void drawTypedLine (core::style::Color *color,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
89 core::style::Color::Shading shading,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
90 core::style::LineType type, int width,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
91 int x1, int y1, int x2, int y2);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
92 void drawRectangle (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
93 core::style::Color::Shading shading, bool filled,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
94 int x, int y, int width, int height);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
95 void drawArc (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
96 core::style::Color::Shading shading, bool filled,
1618
3e2034b39789 drawArc() take coordinates of center
corvid <corvid@lavabit.com>
parents: 1616
diff changeset
97 int centerX, int centerY, int width, int height,
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
98 int angle1, int angle2);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
99 void drawPolygon (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
100 core::style::Color::Shading shading,
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1833
diff changeset
101 bool filled, bool convex, int points[][2], int npoints);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
102
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
103 core::View *getClippingView (int x, int y, int width, int height);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
104 void mergeClippingView (core::View *clippingView);
399
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
105 void setBufferedDrawing (bool b);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
106 };
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
107
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
108
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
109 class FltkWidgetView: public FltkViewBase
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
110 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
111 public:
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
112 FltkWidgetView (int x, int y, int w, int h, const char *label = 0);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
113 ~FltkWidgetView ();
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 422
diff changeset
114
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
115 void drawText (core::style::Font *font,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
116 core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
117 core::style::Color::Shading shading,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
118 int x, int y, const char *text, int len);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
119 void drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
120 int x, int y, int width, int height);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
121
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
122 bool usesFltkWidgets ();
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1760
diff changeset
123 void addFltkWidget (Fl_Widget *widget, core::Allocation *allocation);
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1760
diff changeset
124 void removeFltkWidget (Fl_Widget *widget);
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1760
diff changeset
125 void allocateFltkWidget (Fl_Widget *widget,
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
126 core::Allocation *allocation);
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1760
diff changeset
127 void drawFltkWidget (Fl_Widget *widget, core::Rectangle *area);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
128 };
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
129
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
130 } // namespace fltk
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
131 } // namespace dw
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
132
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
133 #endif // __DW_FLTKVIEWBASE_HH__
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
134