2003-09-09 02:46:20 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
2004-06-11 02:11:44 +04:00
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
2003-09-09 02:46:20 +04:00
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
2004-02-25 18:12:58 +03:00
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
2003-09-09 02:46:20 +04:00
|
|
|
*/
|
|
|
|
|
2004-08-01 17:08:19 +04:00
|
|
|
/** \file
|
|
|
|
* Redraw of a CONTENT_HTML (RISC OS implementation).
|
|
|
|
*/
|
|
|
|
|
2003-09-09 02:46:20 +04:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
2004-07-01 02:09:20 +04:00
|
|
|
#include "swis.h"
|
2003-09-09 02:46:20 +04:00
|
|
|
#include "oslib/colourtrans.h"
|
2004-03-22 03:36:53 +03:00
|
|
|
#include "oslib/draw.h"
|
2003-09-09 02:46:20 +04:00
|
|
|
#include "oslib/font.h"
|
2004-06-10 21:21:58 +04:00
|
|
|
#include "oslib/os.h"
|
2004-06-26 03:10:46 +04:00
|
|
|
#include "oslib/wimp.h"
|
2004-06-09 23:55:06 +04:00
|
|
|
#include "netsurf/utils/config.h"
|
2003-09-09 02:46:20 +04:00
|
|
|
#include "netsurf/content/content.h"
|
2004-08-01 17:08:19 +04:00
|
|
|
#include "netsurf/css/css.h"
|
2004-08-11 23:02:32 +04:00
|
|
|
#include "netsurf/render/box.h"
|
|
|
|
#include "netsurf/render/font.h"
|
2003-10-25 04:35:49 +04:00
|
|
|
#include "netsurf/render/form.h"
|
2003-09-09 02:46:20 +04:00
|
|
|
#include "netsurf/render/html.h"
|
|
|
|
#include "netsurf/riscos/gui.h"
|
2004-06-09 23:55:06 +04:00
|
|
|
#include "netsurf/riscos/options.h"
|
|
|
|
#include "netsurf/riscos/tinct.h"
|
2004-06-26 03:10:46 +04:00
|
|
|
#include "netsurf/riscos/toolbar.h"
|
2004-08-01 17:08:19 +04:00
|
|
|
#include "netsurf/riscos/ufont.h"
|
2004-06-11 02:11:44 +04:00
|
|
|
#include "netsurf/riscos/wimp.h"
|
2003-09-09 02:46:20 +04:00
|
|
|
#include "netsurf/utils/log.h"
|
2004-05-04 02:05:40 +04:00
|
|
|
#include "netsurf/utils/messages.h"
|
2003-10-18 03:47:13 +04:00
|
|
|
#include "netsurf/utils/utils.h"
|
2003-09-09 02:46:20 +04:00
|
|
|
|
2003-09-20 03:36:17 +04:00
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
static bool html_redraw_box(struct box *box,
|
2004-08-01 17:08:19 +04:00
|
|
|
int x, int y,
|
2003-09-09 02:46:20 +04:00
|
|
|
unsigned long current_background_color,
|
2004-08-01 17:08:19 +04:00
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
2004-02-25 18:12:58 +03:00
|
|
|
float scale);
|
2004-08-11 20:26:13 +04:00
|
|
|
static bool html_redraw_clip(int clip_x0, int clip_y0,
|
2004-08-01 17:08:19 +04:00
|
|
|
int clip_x1, int clip_y1);
|
2004-08-11 20:26:13 +04:00
|
|
|
static bool html_redraw_rectangle(int x0, int y0, int width, int height,
|
2004-02-02 03:22:59 +03:00
|
|
|
os_colour colour);
|
2004-08-11 20:26:13 +04:00
|
|
|
static bool html_redraw_fill(int x0, int y0, int width, int height,
|
2004-04-22 01:36:06 +04:00
|
|
|
os_colour colour);
|
2004-08-11 20:26:13 +04:00
|
|
|
static bool html_redraw_circle(int x0, int y0, int radius,
|
2004-04-22 01:36:06 +04:00
|
|
|
os_colour colour);
|
2004-08-11 20:26:13 +04:00
|
|
|
static bool html_redraw_border(colour color, int width, css_border_style style,
|
2004-03-22 03:36:53 +03:00
|
|
|
int x0, int y0, int x1, int y1);
|
2004-08-11 20:26:13 +04:00
|
|
|
static bool html_redraw_checkbox(int x, int y, int width, int height,
|
2004-04-22 01:36:06 +04:00
|
|
|
bool selected);
|
2004-08-11 20:26:13 +04:00
|
|
|
static bool html_redraw_radio(int x, int y, int width, int height,
|
2004-04-22 01:36:06 +04:00
|
|
|
bool selected);
|
2004-08-11 20:26:13 +04:00
|
|
|
static bool html_redraw_file(int x, int y, int width, int height,
|
2004-05-04 02:05:40 +04:00
|
|
|
struct box *box, float scale);
|
2004-08-11 20:26:13 +04:00
|
|
|
static bool html_redraw_background(int x, int y, int width, int height,
|
2004-06-11 02:11:44 +04:00
|
|
|
struct box *box, float scale);
|
2004-02-02 03:22:59 +03:00
|
|
|
|
|
|
|
bool gui_redraw_debug = false;
|
2004-08-07 03:45:21 +04:00
|
|
|
static int ro_gui_redraw_box_depth;
|
2003-09-20 03:36:17 +04:00
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
static os_trfm trfm = { {
|
|
|
|
{ 65536, 0 },
|
|
|
|
{ 0, 65536 },
|
|
|
|
{ 0, 0 } } };
|
|
|
|
|
2003-09-09 02:46:20 +04:00
|
|
|
|
2004-08-01 17:08:19 +04:00
|
|
|
/**
|
|
|
|
* Draw a CONTENT_HTML to a RISC OS window.
|
|
|
|
*
|
|
|
|
* \param c content of type CONTENT_HTML
|
|
|
|
* \param x coordinate for top-left of redraw
|
|
|
|
* \param y coordinate for top-left of redraw
|
|
|
|
* \param width available width (not used for HTML redraw)
|
|
|
|
* \param height available height (not used for HTML redraw)
|
|
|
|
* \param clip_x0 clip rectangle
|
|
|
|
* \param clip_y0 clip rectangle
|
|
|
|
* \param clip_x1 clip rectangle
|
|
|
|
* \param clip_y1 clip rectangle
|
|
|
|
* \param scale scale for redraw
|
2004-08-11 20:26:13 +04:00
|
|
|
* \return true if successful, false otherwise
|
2004-08-01 17:08:19 +04:00
|
|
|
*
|
|
|
|
* x, y, clip_[xy][01] are in RISC OS screen absolute OS-units.
|
|
|
|
*/
|
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
bool html_redraw(struct content *c, int x, int y,
|
2004-06-11 00:41:26 +04:00
|
|
|
int width, int height,
|
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
2004-02-25 18:12:58 +03:00
|
|
|
float scale)
|
2003-09-09 02:46:20 +04:00
|
|
|
{
|
|
|
|
unsigned long background_colour = 0xffffff;
|
|
|
|
struct box *box;
|
2004-08-11 20:26:13 +04:00
|
|
|
os_error *error;
|
2003-09-09 02:46:20 +04:00
|
|
|
|
|
|
|
assert(c->data.html.layout != NULL);
|
|
|
|
box = c->data.html.layout->children;
|
|
|
|
assert(box);
|
|
|
|
|
|
|
|
/* clear to background colour */
|
2004-04-22 01:36:06 +04:00
|
|
|
if (c->data.html.background_colour != TRANSPARENT)
|
2003-09-09 02:46:20 +04:00
|
|
|
background_colour = c->data.html.background_colour;
|
2004-08-11 20:26:13 +04:00
|
|
|
error = xcolourtrans_set_gcol(background_colour << 8,
|
2004-04-22 01:36:06 +04:00
|
|
|
colourtrans_SET_BG | colourtrans_USE_ECFS,
|
2004-08-11 20:26:13 +04:00
|
|
|
os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_clg();
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_clg: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
}
|
2003-09-09 02:46:20 +04:00
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
trfm.entries[0][0] = trfm.entries[1][1] = 65536 * scale;
|
|
|
|
|
2004-08-07 03:45:21 +04:00
|
|
|
ro_gui_redraw_box_depth = 0;
|
2004-08-11 20:26:13 +04:00
|
|
|
return html_redraw_box(box, x, y, background_colour,
|
2004-08-01 17:08:19 +04:00
|
|
|
clip_x0, clip_y0, clip_x1, clip_y1, scale);
|
2003-09-09 02:46:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-01 17:08:19 +04:00
|
|
|
/**
|
|
|
|
* Recursively draw a box to a RISC OS window.
|
|
|
|
*
|
|
|
|
* \param box box to draw
|
|
|
|
* \param x coordinate of parent box
|
|
|
|
* \param y coordinate of parent box
|
|
|
|
* \param current_background_color background colour under this box
|
|
|
|
* \param clip_x0 clip rectangle
|
|
|
|
* \param clip_y0 clip rectangle
|
|
|
|
* \param clip_x1 clip rectangle
|
|
|
|
* \param clip_y1 clip rectangle
|
|
|
|
* \param scale scale for redraw
|
2004-08-11 20:26:13 +04:00
|
|
|
* \return true if successful, false otherwise
|
2004-08-01 17:08:19 +04:00
|
|
|
*
|
|
|
|
* x, y, clip_[xy][01] are in RISC OS screen absolute OS-units.
|
|
|
|
*/
|
2003-09-09 02:46:20 +04:00
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
bool html_redraw_box(struct box *box,
|
2004-08-01 17:08:19 +04:00
|
|
|
int x, int y,
|
2003-09-09 02:46:20 +04:00
|
|
|
unsigned long current_background_color,
|
2004-08-01 17:08:19 +04:00
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
2004-02-25 18:12:58 +03:00
|
|
|
float scale)
|
2003-09-09 02:46:20 +04:00
|
|
|
{
|
2003-09-10 01:43:44 +04:00
|
|
|
struct box *c;
|
2004-04-22 01:36:06 +04:00
|
|
|
int width, height;
|
2004-08-01 17:08:19 +04:00
|
|
|
int padding_left, padding_top, padding_width, padding_height;
|
2004-04-22 01:36:06 +04:00
|
|
|
int x0, y0, x1, y1;
|
|
|
|
int colour;
|
2004-08-11 20:26:13 +04:00
|
|
|
os_error *error;
|
2003-09-23 01:46:07 +04:00
|
|
|
|
2004-08-07 03:45:21 +04:00
|
|
|
ro_gui_redraw_box_depth++;
|
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
x += box->x * 2 * scale;
|
|
|
|
y -= box->y * 2 * scale;
|
2004-04-22 01:36:06 +04:00
|
|
|
width = box->width * 2 * scale;
|
|
|
|
height = box->height * 2 * scale;
|
|
|
|
padding_left = box->padding[LEFT] * 2 * scale;
|
|
|
|
padding_top = box->padding[TOP] * 2 * scale;
|
|
|
|
padding_width = (box->padding[LEFT] + box->width +
|
|
|
|
box->padding[RIGHT]) * 2 * scale;
|
|
|
|
padding_height = (box->padding[TOP] + box->height +
|
|
|
|
box->padding[BOTTOM]) * 2 * scale;
|
2003-09-23 01:46:07 +04:00
|
|
|
|
2004-08-01 17:08:19 +04:00
|
|
|
/* calculate clip rectangle for this box */
|
|
|
|
if (box->style && box->style->overflow != CSS_OVERFLOW_VISIBLE) {
|
|
|
|
x0 = x;
|
|
|
|
y0 = y - padding_height;
|
|
|
|
x1 = x + padding_width - 1;
|
|
|
|
y1 = y - 1;
|
|
|
|
} else {
|
|
|
|
x0 = x + box->descendant_x0 * 2 * scale;
|
|
|
|
y0 = y - box->descendant_y1 * 2 * scale;
|
|
|
|
x1 = x + box->descendant_x1 * 2 * scale + 1;
|
|
|
|
y1 = y - box->descendant_y0 * 2 * scale + 1;
|
|
|
|
}
|
2003-09-23 01:46:07 +04:00
|
|
|
|
2004-02-02 03:22:59 +03:00
|
|
|
/* if visibility is hidden render children only */
|
2004-05-30 01:01:36 +04:00
|
|
|
if (box->style && box->style->visibility == CSS_VISIBILITY_HIDDEN) {
|
2004-02-02 03:22:59 +03:00
|
|
|
for (c = box->children; c; c = c->next)
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_box(c, x, y,
|
|
|
|
current_background_color,
|
|
|
|
x0, y0, x1, y1, scale))
|
|
|
|
return false;
|
|
|
|
return true;
|
2004-02-02 03:22:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gui_redraw_debug) {
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_rectangle(x, y, padding_width,
|
|
|
|
padding_height, os_COLOUR_MAGENTA))
|
|
|
|
return false;
|
|
|
|
if (html_redraw_rectangle(x + padding_left, y - padding_top,
|
|
|
|
width, height, os_COLOUR_CYAN))
|
|
|
|
return false;
|
|
|
|
if (!html_redraw_rectangle(x - (box->border[LEFT] +
|
2004-04-22 01:36:06 +04:00
|
|
|
box->margin[LEFT]) * 2 * scale,
|
|
|
|
y + (box->border[TOP] + box->margin[TOP]) *
|
|
|
|
2 * scale,
|
|
|
|
padding_width + (box->border[LEFT] +
|
|
|
|
box->margin[LEFT] + box->border[RIGHT] +
|
|
|
|
box->margin[RIGHT]) * 2 * scale,
|
|
|
|
padding_height + (box->border[TOP] +
|
|
|
|
box->margin[TOP] + box->border[BOTTOM] +
|
|
|
|
box->margin[BOTTOM]) * 2 * scale,
|
2004-08-11 20:26:13 +04:00
|
|
|
os_COLOUR_YELLOW))
|
|
|
|
return false;
|
2004-02-02 03:22:59 +03:00
|
|
|
}
|
2003-10-10 22:13:36 +04:00
|
|
|
|
2004-03-22 03:36:53 +03:00
|
|
|
/* borders */
|
|
|
|
if (box->style && box->border[TOP])
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_border(box->style->border[TOP].color,
|
2004-03-24 01:14:56 +03:00
|
|
|
box->border[TOP] * 2 * scale,
|
2004-03-22 03:36:53 +03:00
|
|
|
box->style->border[TOP].style,
|
2004-03-24 01:14:56 +03:00
|
|
|
x - box->border[LEFT] * 2 * scale,
|
|
|
|
y + box->border[TOP] * scale,
|
2004-04-22 01:36:06 +04:00
|
|
|
x + padding_width + box->border[RIGHT] *
|
|
|
|
2 * scale,
|
2004-08-11 20:26:13 +04:00
|
|
|
y + box->border[TOP] * scale))
|
|
|
|
return false;
|
2004-03-22 03:36:53 +03:00
|
|
|
if (box->style && box->border[RIGHT])
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_border(box->style->border[RIGHT].color,
|
2004-03-24 01:14:56 +03:00
|
|
|
box->border[RIGHT] * 2 * scale,
|
2004-03-22 03:36:53 +03:00
|
|
|
box->style->border[RIGHT].style,
|
2004-04-22 01:36:06 +04:00
|
|
|
x + padding_width + box->border[RIGHT] * scale,
|
2004-03-24 01:14:56 +03:00
|
|
|
y + box->border[TOP] * 2 * scale,
|
2004-04-22 01:36:06 +04:00
|
|
|
x + padding_width + box->border[RIGHT] * scale,
|
|
|
|
y - padding_height - box->border[BOTTOM] *
|
2004-08-11 20:26:13 +04:00
|
|
|
2 * scale))
|
|
|
|
return false;
|
2004-03-22 03:36:53 +03:00
|
|
|
if (box->style && box->border[BOTTOM])
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_border(box->style->border[BOTTOM].color,
|
2004-03-24 01:14:56 +03:00
|
|
|
box->border[BOTTOM] * 2 * scale,
|
2004-03-22 03:36:53 +03:00
|
|
|
box->style->border[BOTTOM].style,
|
2004-03-24 01:14:56 +03:00
|
|
|
x - box->border[LEFT] * 2 * scale,
|
2004-04-22 01:36:06 +04:00
|
|
|
y - padding_height - box->border[BOTTOM] *
|
|
|
|
scale,
|
|
|
|
x + padding_width + box->border[RIGHT] *
|
|
|
|
2 * scale,
|
|
|
|
y - padding_height - box->border[BOTTOM] *
|
2004-08-11 20:26:13 +04:00
|
|
|
scale))
|
|
|
|
return false;
|
2004-03-22 03:36:53 +03:00
|
|
|
if (box->style && box->border[LEFT])
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_border(box->style->border[LEFT].color,
|
2004-03-24 01:14:56 +03:00
|
|
|
box->border[LEFT] * 2 * scale,
|
2004-03-22 03:36:53 +03:00
|
|
|
box->style->border[LEFT].style,
|
2004-03-24 01:14:56 +03:00
|
|
|
x - box->border[LEFT] * scale,
|
|
|
|
y + box->border[TOP] * 2 * scale,
|
|
|
|
x - box->border[LEFT] * scale,
|
2004-04-22 01:36:06 +04:00
|
|
|
y - padding_height - box->border[BOTTOM] *
|
2004-08-11 20:26:13 +04:00
|
|
|
2 * scale))
|
|
|
|
return false;
|
2004-03-22 03:36:53 +03:00
|
|
|
|
2004-08-01 17:08:19 +04:00
|
|
|
/* return if the box is completely outside the clip rectangle */
|
2004-08-09 10:25:10 +04:00
|
|
|
if ((ro_gui_redraw_box_depth > 2) &&
|
2004-08-07 03:45:21 +04:00
|
|
|
(clip_y1 < y0 || y1 < clip_y0 || clip_x1 < x0 || x1 < clip_x0))
|
2004-08-11 20:26:13 +04:00
|
|
|
return true;
|
2003-09-10 01:43:44 +04:00
|
|
|
|
2004-08-09 10:25:10 +04:00
|
|
|
if ((ro_gui_redraw_box_depth > 2) &&
|
2004-08-07 03:45:21 +04:00
|
|
|
(box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
|
|
|
|
box->type == BOX_TABLE_CELL || box->object)) {
|
2003-09-23 01:46:07 +04:00
|
|
|
/* find intersection of clip rectangle and box */
|
|
|
|
if (x0 < clip_x0) x0 = clip_x0;
|
|
|
|
if (y0 < clip_y0) y0 = clip_y0;
|
|
|
|
if (clip_x1 < x1) x1 = clip_x1;
|
|
|
|
if (clip_y1 < y1) y1 = clip_y1;
|
|
|
|
/* clip to it */
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_clip(x0, y0, x1, y1))
|
|
|
|
return false;
|
2003-09-23 01:46:07 +04:00
|
|
|
} else {
|
|
|
|
/* clip box unchanged */
|
|
|
|
x0 = clip_x0;
|
|
|
|
y0 = clip_y0;
|
|
|
|
x1 = clip_x1;
|
|
|
|
y1 = clip_y1;
|
|
|
|
}
|
|
|
|
|
2004-06-25 18:28:29 +04:00
|
|
|
/* background colour and image */
|
|
|
|
if (box->style && (box->type != BOX_INLINE ||
|
|
|
|
box->style != box->parent->parent->style)) {
|
|
|
|
/* find intersection of clip box and padding box */
|
|
|
|
int px0 = x < x0 ? x0 : x;
|
|
|
|
int py0 = y - padding_height < y0 ? y0 : y - padding_height;
|
|
|
|
int px1 = x + padding_width < x1 ? x + padding_width : x1;
|
|
|
|
int py1 = y < y1 ? y : y1;
|
2003-09-10 01:43:44 +04:00
|
|
|
|
2004-06-25 18:28:29 +04:00
|
|
|
/* background colour */
|
2004-06-25 20:52:01 +04:00
|
|
|
if (box->style->background_color != TRANSPARENT) {
|
2004-08-07 03:45:21 +04:00
|
|
|
if (ro_gui_redraw_box_depth > 2) {
|
|
|
|
|
|
|
|
/* optimisation removed - transparent images break */
|
2004-06-25 20:52:01 +04:00
|
|
|
/* optimisation: skip if fully repeated bg image */
|
2004-08-09 10:25:10 +04:00
|
|
|
if (!box->background ||
|
|
|
|
(ro_gui_current_redraw_gui &&
|
|
|
|
!ro_gui_current_redraw_gui->option.background_images)
|
|
|
|
/* || box->style->background_repeat !=
|
2004-08-07 03:45:21 +04:00
|
|
|
CSS_BACKGROUND_REPEAT_REPEAT*/) {
|
2004-06-25 20:52:01 +04:00
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
error = xcolourtrans_set_gcol(
|
2004-08-07 03:45:21 +04:00
|
|
|
box->style->background_color << 8,
|
|
|
|
colourtrans_USE_ECFS,
|
2004-08-11 20:26:13 +04:00
|
|
|
os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = xos_plot(os_MOVE_TO, px0, py0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (px0 < px1 && py0 < py1) {
|
|
|
|
error = xos_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
|
2004-08-07 03:45:21 +04:00
|
|
|
px1 - 1, py1 - 1);
|
2004-08-11 20:26:13 +04:00
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2004-08-07 03:45:21 +04:00
|
|
|
}
|
2004-06-25 20:52:01 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
/* set current background color for font painting */
|
2004-06-25 18:28:29 +04:00
|
|
|
current_background_color = box->style->background_color;
|
|
|
|
}
|
2004-06-09 23:55:06 +04:00
|
|
|
|
2004-06-25 18:28:29 +04:00
|
|
|
if (box->background) {
|
2004-08-07 03:45:21 +04:00
|
|
|
/* clip to padding box for everything but the main window */
|
|
|
|
if (ro_gui_redraw_box_depth > 2) {
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_clip(px0, py0, px1, py1))
|
|
|
|
return false;
|
2004-08-07 03:45:21 +04:00
|
|
|
} else {
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_clip(clip_x0, clip_y0, clip_x1, clip_y1))
|
|
|
|
return false;
|
2004-08-07 03:45:21 +04:00
|
|
|
}
|
2004-06-25 05:23:41 +04:00
|
|
|
|
2004-06-25 18:28:29 +04:00
|
|
|
/* plot background image */
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_background(x, y, width, clip_y1 - clip_y0,
|
|
|
|
box, scale))
|
|
|
|
return false;
|
2004-06-25 05:23:41 +04:00
|
|
|
|
2004-06-25 18:28:29 +04:00
|
|
|
/* restore previous graphics window */
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_clip(x0, y0, x1, y1))
|
|
|
|
return false;
|
2004-06-25 18:28:29 +04:00
|
|
|
}
|
|
|
|
}
|
2004-06-10 21:21:58 +04:00
|
|
|
|
2004-02-02 03:22:59 +03:00
|
|
|
if (box->object) {
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!content_redraw(box->object, x + padding_left, y - padding_top,
|
|
|
|
width, height, x0, y0, x1, y1, scale))
|
|
|
|
return false;
|
2004-04-22 01:36:06 +04:00
|
|
|
|
|
|
|
} else if (box->gadget && box->gadget->type == GADGET_CHECKBOX) {
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_checkbox(x + padding_left, y - padding_top,
|
2004-04-22 01:36:06 +04:00
|
|
|
width, height,
|
2004-08-11 20:26:13 +04:00
|
|
|
box->gadget->selected))
|
|
|
|
return false;
|
2004-04-22 01:36:06 +04:00
|
|
|
|
|
|
|
} else if (box->gadget && box->gadget->type == GADGET_RADIO) {
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_radio(x + padding_left, y - padding_top,
|
2004-04-22 01:36:06 +04:00
|
|
|
width, height,
|
2004-08-11 20:26:13 +04:00
|
|
|
box->gadget->selected))
|
|
|
|
return false;
|
2003-10-10 22:13:36 +04:00
|
|
|
|
2004-05-04 02:05:40 +04:00
|
|
|
} else if (box->gadget && box->gadget->type == GADGET_FILE) {
|
2004-08-11 20:26:13 +04:00
|
|
|
error = xcolourtrans_set_font_colours(box->font->handle,
|
2004-05-04 02:05:40 +04:00
|
|
|
current_background_color << 8,
|
|
|
|
box->style->color << 8, 14, 0, 0, 0);
|
2004-08-11 20:26:13 +04:00
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_font_colours: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!html_redraw_file(x + padding_left, y - padding_top,
|
|
|
|
width, height, box, scale))
|
|
|
|
return false;
|
2004-05-04 02:05:40 +04:00
|
|
|
|
2003-09-10 01:43:44 +04:00
|
|
|
} else if (box->text && box->font) {
|
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
error = xcolourtrans_set_font_colours(box->font->handle,
|
2004-04-22 01:36:06 +04:00
|
|
|
current_background_color << 8,
|
|
|
|
box->style->color << 8, 14, 0, 0, 0);
|
2004-08-11 20:26:13 +04:00
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_font_colours: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
2004-04-22 01:36:06 +04:00
|
|
|
|
|
|
|
/* antialias colour for under/overline */
|
2003-11-05 19:25:35 +03:00
|
|
|
colour = box->style->color;
|
|
|
|
colour = ((((colour >> 16) + (current_background_color >> 16)) / 2) << 16)
|
|
|
|
| (((((colour >> 8) & 0xff) +
|
|
|
|
((current_background_color >> 8) & 0xff)) / 2) << 8)
|
|
|
|
| ((((colour & 0xff) +
|
|
|
|
(current_background_color & 0xff)) / 2) << 0);
|
2004-08-11 20:26:13 +04:00
|
|
|
error = xcolourtrans_set_gcol((unsigned int)colour << 8, colourtrans_USE_ECFS,
|
|
|
|
os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
2003-10-19 21:17:26 +04:00
|
|
|
|
2004-02-01 01:40:03 +03:00
|
|
|
if (box->style->text_decoration & CSS_TEXT_DECORATION_UNDERLINE) {
|
2004-08-11 20:26:13 +04:00
|
|
|
error = xos_plot(os_MOVE_TO, x, y - (int) (box->height * 1.8 * scale));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
2003-10-18 03:47:13 +04:00
|
|
|
}
|
2004-02-01 01:40:03 +03:00
|
|
|
if (box->parent->parent->style->text_decoration & CSS_TEXT_DECORATION_UNDERLINE && box->parent->parent->type == BOX_BLOCK) {
|
2004-08-11 20:26:13 +04:00
|
|
|
error = xcolourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_MOVE_TO, x, y - (int) (box->height * 1.8 * scale));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xcolourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
2004-02-01 01:40:03 +03:00
|
|
|
}
|
|
|
|
if (box->style->text_decoration & CSS_TEXT_DECORATION_OVERLINE) {
|
2004-08-11 20:26:13 +04:00
|
|
|
error = xos_plot(os_MOVE_TO, x, y - (int) (box->height * 0.2 * scale));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
2003-10-18 03:47:13 +04:00
|
|
|
}
|
2004-02-01 01:40:03 +03:00
|
|
|
if (box->parent->parent->style->text_decoration & CSS_TEXT_DECORATION_OVERLINE && box->parent->parent->type == BOX_BLOCK) {
|
2004-08-11 20:26:13 +04:00
|
|
|
error = xcolourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_MOVE_TO, x, y - (int) (box->height * 0.2 * scale));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xcolourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
2004-02-01 01:40:03 +03:00
|
|
|
}
|
|
|
|
if (box->style->text_decoration & CSS_TEXT_DECORATION_LINE_THROUGH) {
|
2004-08-11 20:26:13 +04:00
|
|
|
error = xos_plot(os_MOVE_TO, x, y - (int) (box->height * 1.0 * scale));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
2003-10-18 03:47:13 +04:00
|
|
|
}
|
2004-02-01 01:40:03 +03:00
|
|
|
if (box->parent->parent->style->text_decoration & CSS_TEXT_DECORATION_LINE_THROUGH && box->parent->parent->type == BOX_BLOCK) {
|
2004-08-11 20:26:13 +04:00
|
|
|
error = xcolourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_MOVE_TO, x, y - (int) (box->height * 1.0 * scale));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xcolourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
2004-02-01 01:40:03 +03:00
|
|
|
}
|
2003-11-05 19:25:35 +03:00
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
if (scale == 1)
|
2004-07-06 00:19:52 +04:00
|
|
|
nsfont_paint(box->font, box->text,
|
2004-02-25 18:12:58 +03:00
|
|
|
x, y - (int) (box->height * 1.5),
|
2004-07-06 00:19:52 +04:00
|
|
|
NULL, (int) box->length);
|
2004-02-25 18:12:58 +03:00
|
|
|
else
|
2004-07-06 00:19:52 +04:00
|
|
|
nsfont_paint(box->font, box->text,
|
2004-02-25 18:12:58 +03:00
|
|
|
x, y - (int) (box->height * 1.5 * scale),
|
2004-07-06 00:19:52 +04:00
|
|
|
&trfm, (int) box->length);
|
2003-11-05 19:25:35 +03:00
|
|
|
|
|
|
|
|
2003-09-10 01:43:44 +04:00
|
|
|
} else {
|
|
|
|
for (c = box->children; c != 0; c = c->next)
|
|
|
|
if (c->type != BOX_FLOAT_LEFT && c->type != BOX_FLOAT_RIGHT)
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_box(c, x,
|
2003-09-23 01:46:07 +04:00
|
|
|
y, current_background_color,
|
2004-08-11 20:26:13 +04:00
|
|
|
x0, y0, x1, y1, scale))
|
|
|
|
return false;
|
2003-09-10 01:43:44 +04:00
|
|
|
|
|
|
|
for (c = box->float_children; c != 0; c = c->next_float)
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_box(c, x,
|
2003-09-23 01:46:07 +04:00
|
|
|
y, current_background_color,
|
2004-08-11 20:26:13 +04:00
|
|
|
x0, y0, x1, y1, scale))
|
|
|
|
return false;
|
2003-09-09 02:46:20 +04:00
|
|
|
}
|
|
|
|
|
2003-09-23 01:46:07 +04:00
|
|
|
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
|
|
|
|
box->type == BOX_TABLE_CELL || box->object)
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_clip(clip_x0, clip_y0, clip_x1, clip_y1))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2003-09-09 02:46:20 +04:00
|
|
|
}
|
|
|
|
|
2003-09-20 03:36:17 +04:00
|
|
|
|
2004-08-01 17:08:19 +04:00
|
|
|
/**
|
|
|
|
* Set the clip rectangle.
|
|
|
|
*/
|
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
bool html_redraw_clip(int clip_x0, int clip_y0,
|
2004-08-01 17:08:19 +04:00
|
|
|
int clip_x1, int clip_y1)
|
2003-09-20 03:36:17 +04:00
|
|
|
{
|
2004-08-11 20:26:13 +04:00
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
error = xos_set_graphics_window();
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_set_graphics_window: 0x%x: %s", error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_writec((char) (clip_x0 & 0xff));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_writec((char) (clip_x0 >> 8));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_writec((char) (clip_y0 & 0xff));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_writec((char) (clip_y0 >> 8));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_writec((char) (clip_x1 & 0xff));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_writec((char) (clip_x1 >> 8));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_writec((char) (clip_y1 & 0xff));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_writec((char) (clip_y1 >> 8));
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2003-09-20 03:36:17 +04:00
|
|
|
}
|
|
|
|
|
2004-02-02 03:22:59 +03:00
|
|
|
|
2004-04-22 01:36:06 +04:00
|
|
|
/**
|
|
|
|
* Plot a dotted rectangle outline.
|
|
|
|
*/
|
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
bool html_redraw_rectangle(int x0, int y0, int width, int height,
|
2004-02-02 03:22:59 +03:00
|
|
|
os_colour colour)
|
|
|
|
{
|
2004-08-11 20:26:13 +04:00
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
error = xcolourtrans_set_gcol(colour, 0, os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_MOVE_TO, x0, y0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_PLOT_DOTTED | os_PLOT_BY, width, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_PLOT_DOTTED | os_PLOT_BY, 0, -height);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_PLOT_DOTTED | os_PLOT_BY, -width, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_PLOT_DOTTED | os_PLOT_BY, 0, height);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2004-02-02 03:22:59 +03:00
|
|
|
}
|
2004-03-22 03:36:53 +03:00
|
|
|
|
|
|
|
|
2004-04-22 01:36:06 +04:00
|
|
|
/**
|
|
|
|
* Fill a rectangle of colour.
|
|
|
|
*/
|
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
bool html_redraw_fill(int x0, int y0, int width, int height,
|
2004-04-22 01:36:06 +04:00
|
|
|
os_colour colour)
|
|
|
|
{
|
2004-08-11 20:26:13 +04:00
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
error = xcolourtrans_set_gcol(colour, 0, os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_MOVE_TO, x0, y0 - height);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_PLOT_RECTANGLE | os_PLOT_BY, width - 1, height - 1);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2004-04-22 01:36:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill a circle of colour.
|
|
|
|
*/
|
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
bool html_redraw_circle(int x0, int y0, int radius,
|
2004-04-22 01:36:06 +04:00
|
|
|
os_colour colour)
|
|
|
|
{
|
2004-08-11 20:26:13 +04:00
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
error = xcolourtrans_set_gcol(colour, 0, os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_MOVE_TO, x0, y0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_plot(os_PLOT_CIRCLE | os_PLOT_BY, radius, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2004-04-22 01:36:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-22 03:36:53 +03:00
|
|
|
static int path[] = { draw_MOVE_TO, 0, 0, draw_LINE_TO, 0, 0,
|
|
|
|
draw_END_PATH, 0 };
|
|
|
|
static const draw_line_style line_style = { draw_JOIN_MITRED,
|
|
|
|
draw_CAP_BUTT, draw_CAP_BUTT, 0, 0x7fffffff,
|
|
|
|
0, 0, 0, 0 };
|
|
|
|
static const int dash_pattern_dotted[] = { 0, 1, 512 };
|
|
|
|
static const int dash_pattern_dashed[] = { 0, 1, 2048 };
|
|
|
|
|
2004-08-01 17:08:19 +04:00
|
|
|
/**
|
|
|
|
* Draw a border.
|
|
|
|
*/
|
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
bool html_redraw_border(colour color, int width, css_border_style style,
|
2004-03-22 03:36:53 +03:00
|
|
|
int x0, int y0, int x1, int y1)
|
|
|
|
{
|
2004-07-14 23:16:49 +04:00
|
|
|
const draw_dash_pattern *dash_pattern;
|
2004-03-22 03:36:53 +03:00
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
if (style == CSS_BORDER_STYLE_DOTTED)
|
2004-07-14 23:16:49 +04:00
|
|
|
dash_pattern = (const draw_dash_pattern *) &dash_pattern_dotted;
|
2004-03-22 03:36:53 +03:00
|
|
|
else if (style == CSS_BORDER_STYLE_DASHED)
|
2004-07-14 23:16:49 +04:00
|
|
|
dash_pattern = (const draw_dash_pattern *) &dash_pattern_dashed;
|
|
|
|
else
|
|
|
|
dash_pattern = NULL;
|
2004-03-22 03:36:53 +03:00
|
|
|
|
|
|
|
path[1] = x0 * 256;
|
|
|
|
path[2] = y0 * 256;
|
|
|
|
path[4] = x1 * 256;
|
|
|
|
path[5] = y1 * 256;
|
|
|
|
error = xcolourtrans_set_gcol(color << 8, 0, os_ACTION_OVERWRITE, 0, 0);
|
2004-08-11 20:26:13 +04:00
|
|
|
if (error) {
|
2004-03-22 03:36:53 +03:00
|
|
|
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
2004-08-11 20:26:13 +04:00
|
|
|
return false;
|
|
|
|
}
|
2004-03-22 03:36:53 +03:00
|
|
|
error = xdraw_stroke((draw_path *) path, 0, 0, 0, width * 256,
|
|
|
|
&line_style, dash_pattern);
|
2004-08-11 20:26:13 +04:00
|
|
|
if (error) {
|
2004-03-22 03:36:53 +03:00
|
|
|
LOG(("xdraw_stroke: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
2004-08-11 20:26:13 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2004-03-22 03:36:53 +03:00
|
|
|
}
|
2004-04-22 01:36:06 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot a checkbox.
|
|
|
|
*/
|
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
bool html_redraw_checkbox(int x, int y, int width, int height,
|
2004-04-22 01:36:06 +04:00
|
|
|
bool selected)
|
|
|
|
{
|
|
|
|
int z = width * 0.15;
|
|
|
|
if (z == 0)
|
|
|
|
z = 1;
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_fill(x, y, width, height, os_COLOUR_BLACK))
|
|
|
|
return false;
|
|
|
|
if (!html_redraw_fill(x + z, y - z, width - z - z, height - z - z,
|
|
|
|
os_COLOUR_WHITE))
|
|
|
|
return false;
|
2004-04-22 01:36:06 +04:00
|
|
|
if (selected)
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_fill(x + z + z, y - z - z,
|
2004-04-22 01:36:06 +04:00
|
|
|
width - z - z - z - z, height - z - z - z - z,
|
2004-08-11 20:26:13 +04:00
|
|
|
os_COLOUR_RED))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2004-04-22 01:36:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot a radio icon.
|
|
|
|
*/
|
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
bool html_redraw_radio(int x, int y, int width, int height,
|
2004-04-22 01:36:06 +04:00
|
|
|
bool selected)
|
|
|
|
{
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_circle(x + width * 0.5, y - height * 0.5,
|
|
|
|
width * 0.5 - 1, os_COLOUR_BLACK))
|
|
|
|
return false;
|
|
|
|
if (!html_redraw_circle(x + width * 0.5, y - height * 0.5,
|
|
|
|
width * 0.4 - 1, os_COLOUR_WHITE))
|
|
|
|
return false;
|
2004-04-22 01:36:06 +04:00
|
|
|
if (selected)
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!html_redraw_circle(x + width * 0.5, y - height * 0.5,
|
|
|
|
width * 0.3 - 1, os_COLOUR_RED))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2004-04-22 01:36:06 +04:00
|
|
|
}
|
2004-05-04 02:05:40 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot a file upload input.
|
|
|
|
*/
|
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
bool html_redraw_file(int x, int y, int width, int height,
|
2004-05-04 02:05:40 +04:00
|
|
|
struct box *box, float scale)
|
|
|
|
{
|
|
|
|
int text_width;
|
|
|
|
const char *text;
|
|
|
|
const char *sprite;
|
2004-07-06 00:19:52 +04:00
|
|
|
int length;
|
2004-05-04 02:05:40 +04:00
|
|
|
|
|
|
|
if (box->gadget->value) {
|
|
|
|
text = box->gadget->value;
|
|
|
|
sprite = "file_fff";
|
|
|
|
} else {
|
|
|
|
text = messages_get("Form_Drop");
|
|
|
|
sprite = "drophere";
|
|
|
|
}
|
2004-07-06 00:19:52 +04:00
|
|
|
length = strlen(text);
|
2004-05-04 02:05:40 +04:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
text_width = nsfont_width(box->font, text, length) * 2 * scale;
|
2004-05-04 02:05:40 +04:00
|
|
|
if (width < text_width + 8)
|
|
|
|
x = x + width - text_width - 4;
|
|
|
|
else
|
|
|
|
x = x + 4;
|
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
nsfont_paint(box->font, text,
|
|
|
|
x, y - height * 0.75, &trfm, length);
|
2004-05-04 02:05:40 +04:00
|
|
|
|
2004-06-11 02:11:44 +04:00
|
|
|
/* xwimpspriteop_put_sprite_user_coords(sprite, x + 4, */
|
|
|
|
/* y - height / 2 - 17, os_ACTION_OVERWRITE); */
|
2004-08-11 20:26:13 +04:00
|
|
|
|
|
|
|
return true;
|
2004-05-04 02:05:40 +04:00
|
|
|
}
|
2004-06-09 23:55:06 +04:00
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
bool html_redraw_background(int xi, int yi, int width, int height,
|
2004-06-11 02:11:44 +04:00
|
|
|
struct box *box, float scale)
|
2004-06-09 23:55:06 +04:00
|
|
|
{
|
2004-06-11 02:11:44 +04:00
|
|
|
unsigned int tinct_options = 0;
|
2004-08-01 17:08:19 +04:00
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
2004-06-11 02:11:44 +04:00
|
|
|
unsigned int image_width, image_height;
|
|
|
|
os_coord image_size;
|
|
|
|
float multiplier;
|
|
|
|
bool fixed = false;
|
2004-06-26 03:10:46 +04:00
|
|
|
wimp_window_state state;
|
2004-08-11 20:26:13 +04:00
|
|
|
os_error *error;
|
2004-06-11 02:11:44 +04:00
|
|
|
|
2004-08-11 20:26:13 +04:00
|
|
|
if (box->background == 0) return true;
|
2004-06-11 16:52:23 +04:00
|
|
|
|
2004-06-26 03:10:46 +04:00
|
|
|
state.w = 0;
|
|
|
|
|
2004-06-11 02:11:44 +04:00
|
|
|
if (ro_gui_current_redraw_gui) {
|
2004-08-07 03:45:21 +04:00
|
|
|
|
2004-06-26 03:10:46 +04:00
|
|
|
/* read state of window we're drawing in */
|
|
|
|
|
|
|
|
state.w = ro_gui_current_redraw_gui->window;
|
|
|
|
error = xwimp_get_window_state(&state);
|
|
|
|
if (error) {
|
|
|
|
/* not fatal: fixed backgrounds will scroll. */
|
|
|
|
LOG(("xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
/* invalidate state.w */
|
|
|
|
state.w = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the plot options */
|
2004-07-17 17:00:38 +04:00
|
|
|
if (!ro_gui_current_redraw_gui->option.background_images)
|
2004-08-11 20:26:13 +04:00
|
|
|
return true;
|
2004-07-17 17:00:38 +04:00
|
|
|
tinct_options = (ro_gui_current_redraw_gui->option.filter_sprites?tinct_BILINEAR_FILTER:0) |
|
|
|
|
(ro_gui_current_redraw_gui->option.dither_sprites?tinct_DITHER:0);
|
2004-06-09 23:55:06 +04:00
|
|
|
} else {
|
2004-08-11 20:26:13 +04:00
|
|
|
if (!option_background_images) return true;
|
2004-06-09 23:55:06 +04:00
|
|
|
tinct_options = (option_filter_sprites?tinct_BILINEAR_FILTER:0) |
|
|
|
|
(option_dither_sprites?tinct_DITHER:0);
|
|
|
|
}
|
|
|
|
|
2004-06-11 02:11:44 +04:00
|
|
|
/* Get the image dimensions for our positioning and scaling */
|
2004-06-24 02:53:50 +04:00
|
|
|
image_size.x = box->background->width * scale;
|
|
|
|
image_size.y = box->background->height * scale;
|
2004-06-11 02:11:44 +04:00
|
|
|
|
|
|
|
/* handle background-attachment */
|
2004-06-09 23:55:06 +04:00
|
|
|
switch (box->style->background_attachment) {
|
2004-06-11 02:11:44 +04:00
|
|
|
case CSS_BACKGROUND_ATTACHMENT_FIXED:
|
2004-06-26 03:10:46 +04:00
|
|
|
/* uncomment this to enable fixed backgrounds */
|
|
|
|
/*if (state.w != 0)
|
|
|
|
fixed = true;*/
|
2004-06-11 02:11:44 +04:00
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_ATTACHMENT_SCROLL:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-06-09 23:55:06 +04:00
|
|
|
}
|
|
|
|
|
2004-06-11 02:11:44 +04:00
|
|
|
/* handle background-repeat */
|
2004-06-09 23:55:06 +04:00
|
|
|
switch (box->style->background_repeat) {
|
2004-06-11 02:11:44 +04:00
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT:
|
|
|
|
tinct_options |= tinct_FILL_HORIZONTALLY | tinct_FILL_VERTICALLY;
|
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT_X:
|
|
|
|
tinct_options |= tinct_FILL_HORIZONTALLY;
|
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_REPEAT_REPEAT_Y:
|
|
|
|
tinct_options |= tinct_FILL_VERTICALLY;
|
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_REPEAT_NO_REPEAT:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-06-11 16:52:23 +04:00
|
|
|
|
2004-06-26 03:10:46 +04:00
|
|
|
/* fixed background */
|
2004-06-11 02:11:44 +04:00
|
|
|
if (fixed) {
|
2004-06-26 03:10:46 +04:00
|
|
|
int toolbar_height = 0;
|
|
|
|
|
|
|
|
/* get toolbar height */
|
|
|
|
if (ro_gui_current_redraw_gui &&
|
2004-07-17 17:00:38 +04:00
|
|
|
ro_gui_current_redraw_gui->toolbar)
|
|
|
|
toolbar_height = ro_gui_current_redraw_gui->
|
|
|
|
toolbar->height;
|
2004-06-26 03:10:46 +04:00
|
|
|
|
|
|
|
/* top left of viewport, taking account of toolbar height */
|
|
|
|
x = state.visible.x0;
|
|
|
|
y = state.visible.y1 - toolbar_height;
|
|
|
|
|
|
|
|
/* handle background-position */
|
|
|
|
switch (box->style->background_position.horz.pos) {
|
|
|
|
case CSS_BACKGROUND_POSITION_PERCENT:
|
|
|
|
multiplier = box->style->background_position.horz.value.percent / 100;
|
|
|
|
x += ((state.visible.x1 - state.visible.x0) - (image_size.x * 2)) * multiplier;
|
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_POSITION_LENGTH:
|
|
|
|
x += 2 * len(&box->style->background_position.horz.value.length, box->style) * scale;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-06-11 16:52:23 +04:00
|
|
|
|
2004-06-26 03:10:46 +04:00
|
|
|
switch (box->style->background_position.vert.pos) {
|
|
|
|
case CSS_BACKGROUND_POSITION_PERCENT:
|
|
|
|
multiplier = box->style->background_position.vert.value.percent / 100;
|
|
|
|
y -= ((state.visible.y1 - state.visible.y0 - toolbar_height) - (image_size.y * 2)) * multiplier;
|
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_POSITION_LENGTH:
|
|
|
|
y -= 2 * len(&box->style->background_position.vert.value.length, box->style) * scale;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-06-09 23:55:06 +04:00
|
|
|
}
|
2004-06-26 03:10:46 +04:00
|
|
|
else {
|
|
|
|
/* handle window offset */
|
|
|
|
x = xi;
|
|
|
|
y = yi;
|
|
|
|
|
|
|
|
/* handle background-position */
|
|
|
|
switch (box->style->background_position.horz.pos) {
|
|
|
|
case CSS_BACKGROUND_POSITION_PERCENT:
|
|
|
|
multiplier = box->style->background_position.horz.value.percent / 100;
|
|
|
|
x += 2 * (box->width + box->padding[LEFT] + box->padding[RIGHT] - image_size.x) * multiplier;
|
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_POSITION_LENGTH:
|
|
|
|
x += 2 * len(&box->style->background_position.horz.value.length, box->style) * scale;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-06-09 23:55:06 +04:00
|
|
|
|
2004-06-26 03:10:46 +04:00
|
|
|
switch (box->style->background_position.vert.pos) {
|
|
|
|
case CSS_BACKGROUND_POSITION_PERCENT:
|
|
|
|
multiplier = box->style->background_position.vert.value.percent / 100;
|
|
|
|
y -= 2 * (box->height + box->padding[TOP] + box->padding[BOTTOM] - image_size.y) * multiplier;
|
|
|
|
break;
|
|
|
|
case CSS_BACKGROUND_POSITION_LENGTH:
|
|
|
|
y -= 2 * len(&box->style->background_position.vert.value.length, box->style) * scale;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-06-09 23:55:06 +04:00
|
|
|
}
|
|
|
|
|
2004-06-11 02:11:44 +04:00
|
|
|
// LOG(("Body [%ld, %ld], Image: [%ld, %ld], Flags: %x", xi, yi, x, y, tinct_options));
|
2004-06-09 23:55:06 +04:00
|
|
|
|
2004-06-24 02:53:50 +04:00
|
|
|
/* convert our sizes into OS units */
|
|
|
|
// ro_convert_pixels_to_os_units(&image_size, (os_mode)-1);
|
|
|
|
image_width = image_size.x * 2;
|
|
|
|
image_height = image_size.y * 2;
|
|
|
|
|
2004-06-11 02:11:44 +04:00
|
|
|
/* and plot the image */
|
|
|
|
switch (box->background->type) {
|
2004-06-09 23:55:06 +04:00
|
|
|
#ifdef WITH_PNG
|
2004-06-11 02:11:44 +04:00
|
|
|
case CONTENT_PNG:
|
|
|
|
_swix(Tinct_PlotScaledAlpha, _IN(2) | _IN(3) | _IN(4) | _IN(5) | _IN(6) | _IN(7),
|
|
|
|
((char*) box->background->data.png.sprite_area + box->background->data.png.sprite_area->first),
|
2004-06-24 01:05:56 +04:00
|
|
|
x, y - image_height, image_width, image_height,
|
2004-06-11 02:11:44 +04:00
|
|
|
tinct_options);
|
|
|
|
break;
|
2004-06-09 23:55:06 +04:00
|
|
|
#endif
|
2004-07-16 23:47:03 +04:00
|
|
|
#ifdef WITH_PNG
|
|
|
|
case CONTENT_JNG:
|
|
|
|
case CONTENT_MNG:
|
|
|
|
_swix(Tinct_PlotScaledAlpha, _IN(2) | _IN(3) | _IN(4) | _IN(5) | _IN(6) | _IN(7),
|
|
|
|
((char*) box->background->data.mng.sprite_area + box->background->data.mng.sprite_area->first),
|
|
|
|
x, y - image_height, image_width, image_height,
|
|
|
|
tinct_options);
|
|
|
|
break;
|
|
|
|
#endif
|
2004-06-09 23:55:06 +04:00
|
|
|
#ifdef WITH_JPEG
|
2004-06-11 02:11:44 +04:00
|
|
|
case CONTENT_JPEG:
|
|
|
|
_swix(Tinct_PlotScaled, _IN(2) | _IN(3) | _IN(4) | _IN(5) | _IN(6) | _IN(7),
|
|
|
|
((char*) box->background->data.jpeg.sprite_area + box->background->data.jpeg.sprite_area->first),
|
2004-06-24 01:05:56 +04:00
|
|
|
x, y - image_height, image_width, image_height,
|
2004-06-11 02:11:44 +04:00
|
|
|
tinct_options);
|
|
|
|
break;
|
2004-06-09 23:55:06 +04:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_GIF
|
2004-06-11 02:11:44 +04:00
|
|
|
case CONTENT_GIF:
|
|
|
|
_swix(Tinct_PlotScaledAlpha, _IN(2) | _IN(3) | _IN(4) | _IN(5) | _IN(6) | _IN(7),
|
2004-08-11 20:26:13 +04:00
|
|
|
((char*) box->background->data.gif.gif->frame_image + box->background->data.gif.gif->frame_image->first),
|
2004-06-24 01:05:56 +04:00
|
|
|
x, y - image_height, image_width, image_height,
|
2004-06-11 02:11:44 +04:00
|
|
|
tinct_options);
|
|
|
|
break;
|
2004-06-09 23:55:06 +04:00
|
|
|
#endif
|
2004-06-11 02:11:44 +04:00
|
|
|
/**\todo Add draw/sprite background support? */
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-08-11 20:26:13 +04:00
|
|
|
|
|
|
|
return true;
|
2004-06-09 23:55:06 +04:00
|
|
|
}
|