Subversion Repositories Kolibri OS

Rev

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