예제 #1
0
static gint
calc_preferred_width (HTMLObject *o,
		      HTMLPainter *painter)
{
	return (* HTML_OBJECT_CLASS (parent_class)->calc_preferred_width) (o, painter)
		+ 2 * html_painter_get_pixel_size (painter) * (HTML_CLUEV (o)->padding + HTML_CLUEV (o)->border_width);
}
예제 #2
0
static void
destroy (HTMLObject *o)
{
	HTMLEmbedded *element;

	d (printf ("destroy embedded %p\n", o));
	element = HTML_EMBEDDED (o);

	if (element->name)
		g_free (element->name);
	if (element->value)
		g_free (element->value);
	if (element->widget) {
		GtkWidget *parent;

		gtk_widget_hide (element->widget);
		parent = gtk_widget_get_parent (element->widget);
		g_signal_handlers_disconnect_matched (element->widget, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, element);
		if (element->changed_id > 0)
			g_signal_handler_disconnect (element->widget, element->changed_id);
		g_object_set_data (G_OBJECT (element->widget), "embeddedelement", NULL);
		if (parent && element->parent) {
			g_assert (parent == element->parent);
			gtk_container_remove (GTK_CONTAINER (element->parent), element->widget);
		} else {
			g_object_ref_sink (element->widget);
			g_object_unref (element->widget);
		}
	}

	HTML_OBJECT_CLASS (parent_class)->destroy (o);
}
예제 #3
0
void
html_embedded_init (HTMLEmbedded *element,
                   HTMLEmbeddedClass *klass,
                   GtkWidget *parent,
                   const gchar *name,
                   const gchar *value)
{
	HTMLObject *object;

	d (printf ("embedded %p init\n", element));

	object = HTML_OBJECT (element);
	html_object_init (object, HTML_OBJECT_CLASS (klass));

	element->form = NULL;
	if (name)
		element->name = g_strdup (name);
	else
		element->name = g_strdup ("");
	if (value)
		element->value = g_strdup (value);
	else
		element->value = g_strdup ("");
	element->widget = NULL;
	element->parent = parent;
	element->width  = 0;
	element->height = 0;
	element->abs_x  = element->abs_y = -1;
	element->changed_id = 0;
}
예제 #4
0
void
html_embedded_class_init (HTMLEmbeddedClass *klass,
                          HTMLType type,
                          guint size)
{
	HTMLObjectClass *object_class;

	g_return_if_fail (klass != NULL);

	object_class = HTML_OBJECT_CLASS (klass);
	html_object_class_init (object_class, type, size);

	/* HTMLEmbedded methods.   */
	klass->reset = reset;
	klass->encode = encode;

	/* HTMLObject methods.   */
	object_class->destroy = destroy;
	object_class->copy = copy;
	object_class->draw = draw;
	object_class->accepts_cursor = accepts_cursor;
	object_class->calc_size = html_embedded_real_calc_size;
	object_class->calc_min_width = calc_min_width;

	parent_class = &html_object_class;
}
예제 #5
0
static void
draw (HTMLObject *o,
      HTMLPainter *p,
      gint x,
      gint y,
      gint width,
      gint height,
      gint tx,
      gint ty)
{
	HTMLFrame   *frame  = HTML_FRAME (o);
	HTMLEngine   *e       = GTK_HTML (frame->html)->engine;
	GdkRectangle paint;

	if (G_OBJECT_TYPE (e->painter) == HTML_TYPE_PRINTER) {
		gint pixel_size = html_painter_get_pixel_size (e->painter);

		if (!html_object_intersect (o, &paint, x, y, width, height))
			return;

		html_object_draw (e->clue, e->painter,
				  x, y,
				  width - pixel_size * (html_engine_get_left_border (e) + html_engine_get_right_border (e)),
				  height - pixel_size * (html_engine_get_top_border (e) + html_engine_get_bottom_border (e)),
				  tx + pixel_size * html_engine_get_left_border (e), ty + pixel_size * html_engine_get_top_border (e));
	} else
		(*HTML_OBJECT_CLASS (parent_class)->draw) (o, p, x, y, width, height, tx, ty);
}
예제 #6
0
static void
copy (HTMLObject *self,
      HTMLObject *dest)
{
	(* HTML_OBJECT_CLASS (parent_class)->copy) (self, dest);

	HTML_CLUEALIGNED (dest)->next_aligned = NULL;
}
예제 #7
0
static void
reset (HTMLObject *clue)
{
	HTMLClueV *cluev;

	cluev = HTML_CLUEV (clue);

	HTML_OBJECT_CLASS (&html_clue_class)->reset (clue);

	cluev->align_left_list = NULL;
	cluev->align_right_list = NULL;
}
예제 #8
0
static void
set_max_height (HTMLObject *o, HTMLPainter *painter, gint height)
{
	HTMLClue *clue = HTML_CLUE (o);

	/* Is it necessary to calc size here? It doesn't seem to. */
	/* html_object_calc_size (o, painter, NULL); */
	if (o->ascent < height) {
		(* HTML_OBJECT_CLASS (parent_class)->set_max_height) (o, painter, height);
		clue->curr = NULL;
	}
}
예제 #9
0
static void
destroy (HTMLObject *o)
{
	HTMLTextInput *ti;

	ti = HTML_TEXTINPUT (o);

	if (ti->default_text)
		g_free (ti->default_text);

	HTML_OBJECT_CLASS (parent_class)->destroy (o);
}
예제 #10
0
static void
copy (HTMLObject *self,
      HTMLObject *dest)
{
	(* HTML_OBJECT_CLASS (parent_class)->copy) (self, dest);

	HTML_TEXTINPUT (dest)->size = HTML_TEXTINPUT (self)->size;
	HTML_TEXTINPUT (dest)->maxlen = HTML_TEXTINPUT (self)->maxlen;
	HTML_TEXTINPUT (dest)->password = HTML_TEXTINPUT (self)->password;
	HTML_TEXTINPUT (dest)->default_text = g_strdup (HTML_TEXTINPUT (self)->default_text);

	/* g_warning ("HTMLTextInput::copy is not complete"); */
}
예제 #11
0
static void
destroy (HTMLObject *o)
{
	HTMLFrame *frame = HTML_FRAME (o);

	frame_set_gdk_painter (frame, NULL);

	if (frame->html) {
		g_signal_handlers_disconnect_matched (frame->html, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, o);
		frame->html = NULL;
	}
	g_free ((frame)->url);

	HTML_OBJECT_CLASS (parent_class)->destroy (o);
}
예제 #12
0
static void
html_cluev_destroy (HTMLObject *self)
{
	HTMLClueV *cluev = HTML_CLUEV (self);

	if (cluev->border_color)
		html_color_unref (cluev->border_color);
	cluev->border_color = NULL;

	if (cluev->background_color)
		html_color_unref (cluev->background_color);
	cluev->background_color = NULL;

	(* HTML_OBJECT_CLASS (parent_class)->destroy) (self);
}
예제 #13
0
static void
copy (HTMLObject *self,
      HTMLObject *dest)
{
	(* HTML_OBJECT_CLASS (parent_class)->copy) (self, dest);

	/* FIXME g_warning ("HTMLEmbedded::copy is not complete."); */

	HTML_EMBEDDED (dest)->name = g_strdup (HTML_EMBEDDED (self)->name);
	HTML_EMBEDDED (dest)->value = g_strdup (HTML_EMBEDDED (self)->value);
	HTML_EMBEDDED (dest)->form = HTML_EMBEDDED (self)->form;

	HTML_EMBEDDED (dest)->widget = NULL;
	HTML_EMBEDDED (dest)->parent = NULL;

	HTML_EMBEDDED (dest)->abs_x = HTML_EMBEDDED (self)->abs_x;
	HTML_EMBEDDED (dest)->abs_y = HTML_EMBEDDED (self)->abs_y;
}
예제 #14
0
static gboolean
html_clue_aligned_real_calc_size (HTMLObject *o, HTMLPainter *painter, GList **changed_objs)
{
	HTMLObject *obj;
	gboolean changed;
	gint old_width, old_ascent;

	changed = HTML_OBJECT_CLASS (&html_clue_class)->calc_size (o, painter, changed_objs);

	old_width = o->width;
	old_ascent = o->ascent;

	o->width = 0;
	o->ascent = ALIGN_BORDER;
	o->descent = 0;

	/* FIXME: Shouldn't it call `calc_size()' on the children first!?!  */

	for (obj = HTML_CLUE (o)->head; obj != 0; obj = obj->next) {
		if (obj->width > o->width)
			o->width = obj->width;

		o->ascent += obj->ascent + obj->descent;

		if (obj->x != ALIGN_BORDER) {
			obj->x = ALIGN_BORDER;
			changed = TRUE;
		}

		if (obj->y != o->ascent - obj->descent) {
			obj->y = o->ascent - obj->descent;
			changed = TRUE;
		}
	}

	o->ascent += ALIGN_BORDER;
	o->width += ALIGN_BORDER * 2;

	if (old_width != o->width || old_ascent != o->ascent)
		changed = TRUE;

	return changed;
}
예제 #15
0
void
html_cluealigned_class_init (HTMLClueAlignedClass *klass,
			     HTMLType type,
			     guint size)
{
	HTMLObjectClass *object_class;
	HTMLClueClass *clue_class;

	clue_class = HTML_CLUE_CLASS (klass);
	object_class = HTML_OBJECT_CLASS (klass);

	html_clue_class_init (clue_class, type, size);

	/* HTMLObject functions FIXME destroy? */

	object_class->copy = copy;
	object_class->calc_size = html_clue_aligned_real_calc_size;
	object_class->set_max_width = set_max_width;

	parent_class = &html_clue_class;
}
예제 #16
0
static void
copy (HTMLObject *self,
      HTMLObject *dest)
{
	(* HTML_OBJECT_CLASS (parent_class)->copy) (self, dest);

	HTML_CLUEV (dest)->padding = HTML_CLUEV (self)->padding;

	HTML_CLUEV (dest)->border_width = HTML_CLUEV (self)->border_width;
	HTML_CLUEV (dest)->border_style = HTML_CLUEV (self)->border_style;
	HTML_CLUEV (dest)->border_color = HTML_CLUEV (self)->border_color;
	if (HTML_CLUEV (dest)->border_color)
		html_color_ref (HTML_CLUEV (dest)->border_color);
	HTML_CLUEV (dest)->background_color = HTML_CLUEV (self)->background_color;
	if (HTML_CLUEV (dest)->background_color)
		html_color_ref (HTML_CLUEV (dest)->background_color);

	HTML_CLUEV (dest)->align_left_list = NULL;
	HTML_CLUEV (dest)->align_right_list = NULL;

	HTML_CLUEV (dest)->dir = HTML_CLUEV (self)->dir;
}
예제 #17
0
void
html_text_input_class_init (HTMLTextInputClass *klass,
                            HTMLType type,
                            guint object_size)
{
	HTMLEmbeddedClass *element_class;
	HTMLObjectClass *object_class;

	element_class = HTML_EMBEDDED_CLASS (klass);
	object_class = HTML_OBJECT_CLASS (klass);

	html_embedded_class_init (element_class, type, object_size);

	/* HTMLObject methods.   */
	object_class->destroy = destroy;
	object_class->copy = copy;

	/* HTMLEmbedded methods.   */
	element_class->reset = reset;
	element_class->encode = encode;

	parent_class = &html_embedded_class;
}
예제 #18
0
static gboolean
html_frame_real_calc_size (HTMLObject *o,
                           HTMLPainter *painter,
                           GList **changed_objs)
{
	HTMLFrame *frame;
	HTMLEngine *e;
	gint old_width, old_ascent, old_descent;

	old_width = o->width;
	old_ascent = o->ascent;
	old_descent = o->descent;

	frame = HTML_FRAME (o);
	e     = GTK_HTML (frame->html)->engine;

	if ((frame->width < 0) && (frame->height < 0)) {
		if (e->clue) {
			html_engine_calc_size (e, changed_objs);
			e->width = html_engine_get_doc_width (e);
			e->height = html_engine_get_doc_height (e);
		}
		html_frame_set_scrolling (frame, GTK_POLICY_NEVER);

		o->width = e->width;
		o->ascent = e->height;
		o->descent = 0;
	} else
		return (* HTML_OBJECT_CLASS (parent_class)->calc_size) (o, painter, changed_objs);

	if (o->descent != old_descent
	    || o->ascent != old_ascent
	    || o->width != old_width)
		return TRUE;

	return FALSE;
}
예제 #19
0
void
html_frame_class_init (HTMLFrameClass *klass,
                        HTMLType type,
                        guint size)
{
	HTMLEmbeddedClass *embedded_class;
	HTMLObjectClass  *object_class;

	g_return_if_fail (klass != NULL);

	embedded_class = HTML_EMBEDDED_CLASS (klass);
	object_class = HTML_OBJECT_CLASS (klass);

	html_embedded_class_init (embedded_class, type, size);
	parent_class = &html_embedded_class;

	object_class->destroy                 = destroy;
	object_class->calc_size               = html_frame_real_calc_size;
	object_class->calc_min_width          = calc_min_width;
	object_class->set_painter             = set_painter;
	/* object_class->reset                   = reset; */
	object_class->draw                    = draw;
	object_class->set_max_width           = set_max_width;
	object_class->forall                  = forall;
	object_class->check_page_split        = check_page_split;
	object_class->search                  = search;
	object_class->head                    = head;
	object_class->tail                    = tail;
	object_class->get_engine              = get_engine;
	object_class->check_point             = check_point;
	object_class->is_container            = is_container;
	object_class->append_selection_string = append_selection_string;
	object_class->select_range            = select_range;
	object_class->find_anchor             = find_anchor;

	embedded_class->reparent = reparent;
}
예제 #20
0
void
html_cluev_class_init (HTMLClueVClass *klass,
		       HTMLType type,
		       guint size)
{
	HTMLObjectClass *object_class;
	HTMLClueClass *clue_class;

	object_class = HTML_OBJECT_CLASS (klass);
	clue_class = HTML_CLUE_CLASS (klass);

	html_clue_class_init (clue_class, type, size);

	object_class->copy = copy;
	object_class->calc_size = html_cluev_real_calc_size;
	object_class->calc_min_width = calc_min_width;
	object_class->calc_preferred_width = calc_preferred_width;
	object_class->relayout = relayout;
	object_class->set_max_width = set_max_width;
	object_class->set_max_height = set_max_height;
	object_class->reset = reset;
	object_class->draw = draw;
	object_class->check_point = check_point;
	object_class->get_left_margin = get_left_margin;
	object_class->get_right_margin = get_right_margin;
	object_class->get_direction = html_cluev_real_get_direction;
	object_class->destroy = html_cluev_destroy;

	clue_class->get_left_clear = get_left_clear;
	clue_class->get_right_clear = get_right_clear;
	clue_class->find_free_area = find_free_area;
	clue_class->appended = appended;
	clue_class->append_left_aligned = append_left_aligned;
	clue_class->append_right_aligned = append_right_aligned;

	parent_class = &html_clue_class;
}
예제 #21
0
static void
draw (HTMLObject *o,
      HTMLPainter *p,
      gint x, gint y,
      gint width, gint height,
      gint tx, gint ty)
{
	HTMLObject *aclue;
	HTMLClueV *cluev;
	GdkRectangle paint;

	cluev = HTML_CLUEV (o);

	if (!html_object_intersect (o, &paint, x, y, width, height))
		return;

	if (cluev->background_color) {
		html_painter_alloc_color (p, &cluev->background_color->color);
		html_painter_draw_background (p,
					      &cluev->background_color->color,
					      NULL, tx + paint.x, ty + paint.y, paint.width, paint.height, 0, 0);
	}

	HTML_OBJECT_CLASS (&html_clue_class)->draw (o,
						    p,
						    x, y ,
						    width, height,
						    tx, ty);

	tx += o->x;
	ty += o->y - o->ascent;

	for ( aclue = HTML_CLUEV (o)->align_left_list;
	      aclue != NULL;
	      aclue = cluev_next_aligned (aclue) ) {
		html_object_draw (aclue,
				  p,
				  x - o->x - aclue->parent->x,
				  y - (o->y - o->ascent) - (aclue->parent->y - aclue->parent->ascent),
				  width - aclue->parent->x, height,
				  tx + aclue->parent->x,
				  ty + aclue->parent->y - aclue->parent->ascent);
	}

	for (aclue = HTML_CLUEV (o)->align_right_list;
	     aclue != NULL;
	     aclue = cluev_next_aligned (aclue)) {
		html_object_draw (aclue,
				  p,
				  x - o->x - aclue->parent->x,
				  y - (o->y - o->ascent) - (aclue->parent->y - aclue->parent->ascent),
				  width - aclue->parent->x, height,
				  tx + aclue->parent->x,
				  ty + aclue->parent->y - aclue->parent->ascent);
	}

	if (cluev->border_style != HTML_BORDER_NONE && cluev->border_width > 0) {
		GdkColor *color;

		if (cluev->border_color) {
			html_painter_alloc_color (p, &cluev->border_color->color);
			color = &cluev->border_color->color;
		} else {
			HTMLEngine *e = html_object_engine (o, GTK_HTML (p->widget)->engine);
			color = &html_colorset_get_color_allocated (e->settings->color_set,
								    p, HTMLTextColor)->color;
		}

		html_painter_draw_border (p, color,
					  tx, ty,
					  o->width,
					  o->ascent + o->descent,
					  cluev->border_style,
					  html_painter_get_pixel_size (p) * cluev->border_width);
	}
}