annotate dw/fltkviewbase.cc @ 2012:bfb8bc9ddf62

Avoid lots of flicker while resizing the window (when "buffered_drawing" is set to 0 or 1)
author Jorge Arellano Cid <jcid@dillo.org>
date Fri, 13 May 2011 14:14:43 -0400
parents 234097ef5e23
children a96b5e1b4b3c
rev   line source
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
1 /*
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
2 * Dillo Widget
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 * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
5 *
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
8 * the Free Software Foundation; either version 3 of the License, or
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
9 * (at your option) any later version.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
10 *
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
14 * GNU General Public License for more details.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
15 *
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
972
d7dbd3dcfa38 Updated the GPL copyright note in the source files
Detlef Riekenberg <wine.dev@web.de>
parents: 930
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
18 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
19
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
20
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
21
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
22 #include "fltkviewport.hh"
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
23
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
24 #include <FL/Fl.H>
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
25 #include <FL/fl_draw.H>
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
26
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
27 #include <stdio.h>
1713
4d87e55c0bbb Add utf8 uppercasing to small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
28 #include <wchar.h>
4d87e55c0bbb Add utf8 uppercasing to small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
29 #include <wctype.h>
772
c1104104babf Added lout/msg.h and normalized debug messages to use it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 464
diff changeset
30 #include "../lout/msg.h"
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
31
1907
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
32 extern Fl_Widget* fl_oldfocus;
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
33
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
34 using namespace lout::object;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
35 using namespace lout::container::typed;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
36
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
37 namespace dw {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
38 namespace fltk {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
39
1903
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
40 FltkViewBase::BackBuffer::BackBuffer ()
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
41 {
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
42 w = 0;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
43 h = 0;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
44 created = false;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
45 }
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
46
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
47 FltkViewBase::BackBuffer::~BackBuffer ()
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
48 {
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
49 if (created)
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
50 fl_delete_offscreen (offscreen);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
51 }
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
52
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
53 void FltkViewBase::BackBuffer::setSize (int w, int h)
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
54 {
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
55 if (!created || w > this->w || h > this->h) {
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
56 this->w = w;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
57 this->h = h;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
58 if (created)
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
59 fl_delete_offscreen (offscreen);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
60 offscreen = fl_create_offscreen (w, h);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
61 created = true;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
62 }
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
63 }
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
64
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
65 FltkViewBase::BackBuffer *FltkViewBase::backBuffer;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
66 bool FltkViewBase::backBufferInUse;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
67
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
68 FltkViewBase::FltkViewBase (int x, int y, int w, int h, const char *label):
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
69 Fl_Group (x, y, w, h, label)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
70 {
1875
d7dc24f8cdfb prevent new Fl_Widgets from automatically being added to a Fl_Group
corvid <corvid@lavabit.com>
parents: 1860
diff changeset
71 Fl_Group::current(0);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
72 canvasWidth = 1;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
73 canvasHeight = 1;
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
74 bgColor = FL_WHITE;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
75 mouse_x = mouse_y = 0;
1907
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
76 focused_child = NULL;
1293
090cc554fefb further reduce size of rectangles before drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1290
diff changeset
77 exposeArea = NULL;
399
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
78 if (backBuffer == NULL) {
1903
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
79 backBuffer = new BackBuffer ();
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
80 }
2012
bfb8bc9ddf62 Avoid lots of flicker while resizing the window
Jorge Arellano Cid <jcid@dillo.org>
parents: 2009
diff changeset
81 box(FL_NO_BOX);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
82 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
83
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
84 FltkViewBase::~FltkViewBase ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
85 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
86 cancelQueueDraw ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
87 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
88
399
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
89 void FltkViewBase::setBufferedDrawing (bool b) {
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
90 if (b && backBuffer == NULL) {
1903
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
91 backBuffer = new BackBuffer ();
399
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
92 } else if (!b && backBuffer != NULL) {
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
93 delete backBuffer;
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
94 backBuffer = NULL;
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
95 }
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
96 }
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
97
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
98 void FltkViewBase::draw ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
99 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
100 int d = damage ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
101
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
102 if ((d & FL_DAMAGE_USER1) && !(d & FL_DAMAGE_EXPOSE)) {
1347
4704ad910042 remove "using namespace" statements from header files
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1329
diff changeset
103 lout::container::typed::Iterator <core::Rectangle> it;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
104
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
105 for (it = drawRegion.rectangles (); it.hasNext (); ) {
1248
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
106 draw (it.getNext (), DRAW_BUFFERED);
347
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 drawRegion.clear ();
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
110 d &= ~FL_DAMAGE_USER1;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
111 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
112
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
113 if (d & FL_DAMAGE_CHILD) {
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
114 drawChildWidgets ();
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
115 d &= ~FL_DAMAGE_CHILD;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
116 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
117
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
118 if (d) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
119 dw::core::Rectangle rect (
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
120 translateViewXToCanvasX (x ()),
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
121 translateViewYToCanvasY (y ()),
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
122 w (),
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
123 h ());
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
124
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
125 if (d == FL_DAMAGE_SCROLL) {
1248
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
126 // a clipping rectangle has already been set by fltk::scrollrect ()
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
127 draw (&rect, DRAW_PLAIN);
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
128 } else {
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
129 draw (&rect, DRAW_CLIPPED);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
130 drawRegion.clear ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
131 }
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 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
134
422
85668a711645 - Unused code cleanup.
jcid
parents: 401
diff changeset
135 void FltkViewBase::draw (const core::Rectangle *rect,
1248
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
136 DrawType type)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
137 {
1919
e920355164cf minimize draw rect before passing it to fl_clip_box to avoid overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1907
diff changeset
138 int X = translateCanvasXToViewX (rect->x);
e920355164cf minimize draw rect before passing it to fl_clip_box to avoid overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1907
diff changeset
139 int Y = translateCanvasYToViewY (rect->y);
e920355164cf minimize draw rect before passing it to fl_clip_box to avoid overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1907
diff changeset
140 int W, H;
e920355164cf minimize draw rect before passing it to fl_clip_box to avoid overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1907
diff changeset
141
e920355164cf minimize draw rect before passing it to fl_clip_box to avoid overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1907
diff changeset
142 // fl_clip_box() can't handle values greater than SHRT_MAX!
e920355164cf minimize draw rect before passing it to fl_clip_box to avoid overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1907
diff changeset
143 if (X > x () + w () || Y > y () + h ())
e920355164cf minimize draw rect before passing it to fl_clip_box to avoid overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1907
diff changeset
144 return;
1849
a2e5201f8fe7 fix scroll performance
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1848
diff changeset
145
1919
e920355164cf minimize draw rect before passing it to fl_clip_box to avoid overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1907
diff changeset
146 W = X + rect->width > x () + w () ? x () + w () - X : rect->width;
e920355164cf minimize draw rect before passing it to fl_clip_box to avoid overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1907
diff changeset
147 H = Y + rect->height > y () + h () ? y () + h () - Y : rect->height;
e920355164cf minimize draw rect before passing it to fl_clip_box to avoid overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1907
diff changeset
148
e920355164cf minimize draw rect before passing it to fl_clip_box to avoid overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1907
diff changeset
149 fl_clip_box(X, Y, W, H, X, Y, W, H);
1849
a2e5201f8fe7 fix scroll performance
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1848
diff changeset
150
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
151 core::Rectangle r (translateViewXToCanvasX (X),
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
152 translateViewYToCanvasY (Y), W, H);
1903
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
153
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
154 if (r.isEmpty ())
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
155 return;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
156
1905
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
157 exposeArea = &r;
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
158
1903
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
159 if (type == DRAW_BUFFERED && backBuffer && !backBufferInUse) {
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
160 backBufferInUse = true;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
161 backBuffer->setSize (X + W, Y + H); // would be nicer to use (W, H)...
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
162 fl_begin_offscreen (backBuffer->offscreen);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
163 fl_push_matrix ();
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
164 fl_color (bgColor);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
165 fl_rectf (X, Y, W, H);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
166 theLayout->expose (this, &r);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
167 fl_pop_matrix ();
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
168 fl_end_offscreen ();
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
169 fl_copy_offscreen (X, Y, W, H, backBuffer->offscreen, X, Y);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
170 backBufferInUse = false;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
171 } else if (type == DRAW_BUFFERED || type == DRAW_CLIPPED) {
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
172 // if type == DRAW_BUFFERED but we do not have backBuffer available
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
173 // we fall back to clipped drawing
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
174 fl_push_clip (X, Y, W, H);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
175 fl_color (bgColor);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
176 fl_rectf (X, Y, W, H);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
177 theLayout->expose (this, &r);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
178 fl_pop_clip ();
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
179 } else {
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
180 fl_color (bgColor);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
181 fl_rectf (X, Y, W, H);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
182 theLayout->expose (this, &r);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
183 }
1905
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
184
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
185 exposeArea = NULL;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
186 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
187
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
188 void FltkViewBase::drawChildWidgets () {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
189 for (int i = children () - 1; i >= 0; i--) {
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
190 Fl_Widget& w = *child(i);
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
191 #if 0
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
192 PORT1.3
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
193 if (w.damage() & DAMAGE_CHILD_LABEL) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
194 draw_outside_label(w);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
195 w.set_damage(w.damage() & ~DAMAGE_CHILD_LABEL);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
196 }
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
197 #endif
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
198 update_child(w);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
199 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
200 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
201
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
202 core::ButtonState getDwButtonState ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
203 {
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
204 int s1 = Fl::event_state ();
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
205 int s2 = (core::ButtonState)0;
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
206
1792
c4dd094670d3 more key/button modifiers
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
207 if (s1 & FL_SHIFT) s2 |= core::SHIFT_MASK;
c4dd094670d3 more key/button modifiers
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
208 if (s1 & FL_CTRL) s2 |= core::CONTROL_MASK;
c4dd094670d3 more key/button modifiers
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
209 if (s1 & FL_ALT) s2 |= core::META_MASK;
c4dd094670d3 more key/button modifiers
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
210 if (s1 & FL_BUTTON1) s2 |= core::BUTTON1_MASK;
c4dd094670d3 more key/button modifiers
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
211 if (s1 & FL_BUTTON2) s2 |= core::BUTTON2_MASK;
c4dd094670d3 more key/button modifiers
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
212 if (s1 & FL_BUTTON3) s2 |= core::BUTTON3_MASK;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
213
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
214 return (core::ButtonState)s2;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
215 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
216
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
217 int FltkViewBase::handle (int event)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
218 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
219 bool processed;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
220
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
221 /**
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
222 * \todo Consider, whether this from the FLTK documentation has any
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
223 * impacts: "To receive fltk::RELEASE events you must return non-zero
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
224 * when passed a fltk::PUSH event. "
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
225 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
226 switch(event) {
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
227 case FL_PUSH:
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
228 processed =
1793
corvid <corvid@lavabit.com>
parents: 1792
diff changeset
229 theLayout->buttonPress (this, Fl::event_clicks () + 1,
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
230 translateViewXToCanvasX (Fl::event_x ()),
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
231 translateViewYToCanvasY (Fl::event_y ()),
1793
corvid <corvid@lavabit.com>
parents: 1792
diff changeset
232 getDwButtonState (), Fl::event_button ());
772
c1104104babf Added lout/msg.h and normalized debug messages to use it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 464
diff changeset
233 _MSG("PUSH => %s\n", processed ? "true" : "false");
449
2c5b0c5b19c4 - Fix: recover page focus when clicking-out of a widget.
jcid
parents: 422
diff changeset
234 if (processed) {
464
357e9dae8d7a Fix: recover page focus when clicking-out of a widget. (try 2)
Jorge Arellano Cid <jcid@dillo.org>
parents: 449
diff changeset
235 /* pressed dw content; give focus to the view */
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
236 Fl::focus(this);
449
2c5b0c5b19c4 - Fix: recover page focus when clicking-out of a widget.
jcid
parents: 422
diff changeset
237 }
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
238 return processed ? true : Fl_Group::handle (event);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
239
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
240 case FL_RELEASE:
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
241 processed =
1793
corvid <corvid@lavabit.com>
parents: 1792
diff changeset
242 theLayout->buttonRelease (this, Fl::event_clicks () + 1,
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
243 translateViewXToCanvasX (Fl::event_x ()),
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
244 translateViewYToCanvasY (Fl::event_y ()),
1793
corvid <corvid@lavabit.com>
parents: 1792
diff changeset
245 getDwButtonState (), Fl::event_button ());
772
c1104104babf Added lout/msg.h and normalized debug messages to use it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 464
diff changeset
246 _MSG("RELEASE => %s\n", processed ? "true" : "false");
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
247 return processed ? true : Fl_Group::handle (event);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
248
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
249 case FL_MOVE:
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
250 mouse_x = Fl::event_x();
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
251 mouse_y = Fl::event_y();
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
252 processed =
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
253 theLayout->motionNotify (this,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
254 translateViewXToCanvasX (mouse_x),
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
255 translateViewYToCanvasY (mouse_y),
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
256 getDwButtonState ());
772
c1104104babf Added lout/msg.h and normalized debug messages to use it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 464
diff changeset
257 _MSG("MOVE => %s\n", processed ? "true" : "false");
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
258 return processed ? true : Fl_Group::handle (event);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
259
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
260 case FL_DRAG:
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
261 processed =
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
262 theLayout->motionNotify (this,
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
263 translateViewXToCanvasX (Fl::event_x ()),
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
264 translateViewYToCanvasY (Fl::event_y ()),
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
265 getDwButtonState ());
772
c1104104babf Added lout/msg.h and normalized debug messages to use it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 464
diff changeset
266 _MSG("DRAG => %s\n", processed ? "true" : "false");
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
267 return processed ? true : Fl_Group::handle (event);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
268
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
269 case FL_ENTER:
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
270 theLayout->enterNotify (this,
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
271 translateViewXToCanvasX (Fl::event_x ()),
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
272 translateViewYToCanvasY (Fl::event_y ()),
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
273 getDwButtonState ());
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
274 return Fl_Group::handle (event);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
275
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
276 case FL_LEAVE:
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
277 theLayout->leaveNotify (this, getDwButtonState ());
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
278 return Fl_Group::handle (event);
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
279
1907
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
280 case FL_FOCUS:
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
281 if (focused_child && find(focused_child) < children()) {
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
282 /* strangely, find() == children() if the child is not found */
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
283 focused_child->take_focus();
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
284 }
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
285 return 1;
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
286
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
287 case FL_UNFOCUS:
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
288 focused_child = fl_oldfocus;
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
289 return 0;
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
290
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
291 default:
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
292 return Fl_Group::handle (event);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
293 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
294 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
295
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
296 // ----------------------------------------------------------------------
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
297
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
298 void FltkViewBase::setLayout (core::Layout *layout)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
299 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
300 theLayout = layout;
2009
234097ef5e23 Bug fix: resize the viewport internally (when attached to a layout)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1919
diff changeset
301 if (usesViewport())
234097ef5e23 Bug fix: resize the viewport internally (when attached to a layout)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1919
diff changeset
302 theLayout->viewportSizeChanged(this, w(), h());
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
303 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
304
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
305 void FltkViewBase::setCanvasSize (int width, int ascent, int descent)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
306 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
307 canvasWidth = width;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
308 canvasHeight = ascent + descent;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
309 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
310
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
311 void FltkViewBase::setCursor (core::style::Cursor cursor)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
312 {
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
313 static Fl_Cursor mapDwToFltk[] = {
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
314 FL_CURSOR_CROSS,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
315 FL_CURSOR_DEFAULT,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
316 FL_CURSOR_HAND,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
317 FL_CURSOR_MOVE,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
318 FL_CURSOR_WE,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
319 FL_CURSOR_NESW,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
320 FL_CURSOR_NWSE,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
321 FL_CURSOR_NS,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
322 FL_CURSOR_NWSE,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
323 FL_CURSOR_NESW,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
324 FL_CURSOR_NS,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
325 FL_CURSOR_WE,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
326 FL_CURSOR_INSERT,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
327 FL_CURSOR_WAIT,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
328 FL_CURSOR_HELP
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
329 };
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
330
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
331 /*
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
332 static char *cursorName[] = {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
333 "CURSOR_CROSS",
1329
0f61dec2d279 adjust debugging code too
corvid <corvid@lavabit.com>
parents: 1328
diff changeset
334 "CURSOR_DEFAULT",
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
335 "CURSOR_HAND",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
336 "CURSOR_MOVE",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
337 "CURSOR_WE",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
338 "CURSOR_NESW",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
339 "CURSOR_NWSE",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
340 "CURSOR_NS",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
341 "CURSOR_NWSE",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
342 "CURSOR_NESW",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
343 "CURSOR_NS",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
344 "CURSOR_WE",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
345 "CURSOR_INSERT",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
346 "CURSOR_WAIT",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
347 "CURSOR_HELP"
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
348 };
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
349
772
c1104104babf Added lout/msg.h and normalized debug messages to use it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 464
diff changeset
350 MSG("Cursor changes to '%s'.\n", cursorName[cursor]);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
351 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
352
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
353 /** \bug Does not work */
1840
corvid <corvid@lavabit.com>
parents: 1833
diff changeset
354 fl_cursor (mapDwToFltk[cursor]);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
355 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
356
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
357 void FltkViewBase::setBgColor (core::style::Color *color)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
358 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
359 bgColor = color ?
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
360 ((FltkColor*)color)->colors[dw::core::style::Color::SHADING_NORMAL] :
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
361 FL_WHITE;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
362 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
363
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
364 void FltkViewBase::startDrawing (core::Rectangle *area)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
365 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
366 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
367
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
368 void FltkViewBase::finishDrawing (core::Rectangle *area)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
369 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
370 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
371
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
372 void FltkViewBase::queueDraw (core::Rectangle *area)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
373 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
374 drawRegion.addRectangle (area);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
375 /** DAMAGE_VALUE is just an arbitrary value other than DAMAGE_EXPOSE here */
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
376 damage (FL_DAMAGE_USER1);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
377 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
378
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
379 void FltkViewBase::queueDrawTotal ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
380 {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
381 damage (FL_DAMAGE_EXPOSE);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
382 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
383
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
384 void FltkViewBase::cancelQueueDraw ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
385 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
386 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
387
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
388 void FltkViewBase::drawPoint (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
389 core::style::Color::Shading shading,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
390 int x, int y)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
391 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
392 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
393
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
394 void FltkViewBase::drawLine (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
395 core::style::Color::Shading shading,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
396 int x1, int y1, int x2, int y2)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
397 {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
398 fl_color(((FltkColor*)color)->colors[shading]);
1905
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
399 // we clip with a large border (5000px), as clipping causes artefacts
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
400 // with non-solid line styles.
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
401 // However it's still better than no clipping at all.
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
402 clipPoint (&x1, &y1, 5000);
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
403 clipPoint (&x2, &y2, 5000);
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
404 fl_line (translateCanvasXToViewX (x1),
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
405 translateCanvasYToViewY (y1),
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
406 translateCanvasXToViewX (x2),
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
407 translateCanvasYToViewY (y2));
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
408 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
409
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
410 void FltkViewBase::drawTypedLine (core::style::Color *color,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
411 core::style::Color::Shading shading,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
412 core::style::LineType type, int width,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
413 int x1, int y1, int x2, int y2)
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
414 {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
415 char dashes[3], w, ng, d, gap, len;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
416 const int f = 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
417
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
418 w = (width == 1) ? 0 : width;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
419 if (type == core::style::LINE_DOTTED) {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
420 /* customized drawing for dotted lines */
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
421 len = (x2 == x1) ? y2 - y1 + 1 : (y2 == y1) ? x2 - x1 + 1 : 0;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
422 ng = len / f*width;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
423 d = len % f*width;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
424 gap = ng ? d/ng + (w > 3 ? 2 : 0) : 0;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
425 dashes[0] = 1; dashes[1] = f*width-gap; dashes[2] = 0;
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
426 fl_line_style(FL_DASH + FL_CAP_ROUND, w, dashes);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
427
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
428 /* These formulas also work, but ain't pretty ;)
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
429 * fl_line_style(FL_DOT + FL_CAP_ROUND, w);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
430 * dashes[0] = 1; dashes[1] = 3*width-2; dashes[2] = 0;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
431 */
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
432 } else if (type == core::style::LINE_DASHED) {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
433 fl_line_style(FL_DASH + FL_CAP_ROUND, w);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
434 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
435
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
436 fl_color(((FltkColor*)color)->colors[shading]);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
437 drawLine (color, shading, x1, y1, x2, y2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
438
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
439 if (type != core::style::LINE_NORMAL)
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
440 fl_line_style(FL_SOLID);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
441 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
442
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
443 void FltkViewBase::drawRectangle (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
444 core::style::Color::Shading shading,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
445 bool filled,
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
446 int X, int Y, int width, int height)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
447 {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
448 fl_color(((FltkColor*)color)->colors[shading]);
1290
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
449 if (width < 0) {
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
450 X += width;
1290
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
451 width = -width;
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
452 }
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
453 if (height < 0) {
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
454 Y += height;
1290
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
455 height = -height;
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
456 }
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
457
1905
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
458 int x1 = X;
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
459 int y1 = Y;
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
460 int x2 = X + width;
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
461 int y2 = Y + height;
1290
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
462
1770
4779a3d891a1 trim some spaces
corvid <corvid@lavabit.com>
parents: 1760
diff changeset
463 // We only support rectangles with line width 1px, so we clip with
1616
29662d35e068 fix clipped drawing of non-filled rectangles
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1352
diff changeset
464 // a rectangle 1px wider and higher than what we actually expose.
29662d35e068 fix clipped drawing of non-filled rectangles
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1352
diff changeset
465 // This is only really necessary for non-filled rectangles.
29662d35e068 fix clipped drawing of non-filled rectangles
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1352
diff changeset
466 clipPoint (&x1, &y1, 1);
29662d35e068 fix clipped drawing of non-filled rectangles
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1352
diff changeset
467 clipPoint (&x2, &y2, 1);
1905
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
468
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
469 x1 = translateCanvasXToViewX (x1);
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
470 y1 = translateCanvasYToViewY (y1);
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
471 x2 = translateCanvasXToViewX (x2);
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
472 y2 = translateCanvasYToViewY (y2);
1290
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
473
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
474 if (filled)
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
475 fl_rectf (x1, y1, x2 - x1, y2 - y1);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
476 else
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
477 fl_rect (x1, y1, x2 - x1, y2 - y1);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
478 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
479
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
480 void FltkViewBase::drawArc (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
481 core::style::Color::Shading shading, bool filled,
1618
3e2034b39789 drawArc() take coordinates of center
corvid <corvid@lavabit.com>
parents: 1616
diff changeset
482 int centerX, int centerY, int width, int height,
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
483 int angle1, int angle2)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
484 {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
485 fl_color(((FltkColor*)color)->colors[shading]);
1618
3e2034b39789 drawArc() take coordinates of center
corvid <corvid@lavabit.com>
parents: 1616
diff changeset
486 int x = translateCanvasXToViewX (centerX) - width / 2;
3e2034b39789 drawArc() take coordinates of center
corvid <corvid@lavabit.com>
parents: 1616
diff changeset
487 int y = translateCanvasYToViewY (centerY) - height / 2;
1858
58d86abb6b3f drawArc
corvid <corvid@lavabit.com>
parents: 1856
diff changeset
488
58d86abb6b3f drawArc
corvid <corvid@lavabit.com>
parents: 1856
diff changeset
489 fl_arc(x, y, width, height, 0.0, 360.0);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
490 if (filled)
1858
58d86abb6b3f drawArc
corvid <corvid@lavabit.com>
parents: 1856
diff changeset
491 fl_pie(x, y, width, height, 0.0, 360.0);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
492 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
493
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
494 void FltkViewBase::drawPolygon (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
495 core::style::Color::Shading shading,
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
496 bool filled, bool convex, int points[][2],
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
497 int npoints)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
498 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
499 if (npoints > 0) {
1859
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
500 fl_color(((FltkColor*)color)->colors[shading]);
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
501
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
502 if (filled) {
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
503 if (convex)
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
504 fl_begin_polygon();
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
505 else
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
506 fl_begin_complex_polygon();
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
507 } else
1859
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
508 fl_begin_loop();
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
509
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
510 for (int i = 0; i < npoints; i++) {
1859
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
511 fl_vertex(translateCanvasXToViewX(points[i][0]),
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
512 translateCanvasYToViewY(points[i][1]));
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
513 }
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
514 if (filled) {
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
515 if (convex)
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
516 fl_end_polygon();
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
517 else
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
518 fl_end_complex_polygon();
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
519 } else
1859
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
520 fl_end_loop();
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
521 }
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
522 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
523
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
524 core::View *FltkViewBase::getClippingView (int x, int y, int width, int height)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
525 {
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
526 fl_push_clip (translateCanvasXToViewX (x), translateCanvasYToViewY (y),
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
527 width, height);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
528 return this;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
529 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
530
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
531 void FltkViewBase::mergeClippingView (core::View *clippingView)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
532 {
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
533 fl_pop_clip ();
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
534 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
535
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
536 // ----------------------------------------------------------------------
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
537
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
538 FltkWidgetView::FltkWidgetView (int x, int y, int w, int h,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
539 const char *label):
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
540 FltkViewBase (x, y, w, h, label)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
541 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
542 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
543
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
544 FltkWidgetView::~FltkWidgetView ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
545 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
546 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
547
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
548 void FltkWidgetView::layout () {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
549 #if 0
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
550 PORT1.3
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
551 /**
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
552 * pass layout to child widgets. This is needed for complex fltk
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
553 * widgets as TextEditor.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
554 * We can't use Group::layout() as that would rearrange the widgets.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
555 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
556 for (int i = children () - 1; i >= 0; i--) {
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
557 Fl_Widget *widget = child (i);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
558
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
559 if (widget->layout_damage ()) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
560 widget->layout ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
561 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
562 }
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
563 #endif
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
564 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
565
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
566 void FltkWidgetView::drawText (core::style::Font *font,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
567 core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
568 core::style::Color::Shading shading,
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
569 int X, int Y, const char *text, int len)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
570 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
571 FltkFont *ff = (FltkFont*)font;
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
572 fl_font(ff->font, ff->size);
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
573 fl_color(((FltkColor*)color)->colors[shading]);
1352
2b0ed71ccec6 use letter spacing when drawing
corvid <corvid@lavabit.com>
parents: 1347
diff changeset
574
1712
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
575 if (!font->letterSpacing && !font->fontVariant) {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
576 fl_draw(text, len,
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
577 translateCanvasXToViewX (X), translateCanvasYToViewY (Y));
1352
2b0ed71ccec6 use letter spacing when drawing
corvid <corvid@lavabit.com>
parents: 1347
diff changeset
578 } else {
2b0ed71ccec6 use letter spacing when drawing
corvid <corvid@lavabit.com>
parents: 1347
diff changeset
579 /* Nonzero letter spacing adjustment, draw each glyph individually */
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
580 int viewX = translateCanvasXToViewX (X),
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
581 viewY = translateCanvasYToViewY (Y);
1715
493343d3d7ae Use utf8encode/utf8decode (instead of mbrtowc/wcrtomb) for smallcaps.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1714
diff changeset
582 int curr = 0, next = 0, nb;
1716
c805b4e0b7ce make dillo compile with clang
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1715
diff changeset
583 char chbuf[4];
1713
4d87e55c0bbb Add utf8 uppercasing to small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
584 wchar_t wc, wcu;
1352
2b0ed71ccec6 use letter spacing when drawing
corvid <corvid@lavabit.com>
parents: 1347
diff changeset
585
1712
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
586 if (font->fontVariant == 1) {
1714
80f90763d2c3 Don't touch letter spacing for small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1713
diff changeset
587 int sc_fontsize = lout::misc::roundInt(ff->size * 0.78);
1713
4d87e55c0bbb Add utf8 uppercasing to small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
588 for (curr = 0; next < len; curr = next) {
1712
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
589 next = theLayout->nextGlyph(text, curr);
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
590 wc = fl_utf8decode(text + curr, text + next, &nb);
1713
4d87e55c0bbb Add utf8 uppercasing to small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
591 if ((wcu = towupper(wc)) == wc) {
4d87e55c0bbb Add utf8 uppercasing to small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
592 /* already uppercase, just draw the character */
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
593 fl_font(ff->font, ff->size);
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
594 fl_draw(text + curr, next - curr, viewX, viewY);
1712
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
595 viewX += font->letterSpacing;
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
596 viewX += (int)fl_width(text + curr, next - curr);
1712
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
597 } else {
1713
4d87e55c0bbb Add utf8 uppercasing to small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
598 /* make utf8 string for converted char */
1856
4f350c333bf1 uncomment utf8encode for smallcaps
corvid <corvid@lavabit.com>
parents: 1852
diff changeset
599 nb = fl_utf8encode(wcu, chbuf);
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
600 fl_font(ff->font, sc_fontsize);
1852
7f050e0ef6d6 fix some leftovers from dd9528825b2f
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1850
diff changeset
601 fl_draw(chbuf, nb, viewX, viewY);
1714
80f90763d2c3 Don't touch letter spacing for small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1713
diff changeset
602 viewX += font->letterSpacing;
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
603 viewX += (int)fl_width(chbuf, nb);
1712
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
604 }
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
605 }
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
606 } else {
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
607 while (next < len) {
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
608 next = theLayout->nextGlyph(text, curr);
1852
7f050e0ef6d6 fix some leftovers from dd9528825b2f
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1850
diff changeset
609 fl_draw(text + curr, next - curr, viewX, viewY);
1770
4779a3d891a1 trim some spaces
corvid <corvid@lavabit.com>
parents: 1760
diff changeset
610 viewX += font->letterSpacing +
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
611 (int)fl_width(text + curr,next - curr);
1712
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
612 curr = next;
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
613 }
1352
2b0ed71ccec6 use letter spacing when drawing
corvid <corvid@lavabit.com>
parents: 1347
diff changeset
614 }
2b0ed71ccec6 use letter spacing when drawing
corvid <corvid@lavabit.com>
parents: 1347
diff changeset
615 }
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
616 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
617
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
618 void FltkWidgetView::drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot,
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
619 int X, int Y, int width, int height)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
620 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
621 ((FltkImgbuf*)imgbuf)->draw (this,
1850
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
622 translateCanvasXToViewX (xRoot),
dd9528825b2f view coordinates are now relative to the window (standard with fltk-1.3)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1849
diff changeset
623 translateCanvasYToViewY (yRoot),
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
624 X, Y, width, height);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
625 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
626
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
627 bool FltkWidgetView::usesFltkWidgets ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
628 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
629 return true;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
630 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
631
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
632 void FltkWidgetView::addFltkWidget (Fl_Widget *widget,
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
633 core::Allocation *allocation)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
634 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
635 allocateFltkWidget (widget, allocation);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
636 add (widget);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
637 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
638
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
639 void FltkWidgetView::removeFltkWidget (Fl_Widget *widget)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
640 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
641 remove (widget);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
642 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
643
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
644 void FltkWidgetView::allocateFltkWidget (Fl_Widget *widget,
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
645 core::Allocation *allocation)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
646 {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
647 widget->resize (translateCanvasXToViewX (allocation->x),
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
648 translateCanvasYToViewY (allocation->y),
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
649 allocation->width,
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
650 allocation->ascent + allocation->descent);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
651
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
652 #if 0
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
653 PORT1.3
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
654 /* widgets created tiny and later resized need this flag to display */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
655 uchar damage = widget->layout_damage ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
656 damage |= LAYOUT_XYWH;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
657 widget->layout_damage (damage);
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
658 #endif
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
659 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
660
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
661 void FltkWidgetView::drawFltkWidget (Fl_Widget *widget,
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
662 core::Rectangle *area)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
663 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
664 draw_child (*widget);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
665 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
666
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
667 } // namespace fltk
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
668 } // namespace dw