Subversion Repositories Kolibri OS

Rev

Rev 4364 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3584 sourcerer 1
/*
2
 * Copyright 2010 Vincent Sanders 
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 .
19
 */
20
 
21
#include 
22
#include 
23
 
24
#include 
25
#include 
26
 
27
#include "desktop/browser.h"
28
 
29
#include "framebuffer/gui.h"
30
#include "framebuffer/fbtk.h"
31
#include "framebuffer/image_data.h"
32
 
33
#include "utils/log.h"
34
#include 
35
 
36
#include "widget.h"
37
 
5043 ashmew2 38
#ifdef DBG
39
#undef DBG
40
#endif
41
//#define DBG(s) __menuet__debug_out(s) /* For the debug messages in BOARD */
42
#define DBG(s) LOG((s))            /* So that we see debug in Netsurf's LOG files */
43
 
44
 
3584 sourcerer 45
static int
46
fb_redraw_bitmap(fbtk_widget_t *widget, fbtk_callback_info *cbi)
47
{
5043 ashmew2 48
	/* LOG(("REDRAW BITMAP")); */
49
	//DBG("REDRAW BITMAP");
3584 sourcerer 50
	nsfb_bbox_t bbox;
51
	nsfb_bbox_t rect;
52
	nsfb_t *nsfb;
53
 
5043 ashmew2 54
	/* LOG(("REDRAW BITMAP 1 ")); */
55
	//DBG("REDRAW BITMAP 1");
3584 sourcerer 56
 
57
 
58
	nsfb = fbtk_get_nsfb(widget);
59
 
5043 ashmew2 60
	/* LOG(("REDRAW BITMAP 2")); */
61
	//DBG("REDRAW BITMAP 2");
3584 sourcerer 62
 
63
 
64
	fbtk_get_bbox(widget, &bbox);
65
 
66
	rect = bbox;
67
 
5043 ashmew2 68
	/* LOG(("REDRAW BITMAP 3 ")); */
69
	//DBG("REDRAW BITMAP 3");
3584 sourcerer 70
 
71
 
72
	nsfb_claim(nsfb, &bbox);
73
 
5043 ashmew2 74
	/* LOG(("REDRAW BITMAP 4")); */
75
	//DBG("REDRAW BITMAP 4");
3584 sourcerer 76
 
77
	/* clear background */
78
	if ((widget->bg & 0xFF000000) != 0) {
79
		/* transparent polygon filling isnt working so fake it */
80
 
5043 ashmew2 81
			/* LOG(("REDRAW BITMAP 5")); */
82
	//DBG("REDRAW BITMAP 5");
3584 sourcerer 83
 
84
		nsfb_plot_rectangle_fill(nsfb, &bbox, widget->bg);
85
	}
86
 
5043 ashmew2 87
	/* LOG(("REDRAW BITMAP 6")); */
88
	//DBG("REDRAW BITMAP 6\n");
3584 sourcerer 89
 
90
	/* plot the image */
91
 
5043 ashmew2 92
	/* LOG(("STUB: DON'T REAL DRAW")); */
93
	//DBG("STUB: DON'T REAL DRAW\n");
3584 sourcerer 94
 
95
 
5043 ashmew2 96
	/* LOG(("pixdata is %x", (nsfb_colour_t *)widget->u.bitmap.bitmap->pixdata)); */
97
	/* LOG(("pixdata is w:%d h:%d",widget->u.bitmap.bitmap->width, */
98
	/* 		 widget->u.bitmap.bitmap->height)); */
3584 sourcerer 99
 
100
	//hmm
101
 
102
	//int zap;
103
	//if (widget->u.bitmap.bitmap->width % 4 != 0) {
104
	//	zap = widget->u.bitmap.bitmap->width + 2; }
105
 
106
	//nsfb_plot_rectangle_fill(nsfb, &rect, 0xFFFFFF);
107
 
108
 
109
	nsfb_plot_bitmap(nsfb,
110
			 &rect,
111
			 (nsfb_colour_t *)widget->u.bitmap.bitmap->pixdata,
112
			 //0, 0, 0,
113
			 widget->u.bitmap.bitmap->width,
114
			 widget->u.bitmap.bitmap->height,
115
			 widget->u.bitmap.bitmap->width,
116
			 !widget->u.bitmap.bitmap->opaque);
117
 
118
 
119
 
120
 
121
 
5043 ashmew2 122
	/* LOG(("REDRAW BITMAP 7")); */
123
	//DBG("REDRAW BITMAP 7\n");
3584 sourcerer 124
 
125
	nsfb_update(nsfb, &bbox);
126
 
5043 ashmew2 127
	/* LOG(("REDRAW BITMAP OK\n")); */
128
	//DBG("REDRAW BITMAP OK\n");
3584 sourcerer 129
 
130
	return 0;
131
}
132
 
133
/* exported function documented in fbtk.h */
134
void
135
fbtk_set_bitmap(fbtk_widget_t *widget, struct fbtk_bitmap *image)
136
{
5043 ashmew2 137
	/* LOG(("SET BITMAP")); */
138
	//DBG("set BITMAP");
3584 sourcerer 139
	if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_BITMAP))
140
		return;
141
 
142
	widget->u.bitmap.bitmap = image;
143
 
144
	fbtk_request_redraw(widget);
145
}
146
 
147
/* exported function documented in fbtk.h */
148
fbtk_widget_t *
149
fbtk_create_bitmap(fbtk_widget_t *parent,
150
		   int x,
151
		   int y,
152
		   int width,
153
		   int height,
154
		   colour c,
155
		   struct fbtk_bitmap *image)
156
{
5043 ashmew2 157
	/* LOG(("CREATE BITMAP")); */
158
	//DBG("cr BITMAP");
3584 sourcerer 159
	fbtk_widget_t *neww;
160
 
161
	neww = fbtk_widget_new(parent, FB_WIDGET_TYPE_BITMAP, x, y, width, height);
162
 
163
	neww->bg = c;
164
	neww->mapped = true;
165
	neww->u.bitmap.bitmap = image;
166
 
167
	fbtk_set_handler(neww, FBTK_CBT_REDRAW, fb_redraw_bitmap, NULL);
168
 
169
	return neww;
170
}
171
 
172
/* exported function documented in fbtk.h */
173
fbtk_widget_t *
174
fbtk_create_button(fbtk_widget_t *parent,
175
		   int x,
176
		   int y,
177
		   int width,
178
		   int height,
179
		   colour c,
180
		   struct fbtk_bitmap *image,
181
		   fbtk_callback click,
182
		   void *pw)
183
{
184
	fbtk_widget_t *neww;
185
 
5043 ashmew2 186
	/* LOG(("CREATE BUTTON BITMAP")); */
187
	//DBG("cr bb BITMAP");
3584 sourcerer 188
	neww = fbtk_widget_new(parent, FB_WIDGET_TYPE_BITMAP, x, y, width, height);
189
 
190
	neww->bg = c;
191
	neww->mapped = true;
192
	neww->u.bitmap.bitmap = image;
193
 
194
	fbtk_set_handler(neww, FBTK_CBT_REDRAW, fb_redraw_bitmap, NULL);
195
	fbtk_set_handler(neww, FBTK_CBT_CLICK, click, pw);
196
	fbtk_set_handler(neww, FBTK_CBT_POINTERENTER, fbtk_set_ptr, &hand_image);
197
 
198
	return neww;
199
}
200
 
201
/*
202
 * Local Variables:
203
 * c-basic-offset:8
204
 * End:
205
 */