[project @ 2003-07-17 23:01:02 by bursa]

Fix 670947, tidy gui code, move some headers.

svn path=/import/netsurf/; revision=231
This commit is contained in:
James Bursa 2003-07-17 23:01:02 +00:00
parent 8bca544448
commit 5031b80b33
17 changed files with 164 additions and 243 deletions

View File

@ -19,9 +19,7 @@
#include "netsurf/content/fetch.h"
#include "netsurf/css/css.h"
#include "netsurf/render/box.h"
#ifdef riscos
#include "netsurf/riscos/font.h"
#endif
#include "netsurf/render/font.h"
/**

View File

@ -60,6 +60,10 @@ static struct fetch *fetch_list = 0;
static size_t fetch_curl_data(void * data, size_t size, size_t nmemb, struct fetch *f);
static size_t fetch_curl_header(char * data, size_t size, size_t nmemb, struct fetch *f);
#ifdef riscos
extern const char * const NETSURF_DIR;
#endif
/**
* fetch_init -- initialise the fetcher

View File

@ -8,10 +8,19 @@
#include <assert.h>
#include <stdio.h>
#include "netsurf/css/css.h"
#include "netsurf/debug/fontd.h"
#include "netsurf/render/font.h"
#include "netsurf/utils/utils.h"
#include "netsurf/utils/log.h"
#define FONT_FAMILIES 1
#define FONT_BOLD 2
#define FONT_SLANTED 1
/* a font_set is just a linked list of font_data for each face for now */
struct font_set {
struct font_data *font[FONT_FAMILIES * 4];
};
/**
* font id = font family * 4 + bold * 2 + slanted
* font family: 0 = sans-serif, 1 = serif, ...

View File

@ -1,48 +0,0 @@
/*
* 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 James Bursa <bursa@users.sourceforge.net>
*/
#ifndef _NETSURF_RISCOS_FONT_H_
#define _NETSURF_RISCOS_FONT_H_
/**
* structures and typedefs
*/
#include "netsurf/css/css.h"
typedef unsigned int font_id;
#define FONT_FAMILIES 1
#define FONT_BOLD 2
#define FONT_SLANTED 1
/* a font_set is just a linked list of font_data for each face for now */
struct font_set {
struct font_data *font[FONT_FAMILIES * 4];
};
struct font_data {
unsigned int size;
unsigned int space_width;
struct font_data *next;
};
/**
* interface
*/
unsigned long font_width(struct font_data *font, const char * text, unsigned int length);
void font_position_in_string(const char* text, struct font_data *font,
unsigned int length, unsigned long x, int* char_offset, int* pixel_offset);
struct font_set *font_new_set(void);
struct font_data *font_open(struct font_set *set, struct css_style *style);
void font_free_set(struct font_set *set);
char * font_split(struct font_data *data, const char * text, unsigned int length,
unsigned int width, unsigned int *used_width);
#endif

View File

@ -6,22 +6,21 @@
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
*/
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "curl/curl.h"
#include "libxml/debugXML.h"
#include "netsurf/content/cache.h"
#include "netsurf/content/fetchcache.h"
#include "netsurf/desktop/browser.h"
#include "netsurf/riscos/font.h"
#include "netsurf/render/box.h"
#include "netsurf/render/font.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
#include "libxml/uri.h"
#include "libxml/debugXML.h"
#include "curl/curl.h"
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
static void browser_window_start_throbber(struct browser_window* bw);
static void browser_window_text_selection(struct browser_window* bw,
@ -187,7 +186,10 @@ void browser_window_destroy(struct browser_window* bw)
content_remove_instance(bw->current_content, bw, 0, 0, 0, &bw->current_content_state);
content_remove_user(bw->current_content, browser_window_callback, bw, 0);
}
if (bw->loading_content != NULL) {
content_remove_user(bw->loading_content, browser_window_callback, bw, 0);
}
/*
if (bw->history != NULL)
{
struct history* current = bw->history;
@ -209,7 +211,7 @@ void browser_window_destroy(struct browser_window* bw)
xfree(hh);
}
}
*/
xfree(bw->url);
gui_window_destroy(bw->window);

View File

