Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
  3.  * Copyright 2006 James Bursa <bursa@users.sourceforge.net>
  4.  *
  5.  * This file is part of NetSurf, http://www.netsurf-browser.org/
  6.  *
  7.  * NetSurf is free software; you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation; version 2 of the License.
  10.  *
  11.  * NetSurf is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  */
  19.  
  20. /** \file
  21.  * Browser window creation and manipulation (interface).
  22.  */
  23.  
  24. #ifndef _NETSURF_DESKTOP_BROWSER_H_
  25. #define _NETSURF_DESKTOP_BROWSER_H_
  26.  
  27. #include <stdbool.h>
  28.  
  29. #include "content/content.h"
  30. #include "desktop/frame_types.h"
  31. #include "desktop/gui.h"
  32. #include "desktop/mouse.h"
  33. #include "utils/types.h"
  34.  
  35.  
  36. struct browser_window;
  37. struct hlcache_handle;
  38. struct gui_window;
  39. struct history;
  40. struct selection;
  41. struct fetch_multipart_data;
  42.  
  43. typedef bool (*browser_caret_callback)(struct browser_window *bw, uint32_t key,
  44.                 void *p1, void *p2);
  45. typedef void (*browser_move_callback)(struct browser_window *bw,
  46.                 void *p1, void *p2);
  47. typedef bool (*browser_paste_callback)(struct browser_window *bw,
  48.                 const char *utf8, unsigned utf8_len, bool last,
  49.                 void *p1, void *p2);
  50.  
  51.  
  52. typedef enum {
  53.         DRAGGING_NONE,
  54.         DRAGGING_SELECTION,
  55.         DRAGGING_PAGE_SCROLL,
  56.         DRAGGING_FRAME,
  57.         DRAGGING_SCR_X,
  58.         DRAGGING_SCR_Y,
  59.         DRAGGING_CONTENT_SCROLLBAR,
  60.         DRAGGING_OTHER
  61. } browser_drag_type;
  62.  
  63.  
  64. extern bool browser_reformat_pending;
  65.  
  66. struct browser_window * browser_window_create(const char *url,
  67.                 struct browser_window *clone, const char *referrer,
  68.                 bool history_add, bool new_tab);
  69. void browser_window_initialise_common(struct browser_window *bw,
  70.                 struct browser_window *clone);
  71. void browser_window_go(struct browser_window *bw, const char *url,
  72.                 const char *referrer, bool history_add);
  73. void browser_window_go_post(struct browser_window *bw,
  74.                 const char *url, char *post_urlenc,
  75.                 struct fetch_multipart_data *post_multipart,
  76.                 bool add_to_history, const char *referer, bool download,
  77.                 bool verifiable, struct hlcache_handle *parent);
  78. void browser_window_go_unverifiable(struct browser_window *bw,
  79.                 const char *url, const char *referrer, bool history_add,
  80.                 struct hlcache_handle *parent);
  81. void browser_window_get_dimensions(struct browser_window *bw,
  82.                 int *width, int *height, bool scaled);
  83. void browser_window_set_dimensions(struct browser_window *bw,
  84.                 int width, int height);
  85. void browser_window_download(struct browser_window *bw,
  86.                 const char *url, const char *referrer);
  87. void browser_window_update(struct browser_window *bw, bool scroll_to_top);
  88. void browser_window_update_box(struct browser_window *bw, struct rect *rect);
  89. void browser_window_stop(struct browser_window *bw);
  90. void browser_window_reload(struct browser_window *bw, bool all);
  91. void browser_window_destroy(struct browser_window *bw);
  92. void browser_window_reformat(struct browser_window *bw, bool background,
  93.                 int width, int height);
  94. void browser_window_set_scale(struct browser_window *bw, float scale, bool all);
  95. float browser_window_get_scale(struct browser_window *bw);
  96.  
  97. /**
  98.  * Get access to any content, link URLs and objects (images) currently
  99.  * at the given (x, y) coordinates.
  100.  *
  101.  * \param bw    browser window to look inside
  102.  * \param x     x-coordinate of point of interest
  103.  * \param y     y-coordinate of point of interest
  104.  * \param data  pointer to contextual_content struct.  Its fields are updated
  105.  *              with pointers to any relevent content, or set to NULL if none.
  106.  */
  107. void browser_window_get_contextual_content(struct browser_window *bw,
  108.                 int x, int y, struct contextual_content *data);
  109.  
  110. /**
  111.  * Send a scroll request to a browser window at a particular point.  The
  112.  * 'deepest' scrollable object which can be scrolled in the requested
  113.  * direction at the given point will consume the scroll.
  114.  *
  115.  * \param bw    browser window to look inside
  116.  * \param x     x-coordinate of point of interest
  117.  * \param y     y-coordinate of point of interest
  118.  * \param scrx  number of px try to scroll something in x direction
  119.  * \param scry  number of px try to scroll something in y direction
  120.  * \return true iff scroll request has been consumed
  121.  */
  122. bool browser_window_scroll_at_point(struct browser_window *bw,
  123.                 int x, int y, int scrx, int scry);
  124.  
  125. /**
  126.  * Drop a file onto a browser window at a particular point, or determine if a
  127.  * file may be dropped onto the content at given point.
  128.  *
  129.  * \param bw    browser window to look inside
  130.  * \param x     x-coordinate of point of interest
  131.  * \param y     y-coordinate of point of interest
  132.  * \param file  path to file to be dropped, or NULL to know if drop allowed
  133.  * \return true iff file drop has been handled, or if drop possible (NULL file)
  134.  */
  135. bool browser_window_drop_file_at_point(struct browser_window *bw,
  136.                 int x, int y, char *file);
  137.  
  138. void browser_window_refresh_url_bar(struct browser_window *bw, nsurl *url,
  139.                 lwc_string *frag);
  140.  
  141. void browser_window_mouse_click(struct browser_window *bw,
  142.                 browser_mouse_state mouse, int x, int y);
  143. void browser_window_mouse_track(struct browser_window *bw,
  144.                 browser_mouse_state mouse, int x, int y);
  145. struct browser_window *browser_window_find_target(
  146.                 struct browser_window *bw, const char *target,
  147.                 browser_mouse_state mouse);
  148.  
  149. void browser_select_menu_callback(void *client_data,
  150.                 int x, int y, int width, int height);
  151.  
  152. void browser_window_redraw_rect(struct browser_window *bw, int x, int y,
  153.                 int width, int height);
  154.  
  155. void browser_window_set_status(struct browser_window *bw, const char *text);
  156. void browser_window_set_pointer(struct browser_window *bw,
  157.                 browser_pointer_shape shape);
  158. void browser_window_page_drag_start(struct browser_window *bw, int x, int y);
  159.  
  160. bool browser_window_back_available(struct browser_window *bw);
  161. bool browser_window_forward_available(struct browser_window *bw);
  162. bool browser_window_reload_available(struct browser_window *bw);
  163. bool browser_window_stop_available(struct browser_window *bw);
  164.  
  165.  
  166. /* In desktop/textinput.c */
  167. void browser_window_place_caret(struct browser_window *bw,
  168.                 int x, int y, int height,
  169.                 browser_caret_callback caret_cb,
  170.                 browser_paste_callback paste_cb,
  171.                 browser_move_callback move_cb,
  172.                 void *p1, void *p2);
  173. void browser_window_remove_caret(struct browser_window *bw);
  174. bool browser_window_key_press(struct browser_window *bw, uint32_t key);
  175. bool browser_window_paste_text(struct browser_window *bw, const char *utf8,
  176.                 unsigned utf8_len, bool last);
  177.  
  178.  
  179. /**
  180.  * Redraw an area of a window
  181.  *
  182.  * Calls the redraw function for the content,
  183.  *
  184.  * \param  bw    The window to redraw
  185.  * \param  x     coordinate for top-left of redraw
  186.  * \param  y     coordinate for top-left of redraw
  187.  * \param  clip  clip rectangle coordinates
  188.  * \param  ctx   redraw context
  189.  * \return true if successful, false otherwise
  190.  *
  191.  * The clip rectangle is guaranteed to be filled to its extents, so there is
  192.  * no need to render a solid background first.
  193.  *
  194.  * x, y and clip are coordinates from the top left of the canvas area.
  195.  *
  196.  * The top left corner of the clip rectangle is (x0, y0) and
  197.  * the bottom right corner of the clip rectangle is (x1, y1).
  198.  * Units for x, y and clip are pixels.
  199.  */
  200. bool browser_window_redraw(struct browser_window *bw, int x, int y,
  201.                 const struct rect *clip, const struct redraw_context *ctx);
  202.  
  203. /**
  204.  * Check whether browser window is ready for redraw
  205.  *
  206.  * \param  bw    The window to redraw
  207.  * \return true if browser window is ready for redraw
  208.  */
  209. bool browser_window_redraw_ready(struct browser_window *bw);
  210.  
  211. /*
  212.  * Update the extent of the inside of a browser window to that of the current
  213.  * content
  214.  *
  215.  * \param  bw   browser_window to update the extent of
  216.  */
  217. void browser_window_update_extent(struct browser_window *bw);
  218.  
  219. /*
  220.  * Get the position of the current browser window with respect to the root or
  221.  * parent browser window
  222.  *
  223.  * \param  bw     browser window to get the position of
  224.  * \param  root   true if we want position wrt root bw, false if wrt parent bw
  225.  * \param  pos_x  updated to x position of bw
  226.  * \param  pos_y  updated to y position of bw
  227.  */
  228. void browser_window_get_position(struct browser_window *bw, bool root,
  229.                 int *pos_x, int *pos_y);
  230.  
  231. /*
  232.  * Set the position of the current browser window with respect to the parent
  233.  * browser window
  234.  *
  235.  * \param  bw     browser window to set the position of
  236.  * \param  x      x position of bw
  237.  * \param  y      y position of bw
  238.  */
  239. void browser_window_set_position(struct browser_window *bw, int x, int y);
  240.  
  241. /*
  242.  * Scroll the browser window to display the passed area
  243.  *
  244.  * \param  bw           browser window to scroll
  245.  * \param  rect         area to display
  246.  */
  247. void browser_window_scroll_visible(struct browser_window *bw,
  248.                 const struct rect *rect);
  249.  
  250. /**
  251.  * Set scroll offsets for a browser window.
  252.  *
  253.  * \param  bw       The browser window
  254.  * \param  x        The x scroll offset to set
  255.  * \param  y        The y scroll offset to set
  256.  *
  257.  * TODO -- Do we really need this and browser_window_scroll_visible?
  258.  *         Ditto for gui_window_* variants.
  259.  */
  260. void browser_window_set_scroll(struct browser_window *bw, int x, int y);
  261.  
  262. /*
  263.  * Set drag type for a browser window, and inform front end
  264.  *
  265.  * \param  bw     browser window to set the type of the current drag for
  266.  * \param  type   drag type
  267.  * \param  rect   area pointer may be confined to, during drag, or NULL
  268.  */
  269. void browser_window_set_drag_type(struct browser_window *bw,
  270.                 browser_drag_type type, const struct rect *rect);
  271.  
  272. /*
  273.  * Get type of any current drag for a browser window
  274.  *
  275.  * \param  bw     browser window to set the type of the current drag for
  276.  * \return  drag type
  277.  */
  278. browser_drag_type browser_window_get_drag_type(struct browser_window *bw);
  279.  
  280. /*
  281.  * Get the root level browser window
  282.  *
  283.  * \param  bw     browser window to set the type of the current drag for
  284.  * \return  root browser window
  285.  */
  286. struct browser_window * browser_window_get_root(struct browser_window *bw);
  287.  
  288. /**
  289.  * Check whether browser window contains a selection
  290.  *
  291.  * \param  bw    The browser window
  292.  * \return true if browser window contains a selection
  293.  */
  294. bool browser_window_has_selection(struct browser_window *bw);
  295.  
  296. /**
  297.  * Set pointer to current selection.  Clears any existing selection.
  298.  *
  299.  * \param  bw    The browser window
  300.  * \param  s     The new selection
  301.  */
  302. void browser_window_set_selection(struct browser_window *bw,
  303.                 struct selection *s);
  304.  
  305. /**
  306.  * Get the current selection context from a root browser window
  307.  *
  308.  * \param  bw    The browser window
  309.  * \return the selection context, or NULL
  310.  */
  311. struct selection *browser_window_get_selection(struct browser_window *bw);
  312.  
  313.  
  314. /**
  315.  * Dump debug info concerning the browser window's contents to file
  316.  *
  317.  * \param  bw    The browser window
  318.  * \param  f    The file to dump to
  319.  */
  320. void browser_window_debug_dump(struct browser_window *bw, FILE *f);
  321.  
  322.  
  323. /* In platform specific hotlist.c. */
  324. void hotlist_visited(struct hlcache_handle *c);
  325.  
  326. /* In platform specific global_history.c. */
  327. void global_history_add(nsurl *url);
  328.  
  329. /* In platform specific theme_install.c. */
  330. #ifdef WITH_THEME_INSTALL
  331. void theme_install_start(struct hlcache_handle *c);
  332. #endif
  333.  
  334. #endif
  335.