Beispiel #1
0
static HTMLObject *
check_point (HTMLObject *self,
             HTMLPainter *painter,
             gint x,
             gint y,
             guint *offset_return,
             gboolean for_cursor)
{
	HTMLEngine *e = GTK_HTML (HTML_FRAME (self)->html)->engine;

	if (x < self->x || x >= self->x + self->width
	    || y >= self->y + self->descent || y < self->y - self->ascent)
		return NULL;

	x -= self->x + html_engine_get_left_border (e) - e->x_offset;
	y -= self->y - self->ascent + html_engine_get_top_border (e) - e->y_offset;

	if (for_cursor && (x < 0 || y < e->clue->y - e->clue->ascent))
		return html_object_check_point (e->clue, e->painter, 0, e->clue->y - e->clue->ascent,
						offset_return, for_cursor);

	if (for_cursor && (x > e->clue->width - 1 || y > e->clue->y + e->clue->descent - 1))
		return html_object_check_point (e->clue, e->painter, e->clue->width - 1, e->clue->y + e->clue->descent - 1,
						offset_return, for_cursor);

	return html_object_check_point (e->clue, e->painter, x, y, offset_return, for_cursor);
}
Beispiel #2
0
static HTMLObject *
check_point (HTMLObject *self,
	     HTMLPainter *painter,
	     gint x, gint y,
	     guint *offset_return,
	     gboolean for_cursor)
{
	HTMLObject *p;
	HTMLObject *obj;
	HTMLClueAligned *clue;
	gint padding = HTML_CLUEV (self)->padding;

	if (x < self->x || x >= self->x + self->width
	    || y < self->y - self->ascent || y >= self->y + self->descent)
		return NULL;

	x = x - self->x;
	y = y - self->y + self->ascent;

	if (!for_cursor) {
		if (x < padding || y < padding) {
			if (offset_return)
				*offset_return = 0;
			return self;
		}
		if (x >= self->width - padding || y >= self->ascent + self->descent - padding) {
			if (offset_return)
				*offset_return = 1;
			return self;
		}
	}

	for (clue = HTML_CLUEALIGNED (HTML_CLUEV (self)->align_left_list);
	     clue != NULL;
	     clue = clue->next_aligned) {
		HTMLObject *parent;

		parent = HTML_OBJECT (clue)->parent;
		obj = html_object_check_point (HTML_OBJECT (clue),
					       painter,
					       x - parent->x,
					       y - parent->y + parent->ascent,
					       offset_return,
					       for_cursor);
		if (obj != NULL) {
			return obj;
		}
	}

	for (clue = HTML_CLUEALIGNED (HTML_CLUEV (self)->align_right_list);
	     clue != NULL;
	     clue = clue->next_aligned) {
		HTMLObject *parent;

		parent = HTML_OBJECT (clue)->parent;
		obj = html_object_check_point (HTML_OBJECT (clue),
					       painter,
					       x - parent->x,
					       y - parent->y + parent->ascent,
					       offset_return,
					       for_cursor);
		if (obj != NULL) {
			return obj;
		}
	}

	for (p = HTML_CLUE (self)->head; p != 0; p = p->next) {
		gint x1, y1;

		if (!for_cursor) {
			x1 = x;
			y1 = y;
		} else {
			if (x >= p->x + p->width) {
				x1 = MAX (0, p->x + p->width - 1);
			} else if (x < p->x) {
				x1 = p->x;
			} else {
				x1 = x;
			}

			if (p->next == NULL && y > p->y + p->descent - 1) {
				x1 = MAX (0, p->x + p->width - 1);
				y1 = p->y + p->descent - 1;
			} else if (p->prev == NULL && y < p->y - p->ascent) {
				y1 = p->y - p->ascent;
			} else {
				y1 = y;
			}
		}

		obj = html_object_check_point (p, painter, x1, y1, offset_return, for_cursor);
		if (obj != NULL)
			return obj;
	}

	if (!for_cursor) {
		if (x >= 0 && y >= 0 && x < self->width && y < self->ascent + self->descent) {
			if (offset_return) {
				if (x < self->width/2)
					*offset_return = 0;
				else
					*offset_return = 1;
			}
			return self;
		}
	}

	return NULL;
}