summaryrefslogtreecommitdiff
path: root/frontends/beos
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/beos')
-rw-r--r--frontends/beos/bitmap.cpp7
-rw-r--r--frontends/beos/fetch_rsrc.cpp22
-rw-r--r--frontends/beos/filetype.cpp1
-rw-r--r--frontends/beos/font.cpp9
-rw-r--r--frontends/beos/gui.cpp39
-rw-r--r--frontends/beos/plotters.cpp1128
l---------frontends/beos/res/adblock.css2
l---------frontends/beos/res/ca-bundle.txt2
l---------frontends/beos/res/de/welcome.html2
l---------frontends/beos/res/default.css2
l---------frontends/beos/res/en/credits.html2
l---------frontends/beos/res/en/licence.html2
l---------frontends/beos/res/en/maps.html2
l---------frontends/beos/res/en/welcome.html2
l---------frontends/beos/res/icons2
l---------frontends/beos/res/internal.css2
l---------frontends/beos/res/it/credits.html2
l---------frontends/beos/res/it/licence.html2
l---------frontends/beos/res/it/welcome.html2
l---------frontends/beos/res/ja/welcome.html2
l---------frontends/beos/res/netsurf.png2
l---------frontends/beos/res/quirks.css2
-rw-r--r--frontends/beos/scaffolding.cpp20
-rw-r--r--frontends/beos/schedule.cpp27
-rw-r--r--frontends/beos/throbber.cpp18
-rw-r--r--frontends/beos/window.cpp179
26 files changed, 851 insertions, 631 deletions
diff --git a/frontends/beos/bitmap.cpp b/frontends/beos/bitmap.cpp
index 68d8442ab..c4b008755 100644
--- a/frontends/beos/bitmap.cpp
+++ b/frontends/beos/bitmap.cpp
@@ -377,7 +377,7 @@ nsbeos_bitmap_get_pretile_x(struct bitmap* bitmap)
if (!bitmap->pretile_x) {
int width = bitmap->primary->Bounds().Width() + 1;
int xmult = (MIN_PRETILE_WIDTH + width - 1)/width;
- LOG("Pretiling %p for X*%d", bitmap, xmult);
+ NSLOG(netsurf, INFO, "Pretiling %p for X*%d", bitmap, xmult);
bitmap->pretile_x = nsbeos_bitmap_generate_pretile(bitmap->primary, xmult, 1);
}
return bitmap->pretile_x;
@@ -396,7 +396,7 @@ nsbeos_bitmap_get_pretile_y(struct bitmap* bitmap)
if (!bitmap->pretile_y) {
int height = bitmap->primary->Bounds().Height() + 1;
int ymult = (MIN_PRETILE_HEIGHT + height - 1)/height;
- LOG("Pretiling %p for Y*%d", bitmap, ymult);
+ NSLOG(netsurf, INFO, "Pretiling %p for Y*%d", bitmap, ymult);
bitmap->pretile_y = nsbeos_bitmap_generate_pretile(bitmap->primary, 1, ymult);
}
return bitmap->pretile_y;
@@ -416,7 +416,8 @@ nsbeos_bitmap_get_pretile_xy(struct bitmap* bitmap)
int height = bitmap->primary->Bounds().Height() + 1;
int xmult = (MIN_PRETILE_WIDTH + width - 1)/width;
int ymult = (MIN_PRETILE_HEIGHT + height - 1)/height;
- LOG("Pretiling %p for X*%d Y*%d", bitmap, xmult, ymult);
+ NSLOG(netsurf, INFO, "Pretiling %p for X*%d Y*%d", bitmap,
+ xmult, ymult);
bitmap->pretile_xy = nsbeos_bitmap_generate_pretile(bitmap->primary, xmult, ymult);
}
return bitmap->pretile_xy;
diff --git a/frontends/beos/fetch_rsrc.cpp b/frontends/beos/fetch_rsrc.cpp
index e77f4c96e..ae3648354 100644
--- a/frontends/beos/fetch_rsrc.cpp
+++ b/frontends/beos/fetch_rsrc.cpp
@@ -71,13 +71,15 @@ BResources *gAppResources = NULL;
static bool fetch_rsrc_initialise(lwc_string *scheme)
{
- LOG("fetch_rsrc_initialise called for %s", lwc_string_data(scheme));
+ NSLOG(netsurf, INFO, "fetch_rsrc_initialise called for %s",
+ lwc_string_data(scheme));
return true;
}
static void fetch_rsrc_finalise(lwc_string *scheme)
{
- LOG("fetch_rsrc_finalise called for %s", lwc_string_data(scheme));
+ NSLOG(netsurf, INFO, "fetch_rsrc_finalise called for %s",
+ lwc_string_data(scheme));
}
static bool fetch_rsrc_can_fetch(const nsurl *url)
@@ -162,7 +164,7 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c)
* rsrc://[TYPE][@NUM]/name[,mime]
*/
- LOG("*** Processing %s", c->url);
+ NSLOG(netsurf, INFO, "*** Processing %s", c->url);
if (strlen(c->url) < 7) {
/* 7 is the minimum possible length (rsrc://) */
@@ -199,11 +201,13 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c)
uint8 c1, c2, c3, c4;
if (sscanf(params, "%c%c%c%c", &c1, &c2, &c3, &c4) > 3) {
type = c1 << 24 | c2 << 16 | c3 << 8 | c4;
- LOG("fetch_rsrc: type:%4.4s\n", (char *)&type);
+ NSLOG(netsurf, INFO, "fetch_rsrc: type:%4.4s\n",
+ (char *)&type);
}
}
- LOG("fetch_rsrc: 0x%08lx, %ld, '%s'\n", type, id, c->name);
+ NSLOG(netsurf, INFO, "fetch_rsrc: 0x%08lx, %ld, '%s'\n", type, id,
+ c->name);
bool found;
if (id)
@@ -278,7 +282,10 @@ static void fetch_rsrc_poll(lwc_string *scheme)
char header[64];
fetch_set_http_code(c->parent_fetch, 200);
- LOG("setting rsrc: MIME type to %s, length to %zd", c->mimetype, c->datalen);
+ NSLOG(netsurf, INFO,
+ "setting rsrc: MIME type to %s, length to %zd",
+ c->mimetype,
+ c->datalen);
/* Any callback can result in the fetch being aborted.
* Therefore, we _must_ check for this after _every_
* call to fetch_rsrc_send_callback().
@@ -308,7 +315,8 @@ static void fetch_rsrc_poll(lwc_string *scheme)
fetch_rsrc_send_callback(&msg, c);
}
} else {
- LOG("Processing of %s failed!", c->url);
+ NSLOG(netsurf, INFO, "Processing of %s failed!",
+ c->url);
/* Ensure that we're unlocked here. If we aren't,
* then fetch_rsrc_process() is broken.
diff --git a/frontends/beos/filetype.cpp b/frontends/beos/filetype.cpp
index 7a2ca97e5..bc988a8c7 100644
--- a/frontends/beos/filetype.cpp
+++ b/frontends/beos/filetype.cpp
@@ -18,6 +18,7 @@
#define __STDBOOL_H__ 1
#include <stdbool.h>
+#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
diff --git a/frontends/beos/font.cpp b/frontends/beos/font.cpp
index 407918f0c..5e7e78228 100644
--- a/frontends/beos/font.cpp
+++ b/frontends/beos/font.cpp
@@ -130,7 +130,7 @@ void nsbeos_style_to_font(BFont &font, const struct plot_font_style *fstyle)
}
//fprintf(stderr, "nsbeos_style_to_font: value %f unit %d\n", style->font_size.value.length.value, style->font_size.value.length.unit);
- size = fstyle->size / FONT_SIZE_SCALE;
+ size = fstyle->size / PLOT_STYLE_SCALE;
//fprintf(stderr, "nsbeos_style_to_font: %f %d\n", size, style->font_size.value.length.unit);
@@ -204,8 +204,8 @@ static nserror beos_font_position(const plot_font_style_t *fstyle,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x)
{
- //LOG("(, '%s', %d, %d, , )", string, length, x);
- //fprintf(stderr, "%s(, '%s', %d, %d, , )\n", __FUNCTION__, string, length, x);
+ NSLOG(netsurf, DEEPDEBUG, "(, '%s', %d, %d, , )", string, length, x);
+
int index;
BFont font;
@@ -261,8 +261,7 @@ static nserror beos_font_split(const plot_font_style_t *fstyle,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x)
{
- //fprintf(stderr, "%s(, '%s', %d, %d, , )\n", __FUNCTION__, string, length, x);
- //LOG("(, '%s', %d, %d, , )", string, length, x);
+ NSLOG(netsurf, DEEPDEBUG, "(, '%s', %d, %d, , )", string, length, x);
int index = 0;
BFont font;
diff --git a/frontends/beos/gui.cpp b/frontends/beos/gui.cpp
index d3321b58d..19f8eac49 100644
--- a/frontends/beos/gui.cpp
+++ b/frontends/beos/gui.cpp
@@ -112,7 +112,7 @@ static int sEventPipe[2];
/* exported function defined in beos/gui.h */
nserror beos_warn_user(const char *warning, const char *detail)
{
- LOG("warn_user: %s (%s)", warning, detail);
+ NSLOG(netsurf, INFO, "warn_user: %s (%s)", warning, detail);
BAlert *alert;
BString text(warning);
if (detail)
@@ -354,14 +354,15 @@ static void check_homedir(void)
if (err < B_OK) {
/* we really can't continue without a home directory. */
- LOG("Can't find user settings directory - nowhere to store state!");
+ NSLOG(netsurf, INFO,
+ "Can't find user settings directory - nowhere to store state!");
die("NetSurf needs to find the user settings directory in order to run.\n");
}
path.Append("NetSurf");
err = create_directory(path.Path(), 0644);
if (err < B_OK) {
- LOG("Unable to create %s", path.Path());
+ NSLOG(netsurf, INFO, "Unable to create %s", path.Path());
die("NetSurf could not create its settings directory.\n");
}
}
@@ -387,7 +388,7 @@ static nsurl *gui_get_resource_url(const char *path)
path = "favicon.png";
u << path;
- LOG("(%s) -> '%s'\n", path, u.String());
+ NSLOG(netsurf, INFO, "(%s) -> '%s'\n", path, u.String());
nsurl_create(u.String(), &url);
return url;
}
@@ -588,7 +589,7 @@ static void gui_init(int argc, char** argv)
die("Unable to load throbber image.\n");
find_resource(buf, "Choices", "%/Choices");
- LOG("Using '%s' as Preferences file", buf);
+ NSLOG(netsurf, INFO, "Using '%s' as Preferences file", buf);
options_file_location = strdup(buf);
nsoption_read(buf, NULL);
@@ -631,12 +632,12 @@ static void gui_init(int argc, char** argv)
if (nsoption_charp(cookie_file) == NULL) {
find_resource(buf, "Cookies", "%/Cookies");
- LOG("Using '%s' as Cookies file", buf);
+ NSLOG(netsurf, INFO, "Using '%s' as Cookies file", buf);
nsoption_set_charp(cookie_file, strdup(buf));
}
if (nsoption_charp(cookie_jar) == NULL) {
find_resource(buf, "Cookies", "%/Cookies");
- LOG("Using '%s' as Cookie Jar file", buf);
+ NSLOG(netsurf, INFO, "Using '%s' as Cookie Jar file", buf);
nsoption_set_charp(cookie_jar, strdup(buf));
}
if ((nsoption_charp(cookie_file) == NULL) ||
@@ -645,13 +646,13 @@ static void gui_init(int argc, char** argv)
if (nsoption_charp(url_file) == NULL) {
find_resource(buf, "URLs", "%/URLs");
- LOG("Using '%s' as URL file", buf);
+ NSLOG(netsurf, INFO, "Using '%s' as URL file", buf);
nsoption_set_charp(url_file, strdup(buf));
}
if (nsoption_charp(ca_path) == NULL) {
find_resource(buf, "certs", "/etc/ssl/certs");
- LOG("Using '%s' as certificate path", buf);
+ NSLOG(netsurf, INFO, "Using '%s' as certificate path", buf);
nsoption_set_charp(ca_path, strdup(buf));
}
@@ -763,17 +764,21 @@ void nsbeos_gui_poll(void)
timeout.tv_sec = (long)(next_schedule / 1000000LL);
timeout.tv_usec = (long)(next_schedule % 1000000LL);
- //LOG("gui_poll: select(%d, ..., %Ldus", max_fd, next_schedule);
+ NSLOG(netsurf, DEEPDEBUG,
+ "gui_poll: select(%d, ..., %Ldus",
+ max_fd, next_schedule);
fd_count = select(max_fd, &read_fd_set, &write_fd_set, &exc_fd_set,
&timeout);
- //LOG("select: %d\n", fd_count);
+ NSLOG(netsurf, DEEPDEBUG, "select: %d\n", fd_count);
if (fd_count > 0 && FD_ISSET(sEventPipe[0], &read_fd_set)) {
BMessage *message;
int len = read(sEventPipe[0], &message, sizeof(void *));
- //LOG("gui_poll: BMessage ? %d read", len);
+ NSLOG(netsurf, DEEPDEBUG, "gui_poll: BMessage ? %d read", len);
if (len == sizeof(void *)) {
- //LOG("gui_poll: BMessage.what %-4.4s\n", &(message->what));
+ NSLOG(netsurf, DEEPDEBUG,
+ "gui_poll: BMessage.what %-4.4s\n",
+ &(message->what));
nsbeos_dispatch_event(message);
}
}
@@ -1038,7 +1043,7 @@ int main(int argc, char** argv)
char path[12];
sprintf(path,"%.2s/Messages", getenv("LC_MESSAGES"));
- LOG("Loading messages from resource %s\n", path);
+ NSLOG(netsurf, INFO, "Loading messages from resource %s\n", path);
const uint8_t* res = (const uint8_t*)resources.LoadResource('data', path, &size);
if (size > 0 && res != NULL) {
@@ -1061,6 +1066,12 @@ int main(int argc, char** argv)
netsurf_exit();
+ /* finalise options */
+ nsoption_finalise(nsoptions, nsoptions_default);
+
+ /* finalise logging */
+ nslog_finalise();
+
return 0;
}
diff --git a/frontends/beos/plotters.cpp b/frontends/beos/plotters.cpp
index 5ba3fbbcb..2c50f9497 100644
--- a/frontends/beos/plotters.cpp
+++ b/frontends/beos/plotters.cpp
@@ -18,8 +18,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Target independent plotting (BeOS/Haiku implementation).
+/**
+ * \file
+ * BeOS/Haiku implementation target independent plotting.
*/
#define __STDBOOL_H__ 1
@@ -31,11 +32,11 @@
#include <View.h>
#include <Shape.h>
extern "C" {
-#include "netsurf/plotters.h"
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
#include "utils/nsurl.h"
+#include "netsurf/plotters.h"
}
#include "beos/font.h"
#include "beos/gui.h"
@@ -50,581 +51,751 @@ extern "C" {
* the right-bottom pixel is actually part of the BRect!
*/
-static bool nsbeos_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool nsbeos_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool nsbeos_plot_polygon(const int *p, unsigned int n, const plot_style_t *style);
-static bool nsbeos_plot_path(const float *p, unsigned int n, colour fill, float width,
- colour c, const float transform[6]);
-static bool nsbeos_plot_clip(const struct rect *ns_clip);
-static bool nsbeos_plot_text(int x, int y, const char *text, size_t length,
- const plot_font_style_t *fstyle);
-static bool nsbeos_plot_disc(int x, int y, int radius, const plot_style_t *style);
-static bool nsbeos_plot_arc(int x, int y, int radius, int angle1, int angle2,
- const plot_style_t *style);
-static bool nsbeos_plot_bitmap(int x, int y, int width, int height,
- struct bitmap *bitmap, colour bg,
- bitmap_flags_t flags);
-
-
#warning make patterns nicer
-static const pattern kDottedPattern = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
-static const pattern kDashedPattern = { 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0x33, 0x33 };
-
-static const rgb_color kBlackColor = { 0, 0, 0, 255 };
-
-struct plotter_table plot;
+static const pattern kDottedPattern = {
+ 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa
+};
+static const pattern kDashedPattern = {
+ 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0x33, 0x33
+};
-const struct plotter_table nsbeos_plotters = {
- nsbeos_plot_clip,
- nsbeos_plot_arc,
- nsbeos_plot_disc,
- nsbeos_plot_line,
- nsbeos_plot_rectangle,
- nsbeos_plot_polygon,
- nsbeos_plot_path,
- nsbeos_plot_bitmap,
- nsbeos_plot_text,
- NULL, // Group Start
- NULL, // Group End
- NULL, // Flush
- true // option_knockout
+static const rgb_color kBlackColor = {
+ 0, 0, 0, 255
};
+//struct plotter_table plot;
// #pragma mark - implementation
-
BView *nsbeos_current_gc(void)
{
- return current_view;
+ return current_view;
}
+
BView *nsbeos_current_gc_lock(void)
{
- BView *view = current_view;
- if (view && view->LockLooper())
- return view;
- return NULL;
+ BView *view = current_view;
+ if (view && view->LockLooper())
+ return view;
+ return NULL;
}
+
void nsbeos_current_gc_unlock(void)
{
- if (current_view)
- current_view->UnlockLooper();
+ if (current_view) {
+ current_view->UnlockLooper();
+ }
}
+
void nsbeos_current_gc_set(BView *view)
{
- // XXX: (un)lock previous ?
- current_view = view;
+ // XXX: (un)lock previous ?
+ current_view = view;
}
-bool nsbeos_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
+
+static nserror
+nsbeos_plot_bbitmap(int x, int y, int width, int height, BBitmap *b, colour bg)
{
- if (style->fill_type != PLOT_OP_TYPE_NONE) {
- BView *view;
+ /* XXX: This currently ignores the background colour supplied.
+ * Does this matter?
+ */
+
+ if (width == 0 || height == 0) {
+ return NSERROR_OK;
+ }
+
+ BView *view;
+
+ view = nsbeos_current_gc/*_lock*/();
+ if (view == NULL) {
+ beos_warn_user("No GC", 0);
+ return NSERROR_INVALID;
+ }
+
+ drawing_mode oldmode = view->DrawingMode();
+ source_alpha alpha;
+ alpha_function func;
+ view->GetBlendingMode(&alpha, &func);
+ //view->SetDrawingMode(B_OP_OVER);
+ view->SetDrawingMode(B_OP_ALPHA);
+ view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
+
+ // XXX DrawBitmap() resamples if rect doesn't match,
+ // but doesn't do any filtering
+ // XXX: use Zeta API if available ?
+
+ BRect rect(x, y, x + width - 1, y + height - 1);
+ /*
+ rgb_color old = view->LowColor();
+ if (bg != NS_TRANSPARENT) {
+ view->SetLowColor(nsbeos_rgb_colour(bg));
+ view->FillRect(rect, B_SOLID_LOW);
+ }
+ */
+ view->DrawBitmap(b, rect);
+ // maybe not needed?
+ //view->SetLowColor(old);
+ view->SetBlendingMode(alpha, func);
+ view->SetDrawingMode(oldmode);
+
+ //nsbeos_current_gc_unlock();
+
+ return NSERROR_OK;
+}
- view = nsbeos_current_gc/*_lock*/();
- if (view == NULL) {
- beos_warn_user("No GC", 0);
- return false;
- }
- nsbeos_set_colour(style->fill_colour);
+static BPoint transform_pt(float x, float y, const float transform[6])
+{
+#warning XXX: verify
+ //return BPoint(x, y);
+ BPoint pt;
+ pt.x = x * transform[0] + y * transform[1] + transform[4];
+ pt.y = x * transform[2] + y * transform[3] + transform[5];
+ /*
+ printf("TR: {%f, %f} { %f, %f, %f, %f, %f, %f} = { %f, %f }\n",
+ x, y,
+ transform[0], transform[1], transform[2],
+ transform[3], transform[4], transform[5],
+ pt.x, pt.y);
+ */
+ return pt;
+}
- BRect rect(x0, y0, x1 - 1, y1 - 1);
- view->FillRect(rect);
- //nsbeos_current_gc_unlock();
+rgb_color nsbeos_rgb_colour(colour c)
+{
+ rgb_color color;
+ if (c == NS_TRANSPARENT)
+ return B_TRANSPARENT_32_BIT;
+ color.red = c & 0x0000ff;
+ color.green = (c & 0x00ff00) >> 8;
+ color.blue = (c & 0xff0000) >> 16;
+ return color;
+}
- }
- if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- pattern pat;
- BView *view;
+void nsbeos_set_colour(colour c)
+{
+ rgb_color color = nsbeos_rgb_colour(c);
+ BView *view = nsbeos_current_gc();
+ view->SetHighColor(color);
+}
- switch (style->stroke_type) {
- case PLOT_OP_TYPE_SOLID: /**< Solid colour */
- default:
- pat = B_SOLID_HIGH;
- break;
- case PLOT_OP_TYPE_DOT: /**< Doted plot */
- pat = kDottedPattern;
- break;
+/**
+ * Plot a caret.
+ *
+ * It is assumed that the plotters have been set up.
+ */
+void nsbeos_plot_caret(int x, int y, int h)
+{
+ BView *view;
- case PLOT_OP_TYPE_DASH: /**< dashed plot */
- pat = kDashedPattern;
- break;
- }
+ view = nsbeos_current_gc/*_lock*/();
+ if (view == NULL)
+ /* TODO: report an error here */
+ return;
- view = nsbeos_current_gc/*_lock*/();
- if (view == NULL) {
- beos_warn_user("No GC", 0);
- return false;
- }
+ BPoint start(x, y);
+ BPoint end(x, y + h - 1);
+#if defined(__HAIKU__) || defined(B_BEOS_VERSION_DANO)
+ view->SetHighColor(ui_color(B_DOCUMENT_TEXT_COLOR));
+#else
+ view->SetHighColor(kBlackColor);
+#endif
+ view->StrokeLine(start, end);
- nsbeos_set_colour(style->stroke_colour);
+ //nsbeos_current_gc_unlock();
+}
- float pensize = view->PenSize();
- view->SetPenSize(style->stroke_width);
- BRect rect(x0, y0, x1, y1);
- view->StrokeRect(rect, pat);
+/**
+ * \brief Sets a clip rectangle for subsequent plot operations.
+ *
+ * \param ctx The current redraw context.
+ * \param ns_clip The rectangle to limit all subsequent plot
+ * operations within.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+nsbeos_plot_clip(const struct redraw_context *ctx, const struct rect *ns_clip)
+{
+ BView *view;
+ //fprintf(stderr, "%s(%d, %d, %d, %d)\n", __FUNCTION__, clip_x0, clip_y0, clip_x1, clip_y1);
- view->SetPenSize(pensize);
+ view = nsbeos_current_gc/*_lock*/();
+ if (view == NULL) {
+ beos_warn_user("No GC", 0);
+ return NSERROR_INVALID;
+ }
- //nsbeos_current_gc_unlock();
+ BRect rect(ns_clip->x0, ns_clip->y0, ns_clip->x1 - 1, ns_clip->y1 - 1);
+ BRegion clip(rect);
+ view->ConstrainClippingRegion(NULL);
+ if (view->Bounds() != rect) {
+ view->ConstrainClippingRegion(&clip);
+ }
- }
+ //nsbeos_current_gc_unlock();
- return true;
+ return NSERROR_OK;
}
-
-bool nsbeos_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
+/**
+ * Plots an arc
+ *
+ * plot an arc segment around (x,y), anticlockwise from angle1
+ * to angle2. Angles are measured anticlockwise from
+ * horizontal, in degrees.
+ *
+ * \param ctx The current redraw context.
+ * \param style Style controlling the arc plot.
+ * \param x The x coordinate of the arc.
+ * \param y The y coordinate of the arc.
+ * \param radius The radius of the arc.
+ * \param angle1 The start angle of the arc.
+ * \param angle2 The finish angle of the arc.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+nsbeos_plot_arc(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ int x, int y, int radius, int angle1, int angle2)
{
- pattern pat;
- BView *view;
+ BView *view;
- switch (style->stroke_type) {
- case PLOT_OP_TYPE_SOLID: /**< Solid colour */
- default:
- pat = B_SOLID_HIGH;
- break;
+ view = nsbeos_current_gc/*_lock*/();
+ if (view == NULL) {
+ beos_warn_user("No GC", 0);
+ return NSERROR_INVALID;
+ }
- case PLOT_OP_TYPE_DOT: /**< Doted plot */
- pat = kDottedPattern;
- break;
+ nsbeos_set_colour(style->fill_colour);
- case PLOT_OP_TYPE_DASH: /**< dashed plot */
- pat = kDashedPattern;
- break;
- }
+ BPoint center(x, y);
+ float angle = angle1; // in degree
+ float span = angle2 - angle1; // in degree
+ view->StrokeArc(center, radius, radius, angle, span);
- view = nsbeos_current_gc/*_lock*/();
- if (view == NULL) {
- beos_warn_user("No GC", 0);
- return false;
- }
+ //nsbeos_current_gc_unlock();
- nsbeos_set_colour(style->stroke_colour);
+ return NSERROR_OK;
+}
+
+
+/**
+ * Plots a circle
+ *
+ * Plot a circle centered on (x,y), which is optionally filled.
+ *
+ * \param ctx The current redraw context.
+ * \param style Style controlling the circle plot.
+ * \param x x coordinate of circle centre.
+ * \param y y coordinate of circle centre.
+ * \param radius circle radius.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+nsbeos_plot_disc(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ int x, int y, int radius)
+{
+ BView *view;
- float pensize = view->PenSize();
- view->SetPenSize(style->stroke_width);
+ view = nsbeos_current_gc/*_lock*/();
+ if (view == NULL) {
+ beos_warn_user("No GC", 0);
+ return NSERROR_INVALID;
+ }
- BPoint start(x0, y0);
- BPoint end(x1, y1);
- view->StrokeLine(start, end, pat);
+ nsbeos_set_colour(style->fill_colour);
- view->SetPenSize(pensize);
+ BPoint center(x, y);
+ if (style->fill_type != PLOT_OP_TYPE_NONE)
+ view->FillEllipse(center, radius, radius);
+ else
+ view->StrokeEllipse(center, radius, radius);
- //nsbeos_current_gc_unlock();
+ //nsbeos_current_gc_unlock();
- return true;
+ return NSERROR_OK;
}
-bool nsbeos_plot_polygon(const int *p, unsigned int n, const plot_style_t *style)
+/**
+ * Plots a line
+ *
+ * plot a line from (x0,y0) to (x1,y1). Coordinates are at
+ * centre of line width/thickness.
+ *
+ * \param ctx The current redraw context.
+ * \param style Style controlling the line plot.
+ * \param line A rectangle defining the line to be drawn
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+nsbeos_plot_line(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ const struct rect *line)
{
- unsigned int i;
- BView *view;
+ pattern pat;
+ BView *view;
- view = nsbeos_current_gc/*_lock*/();
- if (view == NULL) {
- beos_warn_user("No GC", 0);
- return false;
- }
+ switch (style->stroke_type) {
+ case PLOT_OP_TYPE_SOLID: /**< Solid colour */
+ default:
+ pat = B_SOLID_HIGH;
+ break;
- nsbeos_set_colour(style->fill_colour);
+ case PLOT_OP_TYPE_DOT: /**< Doted plot */
+ pat = kDottedPattern;
+ break;
- BPoint points[n];
-
- for (i = 0; i < n; i++) {
- points[i] = BPoint(p[2 * i] - 0.5, p[2 * i + 1] - 0.5);
- }
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
+ pat = kDashedPattern;
+ break;
+ }
- if (style->fill_colour == NS_TRANSPARENT)
- view->StrokePolygon(points, (int32)n);
- else
- view->FillPolygon(points, (int32)n);
+ view = nsbeos_current_gc/*_lock*/();
+ if (view == NULL) {
+ beos_warn_user("No GC", 0);
+ return NSERROR_OK;
+ }
- return true;
-}
+ nsbeos_set_colour(style->stroke_colour);
+ float pensize = view->PenSize();
+ view->SetPenSize(plot_style_fixed_to_float(style->stroke_width));
+ BPoint start(line->x0, line->y0);
+ BPoint end(line->x1, line->y1);
+ view->StrokeLine(start, end, pat);
+ view->SetPenSize(pensize);
-bool nsbeos_plot_clip(const struct rect *ns_clip)
-{
- BView *view;
- //fprintf(stderr, "%s(%d, %d, %d, %d)\n", __FUNCTION__, clip_x0, clip_y0, clip_x1, clip_y1);
-
- view = nsbeos_current_gc/*_lock*/();
- if (view == NULL) {
- beos_warn_user("No GC", 0);
- return false;
- }
-
- BRect rect(ns_clip->x0, ns_clip->y0, ns_clip->x1 - 1,
- ns_clip->y1 - 1);
- BRegion clip(rect);
- view->ConstrainClippingRegion(NULL);
- if (view->Bounds() != rect)
- view->ConstrainClippingRegion(&clip);
-
-
- //nsbeos_current_gc_unlock();
-
- return true;
+ //nsbeos_current_gc_unlock();
+
+ return NSERROR_OK;
}
-bool nsbeos_plot_text(int x, int y, const char *text, size_t length,
- const plot_font_style_t *fstyle)
+/**
+ * Plots a rectangle.
+ *
+ * The rectangle can be filled an outline or both controlled
+ * by the plot style The line can be solid, dotted or
+ * dashed. Top left corner at (x0,y0) and rectangle has given
+ * width and height.
+ *
+ * \param ctx The current redraw context.
+ * \param style Style controlling the rectangle plot.
+ * \param nsrect A rectangle defining the line to be drawn
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+nsbeos_plot_rectangle(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ const struct rect *nsrect)
{
- return nsfont_paint(fstyle, text, length, x, y);
-}
+ if (style->fill_type != PLOT_OP_TYPE_NONE) {
+ BView *view;
+ view = nsbeos_current_gc/*_lock*/();
+ if (view == NULL) {
+ beos_warn_user("No GC", 0);
+ return NSERROR_INVALID;
+ }
-bool nsbeos_plot_disc(int x, int y, int radius, const plot_style_t *style)
-{
- BView *view;
+ nsbeos_set_colour(style->fill_colour);
- view = nsbeos_current_gc/*_lock*/();
- if (view == NULL) {
- beos_warn_user("No GC", 0);
- return false;
- }
+ BRect rect(nsrect->x0, nsrect->y0, nsrect->x1 - 1, nsrect->y1 - 1);
+ view->FillRect(rect);
- nsbeos_set_colour(style->fill_colour);
+ //nsbeos_current_gc_unlock();
+ }
- BPoint center(x, y);
- if (style->fill_type != PLOT_OP_TYPE_NONE)
- view->FillEllipse(center, radius, radius);
- else
- view->StrokeEllipse(center, radius, radius);
+ if (style->stroke_type != PLOT_OP_TYPE_NONE) {
+ pattern pat;
+ BView *view;
+
+ switch (style->stroke_type) {
+ case PLOT_OP_TYPE_SOLID: /**< Solid colour */
+ default:
+ pat = B_SOLID_HIGH;
+ break;
- //nsbeos_current_gc_unlock();
+ case PLOT_OP_TYPE_DOT: /**< Doted plot */
+ pat = kDottedPattern;
+ break;
+
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
+ pat = kDashedPattern;
+ break;
+ }
+
+ view = nsbeos_current_gc/*_lock*/();
+ if (view == NULL) {
+ beos_warn_user("No GC", 0);
+ return NSERROR_INVALID;
+ }
- return true;
+ nsbeos_set_colour(style->stroke_colour);
+
+ float pensize = view->PenSize();
+ view->SetPenSize(plot_style_fixed_to_float(style->stroke_width));
+
+ BRect rect(nsrect->x0, nsrect->y0, nsrect->x1, nsrect->y1);
+ view->StrokeRect(rect, pat);
+
+ view->SetPenSize(pensize);
+
+ //nsbeos_current_gc_unlock();
+ }
+
+ return NSERROR_OK;
}
-bool nsbeos_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style)
+
+/**
+ * Plot a polygon
+ *
+ * Plots a filled polygon with straight lines between
+ * points. The lines around the edge of the ploygon are not
+ * plotted. The polygon is filled with the non-zero winding
+ * rule.
+ *
+ * \param ctx The current redraw context.
+ * \param style Style controlling the polygon plot.
+ * \param p verticies of polygon
+ * \param n number of verticies.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+nsbeos_plot_polygon(const struct redraw_context *ctx,
+ const plot_style_t *style,
+ const int *p,
+ unsigned int n)
{
- BView *view;
+ unsigned int i;
+ BView *view;
+
+ view = nsbeos_current_gc/*_lock*/();
+ if (view == NULL) {
+ beos_warn_user("No GC", 0);
+ return NSERROR_INVALID;
+ }
- view = nsbeos_current_gc/*_lock*/();
- if (view == NULL) {
- beos_warn_user("No GC", 0);
- return false;
- }
+ nsbeos_set_colour(style->fill_colour);
- nsbeos_set_colour(style->fill_colour);
+ BPoint points[n];
- BPoint center(x, y);
- float angle = angle1; // in degree
- float span = angle2 - angle1; // in degree
- view->StrokeArc(center, radius, radius, angle, span);
+ for (i = 0; i < n; i++) {
+ points[i] = BPoint(p[2 * i] - 0.5, p[2 * i + 1] - 0.5);
+ }
- //nsbeos_current_gc_unlock();
+ if (style->fill_colour == NS_TRANSPARENT) {
+ view->StrokePolygon(points, (int32)n);
+ } else {
+ view->FillPolygon(points, (int32)n);
+ }
- return true;
+ return NSERROR_OK;
}
-static bool nsbeos_plot_bbitmap(int x, int y, int width, int height,
- BBitmap *b, colour bg)
+
+/**
+ * Plots a path.
+ *
+ * Path plot consisting of cubic Bezier curves. Line and fill colour is
+ * controlled by the plot style.
+ *
+ * \param ctx The current redraw context.
+ * \param pstyle Style controlling the path plot.
+ * \param p elements of path
+ * \param n nunber of elements on path
+ * \param transform A transform to apply to the path.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+nsbeos_plot_path(const struct redraw_context *ctx,
+ const plot_style_t *pstyle,
+ const float *p,
+ unsigned int n,
+ const float transform[6])
{
- /* XXX: This currently ignores the background colour supplied.
- * Does this matter?
- */
-
- if (width == 0 || height == 0)
- return true;
-
- BView *view;
-
- view = nsbeos_current_gc/*_lock*/();
- if (view == NULL) {
- beos_warn_user("No GC", 0);
- return false;
- }
-
- drawing_mode oldmode = view->DrawingMode();
- source_alpha alpha;
- alpha_function func;
- view->GetBlendingMode(&alpha, &func);
- //view->SetDrawingMode(B_OP_OVER);
- view->SetDrawingMode(B_OP_ALPHA);
- view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
-
- // XXX DrawBitmap() resamples if rect doesn't match,
- // but doesn't do any filtering
- // XXX: use Zeta API if available ?
-
- BRect rect(x, y, x + width - 1, y + height - 1);
- /*
- rgb_color old = view->LowColor();
- if (bg != NS_TRANSPARENT) {
- view->SetLowColor(nsbeos_rgb_colour(bg));
- view->FillRect(rect, B_SOLID_LOW);
- }
- */
- view->DrawBitmap(b, rect);
- // maybe not needed?
- //view->SetLowColor(old);
- view->SetBlendingMode(alpha, func);
- view->SetDrawingMode(oldmode);
-
- //nsbeos_current_gc_unlock();
-
- return true;
+ unsigned int i;
+ BShape shape;
+
+ if (n == 0) {
+ return NSERROR_OK;
+ }
+
+ if (p[0] != PLOTTER_PATH_MOVE) {
+ NSLOG(netsurf, INFO, "path doesn't start with a move");
+ return NSERROR_INVALID;
+ }
+
+ for (i = 0; i < n; ) {
+ if (p[i] == PLOTTER_PATH_MOVE) {
+ BPoint pt(transform_pt(p[i + 1], p[i + 2], transform));
+ shape.MoveTo(pt);
+ i += 3;
+ } else if (p[i] == PLOTTER_PATH_CLOSE) {
+ shape.Close();
+ i++;
+ } else if (p[i] == PLOTTER_PATH_LINE) {
+ BPoint pt(transform_pt(p[i + 1], p[i + 2], transform));
+ shape.LineTo(pt);
+ i += 3;
+ } else if (p[i] == PLOTTER_PATH_BEZIER) {
+ BPoint pt[3] = {
+ transform_pt(p[i + 1], p[i + 2], transform),
+ transform_pt(p[i + 3], p[i + 4], transform),
+ transform_pt(p[i + 5], p[i + 6], transform)
+ };
+ shape.BezierTo(pt);
+ i += 7;
+ } else {
+ NSLOG(netsurf, INFO, "bad path command %f", p[i]);
+ return NSERROR_INVALID;
+ }
+ }
+ shape.Close();
+
+ BView *view;
+
+ view = nsbeos_current_gc/*_lock*/();
+ if (view == NULL) {
+ return NSERROR_INVALID;
+ }
+
+ rgb_color old_high = view->HighColor();
+ float old_pen = view->PenSize();
+ view->SetPenSize(plot_style_fixed_to_float(pstyle->stroke_width));
+ view->MovePenTo(0, 0);
+ if (pstyle->fill_colour != NS_TRANSPARENT) {
+ view->SetHighColor(nsbeos_rgb_colour(pstyle->fill_colour));
+ view->FillShape(&shape);
+ }
+ if (pstyle->stroke_colour != NS_TRANSPARENT) {
+ view->SetHighColor(nsbeos_rgb_colour(pstyle->stroke_colour));
+ view->StrokeShape(&shape);
+ }
+ // restore
+ view->SetPenSize(old_pen);
+ view->SetHighColor(old_high);
+
+ //nsbeos_current_gc_unlock();
+
+ return NSERROR_OK;
}
-bool nsbeos_plot_bitmap(int x, int y, int width, int height,
- struct bitmap *bitmap, colour bg,
- bitmap_flags_t flags)
+/**
+ * Plot a bitmap
+ *
+ * Tiled plot of a bitmap image. (x,y) gives the top left
+ * coordinate of an explicitly placed tile. From this tile the
+ * image can repeat in all four directions -- up, down, left
+ * and right -- to the extents given by the current clip
+ * rectangle.
+ *
+ * The bitmap_flags say whether to tile in the x and y
+ * directions. If not tiling in x or y directions, the single
+ * image is plotted. The width and height give the dimensions
+ * the image is to be scaled to.
+ *
+ * \param ctx The current redraw context.
+ * \param bitmap The bitmap to plot
+ * \param x The x coordinate to plot the bitmap
+ * \param y The y coordiante to plot the bitmap
+ * \param width The width of area to plot the bitmap into
+ * \param height The height of area to plot the bitmap into
+ * \param bg the background colour to alpha blend into
+ * \param flags the flags controlling the type of plot operation
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+nsbeos_plot_bitmap(const struct redraw_context *ctx,
+ struct bitmap *bitmap,
+ int x, int y,
+ int width,
+ int height,
+ colour bg,
+ bitmap_flags_t flags)
{
- int doneheight = 0, donewidth = 0;
- BBitmap *primary;
- BBitmap *pretiled;
+ int doneheight = 0, donewidth = 0;
+ BBitmap *primary;
+ BBitmap *pretiled;
bool repeat_x = (flags & BITMAPF_REPEAT_X);
bool repeat_y = (flags & BITMAPF_REPEAT_Y);
- if (!(repeat_x || repeat_y)) {
- /* Not repeating at all, so just plot it */
+ if (!(repeat_x || repeat_y)) {
+ /* Not repeating at all, so just plot it */
primary = nsbeos_bitmap_get_primary(bitmap);
return nsbeos_plot_bbitmap(x, y, width, height, primary, bg);
- }
-
- if (repeat_x && !repeat_y)
- pretiled = nsbeos_bitmap_get_pretile_x(bitmap);
- if (repeat_x && repeat_y)
- pretiled = nsbeos_bitmap_get_pretile_xy(bitmap);
- if (!repeat_x && repeat_y)
- pretiled = nsbeos_bitmap_get_pretile_y(bitmap);
- primary = nsbeos_bitmap_get_primary(bitmap);
-
- /* use the primary and pretiled widths to scale the w/h provided */
- width *= pretiled->Bounds().Width() + 1;
- width /= primary->Bounds().Width() + 1;
- height *= pretiled->Bounds().Height() + 1;
- height /= primary->Bounds().Height() + 1;
-
- BView *view;
-
- view = nsbeos_current_gc/*_lock*/();
- if (view == NULL) {
- beos_warn_user("No GC", 0);
- return false;
- }
-
- // XXX: do we really need to use clipping reg ?
- // I guess it's faster to not draw clipped out stuff...
-
- BRect cliprect;
- BRegion clipreg;
- view->GetClippingRegion(&clipreg);
- cliprect = clipreg.Frame();
-
- //XXX: FIXME
-
- if (y > cliprect.top)
- doneheight = ((int)cliprect.top - height) + ((y - (int)cliprect.top) % height);
- else
- doneheight = y;
-
- while (doneheight < ((int)cliprect.bottom)) {
- if (x > cliprect.left)
- donewidth = ((int)cliprect.left - width) + ((x - (int)cliprect.left) % width);
- else
- donewidth = x;
- while (donewidth < (cliprect.right)) {
- nsbeos_plot_bbitmap(donewidth, doneheight,
- width, height, pretiled, bg);
- donewidth += width;
- if (!repeat_x) break;
- }
- doneheight += height;
- if (!repeat_y) break;
- }
+ }
+
+ if (repeat_x && !repeat_y)
+ pretiled = nsbeos_bitmap_get_pretile_x(bitmap);
+ if (repeat_x && repeat_y)
+ pretiled = nsbeos_bitmap_get_pretile_xy(bitmap);
+ if (!repeat_x && repeat_y)
+ pretiled = nsbeos_bitmap_get_pretile_y(bitmap);
+ primary = nsbeos_bitmap_get_primary(bitmap);
+
+ /* use the primary and pretiled widths to scale the w/h provided */
+ width *= pretiled->Bounds().Width() + 1;
+ width /= primary->Bounds().Width() + 1;
+ height *= pretiled->Bounds().Height() + 1;
+ height /= primary->Bounds().Height() + 1;
+
+ BView *view;
+
+ view = nsbeos_current_gc/*_lock*/();
+ if (view == NULL) {
+ beos_warn_user("No GC", 0);
+ return NSERROR_INVALID;
+ }
+
+ // XXX: do we really need to use clipping reg ?
+ // I guess it's faster to not draw clipped out stuff...
+
+ BRect cliprect;
+ BRegion clipreg;
+ view->GetClippingRegion(&clipreg);
+ cliprect = clipreg.Frame();
+
+ //XXX: FIXME
+
+ if (y > cliprect.top) {
+ doneheight = ((int)cliprect.top - height) + ((y - (int)cliprect.top) % height);
+ } else {
+ doneheight = y;
+ }
+
+ while (doneheight < ((int)cliprect.bottom)) {
+ if (x > cliprect.left) {
+ donewidth = ((int)cliprect.left - width) + ((x - (int)cliprect.left) % width);
+ } else {
+ donewidth = x;
+ }
+
+ while (donewidth < (cliprect.right)) {
+ nsbeos_plot_bbitmap(donewidth, doneheight,
+ width, height, pretiled, bg);
+ donewidth += width;
+ if (!repeat_x) {
+ break;
+ }
+ }
+ doneheight += height;
+ if (!repeat_y) {
+ break;
+ }
+ }
#warning WRITEME
- return true;
-}
-static BPoint transform_pt(float x, float y, const float transform[6])
-{
-#warning XXX: verify
- //return BPoint(x, y);
- BPoint pt;
- pt.x = x * transform[0] + y * transform[1] + transform[4];
- pt.y = x * transform[2] + y * transform[3] + transform[5];
- /*
- printf("TR: {%f, %f} { %f, %f, %f, %f, %f, %f} = { %f, %f }\n",
- x, y,
- transform[0], transform[1], transform[2],
- transform[3], transform[4], transform[5],
- pt.x, pt.y);
- */
- return pt;
+ return NSERROR_OK;
}
-bool nsbeos_plot_path(const float *p, unsigned int n, colour fill, float width,
- colour c, const float transform[6])
-{
- unsigned int i;
-
- if (n == 0)
- return true;
-
- if (p[0] != PLOTTER_PATH_MOVE) {
- LOG("path doesn't start with a move");
- return false;
- }
-
- BShape shape;
-
- for (i = 0; i < n; ) {
- if (p[i] == PLOTTER_PATH_MOVE) {
- BPoint pt(transform_pt(p[i + 1], p[i + 2], transform));
- shape.MoveTo(pt);
- i += 3;
- } else if (p[i] == PLOTTER_PATH_CLOSE) {
- shape.Close();
- i++;
- } else if (p[i] == PLOTTER_PATH_LINE) {
- BPoint pt(transform_pt(p[i + 1], p[i + 2], transform));
- shape.LineTo(pt);
- i += 3;
- } else if (p[i] == PLOTTER_PATH_BEZIER) {
- BPoint pt[3] = {
- transform_pt(p[i + 1], p[i + 2], transform),
- transform_pt(p[i + 3], p[i + 4], transform),
- transform_pt(p[i + 5], p[i + 6], transform)
- };
- shape.BezierTo(pt);
- i += 7;
- } else {
- LOG("bad path command %f", p[i]);
- return false;
- }
- }
- shape.Close();
-
- BView *view;
-
- view = nsbeos_current_gc/*_lock*/();
- if (view == NULL)
- return false;
-
- rgb_color old_high = view->HighColor();
- float old_pen = view->PenSize();
- view->SetPenSize(width);
- view->MovePenTo(0, 0);
- if (fill != NS_TRANSPARENT) {
- view->SetHighColor(nsbeos_rgb_colour(fill));
- view->FillShape(&shape);
- }
- if (c != NS_TRANSPARENT) {
- view->SetHighColor(nsbeos_rgb_colour(c));
- view->StrokeShape(&shape);
- }
- // restore
- view->SetPenSize(old_pen);
- view->SetHighColor(old_high);
-
- //nsbeos_current_gc_unlock();
-
- return true;
-}
-rgb_color nsbeos_rgb_colour(colour c)
+/**
+ * Text plotting.
+ *
+ * \param ctx The current redraw context.
+ * \param fstyle plot style for this text
+ * \param x x coordinate
+ * \param y y coordinate
+ * \param text UTF-8 string to plot
+ * \param length length of string, in bytes
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+nsbeos_plot_text(const struct redraw_context *ctx,
+ const struct plot_font_style *fstyle,
+ int x,
+ int y,
+ const char *text,
+ size_t length)
{
- rgb_color color;
- if (c == NS_TRANSPARENT)
- return B_TRANSPARENT_32_BIT;
- color.red = c & 0x0000ff;
- color.green = (c & 0x00ff00) >> 8;
- color.blue = (c & 0xff0000) >> 16;
- return color;
-}
+ if (!nsfont_paint(fstyle, text, length, x, y)) {
+ return NSERROR_INVALID;
+ }
-void nsbeos_set_colour(colour c)
-{
- rgb_color color = nsbeos_rgb_colour(c);
- BView *view = nsbeos_current_gc();
- view->SetHighColor(color);
+ return NSERROR_OK;
}
-/** Plot a caret. It is assumed that the plotters have been set up. */
-void nsbeos_plot_caret(int x, int y, int h)
-{
- BView *view;
-
- view = nsbeos_current_gc/*_lock*/();
- if (view == NULL)
- /* TODO: report an error here */
- return;
-
- BPoint start(x, y);
- BPoint end(x, y + h - 1);
-#if defined(__HAIKU__) || defined(B_BEOS_VERSION_DANO)
- view->SetHighColor(ui_color(B_DOCUMENT_TEXT_COLOR));
-#else
- view->SetHighColor(kBlackColor);
-#endif
- view->StrokeLine(start, end);
- //nsbeos_current_gc_unlock();
+/**
+ * beos plotter operation table
+ */
+const struct plotter_table nsbeos_plotters = {
+ nsbeos_plot_clip,
+ nsbeos_plot_arc,
+ nsbeos_plot_disc,
+ nsbeos_plot_line,
+ nsbeos_plot_rectangle,
+ nsbeos_plot_polygon,
+ nsbeos_plot_path,
+ nsbeos_plot_bitmap,
+ nsbeos_plot_text,
+ NULL, // Group Start
+ NULL, // Group End
+ NULL, // Flush
+ true // option_knockout
+};
-}
#ifdef TEST_PLOTTERS
//
static void test_plotters(void)
{
- int x0, y0;
- int x1, y1;
- struct rect r;
-
- x0 = 5;
- y0 = 5;
- x1 = 35;
- y1 = 6;
-
- plot.line(x0, y0, x1, y1, 1, 0x0000ff00, false, false);
- y0+=2; y1+=2;
- plot.line(x0, y0, x1, y1, 1, 0x0000ff00, true, false);
- y0+=2; y1+=2;
- plot.line(x0, y0, x1, y1, 1, 0x0000ff00, false, true);
- y0+=2; y1+=2;
- plot.line(x0, y0, x1, y1, 1, 0x0000ff00, true, true);
- y0+=10; y1+=20;
-
- plot.fill(x0, y0, x1, y1, 0x00ff0000);
- plot.rectangle(x0+10, y0+10, x1-x0+1, y1-y0+1, 2, 0x00ffff00, true, false);
- y0+=30; y1+=30;
-
- r.x0 = x0 + 2;
- r.y0 = y0 + 2;
- r.x1 = x1 - 2;
- r.y1 = y1 - 2;
- plot.clip(&r);
-
- plot.fill(x0, y0, x1, y1, 0x00000000);
- plot.disc(x1, y1, 8, 0x000000ff, false);
-
- r.x0 = 0;
- r.y0 = 0;
- r.x1 = 300;
- r.y1 = 300;
- plot.clip(&r);
-
- y0+=30; y1+=30;
-
+ int x0, y0;
+ int x1, y1;
+ struct rect r;
+
+ x0 = 5;
+ y0 = 5;
+ x1 = 35;
+ y1 = 6;
+
+ plot.line(x0, y0, x1, y1, 1, 0x0000ff00, false, false);
+ y0+=2; y1+=2;
+ plot.line(x0, y0, x1, y1, 1, 0x0000ff00, true, false);
+ y0+=2; y1+=2;
+ plot.line(x0, y0, x1, y1, 1, 0x0000ff00, false, true);
+ y0+=2; y1+=2;
+ plot.line(x0, y0, x1, y1, 1, 0x0000ff00, true, true);
+ y0+=10; y1+=20;
+
+ plot.fill(x0, y0, x1, y1, 0x00ff0000);
+ plot.rectangle(x0+10, y0+10, x1-x0+1, y1-y0+1, 2, 0x00ffff00, true, false);
+ y0+=30; y1+=30;
+
+ r.x0 = x0 + 2;
+ r.y0 = y0 + 2;
+ r.x1 = x1 - 2;
+ r.y1 = y1 - 2;
+ plot.clip(&r);
+
+ plot.fill(x0, y0, x1, y1, 0x00000000);
+ plot.disc(x1, y1, 8, 0x000000ff, false);
+
+ r.x0 = 0;
+ r.y0 = 0;
+ r.x1 = 300;
+ r.y1 = 300;
+ plot.clip(&r);
+
+ y0+=30; y1+=30;
+
}
#include <Application.h>
@@ -632,28 +803,27 @@ static void test_plotters(void)
#include <Window.h>
class PTView : public BView {
public:
- PTView(BRect frame) : BView(frame, "view", B_FOLLOW_NONE, B_WILL_DRAW) {};
- virtual ~PTView() {};
- virtual void Draw(BRect update)
- {
- test_plotters();
- };
+ PTView(BRect frame) : BView(frame, "view", B_FOLLOW_NONE, B_WILL_DRAW) {};
+ virtual ~PTView() {};
+ virtual void Draw(BRect update)
+ {
+ test_plotters();
+ };
};
extern "C" void test_plotters_main(void);
void test_plotters_main(void)
{
- BApplication app("application/x-vnd.NetSurf");
- memcpy(&plot, &nsbeos_plotters, sizeof(plot));
- BRect frame(0,0,300,300);
- PTView *view = new PTView(frame);
- frame.OffsetBySelf(100,100);
- BWindow *win = new BWindow(frame, "NetSurfPlotterTest", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE);
- win->AddChild(view);
- nsbeos_current_gc_set(view);
- win->Show();
- app.Run();
+ BApplication app("application/x-vnd.NetSurf");
+ memcpy(&plot, &nsbeos_plotters, sizeof(plot));
+ BRect frame(0,0,300,300);
+ PTView *view = new PTView(frame);
+ frame.OffsetBySelf(100,100);
+ BWindow *win = new BWindow(frame, "NetSurfPlotterTest", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE);
+ win->AddChild(view);
+ nsbeos_current_gc_set(view);
+ win->Show();
+ app.Run();
}
#endif /* TEST_PLOTTERS */
-
diff --git a/frontends/beos/res/adblock.css b/frontends/beos/res/adblock.css
index ff2485622..0d12aaa7c 120000
--- a/frontends/beos/res/adblock.css
+++ b/frontends/beos/res/adblock.css
@@ -1 +1 @@
-../../../!NetSurf/Resources/AdBlock,f79 \ No newline at end of file
+../../../resources/adblock.css \ No newline at end of file
diff --git a/frontends/beos/res/ca-bundle.txt b/frontends/beos/res/ca-bundle.txt
index 0b0e416ad..1187fa51a 120000
--- a/frontends/beos/res/ca-bundle.txt
+++ b/frontends/beos/res/ca-bundle.txt
@@ -1 +1 @@
-../../../!NetSurf/Resources/ca-bundle \ No newline at end of file
+../../../resources/ca-bundle \ No newline at end of file
diff --git a/frontends/beos/res/de/welcome.html b/frontends/beos/res/de/welcome.html
index 98a53b215..b77e23743 120000
--- a/frontends/beos/res/de/welcome.html
+++ b/frontends/beos/res/de/welcome.html
@@ -1 +1 @@
-../../../../!NetSurf/Resources/de/welcome.html,faf \ No newline at end of file
+../../../../resources/de/welcome.html \ No newline at end of file
diff --git a/frontends/beos/res/default.css b/frontends/beos/res/default.css
index a8579eb7c..fa3ae6c26 120000
--- a/frontends/beos/res/default.css
+++ b/frontends/beos/res/default.css
@@ -1 +1 @@
-../../../!NetSurf/Resources/CSS,f79 \ No newline at end of file
+../../../resources/default.css \ No newline at end of file
diff --git a/frontends/beos/res/en/credits.html b/frontends/beos/res/en/credits.html
index 252516fd7..f73ecd4aa 120000
--- a/frontends/beos/res/en/credits.html
+++ b/frontends/beos/res/en/credits.html
@@ -1 +1 @@
-../../../../!NetSurf/Resources/en/credits.html,faf \ No newline at end of file
+../../../../resources/en/credits.html \ No newline at end of file
diff --git a/frontends/beos/res/en/licence.html b/frontends/beos/res/en/licence.html
index 79f73669b..0c3b430b7 120000
--- a/frontends/beos/res/en/licence.html
+++ b/frontends/beos/res/en/licence.html
@@ -1 +1 @@
-../../../../!NetSurf/Resources/en/licence.html,faf \ No newline at end of file
+../../../../resources/en/licence.html \ No newline at end of file
diff --git a/frontends/beos/res/en/maps.html b/frontends/beos/res/en/maps.html
index bb3ffcbe7..507a4b248 120000
--- a/frontends/beos/res/en/maps.html
+++ b/frontends/beos/res/en/maps.html
@@ -1 +1 @@
-../../../../!NetSurf/Resources/en/maps.html,faf \ No newline at end of file
+../../../../resources/en/maps.html \ No newline at end of file
diff --git a/frontends/beos/res/en/welcome.html b/frontends/beos/res/en/welcome.html
index 601099223..543f31ddd 120000
--- a/frontends/beos/res/en/welcome.html
+++ b/frontends/beos/res/en/welcome.html
@@ -1 +1 @@
-../../../../!NetSurf/Resources/en/welcome.html,faf \ No newline at end of file
+../../../../resources/en/welcome.html \ No newline at end of file
diff --git a/frontends/beos/res/icons b/frontends/beos/res/icons
index c7f860352..94d2dc0df 120000
--- a/frontends/beos/res/icons
+++ b/frontends/beos/res/icons
@@ -1 +1 @@
-../../../!NetSurf/Resources/Icons \ No newline at end of file
+../../../resources/icons \ No newline at end of file
diff --git a/frontends/beos/res/internal.css b/frontends/beos/res/internal.css
index 17f9f1504..5583a9811 120000
--- a/frontends/beos/res/internal.css
+++ b/frontends/beos/res/internal.css
@@ -1 +1 @@
-../../../!NetSurf/Resources/internal.css,f79 \ No newline at end of file
+../../../resources/internal.css \ No newline at end of file
diff --git a/frontends/beos/res/it/credits.html b/frontends/beos/res/it/credits.html
index 64b78982e..2b7c99542 120000
--- a/frontends/beos/res/it/credits.html
+++ b/frontends/beos/res/it/credits.html
@@ -1 +1 @@
-../../../../!NetSurf/Resources/it/credits.html,faf \ No newline at end of file
+../../../../resources/it/credits.html \ No newline at end of file
diff --git a/frontends/beos/res/it/licence.html b/frontends/beos/res/it/licence.html
index 4abc825d3..92afce85b 120000
--- a/frontends/beos/res/it/licence.html
+++ b/frontends/beos/res/it/licence.html
@@ -1 +1 @@
-../../../../!NetSurf/Resources/it/licence.html,faf \ No newline at end of file
+../../../../resources/it/licence.html \ No newline at end of file
diff --git a/frontends/beos/res/it/welcome.html b/frontends/beos/res/it/welcome.html
index 59cef0551..2673ba948 120000
--- a/frontends/beos/res/it/welcome.html
+++ b/frontends/beos/res/it/welcome.html
@@ -1 +1 @@
-../../../../!NetSurf/Resources/it/welcome.html,faf \ No newline at end of file
+../../../../resources/it/welcome.html \ No newline at end of file
diff --git a/frontends/beos/res/ja/welcome.html b/frontends/beos/res/ja/welcome.html
index a2556ee4e..8b603f3df 120000
--- a/frontends/beos/res/ja/welcome.html
+++ b/frontends/beos/res/ja/welcome.html
@@ -1 +1 @@
-../../../../!NetSurf/Resources/ja/welcome.html,faf \ No newline at end of file
+../../../../resources/ja/welcome.html \ No newline at end of file
diff --git a/frontends/beos/res/netsurf.png b/frontends/beos/res/netsurf.png
index 905512c25..d0ab72a5e 120000
--- a/frontends/beos/res/netsurf.png
+++ b/frontends/beos/res/netsurf.png
@@ -1 +1 @@
-../../../!NetSurf/Resources/netsurf.png,b60 \ No newline at end of file
+../../../resources/netsurf.png \ No newline at end of file
diff --git a/frontends/beos/res/quirks.css b/frontends/beos/res/quirks.css
index 88aabe48c..1e752cb9e 120000
--- a/frontends/beos/res/quirks.css
+++ b/frontends/beos/res/quirks.css
@@ -1 +1 @@
-../../../!NetSurf/Resources/Quirks,f79 \ No newline at end of file
+../../../resources/quirks.css \ No newline at end of file
diff --git a/frontends/beos/scaffolding.cpp b/frontends/beos/scaffolding.cpp
index 5e386bdaa..e6fb6e5a1 100644
--- a/frontends/beos/scaffolding.cpp
+++ b/frontends/beos/scaffolding.cpp
@@ -608,8 +608,10 @@ NSBaseView::Instantiate(BMessage *archive)
struct replicant_thread_info *info = new replicant_thread_info;
info->url = BString(url);
- if (nsbeos_find_app_path(info->app) < B_OK)
+ if (nsbeos_find_app_path(info->app) < B_OK) {
+ delete info;
return NULL;
+ }
info->args[0] = info->app;
info->args[1] = (char *)info->url.String();
info->args[2] = NULL;
@@ -794,7 +796,7 @@ int32 nsbeos_replicant_main_thread(void *_arg)
static void nsbeos_window_destroy_event(NSBrowserWindow *window, nsbeos_scaffolding *g, BMessage *event)
{
- LOG("Being Destroyed = %d", g->being_destroyed);
+ NSLOG(netsurf, INFO, "Being Destroyed = %d", g->being_destroyed);
if (--open_windows == 0)
nsbeos_done = true;
@@ -852,7 +854,9 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
bw = nsbeos_get_browser_for_gui(scaffold->top_level);
bool reloadAll = false;
- LOG("nsbeos_scaffolding_dispatch_event() what = 0x%08lx", message->what);
+ NSLOG(netsurf, INFO,
+ "nsbeos_scaffolding_dispatch_event() what = 0x%08lx",
+ message->what);
switch (message->what) {
case B_QUIT_REQUESTED:
nsbeos_scaffolding_destroy(scaffold);
@@ -995,7 +999,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
browser_window_key_press(bw, NS_KEY_PASTE);
break;
case B_SELECT_ALL:
- LOG("Selecting all text");
+ NSLOG(netsurf, INFO, "Selecting all text");
browser_window_key_press(bw, NS_KEY_SELECT_ALL);
break;
case B_NETPOSITIVE_BACK:
@@ -1357,7 +1361,8 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
void nsbeos_scaffolding_destroy(nsbeos_scaffolding *scaffold)
{
- LOG("Being Destroyed = %d", scaffold->being_destroyed);
+ NSLOG(netsurf, INFO, "Being Destroyed = %d",
+ scaffold->being_destroyed);
if (scaffold->being_destroyed) return;
scaffold->being_destroyed = 1;
nsbeos_window_destroy_event(scaffold->window, scaffold, NULL);
@@ -1442,7 +1447,7 @@ static void recursively_set_menu_items_target(BMenu *menu, BHandler *handler)
void nsbeos_attach_toplevel_view(nsbeos_scaffolding *g, BView *view)
{
- LOG("Attaching view to scaffolding %p", g);
+ NSLOG(netsurf, INFO, "Attaching view to scaffolding %p", g);
// this is a replicant,... and it went bad
if (!g->window) {
@@ -1720,7 +1725,8 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
{
struct beos_scaffolding *g = (struct beos_scaffolding *)malloc(sizeof(*g));
- LOG("Constructing a scaffold of %p for gui_window %p", g, toplevel);
+ NSLOG(netsurf, INFO,
+ "Constructing a scaffold of %p for gui_window %p", g, toplevel);
g->top_level = toplevel;
g->being_destroyed = 0;
diff --git a/frontends/beos/schedule.cpp b/frontends/beos/schedule.cpp
index e96e56d81..7877a838b 100644
--- a/frontends/beos/schedule.cpp
+++ b/frontends/beos/schedule.cpp
@@ -28,11 +28,7 @@ extern "C" {
#include "netsurf/content_type.h"
#include "netsurf/browser_window.h"
-#ifdef DEBUG_BEOS_SCHEDULE
#include "utils/log.h"
-#else
-#define LOG(x...)
-#endif
}
/** Killable callback closure embodiment. */
@@ -58,7 +54,10 @@ nsbeos_schedule_kill_callback(void *_target, void *_match)
_nsbeos_callback_t *match = (_nsbeos_callback_t *)_match;
if ((target->callback == match->callback) &&
(target->context == match->context)) {
- LOG("Found match for %p(%p), killing.", target->callback, target->context);
+ NSLOG(schedule, DEBUG,
+ "Found match for %p(%p), killing.",
+ target->callback,
+ target->context);
target->callback = NULL;
target->context = NULL;
target->callback_killed = true;
@@ -69,7 +68,9 @@ nsbeos_schedule_kill_callback(void *_target, void *_match)
static void
schedule_remove(void (*callback)(void *p), void *p)
{
- LOG("schedule_remove() for %p(%p)", cb->callback, cb->context);
+ NSLOG(schedule, DEBUG,
+ "schedule_remove() for %p(%p)",
+ callback, p);
if (callbacks == NULL)
return;
_nsbeos_callback_t cb_match;
@@ -81,7 +82,7 @@ schedule_remove(void (*callback)(void *p), void *p)
nserror beos_schedule(int t, void (*callback)(void *p), void *p)
{
- LOG("t:%d cb:%p p:%p", t, cb->callback, cb->context);
+ NSLOG(schedule, DEBUG, "t:%d cb:%p p:%p", t, callback, p);
if (callbacks == NULL) {
callbacks = new BList;
@@ -111,7 +112,7 @@ nserror beos_schedule(int t, void (*callback)(void *p), void *p)
bool
schedule_run(void)
{
- LOG("schedule_run()");
+ NSLOG(schedule, DEBUG, "schedule_run()");
earliest_callback_timeout = B_INFINITE_TIMEOUT;
if (callbacks == NULL)
@@ -120,7 +121,9 @@ schedule_run(void)
bigtime_t now = system_time();
int32 i;
- LOG("Checking %ld callbacks to for deadline.", this_run->CountItems());
+ NSLOG(schedule, DEBUG,
+ "Checking %ld callbacks to for deadline.",
+ callbacks->CountItems());
/* Run all the callbacks which made it this far. */
for (i = 0; i < callbacks->CountItems(); ) {
@@ -132,7 +135,11 @@ schedule_run(void)
i++;
continue;
}
- LOG("Running callbacks %p(%p).", cb->callback, cb->context);
+ NSLOG(schedule, DEBUG,
+ "Running callbacks %p(%p).",
+ cb->callback,
+ cb->context);
+
if (!cb->callback_killed)
cb->callback(cb->context);
callbacks->RemoveItem(cb);
diff --git a/frontends/beos/throbber.cpp b/frontends/beos/throbber.cpp
index fe40b3edc..315afef83 100644
--- a/frontends/beos/throbber.cpp
+++ b/frontends/beos/throbber.cpp
@@ -50,18 +50,21 @@ bool nsbeos_throbber_initialise_from_png(const int frames, ...)
if (frames < 2) {
/* we need at least two frames - one for idle, one for active */
- LOG("Insufficent number of frames in throbber animation!");
- LOG("(called with %d frames, where 2 is a minimum.)", frames);
+ NSLOG(netsurf, INFO,
+ "Insufficent number of frames in throbber animation!");
+ NSLOG(netsurf, INFO,
+ "(called with %d frames, where 2 is a minimum.)",
+ frames);
return false;
}
BResources *res = get_app_resources();
if (res == NULL) {
- LOG("Can't find resources for throbber!");
+ NSLOG(netsurf, INFO, "Can't find resources for throbber!");
return false;
}
- throb = (struct nsbeos_throbber *)malloc(sizeof(throb));
+ throb = (struct nsbeos_throbber *)malloc(sizeof(*throb));
throb->nframes = frames;
throb->framedata = (BBitmap **)malloc(sizeof(BBitmap *) * throb->nframes);
@@ -74,14 +77,17 @@ bool nsbeos_throbber_initialise_from_png(const int frames, ...)
data = res->LoadResource('data', fn, &size);
throb->framedata[i] = NULL;
if (!data) {
- LOG("Error when loading resource %s", fn);
+ NSLOG(netsurf, INFO, "Error when loading resource %s",
+ fn);
errors_when_loading = true;
continue;
}
BMemoryIO mem(data, size);
throb->framedata[i] = BTranslationUtils::GetBitmap(&mem);
if (throb->framedata[i] == NULL) {
- LOG("Error when loading %s: GetBitmap() returned NULL", fn);
+ NSLOG(netsurf, INFO,
+ "Error when loading %s: GetBitmap() returned NULL",
+ fn);
errors_when_loading = true;
}
}
diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp
index fbf7b1652..f4229207b 100644
--- a/frontends/beos/window.cpp
+++ b/frontends/beos/window.cpp
@@ -354,7 +354,8 @@ static struct gui_window *gui_window_create(struct browser_window *bw,
return 0;
}
- LOG("Creating gui window %p for browser window %p", g, bw);
+ NSLOG(netsurf, INFO, "Creating gui window %p for browser window %p",
+ g, bw);
g->bw = bw;
g->mouse.state = 0;
@@ -436,25 +437,27 @@ void nsbeos_dispatch_event(BMessage *message)
continue;
if (gui && gui != z) {
- LOG("discarding event for destroyed gui_window");
+ NSLOG(netsurf, INFO,
+ "discarding event for destroyed gui_window");
delete message;
return;
}
if (scaffold && (!y || scaffold != y->scaffold)) {
- LOG("discarding event for destroyed scaffolding");
+ NSLOG(netsurf, INFO,
+ "discarding event for destroyed scaffolding");
delete message;
return;
}
// messages for top-level
if (scaffold) {
- LOG("dispatching to top-level");
+ NSLOG(netsurf, INFO, "dispatching to top-level");
nsbeos_scaffolding_dispatch_event(scaffold, message);
delete message;
return;
}
- //LOG("processing message");
+ NSLOG(netsurf, DEEPDEBUG, "processing message");
switch (message->what) {
case B_QUIT_REQUESTED:
// from the BApplication
@@ -763,7 +766,8 @@ void nsbeos_window_keypress_event(BView *view, gui_window *g, BMessage *event)
if (!numbytes)
numbytes = strlen(bytes);
- LOG("mods 0x%08lx key %ld raw %ld byte[0] %d", mods, key, raw_char, buff[0]);
+ NSLOG(netsurf, INFO, "mods 0x%08lx key %ld raw %ld byte[0] %d", mods,
+ key, raw_char, buff[0]);
char byte;
if (numbytes == 1) {
@@ -911,28 +915,6 @@ void nsbeos_reflow_all_windows(void)
}
-
-/**
- * callback from core to reformat a window.
- */
-static void beos_window_reformat(struct gui_window *g)
-{
- if (g == NULL) {
- return;
- }
-
- NSBrowserFrameView *view = g->view;
- if (view && view->LockLooper()) {
- BRect bounds = view->Bounds();
- view->UnlockLooper();
-#warning XXX why - 1 & - 2 !???
- browser_window_reformat(g->bw,
- false,
- bounds.Width() + 1 /* - 2*/,
- bounds.Height() + 1);
- }
-}
-
void nsbeos_window_destroy_browser(struct gui_window *g)
{
browser_window_destroy(g->bw);
@@ -952,10 +934,10 @@ static void gui_window_destroy(struct gui_window *g)
g->next->prev = g->prev;
- LOG("Destroying gui_window %p", g);
+ NSLOG(netsurf, INFO, "Destroying gui_window %p", g);
assert(g != NULL);
assert(g->bw != NULL);
- LOG(" Scaffolding: %p", g->scaffold);
+ NSLOG(netsurf, INFO, " Scaffolding: %p", g->scaffold);
if (g->view == NULL)
return;
@@ -1000,39 +982,39 @@ void nsbeos_redraw_caret(struct gui_window *g)
g->view->UnlockLooper();
}
-static void gui_window_redraw_window(struct gui_window *g)
-{
- if (g->view == NULL)
- return;
- if (!g->view->LockLooper())
- return;
-
- nsbeos_current_gc_set(g->view);
-
- g->view->Invalidate();
-
- nsbeos_current_gc_set(NULL);
- g->view->UnlockLooper();
-}
-
-static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
+/**
+ * Invalidate an area of a beos browser window
+ *
+ * \param g The netsurf window being invalidated.
+ * \param rect area to redraw or NULL for entrire window area.
+ * \return NSERROR_OK or appropriate error code.
+ */
+static nserror
+beos_window_invalidate_area(struct gui_window *g, const struct rect *rect)
{
- if (browser_window_has_content(g->bw) == false)
- return;
+ if (browser_window_has_content(g->bw) == false) {
+ return NSERROR_OK;
+ }
- if (g->view == NULL)
- return;
- if (!g->view->LockLooper())
- return;
+ if (g->view == NULL) {
+ return NSERROR_OK;
+ }
- nsbeos_current_gc_set(g->view);
+ if (!g->view->LockLooper()) {
+ return NSERROR_OK;
+ }
-//XXX +1 ??
- g->view->Invalidate(BRect(rect->x0, rect->y0,
- rect->x1 - 1, rect->y1 - 1));
+ if (rect != NULL) {
+ //XXX +1 ??
+ g->view->Invalidate(BRect(rect->x0, rect->y0,
+ rect->x1 - 1, rect->y1 - 1));
+ } else {
+ g->view->Invalidate();
+ }
- nsbeos_current_gc_set(NULL);
g->view->UnlockLooper();
+
+ return NSERROR_OK;
}
static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
@@ -1053,21 +1035,39 @@ static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return true;
}
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+/**
+ * Set the scroll position of a beos browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The beos implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param g gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
//CALLED();
- if (g->view == NULL)
- return;
- if (!g->view->LockLooper())
- return;
+ if (g->view == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (!g->view->LockLooper()) {
+ return NSERROR_BAD_PARAMETER;
+ }
#warning XXX: report to view frame ?
- if (g->view->ScrollBar(B_HORIZONTAL))
- g->view->ScrollBar(B_HORIZONTAL)->SetValue(sx);
- if (g->view->ScrollBar(B_VERTICAL))
- g->view->ScrollBar(B_VERTICAL)->SetValue(sy);
+ if (g->view->ScrollBar(B_HORIZONTAL)) {
+ g->view->ScrollBar(B_HORIZONTAL)->SetValue(rect->x0);
+ }
+ if (g->view->ScrollBar(B_VERTICAL)) {
+ g->view->ScrollBar(B_VERTICAL)->SetValue(rect->y0);
+ }
g->view->UnlockLooper();
+
+ return NSERROR_OK;
}
@@ -1094,8 +1094,9 @@ static void gui_window_update_extent(struct gui_window *g)
x_max -= g->view->Bounds().Width() + 1;
y_max -= g->view->Bounds().Height() + 1;
- LOG("x_max = %d y_max = %d x_prop = %f y_prop = %f\n",
- x_max, y_max, x_prop, y_prop);
+ NSLOG(netsurf, INFO,
+ "x_max = %d y_max = %d x_prop = %f y_prop = %f\n", x_max,
+ y_max, x_prop, y_prop);
if (g->view->ScrollBar(B_HORIZONTAL)) {
g->view->ScrollBar(B_HORIZONTAL)->SetRange(0, x_max);
@@ -1331,31 +1332,42 @@ static struct gui_clipboard_table clipboard_table = {
struct gui_clipboard_table *beos_clipboard_table = &clipboard_table;
-static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
- bool scaled)
+/**
+ * Find the current dimensions of a beos browser window content area.
+ *
+ * \param g The gui window to measure content area of.
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ * \return NSERROR_OK on sucess and width and height updated
+ * else error code.
+ */
+static nserror
+gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
+ bool scaled)
{
- if (g->view && g->view->LockLooper()) {
- *width = g->view->Bounds().Width() + 1;
- *height = g->view->Bounds().Height() + 1;
- g->view->UnlockLooper();
- }
-
- if (scaled) {
- *width /= g->scale;
- *height /= g->scale;
- }
+ if (g->view &&
+ g->view->LockLooper()) {
+ *width = g->view->Bounds().Width() + 1;
+ *height = g->view->Bounds().Height() + 1;
+ g->view->UnlockLooper();
+
+ if (scaled) {
+ *width /= g->scale;
+ *height /= g->scale;
+ }
+ }
+ return NSERROR_OK;
}
static struct gui_window_table window_table = {
gui_window_create,
gui_window_destroy,
- gui_window_redraw_window,
- gui_window_update_box,
+ beos_window_invalidate_area,
gui_window_get_scroll,
gui_window_set_scroll,
gui_window_get_dimensions,
gui_window_update_extent,
- beos_window_reformat,
/* from scaffold */
gui_window_set_title,
@@ -1369,7 +1381,6 @@ static struct gui_window_table window_table = {
gui_window_stop_throbber,
NULL, //drag_start
NULL, //save_link
- NULL, //scroll_visible
NULL, //scroll_start
gui_window_new_content,
NULL, //create_form_select_menu