@ -13,7 +13,6 @@
#include "netsurf/content/content.h"
#include "netsurf/desktop/gui.h"
#include "netsurf/render/box.h"
#include "netsurf/riscos/font.h"
typedef int browser_window_flags;
#define browser_TOOLBAR ((browser_window_flags) 1)
@ -30,9 +29,6 @@ typedef int action_buttons;
#define act_BUTTON_ALTERNATIVE ((action_buttons) 1)
#define act_BUTTON_CONTEXT_MENU ((action_buttons) 2)
struct history
{
struct history* earlier;

View File

@ -12,7 +12,9 @@
typedef enum { GUI_BROWSER_WINDOW } gui_window_type;
typedef enum { SAFE, UNSAFE } gui_safety;
#include "netsurf/riscos/gui.h"
struct ro_gui_window;
typedef struct ro_gui_window gui_window;
#include "netsurf/desktop/browser.h"
struct gui_message
@ -56,6 +58,6 @@ void gui_gadget_combo(struct browser_window* bw, struct gui_gadget* g, unsigned
void gui_edit_textarea(struct browser_window* bw, struct gui_gadget* g);
void gui_edit_textbox(struct browser_window* bw, struct gui_gadget* g);
void gui_show_choices();
void gui_show_choices(void);
#endif

View File

@ -16,7 +16,6 @@
#include <stdlib.h>
int netsurf_quit = 0;
gui_window* netsurf_gui_windows = NULL;
static void netsurf_init(int argc, char** argv);
static void netsurf_exit(void);

View File

@ -8,9 +8,6 @@
#ifndef _NETSURF_DESKTOP_NETSURF_H_
#define _NETSURF_DESKTOP_NETSURF_H_
#include "netsurf/desktop/browser.h"
extern gui_window* netsurf_gui_windows;
extern int netsurf_quit;
void netsurf_poll(void);

View File

@ -17,10 +17,10 @@
#include "netsurf/content/fetchcache.h"
#include "netsurf/css/css.h"
#include "netsurf/render/box.h"
#include "netsurf/render/font.h"
#include "netsurf/render/html.h"
#ifdef riscos
#include "netsurf/desktop/gui.h"
#include "netsurf/riscos/font.h"
#include "netsurf/riscos/plugin.h"
#endif
#define NDEBUG
@ -1691,12 +1691,12 @@ bool plugin_decode(struct content* content, char* url, struct box* box,
* we can't handle this object.
*/
if(po->data == 0 && po->classid == 0) {
return FALSE;
return false;
}
if(po->data == 0 && po->classid != 0) {
if(strncasecmp(po->classid, "clsid:", 6) == 0) {
LOG(("ActiveX object - n0"));
return FALSE;
return false;
}
else {
url = url_join(po->classid, po->codebase);
@ -1718,11 +1718,11 @@ bool plugin_decode(struct content* content, char* url, struct box* box,
*/
if(po->type != 0) {
if (content_lookup(po->type) == CONTENT_OTHER)
return FALSE;
return false;
}
if(po->codetype != 0) {
if (content_lookup(po->codetype) == CONTENT_OTHER)
return FALSE;
return false;
}
/* If we've got to here, the object declaration has provided us with
@ -1734,6 +1734,6 @@ bool plugin_decode(struct content* content, char* url, struct box* box,
*/
html_fetch_object(content, url, box);
return TRUE;
return true;
}

View File

@ -12,9 +12,7 @@
#include <limits.h>
#include "libxml/HTMLparser.h"
#include "netsurf/css/css.h"
#ifdef riscos
#include "netsurf/riscos/font.h"
#endif
#include "netsurf/render/font.h"
/**
* structures

View File

@ -9,42 +9,21 @@
#ifndef _NETSURF_RISCOS_FONT_H_
#define _NETSURF_RISCOS_FONT_H_
/**
* structures and typedefs
*/
#include "netsurf/css/css.h"
#include "oslib/font.h"
typedef unsigned int font_id;
#define FONT_FAMILIES 1
#define FONT_BOLD 2
#define FONT_SLANTED 1
/* a font_set is just a linked list of font_data for each face for now */
struct font_set {
struct font_data *font[FONT_FAMILIES * 4];
};
struct font_data {
font_f handle;
int handle;
unsigned int size;
unsigned int space_width;
struct font_data *next;
};
/**
* interface
*/
unsigned long font_width(struct font_data *font, const char * text, unsigned int length);
void font_position_in_string(const char* text, struct font_data *font,
unsigned int length, unsigned long x, int* char_offset, int* pixel_offset);
struct font_set *font_new_set(void);
struct font_data *font_open(struct font_set *set, struct css_style *style);
void font_free_set(struct font_set *set);
unsigned long font_width(struct font_data *font, const char * text, unsigned int length);
void font_position_in_string(const char* text, struct font_data *font,
unsigned int length, unsigned long x, int* char_offset, int* pixel_offset);
char * font_split(struct font_data *data, const char * text, unsigned int length,
unsigned int width, unsigned int *used_width);

View File

@ -12,21 +12,17 @@
#include <stdlib.h>
#include <string.h>
#include "libxml/HTMLparser.h"
#include "netsurf/content/content.h"
#include "netsurf/css/css.h"
#ifdef riscos
#include "netsurf/desktop/gui.h"
#endif
#include "netsurf/content/content.h"
#include "netsurf/render/box.h"
#include "netsurf/css/css.h"
#include "netsurf/render/font.h"
#include "netsurf/render/layout.h"
#ifdef riscos
#include "netsurf/riscos/font.h"
#else
#include "netsurf/debug/fontd.h"
#endif
#include "netsurf/utils/utils.h"
#define NDEBUG
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
/**
* internal functions

View File

@ -8,12 +8,21 @@
#include <assert.h>
#include <stdio.h>
#include "netsurf/css/css.h"
#include "netsurf/riscos/font.h"
#include "netsurf/utils/utils.h"
#include "netsurf/desktop/gui.h"
#include "netsurf/utils/log.h"
#include "oslib/font.h"
#include "netsurf/css/css.h"
#include "netsurf/desktop/gui.h"
#include "netsurf/render/font.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
#define FONT_FAMILIES 1
#define FONT_BOLD 2
#define FONT_SLANTED 1
/* a font_set is just a linked list of font_data for each face for now */
struct font_set {
struct font_data *font[FONT_FAMILIES * 4];
};
/**
* font id = font family * 4 + bold * 2 + slanted

View File

@ -22,8 +22,8 @@
#include "netsurf/desktop/gui.h"
#include "netsurf/desktop/netsurf.h"
#include "netsurf/desktop/options.h"
#include "netsurf/render/font.h"
#include "netsurf/render/html.h"
#include "netsurf/riscos/font.h"
#include "netsurf/riscos/theme.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
@ -31,6 +31,7 @@
const char *__dynamic_da_name = "NetSurf";
char *NETSURF_DIR;
static gui_window *window_list = 0;
int gadget_subtract_x;
int gadget_subtract_y;
@ -122,23 +123,6 @@ int config_br_open = 0;
int config_prox_open = 0;
int config_th_open = 0;
void wimp_close_window_CHECK(wimp_w close);
void wimp_close_window_CHECK(wimp_w close)
{
if (close == config)
config_open = 0;
else if (close == config_br)
config_br_open = 0;
else if (close == config_prox)
config_prox_open = 0;
else if (close == config_th)
{
config_th_open = 0;
ro_gui_destroy_theme_menu();
}
wimp_close_window(close);
}
struct ro_gui_drag_info;
typedef enum {
mouseaction_NONE,
@ -148,6 +132,47 @@ typedef enum {
mouseaction_TOGGLESIZE, mouseaction_ICONISE, mouseaction_CLOSE
} mouseaction;
int ro_x_units(unsigned long browser_units);
int ro_y_units(unsigned long browser_units);
unsigned long browser_x_units(int ro_units);
unsigned long browser_y_units(int ro_units);
struct ro_gui_window
{
gui_window_type type;
union {
struct {
wimp_w window;
wimp_w toolbar;
int toolbar_width;
struct browser_window* bw;
} browser;
} data;
char status[256];
char title[256];
char url[256];
gui_window* next;
int throbber;
float throbtime;
gui_safety redraw_safety;
enum { drag_NONE, drag_UNKNOWN, drag_BROWSER_TEXT_SELECTION } drag_status;
int old_width;
};
void ro_gui_window_click(gui_window* g, wimp_pointer* mouse);
//void ro_gui_window_mouse_at(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_keypress(gui_window* g, wimp_key* key);
void gui_remove_gadget(struct gui_gadget* g);
static void ro_gui_load_messages(void);
static wimp_w ro_gui_load_template(const char* template_name);
static void ro_gui_load_templates(void);
@ -184,8 +209,25 @@ static void ro_gui_menu_selection(wimp_selection* selection);
static void ro_msg_datasave(wimp_message* block);
static void ro_msg_dataload(wimp_message* block);
static void gui_set_gadget_extent(struct box* box, int x, int y, os_box* extent, struct gui_gadget* g);
static void ro_gui_close_dialog(wimp_w close);
void ro_gui_close_dialog(wimp_w close)
{
if (close == config)
config_open = 0;
else if (close == config_br)
config_br_open = 0;
else if (close == config_prox)
config_prox_open = 0;
else if (close == config_th)
{
config_th_open = 0;
ro_gui_destroy_theme_menu();
}
wimp_close_window(close);
}
void ro_gui_load_messages(void)
{
int size;
@ -415,6 +457,7 @@ gui_window* create_gui_browser_window(struct browser_window* bw)
strcpy(g->title, "NetSurf");
g->data.browser.toolbar = 0;
if ((bw->flags & browser_TOOLBAR) != 0)
{
ro_theme_window create_toolbar;
@ -502,8 +545,8 @@ gui_window* create_gui_browser_window(struct browser_window* bw)
g->redraw_safety = SAFE;
g->next = netsurf_gui_windows;
netsurf_gui_windows = g;
g->next = window_list;
window_list = g;
return g;
}
@ -518,20 +561,25 @@ void gui_window_set_title(gui_window* g, char* title)
void gui_window_destroy(gui_window* g)
{
if (g == NULL)
return;
assert(g != 0);
if (g == netsurf_gui_windows)
netsurf_gui_windows = g->next;
if (g == window_list)
window_list = g->next;
else
{
gui_window* gg;
gg = netsurf_gui_windows;
assert(window_list != NULL);
gg = window_list;
while (gg->next != g && gg->next != NULL)
gg = gg->next;
if (gg->next == g)
gg->next = g->next;
assert(gg->next != NULL);
gg->next = g->next;
}
xwimp_delete_window(g->data.browser.window);
if (g->data.browser.toolbar)
xwimp_delete_window(g->data.browser.toolbar);
xfree(g);
}
@ -546,13 +594,6 @@ void gui_window_show(gui_window* g)
ro_gui_window_open(g, (wimp_open*)&state);
}
void gui_window_hide(gui_window* g)
{
if (g == NULL)
return;
wimp_close_window(g->data.browser.window);
}
void gui_window_redraw(gui_window* g, unsigned long x0, unsigned long y0,
unsigned long x1, unsigned long y1)
{
@ -1183,11 +1224,11 @@ void gui_init(int argc, char** argv)
void ro_gui_throb(void)
{
gui_window* g = netsurf_gui_windows;
gui_window* g;
//float nowtime = (float) (clock() + 0) / CLOCKS_PER_SEC; /* workaround compiler warning */
float nowtime = (float) clock() / CLOCKS_PER_SEC;
while (g != NULL)
for (g = window_list; g != NULL; g = g->next)
{
if (g->type == GUI_BROWSER_WINDOW)
{
@ -1230,14 +1271,13 @@ void ro_gui_throb(void)
}
}
}
g = g->next;
}
}
gui_window* ro_lookup_gui_from_w(wimp_w window)
{
gui_window* g = netsurf_gui_windows;
while (g != NULL)
gui_window* g;
for (g = window_list; g != NULL; g = g->next)
{
if (g->type == GUI_BROWSER_WINDOW)
{
@ -1246,16 +1286,15 @@ gui_window* ro_lookup_gui_from_w(wimp_w window)
return g;
}
}
g = g->next;
}
return NULL;
}
gui_window* ro_lookup_gui_toolbar_from_w(wimp_w window)
{
gui_window* g = netsurf_gui_windows;
gui_window* g;
while (g != NULL)
for (g = window_list; g != NULL; g = g->next)
{
if (g->type == GUI_BROWSER_WINDOW)
{
@ -1264,7 +1303,6 @@ gui_window* ro_lookup_gui_toolbar_from_w(wimp_w window)
return g;
}
}
g = g->next;
}
return NULL;
}
@ -1420,19 +1458,19 @@ void ro_gui_w_click(wimp_pointer* pointer)
LOG(("closing windows"));
if (pointer->buttons != 1)
{
wimp_close_window_CHECK(config_br);
wimp_close_window_CHECK(config_prox);
wimp_close_window_CHECK(config_th);
wimp_close_window_CHECK(config);
ro_gui_close_dialog(config_br);
ro_gui_close_dialog(config_prox);
ro_gui_close_dialog(config_th);
ro_gui_close_dialog(config);
}
}
else if (pointer->i == ro_gui_icon("CONFIG_CANCEL"))
{
wimp_close_window_CHECK(config_br);
wimp_close_window_CHECK(config_prox);
wimp_close_window_CHECK(config_th);
ro_gui_close_dialog(config_br);
ro_gui_close_dialog(config_prox);
ro_gui_close_dialog(config_th);
if (pointer->buttons != 1)
wimp_close_window_CHECK(config);
ro_gui_close_dialog(config);
else
options_to_ro(&OPTIONS, &choices);
}
@ -1444,12 +1482,12 @@ void ro_gui_w_click(wimp_pointer* pointer)
get_browser_choices(&choices.browser);
get_browser_choices(&browser_choices);
if (pointer->buttons != 1)
wimp_close_window_CHECK(config_br);
ro_gui_close_dialog(config_br);
}
else if (pointer->i == ro_gui_icon("CONFIG_BR_CANCEL"))
{
if (pointer->buttons != 1)
wimp_close_window_CHECK(config_br);
ro_gui_close_dialog(config_br);
else
set_browser_choices(&choices.browser);
}
@ -1471,12 +1509,12 @@ void ro_gui_w_click(wimp_pointer* pointer)
get_proxy_choices(&choices.proxy);
get_proxy_choices(&proxy_choices);
if (pointer->buttons != 1)
wimp_close_window_CHECK(config_prox);
ro_gui_close_dialog(config_prox);
}
else if (pointer->i == ro_gui_icon("CONFIG_PROX_CANCEL"))
{
if (pointer->buttons != 1)
wimp_close_window_CHECK(config_prox);
ro_gui_close_dialog(config_prox);
else
set_proxy_choices(&choices.proxy);
}
@ -1491,12 +1529,12 @@ void ro_gui_w_click(wimp_pointer* pointer)
get_theme_choices(&choices.theme);
get_theme_choices(&theme_choices);
if (pointer->buttons != 1)
wimp_close_window_CHECK(config_th);
ro_gui_close_dialog(config_th);
}
else if (pointer->i == ro_gui_icon("CONFIG_TH_CANCEL"))
{
if (pointer->buttons != 1)
wimp_close_window_CHECK(config_th);
ro_gui_close_dialog(config_th);
else
set_theme_choices(&choices.theme);
}
@ -2207,9 +2245,9 @@ void gui_poll(void)
case wimp_CLOSE_WINDOW_REQUEST :
g = ro_lookup_gui_from_w(block.close.w);
if (g != NULL)
gui_window_hide(g);
browser_window_destroy(g->data.browser.bw);
else
wimp_close_window_CHECK(block.close.w);
ro_gui_close_dialog(block.close.w);
break;
case wimp_POINTER_LEAVING_WINDOW :

