/* Draw window background and contents, including children, within clip. 
Note that when the DRAW event is sent to the window, the TFT clipping region is already set, so all TFT graphics functions called from the event handler will be subject to proper clipping automatically. */
static void win_draw_contents(struct win_window *win, const struct win_clip_region *clip)
/* Draw window background and contents, including children, within clip. 
Note that when the DRAW event is sent to the window, the TFT clipping region is already set, so all TFT graphics functions called from the event handler will be subject to proper clipping automatically. */
static void win_draw_contents(struct win_window *win, const struct win_clip_region *clip)
{
	struct win_window *child;
	gfx_set_clipping(clip->NW.x, clip->NW.y, clip->SE.x, clip->SE.y);
	if (win->attributes.background) {
		gfx_draw_bitmap_tiled(win->attributes.background, clip->NW.x,
				clip->NW.y, clip->SE.x, clip->SE.y,
				clip->origin.x,
				clip->origin.y);
	}
	win_handle_event(win, WIN_EVENT_DRAW, clip);
	child = win->top_child;
	if (child != NULL) {
		do {
			child = child->prev_sibling;
			if (child->is_mapped) {
				win_draw_child(child, clip);
			}
		} while (child != win->top_child);
	}
}