1 /*
2  * Copyright 2009 Vincent Sanders <vince@kyllikki.org>
3  *
4  * This file is part of NetSurf, http://www.netsurf-browser.org/
5  *
6  * NetSurf is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * NetSurf is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 /**
20  * \file
21  * \brief Plotter global styles.
22  *
23  * These plot styles are globaly available and used in many places.
24  */
25 
26 #include "netsurf/plot_style.h"
27 
28 static plot_style_t plot_style_fill_white_static = {
29 	.fill_type = PLOT_OP_TYPE_SOLID,
30 	.fill_colour = 0xffffff,
31 };
32 plot_style_t *plot_style_fill_white = &plot_style_fill_white_static;
33 
34 static plot_style_t plot_style_fill_black_static = {
35 	.fill_type = PLOT_OP_TYPE_SOLID,
36 	.fill_colour = 0x0,
37 };
38 plot_style_t *plot_style_fill_black = &plot_style_fill_black_static;
39 
40 static plot_style_t plot_style_fill_red_static = {
41 	.fill_type = PLOT_OP_TYPE_SOLID,
42 	.fill_colour = 0x000000ff,
43 };
44 plot_style_t *plot_style_fill_red = &plot_style_fill_red_static;
45 
46 /* Box model debug outline styles for content, padding and margin edges */
47 static const plot_style_t plot_style_content_edge_static = {
48 	.stroke_type = PLOT_OP_TYPE_SOLID,
49 	.stroke_colour = 0x00ff0000,
50 	.stroke_width = plot_style_int_to_fixed(1),
51 };
52 plot_style_t const * const plot_style_content_edge =
53 		&plot_style_content_edge_static;
54 
55 static const plot_style_t plot_style_padding_edge_static = {
56 	.stroke_type = PLOT_OP_TYPE_SOLID,
57 	.stroke_colour = 0x000000ff,
58 	.stroke_width = plot_style_int_to_fixed(1),
59 };
60 plot_style_t const * const plot_style_padding_edge =
61 		&plot_style_padding_edge_static;
62 
63 static const plot_style_t plot_style_margin_edge_static = {
64 	.stroke_type = PLOT_OP_TYPE_SOLID,
65 	.stroke_colour = 0x0000ffff,
66 	.stroke_width = plot_style_int_to_fixed(1),
67 };
68 plot_style_t const * const plot_style_margin_edge =
69 		&plot_style_margin_edge_static;
70 
71 /* Broken object replacement styles */
72 static const plot_style_t plot_style_broken_object_static = {
73 	.fill_type = PLOT_OP_TYPE_SOLID,
74 	.fill_colour = 0x008888ff,
75 	.stroke_type = PLOT_OP_TYPE_SOLID,
76 	.stroke_colour = 0x000000ff,
77 	.stroke_width = plot_style_int_to_fixed(1),
78 };
79 plot_style_t const * const plot_style_broken_object =
80 		&plot_style_broken_object_static;
81 
82 static const plot_font_style_t plot_fstyle_broken_object_static = {
83 	.family = PLOT_FONT_FAMILY_SANS_SERIF,
84 	.size = 16 * PLOT_STYLE_SCALE,
85 	.weight = 400,
86 	.flags = FONTF_NONE,
87 	.background = 0x8888ff,
88 	.foreground = 0x000044,
89 };
90 plot_font_style_t const * const plot_fstyle_broken_object =
91 		&plot_fstyle_broken_object_static;
92 
93 /* caret style used in html_redraw_caret */
94 static plot_style_t plot_style_caret_static = {
95 	.stroke_type = PLOT_OP_TYPE_SOLID,
96 	.stroke_colour = 0x0000ff,  /* todo - choose a proper colour */
97 };
98 plot_style_t *plot_style_caret = &plot_style_caret_static;
99 
100 
101 
102 /* html redraw widget styles */
103 
104 /** plot style for filled widget base colour. */
105 static plot_style_t plot_style_fill_wbasec_static = {
106 	.fill_type = PLOT_OP_TYPE_SOLID,
107 	.fill_colour = WIDGET_BASEC,
108 };
109 plot_style_t *plot_style_fill_wbasec = &plot_style_fill_wbasec_static;
110 
111 /** plot style for dark filled widget base colour . */
112 static plot_style_t plot_style_fill_darkwbasec_static = {
113 	.fill_type = PLOT_OP_TYPE_SOLID,
114 	.fill_colour = double_darken_colour(WIDGET_BASEC),
115 };
116 plot_style_t *plot_style_fill_darkwbasec = &plot_style_fill_darkwbasec_static;
117 
118 /** plot style for light filled widget base colour. */
119 static plot_style_t plot_style_fill_lightwbasec_static = {
120 	.fill_type = PLOT_OP_TYPE_SOLID,
121 	.fill_colour = double_lighten_colour(WIDGET_BASEC),
122 };
123 plot_style_t *plot_style_fill_lightwbasec = &plot_style_fill_lightwbasec_static;
124 
125 
126 /** plot style for widget background. */
127 static plot_style_t plot_style_fill_wblobc_static = {
128 	.fill_type = PLOT_OP_TYPE_SOLID,
129 	.fill_colour = WIDGET_BLOBC,
130 };
131 plot_style_t *plot_style_fill_wblobc = &plot_style_fill_wblobc_static;
132 
133 /** plot style for checkbox cross. */
134 static plot_style_t plot_style_stroke_wblobc_static = {
135 	.stroke_type = PLOT_OP_TYPE_SOLID,
136 	.stroke_colour = WIDGET_BLOBC,
137 	.stroke_width = plot_style_int_to_fixed(2),
138 };
139 plot_style_t *plot_style_stroke_wblobc = &plot_style_stroke_wblobc_static;
140 
141 /** stroke style for widget double dark colour. */
142 static plot_style_t plot_style_stroke_darkwbasec_static = {
143 	.stroke_type = PLOT_OP_TYPE_SOLID,
144 	.stroke_colour = double_darken_colour(WIDGET_BASEC),
145 };
146 plot_style_t *plot_style_stroke_darkwbasec = &plot_style_stroke_darkwbasec_static;
147 
148 /** stroke style for widget double light colour. */
149 static plot_style_t plot_style_stroke_lightwbasec_static = {
150 	.stroke_type = PLOT_OP_TYPE_SOLID,
151 	.stroke_colour = double_lighten_colour(WIDGET_BASEC),
152 };
153 plot_style_t *plot_style_stroke_lightwbasec = &plot_style_stroke_lightwbasec_static;
154 
155 
156 /* Generic font style */
157 static const plot_font_style_t plot_style_font_static = {
158 	.family = PLOT_FONT_FAMILY_SANS_SERIF,
159 	.size = 8 * PLOT_STYLE_SCALE,
160 	.weight = 400,
161 	.flags = FONTF_NONE,
162 	.background = 0xffffff,
163 	.foreground = 0x000000,
164 };
165 plot_font_style_t const * const plot_style_font = &plot_style_font_static;
166 
167