annotate dw/fltkviewbase.cc @ 2048:5060d415a85a

clickable menu items (even those introducing submenus) MUST have callbacks I clicked on the "Panel size" item itself instead of any of the options in its submenu, and: Segfault!
author corvid <corvid@lavabit.com>
date Thu, 26 May 2011 02:51:18 +0000
parents f542084fa707
children 877989334d17
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);
2013
a96b5e1b4b3c Fix fltkresources to draw and not change position when resizing
Jorge Arellano Cid <jcid@dillo.org>
parents: 2012
diff changeset
82 resizable(NULL);
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
85 FltkViewBase::~FltkViewBase ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
86 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
87 cancelQueueDraw ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
88 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
89
399
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
90 void FltkViewBase::setBufferedDrawing (bool b) {
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
91 if (b && backBuffer == NULL) {
1903
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
92 backBuffer = new BackBuffer ();
399
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
93 } else if (!b && backBuffer != NULL) {
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
94 delete backBuffer;
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
95 backBuffer = NULL;
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 }
256c36a7e70f - Added the double-buffer as preference patch.
jcid
parents: 347
diff changeset
98
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
99 void FltkViewBase::draw ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
100 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
101 int d = damage ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
102
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
103 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
104 lout::container::typed::Iterator <core::Rectangle> it;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
105
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
106 for (it = drawRegion.rectangles (); it.hasNext (); ) {
1248
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
107 draw (it.getNext (), DRAW_BUFFERED);
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
110 drawRegion.clear ();
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
111 d &= ~FL_DAMAGE_USER1;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
112 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
113
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
114 if (d & FL_DAMAGE_CHILD) {
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
115 drawChildWidgets ();
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
116 d &= ~FL_DAMAGE_CHILD;
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
119 if (d) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
120 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
121 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
122 translateViewYToCanvasY (y ()),
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
123 w (),
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
124 h ());
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
125
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
126 if (d == FL_DAMAGE_SCROLL) {
1248
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
127 // 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
128 draw (&rect, DRAW_PLAIN);
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
129 } else {
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
130 draw (&rect, DRAW_CLIPPED);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
131 drawRegion.clear ();
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 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
135
422
85668a711645 - Unused code cleanup.
jcid
parents: 401
diff changeset
136 void FltkViewBase::draw (const core::Rectangle *rect,
1248
3546dc1e4f1e properly clip draw requests
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
137 DrawType type)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
138 {
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
139 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
140 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
141 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
142
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 // 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
144 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
145 return;
2024
f542084fa707 rm spaces
corvid <corvid@lavabit.com>
parents: 2013
diff changeset
146
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
147 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
148 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
149
e920355164cf minimize draw rect before passing it to fl_clip_box to avoid overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1907
diff changeset
150 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
151
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
152 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
153 translateViewYToCanvasY (Y), W, H);
1903
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
154
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
155 if (r.isEmpty ())
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
156 return;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
157
1905
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
158 exposeArea = &r;
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
159
1903
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
160 if (type == DRAW_BUFFERED && backBuffer && !backBufferInUse) {
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
161 backBufferInUse = true;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
162 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
163 fl_begin_offscreen (backBuffer->offscreen);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
164 fl_push_matrix ();
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
165 fl_color (bgColor);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
166 fl_rectf (X, Y, W, H);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
167 theLayout->expose (this, &r);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
168 fl_pop_matrix ();
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
169 fl_end_offscreen ();
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
170 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
171 backBufferInUse = false;
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
172 } else if (type == DRAW_BUFFERED || type == DRAW_CLIPPED) {
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
173 // 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
174 // we fall back to clipped drawing
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
175 fl_push_clip (X, Y, W, H);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
176 fl_color (bgColor);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
177 fl_rectf (X, Y, W, H);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
178 theLayout->expose (this, &r);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
179 fl_pop_clip ();
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
180 } else {
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
181 fl_color (bgColor);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
182 fl_rectf (X, Y, W, H);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
183 theLayout->expose (this, &r);
631c40949a94 port buffered drawing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1875
diff changeset
184 }
1905
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
185
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
186 exposeArea = NULL;
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
189 void FltkViewBase::drawChildWidgets () {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
190 for (int i = children () - 1; i >= 0; i--) {
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
191 Fl_Widget& w = *child(i);
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
192 #if 0
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
193 PORT1.3
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
194 if (w.damage() & DAMAGE_CHILD_LABEL) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
195 draw_outside_label(w);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
196 w.set_damage(w.damage() & ~DAMAGE_CHILD_LABEL);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
197 }
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
198 #endif
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
199 update_child(w);
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
203 core::ButtonState getDwButtonState ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
204 {
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
205 int s1 = Fl::event_state ();
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
206 int s2 = (core::ButtonState)0;
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
207
1792
c4dd094670d3 more key/button modifiers
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
208 if (s1 & FL_SHIFT) s2 |= core::SHIFT_MASK;
c4dd094670d3 more key/button modifiers
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
209 if (s1 & FL_CTRL) s2 |= core::CONTROL_MASK;
c4dd094670d3 more key/button modifiers
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
210 if (s1 & FL_ALT) s2 |= core::META_MASK;
c4dd094670d3 more key/button modifiers
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
211 if (s1 & FL_BUTTON1) s2 |= core::BUTTON1_MASK;
c4dd094670d3 more key/button modifiers
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
212 if (s1 & FL_BUTTON2) s2 |= core::BUTTON2_MASK;
c4dd094670d3 more key/button modifiers
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
213 if (s1 & FL_BUTTON3) s2 |= core::BUTTON3_MASK;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
214
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
215 return (core::ButtonState)s2;
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
218 int FltkViewBase::handle (int event)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
219 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
220 bool processed;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
221
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
222 /**
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
223 * \todo Consider, whether this from the FLTK documentation has any
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
224 * impacts: "To receive fltk::RELEASE events you must return non-zero
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
225 * when passed a fltk::PUSH event. "
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
226 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
227 switch(event) {
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
228 case FL_PUSH:
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
229 processed =
1793
corvid <corvid@lavabit.com>
parents: 1792
diff changeset
230 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
231 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
232 translateViewYToCanvasY (Fl::event_y ()),
1793
corvid <corvid@lavabit.com>
parents: 1792
diff changeset
233 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
234 _MSG("PUSH => %s\n", processed ? "true" : "false");
449
2c5b0c5b19c4 - Fix: recover page focus when clicking-out of a widget.
jcid
parents: 422
diff changeset
235 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
236 /* pressed dw content; give focus to the view */
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
237 Fl::focus(this);
449
2c5b0c5b19c4 - Fix: recover page focus when clicking-out of a widget.
jcid
parents: 422
diff changeset
238 }
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
239 return processed ? true : Fl_Group::handle (event);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
240
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
241 case FL_RELEASE:
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
242 processed =
1793
corvid <corvid@lavabit.com>
parents: 1792
diff changeset
243 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
244 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
245 translateViewYToCanvasY (Fl::event_y ()),
1793
corvid <corvid@lavabit.com>
parents: 1792
diff changeset
246 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
247 _MSG("RELEASE => %s\n", processed ? "true" : "false");
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
248 return processed ? true : Fl_Group::handle (event);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
249
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
250 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
251 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
252 mouse_y = Fl::event_y();
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
253 processed =
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
254 theLayout->motionNotify (this,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
255 translateViewXToCanvasX (mouse_x),
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
256 translateViewYToCanvasY (mouse_y),
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
257 getDwButtonState ());
772
c1104104babf Added lout/msg.h and normalized debug messages to use it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 464
diff changeset
258 _MSG("MOVE => %s\n", processed ? "true" : "false");
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
259 return processed ? true : Fl_Group::handle (event);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
260
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
261 case FL_DRAG:
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
262 processed =
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
263 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
264 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
265 translateViewYToCanvasY (Fl::event_y ()),
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
266 getDwButtonState ());
772
c1104104babf Added lout/msg.h and normalized debug messages to use it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 464
diff changeset
267 _MSG("DRAG => %s\n", processed ? "true" : "false");
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
268 return processed ? true : Fl_Group::handle (event);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
269
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
270 case FL_ENTER:
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
271 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
272 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
273 translateViewYToCanvasY (Fl::event_y ()),
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
274 getDwButtonState ());
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
275 return Fl_Group::handle (event);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
276
1791
corvid <corvid@lavabit.com>
parents: 1770
diff changeset
277 case FL_LEAVE:
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
278 theLayout->leaveNotify (this, getDwButtonState ());
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
279 return Fl_Group::handle (event);
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
280
1907
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
281 case FL_FOCUS:
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
282 if (focused_child && find(focused_child) < children()) {
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
283 /* strangely, find() == children() if the child is not found */
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
284 focused_child->take_focus();
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
285 }
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
286 return 1;
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
287
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
288 case FL_UNFOCUS:
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
289 focused_child = fl_oldfocus;
5f92140e4bce view and form widget focusing
corvid <corvid@lavabit.com>
parents: 1905
diff changeset
290 return 0;
2024
f542084fa707 rm spaces
corvid <corvid@lavabit.com>
parents: 2013
diff changeset
291
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
292 default:
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
293 return Fl_Group::handle (event);
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
299 void FltkViewBase::setLayout (core::Layout *layout)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
300 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
301 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
302 if (usesViewport())
234097ef5e23 Bug fix: resize the viewport internally (when attached to a layout)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1919
diff changeset
303 theLayout->viewportSizeChanged(this, w(), h());
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
306 void FltkViewBase::setCanvasSize (int width, int ascent, int descent)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
307 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
308 canvasWidth = width;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
309 canvasHeight = ascent + descent;
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
312 void FltkViewBase::setCursor (core::style::Cursor cursor)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
313 {
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
314 static Fl_Cursor mapDwToFltk[] = {
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
315 FL_CURSOR_CROSS,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
316 FL_CURSOR_DEFAULT,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
317 FL_CURSOR_HAND,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
318 FL_CURSOR_MOVE,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
319 FL_CURSOR_WE,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
320 FL_CURSOR_NESW,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
321 FL_CURSOR_NWSE,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
322 FL_CURSOR_NS,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
323 FL_CURSOR_NWSE,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
324 FL_CURSOR_NESW,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
325 FL_CURSOR_NS,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
326 FL_CURSOR_WE,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
327 FL_CURSOR_INSERT,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
328 FL_CURSOR_WAIT,
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
329 FL_CURSOR_HELP
347
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 /*
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
333 static char *cursorName[] = {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
334 "CURSOR_CROSS",
1329
0f61dec2d279 adjust debugging code too
corvid <corvid@lavabit.com>
parents: 1328
diff changeset
335 "CURSOR_DEFAULT",
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
336 "CURSOR_HAND",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
337 "CURSOR_MOVE",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
338 "CURSOR_WE",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
339 "CURSOR_NESW",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
340 "CURSOR_NWSE",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
341 "CURSOR_NS",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
342 "CURSOR_NWSE",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
343 "CURSOR_NESW",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
344 "CURSOR_NS",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
345 "CURSOR_WE",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
346 "CURSOR_INSERT",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
347 "CURSOR_WAIT",
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
348 "CURSOR_HELP"
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
349 };
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
350
772
c1104104babf Added lout/msg.h and normalized debug messages to use it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 464
diff changeset
351 MSG("Cursor changes to '%s'.\n", cursorName[cursor]);
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
354 /** \bug Does not work */
1840
corvid <corvid@lavabit.com>
parents: 1833
diff changeset
355 fl_cursor (mapDwToFltk[cursor]);
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
358 void FltkViewBase::setBgColor (core::style::Color *color)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
359 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
360 bgColor = color ?
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
361 ((FltkColor*)color)->colors[dw::core::style::Color::SHADING_NORMAL] :
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
362 FL_WHITE;
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
365 void FltkViewBase::startDrawing (core::Rectangle *area)
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
369 void FltkViewBase::finishDrawing (core::Rectangle *area)
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
373 void FltkViewBase::queueDraw (core::Rectangle *area)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
374 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
375 drawRegion.addRectangle (area);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
376 /** 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
377 damage (FL_DAMAGE_USER1);
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
380 void FltkViewBase::queueDrawTotal ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
381 {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
382 damage (FL_DAMAGE_EXPOSE);
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
385 void FltkViewBase::cancelQueueDraw ()
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
389 void FltkViewBase::drawPoint (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
390 core::style::Color::Shading shading,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
391 int x, int y)
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
395 void FltkViewBase::drawLine (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
396 core::style::Color::Shading shading,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
397 int x1, int y1, int x2, int y2)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
398 {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
399 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
400 // 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
401 // 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
402 // 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
403 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
404 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
405 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
406 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
407 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
408 translateCanvasYToViewY (y2));
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
409 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
410
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
411 void FltkViewBase::drawTypedLine (core::style::Color *color,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
412 core::style::Color::Shading shading,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
413 core::style::LineType type, int width,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
414 int x1, int y1, int x2, int y2)
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
415 {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
416 char dashes[3], w, ng, d, gap, len;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
417 const int f = 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
418
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
419 w = (width == 1) ? 0 : width;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
420 if (type == core::style::LINE_DOTTED) {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
421 /* customized drawing for dotted lines */
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
422 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
423 ng = len / f*width;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
424 d = len % f*width;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
425 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
426 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
427 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
428
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
429 /* These formulas also work, but ain't pretty ;)
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
430 * 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
431 * 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
432 */
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
433 } else if (type == core::style::LINE_DASHED) {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
434 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
435 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
436
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
437 fl_color(((FltkColor*)color)->colors[shading]);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
438 drawLine (color, shading, x1, y1, x2, y2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
439
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
440 if (type != core::style::LINE_NORMAL)
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
441 fl_line_style(FL_SOLID);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
442 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1716
diff changeset
443
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
444 void FltkViewBase::drawRectangle (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
445 core::style::Color::Shading shading,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
446 bool filled,
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
447 int X, int Y, int width, int height)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
448 {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
449 fl_color(((FltkColor*)color)->colors[shading]);
1290
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
450 if (width < 0) {
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
451 X += width;
1290
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
452 width = -width;
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
453 }
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
454 if (height < 0) {
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
455 Y += height;
1290
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
456 height = -height;
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
457 }
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
458
1905
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
459 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
460 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
461 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
462 int y2 = Y + height;
1290
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
463
1770
4779a3d891a1 trim some spaces
corvid <corvid@lavabit.com>
parents: 1760
diff changeset
464 // 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
465 // 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
466 // 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
467 clipPoint (&x1, &y1, 1);
29662d35e068 fix clipped drawing of non-filled rectangles
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1352
diff changeset
468 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
469
370e97c9f39b port line clipping on expose rectangle to avoid X11 coordinate overflows
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1903
diff changeset
470 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
471 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
472 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
473 y2 = translateCanvasYToViewY (y2);
1290
b91adf535e17 improve FltkViewBase::drawRectangle
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1248
diff changeset
474
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
475 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
476 fl_rectf (x1, y1, x2 - x1, y2 - y1);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
477 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
478 fl_rect (x1, y1, x2 - x1, y2 - y1);
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
481 void FltkViewBase::drawArc (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
482 core::style::Color::Shading shading, bool filled,
1618
3e2034b39789 drawArc() take coordinates of center
corvid <corvid@lavabit.com>
parents: 1616
diff changeset
483 int centerX, int centerY, int width, int height,
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
484 int angle1, int angle2)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
485 {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
486 fl_color(((FltkColor*)color)->colors[shading]);
1618
3e2034b39789 drawArc() take coordinates of center
corvid <corvid@lavabit.com>
parents: 1616
diff changeset
487 int x = translateCanvasXToViewX (centerX) - width / 2;
3e2034b39789 drawArc() take coordinates of center
corvid <corvid@lavabit.com>
parents: 1616
diff changeset
488 int y = translateCanvasYToViewY (centerY) - height / 2;
1858
58d86abb6b3f drawArc
corvid <corvid@lavabit.com>
parents: 1856
diff changeset
489
58d86abb6b3f drawArc
corvid <corvid@lavabit.com>
parents: 1856
diff changeset
490 fl_arc(x, y, width, height, 0.0, 360.0);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
491 if (filled)
1858
58d86abb6b3f drawArc
corvid <corvid@lavabit.com>
parents: 1856
diff changeset
492 fl_pie(x, y, width, height, 0.0, 360.0);
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
495 void FltkViewBase::drawPolygon (core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
496 core::style::Color::Shading shading,
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
497 bool filled, bool convex, int points[][2],
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
498 int npoints)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
499 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
500 if (npoints > 0) {
1859
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
501 fl_color(((FltkColor*)color)->colors[shading]);
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
502
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
503 if (filled) {
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
504 if (convex)
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
505 fl_begin_polygon();
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
506 else
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
507 fl_begin_complex_polygon();
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
508 } else
1859
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
509 fl_begin_loop();
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
510
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
511 for (int i = 0; i < npoints; i++) {
1859
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
512 fl_vertex(translateCanvasXToViewX(points[i][0]),
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
513 translateCanvasYToViewY(points[i][1]));
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
514 }
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
515 if (filled) {
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
516 if (convex)
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
517 fl_end_polygon();
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
518 else
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
519 fl_end_complex_polygon();
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1859
diff changeset
520 } else
1859
17b560081191 polygons
corvid <corvid@lavabit.com>
parents: 1858
diff changeset
521 fl_end_loop();
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
522 }
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
525 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
526 {
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
527 fl_push_clip (translateCanvasXToViewX (x), translateCanvasYToViewY (y),
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
528 width, height);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
529 return this;
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
532 void FltkViewBase::mergeClippingView (core::View *clippingView)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
533 {
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
534 fl_pop_clip ();
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
539 FltkWidgetView::FltkWidgetView (int x, int y, int w, int h,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
540 const char *label):
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
541 FltkViewBase (x, y, w, h, label)
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
545 FltkWidgetView::~FltkWidgetView ()
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
549 void FltkWidgetView::layout () {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
550 #if 0
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
551 PORT1.3
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
552 /**
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
553 * 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
554 * widgets as TextEditor.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
555 * 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
556 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
557 for (int i = children () - 1; i >= 0; i--) {
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
558 Fl_Widget *widget = child (i);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
559
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
560 if (widget->layout_damage ()) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
561 widget->layout ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
562 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
563 }
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
564 #endif
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
567 void FltkWidgetView::drawText (core::style::Font *font,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
568 core::style::Color *color,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
569 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
570 int X, int Y, const char *text, int len)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
571 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
572 FltkFont *ff = (FltkFont*)font;
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
573 fl_font(ff->font, ff->size);
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
574 fl_color(((FltkColor*)color)->colors[shading]);
1352
2b0ed71ccec6 use letter spacing when drawing
corvid <corvid@lavabit.com>
parents: 1347
diff changeset
575
1712
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
576 if (!font->letterSpacing && !font->fontVariant) {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
577 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
578 translateCanvasXToViewX (X), translateCanvasYToViewY (Y));
1352
2b0ed71ccec6 use letter spacing when drawing
corvid <corvid@lavabit.com>
parents: 1347
diff changeset
579 } else {
2b0ed71ccec6 use letter spacing when drawing
corvid <corvid@lavabit.com>
parents: 1347
diff changeset
580 /* 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
581 int viewX = translateCanvasXToViewX (X),
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
582 viewY = translateCanvasYToViewY (Y);
1715
493343d3d7ae Use utf8encode/utf8decode (instead of mbrtowc/wcrtomb) for smallcaps.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1714
diff changeset
583 int curr = 0, next = 0, nb;
1716
c805b4e0b7ce make dillo compile with clang
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1715
diff changeset
584 char chbuf[4];
1713
4d87e55c0bbb Add utf8 uppercasing to small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
585 wchar_t wc, wcu;
1352
2b0ed71ccec6 use letter spacing when drawing
corvid <corvid@lavabit.com>
parents: 1347
diff changeset
586
1712
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
587 if (font->fontVariant == 1) {
1714
80f90763d2c3 Don't touch letter spacing for small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1713
diff changeset
588 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
589 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
590 next = theLayout->nextGlyph(text, curr);
1807
407a73983ed5 some fltkviewbase
corvid <corvid@lavabit.com>
parents: 1793
diff changeset
591 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
592 if ((wcu = towupper(wc)) == wc) {
4d87e55c0bbb Add utf8 uppercasing to small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
593 /* already uppercase, just draw the character */
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
594 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
595 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
596 viewX += font->letterSpacing;
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
597 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
598 } else {
1713
4d87e55c0bbb Add utf8 uppercasing to small-caps
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
599 /* make utf8 string for converted char */
1856
4f350c333bf1 uncomment utf8encode for smallcaps
corvid <corvid@lavabit.com>
parents: 1852
diff changeset
600 nb = fl_utf8encode(wcu, chbuf);
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
601 fl_font(ff->font, sc_fontsize);
1852
7f050e0ef6d6 fix some leftovers from dd9528825b2f
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1850
diff changeset
602 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
603 viewX += font->letterSpacing;
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
604 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
605 }
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
606 }
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
607 } else {
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
608 while (next < len) {
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
609 next = theLayout->nextGlyph(text, curr);
1852
7f050e0ef6d6 fix some leftovers from dd9528825b2f
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1850
diff changeset
610 fl_draw(text + curr, next - curr, viewX, viewY);
1770
4779a3d891a1 trim some spaces
corvid <corvid@lavabit.com>
parents: 1760
diff changeset
611 viewX += font->letterSpacing +
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
612 (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
613 curr = next;
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1618
diff changeset
614 }
1352
2b0ed71ccec6 use letter spacing when drawing
corvid <corvid@lavabit.com>
parents: 1347
diff changeset
615 }
2b0ed71ccec6 use letter spacing when drawing
corvid <corvid@lavabit.com>
parents: 1347
diff changeset
616 }
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
619 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
620 int X, int Y, int width, int height)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
621 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
622 ((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
623 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
624 translateCanvasYToViewY (yRoot),
1846
769c8d16469c adjust FltkView to global coordinates in fltk-1.3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1840
diff changeset
625 X, Y, width, height);
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
628 bool FltkWidgetView::usesFltkWidgets ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
629 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
630 return true;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
631 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
632
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
633 void FltkWidgetView::addFltkWidget (Fl_Widget *widget,
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
634 core::Allocation *allocation)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
635 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
636 allocateFltkWidget (widget, allocation);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
637 add (widget);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
638 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
639
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
640 void FltkWidgetView::removeFltkWidget (Fl_Widget *widget)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
641 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
642 remove (widget);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
643 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
644
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
645 void FltkWidgetView::allocateFltkWidget (Fl_Widget *widget,
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
646 core::Allocation *allocation)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
647 {
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
648 widget->resize (translateCanvasXToViewX (allocation->x),
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
649 translateCanvasYToViewY (allocation->y),
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
650 allocation->width,
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
651 allocation->ascent + allocation->descent);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
652
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
653 #if 0
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
654 PORT1.3
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
655 /* widgets created tiny and later resized need this flag to display */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
656 uchar damage = widget->layout_damage ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
657 damage |= LAYOUT_XYWH;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
658 widget->layout_damage (damage);
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
659 #endif
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
660 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
661
1833
5b8f66e6f715 view changes
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1807
diff changeset
662 void FltkWidgetView::drawFltkWidget (Fl_Widget *widget,
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
663 core::Rectangle *area)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
664 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
665 draw_child (*widget);
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
668 } // namespace fltk
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
669 } // namespace dw