summaryrefslogtreecommitdiff
path: root/desktop/browser.h
blob: ead88eb826757ca7dd9fbe7fcf9d71ba72441801 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 * 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>
 * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
 */

#ifndef _NETSURF_DESKTOP_BROWSER_H_
#define _NETSURF_DESKTOP_BROWSER_H_

#include <stdbool.h>
#include <time.h>
#include "netsurf/utils/config.h"
#include "netsurf/content/content.h"
#include "netsurf/desktop/gui.h"
#include "netsurf/render/box.h"

typedef int browser_window_flags;
#define browser_TOOLBAR             ((browser_window_flags) 1)
#define browser_TITLE               ((browser_window_flags) 2)
#define browser_SCROLL_X_NONE       ((browser_window_flags) 4)
#define browser_SCROLL_X_AUTO       ((browser_window_flags) 8)
#define browser_SCROLL_X_ALWAYS     ((browser_window_flags) 16)
#define browser_SCROLL_Y_NONE       ((browser_window_flags) 32)
#define browser_SCROLL_Y_AUTO       ((browser_window_flags) 64)
#define browser_SCROLL_Y_ALWAYS     ((browser_window_flags) 128)

typedef int action_buttons;
#define act_BUTTON_NORMAL        ((action_buttons) 4)
#define act_BUTTON_ALTERNATIVE   ((action_buttons) 1)
#define act_BUTTON_CONTEXT_MENU  ((action_buttons) 2)

struct history_entry;

struct browser_window
{
  unsigned long format_width;
  unsigned long format_height;
  struct { int mult; int div; } scale;

  struct content* current_content;
  void *current_content_state;
  struct content* loading_content;
  struct history_entry *history_entry;
  bool history_add;
  clock_t time0;

  char* url;

  browser_window_flags flags;
  gui_window* window;

  int throbbing;

  void (*caret_callback)(struct browser_window *bw, char key, void *p);
  void *caret_p;
#ifdef WITH_FRAMES
  struct browser_window *parent;
  unsigned int no_children;
  struct browser_window **children;
#endif
};


struct browser_action
{
  enum { act_UNKNOWN,
         act_MOUSE_AT, act_MOUSE_CLICK, act_START_NEW_SELECTION,
         act_ALTER_SELECTION, act_CLEAR_SELECTION,
         act_FOLLOW_LINK, act_FOLLOW_LINK_NEW_WINDOW,
	 act_GADGET_SELECT
       } type;
  union {
    struct {
      unsigned long x;
      unsigned long y;
      action_buttons buttons;
    } mouse;
    struct {
      struct form_control* g;
      int item;
    } gadget_select;
  } data;
};

struct box_selection
{
  struct box* box;
  int actual_x;
  int actual_y;
  int plot_index;
};

/* public functions */

struct browser_window* create_browser_window(int flags, int width, int height
#ifdef WITH_FRAMES
, struct browser_window *parent
#endif
);
void browser_window_destroy(struct browser_window* bw
#ifdef WITH_FRAMES
, bool self
#endif
);
void browser_window_open_location(struct browser_window* bw, const char* url);
void browser_window_open_location_historical(struct browser_window* bw,
		const char* url
#ifdef WITH_POST
		, char *post_urlenc,
		struct form_successful_control *post_multipart
#endif
		);
int browser_window_action(struct browser_window* bw, struct browser_action* act);
void browser_window_set_status(struct browser_window* bw, const char* text);

void browser_window_back(struct browser_window* bw);
void browser_window_forward(struct browser_window* bw);

void box_under_area(struct box* box, unsigned long x, unsigned long y, unsigned long ox, unsigned long oy,
		struct box_selection** found, int* count, int* plot_index);

int box_position_lt(struct box_position* x, struct box_position* y);
int box_position_gt(struct box_position* x, struct box_position* y);
int box_position_eq(struct box_position* x, struct box_position* y);
int box_position_distance(struct box_position* x, struct box_position* y);

void gui_redraw_gadget(struct browser_window* bw, struct form_control* g);

void browser_window_stop_throbber(struct browser_window* bw);
void browser_window_reformat(struct browser_window* bw, int scroll_to_top);

bool browser_window_key_press(struct browser_window *bw, char key);

struct history_entry * history_add(struct history_entry *current,
		char *url, char *title);

#endif