2003-06-30 16:44:03 +04: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 Phil Mellor <monkeyson@users.sourceforge.net>
|
2004-02-25 18:12:58 +03:00
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* Browser window creation and manipulation (interface).
|
2002-09-11 18:24:02 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETSURF_DESKTOP_BROWSER_H_
|
|
|
|
#define _NETSURF_DESKTOP_BROWSER_H_
|
|
|
|
|
2003-11-15 03:26:42 +03:00
|
|
|
#include <stdbool.h>
|
2004-08-14 16:16:45 +04:00
|
|
|
#include <stddef.h>
|
2003-02-28 14:49:13 +03:00
|
|
|
#include <time.h>
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
struct box;
|
2004-07-18 21:38:01 +04:00
|
|
|
struct content;
|
2005-04-15 22:00:21 +04:00
|
|
|
struct form;
|
2004-07-18 21:38:01 +04:00
|
|
|
struct form_control;
|
2004-06-21 19:09:59 +04:00
|
|
|
struct form_successful_control;
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window;
|
|
|
|
struct history;
|
2005-04-15 09:52:25 +04:00
|
|
|
struct selection;
|
2005-04-20 16:24:41 +04:00
|
|
|
struct browser_window;
|
|
|
|
|
|
|
|
|
|
|
|
typedef void (*browser_caret_callback)(struct browser_window *bw,
|
|
|
|
wchar_t key, void *p);
|
|
|
|
typedef bool (*browser_paste_callback)(struct browser_window *bw,
|
|
|
|
const char *utf8, unsigned utf8_len, bool last, void *p);
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
/** Browser window data. */
|
2004-10-18 01:11:29 +04:00
|
|
|
struct browser_window {
|
2004-02-25 18:12:58 +03:00
|
|
|
/** Page currently displayed, or 0. Must have status READY or DONE. */
|
|
|
|
struct content *current_content;
|
|
|
|
/** Page being loaded, or 0. */
|
|
|
|
struct content *loading_content;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
/** Window history structure. */
|
|
|
|
struct history *history;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2005-04-15 09:52:25 +04:00
|
|
|
/** Selection state */
|
|
|
|
struct selection *sel;
|
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
/** Handler for keyboard input, or 0. */
|
2005-04-20 16:24:41 +04:00
|
|
|
browser_caret_callback caret_callback;
|
|
|
|
/** Handler for pasting text, or 0. */
|
|
|
|
browser_paste_callback paste_callback;
|
|
|
|
|
|
|
|
/** User parameter for caret_callback and paste_callback */
|
2004-02-25 18:12:58 +03:00
|
|
|
void *caret_p;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/** Platform specific window data. */
|
|
|
|
struct gui_window *window;
|
2004-02-25 18:12:58 +03:00
|
|
|
|
|
|
|
/** Busy indicator is active. */
|
|
|
|
bool throbbing;
|
|
|
|
/** Add loading_content to the window history when it loads. */
|
|
|
|
bool history_add;
|
|
|
|
/** Start time of fetching loading_content. */
|
|
|
|
clock_t time0;
|
2004-08-07 02:19:13 +04:00
|
|
|
|
2004-10-18 01:11:29 +04:00
|
|
|
/** Fragment identifier for current_content. */
|
2004-08-07 02:19:13 +04:00
|
|
|
char *frag_id;
|
2004-08-26 03:56:49 +04:00
|
|
|
|
2004-10-18 01:11:29 +04:00
|
|
|
/** Current drag status. */
|
2005-04-15 09:52:25 +04:00
|
|
|
enum {
|
|
|
|
DRAGGING_NONE,
|
|
|
|
DRAGGING_VSCROLL,
|
|
|
|
DRAGGING_HSCROLL,
|
|
|
|
DRAGGING_SELECTION,
|
2005-07-21 03:27:28 +04:00
|
|
|
DRAGGING_PAGE_SCROLL,
|
|
|
|
DRAGGING_2DSCROLL
|
2005-04-15 09:52:25 +04:00
|
|
|
} drag_type;
|
2004-10-18 01:11:29 +04:00
|
|
|
|
2004-08-26 03:56:49 +04:00
|
|
|
/** Box currently being scrolled, or 0. */
|
|
|
|
struct box *scrolling_box;
|
2004-11-20 03:02:56 +03:00
|
|
|
/** Mouse position at start of current scroll drag. */
|
|
|
|
int scrolling_start_x;
|
|
|
|
int scrolling_start_y;
|
|
|
|
/** Scroll offsets at start of current scroll draw. */
|
|
|
|
int scrolling_start_scroll_x;
|
|
|
|
int scrolling_start_scroll_y;
|
|
|
|
/** Well dimensions for current scroll drag. */
|
|
|
|
int scrolling_well_width;
|
|
|
|
int scrolling_well_height;
|
2004-10-02 03:19:08 +04:00
|
|
|
|
|
|
|
/** Referer for current fetch, or 0. */
|
|
|
|
char *referer;
|
2005-01-03 05:09:20 +03:00
|
|
|
|
|
|
|
/** Current fetch is download */
|
|
|
|
bool download;
|
2002-09-11 18:24:02 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-07-18 03:32:09 +04:00
|
|
|
typedef enum {
|
2005-04-15 09:52:25 +04:00
|
|
|
BROWSER_MOUSE_CLICK_1 = 1, /* primary mouse button down (eg. Select) */
|
|
|
|
BROWSER_MOUSE_CLICK_2 = 2,
|
|
|
|
|
|
|
|
BROWSER_MOUSE_DRAG_1 = 8, /* start of drag operation */
|
|
|
|
BROWSER_MOUSE_DRAG_2 = 16,
|
|
|
|
|
|
|
|
BROWSER_MOUSE_HOLDING_1 = 64, /* whilst drag is in progress */
|
|
|
|
BROWSER_MOUSE_HOLDING_2 = 128,
|
|
|
|
|
|
|
|
BROWSER_MOUSE_MOD_1 = 512, /* primary modifier key pressed (eg. Shift) */
|
|
|
|
BROWSER_MOUSE_MOD_2 = 1024
|
|
|
|
} browser_mouse_state;
|
2004-07-18 03:32:09 +04:00
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2005-04-15 09:52:25 +04:00
|
|
|
extern struct browser_window *current_redraw_browser;
|
|
|
|
|
2004-10-02 01:31:55 +04:00
|
|
|
void browser_window_create(const char *url, struct browser_window *clone,
|
|
|
|
char *referer);
|
2004-10-01 04:06:49 +04:00
|
|
|
void browser_window_go(struct browser_window *bw, const char *url,
|
2005-01-25 01:14:59 +03:00
|
|
|
char *referer);
|
2004-02-25 18:12:58 +03:00
|
|
|
void browser_window_go_post(struct browser_window *bw, const char *url,
|
|
|
|
char *post_urlenc,
|
|
|
|
struct form_successful_control *post_multipart,
|
2005-01-03 05:09:20 +03:00
|
|
|
bool history_add, char *referer, bool download);
|
2004-02-25 18:12:58 +03:00
|
|
|
void browser_window_stop(struct browser_window *bw);
|
2004-06-29 23:08:19 +04:00
|
|
|
void browser_window_reload(struct browser_window *bw, bool all);
|
2004-02-25 18:12:58 +03:00
|
|
|
void browser_window_destroy(struct browser_window *bw);
|
2005-03-13 12:04:44 +03:00
|
|
|
void browser_window_update(struct browser_window *bw, bool scroll_to_top);
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-07-18 03:32:09 +04:00
|
|
|
void browser_window_mouse_click(struct browser_window *bw,
|
2005-04-15 09:52:25 +04:00
|
|
|
browser_mouse_state mouse, int x, int y);
|
|
|
|
void browser_window_mouse_track(struct browser_window *bw,
|
|
|
|
browser_mouse_state mouse, int x, int y);
|
|
|
|
void browser_window_mouse_drag_end(struct browser_window *bw,
|
|
|
|
browser_mouse_state mouse, int x, int y);
|
|
|
|
|
2004-08-14 16:16:45 +04:00
|
|
|
bool browser_window_key_press(struct browser_window *bw, wchar_t key);
|
2005-04-20 16:24:41 +04:00
|
|
|
bool browser_window_paste_text(struct browser_window *bw, const char *utf8,
|
|
|
|
unsigned utf8_len, bool last);
|
2004-07-18 03:32:09 +04:00
|
|
|
void browser_window_form_select(struct browser_window *bw,
|
|
|
|
struct form_control *control, int item);
|
2005-04-15 22:00:21 +04:00
|
|
|
void browser_redraw_box(struct content *c, struct box *box);
|
|
|
|
void browser_form_submit(struct browser_window *bw, struct form *form,
|
|
|
|
struct form_control *submit_button);
|
2004-02-25 18:12:58 +03:00
|
|
|
|
2005-04-15 09:52:25 +04:00
|
|
|
void browser_window_redraw_rect(struct browser_window *bw, int x, int y,
|
|
|
|
int width, int height);
|
|
|
|
|
2004-07-03 21:30:28 +04:00
|
|
|
/* In platform specific hotlist.c. */
|
|
|
|
void hotlist_visited(struct content *content);
|
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
/* In platform specific history.c. */
|
|
|
|
struct history *history_create(void);
|
2004-08-07 02:19:13 +04:00
|
|
|
void history_add(struct history *history, struct content *content,
|
|
|
|
char *frag_id);
|
2004-02-25 18:12:58 +03:00
|
|
|
void history_update(struct history *history, struct content *content);
|
|
|
|
void history_destroy(struct history *history);
|
2004-02-26 20:52:10 +03:00
|
|
|
void history_back(struct browser_window *bw, struct history *history);
|
|
|
|
void history_forward(struct browser_window *bw, struct history *history);
|
2004-06-27 02:31:34 +04:00
|
|
|
bool history_back_available(struct history *history);
|
|
|
|
bool history_forward_available(struct history *history);
|
2003-11-15 03:26:42 +03:00
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
/* In platform specific global_history.c. */
|
|
|
|
void global_history_add(struct gui_window *g);
|
|
|
|
void global_history_add_recent(const char *url);
|
|
|
|
char **global_history_get_recent(int *count);
|
|
|
|
|
|
|
|
|
2004-09-04 02:44:48 +04:00
|
|
|
/* In platform specific schedule.c. */
|
|
|
|
void schedule(int t, void (*callback)(void *p), void *p);
|
|
|
|
void schedule_remove(void (*callback)(void *p), void *p);
|
|
|
|
void schedule_run(void);
|
|
|
|
|
2005-01-14 01:42:39 +03:00
|
|
|
/* In platform specific theme_install.c. */
|
|
|
|
#ifdef WITH_THEME_INSTALL
|
|
|
|
void theme_install_start(struct content *c);
|
|
|
|
#endif
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
#endif
|