summaryrefslogtreecommitdiff
path: root/riscos/frames.c
diff options
context:
space:
mode:
Diffstat (limited to 'riscos/frames.c')
-rw-r--r--riscos/frames.c435
1 files changed, 169 insertions, 266 deletions
diff --git a/riscos/frames.c b/riscos/frames.c
index 32e35ad6e..fa1db8c48 100644
--- a/riscos/frames.c
+++ b/riscos/frames.c
@@ -7,299 +7,202 @@
#include <stdbool.h>
+#include "netsurf/desktop/browser.h"
+#include "netsurf/desktop/gui.h"
#include "netsurf/riscos/frames.h"
-#ifndef TEST
+#include "netsurf/riscos/gui.h"
+/*#ifndef TEST
# define NDEBUG
-#endif
+#endif*/
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
-#ifdef TEST
-# include <stdio.h>
-#endif
-
-static struct frame_list fl = {0, 0, &fl, &fl};
-static struct frame_list *flist = &fl;
-
-/* -------------------------------------------------------------------- *
- * List handling stuff *
- * -------------------------------------------------------------------- */
-
-/**
- * Adds a new frameset associated with a browser window to the list
- */
-void frameset_add_to_list(struct browser_window *bw, struct frame *frame) {
-
- struct frame_list *nfl = xcalloc(1, sizeof(*nfl));
-
- LOG(("adding %p to list", frame));
- nfl->frame = frame;
- nfl->bw = bw;
- nfl->prev = flist->prev;
- nfl->next = flist;
- flist->prev->next = nfl;
- flist->prev = nfl;
+#include "oslib/os.h"
+#include "oslib/wimp.h"
+
+void frame_add_instance_to_list(struct content *c, struct browser_window *parent, struct content *page, struct box *box, struct object_params *params, void **state, struct browser_window *bw, gui_window *g);
+void frame_remove_instance_from_list(struct content *c);
+struct frame_list *frame_get_instance_from_list(struct content *c);
+
+void frame_add_instance(struct content *c, struct browser_window *parent,
+ struct content *page, struct box *box,
+ struct object_params *params, void **state)
+{
+
+ wimp_window w;
+ struct browser_window *bw = NULL;
+ os_error *e;
+ gui_window *g = (gui_window*)xcalloc(1, sizeof(gui_window));
+
+ bw = create_browser_window(parent->flags, parent->format_width,
+ parent->format_height, parent);
+
+ w.visible.x0 = 346;
+ w.visible.x1 = 370;
+ w.visible.y0 = 664;
+ w.visible.y1 = 610;
+ w.xscroll = w.yscroll = 0;
+ w.next = wimp_TOP;
+ w.flags = wimp_WINDOW_NEW_FORMAT | wimp_WINDOW_MOVEABLE;
+ w.title_fg = wimp_COLOUR_TRANSPARENT;
+ w.title_bg = wimp_COLOUR_WHITE;
+ w.work_fg = wimp_COLOUR_VERY_LIGHT_GREY;
+ w.work_bg = wimp_COLOUR_RED;
+ w.scroll_outer = wimp_COLOUR_DARK_GREY;
+ w.scroll_inner = wimp_COLOUR_MID_LIGHT_GREY;
+ w.highlight_bg = wimp_COLOUR_CREAM;
+ w.extra_flags = 0;
+ w.extent.x0 = 0;
+ w.extent.y0 = -8192;
+ w.extent.x1 = 8192;
+ w.extent.y1 = 0;
+ w.title_flags = wimp_ICON_HCENTRED | wimp_ICON_VCENTRED;
+ w.work_flags = wimp_BUTTON_CLICK << wimp_ICON_BUTTON_TYPE_SHIFT;
+ w.xmin = 1;
+ w.ymin = 0;
+ w.icon_count = 0;
+
+ LOG(("Creating frame"));
+
+ e = xwimp_create_window(&w, &g->window);
+ if (e) {
+ LOG(("%s", e->errmess));
+ return;
+ }
+
+ g->type = GUI_BROWSER_WINDOW;
+ g->data.browser.bw = bw;
+ g->data.browser.toolbar = 0;
+ g->redraw_safety = SAFE;
+ g->data.browser.reformat_pending = false;
+ g->data.browser.old_width = 0;
+
+ bw->current_content = c;
+ bw->window = g;
+
+ LOG(("Adding to list"));
+
+ frame_add_instance_to_list(c, parent, page, box, params, state, bw, g);
+
+ LOG(("Done"));
}
-/**
- * Removes a frameset associated with a browser window to the list
- */
-void frameset_remove_from_list(struct browser_window *bw) {
+void frame_remove_instance(struct content *c, struct browser_window *bw,
+ struct content *page, struct box *box,
+ struct object_params *params, void **state)
+{
+ struct frame_list *f;
- struct frame_list *temp = frameset_get_from_list(bw);
- if(temp != NULL) {
- delete_tree(temp->frame);
- temp->prev->next = temp->next;
- temp->next->prev = temp->prev;
- xfree(temp);
- }
-}
+ f = frame_get_instance_from_list(c);
-/**
- * Retrieves a frameset from the list
- * Returns a frame_list struct pointer or NULL is nothing is found
- */
-struct frame_list *frameset_get_from_list(struct browser_window *bw) {
-
- struct frame_list *nfl;
-
- for(nfl = flist->next; (nfl != flist) && (nfl->bw != bw);
- nfl = nfl->next)
- ;
-
- if(nfl != flist)
- return nfl;
-
- return NULL;
+ wimp_close_window(f->g->window);
+ wimp_delete_window(f->g->window);
+ frame_remove_instance_from_list(c);
}
-/**
- * Retrieves a frame from the list/tree structure.
- * Returns a frame struct pointer or NULL if nothing is found
- */
-struct frame *frame_get_from_list(struct browser_window *bw, struct box *b,
- bool strict) {
-
- struct frame_list *nfl;
- struct frame *f=0;
-
- for(nfl = flist->next; (nfl != flist); nfl = nfl->next) {
- LOG(("checking tree %p",nfl->frame));
- if ((f = get_frame_from_tree(nfl->frame, bw, b, strict))) {
- LOG(("returning f: %p", f));
- return f;
- }
- }
-
- return NULL;
+void frame_reshape_instance(struct content *c, struct browser_window *bw,
+ struct content *page, struct box *box,
+ struct object_params *params, void **state)
+{
+
+ struct frame_list *f;
+ unsigned long x, y;
+ int x0, y1;
+ os_box b;
+ wimp_window_state s;
+
+ LOG(("Reshaping frame"));
+
+ f = frame_get_instance_from_list(c);
+ if (f == NULL) {
+ LOG(("Couldn't find frame"));
+ return;
+ }
+
+ s.w = bw->window->window;
+ wimp_get_window_state(&s);
+ LOG(("ParentWindow: [(%d,%d),(%d,%d)]", s.visible.x0, s.visible.y0,
+ s.visible.x1, s.visible.y1));
+
+ x0 = s.visible.x0 - s.xscroll;
+ y1 = s.visible.y1 - s.yscroll;
+
+ LOG(("%d,%d", x0, y1));
+
+ box_coords(box, &x, &y);
+ b.x0 = x0 + ((int)x << 1);
+ b.y1 = y1 - (((int)y << 1));
+ b.x1 = (b.x0 + (box->width << 1));
+ b.y0 = (b.y1 - (box->height << 1));
+
+ /*if(b.x1 > (s.visible.x1-s.xscroll)) {
+ b.x1 -= 16;
+ }*/
+ s.w = f->g->window;
+ s.visible = b;
+
+ LOG(("Opening frame window : [(%d,%d),(%d,%d)]",b.x0,b.y0,b.x1,b.y1));
+ xwimp_open_window_nested((wimp_open*)&s, bw->window->window, 0);
}
-/* -------------------------------------------------------------------- *
- * Tree handling stuff *
- * -------------------------------------------------------------------- */
-/**
- * Adds a new frame to the tree
- * Creates a new tree if appropriate.
- */
-void add_frame_to_tree (struct browser_window *parent_bw, struct box *box,
- struct browser_window *bw, struct content *c,
- char *name) {
-
- struct frame *nrf;
- struct frame *parent;
- struct frame *nf = xcalloc(1, sizeof(*nf));
- unsigned int i;
-
- /* get parent node */
- if ((parent = frame_get_from_list(parent_bw, box, false)) == NULL) {
-
- LOG(("no tree found - creating new"));
- nrf = xcalloc(1, sizeof(*nrf));
- nrf->win = parent_bw;
- nrf->box = (struct box*)-1;
- nrf->c = 0;
- nrf->name = xstrdup("_top");
- nrf->parent = 0;
- nrf->no_children = 0;
- nrf->children = xcalloc(0,1);
- frameset_add_to_list(parent_bw, nrf);
- parent = frame_get_from_list(parent_bw, (struct box*)-1, true);
- }
-
- LOG(("got parent"));
- nf->win = bw;
- nf->box = box;
- nf->c = c;
- nf->name = xstrdup(name);
- nf->parent = parent;
- nf->no_children = 0;
-
- LOG(("adding frame to tree"));
- i = parent->no_children;
- parent->children =
- xrealloc(parent->children, (i+1) * sizeof(struct frame));
- parent->children[i] = nf;
- parent->no_children++;
-}
+static struct frame_list pl = {0, 0, 0, 0, 0, 0, 0, 0, &pl, &pl};
+static struct frame_list *plist = &pl;
/**
- * Retrieves a frame from the tree.
- * If 'strict' is true, tests for both bw and box. Otherwise, just tests bw.
- * Returns the frame or NULL.
+ * Adds a plugin instance to the list of plugin instances.
*/
-struct frame *get_frame_from_tree(struct frame *root,
- struct browser_window *bw,
- struct box *b,
- bool strict) {
-
- int i;
-
- if (!root) {
- LOG(("tree was empty"));
- return NULL; /* empty tree */
- }
-
- if (strict) {
- if (root->parent != 0) { /* has a parent node => check that */
- LOG(("(%p, %p),(%p, %p)", root->parent->win, bw, root->box, b));
- if (root->parent->win == bw && root->box == b) { /* found frame */
- LOG(("found frame %p", root));
- return root;
- }
- }
- else { /* no parent node => check this one */
- LOG(("(%p, %p),(%p, %p)", root->win, bw, root->box, b));
- if (root->win == bw && root->box == b) { /* found frame */
- LOG(("found frame %p", root));
- return root;
- }
- }
- }
- else {
- if (root->parent != 0) { /* has a parent node => check that */
- LOG(("(%p, %p),(%p, %p)", root->parent->win, bw, root->box, b));
- if (root->parent->win == bw) { /* found frame */
- LOG(("found frame %p", root));
- return root;
- }
- else if (root->win == bw) {
- LOG(("adding as child of '%s'", root->name));
- return root;
- }
- }
- else { /* no parent node => check this one */
- LOG(("(%p, %p),(%p, %p)", root->win, bw, root->box, b));
- if (root->win == bw) { /* found frame */
- LOG(("found frame %p", root));
- return root;
- }
- }
- }
-
- if (root->no_children == 0)
- return NULL;
-
- for (i=0; i!=root->no_children; i++) { /* not found so recurse */
- return get_frame_from_tree(root->children[i], bw, b, strict);
- }
-
- return NULL;
+void frame_add_instance_to_list(struct content *c, struct browser_window *parent, struct content *page, struct box *box, struct object_params *params, void **state, struct browser_window *bw, gui_window *g) {
+
+ struct frame_list *npl = xcalloc(1, sizeof(*npl));
+
+ npl->c = c;
+ npl->parent = parent;
+ npl->page = page;
+ npl->box = box;
+ npl->params = params;
+ npl->state = state;
+ npl->bw = bw;
+ npl->g = g;
+ npl->prev = plist->prev;
+ npl->next = plist;
+ plist->prev->next = npl;
+ plist->prev = npl;
+
+ LOG(("Added Frame %p", npl));
}
/**
- * Deletes a complete tree.
+ * Removes a plugin instance from the list of plugin instances
*/
-void delete_tree(struct frame *root) {
-
- int i;
-
- if (!root) return; /* empty tree */
-
- if (root->no_children == 0) { /* leaf node => delete and return */
- LOG(("deleting '%s'", root->name));
- xfree(root->name);
- xfree(root);
- return;
- }
-
- for (i=0; i!=root->no_children; i++) { /* non-leaf node
- => kill children */
- delete_tree(root->children[i]);
- }
-
- /* all children killed => remove this node */
- LOG(("deleting '%s'", root->name));
- xfree(root->name);
- xfree(root);
-}
-
+void frame_remove_instance_from_list(struct content *c) {
+ struct frame_list *temp =
+ frame_get_instance_from_list(c);
+ if(temp != NULL) {
-#ifdef TEST
-void traverse_tree(struct frame *root, int depth) {
-
- int i;
-
- if (!root) return; /* empty tree */
-
- if (root->no_children == 0) {
- for (i=0; i!=(depth+1); i++)
- printf("\t");
- printf("frame: %p (%s)\n", root, root->name);
- return;
- }
- else {
- for(i=0; i!=(depth+1); i++)
- printf("\t");
- printf("frame: %p (%s)\n", root, root->name);
- }
-
- for (i=0; i!=root->no_children; i++) { /* not found so recurse */
- traverse_tree(root->children[i], (depth+1));
- }
-
- return;
-}
-
-void dump_all_frame_moose(void) {
-
- struct frame_list *nfl;
-
- for (nfl=flist->next; nfl!=flist; nfl=nfl->next) {
- printf("bw: %p\n", nfl->bw);
- traverse_tree(nfl->frame, 0);
- printf("\n");
- }
+ LOG(("Removed Frame %p", temp));
+ temp->prev->next = temp->next;
+ temp->next->prev = temp->prev;
+ xfree(temp);
+ }
}
-int main (void) {
-
- struct frame *f;
-
- add_frame_to_tree(1, 1, 1, 3, "test");
- add_frame_to_tree(0, 2, 2, 5, "moo");
- add_frame_to_tree(0, 3, 3, 1, "moose");
- add_frame_to_tree(2, 4, 4, 2, "elk");
-
- dump_all_frame_moose();
-
- f = frame_get_from_list(1, 1, true);
- if (f)
- printf("%s: %d, %d\n", f->name, f->win, f->c);
- else
- printf("couldn't find 1,1\n");
+/**
+ * Retrieves an instance of a plugin from the list of plugin instances
+ * returns NULL if no instance is found
+ */
+struct frame_list *frame_get_instance_from_list(struct content *c) {
- frameset_remove_from_list(1);
+ struct frame_list *npl;
- f = frame_get_from_list(2, 4, true);
- if (f)
- printf("%s: %d, %d\n", f->name, f->win, f->c);
- else
- printf("couldn't find 2,4\n");
+ for(npl = plist->next; (npl != plist)
+ && (npl->c != c);
+ npl = npl->next)
+ ;
- dump_all_frame_moose();
+ if(npl != plist)
+ return npl;
- return 0;
+ return NULL;
}
-#endif