Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3584 sourcerer 1
/*
2
 * Copyright 2004 James Bursa 
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 .
17
 */
18
 
19
/** \file
20
 * Plotter styles.
21
 */
22
 
23
#ifndef _NETSURF_DESKTOP_PLOT_STYLE_H_
24
#define _NETSURF_DESKTOP_PLOT_STYLE_H_
25
 
26
#include 
27
 
28
/* html widget colours */
29
#define WIDGET_BASEC 0xd9d9d9
30
#define WIDGET_BLOBC 0x000000
31
 
32
/* Darken a colour by taking three quarters of each channel's intensity */
33
#define darken_colour(c1)				 		\
34
	((((3 * ((c1 >> 16) & 0xff)) >> 2) << 16) |			\
35
	 (((3 * ((c1 >>  8) & 0xff)) >> 2) <<  8) |	 		\
36
	 (((3 * ( c1        & 0xff)) >> 2) <<  0))
37
 
38
/* Darken a colour by taking nine sixteenths of each channel's intensity */
39
#define double_darken_colour(c1)			 		\
40
	((((9 * ((c1 >> 16) & 0xff)) >> 4) << 16) |			\
41
	 (((9 * ((c1 >>  8) & 0xff)) >> 4) <<  8) |	 		\
42
	 (((9 * ( c1        & 0xff)) >> 4) <<  0))
43
 
44
/* Lighten a colour by taking three quarters of each channel's intensity
45
 * and adding a full quarter
46
 */
47
#define lighten_colour(c1)						\
48
	(((((3 * ((c1 >> 16) & 0xff)) >> 2) + 64) << 16) |		\
49
	 ((((3 * ((c1 >>  8) & 0xff)) >> 2) + 64) <<  8) |		\
50
	 ((((3 * ( c1        & 0xff)) >> 2) + 64) <<  0))
51
 
52
/* Lighten a colour by taking nine sixteenths of each channel's intensity and
53
 * adding a full intensity 7/16ths */
54
#define double_lighten_colour(c1)					\
55
	(((((9 * ((c1 >> 16) & 0xff)) >> 4) + 112) << 16) |		\
56
	 ((((9 * ((c1 >>  8) & 0xff)) >> 4) + 112) <<  8) |		\
57
	 ((((9 * ( c1        & 0xff)) >> 4) + 112) <<  0))
58
 
59
/* Blend two colours by taking half the intensity of each channel in the first
60
 * colour and adding them to half the intensity of each channel in the second
61
 * colour */
62
#define blend_colour(c0, c1)						\
63
	(((((c0 >> 16) & 0xff) + ((c1 >> 16) & 0xff)) >> 1) << 16) |	\
64
	(((((c0 >>  8) & 0xff) + ((c1 >>  8) & 0xff)) >> 1) <<  8) |	\
65
	(((( c0        & 0xff) + ( c1        & 0xff)) >> 1) <<  0)
66
 
67
/* get a bitmap pixel (image/bitmap.h) into a plot colour */
68
#define pixel_to_colour(b)					\
69
	b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)
70
 
71
/**
72
 * Colour type: XBGR
73
 */
74
typedef uint32_t colour;
75
 
76
/**
77
 * Magical transparent value
78
 */
79
#define NS_TRANSPARENT 0x01000000
80
 
81
/**
82
 * Type of plot operation
83
 */
84
typedef enum {
85
	PLOT_OP_TYPE_NONE = 0, /**< No operation */
86
	PLOT_OP_TYPE_SOLID, /**< Solid colour */
87
	PLOT_OP_TYPE_DOT, /**< Dotted plot */
88
	PLOT_OP_TYPE_DASH, /**< Dashed plot */
89
} plot_operation_type_t;
90
 
91
/**
92
 * Plot style for stroke/fill plotters
93
 */
94
typedef struct {
95
	plot_operation_type_t stroke_type; /**< Stroke plot type */
96
	int stroke_width; /**< Width of stroke, in pixels */
97
	colour stroke_colour; /**< Colour of stroke */
98
	plot_operation_type_t fill_type; /**< Fill plot type */
99
	colour fill_colour; /**< Colour of fill */
100
} plot_style_t;
101
 
102
/**
103
 * Generic font family type
104
 */
105
typedef enum {
106
	PLOT_FONT_FAMILY_SANS_SERIF = 0,
107
	PLOT_FONT_FAMILY_SERIF,
108
	PLOT_FONT_FAMILY_MONOSPACE,
109
	PLOT_FONT_FAMILY_CURSIVE,
110
	PLOT_FONT_FAMILY_FANTASY,
111
	PLOT_FONT_FAMILY_COUNT /**< Number of generic families */
112
} plot_font_generic_family_t;
113
 
114
/**
115
 * Font plot flags
116
 */
117
typedef unsigned long plot_font_flags_t;
118
#define FONTF_NONE 0
119
#define FONTF_ITALIC 1
120
#define FONTF_OBLIQUE 2
121
#define FONTF_SMALLCAPS 4
122
 
123
/**
124
 * Scaling factor for font sizes
125
 */
126
#define FONT_SIZE_SCALE 1024
127
 
128
/**
129
 * Font style for plotting
130
 */
131
typedef struct {
132
	plot_font_generic_family_t family; /**< Generic family to plot with */
133
	int size; /**< Font size, in points * FONT_SIZE_SCALE */
134
	int weight; /**< Font weight: value in range [100,900] as per CSS */
135
	plot_font_flags_t flags; /**< Font flags */
136
	colour background; /**< Background colour to blend to, if appropriate */
137
	colour foreground; /**< Colour of text */
138
} plot_font_style_t;
139
 
140
/* global fill styles */
141
extern plot_style_t *plot_style_fill_white;
142
extern plot_style_t *plot_style_fill_red;
143
extern plot_style_t *plot_style_fill_black;
144
 
145
/* Box model debug outline styles for content, padding and margin edges */
146
extern plot_style_t const * const plot_style_content_edge;
147
extern plot_style_t const * const plot_style_padding_edge;
148
extern plot_style_t const * const plot_style_margin_edge;
149
 
150
/* Broken object replacement styles */
151
extern plot_style_t const * const plot_style_broken_object;
152
extern plot_font_style_t const * const plot_fstyle_broken_object;
153
 
154
 
155
/* other styles */
156
extern plot_style_t *plot_style_caret;
157
extern plot_style_t *plot_style_stroke_history;
158
extern plot_style_t *plot_style_fill_wbasec;
159
extern plot_style_t *plot_style_fill_darkwbasec;
160
extern plot_style_t *plot_style_fill_lightwbasec;
161
extern plot_style_t *plot_style_fill_wblobc;
162
extern plot_style_t *plot_style_stroke_wblobc;
163
extern plot_style_t *plot_style_stroke_darkwbasec;
164
extern plot_style_t *plot_style_stroke_lightwbasec;
165
 
166
/* Default font style */
167
extern plot_font_style_t const * const plot_style_font;
168
 
169
#ifndef HISTORY_COLOUR_SELECTED
170
#define HISTORY_COLOUR_SELECTED 0xFF0000
171
#endif
172
 
173
#ifndef HISTORY_COLOUR_FOREGROUND
174
#define HISTORY_COLOUR_FOREGROUND 0x333333
175
#endif
176
 
177
#ifndef HISTORY_COLOUR_BACKGROUND
178
#define HISTORY_COLOUR_BACKGROUND 0xFFFFFF
179
#endif
180
 
181
#ifndef HISTORY_COLOUR_LINES
182
#define HISTORY_COLOUR_LINES HISTORY_COLOUR_FOREGROUND
183
#endif
184
 
185
#endif