1 /*
2  * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
3  * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
4  * Copyright 2004 Andrew Timmins <atimmins@blueyonder.co.uk>
5  *
6  * This file is part of NetSurf, http://www.netsurf-browser.org/
7  *
8  * NetSurf is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * NetSurf is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef _NETSURF_RISCOS_GUI_H_
22 #define _NETSURF_RISCOS_GUI_H_
23 
24 #include <oslib/wimp.h>
25 
26 #define RISCOS5 0xAA
27 
28 #define THUMBNAIL_WIDTH 100
29 #define THUMBNAIL_HEIGHT 86
30 
31 /* The maximum size for user-editable URLs in the RISC OS GUI. */
32 
33 #define RO_GUI_MAX_URL_SIZE 2048
34 
35 extern int os_version;
36 
37 extern const char * NETSURF_DIR;
38 
39 struct toolbar;
40 struct status_bar;
41 struct plotter_table;
42 struct gui_window;
43 struct tree;
44 struct node;
45 struct history;
46 struct css_style;
47 struct nsurl;
48 struct hlcache_handle;
49 
50 enum gui_pointer_shape;
51 
52 extern wimp_t task_handle;	/**< RISC OS wimp task handle. */
53 
54 extern wimp_w dialog_info, dialog_saveas, dialog_zoom, dialog_pageinfo,
55 	dialog_objinfo, dialog_tooltip, dialog_warning, dialog_openurl,
56 	dialog_folder, dialog_entry, dialog_url_complete,
57 	dialog_search, dialog_print, dialog_theme_install;
58 extern wimp_w current_menu_window;
59 extern bool current_menu_open;
60 extern wimp_menu *recent_search_menu;	/* search.c */
61 extern bool gui_redraw_debug;
62 extern osspriteop_area *gui_sprites;
63 extern bool dialog_folder_add, dialog_entry_add, hotlist_insert;
64 extern bool print_active, print_text_black;
65 extern bool no_font_blending;
66 
67 typedef enum { GUI_DRAG_NONE, GUI_DRAG_DOWNLOAD_SAVE, GUI_DRAG_SAVE }
68 		ro_gui_drag_type;
69 
70 extern ro_gui_drag_type gui_current_drag_type;
71 
72 extern bool riscos_done;
73 
74 /** RISC OS data for a browser window. */
75 struct gui_window {
76 	/** Associated platform-independent browser window data. */
77 	struct browser_window *bw;
78 
79 	struct toolbar *toolbar;	/**< Toolbar, or 0 if not present. */
80 	struct status_bar *status_bar;	/**< Status bar, or 0 if not present. */
81 
82 	wimp_w window;		/**< RISC OS window handle. */
83 
84 	int old_width;		/**< Width when last opened / os units. */
85 	int old_height;		/**< Height when last opened / os units. */
86 	bool update_extent;	/**< Update the extent on next opening */
87 	bool active;		/**< Whether the throbber should be active */
88 
89 	char title[256];	/**< Buffer for window title. */
90 
91 	int iconise_icon;	/**< ID number of icon when window is iconised */
92 
93 	char validation[12];	/**< Validation string for colours */
94 
95 	/** Options. */
96 	struct {
97 		bool buffer_animations;	/**< Use screen buffering for animations. */
98 		bool buffer_everything;	/**< Use screen buffering for everything. */
99 	} option;
100 
101 	struct gui_window *prev;	/**< Previous in linked list. */
102 	struct gui_window *next;	/**< Next in linked list. */
103 };
104 
105 
106 extern struct gui_window *ro_gui_current_redraw_gui;
107 
108 
109 /* in gui.c */
110 void ro_gui_open_window_request(wimp_open *open);
111 void ro_gui_screen_size(int *width, int *height);
112 void ro_gui_view_source(struct hlcache_handle *c);
113 void ro_gui_dump_browser_window(struct browser_window *bw);
114 void ro_gui_drag_box_start(wimp_pointer *pointer);
115 bool ro_gui_prequit(void);
116 const char *ro_gui_default_language(void);
117 nserror ro_warn_user(const char *warning, const char *detail);
118 
119 /**
120  * Cause an abnormal program termination.
121  *
122  * \note This never returns and is intended to terminate without any cleanup.
123  *
124  * \param error The message to display to the user.
125  */
126 void die(const char * const error) __attribute__ ((noreturn));
127 
128 /* in download.c */
129 void ro_gui_download_init(void);
130 void ro_gui_download_datasave_ack(wimp_message *message);
131 bool ro_gui_download_prequit(void);
132 extern struct gui_download_table *riscos_download_table;
133 
134 /* in schedule.c */
135 extern bool sched_active;
136 extern os_t sched_time;
137 
138 /**
139  * Process events up to current time.
140  */
141 bool schedule_run(void);
142 
143 /**
144  * Schedule a callback.
145  *
146  * \param  t         interval before the callback should be made in ms
147  * \param  callback  callback function
148  * \param  p         user parameter, passed to callback function
149  *
150  * The callback function will be called as soon as possible after t ms have
151  * passed.
152  */
153 nserror riscos_schedule(int t, void (*callback)(void *p), void *p);
154 
155 /* in search.c */
156 void ro_gui_search_init(void);
157 void ro_gui_search_prepare(struct browser_window *g);
158 extern struct gui_search_table *riscos_search_table;
159 
160 /* in print.c */
161 void ro_gui_print_init(void);
162 void ro_gui_print_prepare(struct gui_window *g);
163 
164 /* in plotters.c */
165 extern const struct plotter_table ro_plotters;
166 extern int ro_plot_origin_x;
167 extern int ro_plot_origin_y;
168 
169 /* in theme_install.c */
170 bool ro_gui_theme_install_apply(wimp_w w);
171 
172 /* icon numbers */
173 #define ICON_STATUS_RESIZE 0
174 #define ICON_STATUS_TEXT 1
175 
176 #define ICON_SAVE_ICON 0
177 #define ICON_SAVE_PATH 1
178 #define ICON_SAVE_OK 2
179 #define ICON_SAVE_CANCEL 3
180 
181 #define ICON_PAGEINFO_TITLE 0
182 #define ICON_PAGEINFO_URL 1
183 #define ICON_PAGEINFO_ENC 2
184 #define ICON_PAGEINFO_TYPE 3
185 #define ICON_PAGEINFO_ICON 4
186 
187 #define ICON_OBJINFO_URL 0
188 #define ICON_OBJINFO_TARGET 1
189 #define ICON_OBJINFO_TYPE 2
190 #define ICON_OBJINFO_ICON 3
191 
192 #define ICON_WARNING_MESSAGE 0
193 #define ICON_WARNING_CONTINUE 1
194 #define ICON_WARNING_HELP 2
195 
196 #define ICON_SEARCH_TEXT 0
197 #define ICON_SEARCH_CASE_SENSITIVE 1
198 #define ICON_SEARCH_FIND_NEXT 2
199 #define ICON_SEARCH_FIND_PREV 3
200 #define ICON_SEARCH_CANCEL 4
201 #define ICON_SEARCH_STATUS 5
202 #define ICON_SEARCH_MENU 8
203 #define ICON_SEARCH_SHOW_ALL 9
204 
205 #define ICON_THEME_INSTALL_MESSAGE 0
206 #define ICON_THEME_INSTALL_INSTALL 1
207 #define ICON_THEME_INSTALL_CANCEL 2
208 
209 #define ICON_OPENURL_URL 1
210 #define ICON_OPENURL_CANCEL 2
211 #define ICON_OPENURL_OPEN 3
212 #define ICON_OPENURL_MENU 4
213 
214 #define ICON_ENTRY_NAME 1
215 #define ICON_ENTRY_URL 3
216 #define ICON_ENTRY_CANCEL 4
217 #define ICON_ENTRY_OK 5
218 #define ICON_ENTRY_RECENT 6
219 
220 #define ICON_FOLDER_NAME 1
221 #define ICON_FOLDER_CANCEL 2
222 #define ICON_FOLDER_OK 3
223 
224 #endif
225