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.  * Framebuffer windowing toolkit window widget.
  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. #include <stdbool.h>
  22. #include <stdlib.h>
  23.  
  24. #include <libnsfb.h>
  25. #include <libnsfb_plot.h>
  26.  
  27. #include "desktop/browser.h"
  28.  
  29. #include "framebuffer/gui.h"
  30. #include "framebuffer/fbtk.h"
  31. #include "utils/log.h"
  32.  
  33.  
  34. #include "widget.h"
  35.  
  36. /** Window redraw callback.
  37.  *
  38.  * Called when a window requires redrawing.
  39.  *
  40.  * @param widget The widget to be redrawn.
  41.  * @param cbi The callback parameters.
  42.  * @return The callback result.
  43.  */
  44. static int
  45. fb_redraw_window(fbtk_widget_t *widget, fbtk_callback_info *cbi)
  46. {
  47.         nsfb_bbox_t bbox;
  48.         nsfb_t *nsfb;
  49.  
  50.         if ((widget->bg & 0xFF000000) == 0)
  51.                 return 0;
  52.  
  53.         nsfb = fbtk_get_nsfb(widget);
  54.  
  55.         fbtk_get_bbox(widget, &bbox);
  56.  
  57.         nsfb_claim(nsfb, &bbox);
  58.  
  59.         nsfb_plot_rectangle_fill(nsfb, &bbox, widget->bg);
  60.  
  61.         nsfb_update(nsfb, &bbox);
  62.  
  63.         return 0;
  64. }
  65.  
  66. /* exported function documented in fbtk.h */
  67. fbtk_widget_t *
  68. fbtk_create_window(fbtk_widget_t *parent,
  69.                    int x,
  70.                    int y,
  71.                    int width,
  72.                    int height,
  73.                    colour bg)
  74. {
  75.         LOG(("FBTK new window"));
  76.         fbtk_widget_t *neww;
  77.  
  78.         if (parent == NULL)
  79.                 {LOG(("FBTK no parent window"));return NULL;}
  80.  
  81.         LOG(("FBTK new widget"));
  82.         neww = fbtk_widget_new(parent, FB_WIDGET_TYPE_WINDOW, x, y, width, height);
  83.  
  84.         LOG(("FBTK set bg widget"));
  85.        
  86.         neww->bg = bg;
  87.  
  88.         LOG(("FBTK set handler"));
  89.         fbtk_set_handler(neww, FBTK_CBT_REDRAW, fb_redraw_window, NULL);
  90.  
  91.         return neww;
  92. }
  93.  
  94. /*
  95.  * Local Variables:
  96.  * c-basic-offset:8
  97.  * End:
  98.  */
  99.