2004-06-11 00:57:20 +04:00
|
|
|
|
/*
|
2006-11-27 18:35:18 +03:00
|
|
|
|
* This file is part of NetSurf, http://netsurf-browser.org/
|
2004-06-11 00:57:20 +04:00
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
2006-12-04 01:34:26 +03:00
|
|
|
|
* Copyright 2006 James Bursa <bursa@users.sourceforge.net>
|
2004-06-11 00:57:20 +04:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* Debug display window (implementation).
|
|
|
|
|
*/
|
|
|
|
|
|
2004-08-08 15:39:31 +04:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
2004-06-11 00:57:20 +04:00
|
|
|
|
#include "oslib/wimp.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
|
#include "content/content.h"
|
|
|
|
|
#include "riscos/dialog.h"
|
|
|
|
|
#include "riscos/wimp_event.h"
|
|
|
|
|
#include "utils/log.h"
|
|
|
|
|
#include "utils/talloc.h"
|
|
|
|
|
#include "utils/utils.h"
|
2004-06-11 00:57:20 +04:00
|
|
|
|
|
2004-06-21 19:09:59 +04:00
|
|
|
|
/** Update interval / cs. */
|
|
|
|
|
#define DEBUGWIN_UPDATE 500
|
2004-06-11 00:57:20 +04:00
|
|
|
|
|
|
|
|
|
static void ro_gui_debugwin_resize(void);
|
|
|
|
|
static void ro_gui_debugwin_update(void *p);
|
2005-12-31 07:40:49 +03:00
|
|
|
|
static void ro_gui_debugwin_close(wimp_w w);
|
2004-06-11 00:57:20 +04:00
|
|
|
|
static void ro_gui_debugwin_redraw_plot(wimp_draw *redraw);
|
2005-12-31 07:40:49 +03:00
|
|
|
|
static void ro_gui_debugwin_redraw(wimp_draw *redraw);
|
2004-06-11 00:57:20 +04:00
|
|
|
|
|
|
|
|
|
void ro_gui_debugwin_open(void)
|
|
|
|
|
{
|
2005-12-31 07:40:49 +03:00
|
|
|
|
ro_gui_wimp_event_register_close_window(dialog_debug,
|
|
|
|
|
ro_gui_debugwin_close);
|
|
|
|
|
ro_gui_wimp_event_register_redraw_window(dialog_debug,
|
|
|
|
|
ro_gui_debugwin_redraw);
|
2004-06-11 00:57:20 +04:00
|
|
|
|
ro_gui_debugwin_resize();
|
|
|
|
|
ro_gui_dialog_open(dialog_debug);
|
2004-06-25 03:29:46 +04:00
|
|
|
|
schedule_remove(ro_gui_debugwin_update, 0);
|
2004-06-21 19:09:59 +04:00
|
|
|
|
schedule(DEBUGWIN_UPDATE, ro_gui_debugwin_update, 0);
|
2004-06-11 00:57:20 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ro_gui_debugwin_resize(void)
|
|
|
|
|
{
|
2004-06-21 19:09:59 +04:00
|
|
|
|
unsigned int count = 2;
|
2004-06-11 00:57:20 +04:00
|
|
|
|
struct content *content;
|
|
|
|
|
os_box box;
|
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
|
|
for (content = content_list; content; content = content->next)
|
|
|
|
|
count++;
|
|
|
|
|
|
|
|
|
|
box.x0 = 0;
|
|
|
|
|
box.y0 = -count * 28;
|
2006-12-04 01:34:26 +03:00
|
|
|
|
box.x1 = 1400;
|
2004-06-11 00:57:20 +04:00
|
|
|
|
box.y1 = 0;
|
|
|
|
|
error = xwimp_set_extent(dialog_debug, &box);
|
|
|
|
|
if (error) {
|
|
|
|
|
LOG(("xwimp_set_extent: 0x%x: %s",
|
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ro_gui_debugwin_update(void *p)
|
|
|
|
|
{
|
|
|
|
|
os_error *error;
|
|
|
|
|
ro_gui_debugwin_resize();
|
|
|
|
|
error = xwimp_force_redraw(dialog_debug, 0, -10000, 10000, 0);
|
|
|
|
|
if (error) {
|
|
|
|
|
LOG(("xwimp_force_redraw: 0x%x: %s",
|
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
|
}
|
2004-06-21 19:09:59 +04:00
|
|
|
|
schedule(DEBUGWIN_UPDATE, ro_gui_debugwin_update, 0);
|
2004-06-11 00:57:20 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
|
void ro_gui_debugwin_close(wimp_w w)
|
2004-06-11 00:57:20 +04:00
|
|
|
|
{
|
|
|
|
|
os_error *error;
|
|
|
|
|
error = xwimp_close_window(dialog_debug);
|
|
|
|
|
if (error) {
|
|
|
|
|
LOG(("xwimp_close_window: 0x%x: %s",
|
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
|
}
|
|
|
|
|
schedule_remove(ro_gui_debugwin_update, 0);
|
2005-12-31 07:40:49 +03:00
|
|
|
|
ro_gui_wimp_event_finalise(dialog_debug);
|
2004-06-11 00:57:20 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ro_gui_debugwin_redraw(wimp_draw *redraw)
|
|
|
|
|
{
|
|
|
|
|
osbool more;
|
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
|
|
error = xwimp_redraw_window(redraw, &more);
|
|
|
|
|
if (error) {
|
|
|
|
|
LOG(("xwimp_redraw_window: 0x%x: %s",
|
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
while (more) {
|
|
|
|
|
ro_gui_debugwin_redraw_plot(redraw);
|
|
|
|
|
error = xwimp_get_rectangle(redraw, &more);
|
|
|
|
|
if (error) {
|
|
|
|
|
LOG(("xwimp_get_rectangle: 0x%x: %s",
|
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ro_gui_debugwin_redraw_plot(wimp_draw *redraw)
|
|
|
|
|
{
|
2006-12-04 01:34:26 +03:00
|
|
|
|
char s[40];
|
2004-06-11 00:57:20 +04:00
|
|
|
|
int x0 = redraw->box.x0 - redraw->xscroll;
|
|
|
|
|
int y0 = redraw->box.y1 - redraw->yscroll;
|
|
|
|
|
int i = 1;
|
|
|
|
|
int y;
|
2004-06-21 19:09:59 +04:00
|
|
|
|
unsigned int users;
|
2006-12-04 01:34:26 +03:00
|
|
|
|
unsigned int talloc_size;
|
2004-06-21 19:09:59 +04:00
|
|
|
|
unsigned int size = 0;
|
2004-06-11 00:57:20 +04:00
|
|
|
|
struct content *content;
|
2004-06-21 19:09:59 +04:00
|
|
|
|
struct content_user *user;
|
2004-06-11 00:57:20 +04:00
|
|
|
|
|
|
|
|
|
xwimp_set_font_colours(wimp_COLOUR_BLACK, wimp_COLOUR_LIGHT_GREY);
|
|
|
|
|
xwimptextop_paint(0, "url", x0 + 4, y0 - 20);
|
|
|
|
|
xwimptextop_paint(0, "type", x0 + 600, y0 - 20);
|
2004-06-21 19:09:59 +04:00
|
|
|
|
xwimptextop_paint(0, "fresh", x0 + 680, y0 - 20);
|
2004-08-13 20:59:42 +04:00
|
|
|
|
xwimptextop_paint(0, "mime_type", x0 + 760, y0 - 20);
|
|
|
|
|
xwimptextop_paint(0, "users", x0 + 910, y0 - 20);
|
|
|
|
|
xwimptextop_paint(0, "status", x0 + 990, y0 - 20);
|
2004-06-11 00:57:20 +04:00
|
|
|
|
xwimptextop_paint(0, "size", x0 + 1100, y0 - 20);
|
|
|
|
|
|
|
|
|
|
xwimp_set_font_colours(wimp_COLOUR_BLACK, wimp_COLOUR_WHITE);
|
|
|
|
|
for (content = content_list; content; content = content->next, i++) {
|
|
|
|
|
y = y0 - i * 28 - 20;
|
|
|
|
|
xwimptextop_paint(wimptextop_RJUSTIFY, content->url,
|
|
|
|
|
x0 + 580, y);
|
|
|
|
|
xwimptextop_paint(0, content_type_name[content->type],
|
|
|
|
|
x0 + 600, y);
|
2004-06-21 19:09:59 +04:00
|
|
|
|
xwimptextop_paint(0, content->fresh ? "<EFBFBD>" : "<EFBFBD>",
|
|
|
|
|
x0 + 710, y);
|
2004-06-11 00:57:20 +04:00
|
|
|
|
if (content->mime_type)
|
|
|
|
|
xwimptextop_paint(0, content->mime_type,
|
2004-08-13 20:59:42 +04:00
|
|
|
|
x0 + 760, y);
|
2004-06-21 19:09:59 +04:00
|
|
|
|
users = 0;
|
|
|
|
|
for (user = content->user_list->next; user; user = user->next)
|
|
|
|
|
users++;
|
|
|
|
|
snprintf(s, sizeof s, "%u", users);
|
2004-08-13 20:59:42 +04:00
|
|
|
|
xwimptextop_paint(wimptextop_RJUSTIFY, s, x0 + 960, y);
|
2004-06-11 00:57:20 +04:00
|
|
|
|
xwimptextop_paint(0, content_status_name[content->status],
|
2004-08-13 20:59:42 +04:00
|
|
|
|
x0 + 990, y);
|
2006-12-04 01:34:26 +03:00
|
|
|
|
talloc_size = talloc_total_size(content);
|
|
|
|
|
snprintf(s, sizeof s, "%u+%u=%u", content->size, talloc_size,
|
|
|
|
|
content->size + talloc_size);
|
|
|
|
|
xwimptextop_paint(wimptextop_RJUSTIFY, s, x0 + 1390, y);
|
|
|
|
|
size += content->size + talloc_size;
|
2004-06-11 00:57:20 +04:00
|
|
|
|
}
|
2004-06-21 19:09:59 +04:00
|
|
|
|
snprintf(s, sizeof s, "%u", size);
|
2006-12-04 01:34:26 +03:00
|
|
|
|
xwimptextop_paint(wimptextop_RJUSTIFY, s, x0 + 1390, y0 - i * 28 - 20);
|
2004-06-11 00:57:20 +04:00
|
|
|
|
}
|