changeset 1996:fc0a285c207a

[gaim-migrate @ 2006] border committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 12 Jun 2001 01:08:12 +0000
parents 815997c7d4f1
children 1c01a85c0616
files src/gtkimhtml.c
diffstat 1 files changed, 61 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkimhtml.c	Mon Jun 11 23:25:06 2001 +0000
+++ b/src/gtkimhtml.c	Tue Jun 12 01:08:12 2001 +0000
@@ -51,7 +51,7 @@
 
 gint font_sizes [] = { 80, 100, 120, 140, 200, 300, 400 };
 
-#define BORDER_SIZE 3
+#define BORDER_SIZE 2
 #define MIN_HEIGHT 20
 #define HR_HEIGHT 2
 #define TOOLTIP_TIMEOUT 500
@@ -236,8 +236,10 @@
 					 &attributes, attributes_mask);
 	gdk_window_set_user_data (widget->window, widget);
 
-	attributes.x = 0;
-	attributes.y = 0;
+	attributes.x = widget->style->klass->xthickness + BORDER_SIZE;
+	attributes.y = widget->style->klass->xthickness + BORDER_SIZE;
+	attributes.width = MAX (1, (gint) widget->allocation.width - (gint) attributes.x * 2);
+	attributes.height = MAX (1, (gint) widget->allocation.height - (gint) attributes.y * 2);
 	attributes.event_mask = gtk_widget_get_events (widget)
 				| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
 				| GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK;
@@ -250,9 +252,11 @@
 
 	gdk_window_set_cursor (widget->window, imhtml->arrow_cursor);
 
-	gdk_window_set_background (widget->window, &widget->style->base [GTK_WIDGET_STATE (widget)]);
+	gdk_window_set_background (widget->window, &widget->style->base [GTK_STATE_NORMAL]);
 	gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window,
-				   &widget->style->base [GTK_WIDGET_STATE (widget)]);
+				   &widget->style->base [GTK_STATE_NORMAL]);
+
+	gdk_window_show (GTK_LAYOUT (imhtml)->bin_window);
 }
 
 static gboolean
@@ -473,6 +477,31 @@
 }
 
 static void
+gtk_imhtml_draw_focus (GtkWidget *widget)
+{
+	GtkIMHtml *imhtml;
+	gint x = 0,
+	     y = 0,
+	     w = 0,
+	     h = 0;
+	
+	imhtml = GTK_IMHTML (widget);
+
+	if (!GTK_WIDGET_DRAWABLE (widget))
+		return;
+
+	if (GTK_WIDGET_HAS_FOCUS (widget)) {
+		gtk_paint_focus (widget->style, widget->window, NULL, widget, "text", 0, 0,
+				 widget->allocation.width - 1, widget->allocation.height - 1);
+		x = 1; y = 1; w = 2; h = 2;
+	}
+
+	gtk_paint_shadow (widget->style, widget->window, GTK_STATE_NORMAL,
+			  GTK_SHADOW_IN, NULL, widget, "text", x, y,
+			  widget->allocation.width - w, widget->allocation.height - h);
+}
+
+static void
 gtk_imhtml_draw_exposed (GtkIMHtml *imhtml)
 {
 	GList *bits;
@@ -530,6 +559,8 @@
 		}
 		bits = g_list_next (bits);
 	}
+
+	gtk_imhtml_draw_focus (GTK_WIDGET (imhtml));
 }
 
 static void
@@ -570,9 +601,6 @@
 	g_return_val_if_fail (widget != NULL, FALSE);
 	g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE);
 
-	if (GTK_WIDGET_CLASS (parent_class)->expose_event)
-		(* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
-
 	imhtml = GTK_IMHTML (widget);
 	gtk_imhtml_draw_exposed (imhtml);
 
@@ -602,8 +630,8 @@
 		imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data);
 	}
 
-	imhtml->x = BORDER_SIZE;
-	imhtml->y = BORDER_SIZE + 10;
+	imhtml->x = 0;
+	imhtml->y = 10;
 	imhtml->llheight = 0;
 	imhtml->llascent = 0;
 
@@ -643,6 +671,7 @@
 	}
 
 	gtk_layout_thaw (GTK_LAYOUT (imhtml));
+	gtk_imhtml_draw_focus (GTK_WIDGET (imhtml));
 }
 
 static void
@@ -662,12 +691,15 @@
 	widget->allocation = *allocation;
 
 	if (GTK_WIDGET_REALIZED (widget)) {
+		gint x = widget->style->klass->xthickness + BORDER_SIZE;
+		gint y = widget->style->klass->ythickness + BORDER_SIZE;
 		gdk_window_move_resize (widget->window,
 					allocation->x, allocation->y,
 					allocation->width, allocation->height);
 		gdk_window_move_resize (layout->bin_window,
-					0, 0,
-					allocation->width, allocation->height);
+					x, y,
+					MAX (1, (gint) allocation->width - x * 2),
+					MAX (1, (gint) allocation->height - y * 2));
 	}
 
 	layout->hadjustment->page_size = allocation->width;
