annotate dw/style.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 f2b37c93764b
children 16e52ecf20a8
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 <stdio.h>
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
23 #include <string.h>
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
24 #include <unistd.h>
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
25 #include <ctype.h>
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
26 #include <math.h>
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
27
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
28 #include "core.hh"
772
c1104104babf Added lout/msg.h and normalized debug messages to use it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 699
diff changeset
29 #include "../lout/msg.h"
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
30
1347
4704ad910042 remove "using namespace" statements from header files
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1340
diff changeset
31 using namespace lout;
4704ad910042 remove "using namespace" statements from header files
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1340
diff changeset
32
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
33 namespace dw {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
34 namespace core {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
35 namespace style {
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 void StyleAttrs::initValues ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
38 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
39 x_link = -1;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
40 x_img = -1;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
41 x_tooltip = NULL;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
42 textDecoration = TEXT_DECORATION_NONE;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
43 textAlign = TEXT_ALIGN_LEFT;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
44 textAlignChar = '.';
1464
2ed2df2dfaad add support for CSS property list-style-position
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1436
diff changeset
45 listStylePosition = LIST_STYLE_POSITION_OUTSIDE;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
46 listStyleType = LIST_STYLE_TYPE_DISC;
1331
c1c0fd4a81be default valign is baseline
corvid <corvid@lavabit.com>
parents: 1299
diff changeset
47 valign = VALIGN_BASELINE;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
48 backgroundColor = NULL;
1642
a4eb350d3db2 line-height
corvid, Johannes Hofmann
parents: 1492
diff changeset
49 width = height = lineHeight = LENGTH_AUTO;
1755
71f7877a5d37 css text-indent property
corvid <corvid@lavabit.com>
parents: 1712
diff changeset
50 textIndent = 0;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
51 margin.setVal (0);
1711
b27cf7eb15b6 fix last commit
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1710
diff changeset
52 borderWidth.setVal (0);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
53 padding.setVal (0);
1756
cc7c9180ae95 imported patch border-collapse-parsing
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
54 borderCollapse = BORDER_MODEL_SEPARATE;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
55 setBorderColor (NULL);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
56 setBorderStyle (BORDER_NONE);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
57 hBorderSpacing = 0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
58 vBorderSpacing = 0;
1650
ef996982334c css word-spacing property
corvid <corvid@lavabit.com>
parents: 1642
diff changeset
59 wordSpacing = 0;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
60
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
61 display = DISPLAY_INLINE;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
62 whiteSpace = WHITE_SPACE_NORMAL;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
63 cursor = CURSOR_DEFAULT;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
64 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
65
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
66 /**
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
67 * \brief Reset those style attributes to their standard values, which are
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
68 * not inherited, according to CSS.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
69 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
70 void StyleAttrs::resetValues ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
71 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
72 x_img = -1;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
73
1331
c1c0fd4a81be default valign is baseline
corvid <corvid@lavabit.com>
parents: 1299
diff changeset
74 valign = VALIGN_BASELINE;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
75 textAlignChar = '.';
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
76 backgroundColor = NULL;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
77 width = LENGTH_AUTO;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
78 height = LENGTH_AUTO;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
79
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
80 margin.setVal (0);
1711
b27cf7eb15b6 fix last commit
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1710
diff changeset
81 borderWidth.setVal (0);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
82 padding.setVal (0);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
83 setBorderColor (NULL);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
84 setBorderStyle (BORDER_NONE);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
85 hBorderSpacing = 0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
86 vBorderSpacing = 0;
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 display = DISPLAY_INLINE;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
89 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
90
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
91 /**
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
92 * \brief This method returns whether something may change its size, when
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
93 * its style changes from this style to \em otherStyle.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
94 *
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
95 * It is mainly for optimizing style changes where only colors etc change
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
96 * (where false would be returned), in some cases it may return true, although
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
97 * a size change does not actually happen (e.g. when in a certain
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
98 * context a particular attribute is ignored).
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 * \todo Should for CSS implemented properly. Currently, size changes are
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
101 * not needed, so always false is returned. See also
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
102 * dw::core::Widget::setStyle.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
103 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
104 bool StyleAttrs::sizeDiffs (StyleAttrs *otherStyle)
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 return false;
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 bool StyleAttrs::equals (object::Object *other) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
110 StyleAttrs *otherAttrs = (StyleAttrs *) other;
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 return this == otherAttrs ||
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
113 (font == otherAttrs->font &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
114 textDecoration == otherAttrs->textDecoration &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
115 color == otherAttrs->color &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
116 backgroundColor == otherAttrs->backgroundColor &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
117 textAlign == otherAttrs->textAlign &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
118 valign == otherAttrs->valign &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
119 textAlignChar == otherAttrs->textAlignChar &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
120 hBorderSpacing == otherAttrs->hBorderSpacing &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
121 vBorderSpacing == otherAttrs->vBorderSpacing &&
1650
ef996982334c css word-spacing property
corvid <corvid@lavabit.com>
parents: 1642
diff changeset
122 wordSpacing == otherAttrs->wordSpacing &&
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
123 width == otherAttrs->width &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
124 height == otherAttrs->height &&
1642
a4eb350d3db2 line-height
corvid, Johannes Hofmann
parents: 1492
diff changeset
125 lineHeight == otherAttrs->lineHeight &&
1755
71f7877a5d37 css text-indent property
corvid <corvid@lavabit.com>
parents: 1712
diff changeset
126 textIndent == otherAttrs->textIndent &&
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
127 margin.equals (&otherAttrs->margin) &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
128 borderWidth.equals (&otherAttrs->borderWidth) &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
129 padding.equals (&otherAttrs->padding) &&
1756
cc7c9180ae95 imported patch border-collapse-parsing
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
130 borderCollapse == otherAttrs->borderCollapse &&
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
131 borderColor.top == otherAttrs->borderColor.top &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
132 borderColor.right == otherAttrs->borderColor.right &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
133 borderColor.bottom == otherAttrs->borderColor.bottom &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
134 borderColor.left == otherAttrs->borderColor.left &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
135 borderStyle.top == otherAttrs->borderStyle.top &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
136 borderStyle.right == otherAttrs->borderStyle.right &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
137 borderStyle.bottom == otherAttrs->borderStyle.bottom &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
138 borderStyle.left == otherAttrs->borderStyle.left &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
139 display == otherAttrs->display &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
140 whiteSpace == otherAttrs->whiteSpace &&
1464
2ed2df2dfaad add support for CSS property list-style-position
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1436
diff changeset
141 listStylePosition == otherAttrs->listStylePosition &&
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
142 listStyleType == otherAttrs->listStyleType &&
1492
b9a3ee3fbcb8 check cursor in StyleAttrs::equals() and StyleAttrs::hashValue()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1464
diff changeset
143 cursor == otherAttrs->cursor &&
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
144 x_link == otherAttrs->x_link &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
145 x_img == otherAttrs->x_img &&
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
146 x_tooltip == otherAttrs->x_tooltip);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
147 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
148
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
149 int StyleAttrs::hashValue () {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
150 return (intptr_t) font +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
151 textDecoration +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
152 (intptr_t) color +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
153 (intptr_t) backgroundColor +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
154 textAlign +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
155 valign +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
156 textAlignChar +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
157 hBorderSpacing +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
158 vBorderSpacing +
1650
ef996982334c css word-spacing property
corvid <corvid@lavabit.com>
parents: 1642
diff changeset
159 wordSpacing +
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
160 width +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
161 height +
1642
a4eb350d3db2 line-height
corvid, Johannes Hofmann
parents: 1492
diff changeset
162 lineHeight +
1755
71f7877a5d37 css text-indent property
corvid <corvid@lavabit.com>
parents: 1712
diff changeset
163 textIndent +
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
164 margin.hashValue () +
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 844
diff changeset
165 borderWidth.hashValue () +
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
166 padding.hashValue () +
1756
cc7c9180ae95 imported patch border-collapse-parsing
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
167 borderCollapse +
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
168 (intptr_t) borderColor.top +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
169 (intptr_t) borderColor.right +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
170 (intptr_t) borderColor.bottom +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
171 (intptr_t) borderColor.left +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
172 borderStyle.top +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
173 borderStyle.right +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
174 borderStyle.bottom +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
175 borderStyle.left +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
176 display +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
177 whiteSpace +
1464
2ed2df2dfaad add support for CSS property list-style-position
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1436
diff changeset
178 listStylePosition +
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
179 listStyleType +
1492
b9a3ee3fbcb8 check cursor in StyleAttrs::equals() and StyleAttrs::hashValue()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1464
diff changeset
180 cursor +
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
181 x_link +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
182 x_img +
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
183 (intptr_t) x_tooltip;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
184 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
185
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
186 int Style::totalRef = 0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
187 container::typed::HashTable <StyleAttrs, Style> * Style::styleTable =
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
188 new container::typed::HashTable <StyleAttrs, Style> (false, false, 1024);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
189
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
190 Style::Style (StyleAttrs *attrs)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
191 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
192 copyAttrs (attrs);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
193
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
194 refCount = 1;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
195
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
196 font->ref ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
197 if (color)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
198 color->ref ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
199 if (backgroundColor)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
200 backgroundColor->ref ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
201 if (borderColor.top)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
202 borderColor.top->ref();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
203 if (borderColor.bottom)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
204 borderColor.bottom->ref();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
205 if (borderColor.left)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
206 borderColor.left->ref();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
207 if (borderColor.right)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
208 borderColor.right->ref();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
209 if (x_tooltip)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
210 x_tooltip->ref();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
211
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
212 totalRef++;
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
215 Style::~Style ()
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 font->unref ();
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 if (color)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
220 color->unref ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
221 if (backgroundColor)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
222 backgroundColor->unref ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
223 if (borderColor.top)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
224 borderColor.top->unref();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
225 if (borderColor.bottom)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
226 borderColor.bottom->unref();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
227 if (borderColor.left)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
228 borderColor.left->unref();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
229 if (borderColor.right)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
230 borderColor.right->unref();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
231 if (x_tooltip)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
232 x_tooltip->unref();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
233
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
234 styleTable->remove (this);
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 844
diff changeset
235 totalRef--;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
236 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
237
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
238 void Style::copyAttrs (StyleAttrs *attrs)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
239 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
240 font = attrs->font;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
241 textDecoration = attrs->textDecoration;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
242 color = attrs->color;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
243 backgroundColor = attrs->backgroundColor;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
244 textAlign = attrs->textAlign;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
245 valign = attrs->valign;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
246 textAlignChar = attrs->textAlignChar;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
247 hBorderSpacing = attrs->hBorderSpacing;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
248 vBorderSpacing = attrs->vBorderSpacing;
1650
ef996982334c css word-spacing property
corvid <corvid@lavabit.com>
parents: 1642
diff changeset
249 wordSpacing = attrs->wordSpacing;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
250 width = attrs->width;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
251 height = attrs->height;
1642
a4eb350d3db2 line-height
corvid, Johannes Hofmann
parents: 1492
diff changeset
252 lineHeight = attrs->lineHeight;
1755
71f7877a5d37 css text-indent property
corvid <corvid@lavabit.com>
parents: 1712
diff changeset
253 textIndent = attrs->textIndent;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
254 margin = attrs->margin;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
255 borderWidth = attrs->borderWidth;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
256 padding = attrs->padding;
1756
cc7c9180ae95 imported patch border-collapse-parsing
Jorge Arellano Cid <jcid@dillo.org>
parents: 1712
diff changeset
257 borderCollapse = attrs->borderCollapse;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
258 borderColor = attrs->borderColor;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
259 borderStyle = attrs->borderStyle;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
260 display = attrs->display;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
261 whiteSpace = attrs->whiteSpace;
1464
2ed2df2dfaad add support for CSS property list-style-position
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1436
diff changeset
262 listStylePosition = attrs->listStylePosition;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
263 listStyleType = attrs->listStyleType;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
264 cursor = attrs->cursor;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
265 x_link = attrs->x_link;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
266 x_img = attrs->x_img;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
267 x_tooltip = attrs->x_tooltip;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
268 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
269
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
270 // ----------------------------------------------------------------------
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
271
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
272 bool FontAttrs::equals(object::Object *other)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
273 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
274 FontAttrs *otherAttrs = (FontAttrs*)other;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
275 return
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
276 this == otherAttrs ||
1350
0fb1bd0e94a9 add letter-spacing support to CSS subsystem
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1347
diff changeset
277 (size == otherAttrs->size &&
0fb1bd0e94a9 add letter-spacing support to CSS subsystem
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1347
diff changeset
278 weight == otherAttrs->weight &&
0fb1bd0e94a9 add letter-spacing support to CSS subsystem
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1347
diff changeset
279 style == otherAttrs->style &&
0fb1bd0e94a9 add letter-spacing support to CSS subsystem
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1347
diff changeset
280 letterSpacing == otherAttrs->letterSpacing &&
1712
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1711
diff changeset
281 fontVariant == otherAttrs->fontVariant &&
1350
0fb1bd0e94a9 add letter-spacing support to CSS subsystem
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1347
diff changeset
282 strcmp (name, otherAttrs->name) == 0);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
283 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
284
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
285 int FontAttrs::hashValue()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
286 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
287 int h = object::String::hashValue (name);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
288 h = (h << 5) - h + size;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
289 h = (h << 5) - h + weight;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
290 h = (h << 5) - h + style;
1350
0fb1bd0e94a9 add letter-spacing support to CSS subsystem
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1347
diff changeset
291 h = (h << 5) - h + letterSpacing;
1712
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1711
diff changeset
292 h = (h << 5) - h + fontVariant;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
293 return h;
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 Font::~Font ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
297 {
844
16f0a313536d make StyleAttrs::name const again (by jcid)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 837
diff changeset
298 free ((char*)name);
347
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
301 void Font::copyAttrs (FontAttrs *attrs)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
302 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
303 name = strdup (attrs->name);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
304 size = attrs->size;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
305 weight = attrs->weight;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
306 style = attrs->style;
1350
0fb1bd0e94a9 add letter-spacing support to CSS subsystem
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1347
diff changeset
307 letterSpacing = attrs->letterSpacing;
1712
9a71c8d886ef CSS part for font-variant: small-caps support
Jorge Arellano Cid <jcid@dillo.org>
parents: 1711
diff changeset
308 fontVariant = attrs->fontVariant;
347
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 Font *Font::create0 (Layout *layout, FontAttrs *attrs,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
312 bool tryEverything)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
313 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
314 return layout->createFont (attrs, tryEverything);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
315 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
316
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
317 Font *Font::create (Layout *layout, FontAttrs *attrs)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
318 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
319 return create0 (layout, attrs, false);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
320 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
321
1436
d5536dc7114a properly handle comma separated lists of font names in CSS
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1364
diff changeset
322 bool Font::exists (Layout *layout, const char *name)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
323 {
1436
d5536dc7114a properly handle comma separated lists of font names in CSS
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1364
diff changeset
324 return layout->fontExists (name);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
325 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
326
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
327 // ----------------------------------------------------------------------
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
328
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
329 bool ColorAttrs::equals(object::Object *other)
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 ColorAttrs *oc = (ColorAttrs*)other;
677
b6ef23efdac7 always use shaded colors
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 662
diff changeset
332 return this == oc || (color == oc->color);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
333 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
334
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
335 int ColorAttrs::hashValue()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
336 {
677
b6ef23efdac7 always use shaded colors
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 662
diff changeset
337 return color;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
338 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
339
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
340 Color::~Color ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
341 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
342 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
343
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
344 int Color::shadeColor (int color, int d)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
345 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
346 int red = (color >> 16) & 255;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
347 int green = (color >> 8) & 255;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
348 int blue = color & 255;
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 double oldLightness = ((double) misc::max (red, green, blue)) / 255;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
351 double newLightness;
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 if (oldLightness > 0.8) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
354 if (d > 0)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
355 newLightness = oldLightness - 0.2;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
356 else
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
357 newLightness = oldLightness - 0.4;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
358 } else if (oldLightness < 0.2) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
359 if (d > 0)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
360 newLightness = oldLightness + 0.4;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
361 else
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
362 newLightness = oldLightness + 0.2;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
363 } else
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
364 newLightness = oldLightness + d * 0.2;
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 if (oldLightness) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
367 double f = (newLightness / oldLightness);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
368 red = (int)(red * f);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
369 green = (int)(green * f);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
370 blue = (int)(blue * f);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
371 } else {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
372 red = green = blue = (int)(newLightness * 255);
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
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
375 return (red << 16) | (green << 8) | blue;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
376 }
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 int Color::shadeColor (int color, Shading shading)
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 switch (shading) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
381 case SHADING_NORMAL:
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
382 return color;
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 case SHADING_LIGHT:
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
385 return shadeColor(color, +1);
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 case SHADING_INVERSE:
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
388 return color ^ 0xffffff;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
389
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
390 case SHADING_DARK:
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
391 return shadeColor(color, -1);
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 default:
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
394 // compiler happiness
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
395 misc::assertNotReached ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
396 return -1;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
397 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
398 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
399
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 844
diff changeset
400
677
b6ef23efdac7 always use shaded colors
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 662
diff changeset
401 Color *Color::create (Layout *layout, int col)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
402 {
677
b6ef23efdac7 always use shaded colors
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 662
diff changeset
403 ColorAttrs attrs(col);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
404
677
b6ef23efdac7 always use shaded colors
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 662
diff changeset
405 return layout->createColor (col);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
406 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
407
1340
37f26396a31b some tooltips
corvid <corvid@lavabit.com>
parents: 1331
diff changeset
408 Tooltip *Tooltip::create (Layout *layout, const char *text)
37f26396a31b some tooltips
corvid <corvid@lavabit.com>
parents: 1331
diff changeset
409 {
37f26396a31b some tooltips
corvid <corvid@lavabit.com>
parents: 1331
diff changeset
410 return layout->createTooltip (text);
37f26396a31b some tooltips
corvid <corvid@lavabit.com>
parents: 1331
diff changeset
411 }
37f26396a31b some tooltips
corvid <corvid@lavabit.com>
parents: 1331
diff changeset
412
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
413 // ----------------------------------------------------------------------
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
414
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
415 /*
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
416 * The drawBorder{Top,Bottom,Left,Right} functions are similar. They
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
417 * use a trapezium as draw polygon, or drawTypedLine() for dots and dashes.
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
418 * Although the concept is simple, achieving pixel accuracy is laborious [1].
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
419 *
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
420 * [1] http://www.dillo.org/css_compat/tests/border-style.html
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
421 */
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
422 static void drawBorderTop(View *view, Style *style,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
423 int x1, int y1, int x2, int y2)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
424
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
425 {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
426 int points[4][2], d, w;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
427 const bool filled = true, convex = true;
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
428 bool ridge = false, inset = false, dotted = false;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
429 Color::Shading shading = Color::SHADING_NORMAL;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
430
1771
47ae467a64e0 don't try to draw 0-width borders
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1762
diff changeset
431 if (!style->borderColor.top || style->borderWidth.top == 0)
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
432 return;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
433
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
434 switch (style->borderStyle.top) {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
435 case BORDER_NONE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
436 case BORDER_HIDDEN:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
437 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
438 case BORDER_DOTTED:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
439 dotted = true;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
440 case BORDER_DASHED:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
441 w = style->borderWidth.top;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
442 view->drawTypedLine(style->borderColor.top, shading,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
443 dotted ? LINE_DOTTED : LINE_DASHED,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
444 w, x1+w/2, y1+w/2, x2-w/2, y2+w/2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
445 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
446 case BORDER_SOLID:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
447 case BORDER_INSET:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
448 inset = true;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
449 case BORDER_OUTSET:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
450 if (style->borderStyle.top != BORDER_SOLID)
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
451 shading = (inset) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
452
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
453 if (style->borderWidth.top == 1) {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
454 view->drawLine(style->borderColor.top, shading, x1, y1, x2, y2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
455 } else {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
456 points[0][0] = x1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
457 points[1][0] = x2 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
458 points[0][1] = points[1][1] = y1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
459 points[2][0] = points[1][0] - style->borderWidth.right;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
460 points[3][0] = x1 + style->borderWidth.left;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
461 points[2][1] = points[3][1] = points[0][1] + style->borderWidth.top;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
462 view->drawPolygon (style->borderColor.top, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
463 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
464 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
465 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
466 case BORDER_RIDGE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
467 ridge = true;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
468 case BORDER_GROOVE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
469 d = style->borderWidth.top & 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
470 points[0][0] = x1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
471 points[1][0] = x2 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
472 points[0][1] = points[1][1] = y1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
473 points[2][0] = x2 - style->borderWidth.right / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
474 points[3][0] = x1 + style->borderWidth.left / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
475 points[2][1] = points[3][1] = y1 + style->borderWidth.top / 2 + d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
476 shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
477 view->drawPolygon (style->borderColor.top, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
478 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
479 points[0][0] = x1 + style->borderWidth.left / 2 + d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
480 points[1][0] = x2 - style->borderWidth.right / 2 + 1 - d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
481 points[0][1] = points[1][1] = y1 + style->borderWidth.top / 2 + d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
482 points[2][0] = x2 - style->borderWidth.right + 1 - d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
483 points[3][0] = x1 + style->borderWidth.left;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
484 points[2][1] = points[3][1] = y1 + style->borderWidth.top;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
485 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
486 view->drawPolygon (style->borderColor.top, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
487 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
488 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
489 case BORDER_DOUBLE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
490 w = (int) rint(style->borderWidth.top / 3.0);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
491 d = w ? style->borderWidth.top - 2 * w : 0;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
492 int w_l = (int) rint(style->borderWidth.left / 3.0);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
493 int w_r = (int) rint(style->borderWidth.right / 3.0);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
494 if (style->borderWidth.top == 1) {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
495 view->drawLine(style->borderColor.top, shading, x1, y1, x2, y2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
496 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
497 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
498 points[0][0] = x1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
499 points[1][0] = x2 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
500 points[0][1] = points[1][1] = y1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
501 points[2][0] = points[1][0] - w_r;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
502 points[3][0] = points[0][0] + w_l;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
503 points[2][1] = points[3][1] = points[0][1] + w;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
504 view->drawPolygon (style->borderColor.top, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
505 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
506 points[0][0] = x1 + style->borderWidth.left - w_l;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
507 points[1][0] = x2 + 1 - style->borderWidth.right + w_r;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
508 points[0][1] = points[1][1] = y1 + w + d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
509 points[2][0] = x2 + 1 - style->borderWidth.right;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
510 points[3][0] = x1 + style->borderWidth.left;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
511 points[2][1] = points[3][1] = y1 + style->borderWidth.top;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
512 view->drawPolygon (style->borderColor.top, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
513 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
514 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
515 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
516 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
517
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
518 static void drawBorderBottom(View *view, Style *style,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
519 int x1, int y1, int x2, int y2)
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
520
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
521 {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
522 int points[4][2], d, w;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
523 const bool filled = true, convex = true;
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
524 bool ridge = false, inset = false, dotted = false;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
525 Color::Shading shading = Color::SHADING_NORMAL;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
526
1771
47ae467a64e0 don't try to draw 0-width borders
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1762
diff changeset
527 if (!style->borderColor.bottom || style->borderWidth.bottom == 0)
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
528 return;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
529
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
530 switch (style->borderStyle.bottom) {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
531 case BORDER_NONE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
532 case BORDER_HIDDEN:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
533 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
534 case BORDER_DOTTED:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
535 dotted = true;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
536 case BORDER_DASHED:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
537 w = style->borderWidth.bottom;
1960
3d3a1ece7e0f dw/style.cc: drawBorder*(): use the correct border colors.
Jeremy Henty <onepoint@starurchin.org>
parents: 1771
diff changeset
538 view->drawTypedLine(style->borderColor.bottom, shading,
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
539 dotted ? LINE_DOTTED : LINE_DASHED,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
540 w, x1+w/2, y1-w/2, x2-w/2, y2-w/2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
541 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
542 case BORDER_SOLID:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
543 case BORDER_INSET:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
544 inset = true;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
545 case BORDER_OUTSET:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
546 if (style->borderStyle.bottom != BORDER_SOLID)
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
547 shading = (inset) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
548
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
549 if (style->borderWidth.bottom == 1) { /* 1 pixel line */
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
550 view->drawLine(style->borderColor.bottom, shading, x1, y1, x2, y2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
551 } else {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
552 points[0][0] = x1 - 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
553 points[1][0] = x2 + 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
554 points[0][1] = points[1][1] = y1 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
555 points[2][0] = points[1][0] - style->borderWidth.right;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
556 points[3][0] = points[0][0] + style->borderWidth.left;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
557 points[2][1] = points[3][1] = points[0][1]-style->borderWidth.bottom;
1955
3066d77f278e Fixed border colors mismatches in drawBorder* functions
Jorge Arellano Cid <jcid@dillo.org>
parents: 1860
diff changeset
558 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
559 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
560 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
561 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
562 case BORDER_RIDGE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
563 ridge = true;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
564 case BORDER_GROOVE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
565 w = style->borderWidth.bottom;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
566 d = w & 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
567 points[0][0] = x1 - 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
568 points[1][0] = x2 + 2 - d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
569 points[0][1] = points[1][1] = y1 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
570 points[2][0] = points[1][0] - style->borderWidth.right / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
571 points[3][0] = points[0][0] + style->borderWidth.left / 2 + d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
572 points[2][1] = points[3][1] = points[0][1] - w/2 - d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
573 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
574 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
575 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
576 // clockwise
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
577 points[0][0] = x1 + style->borderWidth.left - 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
578 points[1][0] = x2 + 1 - style->borderWidth.right + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
579 points[0][1] = points[1][1] = y1 - w + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
580 points[2][0] = points[1][0] + style->borderWidth.right / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
581 points[3][0] = points[0][0] - style->borderWidth.left / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
582 points[2][1] = points[3][1] = points[0][1] + w/2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
583 shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
1955
3066d77f278e Fixed border colors mismatches in drawBorder* functions
Jorge Arellano Cid <jcid@dillo.org>
parents: 1860
diff changeset
584 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
585 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
586 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
587 case BORDER_DOUBLE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
588 w = (int) rint(style->borderWidth.bottom / 3.0);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
589 d = w ? style->borderWidth.bottom - 2 * w : 0;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
590 int w_l = (int) rint(style->borderWidth.left / 3.0);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
591 int w_r = (int) rint(style->borderWidth.right / 3.0);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
592 if (style->borderWidth.bottom == 1) {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
593 view->drawLine(style->borderColor.bottom, shading, x1, y1, x2, y2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
594 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
595 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
596 points[0][0] = x2 + 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
597 points[1][0] = x1 - 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
598 points[0][1] = points[1][1] = y1 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
599 points[2][0] = points[1][0] + w_l;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
600 points[3][0] = points[0][0] - w_r;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
601 points[2][1] = points[3][1] = points[0][1] - w;
1955
3066d77f278e Fixed border colors mismatches in drawBorder* functions
Jorge Arellano Cid <jcid@dillo.org>
parents: 1860
diff changeset
602 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
603 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
604 points[0][0] = x2 + 2 - style->borderWidth.right + w_r;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
605 points[1][0] = x1 - 1 + style->borderWidth.left - w_l;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
606 points[0][1] = points[1][1] = y1 + 1 - w - d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
607 points[2][0] = x1 - 1 + style->borderWidth.left;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
608 points[3][0] = x2 + 2 - style->borderWidth.right;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
609 points[2][1] = points[3][1] = y1 + 1 - style->borderWidth.bottom;
1955
3066d77f278e Fixed border colors mismatches in drawBorder* functions
Jorge Arellano Cid <jcid@dillo.org>
parents: 1860
diff changeset
610 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
611 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
612 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
613 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
614 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
615
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
616 static void drawBorderLeft(View *view, Style *style,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
617 int x1, int y1, int x2, int y2)
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
618
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
619 {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
620 int points[4][2], d, w;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
621 bool filled = true, convex = true;
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
622 bool ridge = false, inset = false, dotted = false;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
623 Color::Shading shading = Color::SHADING_NORMAL;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
624
1771
47ae467a64e0 don't try to draw 0-width borders
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1762
diff changeset
625 if (!style->borderColor.left || style->borderWidth.left == 0)
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
626 return;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
627
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
628 switch (style->borderStyle.left) {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
629 case BORDER_NONE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
630 case BORDER_HIDDEN:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
631 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
632 case BORDER_DOTTED:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
633 dotted = true;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
634 case BORDER_DASHED:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
635 w = style->borderWidth.left;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
636 view->drawTypedLine(style->borderColor.left, shading,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
637 dotted ? LINE_DOTTED : LINE_DASHED,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
638 w, x1+w/2, y1+w/2, x1+w/2, y2-w/2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
639 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
640 case BORDER_SOLID:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
641 case BORDER_INSET:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
642 inset = true;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
643 case BORDER_OUTSET:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
644 if (style->borderStyle.left != BORDER_SOLID)
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
645 shading = (inset) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
646 if (style->borderWidth.left == 1) { /* 1 pixel line */
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
647 view->drawLine(style->borderColor.left, shading, x1, y1, x2, y2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
648 } else {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
649 points[0][0] = points[1][0] = x1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
650 points[0][1] = y1 - 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
651 points[1][1] = y2 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
652 points[2][0] = points[3][0] = points[0][0] + style->borderWidth.left;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
653 points[2][1] = points[1][1] - style->borderWidth.bottom;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
654 points[3][1] = points[0][1] + style->borderWidth.top;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
655 view->drawPolygon (style->borderColor.left, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
656 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
657 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
658 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
659 case BORDER_RIDGE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
660 ridge = true;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
661 case BORDER_GROOVE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
662 w = style->borderWidth.left;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
663 d = w & 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
664 points[0][0] = points[1][0] = x1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
665 points[0][1] = y1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
666 points[1][1] = y2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
667 points[2][0] = points[3][0] = x1 + w / 2 + d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
668 points[2][1] = y2 - style->borderWidth.bottom / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
669 points[3][1] = y1 + style->borderWidth.top / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
670 shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
1955
3066d77f278e Fixed border colors mismatches in drawBorder* functions
Jorge Arellano Cid <jcid@dillo.org>
parents: 1860
diff changeset
671 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
672 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
673 points[0][0] = points[1][0] = x1 + w / 2 + d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
674 points[0][1] = y1 + style->borderWidth.top / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
675 points[1][1] = y2 - style->borderWidth.bottom / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
676 points[2][0] = points[3][0] = x1 + w;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
677 points[2][1] = y2 - style->borderWidth.bottom;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
678 points[3][1] = y1 + style->borderWidth.top;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
679 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1955
3066d77f278e Fixed border colors mismatches in drawBorder* functions
Jorge Arellano Cid <jcid@dillo.org>
parents: 1860
diff changeset
680 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
681 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
682 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
683 case BORDER_DOUBLE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
684 w = (int) rint(style->borderWidth.left / 3.0);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
685 d = w ? style->borderWidth.left - 2 * w : 0;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
686 int w_b = (int) rint(style->borderWidth.bottom / 3.0);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
687 int w_t = (int) rint(style->borderWidth.top / 3.0);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
688 if (style->borderWidth.left == 1) {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
689 view->drawLine(style->borderColor.left, shading, x1, y1, x2, y2-1);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
690 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
691 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
692 points[0][0] = points[1][0] = x1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
693 points[0][1] = y1 - 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
694 points[1][1] = y2 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
695 points[2][0] = points[3][0] = points[0][0] + w;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
696 points[2][1] = points[1][1] - w_b;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
697 points[3][1] = points[0][1] + w_t;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
698 view->drawPolygon (style->borderColor.left, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
699 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
700 points[0][0] = points[1][0] = x1 + w + d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
701 points[0][1] = y1 - 1 + style->borderWidth.top - w_t;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
702 points[1][1] = y2 + 1 - style->borderWidth.bottom + w_b;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
703 points[2][0] = points[3][0] = points[0][0] + w;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
704 points[2][1] = y2 + 1 - style->borderWidth.bottom;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
705 points[3][1] = y1 - 1 + style->borderWidth.top;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
706 view->drawPolygon (style->borderColor.left, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
707 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
708 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
709 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
710 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
711
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
712 static void drawBorderRight(View *view, Style *style,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
713 int x1, int y1, int x2, int y2)
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
714
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
715 {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
716 int points[4][2], d, w;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
717 const bool filled = true, convex = true;
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
718 bool ridge = false, inset = false, dotted = false;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
719 Color::Shading shading = Color::SHADING_NORMAL;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
720
1771
47ae467a64e0 don't try to draw 0-width borders
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1762
diff changeset
721 if (!style->borderColor.right || style->borderWidth.right == 0)
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
722 return;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
723
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
724 switch (style->borderStyle.right) {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
725 case BORDER_NONE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
726 case BORDER_HIDDEN:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
727 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
728 case BORDER_DOTTED:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
729 dotted = true;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
730 case BORDER_DASHED:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
731 w = style->borderWidth.right;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
732 view->drawTypedLine(style->borderColor.right, shading,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
733 dotted ? LINE_DOTTED : LINE_DASHED,
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
734 w, x1 - w/2, y1 + w/2, x1 - w/2, y2 - w/2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
735 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
736 case BORDER_SOLID:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
737 case BORDER_INSET:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
738 inset = true;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
739 case BORDER_OUTSET:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
740 if (style->borderStyle.right != BORDER_SOLID)
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
741 shading = (inset) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
742 if (style->borderWidth.right == 1) { /* 1 pixel line */
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
743 view->drawLine(style->borderColor.right, shading, x1, y1, x2, y2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
744 } else {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
745 points[0][0] = points[1][0] = x1 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
746 points[0][1] = y1 - 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
747 points[1][1] = y2 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
748 points[2][0] = points[3][0] = points[0][0]-style->borderWidth.right;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
749 points[2][1] = points[1][1] - style->borderWidth.bottom;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
750 points[3][1] = points[0][1] + style->borderWidth.top;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
751 view->drawPolygon (style->borderColor.right, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
752 points,4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
753 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
754 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
755 case BORDER_RIDGE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
756 ridge = true;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
757 case BORDER_GROOVE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
758 w = style->borderWidth.right;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
759 d = w & 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
760 points[0][0] = points[1][0] = x1 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
761 points[0][1] = y1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
762 points[1][1] = y2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
763 points[2][0] = points[3][0] = points[0][0] - w / 2 - d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
764 points[2][1] = y2 - style->borderWidth.bottom / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
765 points[3][1] = points[0][1] + style->borderWidth.top / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
766 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
767 view->drawPolygon (style->borderColor.right, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
768 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
769 points[0][0] = points[1][0] = x1 + 1 - w / 2 - d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
770 points[0][1] = y1 + style->borderWidth.top / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
771 points[1][1] = y2 - style->borderWidth.bottom / 2;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
772 points[2][0] = points[3][0] = x1 + 1 - w;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
773 points[2][1] = y2 - style->borderWidth.bottom;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
774 points[3][1] = y1 + style->borderWidth.top;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
775 shading = (ridge) ? Color::SHADING_LIGHT: Color::SHADING_DARK;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
776 view->drawPolygon (style->borderColor.right, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
777 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
778 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
779 case BORDER_DOUBLE:
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
780 w = (int) rint(style->borderWidth.right / 3.0);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
781 d = w ? style->borderWidth.right - 2 * w : 0;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
782 int w_b = (int) rint(style->borderWidth.bottom / 3.0);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
783 int w_t = (int) rint(style->borderWidth.top / 3.0);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
784 if (style->borderWidth.right == 1) {
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
785 view->drawLine(style->borderColor.right, shading, x1, y1, x2, y2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
786 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
787 }
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
788 points[0][0] = points[1][0] = x1 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
789 points[0][1] = y1 - 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
790 points[1][1] = y2 + 1;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
791 points[2][0] = points[3][0] = points[0][0] - w;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
792 points[2][1] = points[1][1] - w_b;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
793 points[3][1] = points[0][1] + w_t;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
794 view->drawPolygon (style->borderColor.right, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
795 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
796 points[0][0] = points[1][0] = x1 + 1 - w - d;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
797 points[0][1] = y1 - 1 + style->borderWidth.top - w_t;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
798 points[1][1] = y2 + 1 - style->borderWidth.bottom + w_b;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
799 points[2][0] = points[3][0] = points[0][0] - w;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
800 points[2][1] = y2 + 1 - style->borderWidth.bottom;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
801 points[3][1] = y1 - 1 + style->borderWidth.top;
1860
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
802 view->drawPolygon (style->borderColor.right, shading, filled, convex,
6811278a670c convex polygons for border drawing
corvid <corvid@lavabit.com>
parents: 1771
diff changeset
803 points, 4);
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
804 break;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
805 }
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
806 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
807
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
808 /**
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
809 * \brief Draw the border of a region in window, according to style.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
810 *
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
811 * Used by dw::core::Widget::drawBox and dw::core::Widget::drawWidgetBox.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
812 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
813 void drawBorder (View *view, Rectangle *area,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
814 int x, int y, int width, int height,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
815 Style *style, bool inverse)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
816 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
817 /** \todo a lot! */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
818 Color::Shading dark, light, normal;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
819 int xb1, yb1, xb2, yb2, xp1, yp1, xp2, yp2;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
820
1291
63837a774687 update Style::drawBorder()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1289
diff changeset
821 // top left and bottom right point of outer border boundary
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
822 xb1 = x + style->margin.left;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
823 yb1 = y + style->margin.top;
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
824 xb2 = x + (width > 0 ? width - 1 : 0) - style->margin.right;
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
825 yb2 = y + (height > 0 ? height - 1 : 0) - style->margin.bottom;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
826
1291
63837a774687 update Style::drawBorder()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1289
diff changeset
827 // top left and bottom right point of inner border boundary
63837a774687 update Style::drawBorder()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1289
diff changeset
828 xp1 = xb1 + style->borderWidth.left;
63837a774687 update Style::drawBorder()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1289
diff changeset
829 yp1 = yb1 + style->borderWidth.top;
63837a774687 update Style::drawBorder()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1289
diff changeset
830 xp2 = xb2 - style->borderWidth.right;
63837a774687 update Style::drawBorder()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1289
diff changeset
831 yp2 = yb2 - style->borderWidth.bottom;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
832
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
833 light = inverse ? Color::SHADING_DARK : Color::SHADING_LIGHT;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
834 dark = inverse ? Color::SHADING_LIGHT : Color::SHADING_DARK;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
835 normal = inverse ? Color::SHADING_INVERSE : Color::SHADING_NORMAL;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
836
1760
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
837 drawBorderRight(view, style, xb2, yb1, xb2, yb2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
838 drawBorderLeft(view, style, xb1, yb1, xb1, yb2);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
839 drawBorderTop(view, style, xb1, yb1, xb2, yb1);
cbca357af616 Full CSS border-style implementation
Jorge Arellano Cid <jcid@dillo.org>
parents: 1757
diff changeset
840 drawBorderBottom(view, style, xb1, yb2, xb2, yb2);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
841 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
842
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
843
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
844 /**
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
845 * \brief Draw the background (content plus padding) of a region in window,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
846 * according to style.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
847 *
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
848 * Used by dw::core::Widget::drawBox and dw::core::Widget::drawWidgetBox.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
849 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
850 void drawBackground (View *view, Rectangle *area,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
851 int x, int y, int width, int height,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
852 Style *style, bool inverse)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
853 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
854 Rectangle bgArea, intersection;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
855
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
856 if (style->backgroundColor) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
857 bgArea.x = x + style->margin.left + style->borderWidth.left;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
858 bgArea.y = y + style->margin.top + style->borderWidth.top;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
859 bgArea.width =
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
860 width - style->margin.left - style->borderWidth.left -
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
861 style->margin.right - style->borderWidth.right;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
862 bgArea.height =
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
863 height - style->margin.top - style->borderWidth.top -
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
864 style->margin.bottom - style->borderWidth.bottom;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
865
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
866 if (area->intersectsWith (&bgArea, &intersection))
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
867 view->drawRectangle (style->backgroundColor,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
868 inverse ?
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
869 Color::SHADING_INVERSE : Color::SHADING_NORMAL,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
870 true, intersection.x, intersection.y,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
871 intersection.width, intersection.height);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
872 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
873 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
874
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
875 // ----------------------------------------------------------------------
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
876
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
877 static const char
479
cd066a3f0405 Added some const quialifiers.
corvid <corvid@lavabit.com>
parents: 347
diff changeset
878 *const roman_I0[] = { "","I","II","III","IV","V","VI","VII","VIII","IX" },
cd066a3f0405 Added some const quialifiers.
corvid <corvid@lavabit.com>
parents: 347
diff changeset
879 *const roman_I1[] = { "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC" },
cd066a3f0405 Added some const quialifiers.
corvid <corvid@lavabit.com>
parents: 347
diff changeset
880 *const roman_I2[] = { "","C","CC","CCC","CD","D","DC","DCC","DCCC","CM" },
cd066a3f0405 Added some const quialifiers.
corvid <corvid@lavabit.com>
parents: 347
diff changeset
881 *const roman_I3[] = { "","M","MM","MMM","MMMM" };
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
882
1111
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
883 static void strtolower (char *s)
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
884 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
885 for ( ; *s; s++)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
886 *s = tolower (*s);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
887 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
888
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
889 /**
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
890 * \brief Convert a number into a string, in a given list style.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
891 *
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
892 * Used for ordered lists.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
893 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
894 void numtostr (int num, char *buf, int buflen, ListStyleType listStyleType)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
895 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
896 int i3, i2, i1, i0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
897 bool low = false;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
898 int start_ch = 'A';
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
899
1111
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
900 if (buflen <= 0)
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
901 return;
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
902
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
903 switch(listStyleType){
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
904 case LIST_STYLE_TYPE_LOWER_ALPHA:
1364
f6cf5158796b recognize latin list style types as synonyms for alpha
corvid <corvid@lavabit.com>
parents: 1350
diff changeset
905 case LIST_STYLE_TYPE_LOWER_LATIN:
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
906 start_ch = 'a';
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
907 case LIST_STYLE_TYPE_UPPER_ALPHA:
1364
f6cf5158796b recognize latin list style types as synonyms for alpha
corvid <corvid@lavabit.com>
parents: 1350
diff changeset
908 case LIST_STYLE_TYPE_UPPER_LATIN:
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
909 i0 = num - 1;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
910 i1 = i0/26 - 1; i2 = i1/26 - 1;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
911 if (i2 > 25) /* more than 26+26^2+26^3=18278 elements ? */
1111
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
912 snprintf(buf, buflen, "****.");
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
913 else
1111
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
914 snprintf(buf, buflen, "%c%c%c.",
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
915 i2<0 ? ' ' : start_ch + i2%26,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
916 i1<0 ? ' ' : start_ch + i1%26,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
917 i0<0 ? ' ' : start_ch + i0%26);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
918 break;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
919 case LIST_STYLE_TYPE_LOWER_ROMAN:
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
920 low = true;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
921 case LIST_STYLE_TYPE_UPPER_ROMAN:
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
922 i0 = num;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
923 i1 = i0/10; i2 = i1/10; i3 = i2/10;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
924 i0 %= 10; i1 %= 10; i2 %= 10;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
925 if (num < 0 || i3 > 4) /* more than 4999 elements ? */
1111
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
926 snprintf(buf, buflen, "****.");
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
927 else
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
928 snprintf(buf, buflen, "%s%s%s%s.", roman_I3[i3], roman_I2[i2],
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
929 roman_I1[i1], roman_I0[i0]);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
930 break;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
931 case LIST_STYLE_TYPE_DECIMAL:
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
932 default:
1111
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
933 snprintf(buf, buflen, "%d.", num);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
934 break;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
935 }
1111
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
936
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
937 // ensure termination
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
938 buf[buflen - 1] = '\0';
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
939
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
940 if (low)
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
941 strtolower(buf);
9845cc109124 consistently use snprintf
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 972
diff changeset
942
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
943 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
944
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
945 } // namespace style
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
946 } // namespace dw
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
947 } // namespace core