NetSurf
bitmap.c
Go to the documentation of this file.
1/*
2 * Copyright 2010 Vincent Sanders <vince@simtec.co.uk>
3 *
4 * Framebuffer windowing toolkit bitmaped image 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
28
29#include "framebuffer/gui.h"
30#include "framebuffer/fbtk.h"
32
33#include "widget.h"
34
35static int
37{
38 nsfb_bbox_t bbox;
39 nsfb_bbox_t rect;
40 nsfb_t *nsfb;
41
42 nsfb = fbtk_get_nsfb(widget);
43
44 fbtk_get_bbox(widget, &bbox);
45
46 rect = bbox;
47
48 nsfb_claim(nsfb, &bbox);
49
50 /* clear background */
51 if ((widget->bg & 0xFF000000) != 0) {
52 /* transparent polygon filling isnt working so fake it */
53 nsfb_plot_rectangle_fill(nsfb, &bbox, widget->bg);
54 }
55
56 /* plot the image */
57 nsfb_plot_bitmap(nsfb,
58 &rect,
59 (nsfb_colour_t *)widget->u.bitmap.bitmap->pixdata,
60 widget->u.bitmap.bitmap->width,
61 widget->u.bitmap.bitmap->height,
62 widget->u.bitmap.bitmap->width,
63 !widget->u.bitmap.bitmap->opaque);
64
65 nsfb_update(nsfb, &bbox);
66
67 return 0;
68}
69
70/* exported function documented in fbtk.h */
71void
73{
74 if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_BITMAP))
75 return;
76
77 widget->u.bitmap.bitmap = image;
78
79 fbtk_request_redraw(widget);
80}
81
82/* exported function documented in fbtk.h */
85 int x,
86 int y,
87 int width,
88 int height,
89 colour c,
90 struct fbtk_bitmap *image)
91{
92 fbtk_widget_t *neww;
93
95
96 neww->bg = c;
97 neww->mapped = true;
98 neww->u.bitmap.bitmap = image;
99
101
102 return neww;
103}
104
105/* exported function documented in fbtk.h */
108 int x,
109 int y,
110 int width,
111 int height,
112 colour c,
113 struct fbtk_bitmap *image,
114 fbtk_callback click,
115 void *pw)
116{
117 fbtk_widget_t *neww;
118
120
121 neww->bg = c;
122 neww->mapped = true;
123 neww->u.bitmap.bitmap = image;
124
126 fbtk_set_handler(neww, FBTK_CBT_CLICK, click, pw);
128
129 return neww;
130}
131
132/*
133 * Local Variables:
134 * c-basic-offset:8
135 * End:
136 */
Browser window creation and manipulation interface.
wimp_w parent
Definition: dialog.c:88
int fbtk_set_ptr(fbtk_widget_t *widget, fbtk_callback_info *cbi)
set pointer to bitmap in context.
Definition: fbtk.c:393
fbtk_widget_t * fbtk_widget_new(fbtk_widget_t *parent, enum fbtk_widgettype_e type, int x, int y, int width, int height)
creates a new widget and insert it into to hierachy.
Definition: fbtk.c:546
fbtk_callback fbtk_set_handler(fbtk_widget_t *widget, fbtk_callback_type cbt, fbtk_callback cb, void *pw)
Set a callback handler.
Definition: fbtk.c:693
@ FBTK_CBT_REDRAW
Definition: fbtk.h:44
@ FBTK_CBT_POINTERENTER
Definition: fbtk.h:43
@ FBTK_CBT_CLICK
Definition: fbtk.h:39
void fbtk_request_redraw(fbtk_widget_t *widget)
Indicate a widget should be redrawn.
Definition: fbtk.c:82
bool fbtk_get_bbox(fbtk_widget_t *widget, struct nsfb_bbox_s *bbox)
Get a widget's bounding box in absolute screen co-ordinates.
nsfb_t * fbtk_get_nsfb(fbtk_widget_t *widget)
Retrieve the framebuffer library handle from toolkit widget.
Definition: fbtk.c:802
int(* fbtk_callback)(fbtk_widget_t *widget, fbtk_callback_info *cbi)
Definition: fbtk.h:83
static nsfb_t * nsfb
Definition: framebuffer.c:45
fbtk_widget_t * fbtk_create_button(fbtk_widget_t *parent, int x, int y, int width, int height, colour c, struct fbtk_bitmap *image, fbtk_callback click, void *pw)
Create a button widget with an image.
Definition: bitmap.c:107
fbtk_widget_t * fbtk_create_bitmap(fbtk_widget_t *parent, int x, int y, int width, int height, colour c, struct fbtk_bitmap *image)
Create a bitmap widget.
Definition: bitmap.c:84
static int fb_redraw_bitmap(fbtk_widget_t *widget, fbtk_callback_info *cbi)
Definition: bitmap.c:36
void fbtk_set_bitmap(fbtk_widget_t *widget, struct fbtk_bitmap *image)
Change the bitmap in a widget.
Definition: bitmap.c:72
struct fbtk_bitmap hand_image
int width
Definition: gui.c:160
int height
Definition: gui.c:161
framebuffer toolkit bitmaps
Definition: fbtk.h:63
uint8_t * pixdata
Definition: fbtk.h:66
int height
Definition: fbtk.h:65
int width
Definition: fbtk.h:64
bool opaque
Definition: fbtk.h:67
widget callback information
Definition: fbtk.h:52
Widget description.
Definition: widget.h:120
enum fbtk_widgettype_e type
The type of the widget.
Definition: widget.h:154
bool mapped
The widget is mapped/visible .
Definition: widget.h:130
struct fbtk_bitmap * bitmap
Definition: widget.h:177
colour bg
Definition: widget.h:137
union fbtk_widget_s::@35 u
Rectangle coordinates.
Definition: types.h:40
uint32_t colour
Colour type: XBGR.
Definition: types.h:35
struct rect rect
Rectangle coordinates.
@ FB_WIDGET_TYPE_BITMAP
Definition: widget.h:27