@@ -1058,7 +1090,7 @@
 	if (!imhtml->tip_bit)
 		return FALSE;
 
-	gtk_paint_flat_box(style, imhtml->tip_window->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+	gtk_paint_flat_box (style, imhtml->tip_window->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
 			   NULL, imhtml->tip_window, "tooltip", 0, 0, -1, -1);
 
 	y = style->font->ascent + 4;
@@ -1520,6 +1552,7 @@
 
 	widget_class->realize = gtk_imhtml_realize;
 	widget_class->draw = gtk_imhtml_draw;
+	widget_class->draw_focus = gtk_imhtml_draw_focus;
 	widget_class->style_set = gtk_imhtml_style_set;
 	widget_class->expose_event  = gtk_imhtml_expose_event;
 	widget_class->size_allocate = gtk_imhtml_size_allocate;
@@ -1789,8 +1822,8 @@
 	imhtml->bits = NULL;
 	imhtml->urls = NULL;
 
-	imhtml->x = BORDER_SIZE;
-	imhtml->y = BORDER_SIZE + 10;
+	imhtml->x = 0;
+	imhtml->y = 10;
 	imhtml->llheight = 0;
 	imhtml->llascent = 0;
 	imhtml->line = NULL;
@@ -1893,8 +1926,8 @@
 
 	if (last) {
 		li = last->data;
-		if (li->x + li->width != imhtml->xsize - BORDER_SIZE)
-			li->width = imhtml->xsize - BORDER_SIZE - li->x;
+		if (li->x + li->width != imhtml->xsize)
+			li->width = imhtml->xsize - li->x;
 	}
 
 	last = imhtml->line;
@@ -1916,7 +1949,7 @@
 	g_list_free (imhtml->line);
 	imhtml->line = NULL;
 
-	imhtml->x = BORDER_SIZE;
+	imhtml->x = 0;
 	imhtml->y += imhtml->llheight;
 	imhtml->llheight = 0;
 	imhtml->llascent = 0;
@@ -2058,9 +2091,9 @@
 		height = bit->font->ascent + bit->font->descent;
 		width = gdk_string_width (bit->font, bit->text);
 
-		if ((imhtml->x != BORDER_SIZE) &&
-				((imhtml->x + width + BORDER_SIZE + BORDER_SIZE + 5) > imhtml->xsize)) {
-			gint remain = imhtml->xsize - imhtml->x - BORDER_SIZE - BORDER_SIZE - 5;
+		if ((imhtml->x != 0) &&
+				((imhtml->x + width + 5) > imhtml->xsize)) {
+			gint remain = imhtml->xsize - imhtml->x - 5;
 			while (gdk_text_width (bit->font, copy, pos) < remain) {
 				if (copy [pos] == ' ')
 					seenspace = TRUE;
@@ -2083,9 +2116,9 @@
 
 		while (pos < strlen (bit->text)) {
 			width = gdk_string_width (bit->font, copy + pos);
-			if (imhtml->x + width + BORDER_SIZE + BORDER_SIZE + 5 > imhtml->xsize) {
+			if (imhtml->x + width + 5 > imhtml->xsize) {
 				gint newpos = 0;
-				gint remain = imhtml->xsize - imhtml->x - BORDER_SIZE - BORDER_SIZE - 5;
+				gint remain = imhtml->xsize - imhtml->x - 5;
 				while (gdk_text_width (bit->font, copy + pos, newpos) < remain) {
 					if (copy [pos + newpos] == ' ')
 						seenspace = TRUE;
@@ -2122,8 +2155,8 @@
 	} else if ((bit->type == TYPE_SMILEY) || (bit->type == TYPE_IMG)) {
 		gdk_window_get_size (bit->pm, &width, &height);
 
-		if ((imhtml->x != BORDER_SIZE) &&
-				((imhtml->x + width + BORDER_SIZE + BORDER_SIZE + 5) > imhtml->xsize))
+		if ((imhtml->x != 0) &&
+				((imhtml->x + width + 5) > imhtml->xsize))
 			new_line (imhtml);
 		else
 			backwards_update (imhtml, bit, height, 0);
@@ -2140,7 +2173,7 @@
 		li = g_new0 (struct line_info, 1);
 		li->x = imhtml->x;
 		li->y = imhtml->y;
-		li->width = imhtml->xsize - BORDER_SIZE - BORDER_SIZE;
+		li->width = imhtml->xsize;
 		li->height = HR_HEIGHT * 2;
 		li->ascent = 0;
 		li->text = NULL;
@@ -3296,8 +3329,8 @@
 
 	gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window, imhtml->arrow_cursor);
 
-	imhtml->x = BORDER_SIZE;
-	imhtml->y = BORDER_SIZE + 10;
+	imhtml->x = 0;
+	imhtml->y = 10;
 	imhtml->llheight = 0;
 	imhtml->llascent = 0;
 	imhtml->line = NULL;