summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
Diffstat (limited to 'riscos')
-rw-r--r--riscos/gui.c29
-rw-r--r--riscos/gui.h9
-rw-r--r--riscos/theme.c408
-rw-r--r--riscos/theme.h89
-rw-r--r--riscos/uri.c3
-rw-r--r--riscos/window.c99
6 files changed, 181 insertions, 456 deletions
diff --git a/riscos/gui.c b/riscos/gui.c
index e0d9ae8de..3b28592a2 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -125,7 +125,7 @@ void gui_init(int argc, char** argv)
OPTIONS.theme = strdup("Default");
sprintf(theme_fname, "<NetSurf$Dir>.Themes.Default");
}
- current_theme = ro_theme_create(theme_fname);
+ ro_theme_load(theme_fname);
wimp_open_template("<NetSurf$Dir>.Resources.en.Templates");
ro_gui_dialog_init();
@@ -231,14 +231,9 @@ void gui_poll(bool active)
if (g != NULL)
ro_gui_window_redraw(g, &(block.redraw));
else {
- g = ro_lookup_gui_toolbar_from_w(block.redraw.w);
- if (g != NULL) {
- ro_gui_toolbar_redraw(g, &(block.redraw));
- } else {
- osbool more = wimp_redraw_window(&block.redraw);
- while (more)
- more = wimp_get_rectangle(&block.redraw);
- }
+ osbool more = wimp_redraw_window(&block.redraw);
+ while (more)
+ more = wimp_get_rectangle(&block.redraw);
}
}
break;
@@ -411,14 +406,9 @@ void gui_multitask(void)
if (g)
ro_gui_window_redraw(g, &(block.redraw));
else {
- g = ro_lookup_gui_toolbar_from_w(block.redraw.w);
- if (g)
- ro_gui_toolbar_redraw(g, &(block.redraw));
- else {
- osbool more = wimp_redraw_window(&block.redraw);
- while (more)
- more = wimp_get_rectangle(&block.redraw);
- }
+ osbool more = wimp_redraw_window(&block.redraw);
+ while (more)
+ more = wimp_get_rectangle(&block.redraw);
}
}
break;
@@ -581,7 +571,7 @@ void ro_gui_icon_bar_click(wimp_pointer* pointer)
gui_window_show(bw->window);
browser_window_open_location(bw, HOME_URL);
wimp_set_caret_position(bw->window->data.browser.toolbar,
- ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_URL"),
+ ICON_TOOLBAR_URL,
0,0,-1, (int) strlen(bw->window->url) - 1);
}
}
@@ -930,8 +920,7 @@ void ro_gui_open_help_page (void)
gui_window_show(bw->window);
browser_window_open_location(bw, HELP_URL);
wimp_set_caret_position(bw->window->data.browser.toolbar,
- ro_theme_icon(current_theme, THEME_TOOLBAR,
- "TOOLBAR_URL"),
+ ICON_TOOLBAR_URL,
0,0,-1, (int) strlen(bw->window->url) - 1);
}
diff --git a/riscos/gui.h b/riscos/gui.h
index e831d9f07..1883e53b4 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -3,6 +3,7 @@
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
+ * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
*/
#ifndef _NETSURF_RISCOS_GUI_H_
@@ -61,6 +62,7 @@ struct gui_window
gui_window* next;
int throbber;
+ char throb_buf[12];
float throbtime;
gui_safety redraw_safety;
@@ -134,7 +136,6 @@ void ro_gui_window_click(gui_window* g, wimp_pointer* mouse);
void ro_gui_window_open(gui_window* g, wimp_open* open);
void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw);
void ro_gui_window_mouse_at(wimp_pointer* pointer);
-void ro_gui_toolbar_redraw(gui_window* g, wimp_draw* redraw);
void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer);
void ro_gui_throb(void);
gui_window* ro_lookup_gui_from_w(wimp_w window);
@@ -149,6 +150,12 @@ void ro_gui_history_redraw(wimp_draw *redraw);
void ro_gui_history_click(wimp_pointer *pointer);
/* icon numbers */
+#define ICON_TOOLBAR_THROBBER 1
+#define ICON_TOOLBAR_URL 2
+#define ICON_TOOLBAR_STATUS 3
+#define ICON_TOOLBAR_HISTORY 4
+#define ICON_TOOLBAR_RELOAD 5
+
#define ICON_CONFIG_SAVE 0
#define ICON_CONFIG_CANCEL 1
#define ICON_CONFIG_BROWSER 2
diff --git a/riscos/theme.c b/riscos/theme.c
index 34f66fa19..25cc6eb67 100644
--- a/riscos/theme.c
+++ b/riscos/theme.c
@@ -3,324 +3,148 @@
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
+ * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
*/
-#include "netsurf/riscos/theme.h"
-#include "oslib/wimp.h"
-#include "oslib/messagetrans.h"
-#include "oslib/osspriteop.h"
+/** \file
+ * Toolbar themes (implementation).
+ */
+
+#include <assert.h>
+#include <stdio.h>
#include <string.h>
+#include "oslib/osfile.h"
+#include "oslib/osspriteop.h"
+#include "oslib/wimp.h"
+#include "netsurf/riscos/gui.h"
+#include "netsurf/riscos/theme.h"
#include "netsurf/utils/utils.h"
-#include <stdio.h>
-
-ro_theme* current_theme = NULL;
-
-void ro_theme_preload_template(ro_theme* theme, char* template_name,
- int* total_winicon, int* total_indirected)
-{
- int winicon, indirected;
- if (wimp_load_template(0,0,0, (byte*)0xffffffff, template_name,0, &winicon, &indirected) == 0)
- fprintf(stderr, "Template not found!!!!!!!!!!!\n");
- *total_winicon = *total_winicon + winicon + 32;
- *total_indirected = *total_indirected + indirected + 32;
- return;
-}
-
-wimp_window* ro_theme_load_template(ro_theme* theme, char* template_name, char** indirected_ptr, char* indirected_end)
-{
- int winicon, indirected;
- int temp;
- wimp_window* window;
- char* old_indirected = *indirected_ptr;
-
- if (wimp_load_template(0,0,0, (byte*)0xffffffff, template_name, 0, &winicon, &indirected) == 0)
- fprintf(stderr, "Template not found!!!!!!!!!!!\n");
-fprintf(stderr, "Allocating %d bytes for window / icon data:\n",winicon);
-fprintf(stderr, "Require %d bytes for indirected data:\n",indirected);
-fprintf(stderr, "Indirected before %d:\n",(int)indirected_ptr);
- window = (wimp_window*) xcalloc(winicon + 1024, 1);
- if (wimp_load_template(window, (*indirected_ptr), indirected_end,
- (byte*)0xffffffff, template_name, 0, &temp, &temp) == 0)
- fprintf(stderr, "Template not found!!!!!!!!!!!\n");
+static wimp_window *theme_toolbar_template = 0;
+static osspriteop_area *theme_sprite_area = 0;
+unsigned int theme_throbs;
- *indirected_ptr = *indirected_ptr + indirected;
-fprintf(stderr, "Indirected after %d:\n",(int)*indirected_ptr);
-fprintf(stderr, "Difference: %d\n",(int)*indirected_ptr - (int)old_indirected);
- //*winicon_ptr = old_winicon + winicon + 8 - ((int)(old_winicon + winicon) % 4);
-
-// *indirected_ptr = old_indirected + indirected + 8 - ((int)(old_indirected + indirected) % 4);
-
- return window;
-}
+/**
+ * Load a theme from a directory.
+ *
+ * The directory must contain a Templates file containing the toolbar template,
+ * and a Sprites file containing icons.
+ */
-ro_theme* ro_theme_create(char* pathname)
+void ro_theme_load(char *pathname)
{
- char filename[1024];
-
- int winicon, indirected;
- char* winicon_ptr;
- char* indirected_ptr;
-
- ro_theme* theme;
- messagetrans_file_flags flags;
- int size;
-
- FILE * fp;
- int i;
-
-
- theme = (ro_theme*) xcalloc(sizeof(ro_theme), 1);
-
-fprintf(stderr, "Loading templates...\n");
- sprintf(filename, "%s.Templates", pathname);
-fprintf(stderr, "%s\n",filename);
-
- winicon = 0;
- indirected = 0;
-
- wimp_open_template(filename);
-fprintf(stderr, "Preload theme_info\n");
- ro_theme_preload_template(theme, "theme_info\0 ", &winicon, &indirected);
-fprintf(stderr, "Preload toolbar\n");
- ro_theme_preload_template(theme, "toolbar\0 ", &winicon, &indirected);
-
-fprintf(stderr, "Allocate %d bytes of indirected data\n",indirected + 16);
- theme->indirected_data = xcalloc(sizeof(char), indirected + 16);
- indirected_ptr = theme->indirected_data;
-fprintf(stderr, "Allocate %d bytes of window and icon data\n",winicon + 16);
-// theme->window_and_icon_data = xcalloc(sizeof(char), winicon + 16);
-// winicon_ptr = theme->window_and_icon_data;
-
-fprintf(stderr, "Load toolbar\n");
- theme->toolbar =
- ro_theme_load_template(theme, "toolbar\0 ", &indirected_ptr, theme->indirected_data + indirected + 16);
-fprintf(stderr, "Load theme_info\n");
- theme->theme_info =
- ro_theme_load_template(theme, "theme_info\0 ", &indirected_ptr, theme->indirected_data + indirected + 16);
-
-fprintf(stderr, "Close template\n");
- wimp_close_template();
-
-fprintf(stderr, "Loading icon names...\n");
- sprintf(filename, "%s.IconNames", pathname);
-fprintf(stderr, "%s\n", filename);
- messagetrans_file_info(filename, &flags, &size);
-
-fprintf(stderr, "Allocating %d bytes for icon names data\n", size);
- theme->iconNames.data = xcalloc(size, sizeof(char));
-fprintf(stderr, "Allocating %d bytes for filename\n", strlen(filename)+2);
- theme->iconNames.filename = xcalloc(strlen(filename)+2, sizeof(char));
- strcpy(theme->iconNames.filename, filename);
-fprintf(stderr, "Opening messagetrans file\n");
- messagetrans_open_file(&theme->iconNames.cb, theme->iconNames.filename,
- theme->iconNames.data);
-
-
-
-fprintf(stderr, "Loading icon sizes...\n");
- sprintf(filename, "%s.IconSizes", pathname);
-fprintf(stderr, "%s\n", filename);
- messagetrans_file_info(filename, &flags, &size);
-
-fprintf(stderr, "Allocating %d bytes for icon sizes data\n", size);
- theme->iconSizes.data = xcalloc(size, sizeof(char));
-fprintf(stderr, "Allocating %d bytes for filename\n", strlen(filename)+2);
- theme->iconSizes.filename = xcalloc(strlen(filename)+2, sizeof(char));
- strcpy(theme->iconSizes.filename, filename);
-fprintf(stderr, "Opening messagetrans file\n");
- messagetrans_open_file(&theme->iconSizes.cb, theme->iconSizes.filename,
- theme->iconSizes.data);
-
-
-
- sprintf(filename, "%s.Sprites", pathname);
- fp = fopen(filename, "rb");
- if (fp == 0) die("Failed to open file");
- if (fseek(fp, 0, SEEK_END) != 0) die("fseek() failed");
- if ((size = (int) ftell(fp)) == -1) die("ftell() failed");
- fclose(fp);
-
- theme->sprites = xcalloc(size + 16, 1);
- if (theme->sprites == NULL)
- die("Can't claim memory for theme sprites");
-
- theme->sprites->size = size + 16;
- theme->sprites->sprite_count = 0;
- theme->sprites->first = 16;
- theme->sprites->used = 16;
- osspriteop_clear_sprites(osspriteop_USER_AREA, theme->sprites);
- osspriteop_load_sprite_file(osspriteop_USER_AREA, theme->sprites, filename);
-
- fprintf(stderr, "sprites loaded. %d counted\n", theme->sprites->sprite_count);
- theme->throbs = 0;
- for (i = 1; i <= theme->sprites->sprite_count; i++)
- {
- char name[32];
- fprintf(stderr, "returning name for %d\n", i);
- osspriteop_return_name(osspriteop_USER_AREA, theme->sprites, name, 32, i);
- if (strncmp(name, "throbber", 8) == 0)
- {
- int this_number = atoi(name+8);
- if (this_number > theme->throbs)
- theme->throbs = this_number;
- }
- }
- fprintf(stderr, "%d throbbers found.\n", theme->throbs);
-
-fprintf(stderr, "Returning theme...\n");
- return theme;
+ char name[] = "toolbar";
+ int context, window_size, data_size, size, i;
+ static char *data = 0;
+ char filename[strlen(pathname) + 12];
+ fileswitch_object_type obj_type;
+
+ /* free old theme data */
+ free(theme_toolbar_template);
+ free(data);
+ free(theme_sprite_area);
+
+ /* load template */
+ sprintf(filename, "%s.Templates", pathname);
+ wimp_open_template(filename);
+
+ /* find required buffer sizes */
+ context = wimp_load_template(wimp_GET_SIZE, 0, 0, wimp_NO_FONTS,
+ name, 0, &window_size, &data_size);
+ assert(context != 0);
+
+ theme_toolbar_template = xcalloc((unsigned int) window_size, 1);
+ data = xcalloc((unsigned int) data_size, 1);
+
+ /* load */
+ wimp_load_template(theme_toolbar_template, data, data + data_size,
+ wimp_NO_FONTS, name, 0, 0, 0);
+
+ wimp_close_template();
+
+ assert(ICON_TOOLBAR_RELOAD < theme_toolbar_template->icon_count);
+ theme_toolbar_template->flags |= wimp_WINDOW_FURNITURE_WINDOW;
+ theme_toolbar_template->icons[ICON_TOOLBAR_URL].data.indirected_text.size = 256;
+ theme_toolbar_template->icons[ICON_TOOLBAR_STATUS].data.indirected_text.size = 256;
+
+ /* load sprites */
+ sprintf(filename, "%s.Sprites", pathname);
+ obj_type = osfile_read_no_path(filename, 0, 0, &size, 0);
+ assert(obj_type & fileswitch_IS_FILE);
+
+ theme_sprite_area = xcalloc(size + 16, 1);
+ theme_sprite_area->size = size + 16;
+ theme_sprite_area->sprite_count = 0;
+ theme_sprite_area->first = 16;
+ theme_sprite_area->used = 16;
+ osspriteop_clear_sprites(osspriteop_USER_AREA, theme_sprite_area);
+ osspriteop_load_sprite_file(osspriteop_USER_AREA, theme_sprite_area,
+ filename);
+
+ theme_toolbar_template->sprite_area = theme_sprite_area;
+ theme_toolbar_template->icons[ICON_TOOLBAR_THROBBER].data.indirected_sprite.area =
+ theme_sprite_area;
+
+ /* find the highest sprite called throbber%i */
+ theme_throbs = 0;
+ for (i = 1; i != theme_sprite_area->sprite_count; i++) {
+ char name[32];
+ osspriteop_return_name(osspriteop_USER_AREA,
+ theme_sprite_area, name, 32, i);
+ if (strncmp(name, "throbber", 8) == 0) {
+ int n = atoi(name + 8);
+ if (theme_throbs < n)
+ theme_throbs = n;
+ }
+ }
}
-wimp_i ro_theme_icon(ro_theme* theme, theme_window_type type, const char* token)
-{
- int used;
- char buffer[32];
- messagetrans_lookup(&theme->iconNames.cb, token, buffer, 32, 0,0,0,0, &used);
- if (used > 0)
- return atoi(buffer);
- else
- return -1;
-}
+/**
+ * Create a toolbar from the current theme.
+ *
+ * The buffers url_buffer and status_buffer must be at least 256 bytes each,
+ * throbber_buffer at least 12 bytes;
+ */
-void ro_theme_set_indirected(ro_theme* theme, char* find, wimp_window* win, theme_window_type wintype, char* indirected)
+wimp_w ro_theme_create_toolbar(char *url_buffer, char *status_buffer,
+ char *throbber_buffer)
{
- int context = 0, used;
- char token[32];
+ wimp_w w;
-fprintf(stderr, "setting indirected text...\n");
-fprintf(stderr, "enumerating token '%s'\n", find);
+ theme_toolbar_template->icons[ICON_TOOLBAR_URL].data.indirected_text.text = url_buffer;
+ theme_toolbar_template->icons[ICON_TOOLBAR_STATUS].data.indirected_text.text = status_buffer;
+ theme_toolbar_template->icons[ICON_TOOLBAR_THROBBER].data.indirected_sprite.id =
+ (osspriteop_id) throbber_buffer;
- while (messagetrans_enumerate_tokens(&theme->iconNames.cb, find, token, 32, context, &used, &context))
- {
- fprintf(stderr, "finding theme icon to set indirected text\n");
- win->icons[ro_theme_icon(theme, wintype, token)].data.indirected_text.text = indirected;
- }
-fprintf(stderr, "<-- returning\n");
+ w = wimp_create_window(theme_toolbar_template);
+ return w;
}
-wimp_w ro_theme_create_window(ro_theme* theme, ro_theme_window* create)
-{
- wimp_window* win = NULL;
- if (create == NULL)
- return 0;
+/**
+ * Return the height of the current toolbar.
+ */
- if (create->type == THEME_TOOLBAR)
- {
- int i;
-fprintf(stderr, "Creating toolbar from theme (%d bytes)\n", sizeof(*theme->toolbar));
-for (i = 0; i < 152/4; i++)
+int ro_theme_toolbar_height(void)
{
- fprintf(stderr, "%d:\x09%d\n", i,((int*)(theme->toolbar))[i]);
+ return abs(theme_toolbar_template->extent.y1 - theme_toolbar_template->extent.y0);
}
- //win = xcalloc(1024, 1);
- //memcpy(win, theme->toolbar, 1024);
- win = theme->toolbar;
- win->flags = win->flags | wimp_WINDOW_FURNITURE_WINDOW;
-// win->next = wimp_TOP;
-// win->title_flags = wimp_ICON_TEXT;
- win->sprite_area = theme->sprites;
- ro_theme_set_indirected(theme, "TOOLBAR_URL*", win, THEME_TOOLBAR, create->data.toolbar.indirected_url);
- ro_theme_set_indirected(theme, "TOOLBAR_STATUS*", win, THEME_TOOLBAR, create->data.toolbar.indirected_status);
- }
- else if (create->type == THEME_THEMEINFO)
- {
-fprintf(stderr, "Creating theme_info from theme (%d bytes)\n", sizeof(*theme->theme_info));
-// win = xcalloc(sizeof(*theme->theme_info), 1);
-// memcpy(win, theme->toolbar, sizeof(*theme->theme_info));
- win = theme->theme_info;
- }
- if (win != NULL)
- {
- wimp_w w = wimp_create_window(win);
- //xfree(win);
- return w;
- }
- else
- return 0;
-}
-
-int ro_theme_toolbar_height(ro_theme* theme)
-{
- return abs(theme->toolbar->extent.y1 - theme->toolbar->extent.y0);
-}
+/**
+ * Resize the URL icon in a toolbar.
+ */
-void ro_theme_resize(ro_theme* theme, theme_window_type wintype, wimp_w w, int width, int height)
+void ro_theme_resize_toolbar(wimp_w w, int width, int height)
{
- int context = 0, used;
- char token[32];
- char* find;
- char formula[256];
- char buffer[256];
- char widths[32];
- char heights[32];
-
- sprintf(widths, "%d", width);
- sprintf(heights, "%d", height);
-
- if (wintype == THEME_TOOLBAR)
- find = "TOOLBAR_*";
- else
- return;
-
- while (messagetrans_enumerate_tokens(&theme->iconSizes.cb, find, token, 32, context, &used, &context))
- {
- char* x0;// = strstr(token, "_X0");
- char* x1;// = strstr(token, "_X1");
-
- x0 = strstr(token, "_X0");
- x1 = strstr(token, "_X1");
+ wimp_icon_state ic = {w, ICON_TOOLBAR_URL};
+ wimp_get_icon_state(&ic);
- if (x0 != 0 || x1 != 0)
- {
- char* icon_num = token + strlen(find) - 1;
- char* underscore = token + strlen(find) - 1;
- wimp_i i;
- int new_x, rx0, rx1;
-
- messagetrans_lookup(&theme->iconSizes.cb, token, formula, 255, widths, heights,0,0, &used);
-
- while (*underscore > 32)
- {
- if (*underscore == '_')
- *underscore = '\0';
- underscore++;
- }
-
- i = (wimp_i) atoi(icon_num);
-
- if (os_evaluate_expression(formula, buffer, 255, &new_x) == 0)
- {
- wimp_icon_state ic;
-
- ic.w = w;
- ic.i = i;
- wimp_get_icon_state(&ic);
-
- rx0 = ic.icon.extent.x0;
- rx1 = ic.icon.extent.x1;
-
- if (x0 != 0)
- {
- if (new_x < rx0)
- rx0 = new_x;
- wimp_resize_icon(w, i, new_x, ic.icon.extent.y0, ic.icon.extent.x1, ic.icon.extent.y1);
- }
- else if (x1 != 0)
- {
- if (new_x > rx1)
- rx1 = new_x;
- wimp_resize_icon(w, i, ic.icon.extent.x0, ic.icon.extent.y0, new_x, ic.icon.extent.y1);
- }
- wimp_force_redraw(w, rx0, ic.icon.extent.y0, rx1, ic.icon.extent.y1);
- }
- }
- }
+ wimp_resize_icon(w, ICON_TOOLBAR_URL, ic.icon.extent.x0, ic.icon.extent.y0,
+ width - 8, ic.icon.extent.y1);
+ wimp_force_redraw(w, ic.icon.extent.x0, ic.icon.extent.y0,
+ width, ic.icon.extent.y1);
}
-
diff --git a/riscos/theme.h b/riscos/theme.h
index 5372e3ea1..249328674 100644
--- a/riscos/theme.h
+++ b/riscos/theme.h
@@ -3,83 +3,28 @@
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
+ * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
*/
-#ifndef _MIGRATE_RISCOS_THEME_H_
-#define _MIGRATE_RISCOS_THEME_H_
-
-#include "oslib/wimp.h"
-#include "oslib/messagetrans.h"
-
-typedef enum {THEME_THEMEINFO, THEME_TOOLBAR} theme_window_type;
-
-struct ro_theme
-{
- wimp_window* theme_info;
- wimp_window* toolbar;
-
- char* filename;
-
- char* indirected_data;
- char* window_and_icon_data;
-
- osspriteop_area* sprites;
- int throbs;
-
- struct
- {
- messagetrans_control_block cb;
- char* data;
- char* filename;
- } iconNames;
-
- struct
- {
- messagetrans_control_block cb;
- char* data;
- char* filename;
- } iconSizes;
-
-};
-
-struct ro_theme_window
-{
- theme_window_type type;
-
- union {
- struct {
- char* indirected_url;
- char* indirected_status;
- } toolbar;
- struct {
- char* indirected_url;
- char* indirected_title;
- char* indirected_size;
- char* indirected_process;
- } about;
- } data;
-};
-
-typedef struct ro_theme_window ro_theme_window;
-typedef struct ro_theme ro_theme;
-
-extern ro_theme *current_theme;
-
-typedef enum {theme_TOOLBAR_UNKNOWN,
- theme_TOOLBAR_BACK, theme_TOOLBAR_FORWARD, theme_TOOLBAR_RELOAD,
- theme_TOOLBAR_URL, theme_TOOLBAR_STATUS} theme_gadget;
-
-/* install a new theme */
-ro_theme* ro_theme_create(char* pathname);
+/** \file
+ * Toolbar themes (interface).
+ *
+ * A theme consists of a template for the toolbar and icons. There is one
+ * current theme, which is changed by ro_theme_load(). A toolbar can then be
+ * created and manipulated.
+ */
-/* return icon number */
-wimp_i ro_theme_icon(ro_theme* theme, theme_window_type type, const char* token);
+#ifndef _NETSURF_RISCOS_THEME_H_
+#define _NETSURF_RISCOS_THEME_H_
-/* create a window */
-wimp_w ro_theme_create_window(ro_theme* theme, ro_theme_window* create);
+#include "oslib/wimp.h"
-int ro_theme_toolbar_height(ro_theme* theme);
+extern unsigned int theme_throbs;
-void ro_theme_resize(ro_theme* theme, theme_window_type wintype, wimp_w w, int width, int height);
+void ro_theme_load(char *pathname);
+wimp_w ro_theme_create_toolbar(char *url_buffer, char *status_buffer,
+ char *throbber_buffer);
+int ro_theme_toolbar_height(void);
+void ro_theme_resize_toolbar(wimp_w w, int width, int height);
#endif
diff --git a/riscos/uri.c b/riscos/uri.c
index 46afa76a3..54b856151 100644
--- a/riscos/uri.c
+++ b/riscos/uri.c
@@ -18,7 +18,6 @@
void ro_uri_message_received(uri_full_message_process*);
-extern ro_theme* current_theme;
void ro_uri_message_received(uri_full_message_process* uri_message)
{
@@ -79,7 +78,7 @@ void ro_uri_message_received(uri_full_message_process* uri_message)
browser_window_open_location(bw, uri_requested);
wimp_set_caret_position(bw->window->data.browser.toolbar,
- ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_URL"),
+ ICON_TOOLBAR_URL,
0,0,-1, (int) strlen(bw->window->url) - 1);
diff --git a/riscos/window.c b/riscos/window.c
index 322295995..e5b7bd4ed 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -53,7 +53,7 @@ gui_window *gui_create_browser_window(struct browser_window *bw)
window.extent.x1 = 8192;//ro_x_units(bw->format_width);
if ((bw->flags & browser_TOOLBAR) != 0)
{
- window.extent.y1 = ro_theme_toolbar_height(current_theme);
+ window.extent.y1 = ro_theme_toolbar_height();
}
else
{
@@ -75,13 +75,10 @@ gui_window *gui_create_browser_window(struct browser_window *bw)
g->data.browser.toolbar = 0;
if ((bw->flags & browser_TOOLBAR) != 0)
{
- ro_theme_window create_toolbar;
-
- create_toolbar.type = THEME_TOOLBAR;
- create_toolbar.data.toolbar.indirected_url = g->url;
- create_toolbar.data.toolbar.indirected_status = g->status;
- g->data.browser.toolbar = ro_theme_create_window(current_theme, &create_toolbar);
+ g->data.browser.toolbar = ro_theme_create_toolbar(g->url, g->status,
+ g->throb_buf);
g->data.browser.toolbar_width = -1;
+ sprintf(g->throb_buf, "throbber0");
}
g->redraw_safety = SAFE;
@@ -170,27 +167,6 @@ gui_safety gui_window_set_redraw_safety(gui_window* g, gui_safety s)
}
-void ro_gui_toolbar_redraw(gui_window* g, wimp_draw* redraw)
-{
- osbool more;
- wimp_icon_state throbber;
-
- throbber.w = g->data.browser.toolbar;
- throbber.i = ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_THROBBER");
- wimp_get_icon_state(&throbber);
-
- throbber.icon.flags = wimp_ICON_SPRITE;
- snprintf(throbber.icon.data.sprite, 12, "throbber%d", g->throbber);
-
- more = wimp_redraw_window(redraw);
- while (more)
- {
- wimp_plot_icon(&throbber.icon);
- more = wimp_get_rectangle(redraw);
- }
- return;
-}
-
void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw)
{
osbool more;
@@ -230,7 +206,7 @@ void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy)
state.xscroll = ro_x_units(sx);
state.yscroll = ro_y_units(sy);
if ((g->data.browser.bw->flags & browser_TOOLBAR) != 0)
- state.yscroll += ro_theme_toolbar_height(current_theme);
+ state.yscroll += ro_theme_toolbar_height();
ro_gui_window_open(g, (wimp_open*)&state);
}
@@ -256,7 +232,7 @@ void gui_window_set_extent(gui_window* g, unsigned long width, unsigned long hei
extent.x1 = ro_x_units(width);
if ((g->data.browser.bw->flags & browser_TOOLBAR) != 0)
{
- extent.y1 = ro_theme_toolbar_height(current_theme);
+ extent.y1 = ro_theme_toolbar_height();
}
else
{
@@ -271,7 +247,7 @@ void gui_window_set_status(gui_window* g, const char* text)
if (strcmp(g->status, text) != 0)
{
strncpy(g->status, text, 255);
- wimp_set_icon_state(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_STATUS"), 0, 0);
+ wimp_set_icon_state(g->data.browser.toolbar, ICON_TOOLBAR_STATUS, 0, 0);
}
}
@@ -296,23 +272,7 @@ void gui_window_message(gui_window* g, gui_message* msg)
case msg_SET_URL:
fprintf(stderr, "Set URL '%s'\n", msg->data.set_url.url);
strncpy(g->url, msg->data.set_url.url, 255);
- wimp_set_icon_state(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_URL"), 0, 0);
- if (g->data.browser.bw->history != NULL)
- {
- if (g->data.browser.bw->history->earlier != NULL)
- gui_enable_icon(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_BACK"));
- else
- gui_disable_icon(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_BACK"));
- if (g->data.browser.bw->history->later != NULL)
- gui_enable_icon(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_FORWARD"));
- else
- gui_disable_icon(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_FORWARD"));
- }
- else
- {
- gui_disable_icon(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_BACK"));
- gui_disable_icon(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_FORWARD"));
- }
+ wimp_set_icon_state(g->data.browser.toolbar, ICON_TOOLBAR_URL, 0, 0);
break;
default:
break;
@@ -361,7 +321,7 @@ void ro_gui_window_open(gui_window* g, wimp_open* open)
tstate.visible.x0 = open->visible.x0;
tstate.visible.x1 = outline.outline.x1 - 2;
tstate.visible.y1 = open->visible.y1;
- tstate.visible.y0 = tstate.visible.y1 - ro_theme_toolbar_height(current_theme);
+ tstate.visible.y0 = tstate.visible.y1 - ro_theme_toolbar_height();
tstate.xscroll = 0;
tstate.yscroll = 0;
tstate.next = wimp_TOP;
@@ -379,7 +339,9 @@ void ro_gui_window_open(gui_window* g, wimp_open* open)
if (tstate.visible.x1 - tstate.visible.x0 != g->data.browser.toolbar_width)
{
g->data.browser.toolbar_width = tstate.visible.x1 - tstate.visible.x0;
- ro_theme_resize(current_theme, THEME_TOOLBAR, g->data.browser.toolbar, g->data.browser.toolbar_width, tstate.visible.y1 - tstate.visible.y0);
+ ro_theme_resize_toolbar(g->data.browser.toolbar,
+ g->data.browser.toolbar_width,
+ tstate.visible.y1 - tstate.visible.y0);
}
}
@@ -406,10 +368,11 @@ void ro_gui_throb(void)
{
g->throbtime = nowtime;
g->throbber++;
- if (g->throbber > current_theme->throbs)
+ if (theme_throbs < g->throbber)
g->throbber = 0;
-
- wimp_set_icon_state(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_THROBBER"), 0, 0);
+ sprintf(g->throb_buf, "throbber%u", g->throbber);
+ wimp_set_icon_state(g->data.browser.toolbar,
+ ICON_TOOLBAR_THROBBER, 0, 0);
}
}
}
@@ -497,21 +460,18 @@ void ro_gui_window_mouse_at(wimp_pointer* pointer)
void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer)
{
- if (pointer->i == ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_BACK"))
- {
- ro_gui_history_open(g->data.browser.bw, g->data.browser.bw->history_entry,
- pointer->pos.x - 200, pointer->pos.y + 100);
- }
- else if (pointer->i == ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_FORWARD"))
- {
- ro_gui_history_open(g->data.browser.bw, g->data.browser.bw->history_entry,
- pointer->pos.x - 200, pointer->pos.y + 100);
- }
- else if (pointer->i == ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_RELOAD"))
- {
- browser_window_open_location_historical(g->data.browser.bw,
- g->data.browser.bw->url, 0, 0);
- }
+ switch (pointer->i) {
+ case ICON_TOOLBAR_HISTORY:
+ ro_gui_history_open(g->data.browser.bw,
+ g->data.browser.bw->history_entry,
+ pointer->pos.x - 200,
+ pointer->pos.y + 100);
+ break;
+ case ICON_TOOLBAR_RELOAD:
+ browser_window_open_location_historical(g->data.browser.bw,
+ g->data.browser.bw->url, 0, 0);
+ break;
+ }
}
@@ -604,7 +564,8 @@ void gui_window_start_throbber(struct gui_window* g)
void gui_window_stop_throbber(gui_window* g)
{
g->throbber = 0;
- wimp_set_icon_state(g->data.browser.toolbar, ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_THROBBER"), 0, 0);
+ sprintf(g->throb_buf, "throbber%u", g->throbber);
+ wimp_set_icon_state(g->data.browser.toolbar, ICON_TOOLBAR_THROBBER, 0, 0);
}
void gui_window_place_caret(gui_window *g, int x, int y, int height)