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 2004 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.  * Interface to platform-specific gui functions.
  22.  */
  23.  
  24. #ifndef _NETSURF_DESKTOP_GUI_H_
  25. #define _NETSURF_DESKTOP_GUI_H_
  26.  
  27. typedef enum {
  28.         GUI_SAVE_SOURCE,
  29.         GUI_SAVE_DRAW,
  30.         GUI_SAVE_PDF,
  31.         GUI_SAVE_TEXT,
  32.         GUI_SAVE_COMPLETE,
  33.         GUI_SAVE_OBJECT_ORIG,
  34.         GUI_SAVE_OBJECT_NATIVE,
  35.         GUI_SAVE_LINK_URI,
  36.         GUI_SAVE_LINK_URL,
  37.         GUI_SAVE_LINK_TEXT,
  38.         GUI_SAVE_HOTLIST_EXPORT_HTML,
  39.         GUI_SAVE_HISTORY_EXPORT_HTML,
  40.         GUI_SAVE_TEXT_SELECTION,
  41.         GUI_SAVE_CLIPBOARD_CONTENTS
  42. } gui_save_type;
  43.  
  44. typedef enum {
  45.         GDRAGGING_NONE,
  46.         GDRAGGING_SCROLLBAR,
  47.         GDRAGGING_OTHER
  48. } gui_drag_type;
  49.  
  50. struct gui_window;
  51. struct gui_download_window;
  52. struct browser_window;
  53. struct selection;
  54. struct form_control;
  55.  
  56. #include <stdbool.h>
  57.  
  58. #include <libwapcaplet/libwapcaplet.h>
  59. #include <libcss/libcss.h>
  60.  
  61. #include "utils/config.h"
  62. #include "content/hlcache.h"
  63. #include "desktop/download.h"
  64. #include "desktop/mouse.h"
  65. #include "desktop/search.h"
  66. #include "utils/errors.h"
  67.  
  68. /** \todo remove these when each frontend calls nslog_init */
  69. #include <stdio.h>
  70. bool nslog_ensure(FILE *fptr);
  71.  
  72. void gui_poll(bool active);
  73. void gui_quit(void);
  74.  
  75. struct gui_window *gui_create_browser_window(struct browser_window *bw,
  76.                 struct browser_window *clone, bool new_tab);
  77. void gui_window_destroy(struct gui_window *g);
  78. void gui_window_set_title(struct gui_window *g, const char *title);
  79. void gui_window_redraw_window(struct gui_window *g);
  80. void gui_window_update_box(struct gui_window *g,
  81.                 const struct rect *rect);
  82. bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy);
  83. void gui_window_set_scroll(struct gui_window *g, int sx, int sy);
  84. void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
  85.                 int x1, int y1);
  86. void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
  87.                 bool scaled);
  88. void gui_window_update_extent(struct gui_window *g);
  89. void gui_window_set_status(struct gui_window *g, const char *text);
  90. void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape);
  91. void gui_window_hide_pointer(struct gui_window *g);
  92. void gui_window_set_url(struct gui_window *g, const char *url);
  93. void gui_window_start_throbber(struct gui_window *g);
  94. void gui_window_stop_throbber(struct gui_window *g);
  95. void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon);
  96. void gui_window_set_search_ico(hlcache_handle *ico);
  97. void gui_window_place_caret(struct gui_window *g, int x, int y, int height);
  98. void gui_window_remove_caret(struct gui_window *g);
  99. void gui_window_new_content(struct gui_window *g);
  100. bool gui_window_scroll_start(struct gui_window *g);
  101.  
  102. bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
  103.                 const struct rect *rect);
  104.  
  105. void gui_window_save_link(struct gui_window *g, const char *url,
  106.                 const char *title);
  107.  
  108. struct gui_download_window *gui_download_window_create(download_context *ctx,
  109.                 struct gui_window *parent);
  110. nserror gui_download_window_data(struct gui_download_window *dw,
  111.                 const char *data, unsigned int size);
  112. void gui_download_window_error(struct gui_download_window *dw,
  113.                 const char *error_msg);
  114. void gui_download_window_done(struct gui_download_window *dw);
  115.  
  116. void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
  117.                 struct gui_window *g);
  118. void gui_drag_save_selection(struct selection *s, struct gui_window *g);
  119. void gui_start_selection(struct gui_window *g);
  120. void gui_clear_selection(struct gui_window *g);
  121.  
  122.  
  123.  
  124. /**
  125.  * Core asks front end for clipboard contents.
  126.  *
  127.  * \param  buffer  UTF-8 text, allocated by front end, ownership yeilded to core
  128.  * \param  length  Byte length of UTF-8 text in buffer
  129.  */
  130. void gui_get_clipboard(char **buffer, size_t *length);
  131.  
  132. typedef struct nsnsclipboard_styles {
  133.         size_t start;                   /**< Start of run */
  134.  
  135.         plot_font_style_t style;        /**< Style to give text run */
  136. } nsclipboard_styles;
  137. /**
  138.  * Core tells front end to put given text in clipboard
  139.  *
  140.  * \param  buffer    UTF-8 text, owned by core
  141.  * \param  length    Byte length of UTF-8 text in buffer
  142.  * \param  styles    Array of styles given to text runs, owned by core, or NULL
  143.  * \param  n_styles  Number of text run styles in array
  144.  */
  145. void gui_set_clipboard(const char *buffer, size_t length,
  146.                 nsclipboard_styles styles[], int n_styles);
  147.  
  148.  
  149.  
  150. void gui_create_form_select_menu(struct browser_window *bw,
  151.                 struct form_control *control);
  152.  
  153. void gui_launch_url(const char *url);
  154.  
  155. struct ssl_cert_info;
  156.  
  157. void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
  158.                 unsigned long num, nserror (*cb)(bool proceed, void *pw),
  159.                 void *cbpw);
  160.  
  161. /**
  162.  * Callback to translate resource to full url.
  163.  *
  164.  * Transforms a resource: path into a full URL. The returned URL
  165.  * is used as the target for a redirect. The caller takes ownership of
  166.  * the returned nsurl including unrefing it when finished with it.
  167.  *
  168.  * \param path The path of the resource to locate.
  169.  * \return A string containing the full URL of the target object or
  170.  *         NULL if no suitable resource can be found.
  171.  */
  172. nsurl* gui_get_resource_url(const char *path);
  173.  
  174. /** css callback to obtain named system colours from a frontend. */
  175. css_error gui_system_colour(void *pw, lwc_string *name, css_color *color);
  176.  
  177. /** Obtain a named system colour from a frontend. */
  178. colour gui_system_colour_char(const char *name);
  179.  
  180. bool gui_system_colour_init(void);
  181. void gui_system_colour_finalize(void);
  182.  
  183. #endif
  184.