summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'desktop')
-rw-r--r--desktop/history_core.c18
-rw-r--r--desktop/knockout.c70
-rw-r--r--desktop/plot_style.c121
-rw-r--r--desktop/plot_style.h90
-rw-r--r--desktop/plotters.h30
-rw-r--r--desktop/save_pdf/pdf_plotters.c33
-rw-r--r--desktop/textarea.c8
7 files changed, 264 insertions, 106 deletions
diff --git a/desktop/history_core.c b/desktop/history_core.c
index d02820b20..a40d746bd 100644
--- a/desktop/history_core.c
+++ b/desktop/history_core.c
@@ -661,19 +661,19 @@ bool history_redraw_entry(struct history *history,
if (!plot.line(entry->x + WIDTH + xoffset,
entry->y + HEIGHT / 2 + yoffset,
entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset, 1,
- 0x333333, false, false))
+ entry->y + HEIGHT / 2 + yoffset,
+ plot_style_stroke_history))
return false;
if (!plot.line(entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- child->x - tailsize +xoffset,
- child->y + HEIGHT / 2 + yoffset, 1,
- 0x333333, false, false))
+ entry->y + HEIGHT / 2 + yoffset,
+ child->x - tailsize +xoffset,
+ child->y + HEIGHT / 2 + yoffset,
+ plot_style_stroke_history))
return false;
if (!plot.line(child->x - tailsize + xoffset,
- child->y + HEIGHT / 2 + yoffset,
- child->x + xoffset, child->y + HEIGHT / 2 + yoffset, 1,
- 0x333333, false, false))
+ child->y + HEIGHT / 2 + yoffset,
+ child->x + xoffset, child->y + HEIGHT / 2 + yoffset,
+ plot_style_stroke_history))
return false;
if (!history_redraw_entry(history, child, x0, y0, x1, y1, x, y, clip))
return false;
diff --git a/desktop/knockout.c b/desktop/knockout.c
index 807833b8b..7cecb92c8 100644
--- a/desktop/knockout.c
+++ b/desktop/knockout.c
@@ -75,47 +75,6 @@
#define KNOCKOUT_BOXES 768 /* 28 bytes each */
#define KNOCKOUT_POLYGONS 3072 /* 4 bytes each */
-/** Global fill styles - used everywhere, should they be here? */
-static plot_style_t plot_style_fill_white_static = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = 0xffffff,
-};
-
-static plot_style_t plot_style_fill_red_static = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = 0x000000ff,
-};
-
-static plot_style_t plot_style_fill_black_static = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = 0x0,
-};
-
-static plot_style_t plot_style_stroke_red_static = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = 0x000000ff,
- .stroke_width = 1,
-};
-
-static plot_style_t plot_style_stroke_blue_static = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = 0x00ff0000,
- .stroke_width = 1,
-};
-
-static plot_style_t plot_style_stroke_yellow_static = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = 0x0000ffff,
- .stroke_width = 1,
-};
-
-plot_style_t *plot_style_fill_white = &plot_style_fill_white_static;
-plot_style_t *plot_style_fill_red = &plot_style_fill_red_static;
-plot_style_t *plot_style_fill_black = &plot_style_fill_black_static;
-plot_style_t *plot_style_stroke_red = &plot_style_stroke_red_static;
-plot_style_t *plot_style_stroke_blue = &plot_style_stroke_blue_static;
-plot_style_t *plot_style_stroke_yellow = &plot_style_stroke_yellow_static;
-
struct knockout_box;
struct knockout_entry;
@@ -126,8 +85,7 @@ static bool knockout_plot_fill_recursive(struct knockout_box *box, plot_style_t
static bool knockout_plot_bitmap_recursive(struct knockout_box *box,
struct knockout_entry *entry);
-static bool knockout_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+static bool knockout_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
static bool knockout_plot_polygon(const int *p, unsigned int n, colour fill);
static bool knockout_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *plot_style);
static bool knockout_plot_clip(int clip_x0, int clip_y0,
@@ -208,10 +166,7 @@ struct knockout_entry {
int y0;
int x1;
int y1;
- int width;
- colour c;
- bool dotted;
- bool dashed;
+ plot_style_t plot_style;
} line;
struct {
int *p;
@@ -365,10 +320,7 @@ bool knockout_plot_flush(void)
knockout_entries[i].data.line.y0,
knockout_entries[i].data.line.x1,
knockout_entries[i].data.line.y1,
- knockout_entries[i].data.line.width,
- knockout_entries[i].data.line.c,
- knockout_entries[i].data.line.dotted,
- knockout_entries[i].data.line.dashed);
+ &knockout_entries[i].data.line.plot_style);
break;
case KNOCKOUT_PLOT_POLYGON:
success &= plot.polygon(
@@ -687,18 +639,22 @@ bool knockout_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t
knockout_entries[knockout_entry_cur].data.fill.x1 = x1;
knockout_entries[knockout_entry_cur].data.fill.y1 = y1;
knockout_entries[knockout_entry_cur].data.fill.plot_style = *pstyle;
+ knockout_entries[knockout_entry_cur].data.fill.plot_style.stroke_type = PLOT_OP_TYPE_NONE; /* ensure we only plot the fill */
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_FILL;
if ((++knockout_entry_cur >= KNOCKOUT_ENTRIES) ||
(++knockout_box_cur >= KNOCKOUT_BOXES))
knockout_plot_flush();
- } else if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) {
- /* not a filled area */
+ }
+
+ if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) {
+ /* draw outline */
knockout_entries[knockout_entry_cur].data.rectangle.x0 = x0;
knockout_entries[knockout_entry_cur].data.rectangle.y0 = y0;
knockout_entries[knockout_entry_cur].data.rectangle.x1 = x1;
knockout_entries[knockout_entry_cur].data.rectangle.y1 = y1;
knockout_entries[knockout_entry_cur].data.fill.plot_style = *pstyle;
+ knockout_entries[knockout_entry_cur].data.fill.plot_style.fill_type = PLOT_OP_TYPE_NONE; /* ensure we only plot the outline */
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_RECTANGLE;
if (++knockout_entry_cur >= KNOCKOUT_ENTRIES)
knockout_plot_flush();
@@ -706,17 +662,13 @@ bool knockout_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t
return true;
}
-bool knockout_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool knockout_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle)
{
knockout_entries[knockout_entry_cur].data.line.x0 = x0;
knockout_entries[knockout_entry_cur].data.line.y0 = y0;
knockout_entries[knockout_entry_cur].data.line.x1 = x1;
knockout_entries[knockout_entry_cur].data.line.y1 = y1;
- knockout_entries[knockout_entry_cur].data.line.width = width;
- knockout_entries[knockout_entry_cur].data.line.c = c;
- knockout_entries[knockout_entry_cur].data.line.dotted = dotted;
- knockout_entries[knockout_entry_cur].data.line.dashed = dashed;
+ knockout_entries[knockout_entry_cur].data.line.plot_style = *pstyle;
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_LINE;
if (++knockout_entry_cur >= KNOCKOUT_ENTRIES)
knockout_plot_flush();
diff --git a/desktop/plot_style.c b/desktop/plot_style.c
new file mode 100644
index 000000000..8ed8fb5e6
--- /dev/null
+++ b/desktop/plot_style.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2009 Vincent Sanders <vince@kyllikki.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file Plotter global styles.
+ *
+ * These plot styles are globaly available and used in many places.
+ */
+
+#include "desktop/plotters.h"
+
+static plot_style_t plot_style_fill_white_static = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = 0xffffff,
+};
+plot_style_t *plot_style_fill_white = &plot_style_fill_white_static;
+
+static plot_style_t plot_style_fill_black_static = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = 0x0,
+};
+plot_style_t *plot_style_fill_black = &plot_style_fill_black_static;
+
+static plot_style_t plot_style_fill_red_static = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = 0x000000ff,
+};
+plot_style_t *plot_style_fill_red = &plot_style_fill_red_static;
+
+static plot_style_t plot_style_stroke_red_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = 0x000000ff,
+ .stroke_width = 1,
+};
+plot_style_t *plot_style_stroke_red = &plot_style_stroke_red_static;
+
+static plot_style_t plot_style_stroke_blue_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = 0x00ff0000,
+ .stroke_width = 1,
+};
+plot_style_t *plot_style_stroke_blue = &plot_style_stroke_blue_static;
+
+static plot_style_t plot_style_stroke_yellow_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = 0x0000ffff,
+ .stroke_width = 1,
+};
+plot_style_t *plot_style_stroke_yellow = &plot_style_stroke_yellow_static;
+
+/* caret style used in html_redraw_caret */
+static plot_style_t plot_style_caret_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = 0x808080, /* todo - choose a proper colour */
+};
+plot_style_t *plot_style_caret = &plot_style_caret_static;
+
+
+
+/* html redraw widget styles */
+
+/** plot style for widget base. */
+static plot_style_t plot_style_fill_wbasec_static = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = WIDGET_BASEC,
+};
+plot_style_t *plot_style_fill_wbasec = &plot_style_fill_wbasec_static;
+
+
+/** plot style for widget background. */
+static plot_style_t plot_style_fill_wblobc_static = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = WIDGET_BLOBC,
+};
+plot_style_t *plot_style_fill_wblobc = &plot_style_fill_wblobc_static;
+
+/** plot style for checkbox cross. */
+static plot_style_t plot_style_stroke_wblobc_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = WIDGET_BLOBC,
+ .stroke_width = 2,
+};
+plot_style_t *plot_style_stroke_wblobc = &plot_style_stroke_wblobc_static;
+
+/** stroke style for widget double dark colour. */
+static plot_style_t plot_style_stroke_darkwbasec_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = double_darken_colour(WIDGET_BASEC),
+};
+plot_style_t *plot_style_stroke_darkwbasec = &plot_style_stroke_darkwbasec_static;
+
+/** stroke style for widget double light colour. */
+static plot_style_t plot_style_stroke_lightwbasec_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = double_lighten_colour(WIDGET_BASEC),
+};
+plot_style_t *plot_style_stroke_lightwbasec = &plot_style_stroke_lightwbasec_static;
+
+/* history styles */
+
+/** stroke style for history core. */
+static plot_style_t plot_style_stroke_history_static = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = 0x333333,
+};
+plot_style_t *plot_style_stroke_history = &plot_style_stroke_history_static;
+
diff --git a/desktop/plot_style.h b/desktop/plot_style.h
new file mode 100644
index 000000000..03bb69f91
--- /dev/null
+++ b/desktop/plot_style.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Ploter styles.
+ */
+
+#ifndef _NETSURF_DESKTOP_PLOT_STYLE_H_
+#define _NETSURF_DESKTOP_PLOT_STYLE_H_
+
+/* html widget colours */
+#define WIDGET_BASEC 0xd9d9d9
+#define WIDGET_BLOBC 0x000000
+
+/* Darken a colour by taking three quaters of each channels intensity */
+#define darken_colour(c1) \
+ ((((3 * (c1 >> 16)) >> 2) << 16) | \
+ (((3 * ((c1 >> 8) & 0xff)) >> 2) << 8) | \
+ (((3 * (c1 & 0xff)) >> 2) << 0))
+
+/* Darken a colour by taking nine sixteenths of each channels intensity */
+#define double_darken_colour(c1) \
+ ((((9 * (c1 >> 16)) >> 4) << 16) | \
+ (((9 * ((c1 >> 8) & 0xff)) >> 4) << 8) | \
+ (((9 * (c1 & 0xff)) >> 4) << 0))
+
+/* Lighten a colour by taking three quaters of each channels intensity
+ * and adding a full quater
+ */
+#define lighten_colour(c1) \
+ (((((3 * (c1 >> 16)) >> 2) + 64) << 16) | \
+ ((((3 * ((c1 >> 8) & 0xff)) >> 2) + 64) << 8) | \
+ ((((3 * (c1 & 0xff)) >> 2) + 64) << 0))
+
+/* Lighten a colour by taking nine sixteenths of each channels intensity and adding a full intensity 7/16ths */
+#define double_lighten_colour(c1) \
+ (((((9 * (c1 >> 16)) >> 4) + 112) << 16) | \
+ ((((9 * ((c1 >> 8) & 0xff)) >> 4) + 112) << 8) | \
+ ((((9 * (c1 & 0xff)) >> 4) + 112) << 0))
+
+typedef enum {
+ PLOT_OP_TYPE_NONE = 0, /**< No operation */
+ PLOT_OP_TYPE_SOLID, /**< Solid colour */
+ PLOT_OP_TYPE_DOT, /**< Doted plot */
+ PLOT_OP_TYPE_DASH, /**< dashed plot */
+} plot_operation_type_t;
+
+typedef struct {
+ plot_operation_type_t stroke_type;
+ int stroke_width;
+ colour stroke_colour;
+ plot_operation_type_t fill_type;
+ colour fill_colour;
+} plot_style_t;
+
+/* global fill styles */
+extern plot_style_t *plot_style_fill_white;
+extern plot_style_t *plot_style_fill_red;
+extern plot_style_t *plot_style_fill_black;
+
+/* global stroke styles */
+extern plot_style_t *plot_style_stroke_red;
+extern plot_style_t *plot_style_stroke_blue;
+extern plot_style_t *plot_style_stroke_yellow;
+
+/* other styles */
+extern plot_style_t *plot_style_caret;
+extern plot_style_t *plot_style_stroke_history;
+extern plot_style_t *plot_style_fill_wbasec;
+extern plot_style_t *plot_style_fill_wblobc;
+extern plot_style_t *plot_style_stroke_wblobc;
+extern plot_style_t *plot_style_stroke_darkwbasec;
+extern plot_style_t *plot_style_stroke_lightwbasec;
+
+#endif
diff --git a/desktop/plotters.h b/desktop/plotters.h
index 3f317b1af..4a6261516 100644
--- a/desktop/plotters.h
+++ b/desktop/plotters.h
@@ -26,7 +26,7 @@
#include <stdbool.h>
#include "css/css.h"
#include "content/content.h"
-
+#include "desktop/plot_style.h"
struct bitmap;
@@ -35,29 +35,6 @@ typedef unsigned long bitmap_flags_t;
#define BITMAPF_REPEAT_X 1
#define BITMAPF_REPEAT_Y 2
-typedef enum {
- PLOT_OP_TYPE_NONE = 0, /**< No operation */
- PLOT_OP_TYPE_SOLID, /**< Solid colour */
- PLOT_OP_TYPE_DOT, /**< Doted plot */
- PLOT_OP_TYPE_DASH, /**< dashed plot */
-} plot_operation_type_t;
-
-
-typedef struct {
- plot_operation_type_t stroke_type;
- int stroke_width;
- colour stroke_colour;
- plot_operation_type_t fill_type;
- colour fill_colour;
-} plot_style_t;
-
-/* global styles */
-extern plot_style_t *plot_style_fill_white;
-extern plot_style_t *plot_style_fill_red;
-extern plot_style_t *plot_style_fill_black;
-extern plot_style_t *plot_style_stroke_red;
-extern plot_style_t *plot_style_stroke_blue;
-extern plot_style_t *plot_style_stroke_yellow;
/** Set of target specific plotting functions.
*
@@ -118,9 +95,8 @@ extern plot_style_t *plot_style_stroke_yellow;
* 3 | | | | | |
*/
struct plotter_table {
- bool (*rectangle)(int x0, int y0, int x1, int y1, const plot_style_t *style);
- bool (*line)(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+ bool (*rectangle)(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
+ bool (*line)(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
bool (*polygon)(const int *p, unsigned int n, colour fill);
bool (*clip)(int x0, int y0, int x1, int y1);
bool (*text)(int x, int y, const struct css_style *style,
diff --git a/desktop/save_pdf/pdf_plotters.c b/desktop/save_pdf/pdf_plotters.c
index 468c19ed1..58df607d6 100644
--- a/desktop/save_pdf/pdf_plotters.c
+++ b/desktop/save_pdf/pdf_plotters.c
@@ -46,8 +46,7 @@
/* #define PDF_DEBUG_DUMPGRID */
static bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool pdf_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+static bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
static bool pdf_plot_polygon(const int *p, unsigned int n, colour fill);
static bool pdf_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
@@ -200,16 +199,30 @@ bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *psty
return true;
}
-bool pdf_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle)
{
-#ifdef PDF_DEBUG
- LOG(("."));
-#endif
+ DashPattern_e dash;
+
+ switch (pstyle->stroke_type) {
+ case PLOT_OP_TYPE_DOT:
+ dash = DashPattern_eDotted;
+ break;
+
+ case PLOT_OP_TYPE_DASH:
+ dash = DashPattern_eDash;
+ break;
+
+ default:
+ dash = DashPattern_eNone;
+ break;
+
+ }
- apply_clip_and_mode(false, TRANSPARENT, c, width,
- (dotted) ? DashPattern_eDotted :
- ((dashed) ? DashPattern_eDash : DashPattern_eNone));
+ apply_clip_and_mode(false,
+ TRANSPARENT,
+ pstyle->stroke_colour,
+ pstyle->stroke_width,
+ dash);
HPDF_Page_MoveTo(pdf_page, x0, page_height - y0);
HPDF_Page_LineTo(pdf_page, x1, page_height - y1);
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 520b53090..4e08ff549 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -52,6 +52,12 @@ static plot_style_t pstyle_stroke_border = {
.stroke_width = 1,
};
+static plot_style_t pstyle_stroke_caret = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = CARET_COLOR,
+ .stroke_width = 1,
+};
+
struct line_info {
unsigned int b_start; /**< Byte offset of line start */
unsigned int b_length; /**< Byte length of line */
@@ -526,7 +532,7 @@ bool textarea_set_caret(struct text_area *ta, int caret)
y1 = min(y + height + 1, ta->y + ta->vis_height);
plot.clip(x0, y0, x1, y1);
- plot.line(x, y, x, y + height, 1, CARET_COLOR, false, false);
+ plot.line(x, y, x, y + height, &pstyle_stroke_caret);
}
ta->redraw_end_callback(ta->data);