2003-11-13 01:22:45 +03:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
|
|
|
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2004-01-05 05:10:59 +03:00
|
|
|
#include "netsurf/utils/config.h"
|
2003-12-22 01:10:15 +03:00
|
|
|
#include "netsurf/desktop/browser.h"
|
|
|
|
#include "netsurf/desktop/gui.h"
|
2003-11-13 01:22:45 +03:00
|
|
|
#include "netsurf/riscos/frames.h"
|
2003-12-22 01:10:15 +03:00
|
|
|
#include "netsurf/riscos/gui.h"
|
|
|
|
/*#ifndef TEST
|
2003-11-13 01:22:45 +03:00
|
|
|
# define NDEBUG
|
2003-12-22 01:10:15 +03:00
|
|
|
#endif*/
|
2003-11-13 01:22:45 +03:00
|
|
|
#include "netsurf/utils/log.h"
|
|
|
|
#include "netsurf/utils/utils.h"
|
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
#include "oslib/os.h"
|
|
|
|
#include "oslib/wimp.h"
|
|
|
|
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_FRAMES
|
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
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));
|
|
|
|
|
2003-12-27 03:11:57 +03:00
|
|
|
bw = create_browser_window(parent->flags, (int)parent->format_width,
|
|
|
|
(int)parent->format_height, parent);
|
2003-12-22 01:10:15 +03:00
|
|
|
|
|
|
|
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->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"));
|
2003-11-13 01:22:45 +03:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
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;
|
2003-11-13 01:22:45 +03:00
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
f = frame_get_instance_from_list(c);
|
2003-11-13 01:22:45 +03:00
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
wimp_close_window(f->g->window);
|
|
|
|
wimp_delete_window(f->g->window);
|
|
|
|
frame_remove_instance_from_list(c);
|
2003-11-13 01:22:45 +03:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
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);
|
2003-11-13 01:22:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
static struct frame_list pl = {0, 0, 0, 0, 0, 0, 0, 0, &pl, &pl};
|
|
|
|
static struct frame_list *plist = &pl;
|
2003-11-13 01:22:45 +03:00
|
|
|
|
|
|
|
/**
|
2003-12-22 01:10:15 +03:00
|
|
|
* Adds a plugin instance to the list of plugin instances.
|
2003-11-13 01:22:45 +03:00
|
|
|
*/
|
2003-12-22 01:10:15 +03:00
|
|
|
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));
|
2003-11-13 01:22:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-12-22 01:10:15 +03:00
|
|
|
* Removes a plugin instance from the list of plugin instances
|
2003-11-13 01:22:45 +03:00
|
|
|
*/
|
2003-12-22 01:10:15 +03:00
|
|
|
void frame_remove_instance_from_list(struct content *c) {
|
2003-11-13 01:22:45 +03:00
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
struct frame_list *temp =
|
|
|
|
frame_get_instance_from_list(c);
|
|
|
|
if(temp != NULL) {
|
2003-11-13 01:22:45 +03:00
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
LOG(("Removed Frame %p", temp));
|
|
|
|
temp->prev->next = temp->next;
|
|
|
|
temp->next->prev = temp->prev;
|
|
|
|
xfree(temp);
|
|
|
|
}
|
2003-11-13 01:22:45 +03:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
/**
|
|
|
|
* 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) {
|
2003-11-13 01:22:45 +03:00
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
struct frame_list *npl;
|
2003-11-13 01:22:45 +03:00
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
for(npl = plist->next; (npl != plist)
|
|
|
|
&& (npl->c != c);
|
|
|
|
npl = npl->next)
|
|
|
|
;
|
2003-11-13 01:22:45 +03:00
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
if(npl != plist)
|
|
|
|
return npl;
|
2003-11-13 01:22:45 +03:00
|
|
|
|
2003-12-22 01:10:15 +03:00
|
|
|
return NULL;
|
2003-11-13 01:22:45 +03:00
|
|
|
}
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|