View File

@ -1,59 +0,0 @@
/*
* 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 Phil Mellor <monkeyson@users.sourceforge.net>
*/
#ifndef _NETSURF_RISCOS_GUI_H_
#define _NETSURF_RISCOS_GUI_H_
#include "netsurf/render/box.h"
#include "oslib/wimp.h"
extern char *NETSURF_DIR;
struct ro_gui_window;
typedef struct ro_gui_window gui_window;
int ro_x_units(unsigned long browser_units);
int ro_y_units(unsigned long browser_units);
unsigned long browser_x_units(int ro_units);
unsigned long browser_y_units(int ro_units);
struct ro_gui_window
{
gui_window_type type;
union {
struct {
wimp_w window;
wimp_w toolbar;
int toolbar_width;
struct browser_window* bw;
} browser;
} data;
char status[256];
char title[256];
char url[256];
gui_window* next;
int throbber;
float throbtime;
gui_safety redraw_safety;
enum { drag_NONE, drag_UNKNOWN, drag_BROWSER_TEXT_SELECTION } drag_status;
int old_width;
};
#include "netsurf/desktop/browser.h"
void ro_gui_window_click(gui_window* g, wimp_pointer* mouse);
//void ro_gui_window_mouse_at(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_keypress(gui_window* g, wimp_key* key);
void gui_remove_gadget(struct gui_gadget* g);
#endif

View File

@ -7,6 +7,7 @@
#include <assert.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -131,7 +132,7 @@ void plugin_create_sysvar(const char *mime_type, char* sysvar)
/**
* plugin_handleable
* Tests whether we can handle an object using a browser plugin
* returns TRUE if we can handle it, FALSE if we can't.
* returns true if we can handle it, false if we can't.
*/
bool plugin_handleable(const char *mime_type)
{
@ -142,13 +143,13 @@ bool plugin_handleable(const char *mime_type)
e = xmimemaptranslate_mime_type_to_filetype(mime_type, (bits *) &fv);
if (e) {
LOG(("xmimemaptranslate_mime_type_to_filetype failed: %s", e->errmess));
return FALSE;
return false;
}
sprintf(sysvar, "%s%x", ALIAS_PREFIX, fv);
if (getenv(sysvar) == 0)
return FALSE;
return TRUE;
return false;
return true;
}
/**