Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.  * Copyright 2010 Vincent Sanders <vince@simtec.co.uk>
  3.  *
  4.  * This file is part of NetSurf, http://www.netsurf-browser.org/
  5.  *
  6.  * NetSurf is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; version 2 of the License.
  9.  *
  10.  * NetSurf is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19. #include <sys/types.h>
  20. #include <sys/stat.h>
  21. #include <fcntl.h>
  22. #include <sys/ioctl.h>
  23. #include <limits.h>
  24. #include <unistd.h>
  25. #include <assert.h>
  26. #include <string.h>
  27. #include <stdbool.h>
  28. #include <stdlib.h>
  29.  
  30. #include <libnsfb.h>
  31. #include <libnsfb_plot.h>
  32. #include <libnsfb_event.h>
  33.  
  34. #include "desktop/browser_private.h"
  35. #include "desktop/gui.h"
  36. #include "desktop/plotters.h"
  37. #include "desktop/netsurf.h"
  38. #include "desktop/options.h"
  39. #include "utils/log.h"
  40. #include "utils/url.h"
  41. #include "utils/messages.h"
  42. #include "utils/utils.h"
  43. #include "desktop/textinput.h"
  44. #include "render/form.h"
  45.  
  46. #include "framebuffer/gui.h"
  47. #include "framebuffer/fbtk.h"
  48. #include "framebuffer/framebuffer.h"
  49. #include "framebuffer/schedule.h"
  50. #include "framebuffer/findfile.h"
  51. #include "framebuffer/image_data.h"
  52. #include "framebuffer/font.h"
  53.  
  54. #include "content/urldb.h"
  55. #include "desktop/history_core.h"
  56. #include "content/fetch.h"
  57.  
  58. static int
  59. localhistory_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi)
  60. {
  61.         struct gui_localhistory *glh = cbi->context;
  62.         nsfb_bbox_t rbox;
  63.  
  64.         struct redraw_context ctx = {
  65.                 .interactive = true,
  66.                 .background_images = true,
  67.                 .plot = &fb_plotters
  68.         };
  69.  
  70.         rbox.x0 = fbtk_get_absx(widget);
  71.         rbox.y0 = fbtk_get_absy(widget);
  72.  
  73.         rbox.x1 = rbox.x0 + fbtk_get_width(widget);
  74.         rbox.y1 = rbox.y0 + fbtk_get_height(widget);
  75.  
  76.         nsfb_claim(fbtk_get_nsfb(widget), &rbox);
  77.  
  78.         nsfb_plot_rectangle_fill(fbtk_get_nsfb(widget), &rbox, 0xffffffff);
  79.  
  80.         history_redraw_rectangle(glh->bw->history,
  81.                                  glh->scrollx,
  82.                                  glh->scrolly,
  83.                                  fbtk_get_width(widget) + glh->scrollx,
  84.                                  fbtk_get_height(widget) + glh->scrolly,
  85.                                  0, 0, &ctx);
  86.  
  87.         nsfb_update(fbtk_get_nsfb(widget), &rbox);
  88.  
  89.         return 0;
  90. }
  91.  
  92. static int
  93. localhistory_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
  94. {
  95.         struct gui_localhistory *glh = cbi->context;
  96.  
  97.         if (cbi->event->type != NSFB_EVENT_KEY_UP)
  98.                 return 0;
  99.  
  100.         history_click(glh->bw, glh->bw->history, cbi->x, cbi->y, false);
  101.  
  102.         fbtk_set_mapping(glh->window, false);
  103.  
  104.         return 1;
  105. }
  106.  
  107. struct gui_localhistory *
  108. fb_create_localhistory(struct browser_window *bw,
  109.                        fbtk_widget_t *parent,
  110.                        int furniture_width)
  111. {
  112.        
  113.         LOG(("init local hist.."));
  114.        
  115.         struct gui_localhistory *glh;
  116. LOG(("LH calloc."));
  117.        
  118.         glh = calloc(1, sizeof(struct gui_localhistory));
  119.  
  120.  
  121.         if (glh == NULL)
  122.                 return NULL;
  123.  
  124.         glh->bw = bw;
  125.  
  126. LOG(("conatiner.."));
  127.        
  128.         /* container window */
  129.         LOG(("fbtk window"));
  130.        
  131.         glh->window = fbtk_create_window(parent, 0, 0, 0, 0, 0);
  132.  
  133. LOG(("hist user"));
  134.        
  135.         glh->history = fbtk_create_user(glh->window, 0, 0, -furniture_width, -furniture_width, glh);
  136. LOG(("hist handlers..."));
  137.        
  138.  
  139.         fbtk_set_handler(glh->history, FBTK_CBT_REDRAW, localhistory_redraw, glh);
  140.         fbtk_set_handler(glh->history, FBTK_CBT_CLICK, localhistory_click, glh);
  141.         /*
  142.           fbtk_set_handler(gw->localhistory, FBTK_CBT_INPUT, fb_browser_window_input, gw);
  143.           fbtk_set_handler(gw->localhistory, FBTK_CBT_POINTERMOVE, fb_browser_window_move, bw);
  144.         */
  145.  
  146.         /* create horizontal scrollbar */
  147.        
  148.         LOG(("init hor scroll"));
  149.        
  150.         glh->hscroll = fbtk_create_hscroll(glh->window,
  151.                                            0,
  152.                                            fbtk_get_height(glh->window) - furniture_width,
  153.                                            fbtk_get_width(glh->window) - furniture_width,
  154.                                            furniture_width,
  155.                                            FB_SCROLL_COLOUR,
  156.                                            FB_FRAME_COLOUR,
  157.                                            NULL,
  158.                                            NULL);
  159.  
  160.         LOG(("init ver scroll"));
  161.         glh->vscroll = fbtk_create_vscroll(glh->window,
  162.                                            fbtk_get_width(glh->window) - furniture_width,
  163.                                            0,
  164.                                            furniture_width,
  165.                                            fbtk_get_height(glh->window) - furniture_width,
  166.                                            FB_SCROLL_COLOUR,
  167.                                            FB_FRAME_COLOUR,
  168.                                            NULL,
  169.                                            NULL);
  170.  
  171.         LOG(("init fill"));
  172.         fbtk_create_fill(glh->window,
  173.                          fbtk_get_width(glh->window) - furniture_width,
  174.                          fbtk_get_height(glh->window) - furniture_width,
  175.                          furniture_width,
  176.                          furniture_width,
  177.                          FB_FRAME_COLOUR);
  178.  
  179.         LOG(("fine!"));
  180.         return glh;
  181. }
  182.  
  183. void
  184. fb_localhistory_map(struct gui_localhistory * glh)
  185. {
  186.         fbtk_set_zorder(glh->window, INT_MIN);
  187.         fbtk_set_mapping(glh->window, true);
  188. }
  189.